class Chef::Knife::NodePolicySet
Public Instance Methods
run()
click to toggle source
# File lib/chef/knife/node_policy_set.rb, line 32 def run validate_node! validate_options! node = Chef::Node.load(@name_args[0]) set_policy(node) if node.save ui.info "Successfully set the policy on node #{node.name}" else ui.info "Error in updating node #{node.name}" end end
Private Instance Methods
incomplete_policyfile_options?()
click to toggle source
True if one of policy_name or policy_group was given, but not both
# File lib/chef/knife/node_policy_set.rb, line 72 def incomplete_policyfile_options? policy_group, policy_name = @name_args[1..] (policy_group.nil? || policy_name.nil? || @name_args[1..-1].size > 2) end
set_policy(node)
click to toggle source
Set policy name and group to node
# File lib/chef/knife/node_policy_set.rb, line 47 def set_policy(node) policy_group, policy_name = @name_args[1..] node.policy_name = policy_name node.policy_group = policy_group end
validate_node!()
click to toggle source
Validate node pass in CLI
# File lib/chef/knife/node_policy_set.rb, line 63 def validate_node! if @name_args[0].nil? ui.error("You must specify a node name") show_usage exit 1 end end
validate_options!()
click to toggle source
Validate policy name and policy group
# File lib/chef/knife/node_policy_set.rb, line 54 def validate_options! if incomplete_policyfile_options? ui.error("Policy group and name must be specified together") exit 1 end true end