Class: Fog::Compute::Fogdocker::Server
- Inherits:
-
Server
- Object
- Server
- Fog::Compute::Fogdocker::Server
- Defined in:
- lib/fog/fogdocker/models/compute/server.rb
Overview
fog server is a docker container
Instance Attribute Summary collapse
-
#info ⇒ Object
Returns the value of attribute info.
Instance Method Summary collapse
- #commit(options = {}) ⇒ Object
- #destroy(options = {}) ⇒ Object
- #logs(options = { :stdout => 1, :stderr => 1 }) ⇒ Object
- #mac ⇒ Object
-
#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} }.
- #restart(options = {}) ⇒ Object
- #save ⇒ Object
- #start(options = {}) ⇒ Object
- #stop(options = {}) ⇒ Object
- #stopped? ⇒ Boolean
- #to_s ⇒ Object
- #top(options = {}) ⇒ Object
Instance Attribute Details
#info ⇒ Object
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( = {}) service.container_commit({:id=>id}.merge()) end |
#destroy(options = {}) ⇒ Object
126 127 128 129 |
# File 'lib/fog/fogdocker/models/compute/server.rb', line 126 def destroy( = {}) 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( = { :stdout => 1, :stderr => 1 }) service.container_action(:id =>id, :action => :logs, :options => ) end |
#mac ⇒ Object
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}
}
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( = {}) service.container_action(:id =>id, :action => :restart!) reload end |
#save ⇒ Object
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( = {}) 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( = {}) action = ['force'] ? :kill : :stop service.container_action(:id =>id, :action => action) reload end |
#stopped? ⇒ Boolean
98 99 100 |
# File 'lib/fog/fogdocker/models/compute/server.rb', line 98 def stopped? !ready? end |
#to_s ⇒ Object
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( = {}) service.container_action(:id =>id, :action => :top) end |