Class: Fog::Compute::Ecloud::Servers
- Inherits:
-
Ecloud::Collection
- Object
- Array
- Fog::Collection
- Ecloud::Collection
- Fog::Compute::Ecloud::Servers
- Defined in:
- lib/rackspace-fog/ecloud/models/compute/servers.rb
Instance Attribute Summary
Attributes inherited from Fog::Collection
Instance Method Summary collapse
Methods inherited from Ecloud::Collection
Methods inherited from Fog::Collection
#clear, #destroy, #initialize, #inspect, #load, model, #model, #new, #reload, #table, #to_json
Methods included from Attributes::ClassMethods
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
Methods included from Attributes::InstanceMethods
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one
Constructor Details
This class inherits a constructor from Fog::Collection
Instance Method Details
#all ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/rackspace-fog/ecloud/models/compute/servers.rb', line 12 def all data = connection.get_servers(href).body if data.keys.include?(:VirtualMachines) data = data[:VirtualMachines][:VirtualMachine] else data = data[:VirtualMachine] end load(data) end |
#create(template_uri, options) ⇒ Object
34 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 |
# File 'lib/rackspace-fog/ecloud/models/compute/servers.rb', line 34 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].is_a?(String) ? [[:ips]] : [:ips] else [:network_uri] = [:network_uri].is_a?(String) ? [[:network_uri]] : [:network_uri] [:network_uri].each do |uri| index = [:network_uri].index(uri) ip = Fog::Compute::Ecloud::IpAddresses.new(:connection => connection, :href => uri).detect { |i| i.host == nil }.name [:ips] ||= [] [:ips][index] = ip end end data = connection.virtual_machine_create_from_template( template_uri, ).body else [:uri] = href + "/action/importVirtualMachine" data = connection.virtual_machine_import( template_uri, ).body end object = new(data) object end |
#from_data(data) ⇒ Object
30 31 32 |
# File 'lib/rackspace-fog/ecloud/models/compute/servers.rb', line 30 def from_data(data) new(data) end |