openstack 3.3.2 → 3.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 17681562cf42cf5718e2a958b88b9506b122b8f1
4
- data.tar.gz: 0cbe0dee7b6bc35079a2d7292a95640f8db18c77
3
+ metadata.gz: d2b9b389dd69f7b30c4c8e6d768efddf46eab2ff
4
+ data.tar.gz: 8a05757ddcf7e92309e683fbfeb4b51d8b78a801
5
5
  SHA512:
6
- metadata.gz: 8d6e9528a0fb31296cf2680d7d5168e0f9c271163b9d448b09ba6504cb60abe910ae007c0ed4bd7b921c72d259eec7ad406bc0eb7127d225a982d259b9973219
7
- data.tar.gz: 3ba91eab865e7e3bbb8cb002b0e7bb02ef57f5170fa03c24bd37964a7598c3e5c8559cef43d627068f9d967b9ff8efd0fc53adf3ed4657d5eaa198b298c3e673
6
+ metadata.gz: b33d3daac576ad9a8ed72b11e4314921333d09d555915109956ace1a19e33b369a577e2502aca7affeca78353cb02ce8f4bacce294f7fc857f4487d95a00da93
7
+ data.tar.gz: fd724c40e74c163f56fdaeb3fcd9816bd07c2d6cf543cd53d636769c532047c83eba5fb2332348016a4709035445dc475c2f5bb2b8e380bbe0e2e0dbb359c1cb
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.3.2
1
+ 3.3.3
@@ -347,6 +347,62 @@ module Compute
347
347
  true
348
348
  end
349
349
 
350
+ # Sends an API request to rescue this server.
351
+ #
352
+ # Returns true if the API call succeeds.
353
+ #
354
+ # >> server.rescue
355
+ # => true
356
+ def rescue(options = nil)
357
+ data = JSON.generate(:rescue => options)
358
+ response = @compute.connection.csreq("POST",@svrmgmthost,"#{@svrmgmtpath}/servers/#{URI.encode(self.id.to_s)}/action",@svrmgmtport,@svrmgmtscheme,{'content-type' => 'application/json'},data)
359
+ OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)
360
+ true
361
+ end
362
+
363
+ # Sends an API request to unrescue this server.
364
+ #
365
+ # Returns true if the API call succeeds.
366
+ #
367
+ # >> server.unrescue
368
+ # => true
369
+ def unrescue
370
+ data = JSON.generate(:unrescue => nil)
371
+ response = @compute.connection.csreq("POST",@svrmgmthost,"#{@svrmgmtpath}/servers/#{URI.encode(self.id.to_s)}/action",@svrmgmtport,@svrmgmtscheme,{'content-type' => 'application/json'},data)
372
+ OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)
373
+ true
374
+ end
375
+
376
+ # Add a fixed ip from a specific network to the instance
377
+ #
378
+ # Returns true if the API call succeeds.
379
+ #
380
+ # >> server.add_fixed_ip
381
+ # => true
382
+ def add_fixed_ip(network_id)
383
+ data = JSON.generate(:addFixedIp => {
384
+ :networkId => network_id
385
+ })
386
+ response = @compute.connection.csreq("POST",@svrmgmthost,"#{@svrmgmtpath}/servers/#{URI.encode(self.id.to_s)}/action",@svrmgmtport,@svrmgmtscheme,{'content-type' => 'application/json'},data)
387
+ OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)
388
+ true
389
+ end
390
+
391
+ # Remove a specific fixed ip from the instance
392
+ #
393
+ # Returns true if the API call succeeds.
394
+ #
395
+ # >> server.remove_fixed_ip
396
+ # => true
397
+ def remove_fixed_ip(ip)
398
+ data = JSON.generate(:removeFixedIp => {
399
+ :address => ip
400
+ })
401
+ response = @compute.connection.csreq("POST",@svrmgmthost,"#{@svrmgmtpath}/servers/#{URI.encode(self.id.to_s)}/action",@svrmgmtport,@svrmgmtscheme,{'content-type' => 'application/json'},data)
402
+ OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)
403
+ true
404
+ end
405
+
350
406
  # Lists all interfaces from this server.
351
407
  #
352
408
  # >> server.interface_list
@@ -1,3 +1,6 @@
1
+ require 'openstack/identity/connection_v2'
2
+ require 'openstack/identity/connection_v3'
3
+
1
4
  module OpenStack
2
5
  module Identity
3
6
  class Connection
