Class: Fog::Network::OpenStack::Mock

Inherits:
Object
  • Object
show all
Includes:
OpenStack::Core
Defined in:
lib/fog/network/openstack.rb,
lib/fog/network/openstack/requests/get_port.rb,
lib/fog/network/openstack/requests/get_quota.rb,
lib/fog/network/openstack/requests/get_lb_vip.rb,
lib/fog/network/openstack/requests/get_quotas.rb,
lib/fog/network/openstack/requests/get_router.rb,
lib/fog/network/openstack/requests/get_subnet.rb,
lib/fog/network/openstack/requests/list_ports.rb,
lib/fog/network/openstack/requests/set_tenant.rb,
lib/fog/network/openstack/requests/create_port.rb,
lib/fog/network/openstack/requests/delete_port.rb,
lib/fog/network/openstack/requests/get_lb_pool.rb,
lib/fog/network/openstack/requests/get_network.rb,
lib/fog/network/openstack/requests/update_port.rb,
lib/fog/network/openstack/requests/delete_quota.rb,
lib/fog/network/openstack/requests/list_lb_vips.rb,
lib/fog/network/openstack/requests/list_routers.rb,
lib/fog/network/openstack/requests/list_subnets.rb,
lib/fog/network/openstack/requests/update_quota.rb,
lib/fog/network/openstack/requests/create_lb_vip.rb,
lib/fog/network/openstack/requests/create_router.rb,
lib/fog/network/openstack/requests/create_subnet.rb,
lib/fog/network/openstack/requests/delete_lb_vip.rb,
lib/fog/network/openstack/requests/delete_router.rb,
lib/fog/network/openstack/requests/delete_subnet.rb,
lib/fog/network/openstack/requests/get_extension.rb,
lib/fog/network/openstack/requests/get_lb_member.rb,
lib/fog/network/openstack/requests/list_lb_pools.rb,
lib/fog/network/openstack/requests/list_networks.rb,
lib/fog/network/openstack/requests/update_lb_vip.rb,
lib/fog/network/openstack/requests/update_router.rb,
lib/fog/network/openstack/requests/update_subnet.rb,
lib/fog/network/openstack/requests/create_lb_pool.rb,
lib/fog/network/openstack/requests/create_network.rb,
lib/fog/network/openstack/requests/delete_lb_pool.rb,
lib/fog/network/openstack/requests/delete_network.rb,
lib/fog/network/openstack/requests/get_ike_policy.rb,
lib/fog/network/openstack/requests/get_lbaas_pool.rb,
lib/fog/network/openstack/requests/update_lb_pool.rb,
lib/fog/network/openstack/requests/update_network.rb,
lib/fog/network/openstack/requests/get_floating_ip.rb,
lib/fog/network/openstack/requests/get_rbac_policy.rb,
lib/fog/network/openstack/requests/get_subnet_pool.rb,
lib/fog/network/openstack/requests/get_vpn_service.rb,
lib/fog/network/openstack/requests/list_extensions.rb,
lib/fog/network/openstack/requests/list_lb_members.rb,
lib/fog/network/openstack/requests/create_lb_member.rb,
lib/fog/network/openstack/requests/delete_lb_member.rb,
lib/fog/network/openstack/requests/get_ipsec_policy.rb,
lib/fog/network/openstack/requests/get_lbaas_l7rule.rb,
lib/fog/network/openstack/requests/list_lbaas_pools.rb,
lib/fog/network/openstack/requests/update_lb_member.rb,
lib/fog/network/openstack/requests/create_ike_policy.rb,
lib/fog/network/openstack/requests/create_lbaas_pool.rb,
lib/fog/network/openstack/requests/delete_ike_policy.rb,
lib/fog/network/openstack/requests/delete_lbaas_pool.rb,
lib/fog/network/openstack/requests/get_lb_pool_stats.rb,
lib/fog/network/openstack/requests/list_floating_ips.rb,
lib/fog/network/openstack/requests/list_ike_policies.rb,
lib/fog/network/openstack/requests/list_subnet_pools.rb,
lib/fog/network/openstack/requests/list_vpn_services.rb,
lib/fog/network/openstack/requests/update_ike_policy.rb,
lib/fog/network/openstack/requests/update_lbaas_pool.rb,
lib/fog/network/openstack/requests/create_floating_ip.rb,
lib/fog/network/openstack/requests/create_rbac_policy.rb,
lib/fog/network/openstack/requests/create_subnet_pool.rb,
lib/fog/network/openstack/requests/create_vpn_service.rb,
lib/fog/network/openstack/requests/delete_floating_ip.rb,
lib/fog/network/openstack/requests/delete_rbac_policy.rb,
lib/fog/network/openstack/requests/delete_subnet_pool.rb,
lib/fog/network/openstack/requests/delete_vpn_service.rb,
lib/fog/network/openstack/requests/get_lbaas_l7policy.rb,
lib/fog/network/openstack/requests/get_lbaas_listener.rb,
lib/fog/network/openstack/requests/get_security_group.rb,
lib/fog/network/openstack/requests/list_lbaas_l7rules.rb,
lib/fog/network/openstack/requests/list_rbac_policies.rb,
lib/fog/network/openstack/requests/update_rbac_policy.rb,
lib/fog/network/openstack/requests/update_subnet_pool.rb,
lib/fog/network/openstack/requests/update_vpn_service.rb,
lib/fog/network/openstack/requests/create_ipsec_policy.rb,
lib/fog/network/openstack/requests/create_lbaas_l7rule.rb,
lib/fog/network/openstack/requests/delete_ipsec_policy.rb,
lib/fog/network/openstack/requests/delete_lbaas_l7rule.rb,
lib/fog/network/openstack/requests/list_ipsec_policies.rb,
lib/fog/network/openstack/requests/update_ipsec_policy.rb,
lib/fog/network/openstack/requests/update_lbaas_l7rule.rb,
lib/fog/network/openstack/requests/add_router_interface.rb,
lib/fog/network/openstack/requests/list_lbaas_listeners.rb,
lib/fog/network/openstack/requests/list_security_groups.rb,
lib/fog/network/openstack/requests/associate_floating_ip.rb,
lib/fog/network/openstack/requests/create_lbaas_l7policy.rb,
lib/fog/network/openstack/requests/create_lbaas_listener.rb,
lib/fog/network/openstack/requests/create_security_group.rb,
lib/fog/network/openstack/requests/delete_lbaas_l7policy.rb,
lib/fog/network/openstack/requests/delete_lbaas_listener.rb,
lib/fog/network/openstack/requests/delete_security_group.rb,
lib/fog/network/openstack/requests/get_lb_health_monitor.rb,
lib/fog/network/openstack/requests/get_lbaas_pool_member.rb,
lib/fog/network/openstack/requests/list_lbaas_l7policies.rb,
lib/fog/network/openstack/requests/update_lbaas_l7policy.rb,
lib/fog/network/openstack/requests/update_lbaas_listener.rb,
lib/fog/network/openstack/requests/update_security_group.rb,
lib/fog/network/openstack/requests/get_lbaas_loadbalancer.rb,
lib/fog/network/openstack/requests/get_lbaas_healthmonitor.rb,
lib/fog/network/openstack/requests/get_security_group_rule.rb,
lib/fog/network/openstack/requests/list_lb_health_monitors.rb,
lib/fog/network/openstack/requests/list_lbaas_pool_members.rb,
lib/fog/network/openstack/requests/remove_router_interface.rb,
lib/fog/network/openstack/requests/create_lb_health_monitor.rb,
lib/fog/network/openstack/requests/create_lbaas_pool_member.rb,
lib/fog/network/openstack/requests/delete_lb_health_monitor.rb,
lib/fog/network/openstack/requests/delete_lbaas_pool_member.rb,
lib/fog/network/openstack/requests/disassociate_floating_ip.rb,
lib/fog/network/openstack/requests/list_lbaas_loadbalancers.rb,
lib/fog/network/openstack/requests/update_lb_health_monitor.rb,
lib/fog/network/openstack/requests/update_lbaas_pool_member.rb,
lib/fog/network/openstack/requests/create_lbaas_loadbalancer.rb,
lib/fog/network/openstack/requests/delete_lbaas_loadbalancer.rb,
lib/fog/network/openstack/requests/get_ipsec_site_connection.rb,
lib/fog/network/openstack/requests/list_lbaas_healthmonitors.rb,
lib/fog/network/openstack/requests/list_security_group_rules.rb,
lib/fog/network/openstack/requests/update_lbaas_loadbalancer.rb,
lib/fog/network/openstack/requests/create_lbaas_healthmonitor.rb,
lib/fog/network/openstack/requests/create_security_group_rule.rb,
lib/fog/network/openstack/requests/delete_lbaas_healthmonitor.rb,
lib/fog/network/openstack/requests/delete_security_group_rule.rb,
lib/fog/network/openstack/requests/update_lbaas_healthmonitor.rb,
lib/fog/network/openstack/requests/associate_lb_health_monitor.rb,
lib/fog/network/openstack/requests/get_network_ip_availability.rb,
lib/fog/network/openstack/requests/list_ipsec_site_connections.rb,
lib/fog/network/openstack/requests/create_ipsec_site_connection.rb,
lib/fog/network/openstack/requests/delete_ipsec_site_connection.rb,
lib/fog/network/openstack/requests/update_ipsec_site_connection.rb,
lib/fog/network/openstack/requests/disassociate_lb_health_monitor.rb,
lib/fog/network/openstack/requests/list_network_ip_availabilities.rb

Instance Attribute Summary

Attributes included from OpenStack::Core

#auth_token, #auth_token_expiration, #current_tenant, #current_user, #current_user_id, #openstack_cache_ttl, #openstack_domain_id, #openstack_domain_name, #openstack_identity_prefix, #openstack_project_domain, #openstack_project_domain_id, #openstack_project_id, #openstack_user_domain, #openstack_user_domain_id, #unscoped_token

Class Method Summary collapse

Instance Method Summary collapse

Methods included from OpenStack::Core

#credentials, #initialize_identity, not_found_class, #reload

Constructor Details

#initialize(options = {}) ⇒ Mock

Returns a new instance of Mock.



429
430
431
432
433
434
# File 'lib/fog/network/openstack.rb', line 429

def initialize(options = {})
  @auth_token = Fog::Mock.random_base64(64)
  @auth_token_expiration = (Time.now.utc + 86400).iso8601

  initialize_identity options
end

Class Method Details

.dataObject



265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
# File 'lib/fog/network/openstack.rb', line 265

