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,28 @@
1
+ require 'fog/openstack/models/collection'
2
+ require 'fog/openstack/models/nfv/vnf'
3
+
4
+ module Fog
5
+ module NFV
6
+ class OpenStack
7
+ class Vnfs < Fog::OpenStack::Collection
8
+ model Fog::NFV::OpenStack::Vnf
9
+
10
+ def all(options = {})
11
+ load_response(service.list_vnfs(options), 'vnfs')
12
+ end
13
+
14
+ def get(uuid)
15
+ data = service.get_vnf(uuid).body['vnf']
16
+ new(data)
17
+ rescue Fog::NFV::OpenStack::NotFound
18
+ nil
19
+ end
20
+
21
+ def destroy(uuid)
22
+ vnf = get(uuid)
23
+ vnf.destroy
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,38 @@
1
+ require 'fog/openstack/models/model'
2
+
3
+ module Fog
4
+ module Volume
5
+ class OpenStack
6
+ class Snapshot < Fog::OpenStack::Model
7
+ def update(data)
8
+ requires :id
9
+
10
+ response = service.update_snapshot(id, data)
11
+ merge_attributes(response.body['snapshot'])
12
+
13
+ self
14
+ end
15
+
16
+ def destroy
17
+ requires :id
18
+ service.delete_snapshot(id)
19
+ true
20
+ end
21
+
22
+ # Existing keys have values updated and new key-value pairs are created, but none are deleted
23
+ def update_metadata(metadata)
24
+ requires :id
25
+ service.update_snapshot_metadata(id, metadata)
26
+ true
27
+ end
28
+
29
+ # Delete one specific key-value pair by specifying the key name
30
+ def delete_metadata(key_name)
31
+ requires :id
32
+ service.delete_snapshot_metadata(id, key_name)
33
+ true
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,26 @@
1
+ require 'fog/openstack/models/collection'
2
+
3
+ module Fog
4
+ module Volume
5
+ class OpenStack
6
+ module Snapshots
7
+ def all(options = {})
8
+ load_response(service.list_snapshots_detailed(options), 'snapshots')
9
+ end
10
+
11
+ def summary(options = {})
12
+ load_response(service.list_snapshots(options), 'snapshots')
13
+ end
14
+
15
+ def get(snapshots_id)
16
+ snapshot = service.get_snapshot_details(snapshots_id).body['snapshot']
17
+ if snapshot
18
+ new(snapshot)
19
+ end
20
+ rescue Fog::Volume::OpenStack::NotFound
21
+ nil
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -7,7 +7,7 @@ module Fog
7
7
  attribute :metadata
8
8
  attribute :status
9
9
  attribute :size
10
- attribute :volume_type, :aliases => ['volumeType', 'type']
10
+ attribute :volume_type, :aliases => %w(volumeType type)
11
11
  attribute :snapshot_id, :aliases => 'snapshotId'
12
12
  attribute :imageRef, :aliases => 'image_id'
13
13
  attribute :availability_zone, :aliases => 'availabilityZone'
@@ -30,7 +30,37 @@ module Fog
30
30
  def ready?
31
31
  status == 'available'
32
32
  end
33
+
34
+ def reset_status(status)
35
+ requires :id
36
+ service.action(id, 'os-reset_status' => {:status => status})
37
+ end
38
+
39
+ def create_metadata(metadata)
40
+ replace_metadata(metadata)
41
+ end
42
+
43
+ # Existing keys have values updated and new key-value pairs are created, but none are deleted
44
+ def update_metadata(metadata)
45
+ requires :id
46
+ service.update_metadata(id, metadata)
47
+ true
48
+ end
49
+
50
+ # All existing key-value pairs are deleted and replaced with the key-value pairs specified here
51
+ def replace_metadata(metadata)
52
+ requires :id
53
+ service.replace_metadata(id, metadata)
54
+ true
55
+ end
56
+
57
+ # Delete one specific key-value pair by specifying the key name
58
+ def delete_metadata(key_name)
59
+ requires :id
60
+ service.delete_metadata(id, key_name)
61
+ true
62
+ end
33
63
  end
34
64
  end
35
65
  end
36
- end
66
+ end
@@ -4,13 +4,12 @@ module Fog
4
4
  module Volume
5
5
  class OpenStack
6
6
  class VolumeType < Fog::OpenStack::Model
7
-
8
7
  attribute :extra_specs
9
8
 
10
9
  def create
