Class: Fog::Compute::Fogdocker::Server

Inherits:
Server
  • Object
show all
Defined in:
lib/fog/fogdocker/models/compute/server.rb

Overview

fog server is a docker container

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#infoObject

Returns the value of attribute info.



10
11
12
# File 'lib/fog/fogdocker/models/compute/server.rb', line 10

def info
  @info
end

Instance Method Details

#commit(options = {}) ⇒ Object



122
123
124
# File 'lib/fog/fogdocker/models/compute/server.rb', line 122

def commit(options = {})
  service.container_commit({:id=>id}.merge(options))
end

#destroy(options = {}) ⇒ Object



126
127
128
129
# File 'lib/fog/fogdocker/models/compute/server.rb', line 126

def destroy(options = {})
  service.container_action(:id =>id, :action => :kill)
  service.container_delete(:id => id)
end

#logs(options = { :stdout => 1, :stderr => 1 }) ⇒ Object



131
132
133
# File 'lib/fog/fogdocker/models/compute/server.rb', line 131

def logs(options = { :stdout => 1, :stderr => 1 })
  service.container_action(:id =>id, :action => :logs, :options => options)
end

#macObject



102
103
104
# File 'lib/fog/fogdocker/models/compute/server.rb', line 102

def mac
  # TODO
end

#ready?Boolean

raw = “Created”=>“2014-01-16T12:42:38.081665295Z”, “Path”=>“/bin/bash”, “Args”=>[], “Config”=>{

"Hostname"=>"2ce79789656e",
"Domainname"=>"",
"User"=>"",
"Memory"=>0,
"MemorySwap"=>0,
"CpuShares"=>0,
"AttachStdin"=>true,
"AttachStdout"=>true,
"AttachStderr"=>true,
"PortSpecs"=>nil,
"ExposedPorts"=>{,
"Env": [
    "HOME=/mydir",
],

“State”=>{

"Running"=>true,
"Pid"=>1505,
"ExitCode"=>0,
"StartedAt"=>"2014-01-16T15:50:36.304626413Z",
"FinishedAt"=>"2014-01-16T15:50:36.238743161Z",
"Ghost"=>false},

“Image”=>“7c8cf65e1efa9b55f9ba8c60a970fe41595e56b894c7fdb19871bd9b276ca9d3”, “NetworkSettings”=>{

"IPAddress"=>"172.17.0.2",
"IPPrefixLen"=>16,
"Gateway"=>"172.17.42.1",
"Bridge"=>"docker0",
"PortMapping"=>nil,
"Ports"=>{}},

“SysInitPath”=>“/var/lib/docker/init/dockerinit-0.7.2”, “ResolvConfPath”=>“/etc/resolv.conf”, “HostnamePath”=>“/var/lib/docker/containers/2ce79789656e4f7474624be6496dc6d988899af30d556574389a19aade2f9650/hostname”, “HostsPath”=>“/var/lib/docker/containers/2ce79789656e4f7474624be6496dc6d988899af30d556574389a19aade2f9650/hosts”, “Name”=>“/boring_engelbart”, “Driver”=>“devicemapper”, “Volumes”=>{}, “VolumesRW”=>{}, “HostConfig”=>{

"Binds"=>nil,
"ContainerIDFile"=>"",
"LxcConf"=>[],
"Privileged"=>false,
"PortBindings"=>{},
"Links"=>nil,
"PublishAllPorts"=>false}

}

Returns:

  • (Boolean)


93
94
95
96
# File 'lib/fog/fogdocker/models/compute/server.rb', line 93

def ready?
  reload if state_running.nil?
  state_running
end

#restart(options = {}) ⇒ Object



117
118
119
120
# File 'lib/fog/fogdocker/models/compute/server.rb', line 117

def restart(options = {})
  service.container_action(:id =>id, :action => :restart!)
  reload
end

#saveObject



139
140
141
142
143
144
145
146
# File 'lib/fog/fogdocker/models/compute/server.rb', line 139

def save
  if persisted?
    service.container_update(attributes)
  else
    self.id = service.container_create(attributes)['id']
  end
  reload
end

#start(options = {}) ⇒ Object



106
107
108
109
# File 'lib/fog/fogdocker/models/compute/server.rb', line 106

def start(options = {})
  service.container_action(:id =>id, :action => :start!)
  reload
end

#stop(options = {}) ⇒ Object



111
112
113
114
115
# File 'lib/fog/fogdocker/models/compute/server.rb', line 111

def stop(options = {})
  action = options['force'] ? :kill : :stop
  service.container_action(:id =>id, :action => action)
  reload
end

#stopped?Boolean

Returns:

  • (Boolean)


98
99
100
# File 'lib/fog/fogdocker/models/compute/server.rb', line 98

def stopped?
  !ready?
end

#to_sObject



148
149
150
# File 'lib/fog/fogdocker/models/compute/server.rb', line 148

def to_s
  name
end

#top(options = {}) ⇒ Object



135
136
137
# File 'lib/fog/fogdocker/models/compute/server.rb', line 135

def top(options = {})
  service.container_action(:id =>id, :action => :top)
end