attribute :account_id, :aliases => "account", :squash => "id" attribute :image_id, :aliases => "image", :squash => "id" attribute :flavor_id, :aliases => "server_type", :squash => "id" attribute :zone_id, :aliases => "zone", :squash => "id"
# File lib/fog/ninefold/models/compute/server.rb, line 70 def initialize(attributes={}) merge_attributes({ :flavor_id => 105, # '1CPU, 384MB, 80GB HDD' :image_id => 421 # 'XEN Basic Ubuntu 10.04 Server x64 PV r2.0' }) super end
# File lib/fog/ninefold/models/compute/server.rb, line 102 def destroy requires :identity self.jobid = extract_job_id(service.destroy_virtual_machine(:id => identity)) true end
# File lib/fog/ninefold/models/compute/server.rb, line 108 def flavor requires :flavor_id service.flavors.get(flavor_id) end
# File lib/fog/ninefold/models/compute/server.rb, line 113 def image requires :image_id service.images.get(image_id) end
This is temporary - we need to model nics.
# File lib/fog/ninefold/models/compute/server.rb, line 79 def ipaddress nic[0] ? nic[0]['ipaddress'] : nil end
# File lib/fog/ninefold/models/compute/server.rb, line 118 def ready? if jobid # we do this by polling the last job id status. res = service.query_async_job_result(:jobid => jobid) if res['jobstatus'] == 0 false else # update with new values. merge_attributes(res['jobresult']['virtualmachine']) true end else # No running job, we are ready. Refresh data. reload true end end
# File lib/fog/ninefold/models/compute/server.rb, line 83 def reboot requires :identity self.jobid = extract_job_id(service.reboot_virtual_machine(:id => identity)) puts "jobid: " + jobid.to_s true end
# File lib/fog/ninefold/models/compute/server.rb, line 135 def save raise "Operation not supported" if self.identity requires :flavor_id, :image_id, :zoneid unless networkids # No network specified, use first in this zone. networks = service.list_networks(:zoneid => zoneid) if networks.empty? raise "No networks. Please create one, or specify a network ID" else # use the network with the lowest ID - the safe default 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 = service.deploy_virtual_machine(options) merge_attributes(data) true end
Generated with the Darkfish Rdoc Generator 2.