kaname 0.2.0 → 0.3.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
  SHA1:
3
- metadata.gz: 1b179a8780862a317865a41c2f465fdc1b6fd4cc
4
- data.tar.gz: 087355e6ceafdae9aa47b3e771115dee9e8d09f9
3
+ metadata.gz: 7f2e7d466e2a52ae7929cda90f03ba22dc991308
4
+ data.tar.gz: a7fe1625673a2f04308d924d379f0ac8d338bac6
5
5
  SHA512:
6
- metadata.gz: bf9c89598d82da75808708a5ae04ee82ed4d5a39af5652bb27d2b31f701ea02c9b0ac5c0be22acc41720d56e5663781160206fa765bb9d74a8ed178bfd099a3c
7
- data.tar.gz: 37a77446da38a9e8ee752f5d80bfaa745b0ae22189e51d718ca7249c5cc06311f6aa78ce3b17d1cbc2fa93142f6386bf58d6116b125e426529f485061597d3d0
6
+ metadata.gz: 2c8e5443af92addd2ce06383db1eea2a71766cf974b574945cab021f4fdcf1d28dab7bf9bc1296b0291568614e2370265f2b5be7d3046c78dedbadef8de06702
7
+ data.tar.gz: 2e58e65fe38ffbb30d1e8ae47ec0be53dc9d18592491108a3f081bf6c8b3611effbb5875b1dff8a436df196eb3a548de4e45bee25ae748b4606a2815c4c8d65a
data/.travis.yml CHANGED
@@ -1,3 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.5
3
+ - 2.0.0
4
+ - 2.1.6
5
+ - 2.2.2
data/README.md CHANGED
@@ -41,8 +41,8 @@ run following command.
41
41
 
42
42
  ```sh
43
43
  $ kaname diff # You can see difference of definition
44
- $ kaname apply # You can see all of invoke commands(dryrun)
45
- $ kaname apply --dryrun false # apply configuration into OpenStack
44
+ $ kaname apply # apply configuration into OpenStack
45
+ $ kaname apply --dryrun # You can see all of invoke commands(dryrun)
46
46
  ```
47
47
 
48
48
  You can create user and user's role with tenant.
data/kaname.gemspec CHANGED
@@ -28,4 +28,5 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency "rake"
29
29
  spec.add_development_dependency "minitest"
30
30
  spec.add_development_dependency "mocha"
31
+ spec.add_development_dependency "webmock"
31
32
  end
@@ -1,3 +1,5 @@
1
+ require 'net/http'
2
+
1
3
  module Kaname
2
4
  module Adapter
3
5
  class Real
@@ -19,6 +21,26 @@ module Kaname
19
21
  Fog::Identity[:openstack].create_user_role(tenant.id, user_hash["id"], role.id)
20
22
  end
21
23
 
24
+ def update_user_password(credentials, old_password, new_password)
25
+ if old_password && new_password
26
+ # TODO: need to confirm port number of endpoint
27
+ endpoint = "http://#{URI(credentials[:openstack_management_url]).hostname}:5000/v2.0"
28
+ url = URI.parse("#{endpoint}/OS-KSCRUD/users/#{credentials[:openstack_current_user_id]}")
29
+ req = Net::HTTP::Patch.new(url.path)
30
+ req["Content-type"] = "application/json"
31
+ req["X-Auth-Token"] = credentials[:openstack_auth_token]
32
+ req.body = JSON.generate({'user' => {'password' => new_password, 'original_password' => old_password}})
33
+ res = Net::HTTP.start(url.host, url.port) {|http|
34
+ http.request(req)
35
+ }
36
+ if res.code == "200"
37
+ puts "Your password is updated. Please update your ~/.fog configuration too."
38
+ else
39
+ raise "password updating is failed"
40
+ end
41
+ end
42
+ end
43
+
22
44
  def delete_user(name)
23
45
  user = find_user(name)
24
46
  Fog::Identity[:openstack].delete_user(user["id"])
data/lib/kaname/cli.rb CHANGED
@@ -6,6 +6,21 @@ require 'diffy'
6
6
 
7
7
  module Kaname
8
8
  class CLI < Thor
9
+ desc 'password', 'Commands about updating user password'
10
+ def password
11
+ credentials = Fog::Identity[:openstack].credentials
12
+ puts "current_user: #{credentials[:current_user]["username"]}"
13
+
14
+ print "type your current password: "
15
+ old_password = STDIN.noecho(&:gets).strip
16
+ puts
17
+ print "type your new password: "
18
+ new_password = STDIN.noecho(&:gets).strip
19
+ puts
20
+
21
+ Kaname::Adapter::Real.new.update_user_password(credentials, old_password, new_password)
22
+ end
23
+
9
24
  option :dryrun, type: :boolean
10
25
  desc 'apply', 'Commands about configuration apply'
11
26
  def apply
@@ -1,3 +1,3 @@
1
1
  module Kaname
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
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.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SHIBATA Hiroshi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-04-16 00:00:00.000000000 Z
11
+ date: 2015-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: webmock
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  description: Identity configuration tool for OpenStack. You can apply simple YAML
126
140
  definition into Keystone.
127
141
  email: