From ccced18ed981ed80801c61a7e629f0e2417d956a Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Sat, 28 May 2011 11:46:42 +0200 Subject: [PATCH] feature #622: Removed uneeded files --- src/rm/RequestManagerClusterAllocate.cc | 118 ----------- src/rm/RequestManagerGroupAllocate.cc | 122 ----------- src/rm/RequestManagerHostAllocate.cc | 128 ----------- src/rm/RequestManagerImageAllocate.cc | 199 ------------------ src/rm/RequestManagerTemplateAllocate.cc | 182 ---------------- src/rm/RequestManagerUserAllocate.cc | 129 ------------ .../RequestManagerVirtualNetworkAllocate.cc | 184 ---------------- 7 files changed, 1062 deletions(-) delete mode 100644 src/rm/RequestManagerClusterAllocate.cc delete mode 100644 src/rm/RequestManagerGroupAllocate.cc delete mode 100644 src/rm/RequestManagerHostAllocate.cc delete mode 100644 src/rm/RequestManagerImageAllocate.cc delete mode 100644 src/rm/RequestManagerTemplateAllocate.cc delete mode 100644 src/rm/RequestManagerUserAllocate.cc delete mode 100644 src/rm/RequestManagerVirtualNetworkAllocate.cc diff --git a/src/rm/RequestManagerClusterAllocate.cc b/src/rm/RequestManagerClusterAllocate.cc deleted file mode 100644 index 54fff40ccc..0000000000 --- a/src/rm/RequestManagerClusterAllocate.cc +++ /dev/null @@ -1,118 +0,0 @@ -/* -------------------------------------------------------------------------- */ -/* 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 "RequestManager.h" -#include "NebulaLog.h" - -#include "AuthManager.h" - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -void RequestManager::ClusterAllocate::execute( - xmlrpc_c::paramList const& paramList, - xmlrpc_c::value * const retval) -{ - string session; - string error_str; - - string clustername; - int id; - - const string method_name = "ClusterAllocate"; - - int rc; - ostringstream oss; - - /* -- RPC specific vars -- */ - vector arrayData; - xmlrpc_c::value_array * arrayresult; - - NebulaLog::log("ReM",Log::DEBUG,"ClusterAllocate method invoked"); - - // Get the parameters - session = xmlrpc_c::value_string(paramList.getString(0)); - clustername = xmlrpc_c::value_string(paramList.getString(1)); - - //Authenticate the user - rc = ClusterAllocate::upool->authenticate(session); - - if ( rc == -1 ) - { - goto error_authenticate; - } - - //Authorize the operation - if ( rc != 0 ) // rc == 0 means oneadmin - { - AuthRequest ar(rc); - - ar.add_auth(AuthRequest::CLUSTER,-1,AuthRequest::CREATE,0,false); - - if (UserPool::authorize(ar) == -1) - { - goto error_authorize; - } - } - - // Perform the allocation in the hostpool - rc = ClusterAllocate::cpool->allocate(&id, clustername, error_str); - - if ( rc == -1 ) - { - goto error_cluster_allocate; - } - - // All nice, return the new id to client - arrayData.push_back(xmlrpc_c::value_boolean(true)); // SUCCESS - arrayData.push_back(xmlrpc_c::value_int(id)); - arrayresult = new xmlrpc_c::value_array(arrayData); - // Copy arrayresult into retval mem space - *retval = *arrayresult; - // and get rid of the original - delete arrayresult; - - return; - -error_authenticate: - oss.str(authenticate_error(method_name)); - goto error_common; - -error_authorize: - oss.str(authorization_error(method_name, "CREATE", "CLUSTER", rc, -1)); - goto error_common; - -error_cluster_allocate: - oss << action_error(method_name, "CREATE", "CLUSTER", -2, 0); - oss << " " << error_str; - goto error_common; - -error_common: - - arrayData.push_back(xmlrpc_c::value_boolean(false)); // FAILURE - arrayData.push_back(xmlrpc_c::value_string(oss.str())); - - NebulaLog::log("ReM",Log::ERROR,oss); - - xmlrpc_c::value_array arrayresult_error(arrayData); - - *retval = arrayresult_error; - - return; -} - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ diff --git a/src/rm/RequestManagerGroupAllocate.cc b/src/rm/RequestManagerGroupAllocate.cc deleted file mode 100644 index 51a6364975..0000000000 --- a/src/rm/RequestManagerGroupAllocate.cc +++ /dev/null @@ -1,122 +0,0 @@ -/* -------------------------------------------------------------------------- */ -/* 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 "RequestManager.h" -#include "NebulaLog.h" - -#include "AuthManager.h" - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -void RequestManager::GroupAllocate::execute( - xmlrpc_c::paramList const& paramList, - xmlrpc_c::value * const retval) -{ - string session; - string error_str; - - string name; - int id; - - const string method_name = "GroupAllocate"; - - int rc, uid; - ostringstream oss; - - /* -- RPC specific vars -- */ - vector arrayData; - xmlrpc_c::value_array * arrayresult; - - NebulaLog::log("ReM",Log::DEBUG,"GroupAllocate method invoked"); - - // Get the parameters - session = xmlrpc_c::value_string(paramList.getString(0)); - name = xmlrpc_c::value_string(paramList.getString(1)); - - //Authenticate the user - uid = GroupAllocate::upool->authenticate(session); - - if ( uid == -1 ) - { - goto error_authenticate; - } - - //Authorize the operation - if ( uid != 0 ) // uid == 0 means oneadmin - { - AuthRequest ar(uid); - - ar.add_auth(AuthRequest::GROUP, - -1, - AuthRequest::CREATE, - uid, - false); - - if (UserPool::authorize(ar) == -1) - { - goto error_authorize; - } - } - - // Perform the allocation in the pool - rc = GroupAllocate::gpool->allocate(uid, name, &id, error_str); - - if ( rc == -1 ) - { - goto error_allocate; - } - - // All nice, return the new id to client - arrayData.push_back(xmlrpc_c::value_boolean(true)); // SUCCESS - arrayData.push_back(xmlrpc_c::value_int(id)); - arrayresult = new xmlrpc_c::value_array(arrayData); - // Copy arrayresult into retval mem space - *retval = *arrayresult; - // and get rid of the original - delete arrayresult; - - return; - -error_authenticate: - oss.str(authenticate_error(method_name)); - goto error_common; - -error_authorize: - oss.str(authorization_error(method_name, "CREATE", "GROUP", uid, -1)); - goto error_common; - -error_allocate: - oss << action_error(method_name, "CREATE", "GROUP", -2, 0); - oss << " " << error_str; - goto error_common; - -error_common: - - arrayData.push_back(xmlrpc_c::value_boolean(false)); // FAILURE - arrayData.push_back(xmlrpc_c::value_string(oss.str())); - - NebulaLog::log("ReM",Log::ERROR,oss); - - xmlrpc_c::value_array arrayresult_error(arrayData); - - *retval = arrayresult_error; - - return; -} - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ diff --git a/src/rm/RequestManagerHostAllocate.cc b/src/rm/RequestManagerHostAllocate.cc deleted file mode 100644 index 2ed8eaf9b3..0000000000 --- a/src/rm/RequestManagerHostAllocate.cc +++ /dev/null @@ -1,128 +0,0 @@ -/* -------------------------------------------------------------------------- */ -/* 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 "RequestManager.h" -#include "NebulaLog.h" - -#include "AuthManager.h" - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -void RequestManager::HostAllocate::execute( - xmlrpc_c::paramList const& paramList, - xmlrpc_c::value * const retval) -{ - string session; - - string hostname; - string im_mad_name; - string vmm_mad_name; - string tm_mad_name; - - string error_str; - - const string method_name = "HostAllocate"; - - int hid; - - int rc; - ostringstream oss; - - /* -- RPC specific vars -- */ - vector arrayData; - xmlrpc_c::value_array * arrayresult; - - NebulaLog::log("ReM",Log::DEBUG,"HostAllocate method invoked"); - - // Get the parameters - session = xmlrpc_c::value_string(paramList.getString(0)); - hostname = xmlrpc_c::value_string(paramList.getString(1)); - im_mad_name = xmlrpc_c::value_string(paramList.getString(2)); - vmm_mad_name = xmlrpc_c::value_string(paramList.getString(3)); - tm_mad_name = xmlrpc_c::value_string(paramList.getString(4)); - - //Authenticate the user - rc = HostAllocate::upool->authenticate(session); - - if ( rc == -1 ) - { - goto error_authenticate; - } - - //Authorize the operation - if ( rc != 0 ) // rc == 0 means oneadmin - { - AuthRequest ar(rc); - - ar.add_auth(AuthRequest::HOST,-1,AuthRequest::CREATE,0,false); - - if (UserPool::authorize(ar) == -1) - { - goto error_authorize; - } - } - - // Perform the allocation in the hostpool - rc = HostAllocate::hpool->allocate(&hid, - hostname, - im_mad_name, - vmm_mad_name, - tm_mad_name, - error_str); - if ( rc == -1 ) - { - goto error_host_allocate; - } - - // All nice, return the new hid to client - arrayData.push_back(xmlrpc_c::value_boolean(true)); // SUCCESS - arrayData.push_back(xmlrpc_c::value_int(hid)); - arrayresult = new xmlrpc_c::value_array(arrayData); - // Copy arrayresult into retval mem space - *retval = *arrayresult; - // and get rid of the original - delete arrayresult; - - return; - -error_authenticate: - oss.str(authenticate_error(method_name)); - goto error_common; - -error_authorize: - oss.str(authorization_error(method_name, "CREATE", "HOST", rc, -1)); - goto error_common; - -error_host_allocate: - oss << action_error(method_name, "CREATE", "HOST", -2, 0); - oss << " " << error_str; - goto error_common; - -error_common: - arrayData.push_back(xmlrpc_c::value_boolean(false)); // FAILURE - arrayData.push_back(xmlrpc_c::value_string(oss.str())); - - NebulaLog::log("ReM",Log::ERROR,oss); - - xmlrpc_c::value_array arrayresult_error(arrayData); - - *retval = arrayresult_error; - return; -} - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ diff --git a/src/rm/RequestManagerImageAllocate.cc b/src/rm/RequestManagerImageAllocate.cc deleted file mode 100644 index adc7f2b8ed..0000000000 --- a/src/rm/RequestManagerImageAllocate.cc +++ /dev/null @@ -1,199 +0,0 @@ -/* -------------------------------------------------------------------------- */ -/* 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 "RequestManager.h" - -#include "NebulaLog.h" -#include "Nebula.h" - -#include "AuthManager.h" - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -void RequestManager::ImageAllocate::execute( - xmlrpc_c::paramList const& paramList, - xmlrpc_c::value * const retval) -{ - string session; - string str_template; - string error_str; - - ImageTemplate * img_template = 0; - User * user; - - int iid; - int uid; - int gid; - int rc; - char * error_msg = 0; - - ostringstream oss; - - const string method_name = "ImageAllocate"; - - vector arrayData; - xmlrpc_c::value_array * arrayresult; - - Nebula& nd = Nebula::instance(); - ImageManager * imagem = nd.get_imagem(); - - NebulaLog::log("ReM",Log::DEBUG,"ImageAllocate invoked"); - - session = xmlrpc_c::value_string(paramList.getString(0)); - str_template = xmlrpc_c::value_string(paramList.getString(1)); - str_template += "\n"; - - //-------------------------------------------------------------------------- - // Authenticate this request - //-------------------------------------------------------------------------- - uid = ImageAllocate::upool->authenticate(session); - - if ( uid == -1 ) - { - goto error_authenticate; - } - - //-------------------------------------------------------------------------- - // Authorize this request - //-------------------------------------------------------------------------- - img_template = new ImageTemplate; - - rc = img_template->parse(str_template,&error_msg); - - if ( rc != 0 ) - { - goto error_parse; - } - - if ( uid != 0 ) - { - AuthRequest ar(uid); - string t64; - string pub; - string pub_name = "PUBLIC"; - - img_template->get(pub_name, pub); - transform (pub.begin(), pub.end(), pub.begin(),(int(*)(int))toupper); - - ar.add_auth(AuthRequest::IMAGE, - img_template->to_xml(t64), - AuthRequest::CREATE, - uid, - (pub == "YES")); - - if (UserPool::authorize(ar) == -1) - { - goto error_authorize; - } - } - - //-------------------------------------------------------------------------- - // Get the User Group - //-------------------------------------------------------------------------- - - user = ImageAllocate::upool->get(uid,true); - - if ( user == 0 ) - { - goto error_user_get; - } - - gid = user->get_gid(); - - user->unlock(); - - //-------------------------------------------------------------------------- - // Allocate the Image - //-------------------------------------------------------------------------- - - rc = ImageAllocate::ipool->allocate(uid,gid, img_template,&iid, error_str); - - if ( rc < 0 ) - { - goto error_allocate; - } - - //-------------------------------------------------------------------------- - // Register the Image in the repository - //-------------------------------------------------------------------------- - if ( imagem->register_image(rc) == -1 ) - { - goto error_register; - } - - arrayData.push_back(xmlrpc_c::value_boolean(true)); - arrayData.push_back(xmlrpc_c::value_int(iid)); - - // Copy arrayresult into retval mem space - arrayresult = new xmlrpc_c::value_array(arrayData); - *retval = *arrayresult; - - delete arrayresult; // and get rid of the original - - return; - - -error_user_get: - oss.str(get_error(method_name, "USER", uid)); - delete img_template; - goto error_common; - -error_authenticate: - oss.str(authenticate_error(method_name)); - goto error_common; - -error_authorize: - oss.str(authorization_error(method_name, "CREATE", "IMAGE", uid, -1)); - delete img_template; - goto error_common; - -error_parse: - oss << action_error(method_name, "PARSE", "IMAGE TEMPLATE",-2,rc); - if (error_msg != 0) - { - oss << ". Reason: " << error_msg; - free(error_msg); - } - - delete img_template; - goto error_common; - -error_allocate: - oss << action_error(method_name, "CREATE", "IMAGE", -2, 0); - oss << " " << error_str; - goto error_common; - -error_register: - oss << action_error(method_name, "CREATE", "IMAGE", -2, 0); - oss << " Failed to copy image to repository. Image left in ERROR state."; - goto error_common; - -error_common: - arrayData.push_back(xmlrpc_c::value_boolean(false)); // FAILURE - arrayData.push_back(xmlrpc_c::value_string(oss.str())); - - NebulaLog::log("ReM",Log::ERROR,oss); - - xmlrpc_c::value_array arrayresult_error(arrayData); - - *retval = arrayresult_error; - - return; -} - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ diff --git a/src/rm/RequestManagerTemplateAllocate.cc b/src/rm/RequestManagerTemplateAllocate.cc deleted file mode 100644 index 8214ff0aad..0000000000 --- a/src/rm/RequestManagerTemplateAllocate.cc +++ /dev/null @@ -1,182 +0,0 @@ -/* -------------------------------------------------------------------------- */ -/* 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 "RequestManager.h" -#include "NebulaLog.h" - -#include "Nebula.h" - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -void RequestManager::TemplateAllocate::execute( - xmlrpc_c::paramList const& paramList, - xmlrpc_c::value * const retval) -{ - string session; - string str_template; - string error_str; - - const string method_name = "TemplateAllocate"; - - int oid, uid, gid; - int rc; - - ostringstream oss; - - vector arrayData; - xmlrpc_c::value_array * arrayresult; - - VirtualMachineTemplate * template_contents; - User * user; - char * error_msg = 0; - - - NebulaLog::log("ReM",Log::DEBUG,"TemplateAllocate invoked"); - - session = xmlrpc_c::value_string(paramList.getString(0)); - str_template = xmlrpc_c::value_string(paramList.getString(1)); - str_template += "\n"; - - //-------------------------------------------------------------------------- - // Authenticate the user - //-------------------------------------------------------------------------- - uid = TemplateAllocate::upool->authenticate(session); - - if (uid == -1) - { - goto error_authenticate; - } - - //-------------------------------------------------------------------------- - // Check the template syntax - //-------------------------------------------------------------------------- - template_contents = new VirtualMachineTemplate; - - rc = template_contents->parse(str_template,&error_msg); - - if ( rc != 0 ) - { - goto error_parse; - } - - //-------------------------------------------------------------------------- - // Authorize this request - //-------------------------------------------------------------------------- - if ( uid != 0 ) - { - AuthRequest ar(uid); - string t64; - - ar.add_auth(AuthRequest::TEMPLATE, - template_contents->to_xml(t64), - AuthRequest::CREATE, - uid, - false); - - if (UserPool::authorize(ar) == -1) - { - goto error_authorize; - } - } - - //-------------------------------------------------------------------------- - // Get the User Group - //-------------------------------------------------------------------------- - - user = TemplateAllocate::upool->get(uid,true); - - if ( user == 0 ) - { - goto error_user_get; - } - - gid = user->get_gid(); - - user->unlock(); - - //-------------------------------------------------------------------------- - // Allocate the VMTemplate - //-------------------------------------------------------------------------- - rc = TemplateAllocate::tpool->allocate(uid, - gid, - template_contents, - &oid, - error_str); - - if ( rc < 0 ) - { - goto error_allocate; - } - - arrayData.push_back(xmlrpc_c::value_boolean(true)); - arrayData.push_back(xmlrpc_c::value_int(oid)); - - // Copy arrayresult into retval mem space - arrayresult = new xmlrpc_c::value_array(arrayData); - *retval = *arrayresult; - - delete arrayresult; // and get rid of the original - - return; - - -error_user_get: - oss.str(get_error(method_name, "USER", uid)); - - delete template_contents; - goto error_common; - -error_authenticate: - oss.str(authenticate_error(method_name)); - goto error_common; - -error_authorize: - oss.str(authorization_error(method_name, "CREATE", "TEMPLATE", uid, -1)); - delete template_contents; - goto error_common; - -error_parse: - oss << action_error(method_name, "PARSE", "VM TEMPLATE",-2,rc); - if (error_msg != 0) - { - oss << ". Reason: " << error_msg; - free(error_msg); - } - - delete template_contents; - goto error_common; - -error_allocate: - oss << action_error(method_name, "CREATE", "TEMPLATE", -2, 0); - oss << " " << error_str; - goto error_common; - -error_common: - arrayData.push_back(xmlrpc_c::value_boolean(false)); // FAILURE - arrayData.push_back(xmlrpc_c::value_string(oss.str())); - - NebulaLog::log("ReM",Log::ERROR,oss); - - xmlrpc_c::value_array arrayresult_error(arrayData); - - *retval = arrayresult_error; - - return; -} - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ diff --git a/src/rm/RequestManagerUserAllocate.cc b/src/rm/RequestManagerUserAllocate.cc deleted file mode 100644 index 8e02a6d83b..0000000000 --- a/src/rm/RequestManagerUserAllocate.cc +++ /dev/null @@ -1,129 +0,0 @@ -/* -------------------------------------------------------------------------- */ -/* 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 "RequestManager.h" -#include "NebulaLog.h" - -#include "AuthManager.h" - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -void RequestManager::UserAllocate::execute( - xmlrpc_c::paramList const& paramList, - xmlrpc_c::value * const retval) -{ - string session; - - string username; - string password; - string error_str; - - int uid; - - int rc; - ostringstream oss; - - const string method_name = "UserAllocate"; - - /* -- RPC specific vars -- */ - vector arrayData; - xmlrpc_c::value_array * arrayresult; - - NebulaLog::log("ReM",Log::DEBUG,"UserAllocate method invoked"); - - // Get the parameters - session = xmlrpc_c::value_string(paramList.getString(0)); - - username = xmlrpc_c::value_string(paramList.getString(1)); - password = xmlrpc_c::value_string(paramList.getString(2)); - - rc = UserAllocate::upool->authenticate(session); - - if ( rc == -1 ) - { - goto error_authenticate; - } - - //Authorize the operation - if ( rc != 0 ) // rc == 0 means oneadmin - { - AuthRequest ar(rc); - - ar.add_auth(AuthRequest::USER, - -1, - AuthRequest::CREATE, - 0, - false); - - if (UserPool::authorize(ar) == -1) - { - goto error_authorize; - } - } - - // Now let's add the user - rc = UserAllocate::upool->allocate(&uid, - GroupPool::USERS_ID, - username, - password, - true, - error_str); - if ( rc == -1 ) - { - goto error_allocate; - } - - // All nice, return the new uid to client - arrayData.push_back(xmlrpc_c::value_boolean(true)); // SUCCESS - arrayData.push_back(xmlrpc_c::value_int(uid)); - - // Copy arrayresult into retval mem space - arrayresult = new xmlrpc_c::value_array(arrayData); - *retval = *arrayresult; - - delete arrayresult; // and get rid of the original - - return; - -error_authenticate: - oss.str(authenticate_error(method_name)); - goto error_common; - -error_authorize: - oss.str(authorization_error(method_name, "CREATE", "USER", rc, -1)); - goto error_common; - -error_allocate: - oss << action_error(method_name, "CREATE", "USER", -2, 0); - oss << " " << error_str; - goto error_common; - -error_common: - arrayData.push_back(xmlrpc_c::value_boolean(false)); // FAILURE - arrayData.push_back(xmlrpc_c::value_string(oss.str())); - - NebulaLog::log("ReM",Log::ERROR,oss); - - xmlrpc_c::value_array arrayresult_error(arrayData); - - *retval = arrayresult_error; - - return; -} - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ diff --git a/src/rm/RequestManagerVirtualNetworkAllocate.cc b/src/rm/RequestManagerVirtualNetworkAllocate.cc deleted file mode 100644 index 7daed944ea..0000000000 --- a/src/rm/RequestManagerVirtualNetworkAllocate.cc +++ /dev/null @@ -1,184 +0,0 @@ -/* -------------------------------------------------------------------------- */ -/* 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 "RequestManager.h" -#include "NebulaLog.h" -#include "VirtualNetworkTemplate.h" - -#include "AuthManager.h" - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -void RequestManager::VirtualNetworkAllocate::execute( - xmlrpc_c::paramList const& paramList, - xmlrpc_c::value * const retval) -{ - string session; - string name; - string str_template; - string error_str; - - VirtualNetworkTemplate * vn_template; - User * user; - - int nid; - int uid; - int rc; - int gid; - char * error_msg = 0; - - ostringstream oss; - - const string method_name = "VirtualNetworkAllocate"; - - /* -- RPC specific vars -- */ - vector arrayData; - xmlrpc_c::value_array * arrayresult; - - NebulaLog::log("ReM",Log::DEBUG,"VirtualNetworkAllocate method invoked"); - - // Get the parameters & host - session = xmlrpc_c::value_string(paramList.getString(0)); - str_template = xmlrpc_c::value_string(paramList.getString(1)); - - //-------------------------------------------------------------------------- - // Authorize this request - //-------------------------------------------------------------------------- - uid = VirtualNetworkAllocate::upool->authenticate(session); - - if ( uid == -1 ) - { - goto error_authenticate; - } - - //-------------------------------------------------------------------------- - // Authorize this request - //-------------------------------------------------------------------------- - vn_template = new VirtualNetworkTemplate; - - rc = vn_template->parse(str_template,&error_msg); - - if ( rc != 0 ) - { - goto error_parse; - } - - if ( uid != 0 ) - { - AuthRequest ar(uid); - string t64; - string pub; - string pub_name = "PUBLIC"; - - vn_template->get(pub_name, pub); - transform (pub.begin(), pub.end(), pub.begin(),(int(*)(int))toupper); - - ar.add_auth(AuthRequest::NET, - vn_template->to_xml(t64), - AuthRequest::CREATE, - uid, - (pub == "YES")); - - if (UserPool::authorize(ar) == -1) - { - goto error_authorize; - } - } - - //-------------------------------------------------------------------------- - // Get the User Group - //-------------------------------------------------------------------------- - - user = VirtualNetworkAllocate::upool->get(uid,true); - - if ( user == 0 ) - { - goto error_user_get; - } - - gid = user->get_gid(); - - user->unlock(); - - //-------------------------------------------------------------------------- - // Allocate the Virtual Network - //-------------------------------------------------------------------------- - rc = vnpool->allocate(uid,gid,vn_template,&nid,error_str); - - if ( rc < 0 ) - { - goto error_vn_allocate; - } - - //Result - arrayData.push_back(xmlrpc_c::value_boolean(true)); // SUCCESS - arrayData.push_back(xmlrpc_c::value_int(nid)); - arrayresult = new xmlrpc_c::value_array(arrayData); - - *retval = *arrayresult; - - delete arrayresult; - - return; - - -error_user_get: - oss.str(get_error(method_name, "USER", uid)); - - delete vn_template; - goto error_common; - -error_authenticate: - oss.str(authenticate_error(method_name)); - goto error_common; - -error_authorize: - oss.str(authorization_error(method_name, "CREATE", "VNET", uid, -1)); - delete vn_template; - goto error_common; - -error_parse: - oss << action_error(method_name, "PARSE", "VNET TEMPLATE",-2,rc); - if (error_msg != 0) - { - oss << ". Reason: " << error_msg; - free(error_msg); - } - - delete vn_template; - goto error_common; - -error_vn_allocate: - oss << action_error(method_name, "CREATE", "NET", -2, 0); - oss << " " << error_str; - goto error_common; - -error_common: - NebulaLog::log("ReM",Log::ERROR,oss); - - arrayData.push_back(xmlrpc_c::value_boolean(false)); - arrayData.push_back(xmlrpc_c::value_string(oss.str())); - - xmlrpc_c::value_array arrayresult_error(arrayData); - - *retval = arrayresult_error; - - return; -} - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */