Class: Fog::Compute::HPV2::Real

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/fog/hp/compute_v2.rb,
lib/fog/hp/requests/compute_v2/get_meta.rb,
lib/fog/hp/requests/compute_v2/delete_meta.rb,
lib/fog/hp/requests/compute_v2/get_address.rb,
lib/fog/hp/requests/compute_v2/list_images.rb,
lib/fog/hp/requests/compute_v2/list_limits.rb,
lib/fog/hp/requests/compute_v2/update_meta.rb,
lib/fog/hp/requests/compute_v2/create_image.rb,
lib/fog/hp/requests/compute_v2/delete_image.rb,
lib/fog/hp/requests/compute_v2/get_key_pair.rb,
lib/fog/hp/requests/compute_v2/list_flavors.rb,
lib/fog/hp/requests/compute_v2/list_servers.rb,
lib/fog/hp/requests/compute_v2/set_metadata.rb,
lib/fog/hp/requests/compute_v2/attach_volume.rb,
lib/fog/hp/requests/compute_v2/create_server.rb,
lib/fog/hp/requests/compute_v2/delete_server.rb,
lib/fog/hp/requests/compute_v2/detach_volume.rb,
lib/fog/hp/requests/compute_v2/list_metadata.rb,
lib/fog/hp/requests/compute_v2/reboot_server.rb,
lib/fog/hp/requests/compute_v2/server_action.rb,
lib/fog/hp/requests/compute_v2/update_server.rb,
lib/fog/hp/requests/compute_v2/list_addresses.rb,
lib/fog/hp/requests/compute_v2/list_key_pairs.rb,
lib/fog/hp/requests/compute_v2/rebuild_server.rb,
lib/fog/hp/requests/compute_v2/create_key_pair.rb,
lib/fog/hp/requests/compute_v2/delete_key_pair.rb,
lib/fog/hp/requests/compute_v2/get_vnc_console.rb,
lib/fog/hp/requests/compute_v2/release_address.rb,
lib/fog/hp/requests/compute_v2/update_metadata.rb,
lib/fog/hp/requests/compute_v2/allocate_address.rb,
lib/fog/hp/requests/compute_v2/associate_address.rb,
lib/fog/hp/requests/compute_v2/get_image_details.rb,
lib/fog/hp/requests/compute_v2/add_security_group.rb,
lib/fog/hp/requests/compute_v2/get_console_output.rb,
lib/fog/hp/requests/compute_v2/get_flavor_details.rb,
lib/fog/hp/requests/compute_v2/get_server_details.rb,
lib/fog/hp/requests/compute_v2/list_images_detail.rb,
lib/fog/hp/requests/compute_v2/list_flavors_detail.rb,
lib/fog/hp/requests/compute_v2/list_server_volumes.rb,
lib/fog/hp/requests/compute_v2/list_servers_detail.rb,
lib/fog/hp/requests/compute_v2/disassociate_address.rb,
lib/fog/hp/requests/compute_v2/get_windows_password.rb,
lib/fog/hp/requests/compute_v2/list_server_addresses.rb,
lib/fog/hp/requests/compute_v2/remove_security_group.rb,
lib/fog/hp/requests/compute_v2/list_availability_zones.rb,
lib/fog/hp/requests/compute_v2/create_persistent_server.rb,
lib/fog/hp/requests/compute_v2/get_server_volume_details.rb,
lib/fog/hp/requests/compute_v2/list_server_addresses_by_network.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

#decrypt_using_private_key, #encrypt_using_public_key, #extract_password_from_log

Constructor Details

#initialize(options = {}) ⇒ Real

Returns a new instance of Real.



232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# File 'lib/fog/hp/compute_v2.rb', line 232

def initialize(options={})
  # deprecate hp_account_id
  if options[:hp_account_id]
    Fog::Logger.deprecation(":hp_account_id is deprecated, please use :hp_access_key instead.")
    options[:hp_access_key] = options.delete(:hp_account_id)
  end
  @hp_access_key = options[:hp_access_key]
  unless @hp_access_key
    raise ArgumentError.new("Missing required arguments: hp_access_key. :hp_account_id is deprecated, please use :hp_access_key instead.")
  end
  @hp_secret_key = options[:hp_secret_key]
  @connection_options = options[:connection_options] || {}
  ### Set an option to use the style of authentication desired; :v1 or :v2 (default)
  auth_version = options[:hp_auth_version] || :v2
  ### Pass the service name for compute via the options hash
  options[:hp_service_type] ||= "compute"
  @hp_tenant_id = options[:hp_tenant_id]

  ### Make the authentication call
  if (auth_version == :v2)
    # Call the control services authentication
    credentials = Fog::HP.authenticate_v2(options, @connection_options)
    # the CS service catalog returns the cdn endpoint
    @hp_compute_uri = credentials[:endpoint_url]
    @credentials = credentials
  else
    # Call the legacy v1.0/v1.1 authentication
    credentials = Fog::HP.authenticate_v1(options, @connection_options)
    # the user sends in the cdn endpoint
    @hp_compute_uri = options[:hp_auth_uri]
  end

  @auth_token = credentials[:auth_token]

  uri = URI.parse(@hp_compute_uri)
  @host   = uri.host
  @path   = uri.path
  @persistent = options[:persistent] || false
  @port   = uri.port
  @scheme = uri.scheme

  @connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end

Instance Attribute Details

#credentialsObject (readonly)

Returns the value of attribute credentials.



230
231
232
# File 'lib/fog/hp/compute_v2.rb', line 230

def credentials
  @credentials
end

Instance Method Details

#add_security_group(server_id, sg_name) ⇒ Object

Add an existing security group to an existing server

Parameters

  • ‘server_id’<~String> - UUId of server

  • ‘sg_name’<~String> - Name of security group to add to the server



11
12
13
14
# File 'lib/fog/hp/requests/compute_v2/add_security_group.rb', line 11

def add_security_group(server_id, sg_name)
  body = { 'addSecurityGroup' => { 'name' => sg_name }}
  server_action(server_id, body)
end

#allocate_addressObject

Acquires a floating IP address

Note: This method will proxy the call to the Network (Quantum) service, to allocate an floating IP address from the first network available. If the network is not routable, it will throw an exception.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

    • ‘floating_ip’<~Hash> -

      • ‘id’<~String> - UUId of the Floating IP address

      • ‘ip’<~String> - Floating IP of the address

      • ‘instance_id’<~String> - Id of the associated server instance

      • ‘fixed_ip’<~String> - Fixed IP of the address



19
20
21
22
23
24
25
26
# File 'lib/fog/hp/requests/compute_v2/allocate_address.rb', line 19

def allocate_address
  request(
    :body     => nil,
    :expects  => 200,
    :method   => 'POST',
    :path     => 'os-floating-ips'
  )
end

