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
@@ -0,0 +1,28 @@
1
+ module Fog
2
+ module Network
3
+ class OpenStack
4
+ class Real
5
+ def get_ipsec_site_connection(ipsec_site_connection_id)
6
+ request(
7
+ :expects => [200],
8
+ :method => 'GET',
9
+ :path => "vpn/ipsec-site-connections/#{ipsec_site_connection_id}"
10
+ )
11
+ end
12
+ end
13
+
14
+ class Mock
15
+ def get_ipsec_site_connection(ipsec_site_connection_id)
16
+ response = Excon::Response.new
17
+ if data = self.data[:ipsec_site_connections][ipsec_site_connection_id]
18
+ response.status = 200
19
+ response.body = {'ipsec_site_connection' => data}
20
+ response
21
+ else
22
+ raise Fog::Network::OpenStack::NotFound
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -16,19 +16,7 @@ module Fog
16
16
  response = Excon::Response.new
17
17
  if data = self.data[:networks][network_id]
18
18
  response.status = 200
19
- response.body = {
20
- 'network' => {
21
- 'id' => 'e624a36d-762b-481f-9b50-4154ceb78bbb',
22
- 'name' => 'network_1',
23
- 'subnets' => [
24
- '2e4ec6a4-0150-47f5-8523-e899ac03026e'
25
- ],
26
- 'shared' => false,
27
- 'status' => 'ACTIVE',
28
- 'admin_state_up' => true,
29
- 'tenant_id' => 'f8b26a6032bc47718a7702233ac708b9',
30
- }
31
- }
19
+ response.body = {'network' => data}
32
20
  response
33
21
  else
34
22
  raise Fog::Network::OpenStack::NotFound
