Class: Fog::Compute::Ninefold::Server
Instance Attribute Summary
Attributes inherited from Model
#collection, #connection
Instance Method Summary
collapse
deprecate, self_deprecate
Methods inherited from Server
#scp, #ssh
Methods inherited from Model
#inspect, #reload, #to_json, #wait_for
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one
Constructor Details
#initialize(attributes = {}) ⇒ Server
Returns a new instance of Server.
70
71
72
73
74
75
|
# File 'lib/fog/compute/models/ninefold/server.rb', line 70
def initialize(attributes={})
merge_attributes({
:flavor_id => 105 })
super
end
|
Instance Method Details
#destroy ⇒ Object
101
102
103
104
105
|
# File 'lib/fog/compute/models/ninefold/server.rb', line 101
def destroy
requires :identity
self.jobid = (connection.destroy_virtual_machine(:id => identity))
true
end
|
#flavor ⇒ Object
107
108
109
110
|
# File 'lib/fog/compute/models/ninefold/server.rb', line 107
def flavor
requires :flavor_id
connection.flavors.get(flavor_id)
end
|
#image ⇒ Object
112
113
114
115
|
# File 'lib/fog/compute/models/ninefold/server.rb', line 112
def image
requires :image_id
connection.images.get(image_id)
end
|
#ipaddress ⇒ Object
This is temporary - we need to model nics.
78
79
80
|
# File 'lib/fog/compute/models/ninefold/server.rb', line 78
def ipaddress
nic[0] ? nic[0]['ipaddress'] : nil
end
|
#ready? ⇒ Boolean
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
# File 'lib/fog/compute/models/ninefold/server.rb', line 117
def ready?
if jobid
res = connection.query_async_job_result(:jobid => jobid)
if res['jobstatus'] == 0
false
else
merge_attributes(res['jobresult']['virtualmachine'])
true
end
else reload
true
end
end
|
#reboot ⇒ Object
82
83
84
85
86
87
|
# File 'lib/fog/compute/models/ninefold/server.rb', line 82
def reboot
requires :identity
self.jobid = (connection.reboot_virtual_machine(:id => identity))
puts "jobid: " + jobid.to_s
true
end
|
#save ⇒ Object
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
# File 'lib/fog/compute/models/ninefold/server.rb', line 134
def save
raise "Operation not supported" if self.identity
requires :flavor_id, :image_id, :zoneid
unless networkids
networks = connection.list_networks(:zoneid => zoneid)
if networks.empty?
raise "No networks. Please create one, or specify a network ID"
else
self.networkids = networks.sort {|x,y| x['id'] <=> y['id']}[0]['id']
end
end
options = {
:serviceofferingid => flavor_id,
:templateid => image_id,
:name => name,
:zoneid => zoneid,
:networkids => networkids,
:account => account,
:diskofferingid => diskofferingid,
:displayname => displayname,
:domainid => domainid,
:group => group,
:hypervisor => hypervisor,
:keypair => keypair,
:securitygroupids => securitygroupids,
:size => size,
:userdata => userdata
}.delete_if {|k,v| v.nil? || v == "" }
data = connection.deploy_virtual_machine(options)
merge_attributes(data)
true
end
|
#start ⇒ Object
89
90
91
92
93
|
# File 'lib/fog/compute/models/ninefold/server.rb', line 89
def start
requires :identity
self.jobid = (connection.start_virtual_machine(:id => identity))
true
end
|
#stop ⇒ Object
95
96
97
98
99
|
# File 'lib/fog/compute/models/ninefold/server.rb', line 95
def stop
requires :identity
self.jobid = (connection.stop_virtual_machine(:id => identity))
true
end
|