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

feature #661: Add chgrp and chown commands

This commit is contained in:
Daniel Molina 2011-06-10 19:00:37 +02:00
parent da6bd6eeed
commit 2ef5a87788
6 changed files with 75 additions and 17 deletions

View File

@ -65,21 +65,21 @@ cmd=CommandParser::CmdParser.new(ARGV) do
end
end
command :delete, 'Removes a Virtual Network', [:range, :vnetid_list] do
helper.perform_actions(args[0],options,"deleted") do |vn|
vn.delete
command :delete, 'Removes a Virtual Network', [:range, :hostid_list] do
helper.perform_actions(args[0],options,"deleted") do |host|
host.delete
end
end
command :disable, 'Disbales Host', [:range,:vnetid_list] do
helper.perform_actions(args[0],options,"unpublished") do |vn|
vn.disable
command :disable, 'Disbales Host', [:range,:hostid_list] do
helper.perform_actions(args[0],options,"unpublished") do |host|
host.disable
end
end
command :enable, 'Enables Host', [:range,:vnetid_list] do
helper.perform_actions(args[0],options,"published") do |vn|
vn.enable
command :enable, 'Enables Host', [:range,:hostid_list] do
helper.perform_actions(args[0],options,"published") do |host|
host.enable
end
end

View File

@ -63,6 +63,19 @@ cmd=CommandParser::CmdParser.new(ARGV) do
########################################################################
# Commands
########################################################################
command :chgrp, 'Changes the Image group',[:range, :imageid_list], :text do
helper.perform_actions(args[0],options,"User/Group changed") do |image|
image.chown(-1, args[1].to_i)
end
end
command :chown, 'Changes the Image owner and group', [:range, :imageid_list], :text, [:text,nil] do
gid = args[2].nil? ? -1 : args[2].to_id
helper.perform_actions(args[0],options,"Group changed") do |image|
image.chown(args[1].to_i, gid)
end
end
command :create, 'Registers an Image', :file do
helper.create_resource(options) do |image|
template=File.read(args[0])

View File

@ -48,11 +48,11 @@ cmd=CommandParser::CmdParser.new(ARGV) do
########################################################################
# Formatters for arguments
########################################################################
set :format, :imageid, OneTemplateHelper.to_id_desc do |arg|
set :format, :templateid, OneTemplateHelper.to_id_desc do |arg|
helper.to_id(arg)
end
set :format, :imageid_list, OneTemplateHelper.list_to_id_desc do |arg|
set :format, :templateid_list, OneTemplateHelper.list_to_id_desc do |arg|
helper.list_to_id(arg)
end
@ -63,6 +63,19 @@ cmd=CommandParser::CmdParser.new(ARGV) do
########################################################################
# Commands
########################################################################
command :chgrp, 'Changes the Template group',[:range, :templateid_list], :text do
helper.perform_actions(args[0],options,"User/Group changed") do |t|
t.chown(-1, args[1].to_i)
end
end
command :chown, 'Changes the Template owner and group', [:range, :templateid_list], :text, [:text,nil] do
gid = args[2].nil? ? -1 : args[2].to_id
helper.perform_actions(args[0],options,"Group changed") do |t|
t.chown(args[1].to_i, gid)
end
end
command :create, 'Registers a Template', :file do
helper.create_resource(options) do |t|
template=File.read(args[0])
@ -79,20 +92,20 @@ cmd=CommandParser::CmdParser.new(ARGV) do
end
command :publish, 'Publishes a Template', [:range,:imageid_list] do
helper.perform_actions(args[0],options,"published") do |image|
image.publish
helper.perform_actions(args[0],options,"published") do |t|
t.publish
end
end
command :unpublish, 'Unpublishes a Template', [:range,:imageid_list] do
helper.perform_actions(args[0],options,"unpublished") do |image|
image.unpublish
helper.perform_actions(args[0],options,"unpublished") do |t|
t.unpublish
end
end
command :delete, 'Removes a Template', [:range, :imageid_list] do
helper.perform_actions(args[0],options,"deleted") do |image|
image.delete
helper.perform_actions(args[0],options,"deleted") do |t|
t.delete
end
end

View File

@ -83,6 +83,12 @@ cmd=CommandParser::CmdParser.new(ARGV) do
########################################################################
# Commands
########################################################################
command :chgrp, 'Changes the User group',[:range, :userid_list], :text do
helper.perform_actions(args[0],options,"User/Group changed") do |user|
user.chown(-1, args[1].to_i)
end
end
command :create, 'Creates a new User', :text, :password, :options=>create_options do
helper.create_resource(options) do |user|
user.allocate(args[0], args[1])

View File

@ -65,6 +65,19 @@ cmd=CommandParser::CmdParser.new(ARGV) do
end
end
command :chgrp, 'Changes the Virtual Machine group',[:range, :vmid_list], :text do
helper.perform_actions(args[0],options,"User/Group changed") do |vm|
vm.chown(-1, args[1].to_i)
end
end
command :chown, 'Changes the Virtual Machine owner and group', [:range, :vmid_list], :text, [:text,nil] do
gid = args[2].nil? ? -1 : args[2].to_id
helper.perform_actions(args[0],options,"Group changed") do |vm|
vm.chown(args[1].to_i, gid)
end
end
command :create, 'Create a new Virtual Machine', :file do
helper.create_resource(options) do |vm|
template=File.read(args[0])

View File

@ -66,6 +66,19 @@ cmd=CommandParser::CmdParser.new(ARGV) do
end
end
command :chgrp, 'Changes the Virtual Network group',[:range, :vnid_list], :text do
helper.perform_actions(args[0],options,"User/Group changed") do |vn|
vn.chown(-1, args[1].to_i)
end
end
command :chown, 'Changes the Virtual Network owner and group', [:range, :vnid_list], :text, [:text,nil] do
gid = args[2].nil? ? -1 : args[2].to_id
helper.perform_actions(args[0],options,"Group changed") do |vn|
vn.chown(args[1].to_i, gid)
end
end
command :show, 'Gets info from a Virtual Network', :vnetid,
:options=>OpenNebulaHelper::XML do
helper.show_resource(args[0],options)