#associate_address(server_id, ip_address) ⇒ Object

Associate a floating IP address with an existing server

Note: This method will proxy the call to the Network (Quantum) service, to associate the IP address with the first network available. If the network is not routable, it will throw an exception.

Parameters

  • ‘server_id’<~String> - UUId of server to associate IP with

  • ‘ip_address’<~String> - IP address to associate with the server



15
16
17
18
# File 'lib/fog/hp/requests/compute_v2/associate_address.rb', line 15

def associate_address(server_id, ip_address)
  body = { 'addFloatingIp' => { 'server' => server_id, 'address' => ip_address }}
  server_action(server_id, body)
end

#attach_volume(server_id, volume_id, device) ⇒ Object

Attach a block storage volume to an existing server

Parameters

  • ‘server_id’<~String> - UUId of server to attach the volume to

  • ‘volume_id’<~String> - UUId of the volume to be attached to the server

  • ‘device’<~String> - Device name that is the mount point that the volume will be attached to. e.g. /dev/sdf

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

    • ‘volumeAttachment’<~Hash>:

      • <~Hash>

        • ‘volumeId’:<~Integer> - The volume id

        • ‘device’:<~String> - The name of the device



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/fog/hp/requests/compute_v2/attach_volume.rb', line 19

def attach_volume(server_id, volume_id, device)
  data = { 'volumeAttachment' =>
           { 'volumeId' => volume_id,
             'device'   => device
           }
         }
  response = request(
    :body     => Fog::JSON.encode(data),
    :expects  => 200,
    :method   => 'POST',
    :path     => "servers/#{server_id}/os-volume_attachments"
  )
  response
end

#create_image(server_id, name, metadata = {}) ⇒ Object

Create an image from an existing server

Parameters

  • ‘server_id’<~String> - UUId of server to create the image from

  • ‘name’<~String> - Name of the image

  • ‘metadata’<~Hash> - A hash of metadata options

Returns

Does not return a response body.



14
15
16
17
18
19
20
21
# File 'lib/fog/hp/requests/compute_v2/create_image.rb', line 14

def create_image(server_id, name,  = {})
  body = { 'createImage' =>
           { 'name' => name,
             'metadata' => 
           }
         }
  server_action(server_id, body)
end

#create_key_pair(key_name, public_key = nil) ⇒ Object

Create a new keypair

Parameters

  • ‘key_name’<~String> - Name of the keypair

  • ‘public_key’<~String> - The public key for the keypair

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

    • ‘keypair’<~Hash> - The keypair data

      • ‘public_key’<~String> - The public key for the keypair

      • ‘private_key’<~String> - The private key for the keypair

      • ‘user_id’<~String> - The user id

      • ‘fingerprint’<~String> - SHA-1 digest of DER encoded private key

      • ‘name’<~String> - Name of key



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fog/hp/requests/compute_v2/create_key_pair.rb', line 20

def create_key_pair(key_name, public_key = nil)
  if public_key.nil?
    data = {
      'keypair' => {
        'name' => key_name
      }
    }
  else
    data = {
      'keypair' => {
        'name'       => key_name,
        'public_key' => public_key
      }
    }
  end

  request(
    :body     => Fog::JSON.encode(data),
    :expects  => 200,
    :method   => 'POST',
    :path     => 'os-keypairs'
  )
end

#create_persistent_server(name, flavor_id, block_device_mapping, options = {}) ⇒ Object

Create a new persistent server i.e. use a bootable volume instead of an image

Parameters

  • ‘name’<~String> - Name of server

  • ‘flavor_id’<~Integer> - Id of flavor for server

  • ‘block_device_mapping’<~Array>: Use bootable volumes to create persistent instances

    • <~Hash>:

      • ‘volume_size’<~String> - Size of the volume. Ignored, and automatically picked up from the volume

      • ‘volume_id’<~String> - Id of the bootable volume to use

      • ‘delete_on_termination’<~String> - Setting this to ‘1’ (True) means that the volume gets deleted when the instance is killed. Set it to ‘0’ to preserve the volume.

      • ‘device_name’<~String> - Block device name e.g. “vda”

  • options<~Hash>:

    • ‘availability_zone’<~String> - Availability zone where the server should be created. Defaults to ‘az2’.

    • ‘networks’<~Array> - List of network ids to be associated with the server at creation.

    • ‘metadata’<~Hash> - Up to 5 key value pairs containing 255 bytes of info

    • ‘min_count’<~Integer> - Number of servers to create. Defaults to 1.

    • ‘max_count’<~Integer> - Max. number of servers to create. Defaults to being equal to min_count.

    • ‘key_name’<~String> - Name of keypair to be used

    • ‘security_groups’<~Array> - one or more security groups to be used

    • ‘personality’<~Array>: Up to 5 files to customize server

      • ‘file’<~Hash>:

        • ‘contents’<~String> - Contents of file (10kb total of contents)

        • ‘path’<~String> - Path to file (255 bytes total of path strings)

    • ‘config_drive’<~String> - Disk accessible to the server that contains a FAT filesystem. Values true/false.

    • ‘user_data’<~String> - Base64-encoded user data string

    • ‘accessIPv4’<~String> - IPv4 IP address

    • ‘accessIPv6’<~String> - IPv6 IP address

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

    • ‘server’<~Hash>:

      • ‘addresses’<~Hash>:

        • ‘private’<~Array> - private and public fixed and floating ip addresses

      • ‘flavor’<~Hash>

        • ‘id’<~String> - id of the flavor

        • ‘links’<~Array> - array of flavor links

      • ‘id’<~Integer> - id of server

      • ‘links’<~Array> - array of server links

      • ‘hostId’<~String>

      • ‘metadata’<~Hash> - metadata

      • ‘name’<~String> - name of server

      • ‘accessIPv4’<~String> - IPv4 ip address

      • ‘accessIPv6’<~String> - IPv6 ip address

      • ‘progress’<~Integer> - progress through current status

      • ‘status’<~String> - current server status

      • ‘created’<~String> - created date time stamp

      • ‘updated’<~String> - updated date time stamp

      • ‘user_id’<~String> - user id

      • ‘tenant_id’<~String> - tenant id

      • ‘uuid’<~String> - uuid of the server

      • ‘config_drive’<~String> - config drive

      • ‘security_groups’<~Array of Hash>

        • ‘name’<~String> - name of the security group

      • ‘key_name’<~String> - name of the keypair

      • ‘adminPass’<~String> - admin password for server



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/fog/hp/requests/compute_v2/create_persistent_server.rb', line 61