def self.data
  @data ||= Hash.new do |hash, key|
    qos_policy_id = Fog::UUID.uuid
    network_id   = Fog::UUID.uuid
    extension_id = Fog::UUID.uuid
    subnet_id    = Fog::UUID.uuid
    tenant_id    = Fog::Mock.random_hex(8)

    hash[key] = {
      :extensions             => {
        extension_id => {
          'id'          => extension_id,
          'alias'       => 'dvr',
          'description' => 'Enables configuration of Distributed Virtual Routers.',
          'links'       => [],
          'name'        => 'Distributed Virtual Router'
        }
      },
      :networks               => {
        network_id                => {
          'id'                    => network_id,
          'name'                  => 'Public',
          'subnets'               => [subnet_id],
          'shared'                => true,
          'status'                => 'ACTIVE',
          'tenant_id'             => tenant_id,
          'provider:network:type' => 'vlan',
          'router:external'       => false,
          'admin_state_up'        => true,
          'qos_policy_id'         => qos_policy_id,
          'port_security_enabled' => true
        },
        'e624a36d-762b-481f-9b50-4154ceb78bbb' => {
          'id'                    => 'e624a36d-762b-481f-9b50-4154ceb78bbb',
          'name'                  => 'network_1',
          'subnets'               => ['2e4ec6a4-0150-47f5-8523-e899ac03026e'],
          'shared'                => false,
          'status'                => 'ACTIVE',
          'tenant_id'             => 'f8b26a6032bc47718a7702233ac708b9',
          'provider:network:type' => 'vlan',
          'router:external'       => false,
          'admin_state_up'        => true,
          'qos_policy_id'         => qos_policy_id,
          'port_security_enabled' => true
        }
      },
      :ports                  => {},
      :subnets                => {
        subnet_id => {
          'id'               => subnet_id,
          'name'             => "Public",
          'network_id'       => network_id,
          'cidr'             => "192.168.0.0/22",
          'ip_version'       => 4,
          'gateway_ip'       => Fog::Mock.random_ip,
          'allocation_pools' => [],
          'dns_nameservers'  => [Fog::Mock.random_ip, Fog::Mock.random_ip],
          'host_routes'      => [Fog::Mock.random_ip],
          'enable_dhcp'      => true,
          'tenant_id'        => tenant_id,
        }
      },
      :subnet_pools           => {},
      :floating_ips           => {},
      :routers                => {},
      :lb_pools               => {},
      :lb_members             => {},
      :lb_health_monitors     => {},
      :lb_vips                => {},
      :lbaas_loadbalancers    => {},
      :lbaas_listeners        => {},
      :lbaas_pools            => {},
      :lbaas_pool_members     => {},
      :lbaas_health_monitorss => {},
      :lbaas_l7policies       => {},
      :lbaas_l7rules          => {},
      :vpn_services           => {},
      :ike_policies           => {},
      :ipsec_policies         => {},
      :ipsec_site_connections => {},
      :rbac_policies          => {},
      :quota                  => {
        "subnet"     => 10,
        "router"     => 10,
        "port"       => 50,
        "network"    => 10,
        "floatingip" => 50
      },
      :quotas                 => [
        {
          "subnet"     => 10,
          "network"    => 10,
          "floatingip" => 50,
          "tenant_id"  => tenant_id,
          "router"     => 10,
          "port"       => 30
        }
      ],
      :security_groups            => {},
      :security_group_rules       => {},
      :network_ip_availabilities  => [
        {
          "network_id"              => "4cf895c9-c3d1-489e-b02e-59b5c8976809",
          "network_name"            => "public",
          "subnet_ip_availability"  => [
            {
              "cidr"          => "2001:db8::/64",
              "ip_version"    => 6,
              "subnet_id"     => "ca3f46c4-c6ff-4272-9be4-0466f84c6077",
              "subnet_name"   => "ipv6-public-subnet",
              "total_ips"     => 18446744073709552000,
              "used_ips"      => 1
            },
            {
              "cidr"          => "172.24.4.0/24",
              "ip_version"    => 4,
              "subnet_id"     => "cc02efc1-9d47-46bd-bab6-760919c836b5",
              "subnet_name"   => "public-subnet",
              "total_ips"     => 253,
              "used_ips"      => 1
            }
          ],
          "project_id"  => "1a02cc95f1734fcc9d3c753818f03002",
          "tenant_id"   => "1a02cc95f1734fcc9d3c753818f03002",
          "total_ips"   => 253,
          "used_ips"    => 2
        },
        {
          "network_id"              => "6801d9c8-20e6-4b27-945d-62499f00002e",
          "network_name"            => "private",
          "subnet_ip_availability"  => [
            {
              "cidr"        => "10.0.0.0/24",
              "ip_version"  => 4,
              "subnet_id"   => "44e70d00-80a2-4fb1-ab59-6190595ceb61",
              "subnet_name" => "private-subnet",
              "total_ips"   => 253,
              "used_ips"    => 2
            },
            {
              "ip_version"  => 6,
              "cidr"        => "fdbf:ac66:9be8::/64",
              "subnet_id"   => "a90623df-00e1-4902-a675-40674385d74c",
              "subnet_name" => "ipv6-private-subnet",
              "total_ips"   => 18446744073709552000,
              "used_ips"    => 2
            }
          ],
          "project_id"  => "d56d3b8dd6894a508cf41b96b522328c",
          "tenant_id"   => "d56d3b8dd6894a508cf41b96b522328c",
          "total_ips"   => 18446744073709552000,
          "used_ips"    => 4
        }
      ]
    }
  end
end

.resetObject



423
424
425
# File 'lib/fog/network/openstack.rb', line 423

def self.reset
  @data = nil
end

Instance Method Details

#add_router_interface(_router_id, _subnet_id, _options = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fog/network/openstack/requests/add_router_interface.rb', line 26

def add_router_interface(_router_id, _subnet_id, _options = {})
  response = Excon::Response.new
  response.status = 201
  data = {
    'status'         => 'ACTIVE',
    'name'           => '',
    'admin_state_up' => true,
    'network_id'     => '5307648b-e836-4658-8f1a-ff7536870c64',
    'tenant_id'      => '6b96ff0cb17a4b859e1e575d221683d3',
    'device_owner'   => 'network:router_interface',
    'mac_address'    => 'fa:16:3e:f7:d1:9c',
    'fixed_ips'      => {
      'subnet_id'  => 'a2f1f29d-571b-4533-907f-5803ab96ead1',
      'ip_address' => '10.1.1.1'
    },
    'id'             => '3a44f4e5-1694-493a-a1fb-393881c673a4',
    'device_id'      => '7177abc4-5ae9-4bb7-b0d4-89e94a4abf3b'
  }

  self.data[:routers][data['router_id']] = data
  response.body = {'router' => data}
  response
end

#associate_floating_ip(_floating_ip_id, port_id, options = {}) ⇒ Object



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

def associate_floating_ip(_floating_ip_id, port_id, options = {})
  response = Excon::Response.new
  response.status = 201
  data = {
    'id'                  => '00000000-0000-0000-0000-000000000000',
    'router_id'           => '00000000-0000-0000-0000-000000000000',
    'tenant_id'           => options["tenant_id"],
    'floating_network_id' => options["floating_network_id"],
    'fixed_ip_address'    => options["fixed_ip_address"],
    'floating_ip_address' => options["floating_ip_address"],
    'port_id'             => port_id,
  }

  self.data[:floating_ips][data['floating_ip_id']] = data
  response.body = {'floatingip' => data}
  response
end

#associate_lb_health_monitor(pool_id, health_monitor_id) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fog/network/openstack/requests/associate_lb_health_monitor.rb', line 22

def associate_lb_health_monitor(pool_id, health_monitor_id)
  response = Excon::Response.new
  if pool = list_lb_pools.body['pools'].find { |_| _['id'] == pool_id }
    pool['health_monitors'] << health_monitor_id
    data[:lb_pools][pool_id] = pool
    response.body = {'health_monitor' => {}}
    response.status = 200
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#create_floating_ip(floating_network_id, options = {}) ⇒ Object



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

def create_floating_ip(floating_network_id, options = {})
  response = Excon::Response.new
  response.status = 201
  data = {
    'id'                  => floating_network_id,
    'floating_network_id' => floating_network_id,
    'port_id'             => options[:port_id],
    'tenant_id'           => options[:tenant_id],
    'fixed_ip_address'    => options[:fixed_ip_address],
    'router_id'           => nil,
  }
  self.data[:floating_ips][data['id']] = data
  response.body = {'floatingip' => data}
  response
end

#create_ike_policy(options = {}) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fog/network/openstack/requests/create_ike_policy.rb', line 29

def create_ike_policy(options = {})
  response = Excon::Response.new
  response.status = 201
  data = {
    'id'                      => Fog::Mock.random_numbers(6).to_s,
    'name'                    => options[:name],
    'description'             => options[:description],
    'tenant_id'               => options[:tenant_id],
    'auth_algorithm'          => options[:auth_algorithm],
    'encryption_algorithm'    => options[:encryption_algorithm],
    'pfs'                     => options[:pfs],
    'phase1_negotiation_mode' => options[:phase1_negotiation_mode],
    'lifetime'                => options[:lifetime],
    'ike_version'             => options[:ike_version]
  }

  self.data[:ike_policies][data['id']] = data
  response.body = {'ikepolicy' => data}
  response
end

#create_ipsec_policy(options = {}) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fog/network/openstack/requests/create_ipsec_policy.rb', line 29

def create_ipsec_policy(options = {})
  response = Excon::Response.new
  response.status = 201
  data = {
    'id'                   => Fog::Mock.random_numbers(6).to_s,
    'name'                 => options[:name],
    'description'          => options[:description],
    'tenant_id'            => options[:tenant_id],
    'auth_algorithm'       => options[:auth_algorithm],
    'encryption_algorithm' => options[:encryption_algorithm],
    'pfs'                  => options[:pfs],
    'transform_protocol'   => options[:transform_protocol],
    'lifetime'             => options[:lifetime],
    'encapsulation_mode'   => options[:encapsulation_mode]
  }

  self.data[:ipsec_policies][data['id']] = data
  response.body = {'ipsecpolicy' => data}
  response
end

#create_ipsec_site_connection(vpn_service_id, ike_policy_id, ipsec_policy_id, options = {}) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/fog/network/openstack/requests/create_ipsec_site_connection.rb', line 32

