1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-21 18:03:38 +03:00

Feature #1304: Add new xml-rpc methods one.document.*

This commit is contained in:
Carlos Martín 2012-06-08 16:00:16 +02:00
parent cc132e239a
commit 5d110819d9
20 changed files with 560 additions and 115 deletions

View File

@ -407,6 +407,39 @@ public:
RequestAttributes& att);
};
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class DocumentAllocate : public RequestManagerAllocate
{
public:
DocumentAllocate():
RequestManagerAllocate("DocumentAllocate",
"Allocates a new generic document",
"A:ssi",
true)
{
Nebula& nd = Nebula::instance();
pool = nd.get_docpool();
auth_object = PoolObjectSQL::DOCUMENT;
};
~DocumentAllocate(){};
/* --------------------------------------------------------------------- */
Template * get_object_template()
{
return new Template;
};
int pool_allocate(xmlrpc_c::paramList const& _paramList,
Template * tmpl,
int& id,
string& error_str,
RequestAttributes& att);
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

View File

@ -40,6 +40,12 @@ protected:
virtual void request_execute(xmlrpc_c::paramList const& _paramList,
RequestAttributes& att);
virtual PoolObjectSQL * get_obj(
int oid, xmlrpc_c::paramList const& paramList)
{
return pool->get(oid,true);
};
};
/* ------------------------------------------------------------------------- */
@ -135,6 +141,33 @@ public:
};
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class DocumentChmod : public RequestManagerChmod
{
public:
DocumentChmod():
RequestManagerChmod("DocumentChmod",
"Changes permission bits of a generic document",
"A:siiiiiiiiiii")
{
Nebula& nd = Nebula::instance();
pool = nd.get_docpool();
auth_object = PoolObjectSQL::DOCUMENT;
};
~DocumentChmod(){};
/* -------------------------------------------------------------------- */
PoolObjectSQL * get_obj(int oid, xmlrpc_c::paramList const& paramList)
{
int obj_type = xmlrpc_c::value_int(paramList.getInt(11));
return static_cast<DocumentPool*>(pool)->get(oid, obj_type, true);
};
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

View File

@ -52,6 +52,13 @@ protected:
virtual void request_execute(xmlrpc_c::paramList const& _paramList,
RequestAttributes& att);
virtual PoolObjectSQL * get_obj(
int oid, xmlrpc_c::paramList const& paramList)
{
return pool->get(oid,true);
};
};
/* ------------------------------------------------------------------------- */
@ -172,6 +179,34 @@ public:
};
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class DocumentChown : public RequestManagerChown
{
public:
DocumentChown():
RequestManagerChown("DocumentChown",
"Changes ownership of a generic document",
"A:siiii")
{
Nebula& nd = Nebula::instance();
pool = nd.get_docpool();
auth_object = PoolObjectSQL::DOCUMENT;
};
~DocumentChown(){};
/* -------------------------------------------------------------------- */
PoolObjectSQL * get_obj(int oid, xmlrpc_c::paramList const& paramList)
{
int obj_type = xmlrpc_c::value_int(paramList.getInt(4));
return static_cast<DocumentPool*>(pool)->get(oid, obj_type, true);
};
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

View File

@ -0,0 +1,153 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
#ifndef REQUEST_MANAGER_CLONE_H
#define REQUEST_MANAGER_CLONE_H
#include "Request.h"
#include "Nebula.h"
using namespace std;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class RequestManagerClone: public Request
{
protected:
RequestManagerClone(const string& method_name,
const string& help,
const string& params)
:Request(method_name,params,help)
{};
~RequestManagerClone(){};
/* -------------------------------------------------------------------- */
virtual void request_execute(xmlrpc_c::paramList const& _paramList,
RequestAttributes& att);
virtual PoolObjectSQL * get_obj(
int oid, xmlrpc_c::paramList const& paramList)
{
return pool->get(oid,true);
};
virtual Template * clone_template(PoolObjectSQL* obj) = 0;
virtual int pool_allocate(
xmlrpc_c::paramList const& paramList,
Template * tmpl,
int& id,
string& error_str,
RequestAttributes& att) = 0;
};
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class VMTemplateClone : public RequestManagerClone
{
public:
VMTemplateClone():
RequestManagerClone("VMTemplateClone",
"Clone an existing virtual machine template",
"A:sis")
{
Nebula& nd = Nebula::instance();
pool = nd.get_tpool();
auth_object = PoolObjectSQL::TEMPLATE;
auth_op = AuthRequest::USE;
};
~VMTemplateClone(){};
/* -------------------------------------------------------------------- */
Template * clone_template(PoolObjectSQL* obj)
{
return static_cast<VMTemplate*>(obj)->clone_template();
};
int pool_allocate(
xmlrpc_c::paramList const& paramList,
Template * tmpl,
int& id,
string& error_str,
RequestAttributes& att)
{
VMTemplatePool * tpool = static_cast<VMTemplatePool *>(pool);
VirtualMachineTemplate * ttmpl =
static_cast<VirtualMachineTemplate *>(tmpl);
return tpool->allocate(att.uid, att.gid, att.uname, att.gname, ttmpl,
&id, error_str);
};
};
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class DocumentClone : public RequestManagerClone
{
public:
DocumentClone():
RequestManagerClone("DocumentClone",
"Clone an existing generic document",
"A:sisi")
{
Nebula& nd = Nebula::instance();
pool = nd.get_docpool();
auth_object = PoolObjectSQL::DOCUMENT;
auth_op = AuthRequest::USE;
};
~DocumentClone(){};
/* -------------------------------------------------------------------- */
Template * clone_template(PoolObjectSQL* obj)
{
return static_cast<Document*>(obj)->clone_template();
};
int pool_allocate(
xmlrpc_c::paramList const& paramList,
Template * tmpl,
int& id,
string& error_str,
RequestAttributes& att)
{
int type = xmlrpc_c::value_int(paramList.getInt(3));
DocumentPool * docpool = static_cast<DocumentPool *>(pool);
return docpool->allocate(att.uid, att.gid, att.uname, att.gname, type,
tmpl, &id, error_str);
};
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
#endif

View File

@ -31,8 +31,9 @@ class RequestManagerDelete: public Request
{
protected:
RequestManagerDelete(const string& method_name,
const string& help)
:Request(method_name,"A:si",help)
const string& help,
const string& signature="A:si")
:Request(method_name,signature,help)
{
auth_op = AuthRequest::MANAGE;
@ -48,11 +49,18 @@ protected:
void request_execute(xmlrpc_c::paramList const& _paramList,
RequestAttributes& att);
bool delete_authorization(int oid,
RequestAttributes& att);
bool delete_authorization(int oid,
RequestAttributes& att,
xmlrpc_c::paramList const& paramList);
/* -------------------------------------------------------------------- */
virtual PoolObjectSQL * get_obj(
int oid, xmlrpc_c::paramList const& paramList)
{
return pool->get(oid,true);
};
virtual int drop(int oid, PoolObjectSQL * object, string& error_msg);
virtual int get_cluster_id(PoolObjectSQL * object)
@ -270,6 +278,34 @@ public:
~ClusterDelete(){};
};
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class DocumentDelete : public RequestManagerDelete
{
public:
DocumentDelete():
RequestManagerDelete("DocumentDelete",
"Deletes a generic document",
"A:sii")
{
Nebula& nd = Nebula::instance();
pool = nd.get_docpool();
auth_object = PoolObjectSQL::DOCUMENT;
};
~DocumentDelete(){};
/* -------------------------------------------------------------------- */
PoolObjectSQL * get_obj(int oid, xmlrpc_c::paramList const& paramList)
{
int obj_type = xmlrpc_c::value_int(paramList.getInt(2));
return static_cast<DocumentPool*>(pool)->get(oid, obj_type, true);
};
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

View File

@ -30,8 +30,9 @@ class RequestManagerInfo: public Request
{
protected:
RequestManagerInfo(const string& method_name,
const string& help)
:Request(method_name,"A:si",help)
const string& help,
const string& signature = "A:si")
:Request(method_name,signature,help)
{
auth_op = AuthRequest::USE;
};
@ -49,6 +50,12 @@ protected:
{
object->to_xml(str);
};
virtual PoolObjectSQL * get_obj(
int oid, xmlrpc_c::paramList const& paramList)
{
return pool->get(oid,true);
};
};
/* ------------------------------------------------------------------------- */
@ -231,6 +238,34 @@ public:
~ClusterInfo(){};
};
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class DocumentInfo : public RequestManagerInfo
{
public:
DocumentInfo():
RequestManagerInfo("DocumentInfo",
"Returns generic document information",
"A:sii")
{
Nebula& nd = Nebula::instance();
pool = nd.get_docpool();
auth_object = PoolObjectSQL::DOCUMENT;
};
~DocumentInfo(){};
/* -------------------------------------------------------------------- */
PoolObjectSQL * get_obj(int oid, xmlrpc_c::paramList const& paramList)
{
int obj_type = xmlrpc_c::value_int(paramList.getInt(2));
return static_cast<DocumentPool*>(pool)->get(oid, obj_type, true);
};
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

View File

@ -356,6 +356,30 @@ public:
xmlrpc_c::paramList const& paramList, RequestAttributes& att);
};
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class DocumentPoolInfo : public RequestManagerPoolInfoFilter
{
public:
DocumentPoolInfo():
RequestManagerPoolInfoFilter("DocumentPoolInfo",
"Returns the generic document pool",
"A:siiii")
{
Nebula& nd = Nebula::instance();
pool = nd.get_docpool();
auth_object = PoolObjectSQL::DOCUMENT;
};
~DocumentPoolInfo(){};
/* -------------------------------------------------------------------- */
void request_execute(
xmlrpc_c::paramList const& paramList, RequestAttributes& att);
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

View File

@ -30,8 +30,9 @@ class RequestManagerUpdateTemplate: public Request
{
protected:
RequestManagerUpdateTemplate(const string& method_name,
const string& help)
:Request(method_name,"A:sis",help)
const string& help,
const string& signature = "A:sis")
:Request(method_name,signature,help)
{
auth_op = AuthRequest::MANAGE;
};
@ -42,6 +43,12 @@ protected:
void request_execute(xmlrpc_c::paramList const& _paramList,
RequestAttributes& att);
virtual PoolObjectSQL * get_obj(
int oid, xmlrpc_c::paramList const& paramList)
{
return pool->get(oid,true);
};
};
/* ------------------------------------------------------------------------- */
@ -152,6 +159,34 @@ public:
~DatastoreUpdateTemplate(){};
};
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class DocumentUpdateTemplate : public RequestManagerUpdateTemplate
{
public:
DocumentUpdateTemplate():
RequestManagerUpdateTemplate("DocumentUpdateTemplate",
"Updates a document template",
"A:sisi")
{
Nebula& nd = Nebula::instance();
pool = nd.get_docpool();
auth_object = PoolObjectSQL::DOCUMENT;
};
~DocumentUpdateTemplate(){};
/* -------------------------------------------------------------------- */
PoolObjectSQL * get_obj(int oid, xmlrpc_c::paramList const& paramList)
{
int obj_type = xmlrpc_c::value_int(paramList.getInt(3));
return static_cast<DocumentPool*>(pool)->get(oid, obj_type, true);
};
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

View File

@ -68,26 +68,6 @@ public:
RequestAttributes& att);
};
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class VMTemplateClone : public RequestManagerVMTemplate
{
public:
VMTemplateClone():
RequestManagerVMTemplate("VMTemplateClone",
"Clone an existing virtual machine template",
"A:sis")
{
auth_op = AuthRequest::USE;
};
~VMTemplateClone(){};
void request_execute(xmlrpc_c::paramList const& _paramList,
RequestAttributes& att);
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

View File

@ -25,6 +25,7 @@
#include "RequestManagerUpdateTemplate.h"
#include "RequestManagerChown.h"
#include "RequestManagerChmod.h"
#include "RequestManagerClone.h"
#include "RequestManagerVirtualNetwork.h"
#include "RequestManagerVirtualMachine.h"
@ -236,7 +237,6 @@ void RequestManager::register_xml_methods()
// VMTemplate Methods
xmlrpc_c::methodPtr template_instantiate(new VMTemplateInstantiate());
xmlrpc_c::methodPtr template_clone(new VMTemplateClone());
// VirtualMachine Methods
xmlrpc_c::methodPtr vm_deploy(new VirtualMachineDeploy());
@ -260,6 +260,7 @@ void RequestManager::register_xml_methods()
xmlrpc_c::methodPtr vn_update(new VirtualNetworkUpdateTemplate());
xmlrpc_c::methodPtr user_update(new UserUpdateTemplate());
xmlrpc_c::methodPtr datastore_update(new DatastoreUpdateTemplate());
xmlrpc_c::methodPtr doc_update(new DocumentUpdateTemplate());
// Allocate Methods
xmlrpc_c::methodPtr vm_allocate(new VirtualMachineAllocate());
@ -271,6 +272,11 @@ void RequestManager::register_xml_methods()
xmlrpc_c::methodPtr user_allocate(new UserAllocate());
xmlrpc_c::methodPtr datastore_allocate(new DatastoreAllocate());
xmlrpc_c::methodPtr cluster_allocate(new ClusterAllocate());
xmlrpc_c::methodPtr doc_allocate(new DocumentAllocate());
// Clone Methods
xmlrpc_c::methodPtr template_clone(new VMTemplateClone());
xmlrpc_c::methodPtr doc_clone(new DocumentClone());
// Delete Methods
xmlrpc_c::methodPtr host_delete(new HostDelete());
@ -281,6 +287,7 @@ void RequestManager::register_xml_methods()
xmlrpc_c::methodPtr image_delete(new ImageDelete());
xmlrpc_c::methodPtr datastore_delete(new DatastoreDelete());
xmlrpc_c::methodPtr cluster_delete(new ClusterDelete());
xmlrpc_c::methodPtr doc_delete(new DocumentDelete());
// Info Methods
xmlrpc_c::methodPtr vm_info(new VirtualMachineInfo());
@ -292,6 +299,7 @@ void RequestManager::register_xml_methods()
xmlrpc_c::methodPtr image_info(new ImageInfo());
xmlrpc_c::methodPtr datastore_info(new DatastoreInfo());
xmlrpc_c::methodPtr cluster_info(new ClusterInfo());
xmlrpc_c::methodPtr doc_info(new DocumentInfo());
// PoolInfo Methods
xmlrpc_c::methodPtr hostpool_info(new HostPoolInfo());
@ -303,6 +311,7 @@ void RequestManager::register_xml_methods()
xmlrpc_c::methodPtr vnpool_info(new VirtualNetworkPoolInfo());
xmlrpc_c::methodPtr imagepool_info(new ImagePoolInfo());
xmlrpc_c::methodPtr clusterpool_info(new ClusterPoolInfo());
xmlrpc_c::methodPtr docpool_info(new DocumentInfo());
// Host Methods
xmlrpc_c::methodPtr host_enable(new HostEnable());
@ -321,6 +330,7 @@ void RequestManager::register_xml_methods()
xmlrpc_c::methodPtr image_chown(new ImageChown());
xmlrpc_c::methodPtr user_chown(new UserChown());
xmlrpc_c::methodPtr datastore_chown(new DatastoreChown());
xmlrpc_c::methodPtr doc_chown(new DocumentChown());
// Chmod Methods
xmlrpc_c::methodPtr vm_chmod(new VirtualMachineChmod());
@ -328,6 +338,7 @@ void RequestManager::register_xml_methods()
xmlrpc_c::methodPtr vn_chmod(new VirtualNetworkChmod());
xmlrpc_c::methodPtr image_chmod(new ImageChmod());
xmlrpc_c::methodPtr datastore_chmod(new DatastoreChmod());
xmlrpc_c::methodPtr doc_chmod(new DocumentChmod());
// ACL Methods
xmlrpc_c::methodPtr acl_addrule(new AclAddRule());
@ -453,6 +464,17 @@ void RequestManager::register_xml_methods()
RequestManagerRegistry.addMethod("one.cluster.delvnet", cluster_delvnet);
RequestManagerRegistry.addMethod("one.clusterpool.info",clusterpool_info);
/* Generic Document objects related methods*/
RequestManagerRegistry.addMethod("one.document.allocate",doc_allocate);
RequestManagerRegistry.addMethod("one.document.delete", doc_delete);
RequestManagerRegistry.addMethod("one.document.info", doc_info);
RequestManagerRegistry.addMethod("one.document.update", doc_update);
RequestManagerRegistry.addMethod("one.document.chown", doc_chown);
RequestManagerRegistry.addMethod("one.document.chmod", doc_chmod);
RequestManagerRegistry.addMethod("one.document.clone", doc_clone);
RequestManagerRegistry.addMethod("one.documentpool.info",docpool_info);
};
/* -------------------------------------------------------------------------- */