def create_persistent_server(name, flavor_id, block_device_mapping, options = {})
  data = {
    'server' => {
      'flavorRef'  => flavor_id,
      'name'       => name
    }
  }

  l_options = ['availability_zone', 'metadata', 'accessIPv4', 'accessIPv6', 'key_name', 'config_drive', 'user_data']
  l_options.select{|o| options[o]}.each do |key|
    data['server'][key] = options[key]
  end

  if options['personality']
    data['server']['personality'] = []
    for file in options['personality']
      data['server']['personality'] << {
        'contents'  => Base64.encode64(file['contents']),
        'path'      => file['path']
      }
    end
  end
  min_count = options['min_count'] || 1
  max_count = options['max_count'] || min_count
  data['server']['min_count'] = min_count
  data['server']['max_count'] = max_count

  if options['security_groups']
    data['server']['security_groups'] = []
    for sg in options['security_groups']
      data['server']['security_groups'] << {
        'name' => sg
      }
    end
  end

  # should be in the form of an array
  # [{ 'volume_size' => '', 'volume_id' => "111111", 'delete_on_termination' => '0', 'device_name' => 'vda'}]
  if block_device_mapping
    data['server']['block_device_mapping'] = block_device_mapping
  end

  # add capability to specify a network id while creating a server
  if options['networks']
    data['server']['networks'] = []
    for net_id in options['networks']
      data['server']['networks'] << {
        'uuid' => net_id
      }
    end
  end

  request(
    :body     => Fog::JSON.encode(data),
    :expects  => 202,
    :method   => 'POST',
    :path     => 'os-volumes_boot'
  )
end

#create_server(name, flavor_id, image_id, options = {}) ⇒ Object

Create a new server

Parameters

  • ‘name’<~String> - Name of server

  • ‘flavor_id’<~String> - UUId of flavor for server

  • ‘image_id’<~String> - UUId of image for server. If block_device_mapping is passed, this is ignored.

  • options<~Hash>:

    • ‘availability_zone’<~String> - Availability zone where the server should be created. Defaults to ‘az2’.

    • ‘networks’<~Array> - List of network ids to be associated with the server at creation.

    • ‘metadata’<~Hash> - Up to 5 key value pairs containing 255 bytes of info

    • ‘min_count’<~Integer> - Number of servers to create. Defaults to 1.

    • ‘max_count’<~Integer> - Max. number of servers to create. Defaults to being equal to min_count.

    • ‘key_name’<~String> - Name of keypair to be used

    • ‘security_groups’<~Array> - one or more security groups to be used

    • ‘personality’<~Array>: Up to 5 files to customize server

      • ‘file’<~Hash>:

        • ‘contents’<~String> - Contents of file (10kb total of contents)

        • ‘path’<~String> - Path to file (255 bytes total of path strings)

    • ‘config_drive’<~String> - Disk accessible to the server that contains a FAT filesystem. Values true/false.

    • ‘user_data’<~String> - Base64-encoded user data string

    • ‘accessIPv4’<~String> - IPv4 IP address

    • ‘accessIPv6’<~String> - IPv6 IP address

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

    • ‘server’<~Hash>:

      • ‘addresses’<~Hash>:

        • ‘private’<~Array> - private and public fixed and floating ip addresses

      • ‘flavor’<~Hash>

        • ‘id’<~String> - id of the flavor

        • ‘links’<~Array> - array of flavor links

      • ‘id’<~Integer> - id of server

      • ‘image’<~Hash> - id of image used to boot server

        • ‘id’<~String> - id of the image

        • ‘links’<~Array> - array of image links

      • ‘links’<~Array> - array of server links

      • ‘hostId’<~String>

      • ‘metadata’<~Hash> - metadata

      • ‘name’<~String> - name of server

      • ‘accessIPv4’<~String> - IPv4 ip address

      • ‘accessIPv6’<~String> - IPv6 ip address

      • ‘progress’<~Integer> - progress through current status

      • ‘status’<~String> - current server status

      • ‘created’<~String> - created date time stamp

      • ‘updated’<~String> - updated date time stamp

      • ‘user_id’<~String> - user id

      • ‘tenant_id’<~String> - tenant id

      • ‘uuid’<~String> - uuid of the server

      • ‘config_drive’<~String> - config drive

      • ‘security_groups’<~Array of Hash>

        • ‘name’<~String> - name of the security group

      • ‘key_name’<~String> - name of the keypair

      • ‘adminPass’<~String> - admin password for server



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/fog/hp/requests/compute_v2/create_server.rb', line 59

def create_server(name, flavor_id, image_id, options = {})
  data = {
    'server' => {
      'flavorRef'  => flavor_id,
      'imageRef'   => image_id,
      'name'       => name
    }
  }
  l_options = ['availability_zone', 'metadata', 'accessIPv4', 'accessIPv6', 'key_name', 'config_drive', 'user_data']
  l_options.select{|o| options[o]}.each do |key|
    data['server'][key] = options[key]
  end

  if options['personality']
    data['server']['personality'] = []
    for file in options['personality']
      data['server']['personality'] << {
        'contents'  => Base64.encode64(file['contents']),
        'path'      => file['path']
      }
    end
  end
  min_count = options['min_count'] || 1
  max_count = options['max_count'] || min_count
  data['server']['min_count'] = min_count
  data['server']['max_count'] = max_count

  if options['security_groups']
    data['server']['security_groups'] = []
    for sg in options['security_groups']
      data['server']['security_groups'] << {
        'name' => sg
      }
    end
  end

  # add capability to specify a network id while creating a server
  if options['networks']
    data['server']['networks'] = []
    for net_id in options['networks']
      data['server']['networks'] << {
        'uuid' => net_id
      }
    end
  end

  request(
    :body     => Fog::JSON.encode(data),
    :expects  => 202,
    :method   => 'POST',
    :path     => 'servers'
  )
end

#delete_image(image_id) ⇒ Object

Delete an image

Parameters

  • ‘image_id’<~String> - UUId of image to delete



10
11
12
13
14
15
16
# File 'lib/fog/hp/requests/compute_v2/delete_image.rb', line 10

def delete_image(image_id)
  request(
    :expects  => 204,
    :method   => 'DELETE',
    :path     => "images/#{image_id}"
  )
end

#delete_key_pair(key_name) ⇒ Object

Delete a keypair

Parameters

  • ‘key_name’<~String> - Name of the keypair to delete



10
11
12
13
14
15
16
# File 'lib/fog/hp/requests/compute_v2/delete_key_pair.rb', line 10

def delete_key_pair(key_name)
  request(
    :expects  => 202,
    :method   => 'DELETE',
    :path     => "os-keypairs/#{key_name}"
  )
end

#delete_meta(collection_name, parent_id, key) ⇒ Object

Delete metadata item for specific collections

Parameters

  • ‘collection_name’<~String> - name of the collection i.e. images, servers for which the metadata is intented.

  • ‘parent_id’<~Integer> - id of the collection i.e. image_id or the server_id

  • ‘key’<~String> - key for the metadata item

Returns

  • response<~Excon::Response>:

    • body: Empty response body



16
17
18
19
20
21
22
# File 'lib/fog/hp/requests/compute_v2/delete_meta.rb', line 16

def delete_meta(collection_name, parent_id, key)
  request(
    :expects  => 204,
    :method   => 'DELETE',
    :path     => "#{collection_name}/#{parent_id}/metadata/#{key}"
  )
end

#delete_server(server_id) ⇒ Object

Delete an existing server

Parameters

  • ‘server_id’<~String> - UUId of the server to delete



10
11
12
13
14
15
16
# File 'lib/fog/hp/requests/compute_v2/delete_server.rb', line 10

def delete_server(server_id)
  request(
    :expects => 204,
    :method => 'DELETE',
    :path   => "servers/#{server_id}"
  )
end

#detach_volume(server_id, volume_id) ⇒ Object

Detach a block storage volume from an existing server

Parameters

  • ‘server_id’<~String> - UUId of server to attach the volume to

  • ‘volume_id’<~String> - UUId of the volume to be attached to the server

Returns

  • response<~Excon::Response>:

    • body: Empty



14
15
16
17
18
19
20
21
# File 'lib/fog/hp/requests/compute_v2/detach_volume.rb', line 14

def detach_volume(server_id, volume_id)
  response = request(
    :expects  => 202,
    :method   => 'DELETE',
    :path     => "servers/#{server_id}/os-volume_attachments/#{volume_id}"
  )
  response
end

#disassociate_address(server_id, ip_address) ⇒ Object

Disassociate a floating IP address with an existing server

Parameters

  • ‘server_id’<~String> - UUId of server to associate IP address with

  • ‘ip_address’<~String> - IP address to associate with the server



11
12
13
14
# File 'lib/fog/hp/requests/compute_v2/disassociate_address.rb', line 11

def disassociate_address(server_id, ip_address)
  body = { 'removeFloatingIp' => { 'server' => server_id, 'address' => ip_address }}
  server_action(server_id, body)
end

#get_address(address_id) ⇒ Object

Get details about an existing floating IP address

Note: This method will proxy the call to the Network (Quantum) service, to get details about an existing floating IP address.

Parameters

  • ‘address_id’<~String> - UUId of floating IP address get details for

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘floating_ip’<~Hash> -

        • ‘id’<~String> - UUId of the Floating IP address

        • ‘ip’<~String> - Floating IP of the address

        • ‘instance_id’<~String> - Id of the associated server instance

        • ‘fixed_ip’<~String> - Fixed IP of the address



21
22
23
24
25
26
27
# File 'lib/fog/hp/requests/compute_v2/get_address.rb', line 21

def get_address(address_id)
  request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "os-floating-ips/#{address_id}"
  )
end

#get_console_output(server_id, num_lines) ⇒ Object

Retrieve console output for specified instance

Parameters

  • ‘server_id’<~Stribng> - UUId of instance to get console output from

  • ‘num_lines’<~Integer> - Number of lines of console output from the end

Returns

# * response<~Excon::Response>:

* body<~Hash>:
  * 'output'<~String> - Console output


15
16
17
18
# File 'lib/fog/hp/requests/compute_v2/get_console_output.rb', line 15

def get_console_output(server_id, num_lines)
  body = { 'os-getConsoleOutput' => { 'length' => num_lines }}
  server_action(server_id, body, 200)
end

#get_flavor_details(flavor_id) ⇒ Object

Get details for flavor by id

Parameters

  • ‘flavor_id’<~String> - UUId of the flavor to get details for

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘id’<~String> - UUId of the flavor

      • ‘name’<~String> - Name of the flavor

      • ‘ram’<~Integer> - Amount of ram for the flavor

      • ‘vcpus’<~Integer> - Virtual CPUs for the flavor

      • ‘disk’<~Integer> - Amount of diskspace for the flavor

      • ‘OS-FLV-EXT-DATA:ephemeral’<~Integer> - Amount of ephemeral diskspace for the flavor

      • ‘links’<~Array> - array of flavor links



20
21
22
23
24
25
26
# File 'lib/fog/hp/requests/compute_v2/get_flavor_details.rb', line 20

def get_flavor_details(flavor_id)
  request(
    :expects  => [200, 203],
    :method   => 'GET',
    :path     => "flavors/#{flavor_id}"
  )
end

#get_image_details(image_id) ⇒ Object

Get details for image by id

Parameters

  • ‘image_id’<~String> - UUId of image to get details for

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

    • ‘image’<~Hash>:

      • ‘id’<~String> - UUId of the image

      • ‘name’<~String> - Name of the image

      • ‘links’<~Array> - array of image links

      • ‘server’<~Hash>

        • ‘id’<~String> - UUId of server from which this snapshot image was created

        • ‘links’<~Array> - array of server links

      • ‘updated’<~String> - Last update timestamp for image

      • ‘created’<~String> - Creation timestamp for image

      • ‘minDisk’<~String> - Min. amount of diskspace for the image

      • ‘minRam’<~String> - Min. amount of ram for the image

      • ‘progress’<~Integer> - Progress through current status

      • ‘metadata’<~Hash> - metadata for the image

      • ‘status’<~String> - Status of image



27
28
29
30
31
32
33
# File 'lib/fog/hp/requests/compute_v2/get_image_details.rb', line 27

def get_image_details(image_id)
  request(
    :expects  => [200, 203],
    :method   => 'GET',
    :path     => "images/#{image_id}"
  )
end

#get_key_pair(key_name) ⇒ Object

Get details about a key pair

Parameters

  • ‘key_name’<~String> - Name of the keypair to get

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

    • ‘keypair’<~Hash>:

      • ‘public_key’<~String> - Public portion of the key

      • ‘name’<~String> - Name of the key

      • ‘fingerprint’<~String> - Fingerprint of the key



17
18
19
20
21
22
23
# File 'lib/fog/hp/requests/compute_v2/get_key_pair.rb', line 17

def get_key_pair(key_name)
  request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "os-keypairs/#{key_name}"
  )
end

#get_meta(collection_name, parent_id, key) ⇒ Object

Get metadata item for specific collections

Parameters

  • ‘collection_name’<~String> - name of the collection i.e. images, servers for which the metadata is intended.

  • ‘parent_id’<~Integer> - id of the collection i.e. image_id or the server_id

  • ‘key’<~String> - key for the metadata item

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘meta’<~Hash>: hash of key/value pair for the metadata item found



17
18
19
20
21
22
23
# File 'lib/fog/hp/requests/compute_v2/get_meta.rb', line 17

def get_meta(collection_name, parent_id, key)
  request(
    :expects  => [200, 203],
    :method   => 'GET',
    :path     => "#{collection_name}/#{parent_id}/metadata/#{key}"
  )
end

#get_server_details(server_id) ⇒ Object

Get details about a server

