# 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
Add an existing security group to an existing server
'server_id'<~String> - UUId of server
'sg_name'<~String> - Name of security group to add to the server
# 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
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.
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
# 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 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.
'server_id'<~String> - UUId of server to associate IP with
'ip_address'<~String> - IP address to associate with the server
# 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 a block storage volume to an existing server
'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
response<~Excon::Response>:
body<~Hash>:
'volumeAttachment'<~Hash>:
<~Hash>
'volumeId':<~Integer> - The volume id
'device':<~String> - The name of the device
# 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 an image from an existing server
'server_id'<~String> - UUId of server to create the image from
'name'<~String> - Name of the image
'metadata'<~Hash> - A hash of metadata options
Does not return a response body.
# File lib/fog/hp/requests/compute_v2/create_image.rb, line 14 def create_image(server_id, name, metadata = {}) body = { 'createImage' => { 'name' => name, 'metadata' => metadata } } server_action(server_id, body) end
Create a new keypair
'key_name'<~String> - Name of the keypair
'public_key'<~String> - The public key for the keypair
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
# 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 a new persistent server i.e. use a bootable volume instead of an image
'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
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
# 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 a new server
'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
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
# 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 metadata item for specific collections
'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
response<~Excon::Response>:
body: Empty response body
# 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
Detach a block storage volume from an existing server
'server_id'<~String> - UUId of server to attach the volume to
'volume_id'<~String> - UUId of the volume to be attached to the server
response<~Excon::Response>:
body: Empty
# 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 a floating IP address with an existing server
'server_id'<~String> - UUId of server to associate IP address with
'ip_address'<~String> - IP address to associate with the server
# 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 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.
'address_id'<~String> - UUId of floating IP address get details for
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
# 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
Retrieve console output for specified instance
'server_id'<~Stribng> - UUId of instance to get console output from
'num_lines'<~Integer> - Number of lines of console output from the end
# * response<~Excon::Response>:
* body<~Hash>: * 'output'<~String> - Console output
# 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 details for flavor by id
'flavor_id'<~String> - UUId of the flavor to get details for
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
# 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 details for image by id
'image_id'<~String> - UUId of image to get details for
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
# 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 details about a key pair
'key_name'<~String> - Name of the keypair to get
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
# 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 metadata item for specific collections
'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
response<~Excon::Response>:
body<~Hash>:
'meta'<~Hash>: hash of key/value pair for the metadata item found
# 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 details about a server
'server_id'<~String> - UUId of the server to get details for
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
# 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 a block storage volume attachments for an existing server
'server_id'<~String> - UUId of server to get attached volumes for
'volume_id'<~String> - UUId of the volume attached to the server
response<~Excon::Response>:
body: Empty
# 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
Retrieve VNC console for the specified instance
'server_id'<~String> - UUId of instance to get console output from
'type'<~String> - Type of the vnc console, defaults to 'novnc'
# * 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
# 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
Retrieves the encrypted administrator password for a server running Windows.
'server_id'<~String> - UUId of the server
'password_data'<~string>: Encrypted password for a server running Windows
# 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 all Floating IP addresses
Note: This method will proxy the call to the Network (Quantum) service, to list all floating IP addresses.
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
# 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 all availability zones
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
# 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 all flavors (IDs and names only)
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
response<~Excon::Response>:
body<~Hash>:
'id'<~String> - UUId of the flavor
'name'<~String> - Name of the flavor
'links'<~Array> - array of flavor links
# 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 all flavors
options<~Hash>: filter options
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
# 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 all images (IDs and names only)
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.
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
# 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 all images
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.
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
# 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 all key pairs
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
# 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 the limits on resources on a per tenant basis (absolute and rate limits)
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
# 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 for specific collections
'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
response<~Excon::Response>:
body<~Hash>:
'metadata'<~Hash>: hash of key/value pair for the metadata items found
# File lib/fog/hp/requests/compute_v2/list_metadata.rb, line 16 def list_metadata(collection_name, parent_id) request( :expects => [200, 203], :method => 'GET', :path => "/#{collection_name}/#{parent_id}/metadata" ) end
List all server addresses
'server_id'<~String> - UUId of server to list addresses for
response<~Excon::Response>:
body<~Hash>:
'addresses'<~Hash>:
'custom':<~Array> - IP addresses for the server. The network name can change based on setup.
# 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 private server addresses
'server_id'<~String> - UUId of server to list addresses for
'network_name'<~String> - Name of the network to list addresses for
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
# 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 all volumes attached to a server
'server_id'<~String> - UUId of server to list attached volumes for
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
# 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 all servers (IDs and names only)
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.
response<~Excon::Response>:
body<~Hash>:
'servers'<~Array>:
'id'<~Integer> - UUId of server
'name'<~String> - Name of server
'links'<~Array> - array of server links
# 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 all servers details
options<~Hash>: filter options
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
# 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 an existing server
'server_id'<~String> - UUId of server to reboot
'type'<~String> - Type of reboot, must be in ['HARD', 'SOFT']
# 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 an existing server
'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)
# 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 an existing floating IP address
'address_id'<~String> - UUId of floating IP address to release
# 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
# File lib/fog/hp/compute_v2.rb, line 276 def reload @connection.reset end
Remove an existing security group from an existing server
'server_id'<~String> - UUId of server
'sg_name'<~String> - Name of security group to remove from the server
# 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
# 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 actions for an existing server
'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)
# 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
response<~Excon::Response>:
body<~Hash>:
'metadata'<~Hash> - key/value pairs of metadata items
# File lib/fog/hp/requests/compute_v2/set_metadata.rb, line 17 def set_metadata(collection_name, parent_id, metadata = {}) request( :body => Fog::JSON.encode({ 'metadata' => metadata }), :expects => 200, :method => 'PUT', :path => "#{collection_name}/#{parent_id}/metadata" ) end
Set or update metadata item for specific collections
'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
response<~Excon::Response>:
body<~Hash>:
'meta'<~Hash>: hash of key/value pair for the metadata item updated
# 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
response<~Excon::Response>:
body<~Hash>:
'metadata'<~Hash> - all key/value pairs of metadata items merged with existing metadata
# File lib/fog/hp/requests/compute_v2/update_metadata.rb, line 17 def update_metadata(collection_name, parent_id, metadata = {}) request( :body => Fog::JSON.encode({ 'metadata' => metadata }), :expects => 200, :method => 'POST', :path => "#{collection_name}/#{parent_id}/metadata" ) end
Update an existing server
'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
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
# 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