@@ -6,31 +9,7 @@ module OpenStack
6
9
  def initialize(connection)
7
10
  @connection = connection
8
11
  OpenStack::Authentication.init(@connection)
9
- end
10
-
11
- def list_tenants
12
- response = @connection.req('GET', '/tenants')
13
- tenants_hash = JSON.parse(response.body)['tenants']
14
- tenants_hash.map { |res| OpenStack::Identity::Tenant.new(res) }
15
- end
16
- alias_method :tenants, :list_tenants
17
-
18
- # create_tenant(name: 'tenant1', description: 'description', enabled: true)
19
- #
20
- def create_tenant(options)
21
- req_body = JSON.generate('tenant' => options)
22
- response = @connection.req('POST', '/tenants', data: req_body)
23
- OpenStack::Identity::Tenant.new(JSON.parse(response.body)['tenant'])
24
- end
25
-
26
- def find_tenant_by_name(name)
27
- response = @connection.req('GET', "/tenants?name=#{name}")
28
- OpenStack::Identity::Tenant.new(JSON.parse(response.body)['tenant'])
29
- end
30
-
31
- def delete_tenant(id)
32
- @connection.req('DELETE', "/tenants/#{id}")
33
- true
12
+ extend @connection.auth_path.match(/v3/) ? OpenStack::Identity::ConnectionV3 : OpenStack::Identity::ConnectionV2
34
13
  end
35
14
 
36
15
  def list_users
@@ -40,30 +19,10 @@ module OpenStack
40
19
  end
41
20
  alias_method :users, :list_users
42
21
 
43
- # create_user(name: 'user1', password: 'password1', email: 'email@mail.ru')
44
- #
45
- def create_user(options)
46
- req_body = JSON.generate('user' => options)
47
- response = @connection.req('POST', '/users', data: req_body)
48
- OpenStack::Identity::User.new(JSON.parse(response.body)['user'])
49
- end
50
-
51
22
  def delete_user(id)
52
23
  @connection.req('DELETE', "/users/#{id}")
53
24
  true
54
25
  end
55
-
56
- def add_user_to_tenant(options)
57
- req_body = JSON.generate('role' => { 'tenantId' => options[:tenant_id], 'roleId' => options[:role_id] })
58
- @connection.req('POST', "/users/#{options[:user_id]}/roleRefs", data: req_body)
59
- true
60
- end
61
-
62
- def list_roles
63
- response = @connection.req('GET', '/OS-KSADM/roles')
64
- OpenStack.symbolize_keys(JSON.parse(response.body)['roles'])
65
- end
66
- alias_method :roles, :list_roles
67
26
  end
68
27
  end
69
28
  end
