Class: Fog::HP::Network::Real

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/fog/hp/network.rb,
lib/fog/hp/requests/network/get_port.rb,
lib/fog/hp/requests/network/get_router.rb,
lib/fog/hp/requests/network/get_subnet.rb,
lib/fog/hp/requests/network/list_ports.rb,
lib/fog/hp/requests/network/create_port.rb,
lib/fog/hp/requests/network/delete_port.rb,
lib/fog/hp/requests/network/get_network.rb,
lib/fog/hp/requests/network/update_port.rb,
lib/fog/hp/requests/network/list_routers.rb,
lib/fog/hp/requests/network/list_subnets.rb,
lib/fog/hp/requests/network/create_router.rb,
lib/fog/hp/requests/network/create_subnet.rb,
lib/fog/hp/requests/network/delete_router.rb,
lib/fog/hp/requests/network/delete_subnet.rb,
lib/fog/hp/requests/network/list_networks.rb,
lib/fog/hp/requests/network/update_router.rb,
lib/fog/hp/requests/network/update_subnet.rb,
lib/fog/hp/requests/network/create_network.rb,
lib/fog/hp/requests/network/delete_network.rb,
lib/fog/hp/requests/network/update_network.rb,
lib/fog/hp/requests/network/get_floating_ip.rb,
lib/fog/hp/requests/network/list_floating_ips.rb,
lib/fog/hp/requests/network/create_floating_ip.rb,
lib/fog/hp/requests/network/delete_floating_ip.rb,
lib/fog/hp/requests/network/get_security_group.rb,
lib/fog/hp/requests/network/add_router_interface.rb,
lib/fog/hp/requests/network/list_security_groups.rb,
lib/fog/hp/requests/network/associate_floating_ip.rb,
lib/fog/hp/requests/network/create_security_group.rb,
lib/fog/hp/requests/network/delete_security_group.rb,
lib/fog/hp/requests/network/get_security_group_rule.rb,
lib/fog/hp/requests/network/remove_router_interface.rb,
lib/fog/hp/requests/network/disassociate_floating_ip.rb,
lib/fog/hp/requests/network/list_security_group_rules.rb,
lib/fog/hp/requests/network/create_security_group_rule.rb,
lib/fog/hp/requests/network/delete_security_group_rule.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Real

Returns a new instance of Real.



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/fog/hp/network.rb', line 123

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::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end

Instance Attribute Details

#credentialsObject (readonly)

Returns the value of attribute credentials.



121
122
123
# File 'lib/fog/hp/network.rb', line 121

def credentials
  @credentials
end

Instance Method Details

#add_router_interface(router_id, subnet_id = nil, port_id = nil, options = {}) ⇒ Object

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



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/hp/requests/network/add_router_interface.rb', line 18

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_floating_ip(floating_ip_id, port_id, options = {}) ⇒ Object

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



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fog/hp/requests/network/associate_floating_ip.rb', line 25

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_floating_ip(floating_network_id, options = {}) ⇒ Object

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



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/fog/hp/requests/network/create_floating_ip.rb', line 27

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_network(options = {}) ⇒ Object

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



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/fog/hp/requests/network/create_network.rb', line 29

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_port(network_id, options = {}) ⇒ Object

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



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/fog/hp/requests/network/create_port.rb', line 40

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_router(options = {}) ⇒ Object

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



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fog/hp/requests/network/create_router.rb', line 27

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_security_group(options = {}) ⇒ Object

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



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fog/hp/requests/network/create_security_group.rb', line 33

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_security_group_rule(security_group_id, direction, options = {}) ⇒ Object

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



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/fog/hp/requests/network/create_security_group_rule.rb', line 34

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_subnet(network_id, cidr, ip_version, options = {}) ⇒ Object

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



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/fog/hp/requests/network/create_subnet.rb', line 40

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_floating_ip(floating_ip_id) ⇒ Object

Delete an existing floating ip

Parameters

* 'floating_ip_id'<~String>: - UUId of the floating IP address to delete


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

def delete_floating_ip(floating_ip_id)
  request(
    :expects  => 204,
    :method   => 'DELETE',
    :path     => "floatingips/#{floating_ip_id}"
  )
end

#delete_network(network_id) ⇒ Object

Delete an existing network

Parameters

  • ‘network_id’<~String> - UUId for the network to delete



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

def delete_network(network_id)
  request(
    :expects  => 204,
    :method   => 'DELETE',
    :path     => "networks/#{network_id}"
  )
end

#delete_port(port_id) ⇒ Object

Delete an existing port

Parameters

  • port_id<~String> - UUId for the port to delete



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

def delete_port(port_id)
  request(
    :expects  => 204,
    :method   => 'DELETE',
    :path     => "ports/#{port_id}"
  )
end

#delete_router(router_id) ⇒ Object

Delete an existing router

Parameters

  • ‘router_id’<~String> - UUId for the router to delete



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

def delete_router(router_id)
  request(
    :expects  => 204,
    :method   => 'DELETE',
    :path     => "routers/#{router_id}"
  )
end

#delete_security_group(security_group_id) ⇒ Object

Delete a security group

Parameters

  • ‘security_group_id’<~String> - UUId of the security group to delete



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

def delete_security_group(security_group_id)
  request(
    :expects  => 204,
    :method   => 'DELETE',
    :path     => "security-groups/#{security_group_id}"
  )
end

