1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-11 05:17:41 +03:00

feature #661: Add update template, host and image using an editor

This commit is contained in:
Daniel Molina 2011-06-10 20:08:19 +02:00
parent b4f57b222e
commit a87836a460
4 changed files with 34 additions and 14 deletions

View File

@ -301,4 +301,21 @@ EOT
st = value.to_s + BinarySufix[i]
end
end
def OpenNebulaHelper.update_template(id, resource)
require 'tempfile'
tmp = Tempfile.new(id)
path = tmp.path
tmp << resource.template_str
tmp.flush
# TBD select editor
system("vim #{path}")
tmp.close
str = File.read(path)
str
end
end

View File

@ -77,6 +77,13 @@ cmd=CommandParser::CmdParser.new(ARGV) do
end
end
command :update, 'Modifies a Host attribute', :hostid do
helper.perform_action(args[0],options,"modified") do |host|
str = OpenNebulaHelper.update_template(args[0], host)
host.update(str)
end
end
command :enable, 'Enables Host', [:range,:hostid_list] do
helper.perform_actions(args[0],options,"published") do |host|
host.enable

View File

@ -127,21 +127,10 @@ cmd=CommandParser::CmdParser.new(ARGV) do
end
end
command :update, 'Modifies an Image attribute', :imageid, :text, :text do
command :update, 'Modifies an Image attribute', :imageid do
helper.perform_action(args[0],options,"modified") do |image|
image.update(args[1], args[2])
end
end
command :addattr, 'Add a new Image attribute', :imageid, :text, :text do
helper.perform_action(args[0],options,"att ribute added") do |image|
image.update(args[1], args[2])
end
end
command :rmattr, 'Delete an Image attribute', :imageid, :text do
helper.perform_action(args[0],options,"attribute removed") do |image|
image.remove_attr(args[1])
str = OpenNebulaHelper.update_template(args[0], image)
image.update(str)
end
end

View File

@ -83,6 +83,13 @@ cmd=CommandParser::CmdParser.new(ARGV) do
end
end
command :update, 'Modifies a Template attribute', :templateid do
helper.perform_action(args[0],options,"modified") do |template|
str = OpenNebulaHelper.update_template(args[0], template)
template.update(str)
end
end
command :show, 'Gets info from a Template', :imageid, :options=>OpenNebulaHelper::XML do
helper.show_resource(args[0],options)
end