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,158 @@
1
+ require 'yaml'
2
+
3
+ module Fog
4
+ module NFV
5
+ class OpenStack < Fog::Service
6
+ SUPPORTED_VERSIONS = /v1.0/
7
+
8
+ requires :openstack_auth_url
9
+ recognizes :openstack_auth_token, :openstack_management_url,
10
+ :persistent, :openstack_service_type, :openstack_service_name,
11
+ :openstack_tenant, :openstack_tenant_id,
12
+ :openstack_api_key, :openstack_username, :openstack_identity_endpoint,
13
+ :current_user, :current_tenant, :openstack_region,
14
+ :openstack_endpoint_type,
15
+ :openstack_project_name, :openstack_project_id,
16
+ :openstack_project_domain, :openstack_user_domain, :openstack_domain_name,
17
+ :openstack_project_domain_id, :openstack_user_domain_id, :openstack_domain_id
18
+
19
+ ## REQUESTS
20
+ #
21
+ request_path 'fog/openstack/requests/nfv'
22
+
23
+ # vnfds requests
24
+ request :list_vnfds
25
+ request :get_vnfd
26
+ request :create_vnfd
27
+ request :delete_vnfd
28
+
29
+ # vfns requests
30
+ request :list_vnfs
31
+ request :get_vnf
32
+ request :create_vnf
33
+ request :update_vnf
34
+ request :delete_vnf
35
+
36
+ ## MODELS
37
+ #
38
+ model_path 'fog/openstack/models/nfv'
39
+ model :vnfd
40
+ collection :vnfds
41
+ model :vnf
42
+ collection :vnfs
43
+
44
+ class Mock
45
+ def self.data
46
+ @data ||= Hash.new do |hash, key|
47
+ hash[key] = {
48
+ :vnfs => [
49
+ {
50
+ "status" => "ACTIVE",
51
+ "description" => "demo-example",
52
+ "tenant_id" => "943b6ff8229a4ec2bed0a306f869a0ea",
53
+ "instance_id" => "5a9a7d3b-24f5-4226-8d43-262972a1776e",
54
+ "mgmt_url" => "{\"vdu1\": \"192.168.0.8\"}",
55
+ "attributes" => {"monitoring_policy" => "{\"vdus\": {}}"},
56
+ "id" => "cb4cdbd8-cf1a-4758-8d36-40db788a37a1",
57
+ "name" => "LadasTest"
58
+ }
59
+ ],
60
+ :vnfds => [
61
+ {
62
+ "service_types" => [{"service_type" => "vnfd", "id" => "f9211d81-b58a-4849-8d38-e25376c421bd"}],
63
+ "description" => "demo-example",
64
+ "tenant_id" => "943b6ff8229a4ec2bed0a306f869a0ea",
65
+ "mgmt_driver" => "noop",
66
+ "infra_driver" => "heat",
67
+ "attributes" => {"vnfd" => "template_name: sample-vnfd"},
68
+ "id" => "1f8f33cf-8c94-427e-a040-f3e393b773b7",
69
+ "name" => "sample-vnfd"
70
+ }
71
+ ]
72
+ }
73
+ end
74
+ end
75
+
76
+ def self.reset
77
+ @data = nil
78
+ end
79
+
80
+ include Fog::OpenStack::Core
81
+
82
+ def initialize(options = {})
83
+ @auth_token = Fog::Mock.random_base64(64)
84
+ @auth_token_expiration = (Time.now.utc + 86_400).iso8601
85
+
86
+ initialize_identity options
87
+ end
88
+
89
+ def data
90
+ self.class.data[@openstack_username]
91
+ end
92
+
93
+ def reset_data
94
+ self.class.data.delete(@openstack_username)
95
+ end
96
+ end
97
+
98
+ class Real
99
+ include Fog::OpenStack::Core
100
+
101
+ def initialize(options = {})
102
+ initialize_identity options
103
+
104
+ @openstack_service_type = options[:openstack_service_type] || ['servicevm']
105
+ @openstack_service_name = options[:openstack_service_name]
106
+
107
+ @connection_options = options[:connection_options] || {}
108
+
109
+ authenticate
110
+
111
+ unless @path.match(SUPPORTED_VERSIONS)
112
+ @path = "/" + Fog::OpenStack.get_supported_version(
113
+ SUPPORTED_VERSIONS,
114
+ @openstack_management_uri,
115
+ @auth_token,
116
+ @connection_options
117
+ )
118
+ end
119
+
120
+ @persistent = options[:persistent] || false
121
+ @connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
122
+ end
123
+
124
+ def request(params)
125
+ response = @connection.request(
126
+ params.merge(
127
+ :headers => {
128
+ 'Content-Type' => 'application/json',
129
+ 'X-Auth-Token' => @auth_token
130
+ }.merge!(params[:headers] || {}),
131
+ :path => "#{@path}/#{params[:path]}"
132
+ )
133
+ )
134
+ rescue Excon::Errors::Unauthorized => error
135
+ if error.response.body != "Bad username or password" # token expiration
136
+ @openstack_must_reauthenticate = true
137
+ authenticate
138
+ retry
139
+ else # bad credentials
140
+ raise error
141
+ end
142
+ rescue Excon::Errors::HTTPStatusError => error
143
+ raise case error
144
+ when Excon::Errors::NotFound
145
+ Fog::NFV::OpenStack::NotFound.slurp(error)
146
+ else
147
+ error
148
+ end
149
+ else
150
+ unless response.body.empty?
151
+ response.body = Fog::JSON.decode(response.body)
152
+ end
153
+ response
154
+ end
155
+ end
156
+ end
157
+ end
158
+ end
@@ -9,7 +9,7 @@ module Fog
9
9
  :openstack_tenant, :openstack_tenant_id,
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_cache_ttl,
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,
@@ -11,7 +11,7 @@ module Fog
11
11
  :openstack_tenant, :openstack_tenant_id,