Parameters

  • ‘server_id’<~String> - UUId of the server to get details for

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

    • ‘server’<~Hash>:

      • ‘hostId’<~String>

      • ‘addresses’<~Hash>:

        • <network_name><~Array> - user defined network name

          • ‘version’<~Array> - IP version, 4 or 6

          • ‘addr’<~Array> - public or private ip address

      • ‘links’<~Array> - array of server links

      • ‘key_name’<~String> - Name of the keypair associated with the server

      • ‘image’<~Hash>

        • ‘id’<~String> - UUId of image used to create the server

        • ‘links’<~Array> - array of image links

      • ‘flavor’<~Hash>

        • ‘id’<~String> - UUId of flavor used to create the server

        • ‘links’<~Array> - array of flavor links

      • ‘id’<~String> - UUId of the server

      • ‘security_groups’<~Array>

        • ‘name’<~String> - Name of the security group associated with the server

      • ‘user_id’<~String> - Id of the user that created the server

      • ‘name<~String> - Name of the server

      • ‘tenant_id’<~String> - Id of the tenant that created the server

      • ‘accessIPv4’<~String> - IPv4 IP address

      • ‘accessIPv6’<~String> - IPv6 IP address

      • ‘progress’<~Integer> - Progress through current status

      • ‘created’<~String> - UTC datetime for when the server was created

      • ‘updated’<~String> - UTC datetime for when the server was last updated

      • ‘status’<~String> - Current server status

      • ‘config_drive’<~String> - Config drive setting, ‘true’ or ‘false’

      • ‘metadata’<~Hash> - metadata

      • ‘OS-EXT-AZ:availability_zone’<~String> - Availability zone where the server is created. e.g. ‘az1’, ‘az2’ etc.

      • ‘OS-EXT-STS:power_state’<~String> - Extended power state, either 0 or 1

      • ‘OS-EXT-STS:task_state’<~String> - Extended task state

      • ‘OS-EXT-STS:vm_state’<~String> - Extended vm state



45
46
47
48
49
50
51
# File 'lib/fog/hp/requests/compute_v2/get_server_details.rb', line 45

def get_server_details(server_id)
  request(
    :expects  => [200, 203],
    :method   => 'GET',
    :path     => "servers/#{server_id}"
  )
end

#get_server_volume_details(server_id, volume_id) ⇒ Object

Get a block storage volume attachments for an existing server

Parameters

  • ‘server_id’<~String> - UUId of server to get attached volumes for

  • ‘volume_id’<~String> - UUId of the volume attached to the server

Returns

  • response<~Excon::Response>:

    • body: Empty



14
15
16
17
18
19
20
21
# File 'lib/fog/hp/requests/compute_v2/get_server_volume_details.rb', line 14

def get_server_volume_details(server_id, volume_id)
  response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "servers/#{server_id}/os-volume_attachments/#{volume_id}"
  )
  response
end

#get_vnc_console(server_id, type = 'novnc') ⇒ Object

Retrieve VNC console for the specified instance

Parameters

  • ‘server_id’<~String> - UUId of instance to get console output from

  • ‘type’<~String> - Type of the vnc console, defaults to ‘novnc’

Returns

# * response<~Excon::Response>:

* body<~Hash>:
  * 'console'
    * 'type'<~String> - Type of the vnc console
    * 'url'<~String> - Url to access a VNC console of a server from a browser


17
18
19
20
# File 'lib/fog/hp/requests/compute_v2/get_vnc_console.rb', line 17

def get_vnc_console(server_id, type='novnc')
  body = { 'os-getVNCConsole' => { 'type' => type }}
  server_action(server_id, body, 200)
end

#get_windows_password(server_id) ⇒ Object

Retrieves the encrypted administrator password for a server running Windows.

Parameters

  • ‘server_id’<~String> - UUId of the server

Returns

  • ‘password_data’<~string>: Encrypted password for a server running Windows



13
14
15
16
17
18
# File 'lib/fog/hp/requests/compute_v2/get_windows_password.rb', line 13

def get_windows_password(server_id)
  # get console output assuming that the server is already in active state
  log_output = get_console_output(server_id, 400).body['output']
  # decrypt the log output to extract the encrypted, base64-encoded password
  encrypted_password = extract_password_from_log(log_output)
end

#list_addressesObject

List all Floating IP addresses

Note: This method will proxy the call to the Network (Quantum) service, to list all floating IP addresses.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘floating_ips’<~Array> -

        • ‘id’<~String> - UUId of the Floating IP address

        • ‘ip’<~String> - Floating IP of the address

        • ‘instance_id’<~String> - Id of the associated server instance

        • ‘fixed_ip’<~String> - Fixed IP of the address



18
19
20
21
22
23
24
# File 'lib/fog/hp/requests/compute_v2/list_addresses.rb', line 18

def list_addresses
  request(
    :expects  => 200,
    :method   => 'GET',
    :path     => 'os-floating-ips'
  )
end

#list_availability_zonesObject

List all availability zones

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

    • ‘availabilityZoneInfo’<~Array>

      • ‘zoneName’<~String> - Name of the availability zone i.e. az1, az2, az3 etc.

      • ‘hosts’<~String> - List of hosts

      • ‘zoneState’<~Hash>

        • ‘available’<~Boolean> - State of the availability zone, i.e. true/false



15
16
17
18
19
20
21
# File 'lib/fog/hp/requests/compute_v2/list_availability_zones.rb', line 15

def list_availability_zones
  request(
    :expects  => 200,
    :method   => 'GET',
    :path     => 'os-availability-zone'
  )
end

#list_flavors(options = {}) ⇒ Object

List all flavors (IDs and names only)

Parameters

  • options<~Hash>: filter options

    • ‘minDisk’<~Integer> - Filters the list of flavors to those with the specified minimum number of gigabytes of disk storage.

    • ‘minRam’<~Integer> - Filters the list of flavors to those with the specified minimum amount of RAM in megabytes.

    • ‘marker’<~String> - The ID of the last item in the previous list

    • ‘limit’<~Integer> - Sets the page size

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘id’<~String> - UUId of the flavor

      • ‘name’<~String> - Name of the flavor

      • ‘links’<~Array> - array of flavor links



20
21
22
23
24
25
26
27
# File 'lib/fog/hp/requests/compute_v2/list_flavors.rb', line 20

def list_flavors(options = {})
  request(
    :expects  => [200, 203],
    :method   => 'GET',
    :path     => 'flavors',
    :query    => options
  )
end

#list_flavors_detail(options = {}) ⇒ Object

List all flavors

Parameters

  • options<~Hash>: filter options

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘id’<~String> - UUId of the flavor

      • ‘name’<~String> - Name of the flavor

      • ‘ram’<~Integer> - Amount of ram for the flavor

      • ‘vcpus’<~Integer> - Virtual CPUs for the flavor

      • ‘disk’<~Integer> - Amount of diskspace for the flavor

      • ‘OS-FLV-EXT-DATA:ephemeral’<~Integer> - Amount of ephemeral diskspace for the flavor

      • ‘links’<~Array> - array of flavor links



