Class: Fog::Compute::HPV2::Servers

Inherits:
Fog::Collection
  • Object
show all
Defined in:
lib/fog/hp/models/compute_v2/servers.rb

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Servers

Returns a new instance of Servers.



12
13
14
15
# File 'lib/fog/hp/models/compute_v2/servers.rb', line 12

def initialize(attributes)
  self.filters ||= {}
  super
end

Instance Method Details

#all(filters = filters) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fog/hp/models/compute_v2/servers.rb', line 17

def all(filters = filters)
  details = filters.delete(:details)
  self.filters = filters
  non_aliased_filters = Fog::HP.convert_aliased_attributes_to_original(self.model, filters)
  if details
    data = service.list_servers_detail(non_aliased_filters).body['servers']
  else
    data = service.list_servers(non_aliased_filters).body['servers']
  end
  load(data)
end

#bootstrap(new_attributes = {}) ⇒ Object

Creates a new server and populates ssh keys service.servers.bootstrap :name => ‘my-server’,

:flavor_id => service.flavors.first.id,
:image_id => service.images.find {|img| img.name =~ /Ubuntu/}.id,
:public_key_path => '~/.ssh/my_public_key.pub',
:private_key_path => '~/.ssh/my_private_key'


35
36
37
38
39
40
# File 'lib/fog/hp/models/compute_v2/servers.rb', line 35

def bootstrap(new_attributes = {})
  server = create(new_attributes)
  server.wait_for { ready?  && !public_ip_address.empty?}
  server.setup(:password => server.password)
  server
end

#get(server_id) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/fog/hp/models/compute_v2/servers.rb', line 42

def get(server_id)
  if server = service.get_server_details(server_id).body['server']
    new(server)
  end
rescue Fog::Compute::HPV2::NotFound
  nil
end