Class: Fog::Compute::Ecloud::Servers
- Inherits:
-
Ecloud::Collection
- Object
- Fog::Collection
- Ecloud::Collection
- Fog::Compute::Ecloud::Servers
- Defined in:
- lib/fog/compute/ecloud/models/servers.rb
Instance Method Summary collapse
Methods inherited from Ecloud::Collection
Instance Method Details
#all ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/fog/compute/ecloud/models/servers.rb', line 11 def all data = service.get_servers(href).body if data.keys.include?(:VirtualMachines) data = data[:VirtualMachines][:VirtualMachine] elsif data[:VirtualMachine] data = data[:VirtualMachine] else data = [] end load(data) end |
#create(template_uri, options) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/fog/compute/ecloud/models/servers.rb', line 35 def create(template_uri, ) [:cpus] ||= 1 [:memory] ||= 512 [:description] ||= "" [:tags] ||= [] if template_uri =~ /\/templates\/\d+/ [:uri] = href + "/action/createVirtualMachine" [:customization] ||= :linux [:powered_on] ||= false if [:ips] [:ips] = [*[:ips]] else [*[:network_uri]].each do |uri| index = [:network_uri].index(uri) ip = service.ip_addresses(:href => uri).detect { |i| i.host == nil && i.detected_on.nil? }.name [:ips] ||= [] [:ips][index] = ip end end data = service.virtual_machine_create_from_template(template_uri, ).body else [:uri] = href + "/action/importVirtualMachine" data = service.virtual_machine_import(template_uri, ).body end object = service.servers.new(data) object end |
#from_data(data) ⇒ Object
31 32 33 |
# File 'lib/fog/compute/ecloud/models/servers.rb', line 31 def from_data(data) new(data) end |
#get(uri) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/fog/compute/ecloud/models/servers.rb', line 23 def get(uri) data = service.get_server(uri).body new(data) rescue ServiceError => e raise e unless e.status_code == 404 nil end |