def create_ipsec_site_connection(vpn_service_id, ike_policy_id, ipsec_policy_id, options = {})
  response = Excon::Response.new
  response.status = 201
  data = {
    'id'                => Fog::Mock.random_numbers(6).to_s,
    'name'              => options[:name],
    'description'       => options[:description],
    'status'            => 'ACTIVE',
    'tenant_id'         => options[:tenant_id],
    'admin_state_up'    => options[:admin_state_up],
    'psk'               => options[:psk],
    'initiator'         => options[:initiator],
    'auth_mode'         => "psk",
    'peer_cidrs'        => options[:peer_cidrs],
    'mtu'               => options[:mtu],
    'peer_ep_group_id'  => Fog::Mock.random_numbers(6).to_s,
    'ikepolicy_id'      => ike_policy_id,
    'vpnservice_id'     => vpn_service_id,
    'dpd'               => options[:dpd],
    'route_mode'        => "static",
    'ipsecpolicy_id'    => ipsec_policy_id,
    'local_ep_group_id' => Fog::Mock.random_numbers(6).to_s,
    'peer_address'      => options[:peer_address],
    'peer_id'           => options[:peer_id]
  }

  self.data[:ipsec_site_connections][data['id']] = data
  response.body = {'ipsec_site_connection' => data}
  response
end

#create_lb_health_monitor(type, delay, timeout, max_retries, options = {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fog/network/openstack/requests/create_lb_health_monitor.rb', line 30

def create_lb_health_monitor(type, delay, timeout, max_retries, options = {})
  response = Excon::Response.new
  response.status = 201
  data = {
    'id'             => Fog::Mock.random_numbers(6).to_s,
    'type'           => type,
    'delay'          => delay,
    'timeout'        => timeout,
    'max_retries'    => max_retries,
    'http_method'    => options[:http_method],
    'url_path'       => options[:url_path],
    'expected_codes' => options[:expected_codes],
    'status'         => 'ACTIVE',
    'admin_state_up' => options[:admin_state_up],
    'tenant_id'      => options[:tenant_id],
  }

  self.data[:lb_health_monitors][data['id']] = data
  response.body = {'health_monitor' => data}
  response
end

#create_lb_member(pool_id, address, protocol_port, weight, options = {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fog/network/openstack/requests/create_lb_member.rb', line 30

def create_lb_member(pool_id, address, protocol_port, weight, options = {})
  response = Excon::Response.new
  response.status = 201
  data = {
    'id'             => Fog::Mock.random_numbers(6).to_s,
    'pool_id'        => pool_id,
    'address'        => address,
    'protocol_port'  => protocol_port,
    'weight'         => weight,
    'status'         => 'ACTIVE',
    'admin_state_up' => options[:admin_state_up],
    'tenant_id'      => options[:tenant_id],
  }

  self.data[:lb_members][data['id']] = data
  response.body = {'member' => data}
  response
end

#create_lb_pool(subnet_id, protocol, lb_method, options = {}) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/fog/network/openstack/requests/create_lb_pool.rb', line 29

def create_lb_pool(subnet_id, protocol, lb_method, options = {})
  response = Excon::Response.new
  response.status = 201
  data = {
    'id'                 => Fog::Mock.random_numbers(6).to_s,
    'subnet_id'          => subnet_id,
    'protocol'           => protocol,
    'lb_method'          => lb_method,
    'name'               => options[:name],
    'description'        => options[:description],
    'health_monitors'    => [],
    'members'            => [],
    'status'             => 'ACTIVE',
    'admin_state_up'     => options[:admin_state_up],
    'vip_id'             => nil,
    'tenant_id'          => options[:tenant_id],
    'active_connections' => nil,
    'bytes_in'           => nil,
    'bytes_out'          => nil,
    'total_connections'  => nil
  }

  self.data[:lb_pools][data['id']] = data
  response.body = {'pool' => data}
  response
end

#create_lb_vip(subnet_id, pool_id, protocol, protocol_port, options = {}) ⇒ Object



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

def create_lb_vip(subnet_id,  pool_id, protocol, protocol_port, options = {})
  response = Excon::Response.new
  response.status = 201
  data = {
    'id'                  => Fog::Mock.random_numbers(6).to_s,
    'subnet_id'           => subnet_id,
    'pool_id'             => pool_id,
    'protocol'            => protocol,
    'protocol_port'       => protocol_port,
    'name'                => options[:name],
    'description'         => options[:description],
    'address'             => options[:address],
    'port_id'             => Fog::Mock.random_numbers(6).to_s,
    'session_persistence' => options[:session_persistence],
    'connection_limit'    => options[:connection_limit],
    'status'              => 'ACTIVE',
    'admin_state_up'      => options[:admin_state_up],
    'tenant_id'           => options[:tenant_id],
  }

  self.data[:lb_vips][data['id']] = data
  response.body = {'vip' => data}
  response
end

#create_lbaas_healthmonitor(type, delay, timeout, max_retries, options = {}) ⇒ Object



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

def create_lbaas_healthmonitor(type, delay, timeout, max_retries, options = {})
  response = Excon::Response.new
  response.status = 201
  data = {
    'id'             => Fog::Mock.random_numbers(6).to_s,
    'type'           => type,
    'delay'          => delay,
    'timeout'        => timeout,
    'max_retries'    => max_retries,
    'http_method'    => options[:http_method],
    'url_path'       => options[:url_path],
    'expected_codes' => options[:expected_codes],
    'status'         => 'ACTIVE',
    'admin_state_up' => options[:admin_state_up],
    'tenant_id'      => options[:tenant_id],
    'name'           => options[:name],
    'pools'          => [{ 'id'=> Fog::Mock.random_numbers(6).to_s}]
  }

  self.data[:lbaas_healthmonitors][data['id']] = data
  response.body = {'healthmonitor' => data}
  response
end

#create_lbaas_l7policy(listener_id, action, options = {}) ⇒ Object



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

def create_lbaas_l7policy(listener_id, action, options = {})
  response = Excon::Response.new
  response.status = 201
  data = {
    'id'              => Fog::Mock.random_numbers(6).to_s,
    'listener_id'     => listener_id,
    'action'          => action,
    'position'        => options[:position],
    'tenant_id'       => options[:tenant_id],
    'name'            => options[:name],
    'description'     => options[:description],
    'redirect_pool_id'   => options[:redirect_pool_id],
    'redirect_url'    => options[:redirect_url]
  }

  self.data[:lbaas_l7policies][data['id']] = data
  response.body = {'l7policy' => data}
  response
end

#create_lbaas_l7rule(l7policy_id, type, compare_type, value, options = {}) ⇒ Object



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

def create_lbaas_l7rule(l7policy_id, type, compare_type, value, options = {})
  response = Excon::Response.new
  response.status = 201
  data = {
    'id'              => Fog::Mock.random_numbers(6).to_s,
    'type'            => type,
    'compare_type'    => compare_type,
    'value'           => value,
    'tenant_id'       => options[:tenant_id],
    'key'             => options[:key],
    'invert'          => options[:invert],
    'l7policy_id'     => l7policy_id
  }

  self.data[:lbaas_l7rules][data['id']] = data
  response.body = {'rule' => data}
  response
end

#create_lbaas_listener(loadbalancer_id, protocol, protocol_port, options = {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/fog/network/openstack/requests/create_lbaas_listener.rb', line 30

def create_lbaas_listener(loadbalancer_id, protocol, protocol_port, options = {})
  response = Excon::Response.new
  response.status = 201
  data = {
    'id'                      => Fog::Mock.random_numbers(6).to_s,
    'loadbalancers'           =>  [{'id' =>  loadbalancer_id }],
    'protocol'                => protocol,
    'protocol_port'           => protocol_port,
    'name'                    => options[:name],
    'description'             => options[:description],
    'default_pool_id'         => options[:default_pool_id],
    'connection_limit'        => options[:connection_limit],
    'default_tls_container_ref' => options[:default_tls_container_ref],
    'sni_container_refs'      => options[:sni_container_refs],
    'admin_state_up'          => options[:admin_state_up],
    'tenant_id'               => options[:tenant_id]
  }

  self.data[:lbaas_listener][data['id']] = data
  response.body = {'listener' => data}
  response
end

#create_lbaas_loadbalancer(vip_subnet_id, options = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fog/network/openstack/requests/create_lbaas_loadbalancer.rb', line 26

def create_lbaas_loadbalancer(vip_subnet_id, options = {})
  response = Excon::Response.new
  response.status = 201
  data = {
      'id' => Fog::Mock.random_numbers(6).to_s,
      'subnet_id' => vip_subnet_id,
      'name' => options[:name],
      'description' => options[:description],
      'vip_address' => options[:vip_address],
      'vip_port_id'=> Fog::Mock.random_numbers(6).to_s,
      'vip_subnet_id'=> vip_subnet_id,
      'flavor' => options[:flavor],
      'admin_state_up' => options[:admin_state_up],
      'tenant_id' => options[:tenant_id],
      'listeners'=> [{ 'id'=> Fog::Mock.random_numbers(6).to_s}],
      'operating_status'=> 'ONLINE',
      'provider'=> 'lbprovider',
      'provisioning_status'=> 'ACTIVE'
  }
  self.data[:lbaas_loadbalancer][data['id']] = data
  response.body = {'loadbalancer' => data}
  response
end

#create_lbaas_pool(listener_id, protocol, lb_algorithm, options = {}) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/fog/network/openstack/requests/create_lbaas_pool.rb', line 29

def create_lbaas_pool(listener_id, protocol, lb_algorithm, options = {})
  response = Excon::Response.new
  response.status = 201
  data = {
    'id'                 => Fog::Mock.random_numbers(6).to_s,
    'protocol'           => protocol,
    'lb_algorithm'       => lb_algorithm,
    'name'               => options[:name],
    'description'        => options[:description],
    'healthmonitor_id'   => Fog::Mock.random_numbers(6).to_s,
    'members'            => [Fog::Mock.random_numbers(6).to_s],
    'status'             => 'ACTIVE',
    'admin_state_up'     => options[:admin_state_up],
    'tenant_id'          => options[:tenant_id],
    'listeners'          => [ 'id' => listener_id ],
    'session_persistence' => {}
  }
  self.data[:lbaas_pools][data['id']] = data
  response.body = {'pool' => data}
  response
end

#create_lbaas_pool_member(pool_id, address, protocol_port, options = {}) ⇒ Object



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

def create_lbaas_pool_member(pool_id, address, protocol_port, options = {})
  response = Excon::Response.new
  response.status = 201
  data = {
      'id'              => Fog::Mock.random_numbers(6).to_s,
      'pool_id'         => pool_id,
      'address'         => address,
      'protocol_port'   => protocol_port,
      'weight'          => options[:weight],
      'status'          => 'ACTIVE',
      'admin_state_up'  => options[:admin_state_up],
      'tenant_id'       => options[:tenant_id],
      'subnet_id'       => ptions[:subnet_id]
  }
  self.data[:lb_members][data['id']] = data
  response.body = {'member' => data}
  response
end

#create_network(options = {}) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/fog/network/openstack/requests/create_network.rb', line 66

