Class: Fog::Compute::Libvirt::Servers
- Inherits:
-
Fog::Collection
- Object
- Array
- Fog::Collection
- Fog::Compute::Libvirt::Servers
- Defined in:
- lib/fog/libvirt/models/compute/servers.rb
Instance Attribute Summary
Attributes inherited from Fog::Collection
Instance Method Summary collapse
- #all(filter = nil) ⇒ Object
- #bootstrap(new_attributes = {}) ⇒ Object
- #get(uuid) ⇒ Object
-
#get_by_name(name) ⇒ Object
Retrieve the server by name.
-
#get_by_uuid(uuid) ⇒ Object
Retrieve the server by uuid.
Methods inherited from Fog::Collection
#clear, #create, #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(filter = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/fog/libvirt/models/compute/servers.rb', line 12 def all(filter=nil) data=[] filter={} if filter.nil? include_defined=filter.has_key?(:defined) ? filter[:defined] : true include_active=filter.has_key?(:active) ? filter[:active] : true unless filter.has_key?(:name) || filter.has_key?(:uuid) if include_defined connection.raw.list_defined_domains.map do |domain| data << { :raw => connection.raw.lookup_domain_by_name(domain) } end end if include_active connection.raw.list_domains.each do |domain| data << { :raw => connection.raw.lookup_domain_by_id(domain) } end end else domain=nil begin domain=self.get_by_name(filter[:name]) if filter.has_key?(:name) domain=self.get_by_uuid(filter[:uuid]) if filter.has_key?(:uuid) rescue ::Libvirt::RetrieveError return nil end unless domain.nil? data << { :raw => domain } end end load(data) end |
#bootstrap(new_attributes = {}) ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/fog/libvirt/models/compute/servers.rb', line 50 def bootstrap(new_attributes = {}) raise 'Not Implemented' # server = create(new_attributes) # server.start # server.wait_for { ready? } # server.setup(:password => server.password) # server end |
#get(uuid) ⇒ Object
46 47 48 |
# File 'lib/fog/libvirt/models/compute/servers.rb', line 46 def get(uuid) self.all(:uuid => uuid).first end |
#get_by_name(name) ⇒ Object
Retrieve the server by name
69 70 71 72 73 |
# File 'lib/fog/libvirt/models/compute/servers.rb', line 69 def get_by_name(name) server=connection.raw.lookup_domain_by_name(name) return server # new(:raw => machine) end |
#get_by_uuid(uuid) ⇒ Object
Retrieve the server by uuid
62 63 64 65 66 |
# File 'lib/fog/libvirt/models/compute/servers.rb', line 62 def get_by_uuid(uuid) server=connection.raw.lookup_domain_by_uuid(uuid) return server # new(:raw => machine) end |