fog-openstack 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/.hound.yml +2 -0
  4. data/.rubocop.yml +93 -0
  5. data/.travis.yml +13 -10
  6. data/{lib/fog/openstack/CHANGELOG.md → CHANGELOG.md} +0 -0
  7. data/CODE_OF_CONDUCT.md +1 -1
  8. data/Gemfile +2 -0
  9. data/README.md +497 -3
  10. data/Rakefile +5 -1
  11. data/fog-openstack.gemspec +8 -7
  12. data/gemfiles/Gemfile-1.9 +16 -0
  13. data/lib/fog/openstack.rb +55 -30
  14. data/lib/fog/openstack/docs/metering.md +29 -0
  15. data/lib/fog/openstack/metering.rb +6 -1
  16. data/lib/fog/openstack/models/metering/event.rb +16 -0
  17. data/lib/fog/openstack/models/metering/events.rb +23 -0
  18. data/lib/fog/openstack/models/network/floating_ip.rb +1 -24
  19. data/lib/fog/openstack/models/network/ike_policies.rb +32 -0
  20. data/lib/fog/openstack/models/network/ike_policy.rb +43 -0
  21. data/lib/fog/openstack/models/network/ipsec_policies.rb +32 -0
  22. data/lib/fog/openstack/models/network/ipsec_policy.rb +45 -0
  23. data/lib/fog/openstack/models/network/ipsec_site_connection.rb +51 -0
  24. data/lib/fog/openstack/models/network/ipsec_site_connections.rb +33 -0
  25. data/lib/fog/openstack/models/network/vpn_service.rb +42 -0
  26. data/lib/fog/openstack/models/network/vpn_services.rb +32 -0
  27. data/lib/fog/openstack/network.rb +52 -13
  28. data/lib/fog/openstack/requests/compute/create_volume.rb +28 -21
  29. data/lib/fog/openstack/requests/metering/get_event.rb +27 -0
  30. data/lib/fog/openstack/requests/metering/list_events.rb +42 -0
  31. data/lib/fog/openstack/requests/network/associate_floating_ip.rb +15 -10
  32. data/lib/fog/openstack/requests/network/create_floating_ip.rb +1 -1
  33. data/lib/fog/openstack/requests/network/create_ike_policy.rb +53 -0
  34. data/lib/fog/openstack/requests/network/create_ipsec_policy.rb +53 -0
  35. data/lib/fog/openstack/requests/network/create_ipsec_site_connection.rb +66 -0
  36. data/lib/fog/openstack/requests/network/create_vpn_service.rb +51 -0
  37. data/lib/fog/openstack/requests/network/delete_ike_policy.rb +28 -0
  38. data/lib/fog/openstack/requests/network/delete_ipsec_policy.rb +28 -0
  39. data/lib/fog/openstack/requests/network/delete_ipsec_site_connection.rb +29 -0
  40. data/lib/fog/openstack/requests/network/delete_vpn_service.rb +28 -0
  41. data/lib/fog/openstack/requests/network/disassociate_floating_ip.rb +15 -10
  42. data/lib/fog/openstack/requests/network/get_floating_ip.rb +12 -2
  43. data/lib/fog/openstack/requests/network/get_ike_policy.rb +28 -0
  44. data/lib/fog/openstack/requests/network/get_ipsec_policy.rb +28 -0
  45. data/lib/fog/openstack/requests/network/get_ipsec_site_connection.rb +28 -0
  46. data/lib/fog/openstack/requests/network/get_network.rb +1 -13
  47. data/lib/fog/openstack/requests/network/get_vpn_service.rb +28 -0
  48. data/lib/fog/openstack/requests/network/list_ike_policies.rb +25 -0
  49. data/lib/fog/openstack/requests/network/list_ipsec_policies.rb +25 -0
  50. data/lib/fog/openstack/requests/network/list_ipsec_site_connections.rb +25 -0
  51. data/lib/fog/openstack/requests/network/list_vpn_services.rb +25 -0
  52. data/lib/fog/openstack/requests/network/update_ike_policy.rb +49 -0
  53. data/lib/fog/openstack/requests/network/update_ipsec_policy.rb +52 -0
  54. data/lib/fog/openstack/requests/network/update_ipsec_site_connection.rb +64 -0
  55. data/lib/fog/openstack/requests/network/update_vpn_service.rb +46 -0
  56. data/lib/fog/openstack/storage.rb +2 -2
  57. data/lib/fog/openstack/version.rb +1 -1
  58. data/tests/helper.rb +3 -0
  59. data/tests/openstack/models/network/ike_policies_tests.rb +28 -0
  60. data/tests/openstack/models/network/ike_policy_tests.rb +36 -0
  61. data/tests/openstack/models/network/ipsec_policies_tests.rb +26 -0
  62. data/tests/openstack/models/network/ipsec_policy_tests.rb +36 -0
  63. data/tests/openstack/models/network/ipsec_site_connection_tests.rb +50 -0
  64. data/tests/openstack/models/network/ipsec_site_connections_tests.rb +32 -0
  65. data/tests/openstack/models/network/vpn_service_tests.rb +27 -0
  66. data/tests/openstack/models/network/vpn_services_tests.rb +22 -0
  67. data/tests/openstack/requests/metering/event_tests.rb +17 -0
  68. data/tests/openstack/requests/network/ike_policy_tests.rb +65 -0
  69. data/tests/openstack/requests/network/ipsec_policy_tests.rb +65 -0
  70. data/tests/openstack/requests/network/ipsec_site_connection_tests.rb +82 -0
  71. data/tests/openstack/requests/network/vpn_service_tests.rb +61 -0
  72. metadata +109 -47
  73. data/CONTRIBUTORS.md +0 -79