#delete_security_group_rule(security_group_rule_id) ⇒ Object

Delete a security group rule

Parameters

  • ‘security_group_rule_id’<~String> - UUId of the security group rule to delete



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

def delete_security_group_rule(security_group_rule_id)
  request(
    :expects  => 204,
    :method   => 'DELETE',
    :path     => "security-group-rules/#{security_group_rule_id}"
  )
end

#delete_subnet(subnet_id) ⇒ Object

Delete an existing subnet

Parameters

  • subnet_id<~String> - UUId for the subnet to delete



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

def delete_subnet(subnet_id)
  request(
    :expects  => 204,
    :method   => 'DELETE',
    :path     => "subnets/#{subnet_id}"
  )
end

#disassociate_floating_ip(floating_ip_id, options = {}) ⇒ Object

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



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fog/hp/requests/network/disassociate_floating_ip.rb', line 24

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_floating_ip(floating_ip_id) ⇒ Object

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



22
23
24
25
26
27
28
# File 'lib/fog/hp/requests/network/get_floating_ip.rb', line 22

def get_floating_ip(floating_ip_id)
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => "floatingips/#{floating_ip_id}"
  )
end

#get_network(network_id) ⇒ Object

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



25
26
27
28
29
30
31
# File 'lib/fog/hp/requests/network/get_network.rb', line 25

def get_network(network_id)
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => "networks/#{network_id}"
  )
end

#get_port(port_id) ⇒ Object

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



29
30
31
32
33
34
35
# File 'lib/fog/hp/requests/network/get_port.rb', line 29

def get_port(port_id)
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => "ports/#{port_id}"
  )
end

#get_router(router_id) ⇒ Object

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



22
23
24
25
26
27
28
# File 'lib/fog/hp/requests/network/get_router.rb', line 22

def get_router(router_id)
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => "routers/#{router_id}"
  )
end

#get_security_group(security_group_id) ⇒ Object

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



30
31
32
33
34
35
36
# File 'lib/fog/hp/requests/network/get_security_group.rb', line 30

def get_security_group(security_group_id)
  request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "security-groups/#{security_group_id}"
  )
end

#get_security_group_rule(security_group_rule_id) ⇒ Object

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



25
26
27
28
29
30
31
# File 'lib/fog/hp/requests/network/get_security_group_rule.rb', line 25

def get_security_group_rule(security_group_rule_id)
  request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "security-group-rules/#{security_group_rule_id}"
  )
end

#get_subnet(subnet_id) ⇒ Object

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



28
29
30
31
32
33
34
# File 'lib/fog/hp/requests/network/get_subnet.rb', line 28

def get_subnet(subnet_id)
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => "subnets/#{subnet_id}"
  )
end

#list_floating_ips(options = {}) ⇒ Object

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



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

def list_floating_ips(options = {})
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => 'floatingips',
    :query   => options
  )
end

#list_networks(options = {}) ⇒ Object

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



25
26
27
28
29
30
31
32
# File 'lib/fog/hp/requests/network/list_networks.rb', line 25

def list_networks(options = {})
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => 'networks',
    :query   => options
  )
end

#list_ports(options = {}) ⇒ Object

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



29
30
31
32
33
34
35
36
# File 'lib/fog/hp/requests/network/list_ports.rb', line 29

def list_ports(options = {})
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => 'ports',
    :query   => options
  )
end

#list_routers(options = {}) ⇒ Object

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



22
23
24
25
26
27
28
29
# File 'lib/fog/hp/requests/network/list_routers.rb', line 22

def list_routers(options = {})
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => 'routers',
    :query   => options
  )
end

#list_security_group_rules(options = {}) ⇒ Object

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



25
26
27
28
29
30
31
32
# File 'lib/fog/hp/requests/network/list_security_group_rules.rb', line 25

def list_security_group_rules(options = {})
  request(
    :expects  => 200,
    :method   => 'GET',
    :path     => 'security-group-rules',
    :query    => options
  )
end

#list_security_groups(options = {}) ⇒ Object

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



30
31
32
33
34
35
36
37
# File 'lib/fog/hp/requests/network/list_security_groups.rb', line 30

def list_security_groups(options = {})
  request(
    :expects  => 200,
    :method   => 'GET',
    :path     => 'security-groups',
    :query    => options
  )
end

#list_subnets(options = {}) ⇒ Object

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



28
29
30
31
32
33
34
35
# File 'lib/fog/hp/requests/network/list_subnets.rb', line 28

def list_subnets(options = {})
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => 'subnets',
    :query   => options
  )
end

#reloadObject



161
162
163
# File 'lib/fog/hp/network.rb', line 161

def reload
  @connection.reset
end

#remove_router_interface(router_id, subnet_id = nil, port_id = nil, options = {}) ⇒ Object

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



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/hp/requests/network/remove_router_interface.rb', line 18

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

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



165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/fog/hp/network.rb', line 165

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_network(network_id, options = {}) ⇒ Object

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



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fog/hp/requests/network/update_network.rb', line 27

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_port(port_id, options = {}) ⇒ Object

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



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fog/hp/requests/network/update_port.rb', line 37

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_router(router_id, options = {}) ⇒ Object

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



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fog/hp/requests/network/update_router.rb', line 27

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_subnet(subnet_id, options = {}) ⇒ Object

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



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/fog/hp/requests/network/update_subnet.rb', line 34

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