fog-openstack 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -0
  3. data/.travis.yml +6 -2
  4. data/README.md +4 -0
  5. data/Rakefile +10 -2
  6. data/fog-openstack.gemspec +2 -3
  7. data/gemfiles/Gemfile-1.9 +1 -1
  8. data/lib/fog/openstack.rb +14 -6
  9. data/lib/fog/openstack/baremetal.rb +1 -1
  10. data/lib/fog/openstack/common.rb +0 -2
  11. data/lib/fog/openstack/compute.rb +78 -75
  12. data/lib/fog/openstack/core.rb +2 -1
  13. data/lib/fog/openstack/docs/compute.md +1 -1
  14. data/lib/fog/openstack/docs/network.md +283 -0
  15. data/lib/fog/openstack/docs/nfv.md +144 -0
  16. data/lib/fog/openstack/examples/compute/block_device_mapping_v2.rb +4 -4
  17. data/lib/fog/openstack/examples/network/network_add_port.rb +21 -0
  18. data/lib/fog/openstack/examples/network/network_rbac.rb +69 -0
  19. data/lib/fog/openstack/identity.rb +14 -22
  20. data/lib/fog/openstack/identity_v2.rb +1 -1
  21. data/lib/fog/openstack/image_v1.rb +13 -28
  22. data/lib/fog/openstack/image_v2.rb +15 -17
  23. data/lib/fog/openstack/introspection.rb +1 -1
  24. data/lib/fog/openstack/metering.rb +1 -1
  25. data/lib/fog/openstack/models/collection.rb +4 -1
  26. data/lib/fog/openstack/models/compute/availability_zone.rb +5 -0
  27. data/lib/fog/openstack/models/compute/flavor.rb +21 -9
  28. data/lib/fog/openstack/models/compute/server.rb +64 -77
  29. data/lib/fog/openstack/models/compute/snapshot.rb +6 -6
  30. data/lib/fog/openstack/models/compute/volume_attachment.rb +15 -0
  31. data/lib/fog/openstack/models/compute/volume_attachments.rb +20 -0
  32. data/lib/fog/openstack/models/identity_v3/projects.rb +1 -1
  33. data/lib/fog/openstack/models/identity_v3/users.rb +2 -2
  34. data/lib/fog/openstack/models/image_v2/image.rb +41 -22
  35. data/lib/fog/openstack/models/network/floating_ip.rb +1 -0
  36. data/lib/fog/openstack/models/network/rbac_policies.rb +33 -0
  37. data/lib/fog/openstack/models/network/rbac_policy.rb +35 -0
  38. data/lib/fog/openstack/models/nfv/vnf.rb +58 -0
  39. data/lib/fog/openstack/models/nfv/vnfd.rb +53 -0
  40. data/lib/fog/openstack/models/nfv/vnfds.rb +28 -0
  41. data/lib/fog/openstack/models/nfv/vnfs.rb +28 -0
  42. data/lib/fog/openstack/models/volume/snapshot.rb +38 -0
  43. data/lib/fog/openstack/models/volume/snapshots.rb +26 -0
  44. data/lib/fog/openstack/models/volume/volume.rb +32 -2
  45. data/lib/fog/openstack/models/volume/volume_type.rb +3 -4
  46. data/lib/fog/openstack/models/volume_v1/snapshot.rb +43 -0
  47. data/lib/fog/openstack/models/volume_v1/snapshots.rb +16 -0
  48. data/lib/fog/openstack/models/volume_v1/volume.rb +12 -2
  49. data/lib/fog/openstack/models/volume_v2/snapshot.rb +43 -0
  50. data/lib/fog/openstack/models/volume_v2/snapshots.rb +16 -0
  51. data/lib/fog/openstack/models/volume_v2/volume.rb +12 -3
  52. data/lib/fog/openstack/network.rb +53 -46
  53. data/lib/fog/openstack/nfv.rb +158 -0
  54. data/lib/fog/openstack/orchestration.rb +1 -1
  55. data/lib/fog/openstack/planning.rb +1 -1
  56. data/lib/fog/openstack/requests/compute/create_server.rb +1 -1
  57. data/lib/fog/openstack/requests/compute/{create_volume_snapshot.rb → create_snapshot.rb} +16 -16
  58. data/lib/fog/openstack/requests/compute/delete_flavor_metadata.rb +30 -0
  59. data/lib/fog/openstack/requests/compute/evacuate_server.rb +8 -7
  60. data/lib/fog/openstack/requests/compute/get_key_pair.rb +49 -0
  61. data/lib/fog/openstack/requests/compute/list_availability_zones.rb +23 -0
  62. data/lib/fog/openstack/requests/compute/list_volume_attachments.rb +31 -0
  63. data/lib/fog/openstack/requests/compute/update_flavor_metadata.rb +33 -0
  64. data/lib/fog/openstack/requests/network/create_rbac_policy.rb +42 -0
  65. data/lib/fog/openstack/requests/network/delete_rbac_policy.rb +28 -0
  66. data/lib/fog/openstack/requests/network/get_rbac_policy.rb +28 -0
  67. data/lib/fog/openstack/requests/network/list_rbac_policies.rb +25 -0
  68. data/lib/fog/openstack/requests/network/update_port.rb +8 -7
  69. data/lib/fog/openstack/requests/network/update_rbac_policy.rb +41 -0
  70. data/lib/fog/openstack/requests/nfv/create_vnf.rb +37 -0
  71. data/lib/fog/openstack/requests/nfv/create_vnfd.rb +35 -0
  72. data/lib/fog/openstack/requests/nfv/delete_vnf.rb +23 -0
  73. data/lib/fog/openstack/requests/nfv/delete_vnfd.rb +23 -0
  74. data/lib/fog/openstack/requests/nfv/get_vnf.rb +24 -0
  75. data/lib/fog/openstack/requests/nfv/get_vnfd.rb +24 -0
  76. data/lib/fog/openstack/requests/nfv/list_vnfds.rb +25 -0
  77. data/lib/fog/openstack/requests/nfv/list_vnfs.rb +25 -0
  78. data/lib/fog/openstack/requests/nfv/update_vnf.rb +35 -0
  79. data/lib/fog/openstack/requests/volume/action.rb +16 -0
  80. data/lib/fog/openstack/requests/volume/create_snapshot.rb +18 -0
  81. data/lib/fog/openstack/requests/volume/delete_metadata.rb +15 -0
  82. data/lib/fog/openstack/requests/volume/delete_snapshot.rb +5 -5
  83. data/lib/fog/openstack/requests/volume/delete_snapshot_metadata.rb +15 -0
  84. data/lib/fog/openstack/requests/volume/replace_metadata.rb +20 -0
  85. data/lib/fog/openstack/requests/volume/update_metadata.rb +20 -0
  86. data/lib/fog/openstack/requests/volume/update_snapshot.rb +37 -0
  87. data/lib/fog/openstack/requests/volume/update_snapshot_metadata.rb +20 -0
  88. data/lib/fog/openstack/requests/volume/update_volume.rb +25 -0
  89. data/lib/fog/openstack/requests/volume_v1/action.rb +2 -0
  90. data/lib/fog/openstack/requests/volume_v1/create_snapshot.rb +45 -0
  91. data/lib/fog/openstack/requests/volume_v1/delete_metadata.rb +2 -0
  92. data/lib/fog/openstack/requests/volume_v1/delete_snapshot_metadata.rb +2 -0
  93. data/lib/fog/openstack/requests/volume_v1/replace_metadata.rb +2 -0
  94. data/lib/fog/openstack/requests/volume_v1/update_metadata.rb +2 -0
  95. data/lib/fog/openstack/requests/volume_v1/update_snapshot.rb +2 -0
  96. data/lib/fog/openstack/requests/volume_v1/update_snapshot_metadata.rb +2 -0
  97. data/lib/fog/openstack/requests/volume_v1/update_volume.rb +2 -0
  98. data/lib/fog/openstack/requests/volume_v2/action.rb +2 -0
  99. data/lib/fog/openstack/requests/volume_v2/create_snapshot.rb +45 -0
  100. data/lib/fog/openstack/requests/volume_v2/delete_metadata.rb +2 -0
  101. data/lib/fog/openstack/requests/volume_v2/delete_snapshot_metadata.rb +2 -0
  102. data/lib/fog/openstack/requests/volume_v2/replace_metadata.rb +2 -0
  103. data/lib/fog/openstack/requests/volume_v2/update_metadata.rb +2 -0
  104. data/lib/fog/openstack/requests/volume_v2/update_snapshot.rb +2 -0
  105. data/lib/fog/openstack/requests/volume_v2/update_snapshot_metadata.rb +2 -0
  106. data/lib/fog/openstack/requests/volume_v2/update_volume.rb +2 -0
  107. data/lib/fog/openstack/storage.rb +1 -1
  108. data/lib/fog/openstack/version.rb +1 -1
  109. data/lib/fog/openstack/volume.rb +1 -1
  110. data/lib/fog/openstack/volume_v1.rb +29 -21
  111. data/lib/fog/openstack/volume_v2.rb +29 -21
  112. data/supported.md +54 -0
  113. data/tests/openstack/models/identity/ec2_credential_tests.rb +1 -1
  114. data/tests/openstack/models/identity/ec2_credentials_tests.rb +1 -1
  115. data/tests/openstack/models/identity/role_tests.rb +8 -3
  116. data/tests/openstack/models/identity/roles_tests.rb +5 -4
  117. data/tests/openstack/models/identity/tenant_tests.rb +7 -4
  118. data/tests/openstack/models/identity/tenants_tests.rb +10 -5
  119. data/tests/openstack/models/identity/user_tests.rb +4 -3
  120. data/tests/openstack/models/identity/users_tests.rb +10 -6
  121. data/tests/openstack/models/nfv/vnf_tests.rb +35 -0
  122. data/tests/openstack/models/nfv/vnfd_tests.rb +23 -0
  123. data/tests/openstack/models/nfv/vnfds_tests.rb +31 -0
  124. data/tests/openstack/models/nfv/vnfs_tests.rb +38 -0
  125. data/tests/openstack/requests/identity/ec2_credentials_tests.rb +6 -9
  126. data/tests/openstack/requests/identity/helper.rb +12 -4
  127. data/tests/openstack/requests/identity/role_tests.rb +13 -10
  128. data/tests/openstack/requests/identity/tenant_tests.rb +10 -9
  129. data/tests/openstack/requests/identity/user_tests.rb +11 -6
  130. data/tests/openstack/requests/image/image_tests.rb +1 -0
  131. data/tests/openstack/requests/nfv/vnf_tests.rb +70 -0
  132. data/tests/openstack/requests/nfv/vnfd_tests.rb +44 -0
  133. metadata +81 -31
  134. data/lib/fog/openstack/requests/volume/create_volume_snapshot.rb +0 -26
  135. data/lib/fog/openstack/requests/volume_v1/create_volume_snapshot.rb +0 -44
  136. data/lib/fog/openstack/requests/volume_v2/create_volume_snapshot.rb +0 -43
  137. data/tests/openstack/authenticate_tests.rb +0 -200
  138. data/tests/openstack/identity_version_tests.rb +0 -25
  139. data/tests/openstack/storage_tests.rb +0 -18
  140. data/tests/openstack/version_tests.rb +0 -55
  141. data/tests/openstack/volume_tests.rb +0 -18
