mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-26 09:57:23 +03:00
feature #662: Delete uses a common Request. Moved more functionality to base classes
This commit is contained in:
parent
c15a9e9a12
commit
fc15b443b6
@ -21,6 +21,7 @@
|
||||
#include <xmlrpc-c/registry.hpp>
|
||||
|
||||
#include "RequestManager.h"
|
||||
#include "AuthManager.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -56,9 +57,24 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
/* ------------------- Attributes of the Request ---------------------- */
|
||||
|
||||
int uid; /** id of the user performing the request */
|
||||
|
||||
int gid; /** id of the user performing the request */
|
||||
|
||||
PoolSQL * pool; /** id of the user performing the request */
|
||||
|
||||
AuthRequest::Object auth_object; /** Auth object for the request */
|
||||
|
||||
AuthRequest::Operation auth_op; /** Auth operation for the request */
|
||||
|
||||
|
||||
/* -------------------- Constructors ---------------------------------- */
|
||||
|
||||
Request(const string& mn,
|
||||
const string& signature,
|
||||
const string& help): method_name(mn), retval(0)
|
||||
const string& help): uid(-1),gid(-1),pool(0),method_name(mn),retval(0)
|
||||
{
|
||||
_signature = signature;
|
||||
_help = help;
|
||||
@ -66,7 +82,22 @@ protected:
|
||||
|
||||
virtual ~Request(){};
|
||||
|
||||
/* ----------- Wrapper functions for the PoolObjectSQL class ---------- */
|
||||
|
||||
virtual bool isPublic(PoolObjectSQL *obj){ return false; };
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Performs a basic autorization for this request using the uid/gid
|
||||
* from the request. The function gets the object from the pool to get
|
||||
* the public attribute and its owner. The authorization is based on
|
||||
* object and type of operation for the request.
|
||||
* @param oid of the object.
|
||||
*/
|
||||
bool basic_authorization(int oid);
|
||||
|
||||
/**
|
||||
* Actual Execution method for the request. Must be implemented by the
|
||||
* XML-RPC requests
|
||||
@ -74,9 +105,7 @@ protected:
|
||||
* @param gid of the user making the request
|
||||
* @param _paramlist of the XML-RPC call (complete list)
|
||||
*/
|
||||
virtual void request_execute(int uid,
|
||||
int gid,
|
||||
xmlrpc_c::paramList const& _paramList) = 0;
|
||||
virtual void request_execute(xmlrpc_c::paramList const& _paramList) = 0;
|
||||
|
||||
/**
|
||||
* Builds an XML-RPC response updating retval. After calling this function
|
||||
@ -157,5 +186,58 @@ private:
|
||||
xmlrpc_c::value * retval;
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* TemplateRequest Class implements specific function to handle Templates
|
||||
*/
|
||||
class TemplateRequest
|
||||
{
|
||||
bool isPublic(PoolObjectSQL *obj)
|
||||
{
|
||||
VMTemplate * cobj;
|
||||
|
||||
cobj = static_cast<VMTemplate *>(obj);
|
||||
|
||||
return cobj->isPublic();
|
||||
};
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* VirtualNetworkRequest Class implements specific function to handle VirtualNetworks
|
||||
*/
|
||||
class VirtualNetworkRequest
|
||||
{
|
||||
bool isPublic(PoolObjectSQL *obj)
|
||||
{
|
||||
VirtualNetwork * cobj;
|
||||
|
||||
cobj = static_cast<VirtualNetwork *>(obj);
|
||||
|
||||
return cobj->isPublic();
|
||||
};
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* ImageRequest Class implements specific function to handle Images
|
||||
*/
|
||||
class ImageRequest
|
||||
{
|
||||
bool isPublic(PoolObjectSQL *obj)
|
||||
{
|
||||
Image * cobj;
|
||||
|
||||
cobj = static_cast<Image *>(obj);
|
||||
|
||||
return cobj->isPublic();
|
||||
};
|
||||
};
|
||||
|
||||
#endif //REQUEST_H_
|
||||
|
||||
|
174
include/RequestManagerDelete.h
Normal file
174
include/RequestManagerDelete.h
Normal file
@ -0,0 +1,174 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2011, 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_DELETE_H_
|
||||
#define REQUEST_MANAGER_DELETE_H_
|
||||
|
||||
#include "Request.h"
|
||||
#include "Nebula.h"
|
||||
#include "AuthManager.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
class RequestManagerDelete: public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerDelete(const string& method_name,
|
||||
const string& help)
|
||||
:Request(method_name,"A:si",help)
|
||||
{
|
||||
auth_op = AuthRequest::DELETE;
|
||||
}
|
||||
|
||||
~RequestManagerDelete(){};
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList);
|
||||
};
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
class TemplateDelete : public RequestManagerDelete, public TemplateRequest
|
||||
{
|
||||
public:
|
||||
TemplateDelete():
|
||||
RequestManagerDelete("TemplateDelete",
|
||||
"Deletes a virtual machine template")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_tpool();
|
||||
auth_object = AuthRequest::TEMPLATE;
|
||||
};
|
||||
|
||||
~TemplateDelete(){};
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
class VirtualNetworkDelete: public RequestManagerDelete, public VirtualNetworkRequest
|
||||
{
|
||||
public:
|
||||
VirtualNetworkDelete():
|
||||
RequestManagerDelete("VirtualNetworkDelete",
|
||||
"Deletes a virtual network")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_vnpool();
|
||||
auth_object = AuthRequest::NET;
|
||||
};
|
||||
|
||||
~VirtualNetworkDelete(){};
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
class ImageDelete: public RequestManagerDelete, public ImageRequest
|
||||
{
|
||||
public:
|
||||
ImageDelete():
|
||||
RequestManagerDelete("ImageDelete", "Deletes an image")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_ipool();
|
||||
auth_object = AuthRequest::IMAGE;
|
||||
};
|
||||
|
||||
~ImageDelete(){};
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
class HostDelete : public RequestManagerDelete
|
||||
{
|
||||
public:
|
||||
HostDelete():
|
||||
RequestManagerDelete("HostDelete", "Deletes a host")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_hpool();
|
||||
auth_object = AuthRequest::HOST;
|
||||
};
|
||||
|
||||
~HostDelete(){};
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
class ClusterDelete : public RequestManagerDelete
|
||||
{
|
||||
public:
|
||||
ClusterDelete():
|
||||
RequestManagerDelete("ClusterDelete", "Deletes a cluster")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_cpool();
|
||||
auth_object = AuthRequest::CLUSTER;
|
||||
};
|
||||
|
||||
~ClusterDelete(){};
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
class GroupDelete: public RequestManagerDelete
|
||||
{
|
||||
public:
|
||||
GroupDelete():
|
||||
RequestManagerDelete("GroupDelete", "Deletes a group")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_gpool();
|
||||
auth_object = AuthRequest::GROUP;
|
||||
};
|
||||
|
||||
~GroupDelete(){};
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
class UserDelete: public RequestManagerDelete
|
||||
{
|
||||
public:
|
||||
UserDelete():
|
||||
RequestManagerDelete("UserDelete", "Deletes a user")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_upool();
|
||||
auth_object = AuthRequest::USER;
|
||||
};
|
||||
|
||||
~UserDelete(){};
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#endif
|
@ -19,7 +19,6 @@
|
||||
|
||||
#include "Request.h"
|
||||
#include "Nebula.h"
|
||||
#include "AuthManager.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -32,22 +31,16 @@ class RequestManagerInfo: public Request
|
||||
protected:
|
||||
RequestManagerInfo(const string& method_name,
|
||||
const string& help)
|
||||
:Request(method_name,"A:si",help){};
|
||||
:Request(method_name,"A:si",help)
|
||||
{
|
||||
auth_op = AuthRequest::INFO;
|
||||
};
|
||||
|
||||
~RequestManagerInfo(){};
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
void request_execute(int uid,
|
||||
int gid,
|
||||
xmlrpc_c::paramList const& _paramList);
|
||||
|
||||
virtual bool isPublic(PoolObjectSQL *obj){ return false; };
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
PoolSQL * pool;
|
||||
AuthRequest::Object auth_object;
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList);
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -71,7 +64,7 @@ public:
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
class TemplateInfo : public RequestManagerInfo
|
||||
class TemplateInfo : public RequestManagerInfo, public TemplateRequest
|
||||
{
|
||||
public:
|
||||
TemplateInfo():
|
||||
@ -84,22 +77,13 @@ public:
|
||||
};
|
||||
|
||||
~TemplateInfo(){};
|
||||
|
||||
bool isPublic(PoolObjectSQL *obj)
|
||||
{
|
||||
VMTemplate * cobj;
|
||||
|
||||
cobj = static_cast<VMTemplate *>(obj);
|
||||
|
||||
return cobj->isPublic();
|
||||
};
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
class VirtualNetworkInfo: public RequestManagerInfo
|
||||
class VirtualNetworkInfo: public RequestManagerInfo, public VirtualNetworkRequest
|
||||
{
|
||||
public:
|
||||
VirtualNetworkInfo():
|
||||
@ -113,20 +97,12 @@ public:
|
||||
|
||||
~VirtualNetworkInfo(){};
|
||||
|
||||
bool isPublic(PoolObjectSQL *obj)
|
||||
{
|
||||
VirtualNetwork * cobj;
|
||||
|
||||
cobj = static_cast<VirtualNetwork *>(obj);
|
||||
|
||||
return cobj->isPublic();
|
||||
};
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
class ImageInfo: public RequestManagerInfo
|
||||
class ImageInfo: public RequestManagerInfo, public ImageRequest
|
||||
{
|
||||
public:
|
||||
ImageInfo():
|
||||
@ -140,14 +116,6 @@ public:
|
||||
|
||||
~ImageInfo(){};
|
||||
|
||||
bool isPublic(PoolObjectSQL *obj)
|
||||
{
|
||||
Image * cobj;
|
||||
|
||||
cobj = static_cast<Image *>(obj);
|
||||
|
||||
return cobj->isPublic();
|
||||
};
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
@ -32,20 +32,16 @@ class RequestManagerPoolInfo: public Request
|
||||
protected:
|
||||
RequestManagerPoolInfo(const string& method_name,
|
||||
const string& help)
|
||||
:Request(method_name,"A:s",help){};
|
||||
:Request(method_name,"A:s",help)
|
||||
{
|
||||
auth_op = AuthRequest::INFO_POOL;
|
||||
};
|
||||
|
||||
~RequestManagerPoolInfo(){};
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
void request_execute(int uid,
|
||||
int gid,
|
||||
xmlrpc_c::paramList const& _paramList);
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
PoolSQL * pool;
|
||||
AuthRequest::Object auth_object;
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList);
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
@ -32,7 +32,10 @@ class RequestManagerPoolInfoFilter: public Request
|
||||
protected:
|
||||
RequestManagerPoolInfoFilter(const string& method_name,
|
||||
const string& help)
|
||||
:Request(method_name,"A:si",help){};
|
||||
:Request(method_name,"A:si",help)
|
||||
{
|
||||
auth_op = AuthRequest::INFO_POOL;
|
||||
};
|
||||
|
||||
~RequestManagerPoolInfoFilter(){};
|
||||
|
||||
@ -44,14 +47,7 @@ protected:
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
void request_execute(int uid,
|
||||
int gid,
|
||||
xmlrpc_c::paramList const& _paramList);
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
PoolSQL * pool;
|
||||
AuthRequest::Object auth_object;
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList);
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
@ -25,9 +25,6 @@ void Request::execute(
|
||||
xmlrpc_c::paramList const& _paramList,
|
||||
xmlrpc_c::value * const _retval)
|
||||
{
|
||||
int uid;
|
||||
int gid;
|
||||
|
||||
retval = _retval;
|
||||
session = xmlrpc_c::value_string (_paramList.getString(0));
|
||||
|
||||
@ -42,13 +39,54 @@ void Request::execute(
|
||||
}
|
||||
else
|
||||
{
|
||||
request_execute(uid, gid, _paramList);
|
||||
request_execute(_paramList);
|
||||
}
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
bool Request::basic_authorization(int oid)
|
||||
{
|
||||
PoolObjectSQL * object;
|
||||
|
||||
bool pub;
|
||||
int ouid;
|
||||
|
||||
object = pool->get(oid,true);
|
||||
|
||||
if ( object == 0 )
|
||||
{
|
||||
failure_response(NO_EXISTS, get_error("USER",oid)); //TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
ouid = object->get_uid();
|
||||
pub = isPublic(object);
|
||||
|
||||
object->unlock();
|
||||
|
||||
if ( uid != 0 ) // uid == 0 means oneadmin
|
||||
{
|
||||
AuthRequest ar(uid);
|
||||
|
||||
ar.add_auth(auth_object, oid, auth_op, ouid, pub);
|
||||
|
||||
if (UserPool::authorize(ar) == -1)
|
||||
{
|
||||
failure_response(AUTHORIZATION, //TODO
|
||||
authorization_error("INFO","USER",oid,-1));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void Request::failure_response(ErrorCode ec, const string& str_val)
|
||||
{
|
||||
vector<xmlrpc_c::value> arrayData;
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "RequestManagerPoolInfoFilter.h"
|
||||
#include "RequestManagerPoolInfo.h"
|
||||
#include "RequestManagerInfo.h"
|
||||
#include "RequestManagerDelete.h"
|
||||
|
||||
#include <sys/signal.h>
|
||||
#include <sys/socket.h>
|
||||
@ -217,6 +218,15 @@ void RequestManager::do_action(
|
||||
|
||||
void RequestManager::register_xml_methods()
|
||||
{
|
||||
// Delete Methods
|
||||
xmlrpc_c::methodPtr host_delete(new HostDelete());
|
||||
xmlrpc_c::methodPtr template_delete(new TemplateDelete());
|
||||
xmlrpc_c::methodPtr cluster_delete(new ClusterDelete());
|
||||
xmlrpc_c::methodPtr group_delete(new GroupDelete());
|
||||
xmlrpc_c::methodPtr vn_delete(new VirtualNetworkDelete());
|
||||
xmlrpc_c::methodPtr user_delete(new UserDelete());
|
||||
xmlrpc_c::methodPtr image_delete(new ImageDelete());
|
||||
|
||||
// Info Methods
|
||||
xmlrpc_c::methodPtr vm_info(new VirtualMachineInfo());
|
||||
xmlrpc_c::methodPtr host_info(new HostInfo());
|
||||
@ -263,8 +273,6 @@ void RequestManager::register_xml_methods()
|
||||
xmlrpc_c::methodPtr template_allocate(new
|
||||
RequestManager::TemplateAllocate(tpool,upool));
|
||||
|
||||
xmlrpc_c::methodPtr template_delete(new
|
||||
RequestManager::TemplateDelete(tpool, upool));
|
||||
|
||||
|
||||
xmlrpc_c::methodPtr template_update(new
|
||||
@ -283,8 +291,6 @@ void RequestManager::register_xml_methods()
|
||||
RequestManager::HostAllocate(hpool,upool));
|
||||
|
||||
|
||||
xmlrpc_c::methodPtr host_delete(new
|
||||
RequestManager::HostDelete(hpool,upool));
|
||||
|
||||
xmlrpc_c::methodPtr host_enable(new
|
||||
RequestManager::HostEnable(hpool,upool));
|
||||
@ -293,8 +299,6 @@ void RequestManager::register_xml_methods()
|
||||
RequestManager::ClusterAllocate(upool,cpool));
|
||||
|
||||
|
||||
xmlrpc_c::methodPtr cluster_delete(new
|
||||
RequestManager::ClusterDelete(upool,cpool));
|
||||
|
||||
xmlrpc_c::methodPtr cluster_add(new
|
||||
RequestManager::ClusterAdd(hpool,upool,cpool));
|
||||
@ -306,8 +310,6 @@ void RequestManager::register_xml_methods()
|
||||
RequestManager::GroupAllocate(upool,gpool));
|
||||
|
||||
|
||||
xmlrpc_c::methodPtr group_delete(new
|
||||
RequestManager::GroupDelete(upool,gpool));
|
||||
|
||||
xmlrpc_c::methodPtr vn_allocate(new
|
||||
RequestManager::VirtualNetworkAllocate(vnpool,upool));
|
||||
@ -316,8 +318,6 @@ void RequestManager::register_xml_methods()
|
||||
xmlrpc_c::methodPtr vn_publish(new
|
||||
RequestManager::VirtualNetworkPublish(vnpool, upool));
|
||||
|
||||
xmlrpc_c::methodPtr vn_delete(new
|
||||
RequestManager::VirtualNetworkDelete(vnpool, upool));
|
||||
|
||||
xmlrpc_c::methodPtr vn_addleases(new
|
||||
RequestManager::VirtualNetworkAddLeases(vnpool, upool));
|
||||
@ -331,8 +331,6 @@ void RequestManager::register_xml_methods()
|
||||
xmlrpc_c::methodPtr user_allocate(new
|
||||
RequestManager::UserAllocate(upool));
|
||||
|
||||
xmlrpc_c::methodPtr user_delete(new
|
||||
RequestManager::UserDelete(upool));
|
||||
|
||||
|
||||
xmlrpc_c::methodPtr user_change_password(new
|
||||
@ -344,8 +342,6 @@ void RequestManager::register_xml_methods()
|
||||
xmlrpc_c::methodPtr image_allocate(new
|
||||
RequestManager::ImageAllocate(ipool, upool));
|
||||
|
||||
xmlrpc_c::methodPtr image_delete(new
|
||||
RequestManager::ImageDelete(ipool, upool));
|
||||
|
||||
|
||||
xmlrpc_c::methodPtr image_update(new
|
||||
@ -382,12 +378,12 @@ void RequestManager::register_xml_methods()
|
||||
/* VM Template related methods*/
|
||||
/*
|
||||
RequestManagerRegistry.addMethod("one.template.allocate",template_allocate);
|
||||
RequestManagerRegistry.addMethod("one.template.delete", template_delete);
|
||||
RequestManagerRegistry.addMethod("one.template.update", template_update);
|
||||
RequestManagerRegistry.addMethod("one.template.rmattr", template_rm_attribute);
|
||||
RequestManagerRegistry.addMethod("one.template.publish", template_publish);
|
||||
RequestManagerRegistry.addMethod("one.template.chown", template_chown);
|
||||
*/
|
||||
RequestManagerRegistry.addMethod("one.template.delete", template_delete);
|
||||
RequestManagerRegistry.addMethod("one.template.info", template_info);
|
||||
|
||||
RequestManagerRegistry.addMethod("one.templatepool.info",template_pool_info);
|
||||
@ -395,9 +391,9 @@ void RequestManager::register_xml_methods()
|
||||
/* Host related methods*/
|
||||
/*
|
||||
RequestManagerRegistry.addMethod("one.host.allocate", host_allocate);
|
||||
RequestManagerRegistry.addMethod("one.host.delete", host_delete);
|
||||
RequestManagerRegistry.addMethod("one.host.enable", host_enable);
|
||||
*/
|
||||
RequestManagerRegistry.addMethod("one.host.delete", host_delete);
|
||||
RequestManagerRegistry.addMethod("one.host.info", host_info);
|
||||
|
||||
RequestManagerRegistry.addMethod("one.hostpool.info", hostpool_info);
|
||||
@ -405,10 +401,10 @@ void RequestManager::register_xml_methods()
|
||||
/* Cluster related methods */
|
||||
/*
|
||||
RequestManagerRegistry.addMethod("one.cluster.allocate", cluster_allocate);
|
||||
RequestManagerRegistry.addMethod("one.cluster.delete", cluster_delete);
|
||||
RequestManagerRegistry.addMethod("one.cluster.add", cluster_add);
|
||||
RequestManagerRegistry.addMethod("one.cluster.remove", cluster_remove);
|
||||
*/
|
||||
RequestManagerRegistry.addMethod("one.cluster.delete", cluster_delete);
|
||||
RequestManagerRegistry.addMethod("one.cluster.info", cluster_info);
|
||||
|
||||
RequestManagerRegistry.addMethod("one.clusterpool.info", clusterpool_info);
|
||||
@ -416,8 +412,8 @@ void RequestManager::register_xml_methods()
|
||||
/* Group related methods */
|
||||
/*
|
||||
RequestManagerRegistry.addMethod("one.group.allocate", group_allocate);
|
||||
RequestManagerRegistry.addMethod("one.group.delete", group_delete);
|
||||
*/
|
||||
RequestManagerRegistry.addMethod("one.group.delete", group_delete);
|
||||
RequestManagerRegistry.addMethod("one.group.info", group_info);
|
||||
|
||||
RequestManagerRegistry.addMethod("one.grouppool.info", grouppool_info);
|
||||
@ -426,11 +422,11 @@ void RequestManager::register_xml_methods()
|
||||
/*
|
||||
RequestManagerRegistry.addMethod("one.vn.allocate", vn_allocate);
|
||||
RequestManagerRegistry.addMethod("one.vn.publish", vn_publish);
|
||||
RequestManagerRegistry.addMethod("one.vn.delete", vn_delete);
|
||||
RequestManagerRegistry.addMethod("one.vn.addleases", vn_addleases);
|
||||
RequestManagerRegistry.addMethod("one.vn.rmleases", vn_rmleases);
|
||||
RequestManagerRegistry.addMethod("one.vn.chown", vn_chown);
|
||||
*/
|
||||
RequestManagerRegistry.addMethod("one.vn.delete", vn_delete);
|
||||
RequestManagerRegistry.addMethod("one.vn.info", vn_info);
|
||||
|
||||
RequestManagerRegistry.addMethod("one.vnpool.info", vnpool_info);
|
||||
@ -439,10 +435,10 @@ void RequestManager::register_xml_methods()
|
||||
/* User related methods*/
|
||||
/*
|
||||
RequestManagerRegistry.addMethod("one.user.allocate", user_allocate);
|
||||
RequestManagerRegistry.addMethod("one.user.delete", user_delete);
|
||||
RequestManagerRegistry.addMethod("one.user.passwd", user_change_password);
|
||||
RequestManagerRegistry.addMethod("one.user.chown", user_chown);
|
||||
*/
|
||||
RequestManagerRegistry.addMethod("one.user.delete", user_delete);
|
||||
RequestManagerRegistry.addMethod("one.user.info", user_info);
|
||||
|
||||
RequestManagerRegistry.addMethod("one.userpool.info", userpool_info);
|
||||
@ -450,7 +446,6 @@ void RequestManager::register_xml_methods()
|
||||
/* Image related methods*/
|
||||
/*
|
||||
RequestManagerRegistry.addMethod("one.image.allocate", image_allocate);
|
||||
RequestManagerRegistry.addMethod("one.image.delete", image_delete);
|
||||
RequestManagerRegistry.addMethod("one.image.update", image_update);
|
||||
RequestManagerRegistry.addMethod("one.image.rmattr", image_rm_attribute);
|
||||
RequestManagerRegistry.addMethod("one.image.publish", image_publish);
|
||||
@ -459,6 +454,7 @@ void RequestManager::register_xml_methods()
|
||||
RequestManagerRegistry.addMethod("one.image.chown", image_chown);
|
||||
|
||||
*/
|
||||
RequestManagerRegistry.addMethod("one.image.delete", image_delete);
|
||||
RequestManagerRegistry.addMethod("one.image.info", image_info);
|
||||
|
||||
RequestManagerRegistry.addMethod("one.imagepool.info", imagepool_info);
|
||||
|
56
src/rm/RequestManagerDelete.cc
Normal file
56
src/rm/RequestManagerDelete.cc
Normal file
@ -0,0 +1,56 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2011, 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 "RequestManagerDelete.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
void RequestManagerDelete::request_execute(xmlrpc_c::paramList const& paramList)
|
||||
{
|
||||
int oid = xmlrpc_c::value_int(paramList.getInt(1));
|
||||
PoolObjectSQL * object;
|
||||
|
||||
if ( basic_authorization(oid) == false )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
object = pool->get(oid,true);
|
||||
|
||||
if ( object == 0 )
|
||||
{
|
||||
failure_response(NO_EXISTS, get_error("USER",oid));
|
||||
return;
|
||||
}
|
||||
|
||||
int rc = pool->drop(object);
|
||||
|
||||
object->unlock();
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
failure_response(INTERNAL,"Internal Error");
|
||||
return;
|
||||
}
|
||||
|
||||
success_response(oid);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -21,53 +21,24 @@ using namespace std;
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
void RequestManagerInfo::request_execute(
|
||||
int uid,
|
||||
int gid,
|
||||
xmlrpc_c::paramList const& paramList)
|
||||
void RequestManagerInfo::request_execute(xmlrpc_c::paramList const& paramList)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
int oid = xmlrpc_c::value_int(paramList.getInt(1));
|
||||
int ouid;
|
||||
bool pub;
|
||||
|
||||
int oid = xmlrpc_c::value_int(paramList.getInt(1));
|
||||
PoolObjectSQL * object;
|
||||
|
||||
object = pool->get(oid,true);
|
||||
|
||||
if ( object == 0 )
|
||||
{
|
||||
goto error_get;
|
||||
}
|
||||
|
||||
ouid = object->get_uid();
|
||||
pub = isPublic(object);
|
||||
|
||||
object->unlock();
|
||||
|
||||
//Authorize the operation
|
||||
if ( uid != 0 ) // uid == 0 means oneadmin
|
||||
if ( basic_authorization(oid) == false )
|
||||
{
|
||||
AuthRequest ar(uid);
|
||||
|
||||
ar.add_auth(auth_object,
|
||||
oid,
|
||||
AuthRequest::INFO,
|
||||
ouid,
|
||||
pub);
|
||||
|
||||
if (UserPool::authorize(ar) == -1)
|
||||
{
|
||||
goto error_authorize;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
object = pool->get(oid,true);
|
||||
|
||||
if ( object == 0 )
|
||||
{
|
||||
goto error_get;
|
||||
failure_response(NO_EXISTS, get_error("USER",oid));
|
||||
return;
|
||||
}
|
||||
|
||||
oss << *object;
|
||||
@ -77,14 +48,5 @@ void RequestManagerInfo::request_execute(
|
||||
success_response(oss.str());
|
||||
|
||||
return;
|
||||
|
||||
error_get: //TBD Improve Error messages for DUMP
|
||||
failure_response(INTERNAL,"Internal Error");
|
||||
return;
|
||||
|
||||
//TODO Get the object name from the AuthRequest Class
|
||||
error_authorize:
|
||||
failure_response(NO_EXISTS, get_error("USER",oid));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -21,10 +21,7 @@ using namespace std;
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
void RequestManagerPoolInfo::request_execute(
|
||||
int uid,
|
||||
int gid,
|
||||
xmlrpc_c::paramList const& paramList)
|
||||
void RequestManagerPoolInfo::request_execute(xmlrpc_c::paramList const& paramList)
|
||||
{
|
||||
ostringstream oss;
|
||||
int rc;
|
||||
|
@ -30,10 +30,7 @@ const int RequestManagerPoolInfoFilter::MINE_GROUP = -1;
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
void RequestManagerPoolInfoFilter::request_execute(
|
||||
int uid,
|
||||
int gid,
|
||||
xmlrpc_c::paramList const& paramList)
|
||||
void RequestManagerPoolInfoFilter::request_execute(xmlrpc_c::paramList const& paramList)
|
||||
{
|
||||
int filter_flag = xmlrpc_c::value_int(paramList.getInt(1));
|
||||
|
||||
|
@ -27,6 +27,8 @@ source_files=[
|
||||
'RequestManagerInfo.cc',
|
||||
'RequestManagerPoolInfo.cc',
|
||||
'RequestManagerPoolInfoFilter.cc',
|
||||
'RequestManagerDelete.cc',
|
||||
|
||||
# 'RequestManagerAction.cc',
|
||||
# 'RequestManagerAllocate.cc',
|
||||
# 'RequestManagerDeploy.cc',
|
||||
|
Loading…
x
Reference in New Issue
Block a user