def create_network(options = {})
  response = Excon::Response.new
  response.status = 201
  data = {
    'id'                    => Fog::Mock.random_numbers(6).to_s,
    'name'                  => options[:name],
    'shared'                => options[:shared] || false,
    'subnets'               => [],
    'status'                => 'ACTIVE',
    'admin_state_up'        => options[:admin_state_up] || false,
    'tenant_id'             => options[:tenant_id],
    'qos_policy_id'         => options[:qos_policy_id],
    'port_security_enabled' => options[:port_security_enabled] || false
  }
  data.merge!(Fog::Network::OpenStack::Real.create(options))
  self.data[:networks][data['id']] = data
  response.body = {'network' => data}
  response
end

#create_port(network_id, options = {}) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/fog/network/openstack/requests/create_port.rb', line 29

def create_port(network_id, options = {})
  response = Excon::Response.new
  response.status = 201
  data = {
    'id'                    => Fog::Mock.random_numbers(6).to_s,
    'name'                  => options[:name],
    'network_id'            => network_id,
    'fixed_ips'             => options[:fixed_ips],
    'mac_address'           => options[:mac_address],
    'status'                => 'ACTIVE',
    'admin_state_up'        => options[:admin_state_up],
    'device_owner'          => options[:device_owner],
    'device_id'             => options[:device_id],
    'tenant_id'             => options[:tenant_id],
    'security_groups'       => options[:security_groups],
    'allowed_address_pairs' => options[:allowed_address_pairs],
  }
  self.data[:ports][data['id']] = data
  response.body = {'port' => data}
  response
end

#create_rbac_policy(options = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fog/network/openstack/requests/create_rbac_policy.rb', line 23

def create_rbac_policy(options = {})
  response = Excon::Response.new
  response.status = 201
  data = {
    'id'            => Fog::Mock.random_numbers(6).to_s,
    'object_type'   => options[:object_type],
    'object_id'     => options[:object_id],
    'tenant_id'     => options[:tenant_id],
    'target_tenant' => options[:target_tenant],
    'action'        => options[:action]
  }

  self.data[:rbac_policies][data['id']] = data
  response.body = {'rbac_policy' => data}
  response
end

#create_router(name, options = {}) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/fog/network/openstack/requests/create_router.rb', line 47

def create_router(name, options = {})
  response = Excon::Response.new
  response.status = 201

  # remove this in a future
  egi = options[:external_gateway_info]
  if egi && egi.kind_of?(Fog::Network::OpenStack::Network)
    Fog::Logger.deprecation "Passing a model objects into options[:external_gateway_info] is deprecated. \
    Please pass  external external gateway as follows options[:external_gateway_info] = { :network_id => NETWORK_ID }]"
    egi = {:network_id => egi.id}
  end

  data = {
    'router' => {
      :id                    => Fog::Mock.random_numbers(6).to_s,
      :status                => options[:status] || 'ACTIVE',
      :external_gateway_info => egi,
      :name                  => name,
      :admin_state_up        => options[:admin_state_up],
      :tenant_id             => '6b96ff0cb17a4b859e1e575d221683d3'
    }
  }
  self.data[:routers][data['router'][:id]] = data['router']
  response.body = data
  response
end

#create_security_group(options = {}) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/fog/network/openstack/requests/create_security_group.rb', line 48

def create_security_group(options = {})
  # Spaces are NOT removed from name and description, as in case of compute sec groups
  tenant_id     = Fog::Mock.random_numbers(14).to_s
  sec_group_id  = Fog::UUID.uuid

  response = Excon::Response.new
  response.status = 201
  # by default every security group will come setup with an egress rule to "allow all out"
  data = {
    "security_group_rules" => [
      {"remote_group_id"   => nil,
       "direction"         => "egress",
       "remote_ip_prefix"  => nil,
       "protocol"          => nil,
       "ethertype"         => "IPv4",
       "tenant_id"         => tenant_id,
       "port_range_max"    => nil,
       "port_range_min"    => nil,
       "id"                => Fog::UUID.uuid,
       "security_group_id" => sec_group_id},
      {"remote_group_id"   => nil,
       "direction"         => "egress",
       "remote_ip_prefix"  => nil,
       "protocol"          => nil,
       "ethertype"         => "IPv6",
       "tenant_id"         => tenant_id,
       "port_range_max"    => nil,
       "port_range_min"    => nil,
       "id"                => Fog::UUID.uuid,
       "security_group_id" => sec_group_id}
    ],
    "id"                   => sec_group_id,
    "tenant_id"            => tenant_id,
    "name"                 => options[:name] || "",
    "description"          => options[:description] || ""
  }

  self.data[:security_groups][data["id"]] = data
  response.body = {"security_group" => data}
  response
end

#create_security_group_rule(security_group_id, direction, options = {}) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/fog/network/openstack/requests/create_security_group_rule.rb', line 57

def create_security_group_rule(security_group_id, direction, options = {})
  response = Excon::Response.new
  data = {
    "id"                => Fog::UUID.uuid,
    "remote_group_id"   => options[:remote_group_id],
    "direction"         => direction,
    "remote_ip_prefix"  => options[:remote_ip_prefix],
    "protocol"          => options[:protocol],
    "ethertype"         => options[:ethertype] || "IPv4",
    "tenant_id"         => options[:tenant_id] || Fog::Mock.random_numbers(14).to_s,
    "port_range_max"    => options[:port_range_max],
    "port_range_min"    => options[:port_range_min],
    "security_group_id" => security_group_id
  }
  self.data[:security_group_rules][data["id"]] = data
  response.status = 201
  response.body   = {"security_group_rule" => data}
  response
end

#create_subnet(network_id, cidr, ip_version, options = {}) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fog/network/openstack/requests/create_subnet.rb', line 31

def create_subnet(network_id, cidr, ip_version, options = {})
  response = Excon::Response.new
  response.status = 201
  data = {
    'id'               => Fog::Mock.random_numbers(6).to_s,
    'name'             => options[:name],
    'network_id'       => network_id,
    'cidr'             => cidr,
    'ip_version'       => ip_version,
    'gateway_ip'       => options[:gateway_ip],
    'allocation_pools' => options[:allocation_pools],
    'dns_nameservers'  => options[:dns_nameservers],
    'host_routes'      => options[:host_routes],
    'enable_dhcp'      => options[:enable_dhcp],
    'tenant_id'        => options[:tenant_id]
  }
  self.data[:subnets][data['id']] = data
  response.body = {'subnet' => data}
  response
end

#create_subnet_pool(name, prefixes, options = {}) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fog/network/openstack/requests/create_subnet_pool.rb', line 29

def create_subnet_pool(name, prefixes, options = {})
  response = Excon::Response.new
  response.status = 201
  data = {
    'id'                => Fog::Mock.random_numbers(6).to_s,
    'name'              => name,
    'prefixes'          => prefixes,
    'description'       => options[:description],
    'min_prefixlen'     => options[:min_prefixlen] || 64,
    'max_prefixlen'     => options[:max_prefixlen] || 64,
    'default_prefixlen' => options[:default_prefixlen] || 64,
    'address_scope_id'  => options[:address_scope_id],
    'default_quota'     => options[:default_quota],
    'ip_version'        => options[:ip_version] || 4,
    'shared'            => options[:shared].nil? ? false : options[:shared],
    'is_default'        => options[:is_default].nil? ? false : options[:is_default],
    'created_at'        => Time.now.to_s,
    'updated_at'        => Time.now.to_s,
    'tenant_id'         => Fog::Mock.random_hex(8).to_s
  }
  self.data[:subnet_pools][data['id']] = data
  response.body = {'subnetpool' => data}
  response
end

#create_vpn_service(subnet_id, router_id, options = {}) ⇒ Object



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

def create_vpn_service(subnet_id, router_id, options = {})
  response = Excon::Response.new
  response.status = 201
  data = {
    'id'             => Fog::Mock.random_numbers(6).to_s,
    'subnet_id'      => subnet_id,
    'router_id'      => router_id,
    'name'           => options[:name],
    'description'    => options[:description],
    'status'         => 'ACTIVE',
    'admin_state_up' => options[:admin_state_up],
    'tenant_id'      => options[:tenant_id],
    'external_v4_ip' => '1.2.3.4',
    'external_v6_ip' => '::1'
  }

  self.data[:vpn_services][data['id']] = data
  response.body = {'vpnservice' => data}
  response
end

#dataObject



436
437
438
# File 'lib/fog/network/openstack.rb', line 436

def data
  self.class.data["#{@openstack_username}-#{@openstack_tenant}"]
end

#delete_floating_ip(floating_ip_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/delete_floating_ip.rb', line 15

def delete_floating_ip(floating_ip_id)
  response = Excon::Response.new
  if list_floating_ips.body['floatingips'].map { |r| r['id'] }.include? floating_ip_id
    data[:floating_ips].delete(floating_ip_id)
    response.status = 204
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#delete_ike_policy(ike_policy_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/delete_ike_policy.rb', line 15

def delete_ike_policy(ike_policy_id)
  response = Excon::Response.new
  if list_ike_policies.body['ikepolicies'].collect { |r| r['id'] }.include? ike_policy_id
    data[:ike_policies].delete(ike_policy_id)
    response.status = 204
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#delete_ipsec_policy(ipsec_policy_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/delete_ipsec_policy.rb', line 15

def delete_ipsec_policy(ipsec_policy_id)
  response = Excon::Response.new
  if list_ipsec_policies.body['ipsecpolicies'].collect { |r| r['id'] }.include? ipsec_policy_id
    data[:ipsec_policies].delete(ipsec_policy_id)
    response.status = 204
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#delete_ipsec_site_connection(ipsec_site_connection_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/network/openstack/requests/delete_ipsec_site_connection.rb', line 15

def delete_ipsec_site_connection(ipsec_site_connection_id)
  response = Excon::Response.new
  ip_site_connections = list_ipsec_site_connections.body['ipsec_site_connections']
  if ip_site_connections.collect { |r| r['id'] }.include? ipsec_site_connection_id
    data[:ipsec_site_connections].delete(ipsec_site_connection_id)
    response.status = 204
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#delete_lb_health_monitor(health_monitor_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/delete_lb_health_monitor.rb', line 15

def delete_lb_health_monitor(health_monitor_id)
  response = Excon::Response.new
  if list_lb_health_monitors.body['health_monitors'].map { |r| r['id'] }.include? health_monitor_id
    data[:lb_health_monitors].delete(health_monitor_id)
    response.status = 204
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#delete_lb_member(member_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/delete_lb_member.rb', line 15