View File

@ -541,3 +541,20 @@ int ClusterAllocate::pool_allocate(xmlrpc_c::paramList const& paramList,
return clpool->allocate(name, &id, error_str);
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int DocumentAllocate::pool_allocate(xmlrpc_c::paramList const& paramList,
Template * tmpl,
int& id,
string& error_str,
RequestAttributes& att)
{
int type = xmlrpc_c::value_int(paramList.getInt(2));
DocumentPool * docpool = static_cast<DocumentPool *>(pool);
return docpool->allocate(att.uid, att.gid, att.uname, att.gname, type,
tmpl, &id, error_str);
}

View File

@ -49,7 +49,7 @@ void RequestManagerChmod::request_execute(xmlrpc_c::paramList const& paramList,
AuthRequest::Operation op = AuthRequest::MANAGE;
PoolObjectAuth perms;
object = pool->get(oid,true);
object = get_obj(oid, paramList);
if ( object == 0 )
{
@ -128,7 +128,7 @@ void RequestManagerChmod::request_execute(xmlrpc_c::paramList const& paramList,
// ------------- Update the object ---------------------
object = pool->get(oid,true);
object = get_obj(oid, paramList);
if ( object == 0 )
{

View File

@ -104,7 +104,7 @@ void RequestManagerChown::request_execute(xmlrpc_c::paramList const& paramList,
// ------------- Update the object ---------------------
object = pool->get(oid,true);
object = get_obj(oid, paramList);
if ( object == 0 )
{

View File

@ -0,0 +1,96 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
#include "RequestManagerClone.h"
#include "PoolObjectAuth.h"
#include "Nebula.h"
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void RequestManagerClone::request_execute(
xmlrpc_c::paramList const& paramList,
RequestAttributes& att)
{
int source_id = xmlrpc_c::value_int(paramList.getInt(1));
string name = xmlrpc_c::value_string(paramList.getString(2));
int rc, new_id;
PoolObjectAuth perms;
Template * tmpl;
PoolObjectSQL * source_obj;
string error_str;
source_obj = get_obj(source_id, paramList);
if ( source_obj == 0 )
{
failure_response(NO_EXISTS,
get_error(object_name(auth_object),source_id),
att);
return;
}
tmpl = clone_template(source_obj);
source_obj->get_permissions(perms);
source_obj->unlock();
tmpl->erase("NAME");
tmpl->set(new SingleAttribute("NAME",name));
if ( att.uid != 0 )
{
string tmpl_str = "";
AuthRequest ar(att.uid, att.gid);
ar.add_auth(auth_op, perms); //USE OBJECT
tmpl->to_xml(tmpl_str);
ar.add_create_auth(auth_object, tmpl_str);
if (UserPool::authorize(ar) == -1)
{
failure_response(AUTHORIZATION,
authorization_error(ar.message, att),
att);
delete tmpl;
return;
}
}
rc = pool_allocate(paramList, tmpl, new_id, error_str, att);
if ( rc < 0 )
{
failure_response(INTERNAL, allocate_error(error_str), att);
return;
}
success_response(new_id, att);
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

View File

@ -21,8 +21,10 @@ using namespace std;
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
bool RequestManagerDelete::delete_authorization(int oid,
RequestAttributes& att)
bool RequestManagerDelete::delete_authorization(
int oid,
RequestAttributes& att,
xmlrpc_c::paramList const& paramList)
{
PoolObjectSQL * object;
PoolObjectAuth perms;
@ -32,7 +34,7 @@ bool RequestManagerDelete::delete_authorization(int oid,
return true;
}
object = pool->get(oid,true);
object = get_obj(oid, paramList);
if ( object == 0 )
{
@ -72,12 +74,12 @@ void RequestManagerDelete::request_execute(xmlrpc_c::paramList const& paramList,
PoolObjectSQL * object;
string error_msg;
if ( delete_authorization(oid, att) == false )
if ( delete_authorization(oid, att, paramList) == false )
{
return;
}
object = pool->get(oid,true);
object = get_obj(oid, paramList);
if ( object == 0 )
{

View File

@ -45,7 +45,7 @@ void RequestManagerInfo::request_execute(xmlrpc_c::paramList const& paramList,
return;
}
object = pool->get(oid,true);
object = get_obj(oid, paramList);
if ( object == 0 )
{

View File

@ -243,6 +243,24 @@ void ClusterPoolInfo::request_execute(
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
void DocumentPoolInfo::request_execute(
xmlrpc_c::paramList const& paramList,
RequestAttributes& att)
{
int filter_flag = xmlrpc_c::value_int(paramList.getInt(1));
int start_id = xmlrpc_c::value_int(paramList.getInt(2));
int end_id = xmlrpc_c::value_int(paramList.getInt(3));
int type = xmlrpc_c::value_int(paramList.getInt(4));
ostringstream oss;
oss << "type = " << type;
dump(att, filter_flag, start_id, end_id, oss.str(), "");
}
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
void RequestManagerPoolInfoFilter::where_filter(
RequestAttributes& att,
int filter_flag,

View File

@ -38,7 +38,7 @@ void RequestManagerUpdateTemplate::request_execute(
return;
}
object = pool->get(oid,true);
object = get_obj(oid, paramList);
if ( object == 0 )
{

View File

@ -118,78 +118,3 @@ void VMTemplateInstantiate::request_execute(xmlrpc_c::paramList const& paramList
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void VMTemplateClone::request_execute(xmlrpc_c::paramList const& paramList,
RequestAttributes& att)
{
int source_id = xmlrpc_c::value_int(paramList.getInt(1));
string name = xmlrpc_c::value_string(paramList.getString(2));
int rc, new_id;
PoolObjectAuth perms;
VMTemplatePool * tpool = static_cast<VMTemplatePool *>(pool);
VirtualMachineTemplate * tmpl;
VMTemplate * source_tmpl;
string error_str;
source_tmpl = tpool->get(source_id,true);
if ( source_tmpl == 0 )
{
failure_response(NO_EXISTS,
get_error(object_name(auth_object),source_id),
att);
return;
}
tmpl = source_tmpl->clone_template();
source_tmpl->get_permissions(perms);
source_tmpl->unlock();
tmpl->erase("NAME");
tmpl->set(new SingleAttribute("NAME",name));
if ( att.uid != 0 )
{
string tmpl_str = "";
AuthRequest ar(att.uid, att.gid);
ar.add_auth(auth_op, perms); //USE TEMPLATE
tmpl->to_xml(tmpl_str);
ar.add_create_auth(auth_object, tmpl_str);
if (UserPool::authorize(ar) == -1)
{
failure_response(AUTHORIZATION,
authorization_error(ar.message, att),
att);
delete tmpl;
return;
}
}
rc = tpool->allocate(att.uid, att.gid, att.uname, att.gname,
tmpl, &new_id, error_str);
if ( rc < 0 )
{
failure_response(INTERNAL, allocate_error(error_str), att);
return;
}
success_response(new_id, att);
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

View File

@ -38,7 +38,8 @@ source_files=[
'RequestManagerChown.cc',
'RequestManagerAcl.cc',
'RequestManagerChmod.cc',
'RequestManagerCluster.cc'
'RequestManagerCluster.cc',
'RequestManagerClone.cc'
]
# Build library