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



109
110
111
# File 'lib/fog/fogdocker/models/compute/server.rb', line 109

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

#destroy(options = {}) ⇒ Object



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

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

#macObject



89
90
91
# File 'lib/fog/fogdocker/models/compute/server.rb', line 89

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"=>{,

“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)


80
81
82
83
# File 'lib/fog/fogdocker/models/compute/server.rb', line 80

def ready?
  reload if state_running.nil?
  state_running
end

#restart(options = {}) ⇒ Object



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

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

#saveObject



118
119
120
121
122
123
124
125
# File 'lib/fog/fogdocker/models/compute/server.rb', line 118

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

#start(options = {}) ⇒ Object



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

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

#stop(options = {}) ⇒ Object



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

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

#stopped?Boolean

Returns:

  • (Boolean)


85
86
87
# File 'lib/fog/fogdocker/models/compute/server.rb', line 85

def stopped?
  !ready?
end

#to_sObject



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

def to_s
  name
end