lib/fog/terremark/models/shared/server.rb in fog-maestrodev-1.7.0.20121114190951 vs lib/fog/terremark/models/shared/server.rb in fog-maestrodev-1.8.0.20130109172219
- old
+ new
@@ -29,21 +29,21 @@
attribute :OperatingSystem
attribute :VirtualHardware
attribute :IpAddress
def reload
- merge_attributes(connection.get_vapp(id).body)
+ merge_attributes(service.get_vapp(id).body)
end
def destroy
case self.status
when VAppStatus::BEING_CREATED, VAppStatus::BEING_DEPLOYED
return false
when VAppStatus::POWERED_ON
- data = connection.power_off(self.id).body
+ data = service.power_off(self.id).body
wait_for { off? }
end
- connection.delete_vapp(self.id)
+ service.delete_vapp(self.id)
true
end
def PublicIpAddress
@PublicIpAddress ||=
@@ -52,19 +52,19 @@
end
@PublicIpAddress
end
def internet_services
- @internet_services ||= connection.internetservices.all.select {|item| item.Name == self.name}
+ @internet_services ||= service.internetservices.all.select {|item| item.Name == self.name}
end
-
+
def delete_internet_services
#Find the internet service
while (service = internet_services.pop) do
- nodes = connection.nodeservices.all(service.Id)
+ nodes = service.nodeservices.all(service.Id)
#Delete all the associated nodes
nodes.select { |item| item.destroy }
#Clear out the services
service.destroy(delete_public_ip = !(internet_services.size > 0))
end
@@ -85,43 +85,43 @@
end
def power_on(options = {})
requires :id
begin
- connection.power_on(id)
+ service.power_on(id)
rescue Excon::Errors::InternalServerError => e
#Frankly we shouldn't get here ...
raise e unless e.to_s =~ /because it is already powered on/
end
true
end
def power_off
requires :id
begin
- connection.power_off(id)
+ service.power_off(id)
rescue Excon::Errors::InternalServerError => e
#Frankly we shouldn't get here ...
raise e unless e.to_s =~ /because it is already powered off/
end
true
end
def shutdown
requires :id
begin
- connection.power_shutdown(id)
+ service.power_shutdown(id)
rescue Excon::Errors::InternalServerError => e
#Frankly we shouldn't get here ...
raise e unless e.to_s =~ /because it is already powered off/
end
true
end
def power_reset
requires :id
- connection.power_reset(id)
+ service.power_reset(id)
true
end
def graceful_restart
requires :id
@@ -135,32 +135,32 @@
internet_service_id = nil
internet_spec.each do |proto, ports|
for port in ports
if not public_ip_info
#Create the first internet service and allocate public IP
- inet_services = connection.internetservices.create({
+ inet_services = service.internetservices.create({
"Name" => self.name,
"Protocol" => proto,
"Port" => port,
})
internet_service_id = inet_services.Id
public_ip_info = inet_services.PublicIpAddress
else
#create additional services to existing Public IP
- inet_services = connection.internetservices.create({
- "public_ip_address_id" => public_ip_info["Id"],
+ inet_services = service.internetservices.create({
+ "public_ip_address_id" => public_ip_info["Id"],
"Name" => self.name,
"Protocol" => proto,
"Port" => port,
}
)
internet_service_id = inet_services.Id
end
#Create the associate node service to the server
- connection.nodeservices.create({"Name" => self.name,
+ service.nodeservices.create({"Name" => self.name,
"IpAddress" => self.IpAddress,
"Port" => port,
"InternetServiceId" => internet_service_id
})
end
@@ -170,12 +170,12 @@
def save
requires :name
if powerOn
end
- data = connection.instantiate_vapp_template(
- server_name=name,
- vapp_template=image,
+ data = service.instantiate_vapp_template(
+ server_name=name,
+ vapp_template=image,
options={
'ssh_key_fingerprint' => sshkeyFingerPrint,
'cpus' => vcpus,
'memory' => memory
})