def delete_lb_member(member_id)
  response = Excon::Response.new
  if list_lb_members.body['members'].map { |r| r['id'] }.include? member_id
    data[:lb_members].delete(member_id)
    response.status = 204
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#delete_lb_pool(pool_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/delete_lb_pool.rb', line 15

def delete_lb_pool(pool_id)
  response = Excon::Response.new
  if list_lb_pools.body['pools'].map { |r| r['id'] }.include? pool_id
    data[:lb_pools].delete(pool_id)
    response.status = 204
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#delete_lb_vip(vip_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/delete_lb_vip.rb', line 15

def delete_lb_vip(vip_id)
  response = Excon::Response.new
  if list_lb_vips.body['vips'].map { |r| r['id'] }.include? vip_id
    data[:lb_vips].delete(vip_id)
    response.status = 204
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#delete_lbaas_healthmonitor(healthmonitor_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/delete_lbaas_healthmonitor.rb', line 15

def delete_lbaas_healthmonitor(healthmonitor_id)
  response = Excon::Response.new
  if list_lbaas_healthmonitors.body['healthmonitors'].map { |r| r['id'] }.include? healthmonitor_id
    data[:lbaas_healthmonitors].delete(healthmonitor_id)
    response.status = 204
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#delete_lbaas_l7policy(l7policy_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/delete_lbaas_l7policy.rb', line 15

def delete_lbaas_l7policy(l7policy_id)
  response = Excon::Response.new
  if list_lbaas_l7policies.body['l7policies'].map { |r| r['id'] }.include? l7policy_id
    data[:lbaas_l7policies].delete(l7policy_id)
    response.status = 204
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#delete_lbaas_l7rule(l7policy_id, l7rule_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/delete_lbaas_l7rule.rb', line 15

def delete_lbaas_l7rule(l7policy_id, l7rule_id)
  response = Excon::Response.new
  if list_lbaas_l7rules.body['l7rules'].map { |r| r['id'] }.include? l7rule_id
    data[:lbaas_l7rules].delete(l7rule_id)
    response.status = 204
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#delete_lbaas_listener(listener_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/delete_lbaas_listener.rb', line 15

def delete_lbaas_listener(listener_id)
  response = Excon::Response.new
  if list_lbaas_listeners.body['listsners'].map { |r| r['id'] }.include? listener_id
    data[:lbaas_listeners].delete(listener_id)
    response.status = 204
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#delete_lbaas_loadbalancer(loadbalancer_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/delete_lbaas_loadbalancer.rb', line 15

def delete_lbaas_loadbalancer(loadbalancer_id)
  response = Excon::Response.new
  if list_lbaas_loadbalancers.body['loadbalancers'].map { |r| r['id'] }.include? loadbalancer_id
    data[:lbaas_loadbalancers].delete(loadbalancer_id)
    response.status = 204
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#delete_lbaas_pool(pool_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/delete_lbaas_pool.rb', line 15

def delete_lbaas_pool(pool_id)
  response = Excon::Response.new
  if list_lb_pools.body['pools'].map { |r| r['id'] }.include? pool_id
    data[:lb_pools].delete(pool_id)
    response.status = 204
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#delete_lbaas_pool_member(pool_id, member_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/delete_lbaas_pool_member.rb', line 15

def delete_lbaas_pool_member(pool_id, member_id)
  response = Excon::Response.new
  if list_lbaas_pool_members(pool_id).body['members'].map { |r| r['id'] }.include? member_id
    data[:members].delete(member_id)
    response.status = 204
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#delete_network(network_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/delete_network.rb', line 15

def delete_network(network_id)
  response = Excon::Response.new
  if list_networks.body['networks'].map { |r| r['id'] }.include? network_id
    data[:networks].delete(network_id)
    response.status = 204
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#delete_port(port_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/delete_port.rb', line 15

def delete_port(port_id)
  response = Excon::Response.new
  if list_ports.body['ports'].map { |r| r['id'] }.include? port_id
    data[:ports].delete(port_id)
    response.status = 204
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#delete_quota(_tenant_id) ⇒ Object



15
16
17
18
19
# File 'lib/fog/network/openstack/requests/delete_quota.rb', line 15

def delete_quota(_tenant_id)
  response = Excon::Response.new
  response.status = 204
  response
end

#delete_rbac_policy(rbac_policy_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/delete_rbac_policy.rb', line 15

def delete_rbac_policy(rbac_policy_id)
  response = Excon::Response.new
  if list_rbac_policies.body['rbac_policies'].collect { |r| r['id'] }.include? rbac_policy_id
    data[:rbac_policies].delete(rbac_policy_id)
    response.status = 204
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#delete_router(router_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/delete_router.rb', line 15

def delete_router(router_id)
  response = Excon::Response.new
  if list_routers.body['routers'].find { |r| r[:id] == router_id }
    data[:routers].delete(router_id)
    response.status = 204
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#delete_security_group(security_group_id) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/fog/network/openstack/requests/delete_security_group.rb', line 19

def delete_security_group(security_group_id)
  response = Excon::Response.new
  if data[:security_groups][security_group_id]
    data[:security_groups].delete(security_group_id)
    response.status = 204
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#delete_security_group_rule(security_group_rule_id) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/fog/network/openstack/requests/delete_security_group_rule.rb', line 19

def delete_security_group_rule(security_group_rule_id)
  response = Excon::Response.new
  if data[:security_group_rules][security_group_rule_id]
    data[:security_group_rules].delete(security_group_rule_id)
    response.status = 204
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#delete_subnet(subnet_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/delete_subnet.rb', line 15

def delete_subnet(subnet_id)
  response = Excon::Response.new
  if list_subnets.body['subnets'].map { |r| r['id'] }.include? subnet_id
    data[:subnets].delete(subnet_id)
    response.status = 204
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#delete_subnet_pool(subnet_pool_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/delete_subnet_pool.rb', line 15

def delete_subnet_pool(subnet_pool_id)
  response = Excon::Response.new
  if list_subnet_pools.body['subnetpools'].map { |r| r['id'] }.include? subnet_pool_id
    data[:subnet_pools].delete(subnet_pool_id)
    response.status = 204
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#delete_vpn_service(vpn_service_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/delete_vpn_service.rb', line 15

def delete_vpn_service(vpn_service_id)
  response = Excon::Response.new
  if list_vpn_services.body['vpnservices'].collect { |r| r['id'] }.include? vpn_service_id
    data[:vpn_services].delete(vpn_service_id)
    response.status = 204
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

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



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

def disassociate_floating_ip(_floating_ip_id, options = {})
  response = Excon::Response.new
  response.status = 200
  data = {
    'id'                  => '00000000-0000-0000-0000-000000000000',
    'router_id'           => nil,
    'tenant_id'           => options["tenant_id"],
    'floating_network_id' => options["floating_network_id"],
    'fixed_ip_address'    => nil,
    'floating_ip_address' => options["floating_ip_address"],
    'port_id'             => options["port_id"],
  }

  self.data[:floating_ips][data['floating_ip_id']] = data
  response.body = {'floatingip' => data}
  response
end

#disassociate_lb_health_monitor(pool_id, health_monitor_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/network/openstack/requests/disassociate_lb_health_monitor.rb', line 15

def disassociate_lb_health_monitor(pool_id, health_monitor_id)
  response = Excon::Response.new
  if pool = list_lb_pools.body['pools'].find { |_| _['id'] == pool_id }
    pool['health_monitors'].delete(health_monitor_id)
    data[:lb_pools][pool_id] = pool
    response.status = 204
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#get_extension(name) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/get_extension.rb', line 15

def get_extension(name)
  response = Excon::Response.new
  if data = self.data[:extensions][name]
    response.status = 200
    response.body = {'extension' => data}
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#get_floating_ip(floating_ip_id) ⇒ Object



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

def get_floating_ip(floating_ip_id)
  response = Excon::Response.new
  if data = self.data[:floating_ips][floating_ip_id]
    response.status = 200
    response.body = {
      "floatingip" => {
        "id"                  => "00000000-0000-0000-0000-000000000000",
        # changed
        # "floating_ip_id" => floating_ip_id,
        "port_id"             => data["port_id"],
        "tenant_id"           => data["tenant_id"],
        "fixed_ip_address"    => data["fixed_ip_address"],
        "router_id"           => "00000000-0000-0000-0000-000000000000",
        "floating_ip_address" => data["floating_ip_address"],
      }
    }
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#get_ike_policy(ike_policy_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/get_ike_policy.rb', line 15

def get_ike_policy(ike_policy_id)
  response = Excon::Response.new
  if data = self.data[:ike_policies][ike_policy_id]
    response.status = 200
    response.body   = {'ikepolicy' => data}
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#get_ipsec_policy(ipsec_policy_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/get_ipsec_policy.rb', line 15

def get_ipsec_policy(ipsec_policy_id)
  response = Excon::Response.new
  if data = self.data[:ipsec_policies][ipsec_policy_id]
    response.status = 200
    response.body   = {'ipsecpolicy' => data}
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#get_ipsec_site_connection(ipsec_site_connection_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/get_ipsec_site_connection.rb', line 15

def get_ipsec_site_connection(ipsec_site_connection_id)
  response = Excon::Response.new
  if data = self.data[:ipsec_site_connections][ipsec_site_connection_id]
    response.status = 200
    response.body   = {'ipsec_site_connection' => data}
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#get_lb_health_monitor(health_monitor_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/get_lb_health_monitor.rb', line 15

def get_lb_health_monitor(health_monitor_id)
  response = Excon::Response.new
  if data = self.data[:lb_health_monitors][health_monitor_id]
    response.status = 200
    response.body = {'health_monitor' => data}
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#get_lb_member(member_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/get_lb_member.rb', line 15

def get_lb_member(member_id)
  response = Excon::Response.new
  if data = self.data[:lb_members][member_id]
    response.status = 200
    response.body = {'member' => data}
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#get_lb_pool(pool_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/get_lb_pool.rb', line 15

def get_lb_pool(pool_id)
  response = Excon::Response.new
  if data = self.data[:lb_pools][pool_id]
    response.status = 200
    response.body = {'pool' => data}
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#get_lb_pool_stats(pool_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fog/network/openstack/requests/get_lb_pool_stats.rb', line 15

def get_lb_pool_stats(pool_id)
  response = Excon::Response.new
  if data = self.data[:lb_pools][pool_id]
    stats = {}
    stats["active_connections"] = 0
    stats["bytes_in"] = 0
    stats["bytes_out"] = 0
    stats["total_connections"] = 0
    response.status = 200
    response.body = {'stats' => stats}
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#get_lb_vip(vip_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/get_lb_vip.rb', line 15