@@ -0,0 +1,57 @@
1
+ module OpenStack
2
+ module Identity
3
+ module ConnectionV2
4
+ def list_tenants
5
+ response = @connection.req('GET', '/tenants')
6
+ tenants_hash = JSON.parse(response.body)['tenants']
7
+ tenants_hash.map { |res| OpenStack::Identity::Tenant.new(res) }
8
+ end
9
+ alias_method :tenants, :list_tenants
10
+
11
+ # create_tenant(name: 'tenant1', description: 'description', enabled: true)
12
+ #
13
+ def create_tenant(options)
14
+ req_body = JSON.generate('tenant' => options)
15
+ response = @connection.req('POST', '/tenants', data: req_body)
16
+ OpenStack::Identity::Tenant.new(JSON.parse(response.body)['tenant'])
17
+ end
18
+
19
+ def find_tenant_by_name(name)
20
+ response = @connection.req('GET', "/tenants?name=#{name}")
21
+ OpenStack::Identity::Tenant.new(JSON.parse(response.body)['tenant'])
22
+ end
23
+
24
+ def delete_tenant(id)
25
+ @connection.req('DELETE', "/tenants/#{id}")
26
+ true
27
+ end
28
+
29
+ # create_user(name: 'user1', password: 'password1', email: 'email@mail.ru')
30
+ #
31
+ def create_user(options)
32
+ req_body = JSON.generate('user' => options)
33
+ response = @connection.req('POST', '/users', data: req_body)
34
+ OpenStack::Identity::User.new(JSON.parse(response.body)['user'])
35
+ end
36
+
37
+ # update_user(1, {name: 'user1', password: 'password1', email: 'email@mail.ru'})
38
+ def update_user(user_id, options)
39
+ req_body = JSON.generate('user' => options)
40
+ response = @connection.req('PUT', "/users/#{user_id}", data: req_body)
41
+ OpenStack::Identity::User.new(JSON.parse(response.body)['user'])
42
+ end
43
+
44
+ def add_user_to_tenant(options)
45
+ req_body = JSON.generate('role' => { 'tenantId' => options[:tenant_id], 'roleId' => options[:role_id] })
46
+ @connection.req('POST', "/users/#{options[:user_id]}/roleRefs", data: req_body)
47
+ true
48
+ end
49
+
50
+ def list_roles
51
+ response = @connection.req('GET', '/OS-KSADM/roles')
52
+ OpenStack.symbolize_keys(JSON.parse(response.body)['roles'])
53
+ end
54
+ alias_method :roles, :list_roles
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,58 @@
1
+ module OpenStack
2
+ module Identity
3
+ module ConnectionV3
4
+ def list_tenants
5
+ response = @connection.req('GET', '/projects')
6
+ tenants_hash = JSON.parse(response.body)['projects']
7
+ tenants_hash.map { |res| OpenStack::Identity::Tenant.new(res) }
8
+ end
9
+ alias_method :tenants, :list_tenants
10
+
11
+ # create_tenant(name: 'tenant1', description: 'description', enabled: true)
12
+ #
13
+ def create_tenant(options)
14
+ options.merge!(domain_id: @connection.domain_id)
15
+ req_body = JSON.generate('project' => options)
16
+ response = @connection.req('POST', '/projects', data: req_body)
17
+ OpenStack::Identity::Tenant.new(JSON.parse(response.body)['project'])
18
+ end
19
+
20
+ def find_tenant_by_name(name)
21
+ response = @connection.req('GET', "/projects?name=#{name}")
22
+ OpenStack::Identity::Tenant.new(JSON.parse(response.body)['project'])
23
+ end
24
+
25
+ def delete_tenant(id)
26
+ @connection.req('DELETE', "/projects/#{id}")
27
+ true
28
+ end
29
+
30
+ # create_user(name: 'user1', password: 'password1', email: 'email@mail.ru')
31
+ #
32
+ def create_user(options)
33
+ options.merge!(domain_id: @connection.domain_id)
34
+ req_body = JSON.generate('user' => options)
35
+ response = @connection.req('POST', '/users', data: req_body)
36
+ OpenStack::Identity::User.new(JSON.parse(response.body)['user'])
37
+ end
38
+
39
+ # update_user(1, {name: 'user1', password: 'password1', email: 'email@mail.ru'})
40
+ def update_user(user_id, options)
41
+ req_body = JSON.generate('user' => options)
42
+ response = @connection.req('PATCH', "/users/#{user_id}", data: req_body)
43
+ OpenStack::Identity::User.new(JSON.parse(response.body)['user'])
44
+ end
45
+
46
+ def add_user_to_tenant(options)
47
+ @connection.req('PUT', "/projects/#{options[:tenant_id]}/users/#{options[:user_id]}/roles/#{options[:role_id]}")
48
+ true
49
+ end
50
+
51
+ def list_roles
52
+ response = @connection.req('GET', '/roles')
53
+ OpenStack.symbolize_keys(JSON.parse(response.body)['roles'])
54
+ end
55
+ alias_method :roles, :list_roles
56
+ end
57
+ end
58
+ end
@@ -169,7 +169,7 @@ module Swift
169
169
  end
170
170
 
171
171
  #for ruby 2.x
172
- def read(length, buffer=nil)
172
+ def read(length=nil, buffer=nil)
173
173
  if buffer.nil?
174
174
  chunk = @file.read(length)
175
175
  else
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstack
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.2
4
+ version: 3.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Prince
@@ -98,6 +98,8 @@ files:
98
98
  - lib/openstack/connection.rb
99
99
  - lib/openstack/core_ext/to_query.rb
100
100
  - lib/openstack/identity/connection.rb
101
+ - lib/openstack/identity/connection_v2.rb
102
+ - lib/openstack/identity/connection_v3.rb
101
103
  - lib/openstack/identity/tenant.rb
102
104
  - lib/openstack/identity/user.rb
103
105
  - lib/openstack/image/connection.rb
@@ -136,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
138
  version: '0'
137
139
  requirements: []
138
140
  rubyforge_project:
139
- rubygems_version: 2.4.8
141
+ rubygems_version: 2.4.5.1
140
142
  signing_key:
141
143
  specification_version: 4
142
144
  summary: OpenStack Ruby API