@@ -0,0 +1,42 @@
1
+ module Fog
2
+ module Network
3
+ class OpenStack
4
+ class Real
5
+ def create_rbac_policy(options = {})
6
+ data = {'rbac_policy' => {}}
7
+
8
+ vanilla_options = [:object_type, :object_id, :tenant_id, :target_tenant, :action]
9
+ vanilla_options.select { |o| options.key?(o) }.each do |key|
10
+ data['rbac_policy'][key] = options[key]
11
+ end
12
+
13
+ request(
14
+ :body => Fog::JSON.encode(data),
15
+ :expects => [201],
16
+ :method => 'POST',
17
+ :path => 'rbac-policies'
18
+ )
19
+ end
20
+ end
21
+
22
+ class Mock
23
+ def create_rbac_policy(options = {})
24
+ response = Excon::Response.new
25
+ response.status = 201
26
+ data = {
27
+ 'id' => Fog::Mock.random_numbers(6).to_s,
28
+ 'object_type' => options[:object_type],
29
+ 'object_id' => options[:object_id],
30
+ 'tenant_id' => options[:tenant_id],
31
+ 'target_tenant' => options[:target_tenant],
32
+ 'action' => options[:action]
33
+ }
34
+
35
+ self.data[:rbac_policies][data['id']] = data
36
+ response.body = {'rbac_policy' => data}
37
+ response
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,28 @@
1
+ module Fog
2
+ module Network
3
+ class OpenStack
4
+ class Real
5
+ def delete_rbac_policy(rbac_policy_id)
6
+ request(
7
+ :expects => 204,
8
+ :method => 'DELETE',
9
+ :path => "rbac-policies/#{rbac_policy_id}"
10
+ )
11
+ end
12
+ end
13
+
14
+ class Mock
15
+ def delete_rbac_policy(rbac_policy_id)
16
+ response = Excon::Response.new
17
+ if list_rbac_policies.body['rbac_policies'].collect { |r| r['id'] }.include? rbac_policy_id
18
+ data[:rbac_policies].delete(rbac_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 get_rbac_policy(rbac_policy_id)
6
+ request(
7
+ :expects => [200],
8
+ :method => 'GET',
9
+ :path => "rbac-policies/#{rbac_policy_id}"
10
+ )
11
+ end
12
+ end
13
+
14
+ class Mock
15
+ def get_rbac_policy(rbac_policy_id)
16
+ response = Excon::Response.new
17
+ if data = self.data[:rbac_policies][rbac_policy_id]
18
+ response.status = 200
19
+ response.body = {'rbac_policy' => 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_rbac_policies(filters = {})
6
+ request(
7
+ :expects => 200,
8
+ :method => 'GET',
9
+ :path => 'rbac-policies',
10
+ :query => filters
11
+ )
12
+ end
13
+ end
14
+
15
+ class Mock
16
+ def list_rbac_policies(*)
17
+ Excon::Response.new(
18
+ :body => {'rbac_policies' => data[:rbac_policies].values},
19
+ :status => 200
20
+ )
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -6,7 +6,7 @@ module Fog
6
6
  data = { 'port' => {} }
7
7
 
8
8
  vanilla_options = [:name, :fixed_ips, :admin_state_up, :device_owner,
9
- :device_id, :security_groups]
9
+ :device_id, :security_groups, :allowed_address_pairs]
10
10
  vanilla_options.select{ |o| options.key?(o) }.each do |key|
11
11
  data['port'][key] = options[key]
12
12
  end
@@ -24,12 +24,13 @@ module Fog
24
24
  def update_port(port_id, options = {})
25
25
  response = Excon::Response.new
26
26
  if port = list_ports.body['ports'].find { |_| _['id'] == port_id }
27
- port['name'] = options[:name]
28
- port['fixed_ips'] = options[:fixed_ips] || []
29
- port['admin_state_up'] = options[:admin_state_up]
30
- port['device_owner'] = options[:device_owner]
31
- port['device_id'] = options[:device_id]
32
- port['security_groups'] = options[:security_groups] || []
27
+ port['name'] = options[:name]
28
+ port['fixed_ips'] = options[:fixed_ips] || []
29
+ port['admin_state_up'] = options[:admin_state_up]
30
+ port['device_owner'] = options[:device_owner]
31
+ port['device_id'] = options[:device_id]
32
+ port['security_groups'] = options[:security_groups] || []
33
+ port['allowed_address_pairs'] = options[:allowed_address_pairs] || []
33
34
  response.body = { 'port' => port }
34
35
  response.status = 200
35
36
  response
@@ -0,0 +1,41 @@
1
+ module Fog
2
+ module Network
3
+ class OpenStack
4
+ class Real
5
+ def update_rbac_policy(rbac_policy_id, options = {})
6
+ data = {'rbac_policy' => {}}
7
+
8
+ vanilla_options = [:target_tenant]
9
+ vanilla_options.select { |o| options.key?(o) }.each do |key|
10
+ data['rbac_policy'][key] = options[key]
11
+ end
12
+
13
+ request(
14
+ :body => Fog::JSON.encode(data),
15
+ :expects => 200,
16
+ :method => 'PUT',
17
+ :path => "rbac-policies/#{rbac_policy_id}"
18
+ )
19
+ end
20
+ end
21
+
22
+ class Mock
23
+ def update_rbac_policy(rbac_policy_id, options = {})
24
+ response = Excon::Response.new
25
+ rbac_policy = list_rbac_policies.body['rbac_policies'].detect do |instance|
26
+ instance['id'] == rbac_policy_id
27
+ end
28
+ if rbac_policy
29
+ rbac_policy['target_tenant'] = options[:target_tenant]
30
+
31
+ response.body = {'rbac_policy' => rbac_policy}
32
+ response.status = 200
33
+ response
34
+ else
35
+ raise Fog::Network::OpenStack::NotFound
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,37 @@
1
+ module Fog
2
+ module NFV
3
+ class OpenStack
4
+ class Real
5
+ def create_vnf(options)
6
+ options_valid = [
7
+ :auth,
8
+ :vnf,
9
+ ]
10
+
11
+ # Filter only allowed creation attributes
12
+ data = options.select do |key, _|
13
+ options_valid.include?(key.to_sym) || options_valid.include?(key.to_s)
14
+ end
15
+
16
+ request(
17
+ :body => Fog::JSON.encode(data),
18
+ :expects => 201,
19
+ :method => "POST",
20
+ :path => "vnfs"
21
+ )
22
+ end
23
+ end
24
+
25
+ class Mock
26
+ def create_vnf(_)
27
+ response = Excon::Response.new
28
+ response.status = 201
29
+
30
+ create_data = data[:vnfs].first.merge("vnfd_id" => "id")
31
+ response.body = {"vnf" => create_data}
32
+ response
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,35 @@
1
+ module Fog
2
+ module NFV
3
+ class OpenStack
4
+ class Real
5
+ def create_vnfd(options)
6
+ options_valid = [
7
+ :auth,
8
+ :vnfd,
9
+ ]
10
+
11
+ # Filter only allowed creation attributes
12
+ data = options.select do |key, _|
13
+ options_valid.include?(key.to_sym) || options_valid.include?(key.to_s)
14
+ end
15
+
16
+ request(
17
+ :body => Fog::JSON.encode(data),
18
+ :expects => 201,
19
+ :method => "POST",
20
+ :path => "vnfds"
21
+ )
22
+ end
23
+ end
24
+
25
+ class Mock
26
+ def create_vnfd(_)
27
+ response = Excon::Response.new
28
+ response.status = 201
29
+ response.body = {"vnfd" => data[:vnfds].first}
30
+ response
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,23 @@
1
+ module Fog
2
+ module NFV
3
+ class OpenStack
4
+ class Real
5
+ def delete_vnf(vnf_id)
6
+ request(
7
+ :expects => 204,
8
+ :method => "DELETE",
9
+ :path => "vnfs/#{vnf_id}"
10
+ )
11
+ end
12
+ end
13
+
14
+ class Mock
15
+ def delete_vnf(_vnf_id)
16
+ response = Excon::Response.new
17
+ response.status = 204
18
+ response
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ module Fog
2
+ module NFV
3
+ class OpenStack
4
+ class Real
5
+ def delete_vnfd(vnfd_id)
6
+ request(
7
+ :expects => 204,
8
+ :method => "DELETE",
9
+ :path => "vnfds/#{vnfd_id}"
10
+ )
11
+ end
12
+ end
13
+
14
+ class Mock
15
+ def delete_vnfd(_vnfd_id)
16
+ response = Excon::Response.new
17
+ response.status = 204
18
+ response
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,24 @@
1
+ module Fog
2
+ module NFV
3
+ class OpenStack
4
+ class Real
5
+ def get_vnf(vnf_id)
6
+ request(
7
+ :expects => 200,
8
+ :method => 'GET',
9
+ :path => "vnfs/#{vnf_id}"
10
+ )
11
+ end
12
+ end
13
+
14
+ class Mock
15
+ def get_vnf(_vnf_id)
16
+ response = Excon::Response.new
17
+ response.status = 200
18
+ response.body = {"vnf" => data[:vnfs].first}
19
+ response
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ module Fog
2
+ module NFV
3
+ class OpenStack
4
+ class Real
5
+ def get_vnfd(vnfd_id)
6
+ request(
7
+ :expects => 200,
8
+ :method => 'GET',
9
+ :path => "vnfds/#{vnfd_id}"
10
+ )
11
+ end
12
+ end
13
+
14
+ class Mock
15
+ def get_vnfd(_vnfd_id)
16
+ response = Excon::Response.new
17
+ response.status = 200
18
+ response.body = {"vnfd" => data[:vnfds].first}
19
+ response
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,25 @@
1
+ module Fog
2
+ module NFV
3
+ class OpenStack
4
+ class Real
5
+ def list_vnfds(options = {})
6
+ request(
7
+ :expects => 200,
8
+ :method => 'GET',
9
+ :path => "vnfds",
10
+ :query => options
11
+ )
12
+ end
13
+ end
14
+
15
+ class Mock
16
+ def list_vnfds(_options = {})
17
+ response = Excon::Response.new
18
+ response.status = 200
19
+ response.body = {"vnfds" => data[:vnfds]}
20
+ response
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ module Fog
2
+ module NFV
3
+ class OpenStack
4
+ class Real
5
+ def list_vnfs(options = {})
6
+ request(
7
+ :expects => 200,
8
+ :method => 'GET',
9
+ :path => "vnfs",
10
+ :query => options
11
+ )
12
+ end
13
+ end
14
+
15
+ class Mock
16
+ def list_vnfs(_options = {})
17
+ response = Excon::Response.new
18
+ response.status = 200
19
+ response.body = {"vnfs" => data[:vnfs]}
20
+ response
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,35 @@
1
+ module Fog
2
+ module NFV
3
+ class OpenStack
4
+ class Real
5
+ def update_vnf(id, options)
6
+ options_valid = [
7
+ :auth,
8
+ :vnf,
9
+ ]
10
+
11
+ # Filter only allowed creation attributes
12
+ data = options.select do |key, _|
13
+ options_valid.include?(key.to_sym) || options_valid.include?(key.to_s)
14
+ end
15
+
16
+ request(
17
+ :body => Fog::JSON.encode(data),
18
+ :expects => 200,
19
+ :method => "PUT",
20
+ :path => "vnfs/#{id}",
21
+ )
22
+ end
23
+ end
24
+
25
+ class Mock
26
+ def update_vnf(_, _)
27
+ response = Excon::Response.new
28
+ response.status = 200
29
+ response.body = {"vnf" => data[:vnfs].first}
30
+ response
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end