11
10
  requires :name
12
11
 
13
- response = service.create_volume_type(self.attributes)
12
+ response = service.create_volume_type(attributes)
14
13
  merge_attributes(response.body['volume_type'])
15
14
 
16
15
  self
@@ -19,7 +18,7 @@ module Fog
19
18
  def update
20
19
  requires :id
21
20
 
22
- response = service.update_volume_type(self.id, self.attributes)
21
+ response = service.update_volume_type(id, attributes)
23
22
  merge_attributes(response.body['volume_type'])
24
23
 
25
24
  self
@@ -27,7 +26,7 @@ module Fog
27
26
 
28
27
  def destroy
29
28
  requires :id
30
- service.delete_volume_type(self.id)
29
+ service.delete_volume_type(id)
31
30
  true
32
31
  end
33
32
  end
@@ -0,0 +1,43 @@
1
+ require 'fog/openstack/models/volume/snapshot'
2
+
3
+ module Fog
4
+ module Volume
5
+ class OpenStack
6
+ class V1
7
+ class Snapshot < Fog::Volume::OpenStack::Snapshot
8
+ identity :id
9
+
10
+ attribute :display_name
11
+ attribute :status
12
+ attribute :display_description
13
+ attribute :metadata
14
+ attribute :force
15
+
16
+ def save
17
+ requires :display_name
18
+ data = if id.nil?
19
+ service.create_snapshot(attributes[:volume_id], display_name, display_description, force)
20
+ else
21
+ service.update_snapshot(id, attributes.reject { |k, _v| k == :id })
22
+ end
23
+ merge_attributes(data.body['snapshot'])
24
+ true
25
+ end
26
+
27
+ def create
28
+ requires :display_name
29
+
30
+ # volume_id, name, description, force=false
31
+ response = service.create_snapshot(attributes[:volume_id],
32
+ attributes[:display_name],
33
+ attributes[:display_description],
34
+ attributes[:force])
35
+ merge_attributes(response.body['snapshot'])
36
+
37
+ self
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,16 @@
1
+ require 'fog/openstack/models/collection'
2
+ require 'fog/openstack/models/volume_v1/snapshot'
3
+ require 'fog/openstack/models/volume/snapshots'
4
+
5
+ module Fog
6
+ module Volume
7
+ class OpenStack
8
+ class V1
9
+ class Snapshots < Fog::OpenStack::Collection
10
+ model Fog::Volume::OpenStack::V1::Snapshot
11
+ include Fog::Volume::OpenStack::Snapshots
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -7,18 +7,28 @@ module Fog
7
7
  class Volume < Fog::Volume::OpenStack::Volume
8
8
  identity :id
9
9
 
10
- superclass.attributes.each{|attrib| attribute attrib}
10
+ superclass.attributes.each { |attrib| attribute attrib }
11
11
  attribute :display_name, :aliases => 'displayName'
12
12
  attribute :display_description, :aliases => 'displayDescription'
13
13
  attribute :tenant_id, :aliases => 'os-vol-tenant-attr:tenant_id'
14
14
 
15
15
  def save
16
16
  requires :display_name, :size
17
- data = service.create_volume(display_name, display_description, size, attributes)
17
+ data = if id.nil?
18
+ service.create_volume(display_name, display_description, size, attributes)
19
+ else
20
+ service.update_volume(id, attributes.reject { |k, _v| k == :id })
21
+ end
18
22
  merge_attributes(data.body['volume'])
19
23
  true
20
24
  end
21
25
 
26
+ def update(attr = nil)
27
+ requires :id
28
+ merge_attributes(
29
+ service.update_volume(id, attr || attributes).body['volume'])
30
+ self
31
+ end
22
32
  end
23
33
  end
24
34
  end