@@ -28,7 +28,7 @@ module Fog
28
28
  response = Excon::Response.new
29
29
  response.status = 201
30
30
  data = {
31
- 'id' => Fog::UUID.uuid,
31
+ 'id' => floating_network_id,
32
32
  'floating_network_id' => floating_network_id,
33
33
  'port_id' => options[:port_id],
34
34
  'tenant_id' => options[:tenant_id],
@@ -0,0 +1,53 @@
1
+ module Fog
2
+ module Network
3
+ class OpenStack
4
+ class Real
5
+ def create_ike_policy(options = {})
6
+ data = {
7
+ 'ikepolicy' => {
8
+ }
9
+ }
10
+
11
+ vanilla_options = [:name, :description, :tenant_id,
12
+ :auth_algorithm, :encryption_algorithm,
13
+ :pfs, :phase1_negotiation_mode,
14
+ :lifetime, :ike_version
15
+ ]
16
+ vanilla_options.reject { |o| options[o].nil? }.each do |key|
17
+ data['ikepolicy'][key] = options[key]
18
+ end
19
+
20
+ request(
21
+ :body => Fog::JSON.encode(data),
22
+ :expects => [201],
23
+ :method => 'POST',
24
+ :path => 'vpn/ikepolicies'
25
+ )
26
+ end
27
+ end
28
+
29
+ class Mock
30
+ def create_ike_policy(options = {})
31
+ response = Excon::Response.new
32
+ response.status = 201
33
+ data = {
34
+ 'id' => Fog::Mock.random_numbers(6).to_s,
35
+ 'name' => options[:name],
36
+ 'description' => options[:description],
37
+ 'tenant_id' => options[:tenant_id],
38
+ 'auth_algorithm' => options[:auth_algorithm],
39
+ 'encryption_algorithm' => options[:encryption_algorithm],
40
+ 'pfs' => options[:pfs],
41
+ 'phase1_negotiation_mode' => options[:phase1_negotiation_mode],
42
+ 'lifetime' => options[:lifetime],
43
+ 'ike_version' => options[:ike_version]
44
+ }
45
+
46
+ self.data[:ike_policies][data['id']] = data
47
+ response.body = {'ikepolicy' => data}
48
+ response
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,53 @@
1
+ module Fog
2
+ module Network
3
+ class OpenStack
4
+ class Real
5
+ def create_ipsec_policy(options = {})
6
+ data = {
7
+ 'ipsecpolicy' => {
8
+ }
9
+ }
10
+
11
+ vanilla_options = [:name, :description, :tenant_id,
12
+ :auth_algorithm, :encryption_algorithm,
13
+ :pfs, :transform_protocol,
14
+ :lifetime, :encapsulation_mode
15
+ ]
16
+ vanilla_options.reject { |o| options[o].nil? }.each do |key|
17
+ data['ipsecpolicy'][key] = options[key]
18
+ end
19
+
20
+ request(
21
+ :body => Fog::JSON.encode(data),
22
+ :expects => [201],
23
+ :method => 'POST',
24
+ :path => 'vpn/ipsecpolicies'
25
+ )
26
+ end
27
+ end
28
+
29
+ class Mock
30
+ def create_ipsec_policy(options = {})
31
+ response = Excon::Response.new
32
+ response.status = 201
33
+ data = {
34
+ 'id' => Fog::Mock.random_numbers(6).to_s,
35
+ 'name' => options[:name],
36
+ 'description' => options[:description],
37
+ 'tenant_id' => options[:tenant_id],
38
+ 'auth_algorithm' => options[:auth_algorithm],
39
+ 'encryption_algorithm' => options[:encryption_algorithm],
40
+ 'pfs' => options[:pfs],
41
+ 'transform_protocol' => options[:transform_protocol],
42
+ 'lifetime' => options[:lifetime],
43
+ 'encapsulation_mode' => options[:encapsulation_mode]
44
+ }
45
+
46
+ self.data[:ipsec_policies][data['id']] = data
47
+ response.body = {'ipsecpolicy' => data}
48
+ response
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,66 @@
1
+ module Fog
2
+ module Network
3
+ class OpenStack
4
+ class Real
5
+ def create_ipsec_site_connection(vpn_service_id, ike_policy_id, ipsec_policy_id, options = {})
6
+ data = {
7
+ 'ipsec_site_connection' => {
8
+ 'vpnservice_id' => vpn_service_id,
9
+ 'ikepolicy_id' => ike_policy_id,
10
+ 'ipsecpolicy_id' => ipsec_policy_id
11
+ }
12
+ }
13
+
14
+ vanilla_options = [:name, :description, :tenant_id,
15
+ :peer_address, :peer_id, :peer_cidrs,
16
+ :psk, :mtu, :dpd, :initiator,
17
+ :admin_state_up
18
+ ]
19
+ vanilla_options.reject { |o| options[o].nil? }.each do |key|
20
+ data['ipsec_site_connection'][key] = options[key]
21
+ end
22
+
23
+ request(
24
+ :body => Fog::JSON.encode(data),
25
+ :expects => [201],
26
+ :method => 'POST',
27
+ :path => 'vpn/ipsec-site-connections'
28
+ )
29
+ end
30
+ end
31
+
32
+ class Mock
33
+ def create_ipsec_site_connection(vpn_service_id, ike_policy_id, ipsec_policy_id, options = {})
34
+ response = Excon::Response.new
35
+ response.status = 201
36
+ data = {
37
+ 'id' => Fog::Mock.random_numbers(6).to_s,
38
+ 'name' => options[:name],
39
+ 'description' => options[:description],
40
+ 'status' => 'ACTIVE',
41
+ 'tenant_id' => options[:tenant_id],
42
+ 'admin_state_up' => options[:admin_state_up],
43
+ 'psk' => options[:psk],
44
+ 'initiator' => options[:initiator],
45
+ 'auth_mode' => "psk",
46
+ 'peer_cidrs' => options[:peer_cidrs],
47
+ 'mtu' => options[:mtu],
48
+ 'peer_ep_group_id' => Fog::Mock.random_numbers(6).to_s,
49
+ 'ikepolicy_id' => ike_policy_id,
50
+ 'vpnservice_id' => vpn_service_id,
51
+ 'dpd' => options[:dpd],
52
+ 'route_mode' => "static",
53
+ 'ipsecpolicy_id' => ipsec_policy_id,
54
+ 'local_ep_group_id' => Fog::Mock.random_numbers(6).to_s,
55
+ 'peer_address' => options[:peer_address],
56
+ 'peer_id' => options[:peer_id]
57
+ }
58
+
59
+ self.data[:ipsec_site_connections][data['id']] = data
60
+ response.body = {'ipsec_site_connection' => data}
61
+ response
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,51 @@
1
+ module Fog
2
+ module Network
3
+ class OpenStack
4
+ class Real
5
+ def create_vpn_service(subnet_id, router_id, options = {})
6
+ data = {
7
+ 'vpnservice' => {
8
+ 'subnet_id' => subnet_id,
9
+ 'router_id' => router_id
10
+ }
11
+ }
12
+
13
+ vanilla_options = [:name, :description, :admin_state_up, :tenant_id]
14
+ vanilla_options.reject { |o| options[o].nil? }.each do |key|
15
+ data['vpnservice'][key] = options[key]
16
+ end
17
+
18
+ request(
19
+ :body => Fog::JSON.encode(data),
20
+ :expects => [201],
21
+ :method => 'POST',
22
+ :path => 'vpn/vpnservices'
23
+ )
24
+ end
25
+ end
26
+
27
+ class Mock
28
+ def create_vpn_service(subnet_id, router_id, options = {})
29
+ response = Excon::Response.new
30
+ response.status = 201
31
+ data = {
32
+ 'id' => Fog::Mock.random_numbers(6).to_s,
33
+ 'subnet_id' => subnet_id,
34
+ 'router_id' => router_id,
35
+ 'name' => options[:name],
36
+ 'description' => options[:description],
37
+ 'status' => 'ACTIVE',
38
+ 'admin_state_up' => options[:admin_state_up],
39
+ 'tenant_id' => options[:tenant_id],
40
+ 'external_v4_ip' => '1.2.3.4',
41
+ 'external_v6_ip' => '::1'
42
+ }
43
+
44
+ self.data[:vpn_services][data['id']] = data
45
+ response.body = {'vpnservice' => data}
46
+ response
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,28 @@
1
+ module Fog
2
+ module Network
3
+ class OpenStack
4
+ class Real
5
+ def delete_ike_policy(ike_policy_id)
6
+ request(
7
+ :expects => 204,
8
+ :method => 'DELETE',
9
+ :path => "vpn/ikepolicies/#{ike_policy_id}"
10
+ )
11
+ end
12
+ end
13
+
14
+ class Mock
15
+ def delete_ike_policy(ike_policy_id)
16
+ response = Excon::Response.new
17
+ if list_ike_policies.body['ikepolicies'].collect { |r| r['id'] }.include? ike_policy_id
18
+ data[:ike_policies].delete(ike_policy_id)
19
+ response.status = 204
20
+ response
21
+ else
22
+ raise Fog::Network::OpenStack::NotFound
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ module Fog
2
+ module Network
3
+ class OpenStack
4
+ class Real
5
+ def delete_ipsec_policy(ipsec_policy_id)
6
+ request(
7
+ :expects => 204,
8
+ :method => 'DELETE',
9
+ :path => "vpn/ipsecpolicies/#{ipsec_policy_id}"
10
+ )
11
+ end
12
+ end
13
+
14
+ class Mock
15
+ def delete_ipsec_policy(ipsec_policy_id)
16
+ response = Excon::Response.new
17
+ if list_ipsec_policies.body['ipsecpolicies'].collect { |r| r['id'] }.include? ipsec_policy_id
18
+ data[:ipsec_policies].delete(ipsec_policy_id)
19
+ response.status = 204
20
+ response
21
+ else
22
+ raise Fog::Network::OpenStack::NotFound
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,29 @@
1
+ module Fog
2
+ module Network
3
+ class OpenStack
4
+ class Real
5
+ def delete_ipsec_site_connection(ipsec_site_connection_id)
6
+ request(
7
+ :expects => 204,
8
+ :method => 'DELETE',
9
+ :path => "vpn/ipsec-site-connections/#{ipsec_site_connection_id}"
10
+ )
11
+ end
12
+ end
13
+
14
+ class Mock
15
+ def delete_ipsec_site_connection(ipsec_site_connection_id)
16
+ response = Excon::Response.new
17
+ ip_site_connections = list_ipsec_site_connections.body['ipsec_site_connections']
18
+ if ip_site_connections.collect { |r| r['id'] }.include? ipsec_site_connection_id
19
+ data[:ipsec_site_connections].delete(ipsec_site_connection_id)
20
+ response.status = 204
21
+ response
22
+ else
23
+ raise Fog::Network::OpenStack::NotFound
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,28 @@
1
+ module Fog
2
+ module Network
3
+ class OpenStack
4
+ class Real
5
+ def delete_vpn_service(vpn_service_id)
6
+ request(
7
+ :expects => 204,
8
+ :method => 'DELETE',
9
+ :path => "vpn/vpnservices/#{vpn_service_id}"
10
+ )
11
+ end
12
+ end
13
+
14
+ class Mock
15
+ def delete_vpn_service(vpn_service_id)
16
+ response = Excon::Response.new
17
+ if list_vpn_services.body['vpnservices'].collect { |r| r['id'] }.include? vpn_service_id
18
+ data[:vpn_services].delete(vpn_service_id)
19
+ response.status = 204
20
+ response
21
+ else
22
+ raise Fog::Network::OpenStack::NotFound
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -25,16 +25,21 @@ module Fog
25
25
 
26
26
  class Mock
27
27
  def disassociate_floating_ip(floating_ip_id, options = {})
28
- if data = self.data[:floating_ips][floating_ip_id]
29
- response = Excon::Response.new
30
- response.status = 201
31
- data['port_id'] = nil
32
- data['fixed_ip_address'] = nil
33
- response.body = { 'floatingip' => data }
34
- response
35
- else
36
- raise Fog::Network::OpenStack::NotFound
37
- end
28
+ response = Excon::Response.new
29
+ response.status = 200
30
+ data = {
31
+ 'id' => '00000000-0000-0000-0000-000000000000',
32
+ 'router_id' => nil,
33
+ 'tenant_id' => options["tenant_id"],
34
+ 'floating_network_id' => options["floating_network_id"],
35
+ 'fixed_ip_address' => nil,
36
+ 'floating_ip_address' => options["floating_ip_address"],
37
+ 'port_id' => options["port_id"],
38
+ }
39
+
40
+ self.data[:floating_ips][data['floating_ip_id']] = data
41
+ response.body = { 'floatingip' => data }
42
+ response
38
43
  end
39
44
  end
40
45
  end
@@ -14,10 +14,20 @@ module Fog
14
14
  class Mock
15
15
  def get_floating_ip(floating_ip_id)
16
16
  response = Excon::Response.new
17
-
18
17
  if data = self.data[:floating_ips][floating_ip_id]
19
18
  response.status = 200
20
- response.body = { 'floatingip' => data }
19
+ response.body = {
20
+ "floatingip" => {
21
+ "id" => "00000000-0000-0000-0000-000000000000",
22
+ # changed
23
+ # "floating_ip_id" => floating_ip_id,
24
+ "port_id" => data["port_id"],
25
+ "tenant_id" => data["tenant_id"],
26
+ "fixed_ip_address" => data["fixed_ip_address"],
27
+ "router_id" => "00000000-0000-0000-0000-000000000000",
28
+ "floating_ip_address" => data["floating_ip_address"],
29
+ }
30
+ }
21
31
  response
22
32
  else
23
33
  raise Fog::Network::OpenStack::NotFound
@@ -0,0 +1,28 @@
1
+ module Fog
2
+ module Network
3
+ class OpenStack
4
+ class Real
5
+ def get_ike_policy(ike_policy_id)
6
+ request(
7
+ :expects => [200],
8
+ :method => 'GET',
9
+ :path => "vpn/ikepolicies/#{ike_policy_id}"
10
+ )
11
+ end
12
+ end
13
+
14
+ class Mock
15
+ def get_ike_policy(ike_policy_id)
16
+ response = Excon::Response.new
17
+ if data = self.data[:ike_policies][ike_policy_id]
18
+ response.status = 200
19
+ response.body = {'ikepolicy' => data}
20
+ response
21
+ else
22
+ raise Fog::Network::OpenStack::NotFound
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ module Fog
2
+ module Network
3
+ class OpenStack
4
+ class Real
5
+ def get_ipsec_policy(ipsec_policy_id)
6
+ request(
7
+ :expects => [200],
8
+ :method => 'GET',
9
+ :path => "vpn/ipsecpolicies/#{ipsec_policy_id}"
10
+ )
11
+ end
12
+ end
13
+
14
+ class Mock
15
+ def get_ipsec_policy(ipsec_policy_id)
16
+ response = Excon::Response.new
17
+ if data = self.data[:ipsec_policies][ipsec_policy_id]
18
+ response.status = 200
19
+ response.body = {'ipsecpolicy' => data}
20
+ response
21
+ else
22
+ raise Fog::Network::OpenStack::NotFound
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end