20
21
22
23
24
25
26
27
# File 'lib/fog/hp/requests/compute_v2/list_flavors_detail.rb', line 20

def list_flavors_detail(options = {})
  request(
    :expects  => [200, 203],
    :method   => 'GET',
    :path     => 'flavors/detail',
    :query    => options
  )
end

#list_images(options = {}) ⇒ Object

List all images (IDs and names only)

Parameters

  • options<~Hash>: filter options

    • ‘name’<~String> - Filters by the name of the image

    • ‘status’<~String> - Filters by the status of the image

    • ‘server’<~String> - Filters by the UUId of the server

    • ‘marker’<~String> - The ID of the last item in the previous list

    • ‘limit’<~Integer> - Sets the page size

    • ‘changes-since’<~DateTime> - Filters by the changes-since time. The list contains servers that have been deleted since the changes-since time.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

    • ‘images’<~Array>:

      • ‘id’<~String> - UUId of the image

      • ‘name’<~String> - Name of the image

      • ‘links’<~Array> - array of image links



23
24
25
26
27
28
29
30
# File 'lib/fog/hp/requests/compute_v2/list_images.rb', line 23

def list_images(options = {})
  request(
    :expects  => [200, 203],
    :method   => 'GET',
    :path     => 'images',
    :query    => options
  )
end

#list_images_detail(options = {}) ⇒ Object

List all images

Parameters

  • options<~Hash>: filter options

    • ‘name’<~String> - Filters by the name of the image

    • ‘status’<~String> - Filters by the status of the image

    • ‘server’<~String> - Filters by the UUId of the server

    • ‘marker’<~String> - The ID of the last item in the previous list

    • ‘limit’<~Integer> - Sets the page size

    • ‘changes-since’<~DateTime> - Filters by the changes-since time. The list contains servers that have been deleted since the changes-since time.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

    • ‘images’<~Array>:

      • ‘id’<~String> - UUId of the image

      • ‘name’<~String> - Name of the image

      • ‘links’<~Array> - array of image links

      • ‘server’<~Hash>

        • ‘id’<~String> - UUId of server from which this snapshot image was created

        • ‘links’<~Array> - array of server links

      • ‘updated’<~String> - Last update timestamp for image

      • ‘created’<~String> - Creation timestamp for image

      • ‘minDisk’<~String> - Min. amount of diskspace for the image

      • ‘minRam’<~String> - Min. amount of ram for the image

      • ‘progress’<~Integer> - Progress through current status

      • ‘metadata’<~Hash> - metadata for the image

      • ‘status’<~String> - Status of image



33
34
35
36
37
38
39
40
# File 'lib/fog/hp/requests/compute_v2/list_images_detail.rb', line 33

def list_images_detail(options = {})
  request(
    :expects  => [200, 203],
    :method   => 'GET',
    :path     => 'images/detail',
    :query    => options
  )
end

#list_key_pairsObject

List all key pairs

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

    • ‘keypairs’<~Array>:

      • ‘keypair’<~Hash>:

        • ‘public_key’<~String> - Public portion of the key

        • ‘name’<~String> - Name of the key

        • ‘fingerprint’<~String> - Fingerprint of the key



15
16
17
18
19
20
21
# File 'lib/fog/hp/requests/compute_v2/list_key_pairs.rb', line 15

def list_key_pairs
  request(
    :expects  => [200, 203],
    :method   => 'GET',
    :path     => 'os-keypairs'
  )
end

#list_limitsObject

List the limits on resources on a per tenant basis (absolute and rate limits)

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

    • ‘limits’<~Array>:

      • ‘absolute’<~Hash> - List of absolute limits

        • ‘maxImageMeta’<~String> - the number of image metadata items allowed per instance

        • ‘maxPersonality’<~String> - the number of injected files that can be specified when a new VM instance is created

        • ‘maxPersonalitySize’<~String> - the maximum size of an injected file

        • ‘maxSecurityGroupRules’<~String> - the maximum number of rules in a security group

        • ‘maxSecurityGroups’<~String> - the maximum number of security groups

        • ‘maxTotalKeypairs’<~String> - the maximum number of key pairs

        • ‘maxServerMeta’<~String> - the number of server metadata items allowed per instance

        • ‘maxTotalInstances’<~String> - the maximum number of VM instances that can be created for the tenant

        • ‘maxTotalRAMSize’<~String> - the maximum number of megabytes of instance RAM for the tenant

        • ‘maxTotalCores’<~String> - the maximum number of cores per tenant

        • ‘maxTotalFloatingIps’<~String> - the maximum number of floating ips per tenant

        • ‘totalRAMUsed’<~String> - the total RAM used per tenant

        • ‘totalInstancesUsed’<~String> - the total number of instances used per tenant

        • ‘totalFloatingIpsUsed’<~String> - the total number of floating ips used per tenant

        • ‘totalSecurityGroupsUsed’<~String> - the total number of instances used per tenant

        • ‘totalCoresUsed’<~String> - the total number of cores used per tenant

      • ‘rate’<~Array> - List of rate limits on requests

        • ‘regex’<~String> - pattern to match the suburi

        • ‘uri’<~String> - pattern to mathc the uri

        • ‘limit’<~Array>

        • ‘next-available’<~String> - next available time for request

        • ‘remaining’<~String> - the number of remaining requests

        • ‘unit’<~String> - the unit of time for the limit

        • ‘value’<~String> - the value of the limit

        • ‘verb’<~String> - the http request the limit applies to



37
38
39
40
41
42
43
# File 'lib/fog/hp/requests/compute_v2/list_limits.rb', line 37

def list_limits
  request(
    :expects  => [200, 203],
    :method   => 'GET',
    :path     => 'limits'
  )
end

#list_metadata(collection_name, parent_id) ⇒ Object

List metadata for specific collections

Parameters

  • ‘collection_name’<~String> - name of the collection i.e. images, servers for which the metadata is intended.

  • ‘parent_id’<~Integer> - id of the collection i.e. image_id or the server_id

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘metadata’<~Hash>: hash of key/value pair for the metadata items found



16
17
18
19
20
21
22
# File 'lib/fog/hp/requests/compute_v2/list_metadata.rb', line 16

def (collection_name, parent_id)
  request(
    :expects  => [200, 203],
    :method   => 'GET',
    :path     => "/#{collection_name}/#{parent_id}/metadata"
  )
end

#list_server_addresses(server_id) ⇒ Object

List all server addresses

Parameters

  • ‘server_id’<~String> - UUId of server to list addresses for

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

    • ‘addresses’<~Hash>:

      • ‘custom’:<~Array> - IP addresses for the server. The network name can change based on setup.