@@ -0,0 +1,28 @@
1
+ module Fog
2
+ module Network
3
+ class OpenStack
4
+ class Real
5
+ def get_vpn_service(vpn_service_id)
6
+ request(
7
+ :expects => [200],
8
+ :method => 'GET',
9
+ :path => "vpn/vpnservices/#{vpn_service_id}"
10
+ )
11
+ end
12
+ end
13
+
14
+ class Mock
15
+ def get_vpn_service(vpn_service_id)
16
+ response = Excon::Response.new
17
+ if data = self.data[:vpn_services][vpn_service_id]
18
+ response.status = 200
19
+ response.body = {'vpnservice' => 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,25 @@
1
+ module Fog
2
+ module Network
3
+ class OpenStack
4
+ class Real
5
+ def list_ike_policies(filters = {})
6
+ request(
7
+ :expects => 200,
8
+ :method => 'GET',
9
+ :path => 'vpn/ikepolicies',
10
+ :query => filters
11
+ )
12
+ end
13
+ end
14
+
15
+ class Mock
16
+ def list_ike_policies(*)
17
+ Excon::Response.new(
18
+ :body => {'ikepolicies' => data[:ike_policies].values},
19
+ :status => 200
20
+ )
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ module Fog
2
+ module Network
3
+ class OpenStack
4
+ class Real
5
+ def list_ipsec_policies(filters = {})
6
+ request(
7
+ :expects => 200,
8
+ :method => 'GET',
9
+ :path => 'vpn/ipsecpolicies',
10
+ :query => filters
11
+ )
12
+ end
13
+ end
14
+
15
+ class Mock
16
+ def list_ipsec_policies(*)
17
+ Excon::Response.new(
18
+ :body => {'ipsecpolicies' => data[:ipsec_policies].values},
19
+ :status => 200
20
+ )
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ module Fog
2
+ module Network
3
+ class OpenStack
4
+ class Real
5
+ def list_ipsec_site_connections(filters = {})
6
+ request(
7
+ :expects => 200,
8
+ :method => 'GET',
9
+ :path => 'vpn/ipsec-site-connections',
10
+ :query => filters
11
+ )
12
+ end
13
+ end
14
+
15
+ class Mock
16
+ def list_ipsec_site_connections(*)
17
+ Excon::Response.new(
18
+ :body => {'ipsec_site_connections' => data[:ipsec_site_connections].values},
19
+ :status => 200
20
+ )
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ module Fog
2
+ module Network
3
+ class OpenStack
4
+ class Real
5
+ def list_vpn_services(filters = {})
6
+ request(
7
+ :expects => 200,
8
+ :method => 'GET',
9
+ :path => 'vpn/vpnservices',
10
+ :query => filters
11
+ )
12
+ end
13
+ end
14
+
15
+ class Mock
16
+ def list_vpn_services(*)
17
+ Excon::Response.new(
18
+ :body => {'vpnservices' => data[:vpn_services].values},
19
+ :status => 200
20
+ )
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,49 @@
1
+ module Fog
2
+ module Network
3
+ class OpenStack
4
+ class Real
5
+ def update_ike_policy(ike_policy_id, options = {})
6
+ data = {'ikepolicy' => {}}
7
+
8
+ vanilla_options = [:name, :description, :tenant_id,
9
+ :auth_algorithm, :encryption_algorithm,
10
+ :pfs, :phase1_negotiation_mode,
11
+ :lifetime, :ike_version
12
+ ]
13
+ vanilla_options.select { |o| options.key?(o) }.each do |key|
14
+ data['ikepolicy'][key] = options[key]
15
+ end
16
+
17
+ request(
18
+ :body => Fog::JSON.encode(data),
19
+ :expects => 200,
20
+ :method => 'PUT',
21
+ :path => "vpn/ikepolicies/#{ike_policy_id}"
22
+ )
23
+ end
24
+ end
25
+
26
+ class Mock
27
+ def update_ike_policy(ike_policy_id, options = {})
28
+ response = Excon::Response.new
29
+ if ike_policy = list_ike_policies.body['ikepolicies'].detect { |instance| instance['id'] == ike_policy_id }
30
+ ike_policy['name'] = options[:name]
31
+ ike_policy['description'] = options[:description]
32
+ ike_policy['tenant_id'] = options[:tenant_id]
33
+ ike_policy['auth_algorithm'] = options[:auth_algorithm]
34
+ ike_policy['encryption_algorithm'] = options[:encryption_algorithm]
35
+ ike_policy['pfs'] = options[:pfs]
36
+ ike_policy['phase1_negotiation_mode'] = options[:phase1_negotiation_mode]
37
+ ike_policy['lifetime'] = options[:lifetime]
38
+ ike_policy['ike_version'] = options[:ike_version]
39
+ response.body = {'ikepolicy' => ike_policy}
40
+ response.status = 200
41
+ response
42
+ else
43
+ raise Fog::Network::OpenStack::NotFound
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,52 @@
1
+ module Fog
2
+ module Network
3
+ class OpenStack
4
+ class Real
5
+ def update_ipsec_policy(ipsec_policy_id, options = {})
6
+ data = {'ipsecpolicy' => {}}
7
+
8
+ vanilla_options = [:name, :description, :tenant_id,
9
+ :auth_algorithm, :encryption_algorithm,
10
+ :pfs, :transform_protocol, :encapsulation_mode,
11
+ :lifetime, :ipsec_version
12
+ ]
13
+ vanilla_options.select { |o| options.key?(o) }.each do |key|
14
+ data['ipsecpolicy'][key] = options[key]
15
+ end
16
+
17
+ request(
18
+ :body => Fog::JSON.encode(data),
19
+ :expects => 200,
20
+ :method => 'PUT',
21
+ :path => "vpn/ipsecpolicies/#{ipsec_policy_id}"
22
+ )
23
+ end
24
+ end
25
+
26
+ class Mock
27
+ def update_ipsec_policy(ipsec_policy_id, options = {})
28
+ response = Excon::Response.new
29
+ ipsec_policy = list_ipsec_policies.body['ipsecpolicies'].detect do |instance|
30
+ instance['id'] == ipsec_policy_id
31
+ end
32
+ if ipsec_policy
33
+ ipsec_policy['name'] = options[:name]
34
+ ipsec_policy['description'] = options[:description]
35
+ ipsec_policy['tenant_id'] = options[:tenant_id]
36
+ ipsec_policy['auth_algorithm'] = options[:auth_algorithm]
37
+ ipsec_policy['encryption_algorithm'] = options[:encryption_algorithm]
38
+ ipsec_policy['pfs'] = options[:pfs]
39
+ ipsec_policy['transform_protocol'] = options[:transform_protocol]
40
+ ipsec_policy['encapsulation_mode'] = options[:encapsulation_mode]
41
+ ipsec_policy['lifetime'] = options[:lifetime]
42
+ response.body = {'ipsecpolicy' => ipsec_policy}
43
+ response.status = 200
44
+ response
45
+ else
46
+ raise Fog::Network::OpenStack::NotFound
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,64 @@
1
+ module Fog
2
+ module Network
3
+ class OpenStack
4
+ class Real
5
+ def update_ipsec_site_connection(ipsec_site_connection_id, options = {})
6
+ data = {'ipsec_site_connection' => {}}
7
+
8
+ vanilla_options = [:name, :description, :tenant_id,
9
+ :peer_address, :peer_id, :peer_cidrs,
10
+ :psk, :mtu, :dpd, :initiator,
11
+ :admin_state_up, :ikepolicy_id,
12
+ :ipsecpolicy_id, :vpnservice_id
13
+ ]
14
+ vanilla_options.select { |o| options.key?(o) }.each do |key|
15
+ data['ipsec_site_connection'][key] = options[key]
16
+ end
17
+
18
+ request(
19
+ :body => Fog::JSON.encode(data),
20
+ :expects => 200,
21
+ :method => 'PUT',
22
+ :path => "vpn/ipsec-site-connections/#{ipsec_site_connection_id}"
23
+ )
24
+ end
25
+ end
26
+
27
+ class Mock
28
+ def update_ipsec_site_connection(ipsec_site_connection_id, options = {})
29
+ response = Excon::Response.new
30
+ ipsec_site_connection = list_ipsec_site_connections.body['ipsec_site_connections'].detect do |instance|
31
+ instance['id'] == ipsec_site_connection_id
32
+ end
33
+ if ipsec_site_connection
34
+ ipsec_site_connection['name'] = options[:name]
35
+ ipsec_site_connection['description'] = options[:description]
36
+ ipsec_site_connection['tenant_id'] = options[:tenant_id]
37
+ ipsec_site_connection['status'] = 'ACTIVE'
38
+ ipsec_site_connection['admin_state_up'] = options[:admin_state_up]
39
+ ipsec_site_connection['psk'] = options[:psk]
40
+ ipsec_site_connection['initiator'] = options[:initiator]
41
+ ipsec_site_connection['auth_mode'] = "psk"
42
+ ipsec_site_connection['peer_cidrs'] = options[:peer_cidrs]
43
+ ipsec_site_connection['mtu'] = options[:mtu]
44
+ ipsec_site_connection['peer_ep_group_id'] = Fog::Mock.random_numbers(6).to_s
45
+ ipsec_site_connection['ikepolicy_id'] = options[:ikepolicy_id] || 'ike'
46
+ ipsec_site_connection['vpnservice_id'] = options[:vpnservice_id] || 'vpn'
47
+ ipsec_site_connection['dpd'] = options[:dpd]
48
+ ipsec_site_connection['route_mode'] = "static"
49
+ ipsec_site_connection['ipsecpolicy_id'] = options[:ipsecpolicy_id] || 'ipsec'
50
+ ipsec_site_connection['local_ep_group_id'] = Fog::Mock.random_numbers(6).to_s
51
+ ipsec_site_connection['peer_address'] = options[:peer_address]
52
+ ipsec_site_connection['peer_id'] = options[:peer_id]
53
+
54
+ response.body = {'ipsec_site_connection' => ipsec_site_connection}
55
+ response.status = 200
56
+ response
57
+ else
58
+ raise Fog::Network::OpenStack::NotFound
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,46 @@
1
+ module Fog
2
+ module Network
3
+ class OpenStack
4
+ class Real
5
+ def update_vpn_service(vpn_service_id, options = {})
6
+ data = {'vpnservice' => {}}
7
+
8
+ vanilla_options = [:name, :description, :admin_state_up]
9
+ vanilla_options.select { |o| options.key?(o) }.each do |key|
10
+ data['vpnservice'][key] = options[key]
11
+ end
12
+
13
+ request(
14
+ :body => Fog::JSON.encode(data),
15
+ :expects => 200,
16
+ :method => 'PUT',
17
+ :path => "vpn/vpnservices/#{vpn_service_id}"
18
+ )
19
+ end
20
+ end
21
+
22
+ class Mock
23
+ def update_vpn_service(vpn_service_id, options = {})
24
+ response = Excon::Response.new
25
+ if vpn_service = list_vpn_services.body['vpnservices'].detect { |instance| instance['id'] == vpn_service_id }
26
+ vpn_service['id'] = vpn_service_id
27
+ vpn_service['subnet_id'] = options[:subnet_id]
28
+ vpn_service['router_id'] = options[:router_id]
29
+ vpn_service['name'] = options[:name]
30
+ vpn_service['description'] = options[:description]
31
+ vpn_service['status'] = 'ACTIVE'
32
+ vpn_service['admin_state_up'] = options[:admin_state_up]
33
+ vpn_service['tenant_id'] = options[:tenant_id]
34
+ vpn_service['external_v4_ip'] = '1.2.3.4'
35
+ vpn_service['external_v6_ip'] = '::1'
36
+ response.body = {'vpnservice' => vpn_service}
37
+ response.status = 200
38
+ response
39
+ else
40
+ raise Fog::Network::OpenStack::NotFound
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -6,10 +6,10 @@ module Fog
6
6
  requires :openstack_auth_url
7
7
  recognizes :openstack_auth_token, :openstack_management_url,
8
8
  :persistent, :openstack_service_type, :openstack_service_name,
9
- :openstack_tenant, :openstack_tenant_id,
9
+ :openstack_tenant, :openstack_tenant_id, :openstack_userid,
10
10
  :openstack_api_key, :openstack_username, :openstack_identity_endpoint,
11
11
  :current_user, :current_tenant, :openstack_region,
12
- :openstack_endpoint_type,
12
+ :openstack_endpoint_type, :openstack_auth_omit_default_port,
13
13
  :openstack_project_name, :openstack_project_id,
14
14
  :openstack_project_domain, :openstack_user_domain, :openstack_domain_name,
15
15
  :openstack_project_domain_id, :openstack_user_domain_id, :openstack_domain_id,
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Openstack
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
data/tests/helper.rb CHANGED
@@ -1,3 +1,6 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+
1
4
  require File.expand_path('../../lib/fog/openstack', __FILE__)
2
5
 
3
6
  Bundler.require(:test)
@@ -0,0 +1,28 @@
1
+ Shindo.tests("Fog::Network[:openstack] | ike_policies", ['openstack']) do
2
+ @ike_policy = Fog::Network[:openstack].ike_policies.create(:name => 'test-ike-policy',
3
+ :description => 'Test VPN IKE Policy',
4
+ :tenant_id => 'tenant_id',
5
+ :auth_algorithm => 'sha1',
6
+ :encryption_algorithm => 'aes-256',
7
+ :pfs => 'group5',
8
+ :phase1_negotiation_mode => 'main',
9
+ :lifetime => {
10
+ 'units' => 'seconds',
11
+ 'value' => 3600
12
+ },
13
+ :ike_version => 'v1')
14
+
15
+ @ike_policies = Fog::Network[:openstack].ike_policies
16
+
17
+ tests('success') do
18
+ tests('#all').succeeds do
19
+ @ike_policies.all
20
+ end
21
+
22
+ tests('#get').succeeds do
23
+ @ike_policies.get(@ike_policy.id)
24
+ end
25
+ end
26
+
27
+ @ike_policy.destroy
28
+ end