def get_lb_vip(vip_id)
  response = Excon::Response.new
  if data = self.data[:lb_vips][vip_id]
    response.status = 200
    response.body = {'vip' => data}
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#get_lbaas_healthmonitor(healthmonitor_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/get_lbaas_healthmonitor.rb', line 15

def get_lbaas_healthmonitor(healthmonitor_id)
  response = Excon::Response.new
  if data = self.data[:lbaas_healthmonitors][healthmonitor_id]
    response.status = 200
    response.body = {'healthmonitor' => data}
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#get_lbaas_l7policy(l7policy_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/get_lbaas_l7policy.rb', line 15

def get_lbaas_l7policy(l7policy_id)
  response = Excon::Response.new
  if data = self.data[:lbaas_l7policies][l7policy_id]
    response.status = 200
    response.body = {'l7policy' => data}
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#get_lbaas_l7rule(l7policy_id, l7rule_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/get_lbaas_l7rule.rb', line 15

def get_lbaas_l7rule(l7policy_id, l7rule_id)
  response = Excon::Response.new
  if data = self.data[:lbaas_l7rules][l7rule_id]
    response.status = 200
    response.body = {'rule' => data}
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#get_lbaas_listener(listener_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/get_lbaas_listener.rb', line 15

def get_lbaas_listener(listener_id)
  response = Excon::Response.new
  if data = self.data[:lbaas_listeners][listener_id]
    response.status = 200
    response.body = {'listener' => data}
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#get_lbaas_loadbalancer(loadbalancer_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/get_lbaas_loadbalancer.rb', line 15

def get_lbaas_loadbalancer(loadbalancer_id)
  response = Excon::Response.new
  if data = self.data[:lbaas_loadbalancer][loadbalancer_id]
    response.status = 200
    response.body = {'loadbalancer' => data[:lbaas_loadbalancer]}
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#get_lbaas_pool(pool_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/get_lbaas_pool.rb', line 15

def get_lbaas_pool(pool_id)
  response = Excon::Response.new
  if data = self.data[:lbaas_pools][pool_id]
    response.status = 200
    response.body = {'pool' => data}
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#get_lbaas_pool_member(pool_id, member_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/get_lbaas_pool_member.rb', line 15

def get_lbaas_pool_member(pool_id, member_id)
  response = Excon::Response.new
  if data = self.data[:lbaas_pool_members][member_id]
    response.status = 200
    response.body = {'member' => data}
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#get_network(network_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/get_network.rb', line 15

def get_network(network_id)
  response = Excon::Response.new
  if data = self.data[:networks][network_id]
    response.status = 200
    response.body = {'network' => data}
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#get_network_ip_availability(network_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/get_network_ip_availability.rb', line 15

def get_network_ip_availability(network_id)
  response = Excon::Response.new
  if data = self.data[:network_ip_availabilities].first
    response.status = 200
    response.body = {'network_ip_availability' => data}
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#get_port(port_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fog/network/openstack/requests/get_port.rb', line 15

def get_port(port_id)
  response = Excon::Response.new
  if data = self.data[:ports][port_id]
    response.status = 200
    response.body = {
      'port' => {
        'id'                    => '5c81d975-5fea-4674-9c1f-b8aa10bf9a79',
        'name'                  => 'port_1',
        'network_id'            => 'e624a36d-762b-481f-9b50-4154ceb78bbb',
        'fixed_ips'             => [
          {
            'ip_address' => '10.2.2.2',
            'subnet_id'  => '2e4ec6a4-0150-47f5-8523-e899ac03026e',
          }
        ],
        'mac_address'           => 'fa:16:3e:62:91:7f',
        'status'                => 'ACTIVE',
        'admin_state_up'        => true,
        'device_id'             => 'dhcp724fc160-2b2e-597e-b9ed-7f65313cd73f-e624a36d-762b-481f-9b50-4154ceb78bbb',
        'device_owner'          => 'network:dhcp',
        'tenant_id'             => 'f8b26a6032bc47718a7702233ac708b9',
        'security_groups'       => ['3ddde803-e550-4737-b5de-0862401dc834'],
        'allowed_address_pairs' => [
          'ip_address'  => '10.1.1.1',
          'mac_address' => 'fa:16:3e:3d:2a:cc'
        ]
      }
    }
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#get_quota(_tenant_id) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/fog/network/openstack/requests/get_quota.rb', line 15

def get_quota(_tenant_id)
  response = Excon::Response.new
  response.status = 200
  response.body = {
    'quota' => (data[:quota_updated] || data[:quota])
  }
  response
end

#get_quotasObject



15
16
17
18
19
20
21
22
# File 'lib/fog/network/openstack/requests/get_quotas.rb', line 15

def get_quotas
  response = Excon::Response.new
  response.status = 200
  response.body = {
    'quotas' => data[:quotas]
  }
  response
end

#get_rbac_policy(rbac_policy_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/get_rbac_policy.rb', line 15

def get_rbac_policy(rbac_policy_id)
  response = Excon::Response.new
  if data = self.data[:rbac_policies][rbac_policy_id]
    response.status = 200
    response.body   = {'rbac_policy' => data}
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#get_router(router_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fog/network/openstack/requests/get_router.rb', line 15

def get_router(router_id)
  response = Excon::Response.new
  if data = (self.data[:routers].find { |id, _value| id == router_id })
    response.status = 200
    response.body = {
      'router' => data[1],
    }
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#get_security_group(security_group_id) ⇒ Object



39
40
41
42
43
44
45
46
47
48
# File 'lib/fog/network/openstack/requests/get_security_group.rb', line 39

def get_security_group(security_group_id)
  response = Excon::Response.new
  if sec_group = data[:security_groups][security_group_id]
    response.status = 200
    response.body   = {"security_group" => sec_group}
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#get_security_group_rule(security_group_rule_id) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/fog/network/openstack/requests/get_security_group_rule.rb', line 34

def get_security_group_rule(security_group_rule_id)
  response = Excon::Response.new
  if sec_group_rule = data[:security_group_rules][security_group_rule_id]
    response.status = 200
    response.body   = {"security_group_rule" => sec_group_rule}
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#get_subnet(subnet_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/fog/network/openstack/requests/get_subnet.rb', line 15

def get_subnet(subnet_id)
  response = Excon::Response.new
  if data = self.data[:subnets][subnet_id]
    response.status = 200
    response.body = {
      "subnet" => {
        "id"               => "2e4ec6a4-0150-47f5-8523-e899ac03026e",
        "name"             => "subnet_1",
        "network_id"       => "e624a36d-762b-481f-9b50-4154ceb78bbb",
        "cidr"             => "10.2.2.0/24",
        "ip_version"       => 4,
        "gateway_ip"       => "10.2.2.1",
        "allocation_pools" => [
          {
            "start" => "10.2.2.2",
            "end"   => "10.2.2.254"
          }
        ],
        "dns_nameservers"  => [],
        "host_routes"      => [],
        "enable_dhcp"      => true,
        "tenant_id"        => "f8b26a6032bc47718a7702233ac708b9",
      }
    }
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#get_subnet_pool(subnet_pool_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/network/openstack/requests/get_subnet_pool.rb', line 15

def get_subnet_pool(subnet_pool_id)
  data = self.data[:subnet_pools][subnet_pool_id]
  if data
    response = Excon::Response.new
    response.status = 200
    response.body = {'subnetpool' => data}
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#get_vpn_service(vpn_service_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/get_vpn_service.rb', line 15

def get_vpn_service(vpn_service_id)
  response = Excon::Response.new
  if data = self.data[:vpn_services][vpn_service_id]
    response.status = 200
    response.body   = {'vpnservice' => data}
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#list_extensions(_filters = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/fog/network/openstack/requests/list_extensions.rb', line 16

def list_extensions(_filters = {})
  Excon::Response.new(
    :body   => {'extensions' => data[:extensions].values},
    :status => 200
  )
end

#list_floating_ips(_filters = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/fog/network/openstack/requests/list_floating_ips.rb', line 16

def list_floating_ips(_filters = {})
  Excon::Response.new(
    :body   => {'floatingips' => data[:floating_ips].values},
    :status => 200
  )
end

#list_ike_policiesObject



16
17
18
19
20
21
# File 'lib/fog/network/openstack/requests/list_ike_policies.rb', line 16

def list_ike_policies(*)
  Excon::Response.new(
    :body   => {'ikepolicies' => data[:ike_policies].values},
    :status => 200
  )
end

#list_ipsec_policiesObject



16
17
18
19
20
21
# File 'lib/fog/network/openstack/requests/list_ipsec_policies.rb', line 16

def list_ipsec_policies(*)
  Excon::Response.new(
    :body   => {'ipsecpolicies' => data[:ipsec_policies].values},
    :status => 200
  )
end

#list_ipsec_site_connectionsObject



16
17
18
19
20
21
# File 'lib/fog/network/openstack/requests/list_ipsec_site_connections.rb', line 16

def list_ipsec_site_connections(*)
  Excon::Response.new(
    :body   => {'ipsec_site_connections' => data[:ipsec_site_connections].values},
    :status => 200
  )
end

#list_lb_health_monitors(_filters = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/fog/network/openstack/requests/list_lb_health_monitors.rb', line 16

def list_lb_health_monitors(_filters = {})
  Excon::Response.new(
    :body   => {'health_monitors' => data[:lb_health_monitors].values},
    :status => 200
  )
end

#list_lb_members(_filters = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/fog/network/openstack/requests/list_lb_members.rb', line 16

def list_lb_members(_filters = {})
  Excon::Response.new(
    :body   => {'members' => data[:lb_members].values},
    :status => 200
  )
end

#list_lb_pools(_filters = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/fog/network/openstack/requests/list_lb_pools.rb', line 16

def list_lb_pools(_filters = {})
  Excon::Response.new(
    :body   => {'pools' => data[:lb_pools].values},
    :status => 200
  )
end

#list_lb_vips(_filters = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/fog/network/openstack/requests/list_lb_vips.rb', line 16

def list_lb_vips(_filters = {})
  Excon::Response.new(
    :body   => {'vips' => data[:lb_vips].values},
    :status => 200
  )
end

#list_lbaas_healthmonitors(_filters = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/fog/network/openstack/requests/list_lbaas_healthmonitors.rb', line 16

def list_lbaas_healthmonitors(_filters = {})
  Excon::Response.new(
    :body   => {'healthmonitors' => data[:lbaas_healthmonitors].values},
    :status => 200
  )
end

#list_lbaas_l7policies(filters = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/fog/network/openstack/requests/list_lbaas_l7policies.rb', line 16

def list_lbaas_l7policies(filters = {})
  Excon::Response.new(
      :body   => {'l7policies' => data[:lbaas_l7policies].values},
      :status => 200
  )
