mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[cloudstack] Updates reference to service
This commit is contained in:
parent
4c129b2b4a
commit
245c3452a2
15 changed files with 47 additions and 47 deletions
|
@ -10,12 +10,12 @@ module Fog
|
||||||
model Fog::Compute::Cloudstack::Flavor
|
model Fog::Compute::Cloudstack::Flavor
|
||||||
|
|
||||||
def all
|
def all
|
||||||
data = connection.list_service_offerings["listserviceofferingsresponse"]["serviceoffering"] || []
|
data = service.list_service_offerings["listserviceofferingsresponse"]["serviceoffering"] || []
|
||||||
load(data)
|
load(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get(flavor_id)
|
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)
|
new(flavor)
|
||||||
end
|
end
|
||||||
rescue Fog::Compute::Cloudstack::BadRequest
|
rescue Fog::Compute::Cloudstack::BadRequest
|
||||||
|
|
|
@ -57,13 +57,13 @@ module Fog
|
||||||
'virtualmachineid' => virtual_machine_id,
|
'virtualmachineid' => virtual_machine_id,
|
||||||
'volumeid' => volume_id
|
'volumeid' => volume_id
|
||||||
}
|
}
|
||||||
data = connection.create_template(options)
|
data = service.create_template(options)
|
||||||
merge_attributes(data['createtemplateresponse'])
|
merge_attributes(data['createtemplateresponse'])
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
requires :id
|
requires :id
|
||||||
connection.delete_template('id' => self.id)
|
service.delete_template('id' => self.id)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
end # Server
|
end # Server
|
||||||
|
|
|
@ -12,7 +12,7 @@ module Fog
|
||||||
def all(filters={})
|
def all(filters={})
|
||||||
options = get_filter_options(filters)
|
options = get_filter_options(filters)
|
||||||
|
|
||||||
data = connection.list_templates(options)["listtemplatesresponse"]["template"] || []
|
data = service.list_templates(options)["listtemplatesresponse"]["template"] || []
|
||||||
load(data)
|
load(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ module Fog
|
||||||
filter_option = get_filter_options(filters)
|
filter_option = get_filter_options(filters)
|
||||||
options = filter_option.merge('id' => template_id)
|
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)
|
new(template)
|
||||||
end
|
end
|
||||||
rescue Fog::Compute::Cloudstack::BadRequest
|
rescue Fog::Compute::Cloudstack::BadRequest
|
||||||
|
|
|
@ -17,7 +17,7 @@ module Fog
|
||||||
|
|
||||||
def reload
|
def reload
|
||||||
requires :id
|
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
|
end
|
||||||
|
|
||||||
def ready?
|
def ready?
|
||||||
|
@ -32,7 +32,7 @@ module Fog
|
||||||
def result
|
def result
|
||||||
if successful? && model = Fog::Compute::Cloudstack.constants.find{|c| c.to_s.downcase == self.job_result.keys.first.to_s}.to_s
|
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
|
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
|
else self.job_result
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,12 +10,12 @@ module Fog
|
||||||
model Fog::Compute::Cloudstack::Job
|
model Fog::Compute::Cloudstack::Job
|
||||||
|
|
||||||
def all
|
def all
|
||||||
data = connection.list_async_jobs["listasyncjobsresponse"]["asyncjobs"] || []
|
data = service.list_async_jobs["listasyncjobsresponse"]["asyncjobs"] || []
|
||||||
load(data)
|
load(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get(job_id)
|
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)
|
new(job)
|
||||||
end
|
end
|
||||||
rescue Fog::Compute::Cloudstack::BadRequest
|
rescue Fog::Compute::Cloudstack::BadRequest
|
||||||
|
|
|
@ -15,7 +15,7 @@ module Fog
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
requires :id
|
requires :id
|
||||||
connection.delete_security_group('id' => self.id)
|
service.delete_security_group('id' => self.id)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -37,12 +37,12 @@ module Fog
|
||||||
'projectid' => self.project_id,
|
'projectid' => self.project_id,
|
||||||
'domainid' => self.domain_id,
|
'domainid' => self.domain_id,
|
||||||
}
|
}
|
||||||
data = connection.create_security_group(options)
|
data = service.create_security_group(options)
|
||||||
merge_attributes(data['createsecuritygroupresponse']['securitygroup'])
|
merge_attributes(data['createsecuritygroupresponse']['securitygroup'])
|
||||||
end
|
end
|
||||||
|
|
||||||
def rules
|
def rules
|
||||||
connection.security_group_rules.all("security_group_id" => self.id)
|
service.security_group_rules.all("security_group_id" => self.id)
|
||||||
end
|
end
|
||||||
end # SecurityGroup
|
end # SecurityGroup
|
||||||
end # Cloudstack
|
end # Cloudstack
|
||||||
|
|
|
@ -13,8 +13,8 @@ module Fog
|
||||||
attribute :direction, :type => :string
|
attribute :direction, :type => :string
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
data = connection.send("revoke_security_group_#{self.direction}", "id" => self.id)
|
data = service.send("revoke_security_group_#{self.direction}", "id" => self.id)
|
||||||
job = connection.jobs.new(data["revokesecuritygroup#{self.direction}"])
|
job = service.jobs.new(data["revokesecuritygroup#{self.direction}"])
|
||||||
job.wait_for { ready? }
|
job.wait_for { ready? }
|
||||||
job.successful?
|
job.successful?
|
||||||
end
|
end
|
||||||
|
@ -26,8 +26,8 @@ module Fog
|
||||||
def save
|
def save
|
||||||
requires :security_group_id, :cidr, :direction
|
requires :security_group_id, :cidr, :direction
|
||||||
|
|
||||||
data = connection.send("authorize_security_group_#{self.direction}".to_sym, params)
|
data = service.send("authorize_security_group_#{self.direction}".to_sym, params)
|
||||||
job = connection.jobs.new(data["authorizesecuritygroup#{self.direction}response"])
|
job = service.jobs.new(data["authorizesecuritygroup#{self.direction}response"])
|
||||||
job.wait_for { ready? }
|
job.wait_for { ready? }
|
||||||
# durty
|
# durty
|
||||||
merge_attributes(job.result.send("#{self.direction}_rules").last)
|
merge_attributes(job.result.send("#{self.direction}_rules").last)
|
||||||
|
@ -35,7 +35,7 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def security_group
|
def security_group
|
||||||
connection.security_groups.get(self.security_group_id)
|
service.security_groups.get(self.security_group_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def reload
|
def reload
|
||||||
|
|
|
@ -12,7 +12,7 @@ module Fog
|
||||||
attribute :security_group_id, :type => :string
|
attribute :security_group_id, :type => :string
|
||||||
|
|
||||||
def security_group
|
def security_group
|
||||||
connection.security_groups.get(self.security_group_id)
|
service.security_groups.get(self.security_group_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def create(attributes)
|
def create(attributes)
|
||||||
|
|
|
@ -9,12 +9,12 @@ module Fog
|
||||||
model Fog::Compute::Cloudstack::SecurityGroup
|
model Fog::Compute::Cloudstack::SecurityGroup
|
||||||
|
|
||||||
def all(options={})
|
def all(options={})
|
||||||
data = connection.list_security_groups(options)["listsecuritygroupsresponse"]["securitygroup"] || []
|
data = service.list_security_groups(options)["listsecuritygroupsresponse"]["securitygroup"] || []
|
||||||
load(data)
|
load(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get(security_group_id)
|
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)
|
new(security_group)
|
||||||
end
|
end
|
||||||
rescue Fog::Compute::Cloudstack::BadRequest
|
rescue Fog::Compute::Cloudstack::BadRequest
|
||||||
|
|
|
@ -46,12 +46,12 @@ module Fog
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
requires :id
|
requires :id
|
||||||
data = connection.destroy_virtual_machine("id" => id)
|
data = service.destroy_virtual_machine("id" => id)
|
||||||
connection.jobs.new(data["destroyvirtualmachineresponse"])
|
service.jobs.new(data["destroyvirtualmachineresponse"])
|
||||||
end
|
end
|
||||||
|
|
||||||
def flavor
|
def flavor
|
||||||
connection.flavors.get(self.flavor_id)
|
service.flavors.get(self.flavor_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def ready?
|
def ready?
|
||||||
|
@ -60,8 +60,8 @@ module Fog
|
||||||
|
|
||||||
def reboot
|
def reboot
|
||||||
requires :id
|
requires :id
|
||||||
data = connection.reboot_virtual_machine('id' => self.id) # FIXME: does this ever fail?
|
data = service.reboot_virtual_machine('id' => self.id) # FIXME: does this ever fail?
|
||||||
connection.jobs.new(data["rebootvirtualmachineresponse"])
|
service.jobs.new(data["rebootvirtualmachineresponse"])
|
||||||
end
|
end
|
||||||
|
|
||||||
def security_groups=(security_groups)
|
def security_groups=(security_groups)
|
||||||
|
@ -73,7 +73,7 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def security_groups
|
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
|
end
|
||||||
|
|
||||||
def save
|
def save
|
||||||
|
@ -97,20 +97,20 @@ module Fog
|
||||||
options.merge!('networkids' => network_ids) if network_ids
|
options.merge!('networkids' => network_ids) if network_ids
|
||||||
options.merge!('securitygroupids' => security_group_ids) unless security_group_ids.empty?
|
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'])
|
merge_attributes(data['deployvirtualmachineresponse'])
|
||||||
end
|
end
|
||||||
|
|
||||||
def start
|
def start
|
||||||
requires :id
|
requires :id
|
||||||
data = connection.start_virtual_machine("id" => self.id)
|
data = service.start_virtual_machine("id" => self.id)
|
||||||
connection.jobs.new(data["startvirtualmachineresponse"])
|
service.jobs.new(data["startvirtualmachineresponse"])
|
||||||
end
|
end
|
||||||
|
|
||||||
def stop(force=false)
|
def stop(force=false)
|
||||||
requires :id
|
requires :id
|
||||||
data = connection.stop_virtual_machine("id" => self.id, "force" => force)
|
data = service.stop_virtual_machine("id" => self.id, "force" => force)
|
||||||
connection.jobs.new(data["stopvirtualmachineresponse"])
|
service.jobs.new(data["stopvirtualmachineresponse"])
|
||||||
end
|
end
|
||||||
end # Server
|
end # Server
|
||||||
end # Cloudstack
|
end # Cloudstack
|
||||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
||||||
model Fog::Compute::Cloudstack::Server
|
model Fog::Compute::Cloudstack::Server
|
||||||
|
|
||||||
def all
|
def all
|
||||||
data = connection.list_virtual_machines["listvirtualmachinesresponse"]["virtualmachine"] || []
|
data = service.list_virtual_machines["listvirtualmachinesresponse"]["virtualmachine"] || []
|
||||||
load(data)
|
load(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def get(server_id)
|
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)
|
new(server)
|
||||||
end
|
end
|
||||||
rescue Fog::Compute::Cloudstack::BadRequest
|
rescue Fog::Compute::Cloudstack::BadRequest
|
||||||
|
|
|
@ -39,7 +39,7 @@ module Fog
|
||||||
'snapshotid' => snapshot_id,
|
'snapshotid' => snapshot_id,
|
||||||
'projectid' => project_id
|
'projectid' => project_id
|
||||||
}
|
}
|
||||||
data = connection.create_volume(options)
|
data = service.create_volume(options)
|
||||||
merge_attributes(data['createvolumeresponse'])
|
merge_attributes(data['createvolumeresponse'])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -48,13 +48,13 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def flavor
|
def flavor
|
||||||
connection.disk_offerings.get(self.disk_offering_id)
|
service.disk_offerings.get(self.disk_offering_id)
|
||||||
end
|
end
|
||||||
alias disk_offering flavor
|
alias disk_offering flavor
|
||||||
|
|
||||||
def server
|
def server
|
||||||
if server_id
|
if server_id
|
||||||
connection.servers.get(server_id)
|
service.servers.get(server_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -91,22 +91,22 @@ module Fog
|
||||||
}
|
}
|
||||||
options.merge!('deviceid' => mountpoint) if mountpoint
|
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
|
end
|
||||||
|
|
||||||
def detach
|
def detach
|
||||||
requires :id
|
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
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
requires :id
|
requires :id
|
||||||
connection.delete_volume('id' => id)
|
service.delete_volume('id' => id)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
end # Volume
|
end # Volume
|
||||||
|
|
|
@ -10,12 +10,12 @@ module Fog
|
||||||
model Fog::Compute::Cloudstack::Volume
|
model Fog::Compute::Cloudstack::Volume
|
||||||
|
|
||||||
def all
|
def all
|
||||||
data = connection.list_volumes["listvolumesresponse"]["volume"] || []
|
data = service.list_volumes["listvolumesresponse"]["volume"] || []
|
||||||
load(data)
|
load(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get(volume_id)
|
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)
|
new(volume)
|
||||||
end
|
end
|
||||||
rescue Fog::Compute::Cloudstack::BadRequest
|
rescue Fog::Compute::Cloudstack::BadRequest
|
||||||
|
|
|
@ -28,7 +28,7 @@ module Fog
|
||||||
'internaldns2' => internaldns2,
|
'internaldns2' => internaldns2,
|
||||||
'securitygroupenabled' => security_groups_enabled,
|
'securitygroupenabled' => security_groups_enabled,
|
||||||
}
|
}
|
||||||
data = connection.create_zone(options)
|
data = service.create_zone(options)
|
||||||
merge_attributes(data['createzoneresponse'])
|
merge_attributes(data['createzoneresponse'])
|
||||||
end
|
end
|
||||||
end # Zone
|
end # Zone
|
||||||
|
|
|
@ -14,12 +14,12 @@ module Fog
|
||||||
'templatefilter' => 'self'
|
'templatefilter' => 'self'
|
||||||
}.merge(filters)
|
}.merge(filters)
|
||||||
|
|
||||||
data = connection.list_zones(options)["listzonesresponse"]["zone"] || []
|
data = service.list_zones(options)["listzonesresponse"]["zone"] || []
|
||||||
load(data)
|
load(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get(zone_id)
|
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)
|
new(zone)
|
||||||
end
|
end
|
||||||
rescue Fog::Compute::Cloudstack::BadRequest
|
rescue Fog::Compute::Cloudstack::BadRequest
|
||||||
|
|
Loading…
Reference in a new issue