15
16
17
18
19
20
21
# File 'lib/fog/hp/requests/compute_v2/list_server_addresses.rb', line 15

def list_server_addresses(server_id)
  request(
    :expects  => [200,203],
    :method   => 'GET',
    :path     => "servers/#{server_id}/ips"
  )
end

#list_server_addresses_by_network(server_id, network_name) ⇒ Object

List private server addresses

Parameters

  • ‘server_id’<~String> - UUId of server to list addresses for

  • ‘network_name’<~String> - Name of the network to list addresses for

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘custom’<~Array> - IP addresses for the server, for the network. The network name can change based on setup.

        • ‘version’<~Integer> - IP version, 4 or 6

        • ‘addr’<~String> - IP address



17
18
19
20
21
22
23
# File 'lib/fog/hp/requests/compute_v2/list_server_addresses_by_network.rb', line 17

def list_server_addresses_by_network(server_id, network_name)
  request(
    :expects  => [200,203],
    :method   => 'GET',
    :path     => "servers/#{server_id}/ips/#{Fog::HP.escape(network_name)}"
  )
end

#list_server_volumes(server_id) ⇒ Object

List all volumes attached to a server

Parameters

  • ‘server_id’<~String> - UUId of server to list attached volumes for

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

    • ‘volumeAttachments’<~Array>:

      • <~Hash>

        • ‘device’:<~String> - The name of the device

        • ‘serverId’:<~String> - UUId of the server to which this volume is attached to

        • ‘id’:<~String> - UUId of the volume

        • ‘volumeId’:<~String> - UUId of the volume



19
20
21
22
23
24
25
26
# File 'lib/fog/hp/requests/compute_v2/list_server_volumes.rb', line 19

def list_server_volumes(server_id)
  response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "servers/#{server_id}/os-volume_attachments"
  )
  response
end

#list_servers(options = {}) ⇒ Object

List all servers (IDs and names only)

Parameters

  • options<~Hash>: filter options

    • ‘name’<~String> - Filters by the name of the server

    • ‘image’<~String> - Filters by the UUId of the image

    • ‘flavor’<~String> - Filters by the UUId of the flavor

    • ‘status’<~String> - Filters by the status of the server

    • ‘marker’<~String> - The ID of the last item in the previous list

    • ‘limit’<~Integer> - Sets the page size

    • ‘changes-since’<~DateTime> - Filters by the changes-since time. The list contains servers that have been deleted since the changes-since time.

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

    • ‘servers’<~Array>:

      • ‘id’<~Integer> - UUId of server

      • ‘name’<~String> - Name of server

      • ‘links’<~Array> - array of server links



24
25
26
27
28
29
30
31
# File 'lib/fog/hp/requests/compute_v2/list_servers.rb', line 24

def list_servers(options = {})
  request(
    :expects  => [200, 203],
    :method   => 'GET',
    :path     => 'servers',
    :query    => options
  )
end

#list_servers_detail(options = {}) ⇒ Object

List all servers details

Parameters

  • options<~Hash>: filter options

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

    • ‘servers’<~Array>:

      • ‘hostId’<~String>

      • ‘addresses’<~Hash>:

        • <network_name><~Array> - user defined network name

          • ‘version’<~Array> - IP version, 4 or 6

          • ‘addr’<~Array> - public or private ip address

      • ‘links’<~Array> - array of server links

      • ‘key_name’<~String> - Name of the keypair associated with the server

      • ‘image’<~Hash>

        • ‘id’<~String> - UUId of image used to create the server

        • ‘links’<~Array> - array of image links

      • ‘flavor’<~Hash>

        • ‘id’<~String> - UUId of flavor used to create the server

        • ‘links’<~Array> - array of flavor links

      • ‘id’<~String> - UUId of the server

      • ‘security_groups’<~Array>

        • ‘name’<~String> - Name of the security group associated with the server

      • ‘user_id’<~String> - Id of the user that created the server

      • ‘name<~String> - Name of the server

      • ‘tenant_id’<~String> - Id of the tenant that created the server

      • ‘accessIPv4’<~String> - IPv4 IP address

      • ‘accessIPv6’<~String> - IPv6 IP address

      • ‘progress’<~Integer> - Progress through current status

      • ‘created’<~String> - UTC datetime for when the server was created

      • ‘updated’<~String> - UTC datetime for when the server was last updated

      • ‘status’<~String> - Current server status

      • ‘config_drive’<~String> - Config drive setting, ‘true’ or ‘false’

      • ‘metadata’<~Hash> - metadata for the server

      • ‘OS-EXT-AZ:availability_zone’<~String> - Availability zone where the server is created. e.g. ‘az1’, ‘az2’ etc.

      • ‘OS-EXT-STS:power_state’<~String> - Extended power state, either 0 or 1

      • ‘OS-EXT-STS:task_state’<~String> - Extended task state

      • ‘OS-EXT-STS:vm_state’<~String> - Extended vm state



45
46
47
48
49
50
51
52
# File 'lib/fog/hp/requests/compute_v2/list_servers_detail.rb', line 45

def list_servers_detail(options = {})
  request(
    :expects  => 200,
    :method   => 'GET',
    :path     => 'servers/detail',
    :query    => options
  )
end

#reboot_server(server_id, type = 'SOFT') ⇒ Object

Reboot an existing server

Parameters

  • ‘server_id’<~String> - UUId of server to reboot

  • ‘type’<~String> - Type of reboot, must be in [‘HARD’, ‘SOFT’]



10
11
12
13
# File 'lib/fog/hp/requests/compute_v2/reboot_server.rb', line 10

def reboot_server(server_id, type = 'SOFT')
  body = { 'reboot' => { 'type' => type }}
  server_action(server_id, body)
end

#rebuild_server(server_id, image_id, name, options = {}) ⇒ Object

Rebuild an existing server

Parameters

  • ‘server_id’<~String> - UUId of server to rebuild

  • ‘image_id’<~String> - UUId of image to use to rebuild server

  • ‘name’<~String> - New name for the rebuilt server

  • ‘admin_pass’<~String> - Password for the rebuilt server

  • options<~Hash>:

    • ‘metadata’<~Hash> - Up to 5 key value pairs containing 255 bytes of info

    • ‘accessIPv4’<~String> - IPv4 IP address

    • ‘accessIPv6’<~String> - IPv6 IP address

    • ‘personality’<~Array>: Up to 5 files to customize server

      • ‘file’<~Hash>:

        • ‘contents’<~String> - Contents of file (10kb total of contents)

        • ‘path’<~String> - Path to file (255 bytes total of path strings)



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fog/hp/requests/compute_v2/rebuild_server.rb', line 20

