From c5b19f45df8ea9e8ef5d7757341b8c5eeadab9e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Mon, 30 Nov 2015 16:50:23 +0100 Subject: [PATCH 001/197] Feature #4215: Create new Virtual Router pool --- SConstruct | 2 + include/Nebula.h | 11 +- include/PoolObjectSQL.h | 4 +- include/RequestManagerAllocate.h | 35 ++++ include/RequestManagerChmod.h | 18 ++ include/RequestManagerChown.h | 24 +++ include/RequestManagerDelete.h | 18 ++ include/RequestManagerInfo.h | 18 ++ include/RequestManagerPoolInfoFilter.h | 19 ++ include/RequestManagerRename.h | 22 +++ include/RequestManagerUpdateTemplate.h | 18 ++ include/VirtualRouter.h | 146 +++++++++++++++ include/VirtualRouterPool.h | 138 ++++++++++++++ src/nebula/Nebula.cc | 2 + src/nebula/SConstruct | 1 + src/rm/Request.cc | 2 + src/rm/RequestManager.cc | 20 ++ src/rm/RequestManagerAllocate.cc | 16 ++ src/vrouter/SConstruct | 29 +++ src/vrouter/VirtualRouter.cc | 250 +++++++++++++++++++++++++ 20 files changed, 791 insertions(+), 2 deletions(-) create mode 100644 include/VirtualRouter.h create mode 100644 include/VirtualRouterPool.h create mode 100644 src/vrouter/SConstruct create mode 100644 src/vrouter/VirtualRouter.cc diff --git a/SConstruct b/SConstruct index a575fa3036..d210fc29a2 100644 --- a/SConstruct +++ b/SConstruct @@ -84,6 +84,7 @@ main_env.Append(LIBPATH=[ cwd+'/src/client', cwd+'/src/secgroup', cwd+'/src/vdc', + cwd+'/src/vrouter', ]) # Compile flags @@ -244,6 +245,7 @@ build_scripts=[ 'src/zone/SConstruct', 'src/secgroup/SConstruct', 'src/vdc/SConstruct', + 'src/vrouter/SConstruct', 'share/man/SConstruct', 'src/sunstone/public/locale/languages/SConstruct', 'src/sunstone/public/SConstruct', diff --git a/include/Nebula.h b/include/Nebula.h index cf3fd14741..c3a1f2cae5 100644 --- a/include/Nebula.h +++ b/include/Nebula.h @@ -34,6 +34,7 @@ #include "ZonePool.h" #include "SecurityGroupPool.h" #include "VdcPool.h" +#include "VirtualRouterPool.h" #include "VirtualMachineManager.h" #include "LifeCycleManager.h" @@ -136,6 +137,11 @@ public: return vdcpool; }; + VirtualRouterPool * get_vrouterpool() + { + return vrouterpool; + }; + // -------------------------------------------------------------- // Manager Accessors // -------------------------------------------------------------- @@ -657,7 +663,8 @@ private: "/DEFAULT_GROUP_QUOTAS/VM_QUOTA"), system_db(0), db(0), vmpool(0), hpool(0), vnpool(0), upool(0), ipool(0), gpool(0), tpool(0), - dspool(0), clpool(0), docpool(0), zonepool(0), secgrouppool(0), vdcpool(0), + dspool(0), clpool(0), docpool(0), zonepool(0), + secgrouppool(0), vdcpool(0), vrouterpool(0), lcm(0), vmm(0), im(0), tm(0), dm(0), rm(0), hm(0), authm(0), aclm(0), imagem(0) { @@ -707,6 +714,7 @@ private: delete zonepool; delete secgrouppool; delete vdcpool; + delete vrouterpool; delete vmm; delete lcm; delete im; @@ -786,6 +794,7 @@ private: ZonePool * zonepool; SecurityGroupPool * secgrouppool; VdcPool * vdcpool; + VirtualRouterPool * vrouterpool; // --------------------------------------------------------------- // Nebula Managers diff --git a/include/PoolObjectSQL.h b/include/PoolObjectSQL.h index dd24f93a9f..0aff690c42 100644 --- a/include/PoolObjectSQL.h +++ b/include/PoolObjectSQL.h @@ -62,7 +62,8 @@ public: DOCUMENT = 0x0000400000000000LL, ZONE = 0x0000800000000000LL, SECGROUP = 0x0001000000000000LL, - VDC = 0x0002000000000000LL + VDC = 0x0002000000000000LL, + VROUTER = 0x0004000000000000LL }; static string type_to_str(ObjectType ob) @@ -83,6 +84,7 @@ public: case ZONE: return "ZONE" ; break; case SECGROUP: return "SECGROUP" ; break; case VDC: return "VDC" ; break; + case VROUTER: return "VROUTER" ; break; default: return ""; } }; diff --git a/include/RequestManagerAllocate.h b/include/RequestManagerAllocate.h index 0076f2d7bc..97013c78ae 100644 --- a/include/RequestManagerAllocate.h +++ b/include/RequestManagerAllocate.h @@ -583,6 +583,41 @@ public: string& error_str, RequestAttributes& att); }; + + +/* ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ + +class VirtualRouterAllocate : public RequestManagerAllocate +{ +public: + VirtualRouterAllocate(): + RequestManagerAllocate("VirtualRouterAllocate", + "Allocates a new virtual router", + "A:ss", + true) + { + Nebula& nd = Nebula::instance(); + pool = nd.get_vrouterpool(); + auth_object = PoolObjectSQL::VROUTER; + }; + + ~VirtualRouterAllocate(){}; + + /* --------------------------------------------------------------------- */ + + Template * get_object_template() + { + return new Template; + }; + + int pool_allocate(xmlrpc_c::paramList const& _paramList, + Template * tmpl, + int& id, + string& error_str, + RequestAttributes& att); +}; + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ diff --git a/include/RequestManagerChmod.h b/include/RequestManagerChmod.h index 18520f3181..c3bdab76ad 100644 --- a/include/RequestManagerChmod.h +++ b/include/RequestManagerChmod.h @@ -171,6 +171,24 @@ public: }; +/* ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ + +class VirtualRouterChmod: public RequestManagerChmod +{ +public: + VirtualRouterChmod(): + RequestManagerChmod("VirtualRouterChmod", + "Changes permission bits of a virtual router") + { + Nebula& nd = Nebula::instance(); + pool = nd.get_vrouterpool(); + auth_object = PoolObjectSQL::VROUTER; + }; + + ~VirtualRouterChmod(){}; +}; + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ diff --git a/include/RequestManagerChown.h b/include/RequestManagerChown.h index df88d6e4a7..e61bd8e208 100644 --- a/include/RequestManagerChown.h +++ b/include/RequestManagerChown.h @@ -268,6 +268,30 @@ public: return static_cast(pool)->get(name, uid, lock); }; }; + +/* ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ + +class VirtualRouterChown: public RequestManagerChown +{ +public: + VirtualRouterChown(): + RequestManagerChown("VirtualRouterChown", + "Changes ownership of a virtual router") + { + Nebula& nd = Nebula::instance(); + pool = nd.get_vrouterpool(); + auth_object = PoolObjectSQL::VROUTER; + }; + + ~VirtualRouterChown(){}; + + PoolObjectSQL * get(const string& name, int uid, bool lock) + { + return static_cast(pool)->get(name, uid, lock); + }; +}; + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ diff --git a/include/RequestManagerDelete.h b/include/RequestManagerDelete.h index 25f23adeb7..652cb853b9 100644 --- a/include/RequestManagerDelete.h +++ b/include/RequestManagerDelete.h @@ -354,6 +354,24 @@ public: ~VdcDelete(){}; }; +/* ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ + +class VirtualRouterDelete : public RequestManagerDelete +{ +public: + VirtualRouterDelete(): + RequestManagerDelete("VirtualRouterDelete", + "Deletes a virtual router") + { + Nebula& nd = Nebula::instance(); + pool = nd.get_vrouterpool(); + auth_object = PoolObjectSQL::VROUTER; + }; + + ~VirtualRouterDelete(){}; +}; + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ diff --git a/include/RequestManagerInfo.h b/include/RequestManagerInfo.h index c978be23d9..dc2021f688 100644 --- a/include/RequestManagerInfo.h +++ b/include/RequestManagerInfo.h @@ -318,6 +318,24 @@ public: ~VdcInfo(){}; }; +/* ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ + +class VirtualRouterInfo : public RequestManagerInfo +{ +public: + VirtualRouterInfo(): + RequestManagerInfo("VirtualRouterInfo", + "Returns virtual router information") + { + Nebula& nd = Nebula::instance(); + pool = nd.get_vrouterpool(); + auth_object = PoolObjectSQL::VROUTER; + }; + + ~VirtualRouterInfo(){}; +}; + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ diff --git a/include/RequestManagerPoolInfoFilter.h b/include/RequestManagerPoolInfoFilter.h index 1708e39346..656df43cd4 100644 --- a/include/RequestManagerPoolInfoFilter.h +++ b/include/RequestManagerPoolInfoFilter.h @@ -494,6 +494,25 @@ public: xmlrpc_c::paramList const& paramList, RequestAttributes& att); }; +/* ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ + +class VirtualRouterPoolInfo : public RequestManagerPoolInfoFilter +{ +public: + VirtualRouterPoolInfo(): + RequestManagerPoolInfoFilter("VirtualRouterPoolInfo", + "Returns the virtual router pool", + "A:siii") + { + Nebula& nd = Nebula::instance(); + pool = nd.get_vrouterpool(); + auth_object = PoolObjectSQL::VROUTER; + }; + + ~VirtualRouterPoolInfo(){}; +}; + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ diff --git a/include/RequestManagerRename.h b/include/RequestManagerRename.h index 539c2f7c5b..1c3dac65d9 100644 --- a/include/RequestManagerRename.h +++ b/include/RequestManagerRename.h @@ -334,6 +334,28 @@ public: ~VdcRename(){}; }; +/* ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ + +class VirtualRouterRename: public RequestManagerRename +{ +public: + VirtualRouterRename(): + RequestManagerRename("VirtualRouterRename", "Renames a virtual router") + { + Nebula& nd = Nebula::instance(); + pool = nd.get_vrouterpool(); + auth_object = PoolObjectSQL::VROUTER; + }; + + ~VirtualRouterRename(){}; + + PoolObjectSQL * get(const string& name, int uid, bool lock) + { + return static_cast(pool)->get(name, uid, lock); + }; +}; + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ diff --git a/include/RequestManagerUpdateTemplate.h b/include/RequestManagerUpdateTemplate.h index abffc3aa48..965be43745 100644 --- a/include/RequestManagerUpdateTemplate.h +++ b/include/RequestManagerUpdateTemplate.h @@ -286,6 +286,24 @@ public: ~VdcUpdateTemplate(){}; }; +/* ------------------------------------------------------------------------- */ +/* ------------------------------------------------------------------------- */ + +class VirtualRouterUpdateTemplate : public RequestManagerUpdateTemplate +{ +public: + VirtualRouterUpdateTemplate(): + RequestManagerUpdateTemplate("VirtualRouterUpdateTemplate", + "Updates a virtual router template") + { + Nebula& nd = Nebula::instance(); + pool = nd.get_vrouterpool(); + auth_object = PoolObjectSQL::VROUTER; + }; + + ~VirtualRouterUpdateTemplate(){}; +}; + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ diff --git a/include/VirtualRouter.h b/include/VirtualRouter.h new file mode 100644 index 0000000000..40a512a459 --- /dev/null +++ b/include/VirtualRouter.h @@ -0,0 +1,146 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2015, OpenNebula Project, OpenNebula Systems */ +/* */ +/* 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 VIRTUAL_ROUTER_H_ +#define VIRTUAL_ROUTER_H_ + +#include "PoolObjectSQL.h" +#include "Template.h" + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +/** + * The VirtualRouter class. + */ +class VirtualRouter : public PoolObjectSQL +{ +public: + + /** + * Function to print the VirtualRouter object into a string in XML format + * @param xml the resulting XML string + * @return a reference to the generated string + */ + string& to_xml(string& xml) const; + + // ------------------------------------------------------------------------ + // Template Contents + // ------------------------------------------------------------------------ + + /** + * Factory method for VirtualRouter templates + */ + Template * get_new_template() const + { + return new Template; + } + + /** + * Returns a copy of the Template + * @return A copy of the VirtualMachineTemplate + */ + Template * clone_template() const + { + return new Template( + *(static_cast