kaname 0.6.2 → 0.6.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
- SHA1:
3
- metadata.gz: 15b28f025e86bd66760143c6f4746ea38e43be3c
4
- data.tar.gz: bf491e308de8a2b16f34469d7d80dab03289ac80
2
+ SHA256:
3
+ metadata.gz: 670ec8c0c2f974a1d43bab32bf55cabdc0a3ce9160f4e9e4f6161c2e9d52749c
4
+ data.tar.gz: ecec1d85344a9c03b6adaebf55ca18f06a48893e5db688d6376dd22f734129ca
5
5
  SHA512:
6
- metadata.gz: 84717d072d821c76d99f9a3f9f2b3f24256354f643a37feda0228e5d6965dc7e26ce610fa4a1e4b864deb53cb58ede620f8dd26c50a5f7e4fc99b3f9194bffc0
7
- data.tar.gz: 4422dac3de3308fad2ea4747cd1c951ee7db77239406307da565f3bb6a9dd7a88be5a5fa8772cc1239bf5450b358840ad9e048233b9fbdb3b51e6a3c74010e8c
6
+ metadata.gz: e4542d0669ab3ebfb97e65b028f5637ae5299c0db65bdc27ce3be49adc0927172f0a49b0d16c34a52514b2daf5a0c3ca516944100b648f91e36a24b2a66e7e8c
7
+ data.tar.gz: 4ce6e27c259e7ec7afbf9b3ecac776e9986adf2e9468cd2b946f5a509a63650ac2bf59e5e458a75dab944ea11012147b9772655ed29c10f1ad3d903813492bce
data/README.md CHANGED
@@ -43,7 +43,6 @@ auth_url: "http://your-openstack-auth-endpoint/v2.0"
43
43
  username: "admin"
44
44
  tenant: "admin"
45
45
  password: "admin-no-password"
46
- management_url: "http://your-openstack-management-endpoint/v2.0"
47
46
  ```
48
47
 
49
48
  also, you can set some options.
@@ -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
- endpoint = Kaname::Config.management_url
28
-
29
- url = URI.parse("#{endpoint}/OS-KSCRUD/users/#{me.id}")
22
+ client= Yao.default_client.pool['identity']
30
23
 
31
- req = Net::HTTP::Patch.new(url.path)
32
- req["Content-type"] = "application/json"
33
- req["X-Auth-Token"] = token
34
- req.body = JSON.generate({'user' => {'password' => new_password, 'original_password' => old_password}})
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.code == "200"
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"
@@ -3,12 +3,10 @@ require 'yaml'
3
3
 
4
4
  module Kaname
5
5
  class Config
6
- %w[username management_url].each do |m|
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
@@ -4,7 +4,7 @@ module Kaname
4
4
  class Resource
5
5
  class << self
6
6
  def yaml(filename = 'keystone.yml')
7
- if File.exists?(filename)
7
+ if File.exist?(filename)
8
8
  @_yaml ||= expand_all_tenants(YAML.load_file(filename))
9
9
  end
10
10
  end
@@ -1,3 +1,3 @@
1
1
  module Kaname
2
- VERSION = "0.6.2"
2
+ VERSION = "0.6.3"
3
3
  end
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.2
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: 2018-01-10 00:00:00.000000000 Z
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
- rubyforge_project:
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.