@@ -0,0 +1,43 @@
1
+ require 'fog/openstack/models/volume/snapshot'
2
+
3
+ module Fog
4
+ module Volume
5
+ class OpenStack
6
+ class V2
7
+ class Snapshot < Fog::Volume::OpenStack::Snapshot
8
+ identity :id
9
+
10
+ attribute :name
11
+ attribute :status
12
+ attribute :description
13
+ attribute :metadata
14
+ attribute :force
15
+
16
+ def save
17
+ requires :name
18
+ data = if id.nil?
19
+ service.create_snapshot(attributes[:volume_id], name, description, force)
20
+ else
21
+ service.update_snapshot(id, attributes.reject { |k, _v| k == :id })
22
+ end
23
+ merge_attributes(data.body['snapshot'])
24
+ true
25
+ end
26
+
27
+ def create
28
+ requires :name
29
+
30
+ # volume_id, name, description, force=false
31
+ response = service.create_snapshot(attributes[:volume_id],
32
+ attributes[:name],
33
+ attributes[:description],
34
+ attributes[:force])
35
+ merge_attributes(response.body['snapshot'])
36
+
37
+ self
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,16 @@
1
+ require 'fog/openstack/models/collection'
2
+ require 'fog/openstack/models/volume_v2/snapshot'
3
+ require 'fog/openstack/models/volume/snapshots'
4
+
5
+ module Fog
6
+ module Volume
7
+ class OpenStack
8
+ class V2
9
+ class Snapshots < Fog::OpenStack::Collection
10
+ model Fog::Volume::OpenStack::V2::Snapshot
11
+ include Fog::Volume::OpenStack::Snapshots
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,6 +1,5 @@
1
1
  require 'fog/openstack/models/volume/volume'
2
2
 
3
-
4
3
  module Fog
5
4
  module Volume
6
5
  class OpenStack
@@ -8,18 +7,28 @@ module Fog
8
7
  class Volume < Fog::Volume::OpenStack::Volume
9
8
  identity :id
10
9
 
11
- superclass.attributes.each{|attrib| attribute attrib}
10
+ superclass.attributes.each { |attrib| attribute attrib }
12
11
  attribute :name
13
12
  attribute :description
14
13
  attribute :tenant_id, :aliases => 'os-vol-tenant-attr:tenant_id'
15
14
 
16
15
  def save
17
16
  requires :name, :size
18
- data = service.create_volume(name, description, size, attributes)
17
+ data = if id.nil?
18
+ service.create_volume(name, description, size, attributes)
19
+ else
20
+ service.update_volume(id, attributes.reject { |k, _v| k == :id })
21
+ end
19
22
  merge_attributes(data.body['volume'])
20
23
  true
21
24
  end
22
25
 
26
+ def update(attr = nil)
27
+ requires :id
28
+ merge_attributes(
29
+ service.update_volume(id, attr || attributes).body['volume'])
30
+ self
31
+ end
23
32
  end
24
33
  end
25
34
  end
@@ -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,
@@ -46,6 +46,8 @@ module Fog
46
46
  collection :ipsec_policies
47
47
  model :ipsec_site_connection
48
48
  collection :ipsec_site_connections
49
+ model :rbac_policy
50
+ collection :rbac_policies
49
51
  model :security_group
50
52
  collection :security_groups
51
53
  model :security_group_rule
@@ -152,6 +154,13 @@ module Fog
152
154
  request :get_ipsec_site_connection
153
155
  request :update_ipsec_site_connection
154
156
 
157
+ # RBAC Policy CRUD
158
+ request :list_rbac_policies
159
+ request :create_rbac_policy
160
+ request :delete_rbac_policy
161
+ request :get_rbac_policy
162
+ request :update_rbac_policy
163
+
155
164
  # Security Group
156
165
  request :create_security_group
157
166
  request :delete_security_group
@@ -181,7 +190,7 @@ module Fog
181
190
  tenant_id = Fog::Mock.random_hex(8)
182
191
 
