diff --git a/env/bin/appenv b/env/bin/appenv index c6d7d3ede5..b00b04b594 100755 --- a/env/bin/appenv +++ b/env/bin/appenv @@ -45,6 +45,14 @@ NAME={ :description => "Name of the node" } +DESCRIPTION={ + :name => "description", + :short => "-d description", + :large => "--description description", + :format => String, + :description => "description of the node" +} + TEMPLATES={ :name => "templates", :short => "-t t1,t2", @@ -109,13 +117,14 @@ cmd = CommandParser::CmdParser.new(ARGV) do EOT command :create, addnode_desc, [:node_file], - :options => [NAME, TEMPLATES, COOKBOOKS] do + :options => [NAME, TEMPLATES, COOKBOOKS, DESCRIPTION] do node=OpenNebula::ChefConf.new node.node=File.read args.first node.name=options[:name] if options[:name] node.templates=options[:templates] if options[:templates] node.cookbooks=options[:cookbooks] if options[:cookbooks] + node.description=options[:description] if options[:description] client=Client.new res=node.save(client) @@ -162,7 +171,7 @@ cmd = CommandParser::CmdParser.new(ARGV) do EOT command :update, update_desc, [:node], - :options=>[NAME, TEMPLATES, NODE, COOKBOOKS] do + :options=>[DESCRIPTION, TEMPLATES, NODE, COOKBOOKS] do client=OpenNebula::Client.new doc=OpenNebula::ChefDoc.new( OpenNebula::ChefDoc.build_xml(args[0]), @@ -181,6 +190,7 @@ cmd = CommandParser::CmdParser.new(ARGV) do node.templates=options[:templates] if options[:templates] node.cookbooks=options[:cookbooks] if options[:cookbooks] + node.description=options[:description] if options[:description] doc.update(node.to_json) diff --git a/env/cli/appenv_helper.rb b/env/cli/appenv_helper.rb index da3e7059ae..ed3564765a 100644 --- a/env/cli/appenv_helper.rb +++ b/env/cli/appenv_helper.rb @@ -59,6 +59,10 @@ private puts str % ["COOKBOOKS", node.node['cookbooks']] end + if node.node['description'] + puts str % ["DESCRIPTION", node.node['description']] + end + puts CLIHelper.print_header(str_h1 % "PERMISSIONS",false) @@ -103,7 +107,12 @@ private d['NAME'] end - default :ID, :NAME + column :DESCRIPTION, "Description of the node", + :size=>50 do |d| + JSON.parse(d['TEMPLATE']['BODY'])['description'] + end + + default :ID, :NAME, :DESCRIPTION end table diff --git a/env/lib/onechef.rb b/env/lib/onechef.rb index 0f3c1a0a5b..a68f3f03aa 100644 --- a/env/lib/onechef.rb +++ b/env/lib/onechef.rb @@ -70,6 +70,10 @@ module OpenNebula @chef['cookbooks']=cookbooks end + def description=(description) + @chef['description']=description + end + def save(client) doc=ChefDoc.new(ChefDoc.build_xml, client)