def rebuild_server(server_id, image_id, name, options={})
  body = { 'rebuild' => {
    'imageRef' => image_id,
    'name' => name
  }}
  l_options = ['metadata', 'accessIPv4', 'accessIPv6']
  l_options.select{|o| options[o]}.each do |key|
    body['rebuild'][key] = options[key]
  end
  if options['personality']
    body['rebuild']['personality'] = []
    for file in options['personality']
      body['rebuild']['personality'] << {
        'contents'  => Base64.encode64(file['contents']),
        'path'      => file['path']
      }
    end
  end
  server_action(server_id, body, 202)
end

#release_address(address_id) ⇒ Object

Release an existing floating IP address

Parameters

  • ‘address_id’<~String> - UUId of floating IP address to release



10
11
12
13
14
15
16
# File 'lib/fog/hp/requests/compute_v2/release_address.rb', line 10

def release_address(address_id)
  request(
    :expects => 202,
    :method => 'DELETE',
    :path   => "os-floating-ips/#{address_id}"
  )
end

#reloadObject



276
277
278
# File 'lib/fog/hp/compute_v2.rb', line 276

def reload
  @connection.reset
end

#remove_security_group(server_id, sg_name) ⇒ Object

Remove an existing security group from an existing server

Parameters

  • ‘server_id’<~String> - UUId of server

  • ‘sg_name’<~String> - Name of security group to remove from the server



11
12
13
14
# File 'lib/fog/hp/requests/compute_v2/remove_security_group.rb', line 11

def remove_security_group(server_id, sg_name)
  body = { 'removeSecurityGroup' => { 'name' => sg_name }}
  server_action(server_id, body)
end

#request(params, parse_json = true, &block) ⇒ Object



280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/fog/hp/compute_v2.rb', line 280

def request(params, parse_json = true, &block)
  begin
    response = @connection.request(params.merge!({
      :headers  => {
        'Content-Type' => 'application/json',
        'Accept'       => 'application/json',
        'X-Auth-Token' => @auth_token
      }.merge!(params[:headers] || {}),
      :path     => "#{@path}/#{params[:path]}"
    }), &block)
  rescue Excon::Errors::HTTPStatusError => error
    raise case error
    when Excon::Errors::NotFound
      Fog::Compute::HPV2::NotFound.slurp(error)
    else
      error
    end
  end
  if !response.body.empty? && parse_json && response.headers['Content-Type'] =~ %r{application/json}
    response.body = Fog::JSON.decode(response.body)
  end
  response
end

#server_action(server_id, body, expects = 202) ⇒ Object

Server actions for an existing server

Parameters

  • ‘server_id’<~String> - UUId of server to reboot

  • ‘body’<~.to_json object> - Body of the request, describes the action (see reboot_server as an example)

  • ‘expect’<~Integer> - expected return, 202 except for confirm resize (204)



12
13
14
15
16
17
18
19
# File 'lib/fog/hp/requests/compute_v2/server_action.rb', line 12

def server_action(server_id, body, expects=202)
  request(
    :body     => Fog::JSON.encode(body),
    :expects  => expects,
    :method   => 'POST',
    :path     => "servers/#{server_id}/action"
  )
end

#set_metadata(collection_name, parent_id, metadata = {}) ⇒ Object

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘metadata’<~Hash> - key/value pairs of metadata items



17
18
19
20
21
22
23
24
# File 'lib/fog/hp/requests/compute_v2/set_metadata.rb', line 17

def (collection_name, parent_id,  = {})
  request(
    :body     => Fog::JSON.encode({ 'metadata' =>  }),
    :expects  => 200,
    :method   => 'PUT',
    :path     => "#{collection_name}/#{parent_id}/metadata"
  )
end

#update_meta(collection_name, parent_id, key, value) ⇒ Object

Set or update metadata item for specific collections

Parameters

  • ‘collection_name’<~String> - name of the collection i.e. images, servers for which the metadata is intented.

  • ‘parent_id’<~Integer> - id of the collection i.e. image_id or the server_id

  • ‘key’<~String> - key for the metadata item

  • ‘value’<~String> - value for the metadata item

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘meta’<~Hash>: hash of key/value pair for the metadata item updated



18
19
20
21
22
23
24
25
# File 'lib/fog/hp/requests/compute_v2/update_meta.rb', line 18

def update_meta(collection_name, parent_id, key, value)
  request(
    :body     => Fog::JSON.encode({ 'meta' => { key => value }}),
    :expects  => 200,
    :method   => 'PUT',
    :path     => "#{collection_name}/#{parent_id}/metadata/#{key}"
  )
end

#update_metadata(collection_name, parent_id, metadata = {}) ⇒ Object

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘metadata’<~Hash> - all key/value pairs of metadata items merged with existing metadata



17
18
19
20
21
22
23
24
# File 'lib/fog/hp/requests/compute_v2/update_metadata.rb', line 17

def (collection_name, parent_id,  = {})
  request(
    :body     => Fog::JSON.encode({ 'metadata' =>  }),
    :expects  => 200,
    :method   => 'POST',
    :path     => "#{collection_name}/#{parent_id}/metadata"
  )
end

#update_server(server_id, options = {}) ⇒ Object

Update an existing server

Parameters

  • ‘server_id’<~String> - UUId of the server to update

  • options<~Hash>:

    • ‘name’<~String> - New name for server

    • ‘accessIPv4’<~String> - IPv4 IP address

    • ‘accessIPv6’<~String> - IPv6 IP address

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

    • ‘server’<~Hash>:

      • ‘hostId’<~String>

      • ‘addresses’<~Hash>:

        • <network_name><~Array> - user defined network name

          • ‘version’<~Array> - IP version, 4 or 6

          • ‘addr’<~Array> - public or private ip address

      • ‘links’<~Array> - array of server links

      • ‘image’<~Hash>

        • ‘id’<~String> - UUId of image used to create the server

        • ‘links’<~Array> - array of image links

      • ‘flavor’<~Hash>

        • ‘id’<~String> - UUId of flavor used to create the server

        • ‘links’<~Array> - array of flavor links

      • ‘id’<~String> - UUId of the server

      • ‘user_id’<~String> - Id of the user that created the server

      • ‘name<~String> - Name of the server

      • ‘tenant_id’<~String> - Id of the tenant that created the server

      • ‘accessIPv4’<~String> - IPv4 IP address

      • ‘accessIPv6’<~String> - IPv6 IP address

      • ‘progress’<~Integer> - Progress through current status

      • ‘updated’<~String> - UTC datetime for when the server was last updated

      • ‘status’<~String> - Current server status

      • ‘metadata’<~Hash> - metadata



40
41
42
43
44
45
46
47
# File 'lib/fog/hp/requests/compute_v2/update_server.rb', line 40

def update_server(server_id, options = {})
  request(
    :body     => Fog::JSON.encode({ 'server' => options }),
    :expects  => 200,
    :method   => 'PUT',
    :path     => "servers/#{server_id}"
  )
end