Class: KnifeNodeAttribute::NodeAttributeShow
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- KnifeNodeAttribute::NodeAttributeShow
show all
- Includes:
- Helpers
- Defined in:
- lib/chef/knife/knife-node-attribute.rb
Instance Method Summary
collapse
Methods included from Helpers
#get_all_attributes, #get_default_attributes, #get_node, #get_normal_attributes, #get_override_attributes
Instance Method Details
#parse_args ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/chef/knife/knife-node-attribute.rb', line 52
def parse_args
unless node_name = name_args[0]
show_usage
ui.error "You need to specify a node"
exit 1
end
if name_args[1].nil?
attribute_class = :all
else
attribute_class = name_args[1].downcase.to_sym
if ATTRIBUTE_CLASSES.include? attribute_class
attribute_name = name_args[2] || ""
else
attribute_name = attribute_class
attribute_class = :all
end
end
{:nodename => node_name,
:class => attribute_class,
:name => attribute_name.split(":")}
end
|
#run ⇒ Object
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/chef/knife/knife-node-attribute.rb', line 78
def run
args = parse_args
method = "get_#{args[:class]}_attributes".to_sym
node = get_node(args[:nodename])
attribute_hash = self.send(method, node)
getter = args[:name].empty? ? "" : "['#{args[:name].join("']['")}']"
if args[:name].nil?
pp attribute_hash
else
begin
pp eval "attribute_hash#{getter}"
rescue NoMethodError
ui.error "Key not found"
end
end
end
|