end

#list_lbaas_l7rules(l7policy_id, filters = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/fog/network/openstack/requests/list_lbaas_l7rules.rb', line 16

def list_lbaas_l7rules(l7policy_id, filters = {})
  Excon::Response.new(
      :body   => {'rules' => data[:lbaas_l7rules].values},
      :status => 200
  )
end

#list_lbaas_listeners(_filters = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/fog/network/openstack/requests/list_lbaas_listeners.rb', line 16

def list_lbaas_listeners(_filters = {})
  Excon::Response.new(
      :body => {'listeners' => data[:lbaas_listeners].values},
      :status => 200
  )
end

#list_lbaas_loadbalancers(_filters = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/fog/network/openstack/requests/list_lbaas_loadbalancers.rb', line 16

def list_lbaas_loadbalancers(_filters = {})
   Excon::Response.new(
    :body   => {'loadbalancers' => [data[:lbaas_loadbalancer]]},
    :status => 200
  )
end

#list_lbaas_pool_members(pool_id, _filters = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/fog/network/openstack/requests/list_lbaas_pool_members.rb', line 16

def list_lbaas_pool_members(pool_id, _filters = {})
   Excon::Response.new(
    :body   => {'members' => data[:lbaas_pool_members].values},
    :status => 200
  )
end

#list_lbaas_pools(_filters = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/fog/network/openstack/requests/list_lbaas_pools.rb', line 16

def list_lbaas_pools(_filters = {})
  Excon::Response.new(
    :body   => {'pools' => data[:lbaas_pools].values},
    :status => 200
  )
end

#list_network_ip_availabilitiesObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/network/openstack/requests/list_network_ip_availabilities.rb', line 15

def list_network_ip_availabilities
  response = Excon::Response.new
  if data = self.data[:network_ip_availabilities]
    response.status = 200
    response.body = {'network_ip_availabilities' => data}
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#list_networks(_filters = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/fog/network/openstack/requests/list_networks.rb', line 16

def list_networks(_filters = {})
  Excon::Response.new(
    :body   => {'networks' => data[:networks].values},
    :status => 200
  )
end

#list_ports(_filters = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/fog/network/openstack/requests/list_ports.rb', line 16

def list_ports(_filters = {})
  Excon::Response.new(
    :body   => {'ports' => data[:ports].values},
    :status => 200
  )
end

#list_rbac_policiesObject



16
17
18
19
20
21
# File 'lib/fog/network/openstack/requests/list_rbac_policies.rb', line 16

def list_rbac_policies(*)
  Excon::Response.new(
    :body   => {'rbac_policies' => data[:rbac_policies].values},
    :status => 200
  )
end

#list_routers(_filters = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/fog/network/openstack/requests/list_routers.rb', line 16

def list_routers(_filters = {})
  Excon::Response.new(
    :body   => {'routers' => data[:routers].values},
    :status => 200
  )
end

#list_security_group_rules(_options = {}) ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'lib/fog/network/openstack/requests/list_security_group_rules.rb', line 35

def list_security_group_rules(_options = {})
  response = Excon::Response.new

  sec_group_rules = []
  sec_group_rules = data[:security_group_rules].values unless data[:security_group_rules].nil?

  response.status = 200
  response.body = {'security_group_rules' => sec_group_rules}
  response
end

#list_security_groups(_options = {}) ⇒ Object



40
41
42
43
44
45
46
47
48
49
# File 'lib/fog/network/openstack/requests/list_security_groups.rb', line 40

def list_security_groups(_options = {})
  response = Excon::Response.new

  sec_groups = []
  sec_groups = data[:security_groups].values unless data[:security_groups].nil?

  response.status = 200
  response.body = {'security_groups' => sec_groups}
  response
end

#list_subnet_pools(_filters = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/fog/network/openstack/requests/list_subnet_pools.rb', line 16

def list_subnet_pools(_filters = {})
  Excon::Response.new(
    :body   => {'subnetpools' => data[:subnet_pools].values},
    :status => 200
  )
end

#list_subnets(_filters = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/fog/network/openstack/requests/list_subnets.rb', line 16

def list_subnets(_filters = {})
  Excon::Response.new(
    :body   => {'subnets' => data[:subnets].values},
    :status => 200
  )
end

#list_vpn_servicesObject



16
17
18
19
20
21
# File 'lib/fog/network/openstack/requests/list_vpn_services.rb', line 16

def list_vpn_services(*)
  Excon::Response.new(
    :body   => {'vpnservices' => data[:vpn_services].values},
    :status => 200
  )
end

#remove_router_interface(_router_id, _subnet_id, _options = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fog/network/openstack/requests/remove_router_interface.rb', line 20

def remove_router_interface(_router_id, _subnet_id, _options = {})
  response = Excon::Response.new
  response.status = 201
  data = {
    'subnet_id' => 'a2f1f29d-571b-4533-907f-5803ab96ead1'
  }

  self.data[:routers][data['router_id']] = data
  response.body = {'router' => data}
  response
end

#reset_dataObject



440
441
442
# File 'lib/fog/network/openstack.rb', line 440

def reset_data
  self.class.data.delete("#{@openstack_username}-#{@openstack_tenant}")
end

#set_tenant(_tenant) ⇒ Object



14
15
16
# File 'lib/fog/network/openstack/requests/set_tenant.rb', line 14

def set_tenant(_tenant)
  true
end

#update_ike_policy(ike_policy_id, options = {}) ⇒ Object



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

def update_ike_policy(ike_policy_id, options = {})
  response = Excon::Response.new
  if ike_policy = list_ike_policies.body['ikepolicies'].detect { |instance| instance['id'] == ike_policy_id }
    ike_policy['name']                    = options[:name]
    ike_policy['description']             = options[:description]
    ike_policy['tenant_id']               = options[:tenant_id]
    ike_policy['auth_algorithm']          = options[:auth_algorithm]
    ike_policy['encryption_algorithm']    = options[:encryption_algorithm]
    ike_policy['pfs']                     = options[:pfs]
    ike_policy['phase1_negotiation_mode'] = options[:phase1_negotiation_mode]
    ike_policy['lifetime']                = options[:lifetime]
    ike_policy['ike_version']             = options[:ike_version]
    response.body = {'ikepolicy' => ike_policy}
    response.status = 200
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#update_ipsec_policy(ipsec_policy_id, options = {}) ⇒ Object



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

def update_ipsec_policy(ipsec_policy_id, options = {})
  response = Excon::Response.new
  ipsec_policy = list_ipsec_policies.body['ipsecpolicies'].detect do |instance|
    instance['id'] == ipsec_policy_id
  end
  if ipsec_policy
    ipsec_policy['name']                 = options[:name]
    ipsec_policy['description']          = options[:description]
    ipsec_policy['tenant_id']            = options[:tenant_id]
    ipsec_policy['auth_algorithm']       = options[:auth_algorithm]
    ipsec_policy['encryption_algorithm'] = options[:encryption_algorithm]
    ipsec_policy['pfs']                  = options[:pfs]
    ipsec_policy['transform_protocol']   = options[:transform_protocol]
    ipsec_policy['encapsulation_mode']   = options[:encapsulation_mode]
    ipsec_policy['lifetime']             = options[:lifetime]
    response.body = {'ipsecpolicy' => ipsec_policy}
    response.status = 200
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#update_ipsec_site_connection(ipsec_site_connection_id, options = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/fog/network/openstack/requests/update_ipsec_site_connection.rb', line 27

def update_ipsec_site_connection(ipsec_site_connection_id, options = {})
  response = Excon::Response.new
  ipsec_site_connection = list_ipsec_site_connections.body['ipsec_site_connections'].detect do |instance|
    instance['id'] == ipsec_site_connection_id
  end
  if ipsec_site_connection
    ipsec_site_connection['name']              = options[:name]
    ipsec_site_connection['description']       = options[:description]
    ipsec_site_connection['tenant_id']         = options[:tenant_id]
    ipsec_site_connection['status']            = 'ACTIVE'
    ipsec_site_connection['admin_state_up']    = options[:admin_state_up]
    ipsec_site_connection['psk']               = options[:psk]
    ipsec_site_connection['initiator']         = options[:initiator]
    ipsec_site_connection['auth_mode']         = "psk"
    ipsec_site_connection['peer_cidrs']        = options[:peer_cidrs]
    ipsec_site_connection['mtu']               = options[:mtu]
    ipsec_site_connection['peer_ep_group_id']  = Fog::Mock.random_numbers(6).to_s
    ipsec_site_connection['ikepolicy_id']      = options[:ikepolicy_id] || 'ike'
    ipsec_site_connection['vpnservice_id']     = options[:vpnservice_id] || 'vpn'
    ipsec_site_connection['dpd']               = options[:dpd]
    ipsec_site_connection['route_mode']        = "static"
    ipsec_site_connection['ipsecpolicy_id']    = options[:ipsecpolicy_id] || 'ipsec'
    ipsec_site_connection['local_ep_group_id'] = Fog::Mock.random_numbers(6).to_s
    ipsec_site_connection['peer_address']      = options[:peer_address]
    ipsec_site_connection['peer_id']           = options[:peer_id]

    response.body = {'ipsec_site_connection' => ipsec_site_connection}
    response.status = 200
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#update_lb_health_monitor(health_monitor_id, options = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fog/network/openstack/requests/update_lb_health_monitor.rb', line 23

def update_lb_health_monitor(health_monitor_id, options = {})
  response = Excon::Response.new
  if health_monitor = list_lb_health_monitors.body['health_monitors'].find { |_| _['id'] == health_monitor_id }
    health_monitor['delay']          = options[:delay]
    health_monitor['timeout']        = options[:timeout]
    health_monitor['max_retries']    = options[:max_retries]
    health_monitor['http_method']    = options[:http_method]
    health_monitor['url_path']       = options[:url_path]
    health_monitor['expected_codes'] = options[:expected_codes]
    health_monitor['admin_state_up'] = options[:admin_state_up]
    response.body = {'health_monitor' => health_monitor}
    response.status = 200
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#update_lb_member(member_id, options = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/network/openstack/requests/update_lb_member.rb', line 23

def update_lb_member(member_id, options = {})
  response = Excon::Response.new
  if member = list_lb_members.body['members'].find { |_| _['id'] == member_id }
    member['pool_id']        = options[:pool_id]
    member['weight']         = options[:weight]
    member['admin_state_up'] = options[:admin_state_up]
    response.body = {'member' => member}
    response.status = 200
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#update_lb_pool(pool_id, options = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/fog/network/openstack/requests/update_lb_pool.rb', line 23

def update_lb_pool(pool_id, options = {})
  response = Excon::Response.new
  if pool = list_lb_pools.body['pools'].find { |_| _['id'] == pool_id }
    pool['name']            = options[:name]
    pool['description']     = options[:description]
    pool['lb_method']       = options[:lb_method]
    pool['admin_state_up']  = options[:admin_state_up]
    response.body = {'pool' => pool}
    response.status = 200
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#update_lb_vip(vip_id, options = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fog/network/openstack/requests/update_lb_vip.rb', line 23

def update_lb_vip(vip_id, options = {})
  response = Excon::Response.new
  if vip = list_lb_vips.body['vips'].find { |_| _['id'] == vip_id }
    vip['pool_id']             = options[:pool_id]
    vip['name']                = options[:name]
    vip['description']         = options[:description]
    vip['session_persistence'] = options[:session_persistence]
    vip['connection_limit']    = options[:connection_limit]
    vip['admin_state_up']      = options[:admin_state_up]
    response.body = {'vip' => vip}
    response.status = 200
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#update_lbaas_healthmonitor(healthmonitor_id, options = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fog/network/openstack/requests/update_lbaas_healthmonitor.rb', line 23

def update_lbaas_healthmonitor(healthmonitor_id, options = {})
  response = Excon::Response.new
  if healthmonitor = list_lbaas_health_monitors.body['healthmonitors'].find { |_| _['id'] == healthmonitor_id }
    healthmonitor['delay']          = options[:delay]
    healthmonitor['timeout']        = options[:timeout]
    healthmonitor['max_retries']    = options[:max_retries]
    healthmonitor['http_method']    = options[:http_method]
    healthmonitor['url_path']       = options[:url_path]
    healthmonitor['expected_codes'] = options[:expected_codes]
    healthmonitor['admin_state_up'] = options[:admin_state_up]
    response.body = {'healthmonitor' => healthmonitor}
    response.status = 200
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#update_lbaas_l7rule(l7policy_id, options = {}) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fog/network/openstack/requests/update_lbaas_l7rule.rb', line 24

def update_lbaas_l7rule(l7policy_id, l7rule_id, options = {})
  response = Excon::Response.new
  if l7rule = list_l7rules.body['l7rules'].find { |_| _['id'] == l7rule_id }
    l7rule['type']           = options[:type]
    l7rule['compare_type']   = options[:compare_type]
    l7rule['key']            = options[:key]
    l7rule['value']          = options[:value]
    l7rule['invert']         = options[:invert]
    response.body = {'rule' => l7rule}
    response.status = 200
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#update_lbaas_listener(listener_id, options = {}) ⇒ Object



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

def update_lbaas_listener(listener_id, options = {})
  response = Excon::Response.new
  if listener = list_lbaas_listeners.body['listeners'].find { |_| _['id'] == listener_id }
    listener['name']                = options[:name]
    listener['description']         = options[:description]
    listener['connection_limit']    = options[:connection_limit]
    listener['default_tls_container_ref']    = options[:default_tls_container_ref]
    listener['sni_container_refs']  = options[:sni_container_refs]
    listener['admin_state_up']      = options[:admin_state_up]
    response.body = {'listener' => listener}
    response.status = 200
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#update_lbaas_loadbalancer(loadbalancer_id, options = {}) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fog/network/openstack/requests/update_lbaas_loadbalancer.rb', line 25

def update_lbaas_loadbalancer(loadbalancer_id, options = {})
  response = Excon::Response.new
  if loadbalancer = list_lbaas_loadbalancers.body['loadbalancers'].find { |_| _['id'] == loadbalancer_id }
    loadbalancer['name']                = options[:name]
    loadbalancer['description']         = options[:description]
    loadbalancer['admin_state_up']      = options[:admin_state_up]
    response.body = {'loadbalancer' => loadbalancer}
    response.status = 200
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#update_lbaas_pool(pool_id, options = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/fog/network/openstack/requests/update_lbaas_pool.rb', line 23

def update_lbaas_pool(pool_id, options = {})
  response = Excon::Response.new
  if pool = list_lbaas_pools.body['pools'].find { |_| _['id'] == pool_id }
    pool['name']            = options[:name]
    pool['description']     = options[:description]
    pool['lb_algorithm']    = options[:lb_algorithm]
    pool['admin_state_up']  = options[:admin_state_up]
    response.body = {'pool' => pool}
    response.status = 200
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#update_lbaas_pool_member(pool_id, member_id, options = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/network/openstack/requests/update_lbaas_pool_member.rb', line 23

def update_lbaas_pool_member(pool_id, member_id, options = {})
  response = Excon::Response.new
  if member = list_lbaas_pool_members.body['members'].find { |_| _['id'] == member_id }
    member['pool_id']        = options[:pool_id]
    member['weight']         = options[:weight]
    member['admin_state_up'] = options[:admin_state_up]
    response.body = {'member' => member}
    response.status = 200
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#update_network(network_id, options = {}) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/fog/network/openstack/requests/update_network.rb', line 44

def update_network(network_id, options = {})
  response = Excon::Response.new
  if network = list_networks.body['networks'].find { |_| _['id'] == network_id }
    network.merge!(Fog::Network::OpenStack::Real.update(options))
    response.body = {'network' => network}
    response.status = 200
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#update_port(port_id, options = {}) ⇒ Object



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

def update_port(port_id, options = {})
  response = Excon::Response.new
  if port = list_ports.body['ports'].find { |_| _['id'] == port_id }
    port['name']                  = options[:name]
    port['fixed_ips']             = options[:fixed_ips] || []
    port['admin_state_up']        = options[:admin_state_up]
    port['device_owner']          = options[:device_owner]
    port['device_id']             = options[:device_id]
    port['security_groups']       = options[:security_groups] || []
    port['allowed_address_pairs'] = options[:allowed_address_pairs] || []
    response.body = {'port' => port}
    response.status = 200
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#update_quota(_tenant_id, options = {}) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/fog/network/openstack/requests/update_quota.rb', line 16

def update_quota(_tenant_id, options = {})
  data[:quota_updated] = data[:quota].merge options

  response = Excon::Response.new
  response.status = 200
  response.body = {'quota' => data[:quota_updated]}
  response
end

#update_rbac_policy(rbac_policy_id, options = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fog/network/openstack/requests/update_rbac_policy.rb', line 23

def update_rbac_policy(rbac_policy_id, options = {})
  response = Excon::Response.new
  rbac_policy = list_rbac_policies.body['rbac_policies'].detect do |instance|
    instance['id'] == rbac_policy_id
  end
  if rbac_policy
    rbac_policy['target_tenant'] = options[:target_tenant]

    response.body = {'rbac_policy' => rbac_policy}
    response.status = 200
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#update_router(router_id, options = {}) ⇒ Object

Raises:

  • (Fog::Network::OpenStack::NotFound)


42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/fog/network/openstack/requests/update_router.rb', line 42

def update_router(router_id, options = {})
  response = Excon::Response.new
  router = list_routers.body['routers'].find { |r| r[:id] == router_id }

  raise Fog::Network::OpenStack::NotFound unless router

  options.keys.each { |k| router[k] = options[k] }

  # remove this in a future
  egi = options[:external_gateway_info]
  if egi
    if egi.kind_of?(Fog::Network::OpenStack::Network)
      Fog::Logger.deprecation "Passing a model objects into options[:external_gateway_info] is deprecated. \
      Please pass  external external gateway as follows options[:external_gateway_info] = { :network_id => NETWORK_ID }]"
      router[:external_gateway_info] = { :network_id => egi.id }
    elsif egi.is_a?(Hash)
      router[:external_gateway_info] = egi
    else
      raise ArgumentError.new('Invalid external_gateway_info attribute')
    end
  end

  response.body = {'router' => router}
  response.status = 200
  response
end

#update_security_group(security_group_id, options = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fog/network/openstack/requests/update_security_group.rb', line 22

def update_security_group(security_group_id, options = {})
  response = Excon::Response.new
  security_group = list_security_groups.body['security_groups'].find do |sg|
    sg['id'] == security_group_id
  end

  if security_group
    security_group['name']        = options[:name]
    security_group['description'] = options[:description]
    response.body = {'security_group' => security_group}
    response.status = 200
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#update_subnet(subnet_id, options = {}) ⇒ Object



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

def update_subnet(subnet_id, options = {})
  response = Excon::Response.new
  if subnet = list_subnets.body['subnets'].find { |_| _['id'] == subnet_id }
    subnet['name']              = options[:name]
    subnet['gateway_ip']        = options[:gateway_ip]
    subnet['dns_nameservers']   = options[:dns_nameservers]   || []
    subnet['host_routes']       = options[:host_routes]       || []
    subnet['allocation_pools']  = options[:allocation_pools]  || []
    subnet['enable_dhcp']       = options[:enable_dhcp]
    response.body = {'subnet' => subnet}
    response.status = 200
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#update_subnet_pool(subnet_pool_id, options = {}) ⇒ Object



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

def update_subnet_pool(subnet_pool_id, options = {})
  subnet_pool = list_subnet_pools.body['subnetpools'].find { |s| s['id'] == subnet_pool_id }
  if subnet_pool
    subnet_pool['name']              = options[:name]
    subnet_pool['description']       = options[:description]
    subnet_pool['prefixes']          = options[:prefixes] || []
    subnet_pool['min_prefixlen']     = options[:min_prefixlen] || 64
    subnet_pool['max_prefixlen']     = options[:max_prefixlen] || 64
    subnet_pool['default_prefixlen'] = options[:default_prefixlen] || 64
    subnet_pool['address_scope_id']  = options[:address_scope_id]
    subnet_pool['updated_at']        = Time.now.to_s
    response = Excon::Response.new
    response.body = {'subnetpool' => subnet_pool}
    response.status = 200
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end

#update_vpn_service(vpn_service_id, options = {}) ⇒ Object



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

def update_vpn_service(vpn_service_id, options = {})
  response = Excon::Response.new
  if vpn_service = list_vpn_services.body['vpnservices'].detect { |instance| instance['id'] == vpn_service_id }
    vpn_service['id']             = vpn_service_id
    vpn_service['subnet_id']      = options[:subnet_id]
    vpn_service['router_id']      = options[:router_id]
    vpn_service['name']           = options[:name]
    vpn_service['description']    = options[:description]
    vpn_service['status']         = 'ACTIVE'
    vpn_service['admin_state_up'] = options[:admin_state_up]
    vpn_service['tenant_id']      = options[:tenant_id]
    vpn_service['external_v4_ip'] = '1.2.3.4'
    vpn_service['external_v6_ip'] = '::1'
    response.body = {'vpnservice' => vpn_service}
    response.status = 200
    response
  else
    raise Fog::Network::OpenStack::NotFound
  end
end