12
12
  :openstack_api_key, :openstack_username, :openstack_identity_endpoint,
13
13
  :current_user, :current_tenant, :openstack_region,
14
- :openstack_endpoint_type,
14
+ :openstack_endpoint_type, :openstack_cache_ttl,
15
15
  :openstack_project_name, :openstack_project_id,
16
16
  :openstack_project_domain, :openstack_user_domain, :openstack_domain_name,
17
17
  :openstack_project_domain_id, :openstack_user_domain_id, :openstack_domain_id,
@@ -77,7 +77,7 @@ module Fog
77
77
  end
78
78
  end
79
79
 
80
- path = block_device_mapping ? 'os-volumes_boot.json' : 'servers.json'
80
+ path = options['block_device_mapping'] ? 'os-volumes_boot.json' : 'servers.json'
81
81
 
82
82
  request(
83
83
  :body => Fog::JSON.encode(data),
@@ -2,7 +2,7 @@ module Fog
2
2
  module Compute
3
3
  class OpenStack
4
4
  class Real
5
- def create_volume_snapshot(volume_id, name, description, force=false)
5
+ def create_snapshot(volume_id, name, description, force = false)
6
6
  data = {
7
7
  'snapshot' => {
8
8
  'volume_id' => volume_id,
@@ -13,36 +13,36 @@ module Fog
13
13
  }
14
14
 
15
15
  request(
16
- :body => Fog::JSON.encode(data),
17
- :expects => [200, 202],
18
- :method => 'POST',
19
- :path => "os-snapshots"
16
+ :body => Fog::JSON.encode(data),
17
+ :expects => [200, 202],
18
+ :method => 'POST',
19
+ :path => "os-snapshots"
20
20
  )
21
21
  end
22
22
  end
23
23
 
24
24
  class Mock
25
- def create_volume_snapshot(volume_id, name, description, force=false)
25
+ def create_snapshot(volume_id, name, description, _force = false)
26
26
  volume_response = get_volume_details(volume_id)
27
27
  volume = volume_response.data[:body]['volume']
28
- unless volume.nil?
28
+ if volume.nil?
29
+ raise Fog::Compute::OpenStack::NotFound
30
+ else
29
31
  response = Excon::Response.new
30
32
  data = {
31
- "status" => "availble",
32
- "name" => name,
33
- "created_at" => Time.now,
33
+ "status" => "availble",
34
+ "name" => name,
35
+ "created_at" => Time.now,
34
36
  "description" => description,
35
- "volume_id" => volume_id,
36
- "id" => Fog::Mock.random_numbers(2),
37
- "size" => volume['size']
37
+ "volume_id" => volume_id,
38
+ "id" => Fog::Mock.random_numbers(2),
39
+ "size" => volume['size']
38
40
  }
39
41
 
40
42
  self.data[:snapshots][data['id']] = data
41
- response.body = { "snapshot" => data }
43
+ response.body = {"snapshot" => data}
42
44
  response.status = 202
43
45
  response
44
- else
45
- raise Fog::Compute::OpenStack::NotFound
46
46
  end
47
47
  end
48
48
  end
@@ -0,0 +1,30 @@
1
+ module Fog
2
+ module Compute
3
+ class OpenStack
4
+ class Real
5
+ def delete_flavor_metadata(flavor_ref, key)
6
+ request(
7
+ :expects => 200,
8
+ :method => 'DELETE',
9
+ :path => "flavors/#{flavor_ref}/os-extra_specs/#{key}"
10
+ )
11
+ end
12
+ end
13
+
14
+ class Mock
15
+ def delete_flavor_metadata(_flavor_ref, _key)
16
+ response = Excon::Response.new
17
+ response.status = 200
18
+ response.headers = {
19
+ "X-Compute-Request-Id" => "req-fdc6f99e-55a2-4ab1-8904-0892753828cf",
20
+ "Content-Type" => "application/json",
21
+ "Content-Length" => "356",
22
+ "Date" => Date.new
23
+ }
24
+ response.body = nil
25
+ response
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -2,11 +2,12 @@ module Fog
2
2
  module Compute
3
3
  class OpenStack
4
4
  class Real
5
- def evacuate_server(server_id, host = nil, on_shared_storage = true, admin_password = nil)
6
- evacuate = {'onSharedStorage' => on_shared_storage}
7
- evacuate['host'] = host if host
8
- evacuate['adminPass'] = admin_password if admin_password
9
- body = {
5
+ def evacuate_server(server_id, host = nil, on_shared_storage = nil, admin_password = nil)
6
+ evacuate = {}
7
+ evacuate['host'] = host if host
8
+ evacuate['onSharedStorage'] = on_shared_storage if on_shared_storage
9
+ evacuate['adminPass'] = admin_password if admin_password
10
+ body = {
10
11
  'evacuate' => evacuate
11
12
  }
12
13
  server_action(server_id, body)
@@ -14,8 +15,8 @@ module Fog
14
15
  end
15
16
 
16
17
  class Mock
17
- def evacuate_server(server_id, host, on_shared_storage, admin_password = nil)
18
- response = Excon::Response.new
18
+ def evacuate_server(_server_id, _host, _on_shared_storage, _admin_password = nil)
19
+ response = Excon::Response.new
19
20
  response.status = 202
20
21
  response
21
22
  end
@@ -0,0 +1,49 @@
1
+ module Fog
2
+ module Compute
3
+ class OpenStack
4
+ class Real
5
+ def get_key_pair(key_name)
6
+ request(
7
+ :expects => 200,
8
+ :method => 'GET',
9
+ :path => "os-keypairs/#{key_name}"
10
+ )
11
+ end
12
+ end
13
+
14
+ class Mock
15
+ def delete_key_pair(key_name)
16
+ response = Excon::Response.new
17
+ response.status = 200
18
+ response.headers = {
19
+ "X-Compute-Request-Id" => "req-c373a42c-2825-4e60-8d34-99416ea850be",
20
+ "Content-Type" => "application/json",
21
+ "Content-Length" => "1289",
22
+ "Date" => Date.new}
23
+ response.body = {
24
+ "keypair" => {
25
+ "public_key" => "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDCdAZLjljntJbLVVkNHjWFSoKen2nZbk39ZfqhZJOMdeFdz"\
26
+ "02GWBS45rcuboeGg/gozKRwsLu4N6NLPlYtbK/NapJIvgO/djBp+FQG1QZNtLPsx7j4hVJac3yISGms+Xtu4c"\
27
+ "Ev6j5sFDzAgTQbWez0Z1+9qOq9ngdaoW+YClfQ== vagrant@nova\n",
28
+ "private_key" => "-----BEGIN RSA PRIVATE KEY-----\nMIICXgIBAAKBgQDCdAZLjljn1tJbLVVkNHjWFSoKen2nZbk39Zfq"\
29
+ "hZJOMdeFdz02\nGWBS45rcuHboeGg/gozKRwsLu4N6NLPlYtbK/NapJIvgO/djBp+FQG1QZNtLPsx7\nj4hVJ"\
30
+ "ac3yISGms+Xtu4cEv6j5sFDzAgTQbWez0Z1+9qOq9ngdaoW+YClfQIDAQAB\nAoGBALBoT9m1vuQ82EONQf2R"\
31
+ "ONqHAsfUzi/SMhEZRgOlv9AemXZkcWyl4uPvxmtd\nEcreiTystAtCHjw7lhCExXthipevUjtIAAt+b3pMn6O"\
32
+ "yjad3IRvde6atMdjrje43\n/nftYtuXYyJTsvwEvLYqSioLQ0Nn/XDKhOpcM5tejDHOH35lAkEA+H4r7y9X52"\
33
+ "1u\nIABVAezBWaT/wvdMjx5cwfyYEQjnI1bxfRIqkgoY5gDDBdVbT75UTsHHbHLORQcw\nRjRvS2zgewJBAMh"\
34
+ "T6eyMonJvHHvC5RcchcY+dWkscIKoOzeyUKMb+7tERQa9/UN2\njYb+jdM0VyL0ruLFwYtl2m34gfmhcXgIvG"\
35
+ "cCQGzKMEnjHEUBr7jq7EyPbobkqeSd\niDMQQ+PZxmmO0EK0ib0L+v881HG926PuKK/cz+Q7Cif8iznFT+ksg"\
36
+ "50t6YkCQQC9\nwfcAskqieSuS9A9LcCIrojhXctf0e+T0Ij2N89DlF4sHEuqXf/IZ4IB5gsfTfdE3\nUDnAkK"\
37
+ "9yogaEbu/r0uKbAkEAy5kl71bIqvKTKsY2mES9ziVxfftl/9UIi5LI+QHb\nmC/c6cTrGVCM71fi2GMxGgBeE"\
38
+ "ea4+7xwoWTL4CxA00kmTg==\n-----END RSA PRIVATE KEY-----\n",
39
+ "user_id" => "admin",
40
+ "name" => key_name,
41
+ "fingerprint" => "97:86:f4:15:68:0c:7b:a7:e5:8f:f0:bd:1f:27:65:ad"
42
+ }
43
+ }
44
+ response
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,23 @@
1
+ module Fog
2
+ module Compute
3
+ class OpenStack
4
+ class Real
5
+ def list_availability_zones(options = {})
6
+ params = options
7
+
8
+ request(
9
+ :expects => [200],
10
+ :method => 'GET',
11
+ :path => "os-availability-zone",
12
+ :query => params
13
+ )
14
+ end
15
+ end
16
+
17
+ class Mock
18
+ def list_endpoints
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,31 @@
1
+ module Fog
2
+ module Compute
3
+ class OpenStack
4
+ class Real
5
+ def list_volume_attachments(server_id)
6
+ request(
7
+ expects: 200,
8
+ method: 'GET',
9
+ path: format('servers/%s/os-volume_attachments', server_id)
10
+ )
11
+ end
12
+ end
13
+
14
+ class Mock
15
+ def list_volume_attachments(server_id)
16
+ Excon::Response.new(
17
+ body: {
18
+ volumeAttachments: [{
19
+ device: '/dev/vdd',
20
+ serverId: server_id,
21
+ id: '24011ca7-9937-41e4-b19b-141307d1b656',
22
+ volumeId: '24011ca7-9937-41e4-b19b-141307d1b656'
23
+ }]
24
+ },
25
+ status: 200
26
+ )
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,33 @@
1
+ module Fog
2
+ module Compute
3
+ class OpenStack
4
+ class Real
5
+ def update_flavor_metadata(flavor_ref, key, value)
6
+ data = {key => value}
7
+
8
+ request(
9
+ :body => Fog::JSON.encode(data),
10
+ :expects => 200,
11
+ :method => 'PUT',
12
+ :path => "flavors/#{flavor_ref}/os-extra_specs/#{key}"
13
+ )
14
+ end
15
+ end
16
+
17
+ class Mock
18
+ def update_flavor_metadata(_flavor_ref, key, value)
19
+ response = Excon::Response.new
20
+ response.status = 200
21
+ response.headers = {
22
+ "X-Compute-Request-Id" => "req-fdc6f99e-55a2-4ab1-8904-0892753828cf",
23
+ "Content-Type" => "application/json",
24
+ "Content-Length" => "356",
25
+ "Date" => Date.new
26
+ }
27
+ response.body = {key => value}
28
+ response
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end