class Fog::HP::Network::Real
Attributes
Public Class Methods
# File lib/fog/hp/network.rb, line 120 def initialize(options={}) @hp_access_key = options[:hp_access_key] @hp_secret_key = options[:hp_secret_key] @hp_auth_uri = options[:hp_auth_uri] @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 network to the authentication call options[:hp_service_type] ||= "Networking" @hp_tenant_id = options[:hp_tenant_id] @hp_avl_zone = options[:hp_avl_zone] ### 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 network endpoint @hp_network_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 network endpoint @hp_network_uri = options[:hp_auth_uri] end @auth_token = credentials[:auth_token] @persistent = options[:persistent] || false uri = URI.parse(@hp_network_uri) @host = uri.host @path = uri.path @port = uri.port @scheme = uri.scheme @connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options) end
Public Instance Methods
Add an internal router interface, thus attaching a subnet or a port to an existing router
Parameters¶ ↑
-
'router_id'<~String>: - UUId for the router
-
'subnet_id'<~String>: - UUId for the subnet (Either a subnet or a port can be passed, not both)
-
'port_id'<~String>: - UUId for the port (Either a subnet or a port can be passed, not both)
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'subnet_id'<~String>: - UUId for the subnet
-
'port_id'<~String>: - UUId for the port
-
-
# File lib/fog/hp/requests/network/add_router_interface.rb, line 17 def add_router_interface(router_id, subnet_id=nil, port_id=nil, options = {}) # Either a subnet or a port can be passed, not both if (subnet_id && port_id) || (subnet_id.nil? && port_id.nil?) raise ArgumentError.new('Either a subnet or a port can be passed, not both') end if subnet_id data = { 'subnet_id' => subnet_id } elsif port_id data = { 'port_id' => port_id } end request( :body => Fog::JSON.encode(data), :expects => 200, :method => 'PUT', :path => "routers/#{router_id}/add_router_interface" ) end
Associate port with floating ip
Parameters¶ ↑
* 'floating_ip_id'<~String>: - UUId of the floating IP address to associate with * 'port_id'<~String>: - Port to associate with the floating IP
-
options<~Hash>:
-
'fixed_ip_address'<~String>: - Fixed IP address to associate with the floating IP. Mandatory, if the port has multiple IP addresses
-
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
floatingip<~Array>:
-
'id'<~String>: - UUId for the floating ip
-
'tenant_id'<~String>: - TenantId that owns the floating ip
-
'floating_network_id'<~String>: - UUId of the external network
-
'router_id'<~String>: - Id of the router, null if not assigned
-
'fixed_ip_address'<~String>: - Fixed IP address associated to the floating IP, null if not assigned
-
'floating_ip_address'<~String>: - Floating IP address
-
'port_id'<~String>: - Port associated to the floating IP, null if not assigned
-
-
-
# File lib/fog/hp/requests/network/associate_floating_ip.rb, line 24 def associate_floating_ip(floating_ip_id, port_id, options = {}) data = { 'floatingip' => { 'port_id' => port_id } } l_options = [:fixed_ip_address] l_options.select{|o| options[o]}.each do |key| data['floatingip'][key] = options[key] end request( :body => Fog::JSON.encode(data), :expects => 200, :method => 'PUT', :path => "floatingips/#{floating_ip_id}" ) end
Create a new floating ip
Parameters¶ ↑
-
'floating_network_id'<~String>: - UUId of the external network
-
options<~Hash>:
-
'port_id'<~String>: - Port to associate with the floating IP
-
'tenant_id'<~String>: - TenantId that owns the floating IP
-
'fixed_ip_address'<~String>: - Fixed IP address to associate with the floating IP. Mandatory, if the port has multiple IP addresses
-
'floating_ip_address'<~String>: - Specific floating IP address to allocate, otherwise automatically allocated
-
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
floatingip<~Array>:
-
'id'<~String>: - UUId for the floating ip
-
'tenant_id'<~String>: - TenantId that owns the floating ip
-
'floating_network_id'<~String>: - UUId of the external network
-
'router_id'<~String>: - Id of the router, null if not assigned
-
'fixed_ip_address'<~String>: - Fixed IP address associated to the floating IP, null if not assigned
-
'floating_ip_address'<~String>: - Floating IP address
-
'port_id'<~String>: - Port associated to the floating IP, null if not assigned
-
-
-
# File lib/fog/hp/requests/network/create_floating_ip.rb, line 26 def create_floating_ip(floating_network_id, options = {}) data = { 'floatingip' => { 'floating_network_id' => floating_network_id } } l_options = [:port_id, :fixed_ip_address, :floating_ip_address, :tenant_id] l_options.select{|o| options[o]}.each do |key| data['floatingip'][key] = options[key] end request( :body => Fog::JSON.encode(data), :expects => 201, :method => 'POST', :path => 'floatingips' ) end
Create a new server
Parameters¶ ↑
-
options<~Hash>:
-
'name'<~String> - Name of the network
-
'admin_state_up'<~Boolean> - The administrative state of the network, true or false
-
'shared'<~Boolean> - true or false
-
'tenant_id'<~String> - TenantId different than the current user, that should own the network. Only allowed if user has 'admin' role.
-
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
network<~Hash>:
-
'id'<~String>: - UUId for the network
-
'name'<~String>: - Name of the network
-
'tenant_id'<~String>: - TenantId that owns the network
-
'status'<~String>: - Status of the network i.e. “ACTIVE”
-
'subnets'<~Array>: - Subnets for the network
-
'id'<~Integer>: - UUId for the subnet
-
-
'router:external'<~Boolean>: - true or false
-
'admin_state_up'<~Boolean>: - true or false
-
'shared'<~Boolean>: - true or false
-
-
-
# File lib/fog/hp/requests/network/create_network.rb, line 27 def create_network(options = {}) data = { 'network' => {} } l_options = [:name, :admin_state_up, :shared, :tenant_id] l_options.select{|o| options[o]}.each do |key| data['network'][key] = options[key] end request( :body => Fog::JSON.encode(data), :expects => 201, :method => 'POST', :path => 'networks' ) end
Create a new port
Parameters¶ ↑
-
'network_id'<~String>: - UUId of the network
-
options<~Hash>:
-
'name'<~String>: - Name of the port
-
'tenant_id'<~String>: - TenantId that owns the port
-
'admin_state_up'<~Boolean> - The administrative state of the port, true or false
-
'mac_address'<~String>: - MAC address of the port
-
'fixed_ips'<~Array>:
-
'subnet_id'<~String>: - UUId of the subnet
-
'ip_address'<~String>: - IP address
-
-
'device_id'<~String>: - Id of the device
-
'device_owner'<~String>: - Device owner of the port i.e. “network:dhcp”
-
'security_groups'<~Array>: - Security Groups
-
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
port<~Array>:
-
'id'<~String>: - UUId for the port
-
'name'<~String>: - Name of the port
-
'network_id'<~String>: - UUId of the network
-
'tenant_id'<~String>: - TenantId that owns the port
-
'status'<~String>: - Status of the port i.e. ACTIVE
-
'admin_state_up'<~Boolean>: - The administrative state of the port, true or false
-
'binding:vif_type'<~String>: - “other”
-
'device_owner'<~String>: - Device owner of the port i.e. “network:dhcp”
-
'mac_address'<~String>: - MAC address of the port
-
'fixed_ips'<~Array>:
-
'subnet_id'<~String>: - UUId of the subnet
-
'ip_address'<~String>: - IP address
-
-
'security_groups'<~Array>: - Security Groups
-
'device_id'<~String>: - Id of the device
-
-
-
# File lib/fog/hp/requests/network/create_port.rb, line 39 def create_port(network_id, options = {}) data = { 'port' => { 'network_id' => network_id } } l_options = [:name, :mac_address, :fixed_ips, :security_groups, :device_id, :device_owner, :admin_state_up, :tenant_id] l_options.select{|o| options[o]}.each do |key| data['port'][key] = options[key] end request( :body => Fog::JSON.encode(data), :expects => 201, :method => 'POST', :path => 'ports' ) end
Create a new router
Parameters¶ ↑
-
options<~Hash>:
-
'name'<~String> - Name of the router
-
'admin_state_up'<~Boolean> - The administrative state of the router, true or false
-
'tenant_id'<~String> - TenantId different than the current user, that should own the network. Only allowed if user has 'admin' role.
-
'external_gateway_info'<~Hash>: - External gateway info.
-
'network_id'<~String>: - UUId of the external network
-
-
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
router<~Array>:
-
'id'<~String>: - UUId for the router
-
'name'<~String>: - Name of the router
-
'tenant_id'<~String>: - TenantId that owns the router
-
'status'<~String>: - Status of the router i.e. ACTIVE
-
'admin_state_up'<~Boolean>: - true or false
-
'external_gateway_info'<~Hash>: - External gateway info.
-
'network_id'<~String>: - UUId of the external network
-
-
-
-
# File lib/fog/hp/requests/network/create_router.rb, line 26 def create_router(options = {}) data = { 'router' => {} } l_options = [:name, :admin_state_up, :tenant_id, :external_gateway_info] l_options.select{|o| options[o]}.each do |key| data['router'][key] = options[key] end request( :body => Fog::JSON.encode(data), :expects => 201, :method => 'POST', :path => 'routers' ) end
Create a new security group
Parameters¶ ↑
-
options<~Hash>:
-
'name'<~String> - Name of the security group
-
'description'<~String> - Description of the security group
-
'tenant_id'<~String> - TenantId different than the current user, that should own the security group. Only allowed if user has 'admin' role.
-
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'security_groups'<~Array>:
-
'id'<~String> - UUId of the security group
-
'name'<~String> - Name of the security group
-
'description'<~String> - Description of the security group
-
'tenant_id'<~String> - Tenant id that owns the security group
-
'security_group_rules'<~Array>: - Array of security group rules
-
'id'<~String> - UUId of the security group rule
-
'direction'<~String> - Direction of traffic, must be in ['ingress', 'egress']
-
'port_range_min'<~Integer> - Start port for rule i.e. 22 (or -1 for ICMP wildcard)
-
'port_range_max'<~Integer> - End port for rule i.e. 22 (or -1 for ICMP wildcard)
-
'protocol'<~String> - IP protocol for rule, must be in ['tcp', 'udp', 'icmp']
-
'ethertype'<~String> - Type of ethernet support, must be in ['IPv4', 'IPv6']
-
'security_group_id'<~String> - UUId of the parent security group
-
'remote_group_id'<~String> - UUId of the remote security group
-
'remote_ip_prefix'<~String> - IP cidr range address i.e. '0.0.0.0/0'
-
'tenant_id'<~String> - Tenant id that owns the security group rule
-
-
-
# File lib/fog/hp/requests/network/create_security_group.rb, line 32 def create_security_group(options = {}) data = { 'security_group' => {} } l_options = [:name, :description, :tenant_id] l_options.select{|o| options[o]}.each do |key| data['security_group'][key] = options[key] end request( :body => Fog::JSON.encode(data), :expects => 201, :method => 'POST', :path => 'security-groups' ) end
Create a new security group rule
Parameters¶ ↑
-
'security_group_id'<~String> - UUId of the parent security group
-
'direction'<~String> - Direction of traffic, must be in ['ingress', 'egress']
-
options<~Hash>:
-
'port_range_min'<~Integer> - Start port for rule i.e. 22 (or -1 for ICMP wildcard)
-
'port_range_max'<~Integer> - End port for rule i.e. 22 (or -1 for ICMP wildcard)
-
'protocol'<~String> - IP protocol for rule, must be in ['tcp', 'udp', 'icmp']
-
'ethertype'<~String> - Type of ethernet support, must be in ['IPv4', 'IPv6']
-
'remote_group_id'<~String> - UUId of the remote security group
-
'remote_ip_prefix'<~String> - IP cidr range address i.e. '0.0.0.0/0'
-
'tenant_id'<~String> - TenantId different than the current user, that should own the security group. Only allowed if user has 'admin' role.
-
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'security_group_rule'<~Hash>:
-
'id'<~String> - UUId of the security group rule
-
'direction'<~String> - Direction of traffic, must be in ['ingress', 'egress']
-
'port_range_min'<~String> - Start port for rule i.e. 22 (or -1 for ICMP wildcard)
-
'port_range_max'<~String> - End port for rule i.e. 22 (or -1 for ICMP wildcard)
-
'protocol'<~String> - IP protocol for rule, must be in ['tcp', 'udp', 'icmp']
-
'ethertype'<~String> - Type of ethernet support, must be in ['IPv4', 'IPv6']
-
'security_group_id'<~String> - UUId of the parent security group
-
'remote_group_id'<~String> - UUId of the source security group
-
'remote_ip_prefix'<~String> - IP cidr range address i.e. '0.0.0.0/0'
-
'tenant_id'<~String> - Tenant id that owns the security group rule
-
-
# File lib/fog/hp/requests/network/create_security_group_rule.rb, line 33 def create_security_group_rule(security_group_id, direction, options = {}) data = { 'security_group_rule' => { 'security_group_id' => security_group_id, 'direction' => direction } } l_options = [:port_range_min, :port_range_max, :protocol, :ethertype, :remote_group_id, :remote_ip_prefix, :tenant_id] l_options.select{|o| options[o]}.each do |key| data['security_group_rule'][key] = options[key] end request( :body => Fog::JSON.encode(data), :expects => 201, :method => 'POST', :path => 'security-group-rules' ) end
Create a new subnet
Parameters¶ ↑
-
'network_id'<~String>: - UUId of the network
-
'cidr'<~String>: - Cidr
-
'ip_version'<~Integer>: - IP version, values 4 or 6
-
options<~Hash>:
-
'name'<~String>: - Name of the subnet
-
'tenant_id'<~String>: - TenantId that owns the subnet
-
'dns_nameservers'<~Array>: - Array of DNS Nameservers
-
'allocation_pools'<~Array>:
-
'start'<~String>: - Start IP address
-
'end'<~String>: - End IP address
-
-
'host_routes'<~Array>: - Array of host routes
-
'gateway_ip'<~String>: - Gateway IP address
-
'enable_dhcp'<~Boolean>: - true or false, defaults to true
-
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
subnet<~Array>:
-
'id'<~String>: - UUId for the subnet
-
'name'<~String>: - Name of the subnet
-
'network_id'<~String>: - UUId of the network
-
'tenant_id'<~String>: - TenantId that owns the subnet
-
'dns_nameservers'<~Array>: - Array of DNS Nameservers
-
'allocation_pools'<~Array>:
-
'start'<~String>: - Start IP address
-
'end'<~String>: - End IP address
-
-
'host_routes'<~Array>: - Array of host routes
-
'gateway_ip'<~String>: - Gateway IP address
-
'ip_version'<~Integer>: - IP version, values 4 or 6
-
'cidr'<~String>: - Cidr
-
'enable_dhcp'<~Boolean>: - true or false, defaults to true
-
-
-
# File lib/fog/hp/requests/network/create_subnet.rb, line 39 def create_subnet(network_id, cidr, ip_version, options = {}) data = { 'subnet' => { 'network_id' => network_id, 'cidr' => cidr, 'ip_version' => ip_version } } l_options = [:name, :gateway_ip, :allocation_pools, :dns_nameservers, :host_routes, :enable_dhcp, :tenant_id] l_options.select{|o| options[o]}.each do |key| data['subnet'][key] = options[key] end request( :body => Fog::JSON.encode(data), :expects => 201, :method => 'POST', :path => 'subnets' ) end
Delete an existing floating ip
Parameters¶ ↑
* 'floating_ip_id'<~String>: - UUId of the floating IP address to delete
# File lib/fog/hp/requests/network/delete_floating_ip.rb, line 9 def delete_floating_ip(floating_ip_id) request( :expects => 204, :method => 'DELETE', :path => "floatingips/#{floating_ip_id}" ) end
Delete a security group
Parameters¶ ↑
-
'security_group_id'<~String> - UUId of the security group to delete
# File lib/fog/hp/requests/network/delete_security_group.rb, line 9 def delete_security_group(security_group_id) request( :expects => 204, :method => 'DELETE', :path => "security-groups/#{security_group_id}" ) end
Delete a security group rule
Parameters¶ ↑
-
'security_group_rule_id'<~String> - UUId of the security group rule to delete
# File lib/fog/hp/requests/network/delete_security_group_rule.rb, line 9 def delete_security_group_rule(security_group_rule_id) request( :expects => 204, :method => 'DELETE', :path => "security-group-rules/#{security_group_rule_id}" ) end
Associate port with floating ip
Parameters¶ ↑
* 'floating_ip_id'<~String>: - UUId of the floating IP address to associate with
-
options<~Hash>:
-
'fixed_ip_address'<~String>: - Fixed IP address associated to the floating IP, nil to disassociate
-
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
floatingip<~Array>:
-
'id'<~String>: - UUId for the floating ip
-
'tenant_id'<~String>: - TenantId that owns the floating ip
-
'floating_network_id'<~String>: - UUId of the external network
-
'router_id'<~String>: - Id of the router, null if not assigned
-
'fixed_ip_address'<~String>: - Fixed IP address associated to the floating IP, null if not assigned
-
'floating_ip_address'<~String>: - Floating IP address
-
'port_id'<~String>: - Port associated to the floating IP, null if not assigned
-
-
-
# File lib/fog/hp/requests/network/disassociate_floating_ip.rb, line 23 def disassociate_floating_ip(floating_ip_id, options = {}) data = { 'floatingip' => { 'port_id' => nil # nil, to disassociate } } l_options = [:fixed_ip_address] l_options.select{|o| options[o]}.each do |key| data['floatingip'][key] = nil # nil, to disassociate end request( :body => Fog::JSON.encode(data), :expects => 200, :method => 'PUT', :path => "floatingips/#{floating_ip_id}" ) end
Get details for an existing floating ip by id
Parameters¶ ↑
-
'floating_ip_id'<~String>: - UUId for the floating ip to get details for
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
floatingip<~Array>:
-
'id'<~String>: - UUId for the floating ip
-
'tenant_id'<~String>: - TenantId that owns the floating ip
-
'floating_network_id'<~String>: - UUId of the external network
-
'router_id'<~String>: - Id of the router, null if not assigned
-
'fixed_ip_address'<~String>: - Fixed IP address associated to the floating IP, null if not assigned
-
'floating_ip_address'<~String>: - Floating IP address
-
'port_id'<~String>: - Port associated to the floating IP, null if not assigned
-
-
-
# File lib/fog/hp/requests/network/get_floating_ip.rb, line 21 def get_floating_ip(floating_ip_id) request( :expects => 200, :method => 'GET', :path => "floatingips/#{floating_ip_id}" ) end
Get details for an existing network by id
Parameters¶ ↑
-
'network_id'<~String>: - UUId for the network to get details for
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
network<~Hash>:
-
'id'<~String>: - UUId for the network
-
'name'<~String>: - Name of the network
-
'tenant_id'<~String>: - TenantId that owns the network
-
'status'<~String>: - Status of the network i.e. “ACTIVE”
-
'subnets'<~Array>: - Subnets for the network
-
'id'<~Integer>: - UUId for the subnet
-
-
'router:external'<~Boolean>: - true or false
-
'admin_state_up'<~Boolean>: - true or false
-
'shared'<~Boolean>: - true or false
-
-
-
# File lib/fog/hp/requests/network/get_network.rb, line 23 def get_network(network_id) request( :expects => 200, :method => 'GET', :path => "networks/#{network_id}" ) end
Get details for an existing port by id
Parameters¶ ↑
-
'port_id'<~String>: - UUId for the port to get details for
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
port<~Array>:
-
'id'<~String>: - UUId for the port
-
'name'<~String>: - Name of the port
-
'network_id'<~String>: - UUId of the network
-
'tenant_id'<~String>: - TenantId that owns the port
-
'status'<~String>: - Status of the port i.e. ACTIVE
-
'admin_state_up'<~Boolean>: - true or false
-
'binding:vif_type'<~String>: - “other”
-
'device_owner'<~String>: - Device owner of the port i.e. “network:dhcp”
-
'mac_address'<~String>: - MAC address of the port
-
'fixed_ips'<~Array>:
-
'subnet_id'<~String>: - UUId of the subnet
-
'ip_address'<~String>: - IP address
-
-
'security_groups'<~Array>: - Security Groups
-
'device_id'<~String>: - Id of the device
-
-
-
# File lib/fog/hp/requests/network/get_port.rb, line 28 def get_port(port_id) request( :expects => 200, :method => 'GET', :path => "ports/#{port_id}" ) end
Get details for an existing router by id
Parameters¶ ↑
-
'router_id'<~String>: - UUId for the router to get details for
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
router<~Array>:
-
'id'<~String>: - UUId for the router
-
'name'<~String>: - Name of the router
-
'tenant_id'<~String>: - TenantId that owns the router
-
'status'<~String>: - Status of the router i.e. ACTIVE
-
'admin_state_up'<~Boolean>: - true or false
-
'external_gateway_info'<~Hash>: - External gateway info.
-
'network_id'<~String>: - UUId of the external network
-
-
-
-
# File lib/fog/hp/requests/network/get_router.rb, line 21 def get_router(router_id) request( :expects => 200, :method => 'GET', :path => "routers/#{router_id}" ) end
Get details about a security group
Parameters¶ ↑
-
'security_group_id'<~String> - UUId of the security group
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'security_group'<~Array>:
-
'id'<~String> - UUId of the security group
-
'name'<~String> - Name of the security group
-
'description'<~String> - Description of the security group
-
'tenant_id'<~String> - Tenant id that owns the security group
-
'security_group_rules'<~Array>: - Array of security group rules
-
'id'<~String> - UUId of the security group rule
-
'direction'<~String> - Direction of traffic, must be in ['ingress', 'egress']
-
'port_range_min'<~Integer> - Start port for rule i.e. 22 (or -1 for ICMP wildcard)
-
'port_range_max'<~Integer> - End port for rule i.e. 22 (or -1 for ICMP wildcard)
-
'protocol'<~String> - IP protocol for rule, must be in ['tcp', 'udp', 'icmp']
-
'ethertype'<~String> - Type of ethernet support, must be in ['IPv4', 'IPv6']
-
'security_group_id'<~String> - UUId of the parent security group
-
'remote_group_id'<~String> - UUId of the remote security group
-
'remote_ip_prefix'<~String> - IP cidr range address i.e. '0.0.0.0/0'
-
'tenant_id'<~String> - Tenant id that owns the security group rule
-
-
-
# File lib/fog/hp/requests/network/get_security_group.rb, line 29 def get_security_group(security_group_id) request( :expects => 200, :method => 'GET', :path => "security-groups/#{security_group_id}" ) end
Get details about a security group rule
Parameters¶ ↑
-
'security_group_rule_id'<~String> - UUId of the security group rule
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'security_group_rule'<~Hash>:
-
'id'<~String> - UUId of the security group rule
-
'direction'<~String> - Direction of traffic, must be in ['ingress', 'egress']
-
'port_range_min'<~Integer> - Start port for rule i.e. 22 (or -1 for ICMP wildcard)
-
'port_range_max'<~Integer> - End port for rule i.e. 22 (or -1 for ICMP wildcard)
-
'protocol'<~String> - IP protocol for rule, must be in ['tcp', 'udp', 'icmp']
-
'ethertype'<~String> - Type of ethernet support, must be in ['IPv4', 'IPv6']
-
'security_group_id'<~String> - UUId of the parent security group
-
'remote_group_id'<~String> - UUId of the remote security group
-
'remote_ip_prefix'<~String> - IP cidr range address i.e. '0.0.0.0/0'
-
'tenant_id'<~String> - Tenant id that owns the security group rule
-
-
# File lib/fog/hp/requests/network/get_security_group_rule.rb, line 24 def get_security_group_rule(security_group_rule_id) request( :expects => 200, :method => 'GET', :path => "security-group-rules/#{security_group_rule_id}" ) end
Gets an existing subnet by id
Parameters¶ ↑
-
'id'<~String>: - UUId for the subnet
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
subnet<~Array>:
-
'id'<~String>: - UUId for the subnet
-
'name'<~String>: - Name of the subnet
-
'network_id'<~String>: - UUId of the network
-
'tenant_id'<~String>: - TenantId that owns the subnet
-
'dns_nameservers'<~Array>: - Array of DNS Nameservers
-
'allocation_pools'<~Array>:
-
'start'<~String>: - Start IP address
-
'end'<~String>: - End IP address
-
-
'host_routes'<~Array>: - Array of host routes
-
'gateway_ip'<~String>: - Gateway IP address
-
'ip_version'<~Integer>: - IP version, values 4 or 6
-
'cidr'<~String>: - Cidr
-
'enable_dhcp'<~Boolean>: - true or false, defaults to true
-
-
-
# File lib/fog/hp/requests/network/get_subnet.rb, line 27 def get_subnet(subnet_id) request( :expects => 200, :method => 'GET', :path => "subnets/#{subnet_id}" ) end
List existing floating ips
Parameters¶ ↑
-
options<~Hash>:
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
floatingips<~Array>:
-
'id'<~String>: - UUId for the floating ip
-
'tenant_id'<~String>: - TenantId that owns the floating ip
-
'floating_network_id'<~String>: - UUId of the external network
-
'router_id'<~String>: - Id of the router, null if not assigned
-
'fixed_ip_address'<~String>: - Fixed IP address associated to the floating IP, null if not assigned
-
'floating_ip_address'<~String>: - Floating IP address
-
'port_id'<~String>: - Port associated to the floating IP, null if not assigned
-
-
-
# File lib/fog/hp/requests/network/list_floating_ips.rb, line 22 def list_floating_ips(options = {}) request( :expects => 200, :method => 'GET', :path => 'floatingips', :query => options ) end
List existing networks
Parameters¶ ↑
-
options<~Hash>:
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
networks<~Array>:
-
'id'<~String>: - UUId for the network
-
'name'<~String>: - Name of the network
-
'tenant_id'<~String>: - TenantId that owns the network
-
'status'<~String>: - Status of the network i.e. “ACTIVE”
-
'subnets'<~Array>: - Subnets for the network
-
'id'<~Integer>: - UUId for the subnet
-
-
'router:external'<~Boolean>: - true or false
-
'admin_state_up'<~Boolean>: - true or false
-
'shared'<~Boolean>: - true or false
-
-
-
# File lib/fog/hp/requests/network/list_networks.rb, line 23 def list_networks(options = {}) request( :expects => 200, :method => 'GET', :path => 'networks', :query => options ) end
List existing ports
Parameters¶ ↑
-
options<~Hash>:
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
ports<~Array>:
-
'id'<~String>: - UUId for the port
-
'name'<~String>: - Name of the port
-
'network_id'<~String>: - UUId of the network
-
'tenant_id'<~String>: - TenantId that owns the port
-
'status'<~String>: - Status of the port i.e. ACTIVE
-
'admin_state_up'<~Boolean>: - true or false
-
'binding:vif_type'<~String>: - “other”
-
'device_owner'<~String>: - Device owner of the port i.e. “network:dhcp”
-
'mac_address'<~String>: - MAC address of the port
-
'fixed_ips'<~Array>:
-
'subnet_id'<~String>: - UUId of the subnet
-
'ip_address'<~String>: - IP address
-
-
'security_groups'<~Array>: - Security Groups
-
'device_id'<~String>: - Id of the device
-
-
-
# File lib/fog/hp/requests/network/list_ports.rb, line 28 def list_ports(options = {}) request( :expects => 200, :method => 'GET', :path => 'ports', :query => options ) end
List existing routers
Parameters¶ ↑
-
options<~Hash>:
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
routers<~Array>:
-
'id'<~String>: - UUId for the router
-
'name'<~String>: - Name of the router
-
'tenant_id'<~String>: - TenantId that owns the router
-
'status'<~String>: - Status of the router i.e. ACTIVE
-
'admin_state_up'<~Boolean>: - true or false
-
'external_gateway_info'<~Hash>: - External gateway info.
-
'network_id'<~String>: - UUId of the external network
-
-
-
-
# File lib/fog/hp/requests/network/list_routers.rb, line 21 def list_routers(options = {}) request( :expects => 200, :method => 'GET', :path => 'routers', :query => options ) end
List all security group rules
Parameters¶ ↑
-
options<~Hash>:
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'security_group_rules'<~Array>:
-
'id'<~String> - UUId of the security group rule
-
'direction'<~String> - Direction of traffic, must be in ['ingress', 'egress']
-
'port_range_min'<~Integer> - Start port for rule i.e. 22 (or -1 for ICMP wildcard)
-
'port_range_max'<~Integer> - End port for rule i.e. 22 (or -1 for ICMP wildcard)
-
'protocol'<~String> - IP protocol for rule, must be in ['tcp', 'udp', 'icmp']
-
'ethertype'<~String> - Type of ethernet support, must be in ['IPv4', 'IPv6']
-
'security_group_id'<~String> - UUId of the parent security group
-
'remote_group_id'<~String> - UUId of the remote security group
-
'remote_ip_prefix'<~String> - IP cidr range address i.e. '0.0.0.0/0'
-
'tenant_id'<~String> - Tenant id that owns the security group rule
-
-
# File lib/fog/hp/requests/network/list_security_group_rules.rb, line 24 def list_security_group_rules(options = {}) request( :expects => 200, :method => 'GET', :path => 'security-group-rules', :query => options ) end
List all security groups
Parameters¶ ↑
-
options<~Hash>:
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'security_groups'<~Array>:
-
'id'<~String> - UUId of the security group
-
'name'<~String> - Name of the security group
-
'description'<~String> - Description of the security group
-
'tenant_id'<~String> - Tenant id that owns the security group
-
'security_group_rules'<~Array>: - Array of security group rules
-
'id'<~String> - UUId of the security group rule
-
'direction'<~String> - Direction of traffic, must be in ['ingress', 'egress']
-
'port_range_min'<~Integer> - Start port for rule i.e. 22 (or -1 for ICMP wildcard)
-
'port_range_max'<~Integer> - End port for rule i.e. 22 (or -1 for ICMP wildcard)
-
'protocol'<~String> - IP protocol for rule, must be in ['tcp', 'udp', 'icmp']
-
'ethertype'<~String> - Type of ethernet support, must be in ['IPv4', 'IPv6']
-
'security_group_id'<~String> - UUId of the parent security group
-
'remote_group_id'<~String> - UUId of the remote security group
-
'remote_ip_prefix'<~String> - IP cidr range address i.e. '0.0.0.0/0'
-
'tenant_id'<~String> - Tenant id that owns the security group rule
-
-
-
# File lib/fog/hp/requests/network/list_security_groups.rb, line 29 def list_security_groups(options = {}) request( :expects => 200, :method => 'GET', :path => 'security-groups', :query => options ) end
List existing subnets
Parameters¶ ↑
-
options<~Hash>:
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
subnets<~Array>:
-
'id'<~String>: - UUId for the subnet
-
'name'<~String>: - Name of the subnet
-
'network_id'<~String>: - UUId of the network
-
'tenant_id'<~String>: - TenantId that owns the subnet
-
'dns_nameservers'<~Array>: - Array of DNS Nameservers
-
'allocation_pools'<~Array>:
-
'start'<~String>: - Start IP address
-
'end'<~String>: - End IP address
-
-
'host_routes'<~Array>: - Array of host routes
-
'gateway_ip'<~String>: - Gateway IP address
-
'ip_version'<~Integer>: - IP version, values 4 or 6
-
'cidr'<~String>: - Cidr
-
'enable_dhcp'<~Boolean>: - true or false, defaults to true
-
-
-
# File lib/fog/hp/requests/network/list_subnets.rb, line 27 def list_subnets(options = {}) request( :expects => 200, :method => 'GET', :path => 'subnets', :query => options ) end
# File lib/fog/hp/network.rb, line 158 def reload @connection.reset end
Remove an internal router interface, thus detaching a subnet or a port from an existing router
Parameters¶ ↑
-
'router_id'<~String>: - UUId for the router
-
'subnet_id'<~String>: - UUId for the subnet (Either a subnet or a port can be passed, not both)
-
'port_id'<~String>: - UUId for the port (Either a subnet or a port can be passed, not both)
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
'subnet_id'<~String>: - UUId for the subnet
-
'port_id'<~String>: - UUId for the port
-
-
# File lib/fog/hp/requests/network/remove_router_interface.rb, line 17 def remove_router_interface(router_id, subnet_id=nil, port_id=nil, options = {}) # Either a subnet or a port can be passed, not both if (subnet_id && port_id) || (subnet_id.nil? && port_id.nil?) raise ArgumentError.new('Bad router request: Cannot specify both subnet-id and port-id') end if subnet_id data = { 'subnet_id' => subnet_id } elsif port_id data = { 'port_id' => port_id } end request( :body => Fog::JSON.encode(data), :expects => 200, :method => 'PUT', :path => "routers/#{router_id}/remove_router_interface" ) end
# File lib/fog/hp/network.rb, line 162 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}/v2.0/#{params[:path]}" }), &block) rescue Excon::Errors::HTTPStatusError => error raise case error when Excon::Errors::NotFound Fog::HP::Network::NotFound.slurp(error) else error end end if !response.body.empty? && parse_json && response.headers['Content-Type'] =~ %r{application/json} if response.body.nil? || response.body == 'null' response.body = '' else response.body = Fog::JSON.decode(response.body) end end response end
Update attributes for an existing network
Parameters¶ ↑
-
'network_id'<~String>: - UUId of the network
-
options<~Hash>:
-
'name'<~String> - Name of the network
-
'admin_state_up'<~Boolean> - The administrative state of the network, true or false
-
'shared'<~Boolean> - true or false
-
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
network<~Hash>:
-
'id'<~String>: - UUId for the network
-
'name'<~String>: - Name of the network
-
'tenant_id'<~String>: - TenantId that owns the network
-
'status'<~String>: - Status of the network i.e. “ACTIVE”
-
'subnets'<~Array>: - Subnets for the network
-
'id'<~Integer>: - UUId for the subnet
-
-
'admin_state_up'<~Boolean>: - true or false
-
'shared'<~Boolean>: - true or false
-
-
-
# File lib/fog/hp/requests/network/update_network.rb, line 26 def update_network(network_id, options = {}) data = { 'network' => {} } l_options = [:name, :admin_state_up, :shared] l_options.select{|o| options[o]}.each do |key| data['network'][key] = options[key] end request( :body => Fog::JSON.encode(data), :expects => 200, :method => 'PUT', :path => "networks/#{network_id}" ) end
Update an existing port by id
Parameters¶ ↑
-
'port_id'<~String>: - UUId of the port
-
options<~Hash>:
-
'name'<~String>: - Name of the port
-
'admin_state_up'<~Boolean> - The administrative state of the port, true or false
-
'fixed_ips'<~Array>:
-
'subnet_id'<~String>: - UUId of the subnet
-
'ip_address'<~String>: - IP address
-
-
'device_id'<~String>: - Id of the device
-
'device_owner'<~String>: - Device owner of the port i.e. “network:dhcp”
-
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
port<~Array>:
-
'id'<~String>: - UUId for the port
-
'name'<~String>: - Name of the port
-
'network_id'<~String>: - UUId of the network
-
'tenant_id'<~String>: - TenantId that owns the port
-
'status'<~String>: - Status of the port i.e. ACTIVE
-
'admin_state_up'<~Boolean>: - The administrative state of the port, true or false
-
'binding:vif_type'<~String>: - “other”
-
'device_owner'<~String>: - Device owner of the port i.e. “network:dhcp”
-
'mac_address'<~String>: - MAC address of the port
-
'fixed_ips'<~Array>:
-
'subnet_id'<~String>: - UUId of the subnet
-
'ip_address'<~String>: - IP address
-
-
'security_groups'<~Array>: - Security Groups
-
'device_id'<~String>: - Id of the device
-
-
-
# File lib/fog/hp/requests/network/update_port.rb, line 36 def update_port(port_id, options = {}) data = { 'port' => {} } l_options = [:name, :fixed_ips, :device_id, :device_owner, :admin_state_up] l_options.select{|o| options[o]}.each do |key| data['port'][key] = options[key] end request( :body => Fog::JSON.encode(data), :expects => 200, :method => 'PUT', :path => "ports/#{port_id}" ) end
Update an existing router by id
Parameters¶ ↑
-
'router_id'<~String>: - UUId for the router
-
options<~Hash>:
-
'name'<~String> - Name of the router
-
'admin_state_up'<~Boolean> - The administrative state of the router, true or false
-
'external_gateway_info'<~Hash>: - External gateway info.
-
'network_id'<~String>: - UUId of the external network
-
-
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
router<~Array>:
-
'id'<~String>: - UUId for the router
-
'name'<~String>: - Name of the router
-
'tenant_id'<~String>: - TenantId that owns the router
-
'status'<~String>: - Status of the router i.e. ACTIVE
-
'admin_state_up'<~Boolean>: - true or false
-
'external_gateway_info'<~Hash>: - External gateway info.
-
'network_id'<~String>: - UUId of the external network
-
-
-
-
# File lib/fog/hp/requests/network/update_router.rb, line 26 def update_router(router_id, options = {}) data = { 'router' => {} } l_options = [:name, :admin_state_up, :external_gateway_info] l_options.select{|o| options[o]}.each do |key| data['router'][key] = options[key] end request( :body => Fog::JSON.encode(data), :expects => 200, :method => 'PUT', :path => "routers/#{router_id}" ) end
Update an existing subnet
Parameters¶ ↑
-
'id'<~String>: - UUId for the subnet
-
options<~Hash>:
-
'name'<~String>: - Name of the subnet
-
'dns_nameservers'<~Array>: - Array of DNS Nameservers
-
'host_routes'<~Array>: - Array of host routes
-
'gateway_ip'<~String>: - Gateway IP address
-
'enable_dhcp'<~Boolean>: - true or false, defaults to true
-
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>:
-
subnet<~Array>:
-
'id'<~String>: - UUId for the subnet
-
'name'<~String>: - Name of the subnet
-
'network_id'<~String>: - UUId of the network
-
'tenant_id'<~String>: - TenantId that owns the subnet
-
'dns_nameservers'<~Array>: - Array of DNS Nameservers
-
'allocation_pools'<~Array>:
-
'start'<~String>: - Start IP address
-
'end'<~String>: - End IP address
-
-
'host_routes'<~Array>: - Array of host routes
-
'gateway_ip'<~String>: - Gateway IP address
-
'ip_version'<~Integer>: - IP version, values 4 or 6
-
'cidr'<~String>: - Cidr
-
'enable_dhcp'<~Boolean>: - true or false, defaults to true
-
-
-
# File lib/fog/hp/requests/network/update_subnet.rb, line 33 def update_subnet(subnet_id, options = {}) data = { 'subnet' => {} } l_options = [:name, :gateway_ip, :dns_nameservers, :host_routes, :enable_dhcp] l_options.select{|o| options[o]}.each do |key| data['subnet'][key] = options[key] end request( :body => Fog::JSON.encode(data), :expects => 200, :method => 'PUT', :path => "subnets/#{subnet_id}" ) end