-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrated knife-opc into Chef #10187
Integrated knife-opc into Chef #10187
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for getting this started!
lib/chef/knife/opc_org_create.rb
Outdated
module Opc | ||
class OpcOrgCreate < Chef::Knife | ||
category "CHEF ORGANIZATION MANAGEMENT" | ||
banner "knife opc org create ORG_SHORT_NAME ORG_FULL_NAME (options)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should consider removing the opc
prefix from all of these commands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed
lib/chef/knife/opc_org_list.rb
Outdated
def run | ||
results = root_rest.get("organizations") | ||
unless config[:all_orgs] | ||
results = results.select { |k, v| !(k.length == 20 && k =~ /^[a-z]+$/) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this filter is from when we used to pre-generate organizations because organization took a long time. I believe this is no longer the default so perhaps it would be best to turn this filtering off by default and it can end up filtering out legit organizations.
lib/chef/org/group_operations.rb
Outdated
|
||
class Chef | ||
class Org | ||
module GroupOperations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we really need a separate module for this. It was structured this way in the plugin because we lived outside the Chef codebase, but we could probably add these features directly to the Chef::Org class or create a new Chef::Group class that would abstract away some of these features.
lib/chef/knife/opc_user_create.rb
Outdated
module Opc | ||
class OpcUserCreate < Chef::Knife | ||
category "CHEF ORGANIZATION MANAGEMENT" | ||
banner "knife opc user create USERNAME FIRST_NAME [MIDDLE_NAME] LAST_NAME EMAIL PASSWORD" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have a set of knife user
commands that I think should cover most of the user-related commands in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see one or the other, but not both user commands. Since every chef server is a server with an org at this point we should just make any missing functionality part of the existing knife user
operations.
lib/chef/mixin/root_rest.rb
Outdated
# Rather than upgrade all of this code to move to v1, the goal is to remove the | ||
# need for this plugin. See | ||
# https://github.com/chef/chef/issues/3517 | ||
@root_rest ||= Chef::ServerAPI.new(Chef::Config[:chef_server_root], { api_version: "0" }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that the existing user plugins were converted to v1 and that none of the other APIs here really care about the API version so we can probably don't need to specify the api_version if we end up removing the user-related commands from this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this should go away and we should not be using v0 here.
NOTE: This test is failing due to changes in gem chef/.bundle/ruby/2.7.0/gems/tty-prompt-0.21.0/lib/tty/prompt/question.rb |
I am working on all review comments also I found that both |
d8deb15
to
76ffdf5
Compare
lib/chef/knife/org_delete.rb
Outdated
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
require_relative "../mixin/root_rest" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this mixin still needs to go away
lib/chef/knife/user_list.rb
Outdated
@@ -1,6 +1,6 @@ | |||
# | |||
# Author:: Steven Danna (<steve@chef.io>) | |||
# Copyright:: Copyright (c) Chef Software Inc. | |||
# Copyright:: Copyright 2011-2016 Chef Software, Inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of these copyrights need to get updated
7956edd
to
6146928
Compare
lib/chef/knife/user_create.rb
Outdated
end | ||
end | ||
end | ||
|
||
def prompt_for_password | ||
ui.ask("Please enter the user's password: ") { |q| q.echo = false } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ui.ask("Please enter the user's password: ") { |q| q.echo = false } | |
ui.ask("Please enter the user's password: ", echo: false) |
6146928
to
30cde90
Compare
@snehaldwivedi if |
c9d41dc
to
3842097
Compare
lib/chef/knife/org_show.rb
Outdated
|
||
def run | ||
org_name = @name_args[0] | ||
ui.output root_rest.get("organizations/#{org_name}") | ||
org = Chef::Org.from_hash({ "name" => org_name }) | ||
ui.output org.chef_rest.get("organizations/#{org_name}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like this should be pushed into the Chef::Org object.
I haven't looked but we should be able to do something to get a Chef::Org object for the org_name directly rather than going in through from_hash
and then the get
call should be hidden from the caller. That could be combined into one static method if necessary like Chef::Org.load(org_name)
(unless that collides with an existing method name but something like that)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay I will look into that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lamont-granquist I would prefer to add root_rest
method to knife.rb
similar to rest
so that it will be available to all subclasses as we have more root level operations into chef core.
def root_rest
@root_rest ||= begin
require_relative "server_api"
Chef::ServerAPI.new(Chef::Config[:chef_server_root])
end
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the point here though is that AFAIK we should not be using protocol v0, and I don't understand why this PR is spreading it everywhere.
The chef/user.rb that defines the chef_rest_v0 object has a large banner at the top of it that Chef::User should be replaced by Chef::UserV1 in Chef 13 (that didn't happen) but AFAIK it should all go away. I have no idea why knife-opc was using v0, that may have been due to some kind of backwards compatibility with now-ancient chef-servers. Without knowing what breaks, my position is that it should be removed and we should be using our normal v2 rest objects consistently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
knife-opc was using v0 simply because we needed it to work ASAP and that was the smallest possible change, so 👍 to doing it right this time around.
option :no_disassociate_user, | ||
long: "--no-disassociate-user", | ||
short: "-d", | ||
description: "Don't disassociate the user first" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
disassociate from what? This description isn't very helpful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will update it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for disassociate user I will update once this is merge chef-boneyard/knife-opc#36 as it has changes related to it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tas50 can you please confirm if chef-boneyard/knife-opc#56 is good to add changes in this PR?
4a154f9
to
e419e96
Compare
e419e96
to
38d874a
Compare
I have removed Please let me know if require any changes |
@tas50 Can you please have a look into the PR for merge or if any more changes required form my side? |
You should be able to eliminate the |
As per my analysis, I cannot use the default If we can change |
Okay the communication failure is now a bit more obvious. You can do that, but you need to remove |
3a7e23b
to
182d836
Compare
lib/chef/knife.rb
Outdated
@@ -640,7 +640,7 @@ def test_mandatory_field(field, fieldname) | |||
def rest | |||
@rest ||= begin | |||
require_relative "server_api" | |||
Chef::ServerAPI.new(Chef::Config[:chef_server_url]) | |||
Chef::ServerAPI.new(Chef::Config[:chef_server_root]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't this change the rest API for all the rest of the knife commands though?
i was okay with the root_rest object but just didn't want it v1.
Signed-off-by: snehaldwivedi <sdwivedi@msystechnologies.com>
Signed-off-by: snehaldwivedi <sdwivedi@msystechnologies.com>
Signed-off-by: snehaldwivedi <sdwivedi@msystechnologies.com>
Signed-off-by: snehaldwivedi <sdwivedi@msystechnologies.com>
Signed-off-by: snehaldwivedi <sdwivedi@msystechnologies.com>
Signed-off-by: snehaldwivedi <sdwivedi@msystechnologies.com>
Signed-off-by: snehaldwivedi <sdwivedi@msystechnologies.com>
Signed-off-by: snehaldwivedi <sdwivedi@msystechnologies.com>
Signed-off-by: snehaldwivedi <sdwivedi@msystechnologies.com>
Signed-off-by: snehaldwivedi <sdwivedi@msystechnologies.com>
Signed-off-by: snehaldwivedi <sdwivedi@msystechnologies.com>
This reverts commit 182d836.
Signed-off-by: snehaldwivedi <sdwivedi@msystechnologies.com>
182d836
to
0570757
Compare
Signed-off-by: snehaldwivedi sdwivedi@msystechnologies.com
Description
user password
command to core chefRelated Issue
chef-boneyard/knife-opc#48
chef-boneyard/knife-opc#57
#3517
#3514 (covers
knife user create
should check file permissions), #3515, #3516Types of changes
Checklist: