1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-22 13:33:52 +03:00

Feature #1112: New onedatastore update method

This commit is contained in:
Carlos Martín 2012-03-02 17:25:42 +01:00
parent 6ff6e1f200
commit 759c0a2366
5 changed files with 50 additions and 0 deletions

View File

@ -180,6 +180,14 @@ private:
string error_str;
return insert_replace(db, true, error_str);
}
/**
* Factory method for virtual network templates
*/
Template * get_new_template()
{
return new DatastoreTemplate;
}
};
#endif /*DATASTORE_H_*/

View File

@ -134,6 +134,24 @@ public:
~UserUpdateTemplate(){};
};
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class DatastoreUpdateTemplate : public RequestManagerUpdateTemplate
{
public:
DatastoreUpdateTemplate():
RequestManagerUpdateTemplate("DatastoreUpdateTemplate",
"Updates a datastore template")
{
Nebula& nd = Nebula::instance();
pool = nd.get_dspool();
auth_object = PoolObjectSQL::DATASTORE;
};
~DatastoreUpdateTemplate(){};
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

View File

@ -133,4 +133,15 @@ cmd=CommandParser::CmdParser.new(ARGV) do
command :show, show_desc, :datastoreid, :options=>OpenNebulaHelper::XML do
helper.show_resource(args[0],options)
end
update_desc = <<-EOT.unindent
Launches the system editor to modify and update the template contents
EOT
command :update, update_desc, :datastoreid do
helper.perform_action(args[0],options,"modified") do |obj|
str = OpenNebulaHelper.update_template(args[0], obj)
obj.update(str)
end
end
end

View File

@ -27,6 +27,7 @@ module OpenNebula
:info => "datastore.info",
:allocate => "datastore.allocate",
:delete => "datastore.delete",
:update => "datastore.update",
:chown => "datastore.chown",
:chmod => "datastore.chmod"
}
@ -78,6 +79,16 @@ module OpenNebula
super(DATASTORE_METHODS[:delete])
end
# Replaces the template contents
#
# @param new_template [String] New template contents
#
# @return [nil, OpenNebula::Error] nil in case of success, Error
# otherwise
def update(new_template)
super(DATASTORE_METHODS[:update], new_template)
end
# Changes the owner/group
#
# @param uid [Integer] the new owner id. Set to -1 to leave the current one

View File

@ -255,6 +255,7 @@ void RequestManager::register_xml_methods()
xmlrpc_c::methodPtr host_update(new HostUpdateTemplate());
xmlrpc_c::methodPtr vn_update(new VirtualNetworkUpdateTemplate());
xmlrpc_c::methodPtr user_update(new UserUpdateTemplate());
xmlrpc_c::methodPtr datastore_update(new DatastoreUpdateTemplate());
// Allocate Methods
xmlrpc_c::methodPtr vm_allocate(new VirtualMachineAllocate());
@ -421,6 +422,7 @@ void RequestManager::register_xml_methods()
RequestManagerRegistry.addMethod("one.datastore.allocate",datastore_allocate);
RequestManagerRegistry.addMethod("one.datastore.delete", datastore_delete);
RequestManagerRegistry.addMethod("one.datastore.info", datastore_info);
RequestManagerRegistry.addMethod("one.datastore.update", datastore_update);
RequestManagerRegistry.addMethod("one.datastore.chown", datastore_chown);
RequestManagerRegistry.addMethod("one.datastore.chmod", datastore_chmod);