From 245c3452a2c8a463a5fd97ca3333c054517bf7e4 Mon Sep 17 00:00:00 2001 From: Paul Thornthwaite Date: Sat, 22 Dec 2012 23:28:53 +0000 Subject: [PATCH] [cloudstack] Updates reference to service --- lib/fog/cloudstack/models/compute/flavors.rb | 4 ++-- lib/fog/cloudstack/models/compute/image.rb | 4 ++-- lib/fog/cloudstack/models/compute/images.rb | 4 ++-- lib/fog/cloudstack/models/compute/job.rb | 4 ++-- lib/fog/cloudstack/models/compute/jobs.rb | 4 ++-- .../models/compute/security_group.rb | 6 ++--- .../models/compute/security_group_rule.rb | 10 ++++----- .../models/compute/security_group_rules.rb | 2 +- .../models/compute/security_groups.rb | 4 ++-- lib/fog/cloudstack/models/compute/server.rb | 22 +++++++++---------- lib/fog/cloudstack/models/compute/servers.rb | 4 ++-- lib/fog/cloudstack/models/compute/volume.rb | 16 +++++++------- lib/fog/cloudstack/models/compute/volumes.rb | 4 ++-- lib/fog/cloudstack/models/compute/zone.rb | 2 +- lib/fog/cloudstack/models/compute/zones.rb | 4 ++-- 15 files changed, 47 insertions(+), 47 deletions(-) diff --git a/lib/fog/cloudstack/models/compute/flavors.rb b/lib/fog/cloudstack/models/compute/flavors.rb index 1125681f9..001c587c3 100644 --- a/lib/fog/cloudstack/models/compute/flavors.rb +++ b/lib/fog/cloudstack/models/compute/flavors.rb @@ -10,12 +10,12 @@ module Fog model Fog::Compute::Cloudstack::Flavor def all - data = connection.list_service_offerings["listserviceofferingsresponse"]["serviceoffering"] || [] + data = service.list_service_offerings["listserviceofferingsresponse"]["serviceoffering"] || [] load(data) end def get(flavor_id) - if flavor = connection.list_service_offerings('id' => flavor_id)["listserviceofferingsresponse"]["serviceoffering"].first + if flavor = service.list_service_offerings('id' => flavor_id)["listserviceofferingsresponse"]["serviceoffering"].first new(flavor) end rescue Fog::Compute::Cloudstack::BadRequest diff --git a/lib/fog/cloudstack/models/compute/image.rb b/lib/fog/cloudstack/models/compute/image.rb index ceae76d9d..3cbc1efeb 100644 --- a/lib/fog/cloudstack/models/compute/image.rb +++ b/lib/fog/cloudstack/models/compute/image.rb @@ -57,13 +57,13 @@ module Fog 'virtualmachineid' => virtual_machine_id, 'volumeid' => volume_id } - data = connection.create_template(options) + data = service.create_template(options) merge_attributes(data['createtemplateresponse']) end def destroy requires :id - connection.delete_template('id' => self.id) + service.delete_template('id' => self.id) true end end # Server diff --git a/lib/fog/cloudstack/models/compute/images.rb b/lib/fog/cloudstack/models/compute/images.rb index 2b1b6848d..bc13f8682 100644 --- a/lib/fog/cloudstack/models/compute/images.rb +++ b/lib/fog/cloudstack/models/compute/images.rb @@ -12,7 +12,7 @@ module Fog def all(filters={}) options = get_filter_options(filters) - data = connection.list_templates(options)["listtemplatesresponse"]["template"] || [] + data = service.list_templates(options)["listtemplatesresponse"]["template"] || [] load(data) end @@ -20,7 +20,7 @@ module Fog filter_option = get_filter_options(filters) options = filter_option.merge('id' => template_id) - if template = connection.list_templates(options)["listtemplatesresponse"]["template"].first + if template = service.list_templates(options)["listtemplatesresponse"]["template"].first new(template) end rescue Fog::Compute::Cloudstack::BadRequest diff --git a/lib/fog/cloudstack/models/compute/job.rb b/lib/fog/cloudstack/models/compute/job.rb index 0cdbe1e32..55ea8d9e9 100644 --- a/lib/fog/cloudstack/models/compute/job.rb +++ b/lib/fog/cloudstack/models/compute/job.rb @@ -17,7 +17,7 @@ module Fog def reload requires :id - merge_attributes(connection.query_async_job_result('jobid' => self.id)['queryasyncjobresultresponse']) + merge_attributes(service.query_async_job_result('jobid' => self.id)['queryasyncjobresultresponse']) end def ready? @@ -32,7 +32,7 @@ module Fog def result if successful? && model = Fog::Compute::Cloudstack.constants.find{|c| c.to_s.downcase == self.job_result.keys.first.to_s}.to_s collection = model.gsub(/.[A-Z]/){|w| "#{w[0,1]}_#{w[1,1].downcase}"}.downcase + "s" # cheap underscorize, assume simple pluralization - connection.send(collection).new(self.job_result.values.first) + service.send(collection).new(self.job_result.values.first) else self.job_result end end diff --git a/lib/fog/cloudstack/models/compute/jobs.rb b/lib/fog/cloudstack/models/compute/jobs.rb index eec3c71b7..1fac02fbf 100644 --- a/lib/fog/cloudstack/models/compute/jobs.rb +++ b/lib/fog/cloudstack/models/compute/jobs.rb @@ -10,12 +10,12 @@ module Fog model Fog::Compute::Cloudstack::Job def all - data = connection.list_async_jobs["listasyncjobsresponse"]["asyncjobs"] || [] + data = service.list_async_jobs["listasyncjobsresponse"]["asyncjobs"] || [] load(data) end def get(job_id) - if job = connection.query_async_job_result('jobid' => job_id)["queryasyncjobresultresponse"] + if job = service.query_async_job_result('jobid' => job_id)["queryasyncjobresultresponse"] new(job) end rescue Fog::Compute::Cloudstack::BadRequest diff --git a/lib/fog/cloudstack/models/compute/security_group.rb b/lib/fog/cloudstack/models/compute/security_group.rb index b0d449028..84b6137cd 100644 --- a/lib/fog/cloudstack/models/compute/security_group.rb +++ b/lib/fog/cloudstack/models/compute/security_group.rb @@ -15,7 +15,7 @@ module Fog def destroy requires :id - connection.delete_security_group('id' => self.id) + service.delete_security_group('id' => self.id) true end @@ -37,12 +37,12 @@ module Fog 'projectid' => self.project_id, 'domainid' => self.domain_id, } - data = connection.create_security_group(options) + data = service.create_security_group(options) merge_attributes(data['createsecuritygroupresponse']['securitygroup']) end def rules - connection.security_group_rules.all("security_group_id" => self.id) + service.security_group_rules.all("security_group_id" => self.id) end end # SecurityGroup end # Cloudstack diff --git a/lib/fog/cloudstack/models/compute/security_group_rule.rb b/lib/fog/cloudstack/models/compute/security_group_rule.rb index 487a65f08..b9d498911 100644 --- a/lib/fog/cloudstack/models/compute/security_group_rule.rb +++ b/lib/fog/cloudstack/models/compute/security_group_rule.rb @@ -13,8 +13,8 @@ module Fog attribute :direction, :type => :string def destroy - data = connection.send("revoke_security_group_#{self.direction}", "id" => self.id) - job = connection.jobs.new(data["revokesecuritygroup#{self.direction}"]) + data = service.send("revoke_security_group_#{self.direction}", "id" => self.id) + job = service.jobs.new(data["revokesecuritygroup#{self.direction}"]) job.wait_for { ready? } job.successful? end @@ -26,8 +26,8 @@ module Fog def save requires :security_group_id, :cidr, :direction - data = connection.send("authorize_security_group_#{self.direction}".to_sym, params) - job = connection.jobs.new(data["authorizesecuritygroup#{self.direction}response"]) + data = service.send("authorize_security_group_#{self.direction}".to_sym, params) + job = service.jobs.new(data["authorizesecuritygroup#{self.direction}response"]) job.wait_for { ready? } # durty merge_attributes(job.result.send("#{self.direction}_rules").last) @@ -35,7 +35,7 @@ module Fog end def security_group - connection.security_groups.get(self.security_group_id) + service.security_groups.get(self.security_group_id) end def reload diff --git a/lib/fog/cloudstack/models/compute/security_group_rules.rb b/lib/fog/cloudstack/models/compute/security_group_rules.rb index 44434a075..2271c935f 100644 --- a/lib/fog/cloudstack/models/compute/security_group_rules.rb +++ b/lib/fog/cloudstack/models/compute/security_group_rules.rb @@ -12,7 +12,7 @@ module Fog attribute :security_group_id, :type => :string def security_group - connection.security_groups.get(self.security_group_id) + service.security_groups.get(self.security_group_id) end def create(attributes) diff --git a/lib/fog/cloudstack/models/compute/security_groups.rb b/lib/fog/cloudstack/models/compute/security_groups.rb index 31d7cdb48..8a22b7cef 100644 --- a/lib/fog/cloudstack/models/compute/security_groups.rb +++ b/lib/fog/cloudstack/models/compute/security_groups.rb @@ -9,12 +9,12 @@ module Fog model Fog::Compute::Cloudstack::SecurityGroup def all(options={}) - data = connection.list_security_groups(options)["listsecuritygroupsresponse"]["securitygroup"] || [] + data = service.list_security_groups(options)["listsecuritygroupsresponse"]["securitygroup"] || [] load(data) end def get(security_group_id) - if security_group = connection.list_security_groups('id' => security_group_id)["listsecuritygroupsresponse"]["securitygroup"].first + if security_group = service.list_security_groups('id' => security_group_id)["listsecuritygroupsresponse"]["securitygroup"].first new(security_group) end rescue Fog::Compute::Cloudstack::BadRequest diff --git a/lib/fog/cloudstack/models/compute/server.rb b/lib/fog/cloudstack/models/compute/server.rb index 10e2e2369..97e5d8c81 100644 --- a/lib/fog/cloudstack/models/compute/server.rb +++ b/lib/fog/cloudstack/models/compute/server.rb @@ -46,12 +46,12 @@ module Fog def destroy requires :id - data = connection.destroy_virtual_machine("id" => id) - connection.jobs.new(data["destroyvirtualmachineresponse"]) + data = service.destroy_virtual_machine("id" => id) + service.jobs.new(data["destroyvirtualmachineresponse"]) end def flavor - connection.flavors.get(self.flavor_id) + service.flavors.get(self.flavor_id) end def ready? @@ -60,8 +60,8 @@ module Fog def reboot requires :id - data = connection.reboot_virtual_machine('id' => self.id) # FIXME: does this ever fail? - connection.jobs.new(data["rebootvirtualmachineresponse"]) + data = service.reboot_virtual_machine('id' => self.id) # FIXME: does this ever fail? + service.jobs.new(data["rebootvirtualmachineresponse"]) end def security_groups=(security_groups) @@ -73,7 +73,7 @@ module Fog end def security_groups - security_group_ids.map{|id| self.connection.security_groups.get(id)} + security_group_ids.map{|id| service.security_groups.get(id)} end def save @@ -97,20 +97,20 @@ module Fog options.merge!('networkids' => network_ids) if network_ids options.merge!('securitygroupids' => security_group_ids) unless security_group_ids.empty? - data = connection.deploy_virtual_machine(options) + data = service.deploy_virtual_machine(options) merge_attributes(data['deployvirtualmachineresponse']) end def start requires :id - data = connection.start_virtual_machine("id" => self.id) - connection.jobs.new(data["startvirtualmachineresponse"]) + data = service.start_virtual_machine("id" => self.id) + service.jobs.new(data["startvirtualmachineresponse"]) end def stop(force=false) requires :id - data = connection.stop_virtual_machine("id" => self.id, "force" => force) - connection.jobs.new(data["stopvirtualmachineresponse"]) + data = service.stop_virtual_machine("id" => self.id, "force" => force) + service.jobs.new(data["stopvirtualmachineresponse"]) end end # Server end # Cloudstack diff --git a/lib/fog/cloudstack/models/compute/servers.rb b/lib/fog/cloudstack/models/compute/servers.rb index ea403d8d4..4a4a7a085 100644 --- a/lib/fog/cloudstack/models/compute/servers.rb +++ b/lib/fog/cloudstack/models/compute/servers.rb @@ -10,7 +10,7 @@ module Fog model Fog::Compute::Cloudstack::Server def all - data = connection.list_virtual_machines["listvirtualmachinesresponse"]["virtualmachine"] || [] + data = service.list_virtual_machines["listvirtualmachinesresponse"]["virtualmachine"] || [] load(data) end @@ -21,7 +21,7 @@ module Fog end def get(server_id) - if server = connection.list_virtual_machines('id' => server_id)["listvirtualmachinesresponse"]["virtualmachine"].first + if server = service.list_virtual_machines('id' => server_id)["listvirtualmachinesresponse"]["virtualmachine"].first new(server) end rescue Fog::Compute::Cloudstack::BadRequest diff --git a/lib/fog/cloudstack/models/compute/volume.rb b/lib/fog/cloudstack/models/compute/volume.rb index bfe85bc8b..a20c9e344 100644 --- a/lib/fog/cloudstack/models/compute/volume.rb +++ b/lib/fog/cloudstack/models/compute/volume.rb @@ -39,7 +39,7 @@ module Fog 'snapshotid' => snapshot_id, 'projectid' => project_id } - data = connection.create_volume(options) + data = service.create_volume(options) merge_attributes(data['createvolumeresponse']) end @@ -48,13 +48,13 @@ module Fog end def flavor - connection.disk_offerings.get(self.disk_offering_id) + service.disk_offerings.get(self.disk_offering_id) end alias disk_offering flavor def server if server_id - connection.servers.get(server_id) + service.servers.get(server_id) end end @@ -91,22 +91,22 @@ module Fog } options.merge!('deviceid' => mountpoint) if mountpoint - data = connection.attach_volume(options) + data = service.attach_volume(options) - connection.jobs.new(data["attachvolumeresponse"]) + service.jobs.new(data["attachvolumeresponse"]) end def detach requires :id - data = connection.detach_volume('id' => id) + data = service.detach_volume('id' => id) - connection.jobs.new(data["detachvolumeresponse"]) + service.jobs.new(data["detachvolumeresponse"]) end def destroy requires :id - connection.delete_volume('id' => id) + service.delete_volume('id' => id) true end end # Volume diff --git a/lib/fog/cloudstack/models/compute/volumes.rb b/lib/fog/cloudstack/models/compute/volumes.rb index c9cfe8b85..f4dd65d09 100644 --- a/lib/fog/cloudstack/models/compute/volumes.rb +++ b/lib/fog/cloudstack/models/compute/volumes.rb @@ -10,12 +10,12 @@ module Fog model Fog::Compute::Cloudstack::Volume def all - data = connection.list_volumes["listvolumesresponse"]["volume"] || [] + data = service.list_volumes["listvolumesresponse"]["volume"] || [] load(data) end def get(volume_id) - if volume = connection.list_volumes('id' => volume_id)["listvolumesresponse"]["volume"].first + if volume = service.list_volumes('id' => volume_id)["listvolumesresponse"]["volume"].first new(volume) end rescue Fog::Compute::Cloudstack::BadRequest diff --git a/lib/fog/cloudstack/models/compute/zone.rb b/lib/fog/cloudstack/models/compute/zone.rb index 147518675..2d0cf081a 100644 --- a/lib/fog/cloudstack/models/compute/zone.rb +++ b/lib/fog/cloudstack/models/compute/zone.rb @@ -28,7 +28,7 @@ module Fog 'internaldns2' => internaldns2, 'securitygroupenabled' => security_groups_enabled, } - data = connection.create_zone(options) + data = service.create_zone(options) merge_attributes(data['createzoneresponse']) end end # Zone diff --git a/lib/fog/cloudstack/models/compute/zones.rb b/lib/fog/cloudstack/models/compute/zones.rb index 38b46e1b6..108aafe33 100644 --- a/lib/fog/cloudstack/models/compute/zones.rb +++ b/lib/fog/cloudstack/models/compute/zones.rb @@ -14,12 +14,12 @@ module Fog 'templatefilter' => 'self' }.merge(filters) - data = connection.list_zones(options)["listzonesresponse"]["zone"] || [] + data = service.list_zones(options)["listzonesresponse"]["zone"] || [] load(data) end def get(zone_id) - if zone = connection.list_zones('id' => zone_id)["listzonesresponse"]["zone"].first + if zone = service.list_zones('id' => zone_id)["listzonesresponse"]["zone"].first new(zone) end rescue Fog::Compute::Cloudstack::BadRequest