183
192
  hash[key] = {
184
- :networks => {
193
+ :networks => {
185
194
  network_id => {
186
195
  'id' => network_id,
187
196
  'name' => 'Public',
@@ -203,8 +212,8 @@ module Fog
203
212
  'tenant_id' => 'f8b26a6032bc47718a7702233ac708b9',
204
213
  }
205
214
  },
206
- :ports => {},
207
- :subnets => {
215
+ :ports => {},
216
+ :subnets => {
208
217
  subnet_id => {
209
218
  'id' => subnet_id,
210
219
  'name' => "Public",
@@ -219,35 +228,36 @@ module Fog
219
228
  'tenant_id' => tenant_id,
220
229
  }
221
230
  },
222
- :floating_ips => {},
223
- :routers => {},
224
- :lb_pools => {},
225
- :lb_members => {},
226
- :lb_health_monitors => {},
227
- :lb_vips => {},
231
+ :floating_ips => {},
232
+ :routers => {},
233
+ :lb_pools => {},
234
+ :lb_members => {},
235
+ :lb_health_monitors => {},
236
+ :lb_vips => {},
228
237
  :vpn_services => {},
229
238
  :ike_policies => {},
230
239
  :ipsec_policies => {},
231
240
  :ipsec_site_connections => {},
232
- :quota => {
233
- "subnet" => 10,
234
- "router" => 10,
235
- "port" => 50,
236
- "network" => 10,
241
+ :rbac_policies => {},
242
+ :quota => {
243
+ "subnet" => 10,
244
+ "router" => 10,
245
+ "port" => 50,
246
+ "network" => 10,
237
247
  "floatingip" => 50
238
248
  },
239
- :quotas => [
249
+ :quotas => [
240
250
  {
241
- "subnet" => 10,
242
- "network" => 10,
251
+ "subnet" => 10,
252
+ "network" => 10,
243
253
  "floatingip" => 50,
244
- "tenant_id" => tenant_id,
245
- "router" => 10,
246
- "port" => 30
254
+ "tenant_id" => tenant_id,
255
+ "router" => 10,
256
+ "port" => 30
247
257
  }
248
258
  ],
249
- :security_groups => {},
250
- :security_group_rules => {},
259
+ :security_groups => {},
260
+ :security_group_rules => {},
251
261
  }
252
262
  end
253
263
  end
@@ -258,7 +268,7 @@ module Fog
258
268
 
259
269
  include Fog::OpenStack::Core
260
270
 
261
- def initialize(options={})
271
+ def initialize(options = {})
262
272
  @auth_token = Fog::Mock.random_base64(64)
263
273
  @auth_token_expiration = (Time.now.utc + 86400).iso8601
264
274
 
@@ -272,14 +282,12 @@ module Fog
272
282
  def reset_data
273
283
  self.class.data.delete("#{@openstack_username}-#{@openstack_tenant}")
274
284
  end
275
-
276
285
  end
277
286
 
278
287
  class Real
279
-
280
288
  include Fog::OpenStack::Core
281
289
 
282
- def initialize(options={})
290
+ def initialize(options = {})
283
291
  initialize_identity options
284
292
 
285
293
  @openstack_service_type = options[:openstack_service_type] || ['network']
@@ -294,17 +302,16 @@ module Fog
294
302
  @connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
295
303
  end
296
304
 
297
-
298
305
  def request(params)
299
306
  begin
300
- response = @connection.request(params.merge({
301
- :headers => {
302
- 'Content-Type' => 'application/json',
303
- 'Accept' => 'application/json',
304
- 'X-Auth-Token' => @auth_token
305
- }.merge!(params[:headers] || {}),
306
- :path => "#{@path}/#{params[:path]}"#,
307
- }))
307
+ response = @connection.request(params.merge(
308
+ :headers => {
309
+ 'Content-Type' => 'application/json',
310
+ 'Accept' => 'application/json',
311
+ 'X-Auth-Token' => @auth_token
312
+ }.merge!(params[:headers] || {}),
313
+ :path => "#{@path}/#{params[:path]}" # ,
314
+ ))
308
315
  rescue Excon::Errors::Unauthorized => error
309
316
  if error.response.body != 'Bad username or password' # token expiration
310
317
  @openstack_must_reauthenticate = true
@@ -316,11 +323,11 @@ module Fog
316
323
  end
317
324
  rescue Excon::Errors::HTTPStatusError => error
318
325
  raise case error
319
- when Excon::Errors::NotFound
320
- Fog::Network::OpenStack::NotFound.slurp(error)
321
- else
322
- error
323
- end
326
+ when Excon::Errors::NotFound
327
+ Fog::Network::OpenStack::NotFound.slurp(error)
328
+ else
329
+ error
330
+ end
324
331
  end
325
332
  unless response.body.empty?
326
333
  response.body = Fog::JSON.decode(response.body)
@@ -329,12 +336,12 @@ module Fog
329
336
  end
330
337
 
331
338
  def set_api_path
332
- @path.sub!(/\/$/, '')
339
+ @path.sub!(%r{\/$}, '')
333
340
  unless @path.match(SUPPORTED_VERSIONS)
334
- @path = "/" + Fog::OpenStack.get_supported_version(SUPPORTED_VERSIONS,
335
- @openstack_management_uri,
336
- @auth_token,
337
- @connection_options)
341
+ @path = Fog::OpenStack.get_supported_version_path(SUPPORTED_VERSIONS,
342
+ @openstack_management_uri,
343
+ @auth_token,
344
+ @connection_options)
338
345
  end
339
346
  end
340
347
  end