kaname 0.6.2 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +0 -1
- data/lib/kaname/adapter/read_and_write.rb +7 -15
- data/lib/kaname/config.rb +13 -16
- data/lib/kaname/resource.rb +1 -1
- data/lib/kaname/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 670ec8c0c2f974a1d43bab32bf55cabdc0a3ce9160f4e9e4f6161c2e9d52749c
|
4
|
+
data.tar.gz: ecec1d85344a9c03b6adaebf55ca18f06a48893e5db688d6376dd22f734129ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4542d0669ab3ebfb97e65b028f5637ae5299c0db65bdc27ce3be49adc0927172f0a49b0d16c34a52514b2daf5a0c3ca516944100b648f91e36a24b2a66e7e8c
|
7
|
+
data.tar.gz: 4ce6e27c259e7ec7afbf9b3ecac776e9986adf2e9468cd2b946f5a509a63650ac2bf59e5e458a75dab944ea11012147b9772655ed29c10f1ad3d903813492bce
|
data/README.md
CHANGED
@@ -17,25 +17,17 @@ module Kaname
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def update_user_password(old_password, new_password)
|
20
|
-
unless Kaname::Config.management_url
|
21
|
-
raise 'management_url is missing. Check the configuration file.'
|
22
|
-
end
|
23
|
-
|
24
20
|
if old_password && new_password
|
25
|
-
token = Yao::Auth.try_new.token
|
26
21
|
me = Yao::User.get_by_name(Kaname::Config.username)
|
27
|
-
|
28
|
-
|
29
|
-
url = URI.parse("#{endpoint}/OS-KSCRUD/users/#{me.id}")
|
22
|
+
client= Yao.default_client.pool['identity']
|
30
23
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
res = Net::HTTP.start(url.host, url.port) {|http| http.request(req) }
|
24
|
+
params = JSON.generate({'user' => {'password' => new_password, 'original_password' => old_password}})
|
25
|
+
res = client.patch("./OS-KSCRUD/users/#{me.id}") do |req|
|
26
|
+
req.body = params
|
27
|
+
req.headers['Content-Type'] = 'application/json'
|
28
|
+
end
|
37
29
|
|
38
|
-
if res.
|
30
|
+
if res.status == 200
|
39
31
|
puts "Your password is updated. Please update your ~/.kaname configuration too."
|
40
32
|
else
|
41
33
|
raise "password updating is failed"
|
data/lib/kaname/config.rb
CHANGED
@@ -3,12 +3,10 @@ require 'yaml'
|
|
3
3
|
|
4
4
|
module Kaname
|
5
5
|
class Config
|
6
|
-
|
7
|
-
self.class_variable_set(:"@@#{m}", String.new)
|
8
|
-
end
|
6
|
+
@@username = String.new
|
9
7
|
|
10
8
|
def self.setup
|
11
|
-
load_config
|
9
|
+
load_config unless envs_exist?
|
12
10
|
setup_yao
|
13
11
|
end
|
14
12
|
|
@@ -16,12 +14,12 @@ module Kaname
|
|
16
14
|
@@username
|
17
15
|
end
|
18
16
|
|
19
|
-
def self.management_url
|
20
|
-
@@management_url
|
21
|
-
end
|
22
|
-
|
23
17
|
private
|
24
18
|
|
19
|
+
def self.envs_exist?
|
20
|
+
%w[OS_AUTH_URL OS_TENANT_NAME OS_USERNAME OS_PASSWORD OS_CERT OS_KEY OS_REGION_NAME].any?{|k|ENV[k]}
|
21
|
+
end
|
22
|
+
|
25
23
|
def self.load_config
|
26
24
|
config_file = File.join(Dir.home, '.kaname')
|
27
25
|
raise '~/.kaname is missing' unless File.exists?(config_file)
|
@@ -36,7 +34,6 @@ module Kaname
|
|
36
34
|
@@tenant = config['tenant']
|
37
35
|
@@username = config['username']
|
38
36
|
@@password = config['password']
|
39
|
-
@@management_url = config['management_url']
|
40
37
|
@@client_cert = config['client_cert']
|
41
38
|
@@client_key = config['client_key']
|
42
39
|
@@region_name = config['region_name']
|
@@ -45,13 +42,13 @@ module Kaname
|
|
45
42
|
|
46
43
|
def self.setup_yao
|
47
44
|
Yao.configure do
|
48
|
-
auth_url @@auth_url
|
49
|
-
tenant_name @@tenant
|
50
|
-
username @@username
|
51
|
-
password @@password
|
52
|
-
client_cert @@client_cert
|
53
|
-
client_key @@client_key
|
54
|
-
region_name @@region_name
|
45
|
+
auth_url (ENV['OS_AUTH_URL'] || @@auth_url)
|
46
|
+
tenant_name (ENV['OS_TENANT_NAME'] || @@tenant)
|
47
|
+
username (ENV['OS_USERNAME'] || @@username)
|
48
|
+
password (ENV['OS_PASSWORD'] || @@password)
|
49
|
+
client_cert (ENV['OS_CERT'] || @@client_cert)
|
50
|
+
client_key (ENV['OS_KEY'] || @@client_key)
|
51
|
+
region_name (ENV['OS_REGION_NAME'] || @@region_name)
|
55
52
|
end
|
56
53
|
end
|
57
54
|
end
|
data/lib/kaname/resource.rb
CHANGED
data/lib/kaname/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kaname
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SHIBATA Hiroshi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yao
|
@@ -197,8 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
197
197
|
- !ruby/object:Gem::Version
|
198
198
|
version: '0'
|
199
199
|
requirements: []
|
200
|
-
|
201
|
-
rubygems_version: 2.5.2
|
200
|
+
rubygems_version: 3.0.1
|
202
201
|
signing_key:
|
203
202
|
specification_version: 4
|
204
203
|
summary: Identity configuration tool for OpenStack.
|