fog-openstack 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fog/openstack/compute.rb +9 -0
- data/lib/fog/openstack/models/compute/server_group.rb +22 -0
- data/lib/fog/openstack/models/compute/server_groups.rb +28 -0
- data/lib/fog/openstack/requests/compute/create_server.rb +6 -0
- data/lib/fog/openstack/requests/compute/create_server_group.rb +31 -0
- data/lib/fog/openstack/requests/compute/delete_server.rb +2 -0
- data/lib/fog/openstack/requests/compute/delete_server_group.rb +28 -0
- data/lib/fog/openstack/requests/compute/get_server_group.rb +38 -0
- data/lib/fog/openstack/requests/compute/list_server_groups.rb +28 -0
- data/lib/fog/openstack/version.rb +1 -1
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9eaa14481a05674d47cb4442aa19d6339427ed1
|
4
|
+
data.tar.gz: b895660e192fd3313cc67b6c7696b25ef3c1caef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e20858aaa8a42796e3432f1724d8b49868f492c145657a780ee96782157dafe390a87e3457cf3e8569abe6fd0202c46d786399d11216bc8bd1f1e2ac5bc5e08
|
7
|
+
data.tar.gz: 9db350b24e7d90f38a2f973d4c554c6cba462f8a2b3adcb6e0a4bb81aa9ef3940ec1617481263cf2a51af5bad1746bf3054e2b3d36b0fe6739ffdd8e684a88a4
|
@@ -52,6 +52,8 @@ module Fog
|
|
52
52
|
collection :snapshots
|
53
53
|
model :host
|
54
54
|
collection :hosts
|
55
|
+
model :server_group
|
56
|
+
collection :server_groups
|
55
57
|
|
56
58
|
## REQUESTS
|
57
59
|
#
|
@@ -225,6 +227,12 @@ module Fog
|
|
225
227
|
request :list_zones_detailed
|
226
228
|
request :list_availability_zones
|
227
229
|
|
230
|
+
# Server Group
|
231
|
+
request :list_server_groups
|
232
|
+
request :get_server_group
|
233
|
+
request :create_server_group
|
234
|
+
request :delete_server_group
|
235
|
+
|
228
236
|
class Mock
|
229
237
|
attr_reader :auth_token
|
230
238
|
attr_reader :auth_token_expiration
|
@@ -284,6 +292,7 @@ module Fog
|
|
284
292
|
],
|
285
293
|
},
|
286
294
|
},
|
295
|
+
:server_groups => {},
|
287
296
|
:server_security_group_map => {},
|
288
297
|
:addresses => {},
|
289
298
|
:quota => {
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'fog/openstack/models/model'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Compute
|
5
|
+
class OpenStack
|
6
|
+
class ServerGroup < Fog::OpenStack::Model
|
7
|
+
identity :id
|
8
|
+
attribute :name
|
9
|
+
attribute :policies, :type => :array
|
10
|
+
attribute :members
|
11
|
+
|
12
|
+
VALID_SERVER_GROUP_POLICIES = ['affinity', 'anti-affinity'].freeze
|
13
|
+
|
14
|
+
def self.validate_server_group_policy(policy)
|
15
|
+
fail ArgumentError, "#{policy} is an invalid policy... must use one of #{VALID_SERVER_GROUP_POLICIES.join(', ')}" \
|
16
|
+
unless VALID_SERVER_GROUP_POLICIES.include? policy
|
17
|
+
true
|
18
|
+
end
|
19
|
+
end # class ServerGroup
|
20
|
+
end # class OpenStack
|
21
|
+
end # module Compute
|
22
|
+
end # module Fog
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'fog/openstack/models/collection'
|
2
|
+
require 'fog/openstack/models/compute/server_group'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
class OpenStack
|
7
|
+
class ServerGroups < Fog::OpenStack::Collection
|
8
|
+
model Fog::Compute::OpenStack::ServerGroup
|
9
|
+
|
10
|
+
def all(options = {})
|
11
|
+
load_response(service.list_server_groups(options), 'server_groups')
|
12
|
+
end
|
13
|
+
|
14
|
+
def get(server_group_id)
|
15
|
+
if server_group_id
|
16
|
+
new(service.get_server_group(server_group_id).body['server_group'])
|
17
|
+
end
|
18
|
+
rescue Fog::Compute::OpenStack::NotFound
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
|
22
|
+
def create(*args)
|
23
|
+
new(service.create_server_group(*args).body['server_group'])
|
24
|
+
end
|
25
|
+
end # class ServerGroups
|
26
|
+
end # class OpenStack
|
27
|
+
end # module Compute
|
28
|
+
end # module Fog
|
@@ -169,6 +169,12 @@ module Fog
|
|
169
169
|
|
170
170
|
self.data[:last_modified][:servers][server_id] = Time.now
|
171
171
|
self.data[:servers][server_id] = mock_data
|
172
|
+
|
173
|
+
if options['os:scheduler_hints'] && options['os:scheduler_hints']['group']
|
174
|
+
group = self.data[:server_groups][options['os:scheduler_hints']['group']]
|
175
|
+
group[:members] << server_id if group
|
176
|
+
end
|
177
|
+
|
172
178
|
if options['return_reservation_id'] == 'True' then
|
173
179
|
response.body = response_data
|
174
180
|
else
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OpenStack
|
4
|
+
class Real
|
5
|
+
def create_server_group(name, policy)
|
6
|
+
Fog::Compute::OpenStack::ServerGroup.validate_server_group_policy policy
|
7
|
+
|
8
|
+
body = { 'server_group' => {
|
9
|
+
'name' => name,
|
10
|
+
'policies' => [policy]
|
11
|
+
}}
|
12
|
+
request(
|
13
|
+
:body => Fog::JSON.encode(body),
|
14
|
+
:expects => 200,
|
15
|
+
:method => 'POST',
|
16
|
+
:path => 'os-server-groups'
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class Mock
|
22
|
+
def create_server_group(name, policy)
|
23
|
+
Fog::Compute::OpenStack::ServerGroup.validate_server_group_policy policy
|
24
|
+
id = SecureRandom.uuid
|
25
|
+
data[:server_groups][id] = { name: name, policies: [policy], members: []}
|
26
|
+
get_server_group id
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -22,6 +22,8 @@ module Fog
|
|
22
22
|
self.data[:last_modified][:servers].delete(server_id)
|
23
23
|
self.data[:servers].delete(server_id)
|
24
24
|
response.status = 204
|
25
|
+
group_id, = data[:server_groups].find { |_id, grp| grp[:members].include?(server_id) }
|
26
|
+
data[:server_groups][group_id][:members] -= [server_id] if group_id
|
25
27
|
end
|
26
28
|
response
|
27
29
|
else
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OpenStack
|
4
|
+
class Real
|
5
|
+
def delete_server_group(group_id)
|
6
|
+
request(
|
7
|
+
:expects => 204,
|
8
|
+
:method => 'DELETE',
|
9
|
+
:path => "os-server-groups/#{group_id}"
|
10
|
+
)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Mock
|
15
|
+
def delete_server_group(group_id)
|
16
|
+
response = Excon::Response.new
|
17
|
+
response.status = data[:server_groups].delete(group_id) ? 204 : 404
|
18
|
+
response.headers = {
|
19
|
+
"Content-Type" => "text/html; charset=UTF-8",
|
20
|
+
"Content-Length" => "0",
|
21
|
+
"Date" => Date.new
|
22
|
+
}
|
23
|
+
response
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OpenStack
|
4
|
+
class Real
|
5
|
+
def get_server_group(group_id)
|
6
|
+
request(
|
7
|
+
:expects => 200,
|
8
|
+
:method => 'GET',
|
9
|
+
:path => "/os-server-groups/#{group_id}"
|
10
|
+
)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Mock
|
15
|
+
def get_server_group(group_id)
|
16
|
+
grp = data[:server_groups][group_id]
|
17
|
+
response = Excon::Response.new
|
18
|
+
response.status = 200
|
19
|
+
response.headers = {
|
20
|
+
"Content-Type" => "text/html; charset=UTF-8",
|
21
|
+
"Content-Length" => "0",
|
22
|
+
"Date" => Date.new
|
23
|
+
}
|
24
|
+
response.body = { 'server_group' => {
|
25
|
+
'id' => group_id,
|
26
|
+
'name' => grp[:name],
|
27
|
+
'policies' => grp[:policies],
|
28
|
+
'members' => grp[:members],
|
29
|
+
'metadata' => {},
|
30
|
+
'project_id' => 'test-project',
|
31
|
+
'user_id' => 'test-user'
|
32
|
+
} }
|
33
|
+
response
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OpenStack
|
4
|
+
class Real
|
5
|
+
def list_server_groups(options = {})
|
6
|
+
request(
|
7
|
+
:expects => 200,
|
8
|
+
:method => 'GET',
|
9
|
+
:path => 'os-server-groups',
|
10
|
+
:query => options
|
11
|
+
)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Mock
|
16
|
+
def list_server_groups(_options = {})
|
17
|
+
groups = data[:server_groups].map do |id, group|
|
18
|
+
group.merge('id' => id, 'project_id' => 'test-project', 'user_id' => 'test-user')
|
19
|
+
end
|
20
|
+
Excon::Response.new(
|
21
|
+
:body => { 'server_groups' => groups },
|
22
|
+
:status => 200
|
23
|
+
)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fog-openstack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Darby
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog-core
|
@@ -282,6 +282,8 @@ files:
|
|
282
282
|
- lib/fog/openstack/models/compute/security_group_rules.rb
|
283
283
|
- lib/fog/openstack/models/compute/security_groups.rb
|
284
284
|
- lib/fog/openstack/models/compute/server.rb
|
285
|
+
- lib/fog/openstack/models/compute/server_group.rb
|
286
|
+
- lib/fog/openstack/models/compute/server_groups.rb
|
285
287
|
- lib/fog/openstack/models/compute/servers.rb
|
286
288
|
- lib/fog/openstack/models/compute/service.rb
|
287
289
|
- lib/fog/openstack/models/compute/services.rb
|
@@ -484,6 +486,7 @@ files:
|
|
484
486
|
- lib/fog/openstack/requests/compute/create_security_group.rb
|
485
487
|
- lib/fog/openstack/requests/compute/create_security_group_rule.rb
|
486
488
|
- lib/fog/openstack/requests/compute/create_server.rb
|
489
|
+
- lib/fog/openstack/requests/compute/create_server_group.rb
|
487
490
|
- lib/fog/openstack/requests/compute/create_snapshot.rb
|
488
491
|
- lib/fog/openstack/requests/compute/create_volume.rb
|
489
492
|
- lib/fog/openstack/requests/compute/delete_aggregate.rb
|
@@ -496,6 +499,7 @@ files:
|
|
496
499
|
- lib/fog/openstack/requests/compute/delete_security_group.rb
|
497
500
|
- lib/fog/openstack/requests/compute/delete_security_group_rule.rb
|
498
501
|
- lib/fog/openstack/requests/compute/delete_server.rb
|
502
|
+
- lib/fog/openstack/requests/compute/delete_server_group.rb
|
499
503
|
- lib/fog/openstack/requests/compute/delete_service.rb
|
500
504
|
- lib/fog/openstack/requests/compute/delete_snapshot.rb
|
501
505
|
- lib/fog/openstack/requests/compute/delete_volume.rb
|
@@ -521,6 +525,7 @@ files:
|
|
521
525
|
- lib/fog/openstack/requests/compute/get_security_group.rb
|
522
526
|
- lib/fog/openstack/requests/compute/get_security_group_rule.rb
|
523
527
|
- lib/fog/openstack/requests/compute/get_server_details.rb
|
528
|
+
- lib/fog/openstack/requests/compute/get_server_group.rb
|
524
529
|
- lib/fog/openstack/requests/compute/get_server_password.rb
|
525
530
|
- lib/fog/openstack/requests/compute/get_server_volumes.rb
|
526
531
|
- lib/fog/openstack/requests/compute/get_snapshot_details.rb
|
@@ -542,6 +547,7 @@ files:
|
|
542
547
|
- lib/fog/openstack/requests/compute/list_private_addresses.rb
|
543
548
|
- lib/fog/openstack/requests/compute/list_public_addresses.rb
|
544
549
|
- lib/fog/openstack/requests/compute/list_security_groups.rb
|
550
|
+
- lib/fog/openstack/requests/compute/list_server_groups.rb
|
545
551
|
- lib/fog/openstack/requests/compute/list_servers.rb
|
546
552
|
- lib/fog/openstack/requests/compute/list_servers_detail.rb
|
547
553
|
- lib/fog/openstack/requests/compute/list_services.rb
|
@@ -1109,7 +1115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1109
1115
|
version: '0'
|
1110
1116
|
requirements: []
|
1111
1117
|
rubyforge_project:
|
1112
|
-
rubygems_version: 2.
|
1118
|
+
rubygems_version: 2.2.2
|
1113
1119
|
signing_key:
|
1114
1120
|
specification_version: 4
|
1115
1121
|
summary: OpenStack fog provider gem
|