yao 0.11.3 → 0.12.0

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
  SHA256:
3
- metadata.gz: c3cbb72cd422a646b28bb0493c19f63ae4f60b3d951a67807d343e67e684baa9
4
- data.tar.gz: '09622cbb3bcd99965722ec00c6bfbf4adae237aeec0932706c08a71fee9587c6'
3
+ metadata.gz: b2ea8c98f6fdefadcfeca2782ed5dde20a91423afc3cc44b925a64fdee3b552a
4
+ data.tar.gz: a0993ca6bd8ddb9a222d632e98c77031682b492756be20c164632410da64bed4
5
5
  SHA512:
6
- metadata.gz: 53d922dd979a4bef85b50bbdc9bb63b2c62119a5e1e8a1edb09259a3776ca9e4c04e2b521a65e3c408e507bdffaf709b20e7854c1f0db32c53cc15c734d21b8f
7
- data.tar.gz: 1fe061f8f816c30c5bada3edbbef1535b1fc992fd932715a698b4752334931eb7685d67e6f3381c4d18879b9e61ce9f81b41244c09e314efc2cd80da8e530b6a
6
+ metadata.gz: aa2d0252174bc0e69a7697d6fb8e90aba053105fa416219bb5c7b0800a861fcffee6d1e48d0fdc3d84a38f20cb4790d8030dbafbae65f1548c221ae79dbd7e52
7
+ data.tar.gz: ccef8bca36eda0c7191017929f466a9b424ca8ac697e2e0f104519394ccdc022bd7159391ad1cfebbf9590635ca4b74c5a5705823b2fc54a27027877e252bcb5
data/Gemfile CHANGED
@@ -6,7 +6,7 @@ gemspec
6
6
  group :development do
7
7
  gem 'rubocop'
8
8
  gem "bundler", ">= 1.10"
9
- gem "rake", "~> 10.0"
9
+ gem "rake", "~> 13.0"
10
10
  gem "test-unit", ">= 3"
11
11
  gem "test-unit-rr"
12
12
  gem "power_assert"
data/Rakefile CHANGED
@@ -9,4 +9,5 @@ Rake::TestTask.new do |t|
9
9
  t.test_files = Dir["test/**/test_*.rb"]
10
10
  t.verbose = true
11
11
  t.ruby_opts = ["-r config"]
12
+ t.warning = false
12
13
  end
data/lib/yao/auth.rb CHANGED
@@ -19,6 +19,7 @@ module Yao
19
19
  end
20
20
 
21
21
  def build_authv3_info(tenant_name, username, password,
22
+ default_domain,
22
23
  user_domain_id, user_domain_name,
23
24
  project_domain_id, project_domain_name)
24
25
  identity = {
@@ -31,6 +32,8 @@ module Yao
31
32
  identity[:password][:user][:domain] = { id: user_domain_id }
32
33
  elsif user_domain_name
33
34
  identity[:password][:user][:domain] = { name: user_domain_name }
35
+ elsif default_domain
36
+ identity[:password][:user][:domain] = { id: default_domain }
34
37
  end
35
38
 
36
39
  scope = {
@@ -40,6 +43,8 @@ module Yao
40
43
  scope[:project][:domain] = { id: project_domain_id }
41
44
  elsif project_domain_name
42
45
  scope[:project][:domain] = { name: project_domain_name }
46
+ elsif default_domain
47
+ scope[:project][:domain] = { id: default_domain }
43
48
  end
44
49
 
45
50
  {
@@ -68,6 +73,7 @@ module Yao
68
73
  username: Yao.config.username,
69
74
  password: Yao.config.password,
70
75
  identity_api_version: Yao.config.identity_api_version,
76
+ default_domain: Yao.config.default_domain,
71
77
  user_domain_id: Yao.config.user_domain_id,
72
78
  user_domain_name: Yao.config.user_domain_name,
73
79
  project_domain_id: Yao.config.project_domain_id,
@@ -75,6 +81,7 @@ module Yao
75
81
  )
76
82
  if identity_api_version.to_i == 3
77
83
  auth_info = build_authv3_info(tenant_name, username, password,
84
+ default_domain,
78
85
  user_domain_id, user_domain_name,
79
86
  project_domain_id, project_domain_name)
80
87
  issue = TokenV3.issue(Yao.default_client.default, auth_info)
data/lib/yao/client.rb CHANGED
@@ -107,7 +107,10 @@ module Yao
107
107
  # @param [String]
108
108
  def reset_client(new_endpoint=nil)
109
109
  set = ClientSet.new
110
- set.register_endpoints("default" => {public_url: new_endpoint || Yao.config.endpoint})
110
+ endpoint = {
111
+ "default" => {public_url: new_endpoint || Yao.config.endpoint}
112
+ }
113
+ set.register_endpoints(endpoint)
111
114
  self.default_client = set
112
115
  end
113
116
 
@@ -145,6 +148,8 @@ module Yao
145
148
  Yao::Client.default_client
146
149
  end
147
150
 
151
+ Yao.config.param :default_domain, 'default'
152
+
148
153
  Yao.config.param :noop_on_write, false
149
154
  Yao.config.param :raise_on_write, false
150
155
 
data/lib/yao/resources.rb CHANGED
@@ -6,6 +6,7 @@ module Yao
6
6
  require "yao/resources/network_associationable"
7
7
 
8
8
  autoload :Server, "yao/resources/server"
9
+ autoload :ServerGroup, "yao/resources/server_group"
9
10
  autoload :Flavor, "yao/resources/flavor"
10
11
  autoload :Image, "yao/resources/image"
11
12
  autoload :SecurityGroup, "yao/resources/security_group"
@@ -0,0 +1,9 @@
1
+ module Yao::Resources
2
+ class ServerGroup < Base
3
+ friendly_attributes :name, :poicies, :members, :metadata, :project_id, :user_id, :policy, :rules
4
+
5
+ self.service = "compute"
6
+ self.resource_name = "server_group"
7
+ self.resources_name = "os-server-groups"
8
+ end
9
+ end
data/lib/yao/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Yao
2
- VERSION = "0.11.3"
2
+ VERSION = "0.12.0"
3
3
  end
@@ -0,0 +1,23 @@
1
+ class TestServerGroup < TestYaoResource
2
+ def test_server_group
3
+ # https://docs.openstack.org/api-ref/compute/?expanded=list-server-groups-detail,show-server-group-details-detail#list-server-groups
4
+ params = {
5
+ "id" => "616fb98f-46ca-475e-917e-2563e5a8cd19",
6
+ "name" => "test",
7
+ "policy" => "anti-affinity",
8
+ "rules" => {"max_server_per_host" => 3},
9
+ "members" => [],
10
+ "project_id" => "6f70656e737461636b20342065766572",
11
+ "user_id" => "fake"
12
+ }
13
+
14
+ sg = Yao::ServerGroup.new(params)
15
+ assert_equal("616fb98f-46ca-475e-917e-2563e5a8cd19", sg.id)
16
+ assert_equal("test", sg.name)
17
+ assert_equal("anti-affinity", sg.policy)
18
+ assert_equal({"max_server_per_host" => 3}, sg.rules)
19
+ assert_equal([], sg.members)
20
+ assert_equal("6f70656e737461636b20342065766572", sg.project_id)
21
+ assert_equal("fake", sg.user_id)
22
+ end
23
+ end
@@ -103,18 +103,22 @@ class TestAuthV3 < Test::Unit::TestCase
103
103
  end
104
104
 
105
105
  def test_build_authv3_info
106
- auth_info = Yao::Auth.build_authv3_info("example", "udzura", "XXXXXXXX", "default", nil, "default", nil)
106
+ auth_info = Yao::Auth.build_authv3_info("example", "udzura", "XXXXXXXX", "test", nil, nil, nil, nil)
107
107
 
108
108
  user = auth_info[:auth][:identity][:password][:user]
109
109
  assert { user[:name] == "udzura" }
110
110
  assert { user[:password] == "XXXXXXXX" }
111
- assert { user[:domain][:id] == "default" }
111
+ assert { user[:domain][:id] == "test" }
112
112
 
113
113
  project = auth_info[:auth][:scope][:project]
114
114
  assert { project[:name] == "example" }
115
- assert { project[:domain][:id] == "default" }
115
+ assert { project[:domain][:id] == "test" }
116
116
 
117
- auth_info = Yao::Auth.build_authv3_info("example", "udzura", "XXXXXXXX", nil, "default", nil, "default")
117
+ auth_info = Yao::Auth.build_authv3_info("example", "udzura", "XXXXXXXX", nil, "default", nil, "default", nil)
118
+ assert { auth_info[:auth][:identity][:password][:user][:domain][:id] == "default" }
119
+ assert { auth_info[:auth][:scope][:project][:domain][:id] == "default" }
120
+
121
+ auth_info = Yao::Auth.build_authv3_info("example", "udzura", "XXXXXXXX", nil, nil, "default", nil, "default")
118
122
  assert { auth_info[:auth][:identity][:password][:user][:domain][:name] == "default" }
119
123
  assert { auth_info[:auth][:scope][:project][:domain][:name] == "default" }
120
124
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yao
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.3
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Uchio, KONDO
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-04 00:00:00.000000000 Z
11
+ date: 2020-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -116,6 +116,7 @@ files:
116
116
  - lib/yao/resources/security_group.rb
117
117
  - lib/yao/resources/security_group_rule.rb
118
118
  - lib/yao/resources/server.rb
119
+ - lib/yao/resources/server_group.rb
119
120
  - lib/yao/resources/subnet.rb
120
121
  - lib/yao/resources/tenant.rb
121
122
  - lib/yao/resources/tenant_associationable.rb
@@ -163,6 +164,7 @@ files:
163
164
  - test/yao/resources/test_security_group.rb
164
165
  - test/yao/resources/test_security_group_rule.rb
165
166
  - test/yao/resources/test_server.rb
167
+ - test/yao/resources/test_server_group.rb
166
168
  - test/yao/resources/test_subnet.rb
167
169
  - test/yao/resources/test_user.rb
168
170
  - test/yao/resources/test_volume.rb
@@ -239,6 +241,7 @@ test_files:
239
241
  - test/yao/resources/test_security_group.rb
240
242
  - test/yao/resources/test_security_group_rule.rb
241
243
  - test/yao/resources/test_server.rb
244
+ - test/yao/resources/test_server_group.rb
242
245
  - test/yao/resources/test_subnet.rb
243
246
  - test/yao/resources/test_user.rb
244
247
  - test/yao/resources/test_volume.rb