# File lib/fog/hp/compute.rb, line 178 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] 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::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options) end
Acquires a floating IP address
response<~Excon::Response>:
body<~Hash>:
'floating_ip'<~Hash> -
'id'<~Integer> - Id of the 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/allocate_address.rb, line 16 def allocate_address request( :body => nil, :expects => 200, :method => 'POST', :path => 'os-floating-ips.json' ) end
Associate a floating IP address with existing server
server_id<~Integer> - Id of server to associate IP with
ip_address<~String> - IP address to associate with the server
# File lib/fog/hp/requests/compute/associate_address.rb, line 12 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<~Integer> - Id of server to attach the volume to
volume_id<~Integer> - Id 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/attach_volume.rb, line 20 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
# File lib/fog/hp/requests/compute/change_password_server.rb, line 6 def change_password_server(server_id, admin_password) body = { 'changePassword' => { 'adminPass' => admin_password }} server_action(server_id, body) end
Confirm resizing
server_id<~Integer> - Id of server to confirm
# File lib/fog/hp/requests/compute/confirm_resized_server.rb, line 11 def confirm_resized_server(server_id) body = { 'confirmResize' => nil } server_action(server_id, body, 204) end
Create an image from an existing server
server_id<~Integer> - Id of server to create image from
name<~String> - Name of the image
metadata<~Hash> - A hash of metadata options
'ImageType'<~String> - type of the image i.e. Gold
'ImageVersion'<~String> - version of the image i.e. 2.0
Does not return a response body.
# File lib/fog/hp/requests/compute/create_image.rb, line 18 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/create_key_pair.rb, line 23 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.json' ) 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>:
'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)
'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>
'id'<~Integer> - id of the security group
'name'<~String> - name of the security group
'links'<~Array> - array of security group links
'key_name'<~String> - name of the keypair
'adminPass'<~String> - admin password for server
# File lib/fog/hp/requests/compute/create_persistent_server.rb, line 60 def create_persistent_server(name, flavor_id, block_device_mapping = [], options = {}) data = { 'server' => { 'flavorRef' => flavor_id, 'imageRef' => nil, 'name' => name } } if options['metadata'] data['server']['metadata'] = options['metadata'] end if options['accessIPv4'] data['server']['accessIPv4'] = options['accessIPv4'] end if options['accessIPv6'] data['server']['accessIPv6'] = options['accessIPv6'] 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['key_name'] data['server']['key_name'] = options['key_name'] end if options['security_groups'] data['server']['security_groups'] = [] for sg in options['security_groups'] data['server']['security_groups'] << { 'name' => sg } end end if options['config_drive'] data['server']['config_drive'] = options['config_drive'] end if block_device_mapping data['server']['block_device_mapping'] = block_device_mapping end request( :body => Fog::JSON.encode(data), :expects => 200, :method => 'POST', :path => 'os-volumes_boot' ) end
Create a new security group
'name'<~String> - name of the security group
'description'<~String> - description of the security group
response<~Excon::Response>:
body<~Hash>:
'security_group'<~Array>:
'rules'<~Array>: - array of security group rules
'id'<~Integer> - id of the security group rule
'from_port'<~Integer> - start port for rule i.e. 22 (or -1 for ICMP wildcard)
'to_port'<~Integer> - end port for rule i.e. 22 (or -1 for ICMP wildcard)
'ip_protocol'<~String> - ip protocol for rule, must be in ['tcp', 'udp', 'icmp']
'group'<~Hash>:
* Undefined
'parent_group_id'<~Integer> - parent group id
'ip_range'<~Hash>:
'cidr'<~String> - ip range address i.e. '0.0.0.0/0'
'id'<~Integer> - id of the security group
'name'<~String> - name of the security group
'description'<~String> - description of the security group
'tenant_id'<~String> - tenant id of the user
# File lib/fog/hp/requests/compute/create_security_group.rb, line 32 def create_security_group(name, description) data = { 'security_group' => { 'name' => name, 'description' => description } } request( :body => Fog::JSON.encode(data), :expects => 200, :method => 'POST', :path => 'os-security-groups.json' ) end
Create a new security group rule and attach it to a security group
* 'parent_group_id'<~Integer> - id of the parent security group * 'ip_protocol'<~String> - ip protocol for rule, must be in ['tcp', 'udp', 'icmp'] * 'from_port'<~Integer> - start port for rule i.e. 22 (or -1 for ICMP wildcard) * 'to_port'<~Integer> - end port for rule i.e. 22 (or -1 for ICMP wildcard) * 'cidr'<~String> - ip range address i.e. '0.0.0.0/0' * 'group_id'<~Integer> - id of the security group to which this rule applies
response<~Excon::Response>:
body<~Hash>:
# File lib/fog/hp/requests/compute/create_security_group_rule.rb, line 21 def create_security_group_rule(parent_group_id, ip_protocol, from_port, to_port, cidr, group_id=nil) data = { 'security_group_rule' => { 'parent_group_id' => parent_group_id, 'ip_protocol' => ip_protocol, 'from_port' => from_port, 'to_port' => to_port, 'cidr' => cidr, 'group_id' => group_id } } request( :body => Fog::JSON.encode(data), :expects => 200, :method => 'POST', :path => 'os-security-group-rules.json' ) end
Create a new server
name<~String> - Name of server
flavor_id<~Integer> - Id of flavor for server
image_id<~Integer> - Id of image for server. If block_device_mapping is passed, this is ignored.
options<~Hash>:
'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)
'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>
'id'<~Integer> - id of the security group
'name'<~String> - name of the security group
'links'<~Array> - array of security group links
'key_name'<~String> - name of the keypair
'adminPass'<~String> - admin password for server
# File lib/fog/hp/requests/compute/create_server.rb, line 58 def create_server(name, flavor_id, image_id, options = {}) data = { 'server' => { 'flavorRef' => flavor_id, 'imageRef' => image_id, 'name' => name } } l_options = ['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 request( :body => Fog::JSON.encode(data), :expects => 202, :method => 'POST', :path => 'servers.json' ) end
Delete an image
image_id<~Integer> - Id of image to delete
# File lib/fog/hp/requests/compute/delete_image.rb, line 11 def delete_image(image_id) request( :expects => 204, :method => 'DELETE', :path => "images/#{image_id}" ) end
Delete a keypair
key_name<~String> - Name of the keypair to delete
# File lib/fog/hp/requests/compute/delete_key_pair.rb, line 11 def delete_key_pair(key_name) request( :expects => 202, :method => 'DELETE', :path => "os-keypairs/#{key_name}" ) 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/delete_meta.rb, line 17 def delete_meta(collection_name, parent_id, key) request( :expects => 204, :method => 'DELETE', :path => "#{collection_name}/#{parent_id}/metadata/#{key}" ) end
Delete a security group
id<~Integer> - Id of the security group to delete
# File lib/fog/hp/requests/compute/delete_security_group.rb, line 13 def delete_security_group(security_group_id) request( :expects => 202, :method => 'DELETE', :path => "os-security-groups/#{security_group_id}" ) end
Delete a security group rule
id<~Integer> - id of the security group rule to delete
# File lib/fog/hp/requests/compute/delete_security_group_rule.rb, line 12 def delete_security_group_rule(security_group_rule_id) request( :expects => 202, :method => 'DELETE', :path => "os-security-group-rules/#{security_group_rule_id}" ) end
Delete an existing server
id<~Integer> - Id of server to delete
# File lib/fog/hp/requests/compute/delete_server.rb, line 11 def delete_server(server_id) request( :expects => 204, :method => 'DELETE', :path => "servers/#{server_id}" ) end
Detach a block storage volume from an existing server
server_id<~Integer> - Id of server to attach the volume to
volume_id<~Integer> - Id of the volume to be attached to the server
response<~Excon::Response>:
body: Empty
# File lib/fog/hp/requests/compute/detach_volume.rb, line 15 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 existing server
server_id<~Integer> - Id of server to associate IP with
ip_address<~String> - IP address to associate with the server
# File lib/fog/hp/requests/compute/disassociate_address.rb, line 12 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
'address_id'<~Integer> - Id of floating IP address get details for
response<~Excon::Response>:
body<~Hash>:
'floating_ip'<~Hash> -
'id'<~Integer> - Id of the 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/get_address.rb, line 19 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<~Integer> - Id 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/get_console_output.rb, line 18 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
response<~Excon::Response>:
body<~Hash>:
'id'<~Integer> - Id of the flavor
'name'<~String> - Name of the flavor
'ram'<~Integer> - Amount of ram for the flavor
'disk'<~Integer> - Amount of diskspace for the flavor
# File lib/fog/hp/requests/compute/get_flavor_details.rb, line 15 def get_flavor_details(flavor_id) request( :expects => [200, 203], :method => 'GET', :path => "flavors/#{flavor_id}.json" ) end
Get details for image by id
response<~Excon::Response>:
body<~Hash>:
'id'<~Integer> - Id of the image
'name'<~String> - Name of the image
'serverId'<~Integer> - Id of server image was created from
'status'<~Integer> - Status of image
'updated'<~String> - Timestamp of last update
# File lib/fog/hp/requests/compute/get_image_details.rb, line 16 def get_image_details(image_id) request( :expects => [200, 203], :method => 'GET', :path => "images/#{image_id}.json" ) 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/get_meta.rb, line 18 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 security group
'security_group_id'<~Integer> - Id of security group to get details for
response<~Excon::Response>:
body<~Hash>:
'security_group'<~Array>:
'rules'<~Array>: - array of security group rules
'id'<~Integer> - id of the security group rule
'from_port'<~Integer> - start port for rule i.e. 22 (or -1 for ICMP wildcard)
'to_port'<~Integer> - end port for rule i.e. 22 (or -1 for ICMP wildcard)
'ip_protocol'<~String> - ip protocol for rule, must be in ['tcp', 'udp', 'icmp']
'group'<~Hash>:
* Undefined
'parent_group_id'<~Integer> - parent group id
'ip_range'<~Hash>:
'cidr'<~String> - ip range address i.e. '0.0.0.0/0'
'id'<~Integer> - id of the security group
'name'<~String> - name of the security group
'description'<~String> - description of the security group
'tenant_id'<~String> - tenant id of the user
# File lib/fog/hp/requests/compute/get_security_group.rb, line 31 def get_security_group(security_group_id) request( :expects => [200], :method => 'GET', :path => "os-security-groups/#{security_group_id}" ) end
Get details about a server
server_id<~Integer> - Id of server to get details for
response<~Excon::Response>:
body<~Hash>:
'server'<~Hash>:
'addresses'<~Hash>:
'public'<~Array> - public address strings
'private'<~Array> - private address strings
'flavorId'<~Integer> - Id of servers current flavor
'hostId'<~String>
'id'<~Integer> - Id of server
'imageId'<~Integer> - Id of image used to boot server
'metadata'<~Hash> - metadata
'name<~String> - Name of server
'progress'<~Integer> - Progress through current status
'status'<~String> - Current server status
# File lib/fog/hp/requests/compute/get_server_details.rb, line 26 def get_server_details(server_id) request( :expects => [200, 203], :method => 'GET', :path => "servers/#{server_id}.json" ) end
Retrieves the encrypted administrator password for a server running Windows.
server_id<~Integer> - Id of server
password_data<~string>: Encrypted password for a server running Windows
# File lib/fog/hp/requests/compute/get_windows_password.rb, line 14 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
response<~Excon::Response>:
body<~Hash>:
'floating_ips'<~Array> -
'id'<~Integer> - Id of the 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/list_addresses.rb, line 16 def list_addresses request( :expects => 200, :method => 'GET', :path => "os-floating-ips.json" ) end
List all flavors (IDs and names only)
response<~Excon::Response>:
body<~Hash>:
'id'<~Integer> - Id of the flavor
'name'<~String> - Name of the flavor
# File lib/fog/hp/requests/compute/list_flavors.rb, line 13 def list_flavors request( :expects => [200, 203], :method => 'GET', :path => 'flavors.json' ) end
List all flavors
response<~Excon::Response>:
body<~Hash>:
'id'<~Integer> - Id of the flavor
'name'<~String> - Name of the flavor
'ram'<~Integer> - Amount of ram for the flavor
'disk'<~Integer> - Amount of diskspace for the flavor
# File lib/fog/hp/requests/compute/list_flavors_detail.rb, line 15 def list_flavors_detail request( :expects => [200, 203], :method => 'GET', :path => 'flavors/detail.json' ) end
List all images (IDs and names only)
response<~Excon::Response>:
body<~Hash>:
'id'<~Integer> - Id of the image
'name'<~String> - Name of the image
# File lib/fog/hp/requests/compute/list_images.rb, line 13 def list_images request( :expects => [200, 203], :method => 'GET', :path => 'images.json' ) end
List all images
response<~Excon::Response>:
body<~Hash>:
'id'<~Integer> - Id of the image
'name'<~String> - Name of the image
'updated'<~String> - Last update timestamp for image
'created'<~String> - Creation timestamp for image
'status'<~String> - Status of image
# File lib/fog/hp/requests/compute/list_images_detail.rb, line 16 def list_images_detail request( :expects => [200, 203], :method => 'GET', :path => 'images/detail.json' ) 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/list_key_pairs.rb, line 18 def list_key_pairs request( :expects => [200, 203], :method => 'GET', :path => 'os-keypairs.json' ) 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/list_metadata.rb, line 17 def list_metadata(collection_name, parent_id) request( :expects => [200, 203], :method => 'GET', :path => "/#{collection_name}/#{parent_id}/metadata.json" ) end
List all security groups
response<~Excon::Response>:
body<~Hash>:
'security_groups'<~Array>:
'rules'<~Array>: - array of security group rules
'id'<~Integer> - id of the security group rule
'from_port'<~Integer> - start port for rule i.e. 22 (or -1 for ICMP wildcard)
'to_port'<~Integer> - end port for rule i.e. 22 (or -1 for ICMP wildcard)
'ip_protocol'<~String> - ip protocol for rule, must be in ['tcp', 'udp', 'icmp']
'group'<~Hash>:
* Undefined
'parent_group_id'<~Integer> - parent group id
'ip_range'<~Hash>:
'cidr'<~String> - ip range address i.e. '0.0.0.0/0'
'id'<~Integer> - id of the security group
'name'<~String> - name of the security group
'description'<~String> - description of the security group
'tenant_id'<~String> - tenant id of the user
# File lib/fog/hp/requests/compute/list_security_groups.rb, line 28 def list_security_groups request( :expects => [200], :method => 'GET', :path => 'os-security-groups.json' ) end
List all server addresses
server_id<~Integer> - Id of server to list addresses for
response<~Excon::Response>:
body<~Hash>:
'addresses'<~Hash>:
'novanet_7':<~Array> - The network name can change based on setup
# File lib/fog/hp/requests/compute/list_server_addresses.rb, line 16 def list_server_addresses(server_id) request( :expects => 200, :method => 'GET', :path => "servers/#{server_id}/ips.json" ) end
List private server addresses
server_id<~Integer> - Id of server to list addresses for
network_name<~String> - The name of the network name i.e. public, private or custom name
response<~Excon::Response>:
body<~Hash>:
'private'<~Array> - Private ip addresses
# File lib/fog/hp/requests/compute/list_server_private_addresses.rb, line 16 def list_server_private_addresses(server_id, network_name) response = request( :expects => 200, :method => 'GET', :path => "servers/#{server_id}/ips/#{network_name}.json" ) # return the first address private_address = [] data = response.body["#{network_name}"][0] if data private_address << data end response.body = { 'private' => private_address } response end
List public server addresses
server_id<~Integer> - Id of server to list addresses for
network_name<~String> - The name of the network name i.e. public, private or custom name
response<~Excon::Response>:
body<~Hash>:
'public'<~Array> - Public ip addresses
# File lib/fog/hp/requests/compute/list_server_public_addresses.rb, line 16 def list_server_public_addresses(server_id, network_name) response = request( :expects => 200, :method => 'GET', :path => "servers/#{server_id}/ips/#{network_name}.json" ) # return everything except the first address data = response.body["#{network_name}"] if data data.delete_at(0) public_address = data end response.body = { 'public' => public_address } response end
List all volumes attached to a server
server_id<~Integer> - Id of server to list attached volumes for
response<~Excon::Response>:
body<~Hash>:
'volumeAttachments'<~Array>:
<~Hash>
'device':<~String> - The name of the device
'serverId':<~Integer> - The server id to which thsi volume is attached
'id':<~Integer> - The volume id
'volumeId':<~Integer> - The volume id
# File lib/fog/hp/requests/compute/list_server_volumes.rb, line 20 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)
response<~Excon::Response>:
body<~Hash>:
'servers'<~Array>:
'id'<~Integer> - Id of server
'name<~String> - Name of server
# File lib/fog/hp/requests/compute/list_servers.rb, line 14 def list_servers request( :expects => [200, 203], :method => 'GET', :path => 'servers.json' ) end
List all servers details
response<~Excon::Response>:
body<~Hash>:
'servers'<~Array>:
'id'<~Integer> - Id of server
'name<~String> - Name of server
'imageId'<~Integer> - Id of image used to boot server
'flavorId'<~Integer> - Id of servers current flavor
'hostId'<~String>
'status'<~String> - Current server status
'progress'<~Integer> - Progress through current status
'addresses'<~Hash>:
'public'<~Array> - public address strings
'private'<~Array> - private address strings
'metadata'<~Hash> - metadata
# File lib/fog/hp/requests/compute/list_servers_detail.rb, line 23 def list_servers_detail request( :expects => [200, 203], :method => 'GET', :path => 'servers/detail.json' ) end
Reboot an existing server
server_id<~Integer> - Id of server to reboot
type<~String> - Type of reboot, must be in ['HARD', 'SOFT']
# File lib/fog/hp/requests/compute/reboot_server.rb, line 12 def reboot_server(server_id, type = 'SOFT') body = { 'reboot' => { 'type' => type }} server_action(server_id, body) end
# File lib/fog/hp/requests/compute/rebuild_server.rb, line 6 def rebuild_server(server_id, image_ref, name, admin_pass=nil, metadata=nil, personality=nil) body = { 'rebuild' => { 'imageRef' => image_ref, 'name' => name }} body['rebuild']['adminPass'] = admin_pass if admin_pass body['rebuild']['metadata'] = metadata if metadata body['rebuild']['personality'] = personality if personality server_action(server_id, body, 202) end
Release an existing floating IP address
id<~Integer> - Id of floating IP address to delete
# File lib/fog/hp/requests/compute/release_address.rb, line 11 def release_address(address_id) request( :expects => 202, :method => 'DELETE', :path => "os-floating-ips/#{address_id}" ) end
# File lib/fog/hp/compute.rb, line 221 def reload @connection.reset end
# File lib/fog/hp/compute.rb, line 225 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] || {}), :host => @host, :path => "#{@path}/#{params[:path]}", :query => ('ignore_awful_caching' << Time.now.to_i.to_s) }), &block) rescue Excon::Errors::HTTPStatusError => error raise case error when Excon::Errors::NotFound Fog::Compute::HP::NotFound.slurp(error) else error end end if !response.body.empty? && parse_json && response.headers['Content-Type'] =~ %{application/json} response.body = Fog::JSON.decode(response.body) end response end
Reboot an existing server
server_id<~Integer> - Id of server to resize
size<~String> - new size. call list_flavors to get available flavors
# File lib/fog/hp/requests/compute/resize_server.rb, line 12 def resize_server(server_id, flavor_id) body = { 'resize' => { 'flavorRef' => flavor_id }} server_action(server_id, body) end
Revert resizing
server_id<~Integer> - Id of server to revert
# File lib/fog/hp/requests/compute/revert_resized_server.rb, line 11 def revert_resized_server(server_id) body = { 'revertResize' => nil } server_action(server_id, body) end
Server actions for an existing server
server_id<~Integer> - Id 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/server_action.rb, line 13 def server_action(server_id, body, expects=202) request( :body => Fog::JSON.encode(body), :expects => expects, :method => 'POST', :path => "servers/#{server_id}/action.json" ) end
response<~Excon::Response>:
body<~Hash>:
metadata<~Hash> - key/value pairs of metadata items
# File lib/fog/hp/requests/compute/set_metadata.rb, line 18 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/update_meta.rb, line 19 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/update_metadata.rb, line 18 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.json" ) end
Update an existing server
# server_id<~Integer> - Id of server to update
options<~Hash>:
adminPass<~String> - New admin password for server
name<~String> - New name for server
# File lib/fog/hp/requests/compute/update_server.rb, line 13 def update_server(server_id, options = {}) request( :body => Fog::JSON.encode({ 'server' => options }), :expects => 200, :method => 'PUT', :path => "servers/#{server_id}.json" ) end
Generated with the Darkfish Rdoc Generator 2.