Module: HPCompute

Defined in:
lib/process/cloud/providers/hpcloud/compute.rb

Overview

Defined HPCloud controller.

Class Method Summary collapse

Class Method Details

.create_server(oComputeConnect, options, oUser_data, oMeta_data) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/process/cloud/providers/hpcloud/compute.rb', line 27

def self.create_server(oComputeConnect, options, oUser_data, )
  if oUser_data
    options[:user_data_encoded] = Base64.strict_encode64(oUser_data)
  end
  options[:metadata] =  if 
  server = oComputeConnect.servers.create(options)
  HPCompute.get_server(oComputeConnect, server.id) if server
end

.delete_server(oComputeConnect, server) ⇒ Object



69
70
71
# File 'lib/process/cloud/providers/hpcloud/compute.rb', line 69

def self.delete_server(oComputeConnect, server)
  oComputeConnect.servers.get(server.id).destroy
end

.get_image(oComputeConnect, oImageID) ⇒ Object



73
74
75
# File 'lib/process/cloud/providers/hpcloud/compute.rb', line 73

def self.get_image(oComputeConnect, oImageID)
  oComputeConnect.images.get(oImageID)
end

.get_server(oComputeConnect, sId) ⇒ Object



19
20
21
# File 'lib/process/cloud/providers/hpcloud/compute.rb', line 19

def self.get_server(oComputeConnect, sId)
  oComputeConnect.servers.get(sId)
end

.get_server_assigned_address(oComputeConnect, id) ⇒ Object



36
37
38
39
# File 'lib/process/cloud/providers/hpcloud/compute.rb', line 36

def self.get_server_assigned_address(oComputeConnect, id)
  addresses = oComputeConnect.addresses.all
  addresses.each { |oElem| return oElem if oElem.attributes['id'] == id }
end

.query_addresses(oComputeConnect, sQuery) ⇒ Object



23
24
25
# File 'lib/process/cloud/providers/hpcloud/compute.rb', line 23

def self.query_addresses(oComputeConnect, sQuery)
  oComputeConnect.addresses.all(sQuery)
end

.server_assign_address(oComputeConnect, server) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/process/cloud/providers/hpcloud/compute.rb', line 41

def self.server_assign_address(oComputeConnect, server)
  while server.state != 'ACTIVE'
    sleep(5)
    server = oComputeConnect.servers.get(server.id)
  end

  addresses = oComputeConnect.addresses.all
  address = nil
  # Search for an available IP
  addresses.each do |oElem|
    if oElem.fixed_ip.nil?
      address = oElem
      break
    end
  end

  if address.nil?
    # Create a new public IP to add in the pool.
    address = oComputeConnect.addresses.create
  end
  fail "No Public IP to assign to server '%s'", server.name if address.nil?
  address.server = server # associate the server
  address.reload
  # This function needs to returns a list of object.
  # This list must support the each function.
  address
end