knife-opc 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -1
- data/lib/chef/knife/opc_org_associate.rb +50 -0
- data/lib/chef/knife/opc_org_dissociate.rb +43 -0
- data/lib/chef/knife/opc_user_create.rb +11 -0
- data/lib/knife-opc/version.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f81638cb44c3efb4b8b2a2c1e98ca1a48295a8e9
|
4
|
+
data.tar.gz: 8166172b30bc738ac5ffb40ec8f492fb34fac43a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 08ea03824872034a74c154a96f848614cc23c2cc870e20e546b2923de810f6257652ed0a6a48015ea3cac59f29a4aa5385e6c8a120b78e81a5030bff95a6cd1e
|
7
|
+
data.tar.gz: 3f8ee073eb6e57d8f80b19e85e3a8288a2a69e6cf07f17451f3b6f9a10ed9f335f9d70d47241a88a22c939668aa5e8f4d792289065cb3ef1530b243a9a82e976
|
data/README.md
CHANGED
@@ -16,7 +16,7 @@ This knife plugin is packaged as a gem. To install it, clone the
|
|
16
16
|
git repository and run the following:
|
17
17
|
|
18
18
|
gem build knife-opc.gemspec
|
19
|
-
gem install knife-opc-0.
|
19
|
+
gem install knife-opc-0.1.1.gem
|
20
20
|
|
21
21
|
# Configuration
|
22
22
|
|
@@ -112,6 +112,17 @@ validator client is returned.
|
|
112
112
|
|
113
113
|
Deletes the given OPC user.
|
114
114
|
|
115
|
+
## knife opc associate ORGNAME USERNAME
|
116
|
+
|
117
|
+
Associates a user with an organization. Requires that the named
|
118
|
+
organization and user both exist.
|
119
|
+
|
120
|
+
## knife opc disassociate ORGNAME USERNAME
|
121
|
+
|
122
|
+
Dissociates a user with an organization. Requires that the named
|
123
|
+
organization and user both exist, and that the user is currently
|
124
|
+
associated with the organization.
|
125
|
+
|
115
126
|
# KNOWN ISSUES
|
116
127
|
|
117
128
|
* Attempting to delete and immediately recreate an organization will
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Marc Paradise (<marc@getchef.com>)
|
3
|
+
# Copyright:: Copyright 2014 Chef Software, Inc
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
module Opc
|
20
|
+
class OpcOrgAssociate < Chef::Knife
|
21
|
+
category "OPSCODE PRIVATE CHEF ORGANIZATION MANAGEMENT"
|
22
|
+
banner "knife opc org associate ORG_NAME USER_NAME"
|
23
|
+
attr_accessor :org_name, :username
|
24
|
+
|
25
|
+
def run
|
26
|
+
@org_name, @username = @name_args
|
27
|
+
|
28
|
+
if !org_name || !username
|
29
|
+
ui.fatal "You must specify an ORG_NAME and USER_NAME"
|
30
|
+
show_usage
|
31
|
+
exit 1
|
32
|
+
end
|
33
|
+
|
34
|
+
@chef_rest = Chef::REST.new(Chef::Config[:chef_server_root])
|
35
|
+
request_body = {:user => username}
|
36
|
+
response = @chef_rest.post_rest "organizations/#{org_name}/association_requests", request_body
|
37
|
+
if response["error"]
|
38
|
+
ui.msg response["error"]
|
39
|
+
else
|
40
|
+
association_id = response["uri"].split("/").last
|
41
|
+
response = @chef_rest.put_rest "users/#{username}/association_requests/#{association_id}", { :response => 'accept' }
|
42
|
+
if response["error"]
|
43
|
+
ui.msg response["error"]
|
44
|
+
else
|
45
|
+
ui.msg "User #{username} is now associated with organization #{org_name}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Marc Paradise (<marc@getchef.com>)
|
3
|
+
# Copyright:: Copyright 2014 Chef Software, Inc
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
module Opc
|
20
|
+
class OpcOrgDissociate < Chef::Knife
|
21
|
+
category "OPSCODE PRIVATE CHEF ORGANIZATION MANAGEMENT"
|
22
|
+
banner "knife opc org dissociate ORG_NAME USER_NAME"
|
23
|
+
attr_accessor :org_name, :username
|
24
|
+
|
25
|
+
def run
|
26
|
+
@org_name, @username = @name_args
|
27
|
+
|
28
|
+
if !org_name || !username
|
29
|
+
ui.fatal "You must specify an ORG_NAME and USER_NAME"
|
30
|
+
show_usage
|
31
|
+
exit 1
|
32
|
+
end
|
33
|
+
|
34
|
+
@chef_rest = Chef::REST.new(Chef::Config[:chef_server_root])
|
35
|
+
response = @chef_rest.delete_rest "organizations/#{org_name}/users/#{username}"
|
36
|
+
if response["error"]
|
37
|
+
ui.msg response["error"]
|
38
|
+
else
|
39
|
+
ui.msg "User #{username} has been dissociated from organization #{org_name}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -26,6 +26,11 @@ module Opc
|
|
26
26
|
:short => '-f FILENAME',
|
27
27
|
:description => 'Write private key to FILENAME rather than STDOUT'
|
28
28
|
|
29
|
+
option :orgname,
|
30
|
+
:long => '--orgname ORGNAME',
|
31
|
+
:short => '-o ORGNAME',
|
32
|
+
:description => 'Associate new user to an organization matching ORGNAME'
|
33
|
+
|
29
34
|
def run
|
30
35
|
case @name_args.count
|
31
36
|
when 6
|
@@ -58,6 +63,12 @@ module Opc
|
|
58
63
|
else
|
59
64
|
ui.msg result['private_key']
|
60
65
|
end
|
66
|
+
if config[:orgname]
|
67
|
+
request_body = {:user => username}
|
68
|
+
response = @chef_rest.post_rest "organizations/#{config[:orgname]}/association_requests", request_body
|
69
|
+
association_id = response["uri"].split("/").last
|
70
|
+
@chef_rest.put_rest "users/#{username}/association_requests/#{association_id}", { :response => 'accept' }
|
71
|
+
end
|
61
72
|
end
|
62
73
|
end
|
63
74
|
end
|
data/lib/knife-opc/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-opc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Danna
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
description: Knife Tools for Opscode
|
69
|
+
description: Knife Tools for Opscode Chef Server
|
70
70
|
email: steve@opscode.com
|
71
71
|
executables: []
|
72
72
|
extensions: []
|
@@ -76,8 +76,10 @@ extra_rdoc_files:
|
|
76
76
|
files:
|
77
77
|
- LICENSE
|
78
78
|
- README.md
|
79
|
+
- lib/chef/knife/opc_org_associate.rb
|
79
80
|
- lib/chef/knife/opc_org_create.rb
|
80
81
|
- lib/chef/knife/opc_org_delete.rb
|
82
|
+
- lib/chef/knife/opc_org_dissociate.rb
|
81
83
|
- lib/chef/knife/opc_org_list.rb
|
82
84
|
- lib/chef/knife/opc_org_show.rb
|
83
85
|
- lib/chef/knife/opc_user_create.rb
|
@@ -108,6 +110,6 @@ rubyforge_project:
|
|
108
110
|
rubygems_version: 2.2.1
|
109
111
|
signing_key:
|
110
112
|
specification_version: 4
|
111
|
-
summary: Knife Tools for Opscode
|
113
|
+
summary: Knife Tools for Opscode Chef Server
|
112
114
|
test_files: []
|
113
115
|
has_rdoc:
|