mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-26 06:50:09 +03:00
Merge branch 'feature-4809'
This commit is contained in:
commit
db9f9dedca
@ -55,6 +55,7 @@ main_env.Append(CPPPATH=[
|
||||
main_env.Append(LIBPATH=[
|
||||
cwd+'/src/common',
|
||||
cwd+'/src/log',
|
||||
cwd+'/src/raft',
|
||||
cwd+'/src/sql',
|
||||
cwd+'/src/host',
|
||||
cwd+'/src/cluster',
|
||||
@ -211,6 +212,7 @@ main_env.ParseConfig('xml2-config --libs --cflags')
|
||||
build_scripts=[
|
||||
'src/sql/SConstruct',
|
||||
'src/log/SConstruct',
|
||||
'src/raft/SConstruct',
|
||||
'src/common/SConstruct',
|
||||
'src/template/SConstruct',
|
||||
'src/host/SConstruct',
|
||||
|
@ -37,7 +37,6 @@ extern "C" void * acl_action_loop(void *arg);
|
||||
class AclManager : public Callbackable, public ActionListener
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @param _db pointer to the DB
|
||||
* @param zone_id of the Zone
|
||||
@ -58,6 +57,15 @@ public:
|
||||
|
||||
void finalize();
|
||||
|
||||
/**
|
||||
* Reload the ACL rules from the DB. This function needs to be used when
|
||||
* a server becomes leader of the zone as the ACL cache maybe out-dated
|
||||
*/
|
||||
void reload_rules()
|
||||
{
|
||||
select();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Rule management */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -186,7 +194,6 @@ public:
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* DB management */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Bootstraps the database table(s) associated to the ACL Manager
|
||||
* @return 0 on success
|
||||
@ -200,10 +207,9 @@ public:
|
||||
*/
|
||||
virtual int dump(ostringstream& oss);
|
||||
|
||||
// ----------------------------------------
|
||||
// -------------------------------------------------------------------------
|
||||
// Refresh loop thread
|
||||
// ----------------------------------------
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
/**
|
||||
* Gets the AclManager thread identification. The thread is only
|
||||
* initialized if the refresh_cache flag is true.
|
||||
@ -215,22 +221,20 @@ public:
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* Constructor for derived ACL managers. Classes derived from this one
|
||||
* will operate in a stand-alone fashion (i.e. no refresh of ACL rules
|
||||
* from DB)
|
||||
*/
|
||||
AclManager(int _zone_id)
|
||||
:zone_id(_zone_id), db(0),lastOID(0), is_federation_slave(false)
|
||||
:zone_id(_zone_id), db(0), is_federation_slave(false)
|
||||
{
|
||||
pthread_mutex_init(&mutex, 0);
|
||||
};
|
||||
|
||||
// ----------------------------------------
|
||||
// -------------------------------------------------------------------------
|
||||
// ACL rules management
|
||||
// ----------------------------------------
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
/**
|
||||
* ACL rules. Each rule is indexed by its 'user' long long attibute,
|
||||
* several rules can apply to the same user
|
||||
@ -324,15 +328,15 @@ private:
|
||||
*/
|
||||
void del_zone_matching_rules(long long zone_req);
|
||||
|
||||
// ----------------------------------------
|
||||
// -------------------------------------------------------------------------
|
||||
// Local zone
|
||||
// ----------------------------------------
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
int zone_id;
|
||||
|
||||
// ----------------------------------------
|
||||
// -------------------------------------------------------------------------
|
||||
// Mutex synchronization
|
||||
// ----------------------------------------
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
pthread_mutex_t mutex;
|
||||
|
||||
@ -352,20 +356,14 @@ private:
|
||||
pthread_mutex_unlock(&mutex);
|
||||
};
|
||||
|
||||
// ----------------------------------------
|
||||
// -------------------------------------------------------------------------
|
||||
// DataBase implementation variables
|
||||
// ----------------------------------------
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
/**
|
||||
* Pointer to the database.
|
||||
*/
|
||||
SqlDB * db;
|
||||
|
||||
/**
|
||||
* Last object ID assigned to a rule.
|
||||
*/
|
||||
int lastOID;
|
||||
|
||||
/**
|
||||
* Tablename for the ACL rules
|
||||
*/
|
||||
@ -375,11 +373,6 @@ private:
|
||||
|
||||
static const char * db_bootstrap;
|
||||
|
||||
/**
|
||||
* Inserts the last oid into the pool_control table
|
||||
*/
|
||||
void update_lastOID();
|
||||
|
||||
/**
|
||||
* Callback function to unmarshall the ACL rules
|
||||
* @param num the number of columns read from the DB
|
||||
@ -423,15 +416,9 @@ private:
|
||||
*/
|
||||
int drop(int oid);
|
||||
|
||||
/**
|
||||
* Callback to set the lastOID
|
||||
*/
|
||||
int init_cb(void *nil, int num, char **values, char **names);
|
||||
|
||||
// ----------------------------------------
|
||||
// -------------------------------------------------------------------------
|
||||
// Refresh loop thread
|
||||
// ----------------------------------------
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
/**
|
||||
* Flag to refresh the cache periodically
|
||||
*/
|
||||
|
@ -151,7 +151,17 @@ public:
|
||||
* @param timeout for the periodic action.
|
||||
* @param timer_args arguments for the timer action
|
||||
*/
|
||||
void loop(time_t timeout, const ActionRequest& trequest);
|
||||
void loop(struct timespec& _timeout, const ActionRequest& trequest);
|
||||
|
||||
void loop(time_t timeout, const ActionRequest& trequest)
|
||||
{
|
||||
struct timespec _timeout;
|
||||
|
||||
_timeout.tv_sec = timeout;
|
||||
_timeout.tv_nsec = 0;
|
||||
|
||||
loop(_timeout, trequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* The calling thread will be suspended until an action is triggered.
|
||||
@ -162,7 +172,19 @@ public:
|
||||
{
|
||||
ActionRequest trequest(ActionRequest::TIMER);
|
||||
|
||||
loop(timeout, trequest);
|
||||
struct timespec _timeout;
|
||||
|
||||
_timeout.tv_sec = timeout;
|
||||
_timeout.tv_nsec = 0;
|
||||
|
||||
loop(_timeout, trequest);
|
||||
}
|
||||
|
||||
void loop(struct timespec& _timeout)
|
||||
{
|
||||
ActionRequest trequest(ActionRequest::TIMER);
|
||||
|
||||
loop(_timeout, trequest);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -172,8 +194,12 @@ public:
|
||||
void loop()
|
||||
{
|
||||
ActionRequest trequest(ActionRequest::TIMER);
|
||||
struct timespec _timeout;
|
||||
|
||||
loop(0, trequest);
|
||||
_timeout.tv_sec = 0;
|
||||
_timeout.tv_nsec = 0;
|
||||
|
||||
loop(_timeout, trequest);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -122,7 +122,7 @@ public:
|
||||
std::ostringstream oss;
|
||||
oss << "DELETE FROM " << db_table << " WHERE id = " << id ;
|
||||
|
||||
return db->exec(oss);
|
||||
return db->exec_wr(oss);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -263,7 +263,7 @@ private:
|
||||
|
||||
oss << "SELECT map FROM " << db_table << " WHERE id = " << id ;
|
||||
|
||||
rc = db->exec(oss, this);
|
||||
rc = db->exec_rd(oss, this);
|
||||
|
||||
unset_callback();
|
||||
|
||||
@ -318,7 +318,7 @@ private:
|
||||
oss << "INTO " << db_table << " (id, map) VALUES ("
|
||||
<< id << ",'" << ezipped64 << "')";
|
||||
|
||||
int rc = db->exec(oss);
|
||||
int rc = db->exec_wr(oss);
|
||||
|
||||
delete zipped;
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
#define CALLBACKABLE_H_
|
||||
|
||||
#include <pthread.h>
|
||||
#include <sstream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -105,4 +106,67 @@ private:
|
||||
pthread_mutex_t mutex;
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Classes to obtain values from a DB it support concurrent queries using */
|
||||
/* different objects */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
template <class T>
|
||||
class single_cb : public Callbackable
|
||||
{
|
||||
public:
|
||||
void set_callback(T * _value)
|
||||
{
|
||||
value = _value;
|
||||
|
||||
Callbackable::set_callback(
|
||||
static_cast<Callbackable::Callback>(&single_cb::callback));
|
||||
}
|
||||
|
||||
virtual int callback(void *nil, int num, char **values, char **names)
|
||||
{
|
||||
if ( values == 0 || values[0] == 0 || num != 1 )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::istringstream iss(values[0]);
|
||||
|
||||
iss >> *value;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
T * value;
|
||||
};
|
||||
|
||||
template<>
|
||||
class single_cb<std::string> : public Callbackable
|
||||
{
|
||||
public:
|
||||
void set_callback(std::string * _value)
|
||||
{
|
||||
value = _value;
|
||||
|
||||
Callbackable::set_callback(
|
||||
static_cast<Callbackable::Callback>(&single_cb::callback));
|
||||
}
|
||||
|
||||
virtual int callback(void *nil, int num, char **values, char **names)
|
||||
{
|
||||
if ( values == 0 || values[0] == 0 || num != 1 )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
*value = values[0];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string * value;
|
||||
};
|
||||
|
||||
#endif /*CALLBACKABLE_H_*/
|
||||
|
@ -75,6 +75,29 @@ public:
|
||||
*/
|
||||
static int read_oneauth(std::string &secret, std::string& error);
|
||||
|
||||
/**
|
||||
* Performs a xmlrpc call to the initialized server
|
||||
* @param method name
|
||||
* @param plist initialized param list
|
||||
* @param result of the xmlrpc call
|
||||
*/
|
||||
void call(const std::string& method, const xmlrpc_c::paramList& plist,
|
||||
xmlrpc_c::value * const result);
|
||||
|
||||
/**
|
||||
* Performs a xmlrpc call
|
||||
* @param endpoint of server
|
||||
* @param method name
|
||||
* @param plist initialized param list
|
||||
* @param timeout (ms) for the request, set 0 for global xml_rpc timeout
|
||||
* @param result of the xmlrpc call
|
||||
* @param error string if any
|
||||
* @return 0
|
||||
*/
|
||||
static int call(const std::string& endpoint, const std::string& method,
|
||||
const xmlrpc_c::paramList& plist, long long _timeout,
|
||||
xmlrpc_c::value * const result, std::string& error);
|
||||
|
||||
/**
|
||||
* Performs an xmlrpc call to the initialized server and credentials.
|
||||
* This method automatically adds the credential argument.
|
||||
@ -87,14 +110,6 @@ public:
|
||||
void call(const std::string &method, const std::string format,
|
||||
xmlrpc_c::value * const result, ...);
|
||||
|
||||
/**
|
||||
* Performs a xmlrpc call to the initialized server
|
||||
* @param method name
|
||||
* @param plist initialized param list
|
||||
* @param result of the xmlrpc call
|
||||
*/
|
||||
void call(const std::string& method, const xmlrpc_c::paramList& plist,
|
||||
xmlrpc_c::value * const result);
|
||||
private:
|
||||
/**
|
||||
* Creates a new xml-rpc client with specified options.
|
||||
|
@ -283,13 +283,13 @@ private:
|
||||
ostringstream oss;
|
||||
|
||||
oss.str(Cluster::db_bootstrap);
|
||||
rc = db->exec(oss);
|
||||
rc = db->exec_local_wr(oss);
|
||||
|
||||
oss.str(Cluster::datastore_db_bootstrap);
|
||||
rc += db->exec(oss);
|
||||
rc += db->exec_local_wr(oss);
|
||||
|
||||
oss.str(Cluster::network_db_bootstrap);
|
||||
rc += db->exec(oss);
|
||||
rc += db->exec_local_wr(oss);
|
||||
|
||||
return rc;
|
||||
};
|
||||
|
@ -201,7 +201,8 @@ public:
|
||||
int rc;
|
||||
|
||||
rc = Cluster::bootstrap(_db);
|
||||
rc += _db->exec(BitMap<0>::bootstrap(Cluster::bitmap_table, oss_bitmap));
|
||||
rc += _db->exec_local_wr(
|
||||
BitMap<0>::bootstrap(Cluster::bitmap_table, oss_bitmap));
|
||||
|
||||
return rc;
|
||||
};
|
||||
|
@ -364,7 +364,7 @@ private:
|
||||
{
|
||||
ostringstream oss(Datastore::db_bootstrap);
|
||||
|
||||
return db->exec(oss);
|
||||
return db->exec_local_wr(oss);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -107,7 +107,7 @@ private:
|
||||
{
|
||||
ostringstream oss(Document::db_bootstrap);
|
||||
|
||||
return db->exec(oss);
|
||||
return db->exec_local_wr(oss);
|
||||
};
|
||||
|
||||
/**
|
||||
|
274
include/ExtendedAttribute.h
Normal file
274
include/ExtendedAttribute.h
Normal file
@ -0,0 +1,274 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2016, 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 EXTENDED_ATTRIBUTE_H_
|
||||
#define EXTENDED_ATTRIBUTE_H_
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include "Attribute.h"
|
||||
#include "Template.h"
|
||||
|
||||
/**
|
||||
* This class represents a generic attribute, it exposes the basic
|
||||
* VectorAttribute interface and can be decorated with functionality
|
||||
* for an specific class.
|
||||
*
|
||||
* The attribute operates directly on the OriginalTemplate attribute. IT
|
||||
* IS NOT CLONED OR COPIED
|
||||
*/
|
||||
class ExtendedAttribute: public Attribute
|
||||
{
|
||||
public:
|
||||
VectorAttribute * vector_attribute()
|
||||
{
|
||||
return va;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* VectorAttribute Interface */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
template<typename T>
|
||||
int vector_value(const std::string& name, T& value) const
|
||||
{
|
||||
return va->vector_value(name, value);
|
||||
}
|
||||
|
||||
string vector_value(const std::string& name) const
|
||||
{
|
||||
return va->vector_value(name);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void replace(const std::string& name, T value)
|
||||
{
|
||||
va->replace(name, value);
|
||||
}
|
||||
|
||||
void remove(const std::string& name)
|
||||
{
|
||||
va->remove(name);
|
||||
}
|
||||
|
||||
|
||||
void merge(VectorAttribute* vattr, bool replace)
|
||||
{
|
||||
va->merge(vattr, replace);
|
||||
}
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Creates the attribute with a reference to a VectorAttribute. The object
|
||||
* is shared and WILL BE modified through this interface.
|
||||
* @param va pointer to the VectorAttribute.
|
||||
*/
|
||||
ExtendedAttribute(VectorAttribute *_va):
|
||||
Attribute(_va->name()) ,va(_va), id(-1) {};
|
||||
|
||||
ExtendedAttribute(VectorAttribute *_va, int _id):
|
||||
Attribute(_va->name()) ,va(_va), id(_id) {};
|
||||
|
||||
virtual ~ExtendedAttribute(){};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Attribute Interface */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
string * marshall(const char * _sep = 0) const
|
||||
{
|
||||
return va->marshall(_sep);
|
||||
};
|
||||
|
||||
string * to_xml() const
|
||||
{
|
||||
return va->to_xml();
|
||||
};
|
||||
|
||||
void unmarshall(const std::string& sattr, const char * _sep = 0)
|
||||
{
|
||||
va->unmarshall(sattr, _sep);
|
||||
}
|
||||
|
||||
AttributeType type()
|
||||
{
|
||||
return va->type();
|
||||
};
|
||||
|
||||
Attribute* clone() const
|
||||
{
|
||||
return va->clone();
|
||||
};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* ExtendedAttribute Interface */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
int get_id() const
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
friend class ExtendedAttributeSet;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/**
|
||||
* The associated VectorAttribute
|
||||
*/
|
||||
VectorAttribute * va;
|
||||
|
||||
/**
|
||||
* Set if the attribute can be addressed by an identifier, -1 otherwise
|
||||
*/
|
||||
int id;
|
||||
};
|
||||
|
||||
/**
|
||||
* This class represents a set of ExtendedAttributes it provides fast
|
||||
* access to individual elements (by ID) and implement collective operations
|
||||
*/
|
||||
class ExtendedAttributeSet
|
||||
{
|
||||
protected:
|
||||
/**
|
||||
* Creates the ExtenededAttribute set
|
||||
* @param dispose elements upon set destruction
|
||||
*/
|
||||
ExtendedAttributeSet(bool _dispose):dispose(_dispose){};
|
||||
|
||||
virtual ~ExtendedAttributeSet();
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Method to access attributes */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/**
|
||||
* @return attribute by id or 0 if not found
|
||||
*/
|
||||
ExtendedAttribute * get_attribute(int id) const;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Iterators */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/**
|
||||
* Generic iterator for the set. Wraps the STL iterator for map, can be
|
||||
* used to iterate over the attributes
|
||||
*/
|
||||
class AttributeIterator
|
||||
{
|
||||
public:
|
||||
AttributeIterator& operator=(const AttributeIterator& rhs)
|
||||
{
|
||||
map_it = rhs.map_it;
|
||||
return *this;
|
||||
}
|
||||
|
||||
AttributeIterator& operator++()
|
||||
{
|
||||
++map_it;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator!=(const AttributeIterator& rhs)
|
||||
{
|
||||
return map_it != rhs.map_it;
|
||||
}
|
||||
|
||||
AttributeIterator(){};
|
||||
AttributeIterator(const AttributeIterator& ait):map_it(ait.map_it){};
|
||||
AttributeIterator(const std::map<int,
|
||||
ExtendedAttribute *>::iterator& _map_it):map_it(_map_it){};
|
||||
|
||||
virtual ~AttributeIterator(){};
|
||||
|
||||
protected:
|
||||
std::map<int, ExtendedAttribute *>::iterator map_it;
|
||||
};
|
||||
|
||||
AttributeIterator begin()
|
||||
{
|
||||
AttributeIterator it(a_set.begin());
|
||||
return it;
|
||||
}
|
||||
|
||||
AttributeIterator end()
|
||||
{
|
||||
AttributeIterator it(a_set.end());
|
||||
return it;
|
||||
}
|
||||
|
||||
typedef class AttributeIterator attribute_iterator;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Attribute map interface */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/**
|
||||
* Adds a new VirtualMachine attribute to the set
|
||||
* @param a the Extended attribute to add
|
||||
* @param id of the new attribute
|
||||
*/
|
||||
void add_attribute(ExtendedAttribute * a, int id)
|
||||
{
|
||||
a_set.insert(make_pair(id, a));
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an attribute from the set
|
||||
* @param id of the attribute
|
||||
* @return the attribute removed or 0 if not found
|
||||
*/
|
||||
ExtendedAttribute * delete_attribute(int id);
|
||||
|
||||
/**
|
||||
* Init the attribute set from a vector
|
||||
* @param id_name with the ID of the attribute
|
||||
* @param auto_ids automatically generate ids for the attributes
|
||||
* @param vas vector of attribute to use
|
||||
*/
|
||||
void init_attribute_map(const std::string& id_name,
|
||||
std::vector<VectorAttribute *>& vas);
|
||||
/**
|
||||
* Abstract method to create the VirtualMachineAttributes for this set
|
||||
*/
|
||||
virtual ExtendedAttribute * attribute_factory(VectorAttribute * va,
|
||||
int id) const = 0;
|
||||
|
||||
/**
|
||||
* @return the number of elements in the set
|
||||
*/
|
||||
unsigned int size()
|
||||
{
|
||||
return a_set.size();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Map with the disk attributes
|
||||
*/
|
||||
std::map<int, ExtendedAttribute *> a_set;
|
||||
|
||||
/**
|
||||
* Frees the VectorAttribute associated with each VirtualMachineAttribute
|
||||
* upon object destruction
|
||||
*/
|
||||
bool dispose;
|
||||
};
|
||||
|
||||
#endif /*VIRTUAL_MACHINE_ATTRIBUTE_H_*/
|
271
include/FedReplicaManager.h
Normal file
271
include/FedReplicaManager.h
Normal file
@ -0,0 +1,271 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2016, 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 FED_REPLICA_MANAGER_H_
|
||||
#define FED_REPLICA_MANAGER_H_
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "ReplicaManager.h"
|
||||
#include "ActionManager.h"
|
||||
|
||||
extern "C" void * frm_loop(void *arg);
|
||||
|
||||
class SqlDB;
|
||||
|
||||
class FedReplicaManager : public ReplicaManager, ActionListener
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @param _t timer for periofic actions (sec)
|
||||
* @param _p purge timeout for log
|
||||
* @param d pointer to underlying DB (LogDB)
|
||||
* @param l log_retention length (num records)
|
||||
*/
|
||||
FedReplicaManager(time_t _t, time_t _p, SqlDB * d, const std::string& l);
|
||||
|
||||
virtual ~FedReplicaManager();
|
||||
|
||||
/**
|
||||
* Creates a new record in the federation log and sends the replication
|
||||
* event to the replica threads. [MASTER]
|
||||
* @param sql db command to replicate
|
||||
* @return 0 on success -1 otherwise
|
||||
*/
|
||||
int replicate(const std::string& sql);
|
||||
|
||||
/**
|
||||
* Updates the current index in the server and applies the command to the
|
||||
* server. It also stores the record in the zone log [SLAVE]
|
||||
* @param index of the record
|
||||
* @param sql command to apply to DB
|
||||
* @return 0 on success, last_index if missing records, -1 on DB error
|
||||
*/
|
||||
int apply_log_record(int index, const std::string& sql);
|
||||
|
||||
/**
|
||||
* Record was successfully replicated on zone, increase next index and
|
||||
* send any pending records.
|
||||
* @param zone_id
|
||||
*/
|
||||
void replicate_success(int zone_id);
|
||||
|
||||
/**
|
||||
* Record could not be replicated on zone, decrease next index and
|
||||
* send any pending records.
|
||||
* @param zone_id
|
||||
*/
|
||||
void replicate_failure(int zone_id, int zone_last);
|
||||
|
||||
/**
|
||||
* XML-RPC API call to replicate a log entry on slaves
|
||||
* @param zone_id
|
||||
* @param success status of API call
|
||||
* @param last index replicate in zone slave
|
||||
* @param error description if any
|
||||
* @return 0 on success -1 if a xml-rpc/network error occurred
|
||||
*/
|
||||
int xmlrpc_replicate_log(int zone_id, bool& success, int& last,
|
||||
std::string& err);
|
||||
|
||||
/**
|
||||
* Finalizes the Federation Replica Manager
|
||||
*/
|
||||
void finalize()
|
||||
{
|
||||
am.finalize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the Federation Replica Manager
|
||||
*/
|
||||
int start();
|
||||
|
||||
/**
|
||||
* Start the replication threads, and updates the server list of the zone
|
||||
*/
|
||||
void start_replica_threads()
|
||||
{
|
||||
std::vector<int> zids;
|
||||
|
||||
update_zones(zids);
|
||||
|
||||
get_last_index(last_index);
|
||||
|
||||
ReplicaManager::start_replica_threads(zids);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the list of zones and servers in the zone. This function is
|
||||
* invoked when a server becomes leader, or whenever a server is +
|
||||
* added/removed to the zone
|
||||
* @param zids ids of zones
|
||||
*/
|
||||
void update_zones(std::vector<int>& zids);
|
||||
|
||||
/**
|
||||
* Adds a new zone to the replication list and starts the associated
|
||||
* replica thread
|
||||
* @param zone_id of the new zone
|
||||
*/
|
||||
void add_zone(int zone_id);
|
||||
|
||||
/**
|
||||
* Deletes zone from the replication list and stops the associated
|
||||
* replica thread
|
||||
* @param zone_id of the zone
|
||||
*/
|
||||
void delete_zone(int zone_id);
|
||||
|
||||
/**
|
||||
* Bootstrap federated log
|
||||
*/
|
||||
static int bootstrap(SqlDB *_db);
|
||||
|
||||
/**
|
||||
* @return the id of fed. replica thread
|
||||
*/
|
||||
pthread_t get_thread_id() const
|
||||
{
|
||||
return frm_thread;
|
||||
};
|
||||
|
||||
private:
|
||||
friend void * frm_loop(void *arg);
|
||||
|
||||
/**
|
||||
* Creates federation replica thread objects
|
||||
*/
|
||||
ReplicaThread * thread_factory(int follower_id);
|
||||
|
||||
/**
|
||||
* Thread id of the main event loop
|
||||
*/
|
||||
pthread_t frm_thread;
|
||||
|
||||
/**
|
||||
* Controls access to the zone list and server data
|
||||
*/
|
||||
pthread_mutex_t mutex;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Timers
|
||||
// - timer_period. Base timer to wake up the manager
|
||||
// - purge_period. How often the replicated log is purged (600s)
|
||||
// - xmlrpc_timeout. To timeout xml-rpc api calls to replicate log
|
||||
//--------------------------------------------------------------------------
|
||||
time_t timer_period;
|
||||
|
||||
time_t purge_period;
|
||||
|
||||
static const time_t xmlrpc_timeout_ms;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Synchronization variables
|
||||
// - last_index in the replication log
|
||||
// - zones list of zones in the federation with:
|
||||
// - list of servers <id, xmlrpc endpoint>
|
||||
// - next index to send to this zone
|
||||
// -------------------------------------------------------------------------
|
||||
struct ZoneServers
|
||||
{
|
||||
ZoneServers(int z, unsigned int l, const std::map<int,std::string>& s):
|
||||
zone_id(z), servers(s), next(l){};
|
||||
|
||||
~ZoneServers(){};
|
||||
|
||||
int zone_id;
|
||||
|
||||
std::map<int, std::string> servers;
|
||||
|
||||
unsigned int next;
|
||||
};
|
||||
|
||||
std::map<int, ZoneServers *> zones;
|
||||
|
||||
unsigned int last_index;
|
||||
|
||||
SqlDB * logdb;
|
||||
|
||||
std::string log_retention;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Action Listener interface
|
||||
// -------------------------------------------------------------------------
|
||||
ActionManager am;
|
||||
|
||||
/**
|
||||
* Termination function
|
||||
*/
|
||||
void finalize_action(const ActionRequest& ar);
|
||||
|
||||
/**
|
||||
* This function is executed periodically to purge the state log
|
||||
*/
|
||||
void timer_action(const ActionRequest& ar);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Database Implementation
|
||||
// Store log records to replicate on federation slaves
|
||||
// -------------------------------------------------------------------------
|
||||
static const char * table;
|
||||
|
||||
static const char * db_names;
|
||||
|
||||
static const char * db_bootstrap;
|
||||
|
||||
/**
|
||||
* Gets a record from the log
|
||||
* @param index of the record
|
||||
* @param sql command of the record
|
||||
* @return 0 in case of success -1 otherwise
|
||||
*/
|
||||
int get_log_record(int index, std::string& sql);
|
||||
|
||||
/**
|
||||
* Inserts a new record in the log ans updates the last_index variable
|
||||
* (memory and db)
|
||||
* @param index of new record
|
||||
* @param sql of DB command to execute
|
||||
* @return 0 on success
|
||||
*/
|
||||
int insert_log_record(int index, const std::string& sql);
|
||||
|
||||
/**
|
||||
* Reads the last index from DB for initialization
|
||||
* @param index
|
||||
* @return 0 on success
|
||||
*/
|
||||
int get_last_index(unsigned int& index);
|
||||
|
||||
/**
|
||||
* Get the nest record to replicate in a zone
|
||||
* @param zone_id of the zone
|
||||
* @param index of the next record to send
|
||||
* @param sql command to replicate
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int get_next_record(int zone_id, int& index, std::string& sql,
|
||||
std::map<int, std::string>& zservers);
|
||||
};
|
||||
|
||||
#endif /*FED_REPLICA_MANAGER_H_*/
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
@ -210,7 +210,7 @@ private:
|
||||
{
|
||||
ostringstream oss_group(Group::db_bootstrap);
|
||||
|
||||
return db->exec(oss_group);
|
||||
return db->exec_local_wr(oss_group);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -532,8 +532,8 @@ private:
|
||||
ostringstream oss_host(Host::db_bootstrap);
|
||||
ostringstream oss_monit(Host::monit_db_bootstrap);
|
||||
|
||||
rc = db->exec(oss_host);
|
||||
rc += db->exec(oss_monit);
|
||||
rc = db->exec_local_wr(oss_host);
|
||||
rc += db->exec_local_wr(oss_monit);
|
||||
|
||||
return rc;
|
||||
};
|
||||
|
@ -696,7 +696,7 @@ private:
|
||||
{
|
||||
ostringstream oss_image(Image::db_bootstrap);
|
||||
|
||||
return db->exec(oss_image);
|
||||
return db->exec_local_wr(oss_image);
|
||||
};
|
||||
|
||||
/**
|
||||
|
355
include/LogDB.h
Normal file
355
include/LogDB.h
Normal file
@ -0,0 +1,355 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2016, 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 LOG_DB_H_
|
||||
#define LOG_DB_H_
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
#include "SqlDB.h"
|
||||
|
||||
/**
|
||||
* This class represents a log record
|
||||
*/
|
||||
class LogDBRecord : public Callbackable
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Index for this log entry (and previous)
|
||||
*/
|
||||
unsigned int index;
|
||||
|
||||
unsigned int prev_index;
|
||||
|
||||
/**
|
||||
* Term where this log (and previous) entry was generated
|
||||
*/
|
||||
unsigned int term;
|
||||
|
||||
unsigned int prev_term;
|
||||
|
||||
/**
|
||||
* SQL command to exec in the DB to update (INSERT, REPLACE, DROP)
|
||||
*/
|
||||
std::string sql;
|
||||
|
||||
/**
|
||||
* Time when the record has been applied to DB. 0 if not applied
|
||||
*/
|
||||
time_t timestamp;
|
||||
|
||||
/**
|
||||
* Sets callback to load register from DB
|
||||
*/
|
||||
void set_callback()
|
||||
{
|
||||
Callbackable::set_callback(
|
||||
static_cast<Callbackable::Callback>(&LogDBRecord::select_cb));
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* SQL callback to load logDBRecord from DB (SELECT commands)
|
||||
*/
|
||||
int select_cb(void *nil, int num, char **values, char **names)
|
||||
{
|
||||
if ( !values || !values[0] || !values[1] || !values[2] || !values[3] ||
|
||||
!values[4] || !values[5] || num != 6 )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
index = static_cast<unsigned int>(atoi(values[0]));
|
||||
term = static_cast<unsigned int>(atoi(values[1]));
|
||||
sql = values[2];
|
||||
|
||||
timestamp = static_cast<unsigned int>(atoi(values[3]));
|
||||
|
||||
prev_index = static_cast<unsigned int>(atoi(values[4]));
|
||||
prev_term = static_cast<unsigned int>(atoi(values[5]));
|
||||
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This class implements a generic DB interface with replication. The associated
|
||||
* DB stores a log to replicate on followers.
|
||||
*/
|
||||
class LogDB : public SqlDB
|
||||
{
|
||||
public:
|
||||
LogDB(SqlDB * _db, bool solo, const std::string& log_retention);
|
||||
|
||||
virtual ~LogDB();
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Interface to access Log records
|
||||
// -------------------------------------------------------------------------
|
||||
/**
|
||||
* Loads a log record from the database. Memory is allocated by this class
|
||||
* and needs to be freed.
|
||||
* @param index of the associated logDB entry
|
||||
* @param lr logDBrecored to load from the DB
|
||||
* @return 0 on success -1 otherwise
|
||||
*/
|
||||
int get_log_record(unsigned int index, LogDBRecord& lr);
|
||||
|
||||
/**
|
||||
* Applies the SQL command of the given record to the database. The
|
||||
* timestamp of the record is updated.
|
||||
* @param lr the log record
|
||||
* @param index of the log record
|
||||
*/
|
||||
int apply_log_record(LogDBRecord * lr);
|
||||
|
||||
int apply_log_records(unsigned int commit_index);
|
||||
|
||||
/**
|
||||
* Deletes the record in start_index and all that follow it
|
||||
* @param start_index first log record to delete
|
||||
*/
|
||||
int delete_log_records(unsigned int start_index);
|
||||
|
||||
/**
|
||||
* Inserts a new log record in the database. This method should be used
|
||||
* in FOLLOWER mode to replicate leader log.
|
||||
* @param index for the record
|
||||
* @param term for the record
|
||||
* @param sql command of the record
|
||||
* @param timestamp associated to this record
|
||||
*
|
||||
* @return -1 on failure, index of the inserted record on success
|
||||
*/
|
||||
int insert_log_record(unsigned int index, unsigned int term,
|
||||
std::ostringstream& sql, time_t timestamp);
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Functions to manage the Raft state. Log record 0, term -1
|
||||
// -------------------------------------------------------------------------
|
||||
/**
|
||||
* Stores the raft state in the log
|
||||
* @param raft attributes in XML format
|
||||
* @return 0 on success
|
||||
*/
|
||||
int insert_raft_state(std::string& raft_xml)
|
||||
{
|
||||
return insert_replace(-1, -1, raft_xml, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the raft state attributes as stored in the log
|
||||
* @param raft_xml attributes in xml
|
||||
* @return 0 on success
|
||||
*/
|
||||
int get_raft_state(std::string &raft_xml);
|
||||
|
||||
/**
|
||||
* Purge log records. Delete old records applied to database upto the
|
||||
* LOG_RETENTION configuration variable.
|
||||
* @return 0 on success
|
||||
*/
|
||||
int purge_log();
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// SQL interface
|
||||
// -------------------------------------------------------------------------
|
||||
/**
|
||||
* This function replicates the DB changes on followers before updating
|
||||
* the DB state
|
||||
*/
|
||||
int exec_wr(ostringstream& cmd);
|
||||
|
||||
int exec_local_wr(ostringstream& cmd)
|
||||
{
|
||||
return db->exec_local_wr(cmd);
|
||||
}
|
||||
|
||||
int exec_rd(ostringstream& cmd, Callbackable* obj)
|
||||
{
|
||||
return db->exec_rd(cmd, obj);
|
||||
}
|
||||
|
||||
char * escape_str(const string& str)
|
||||
{
|
||||
return db->escape_str(str);
|
||||
}
|
||||
|
||||
void free_str(char * str)
|
||||
{
|
||||
db->free_str(str);
|
||||
}
|
||||
|
||||
bool multiple_values_support()
|
||||
{
|
||||
return db->multiple_values_support();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Database methods
|
||||
// -------------------------------------------------------------------------
|
||||
static int bootstrap(SqlDB *_db)
|
||||
{
|
||||
std::ostringstream oss(db_bootstrap);
|
||||
|
||||
return _db->exec_local_wr(oss);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function gets and initialize log related index
|
||||
* @param last_applied, highest index applied to the DB
|
||||
* @param last_index
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int setup_index(int& last_applied, int& last_index);
|
||||
|
||||
/**
|
||||
* Gets the index & term of the last record in the log
|
||||
* @param _i the index
|
||||
* @param _t the term
|
||||
*/
|
||||
void get_last_record_index(unsigned int& _i, unsigned int& _t);
|
||||
|
||||
protected:
|
||||
int exec(std::ostringstream& cmd, Callbackable* obj, bool quiet)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
private:
|
||||
pthread_mutex_t mutex;
|
||||
|
||||
/**
|
||||
* The Database was started in solo mode (no server_id defined)
|
||||
*/
|
||||
bool solo;
|
||||
|
||||
/**
|
||||
* Pointer to the underlying DB store
|
||||
*/
|
||||
SqlDB * db;
|
||||
|
||||
/**
|
||||
* Index to be used by the next logDB record
|
||||
*/
|
||||
unsigned int next_index;
|
||||
|
||||
/**
|
||||
* Index of the last log entry applied to the DB state
|
||||
*/
|
||||
unsigned int last_applied;
|
||||
|
||||
/**
|
||||
* Index of the last (highest) log entry
|
||||
*/
|
||||
unsigned int last_index;
|
||||
|
||||
/**
|
||||
* term of the last (highest) log entry
|
||||
*/
|
||||
unsigned int last_term;
|
||||
|
||||
/**
|
||||
* Max number of records to keep in the database
|
||||
*/
|
||||
std::string log_retention;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// DataBase implementation
|
||||
// -------------------------------------------------------------------------
|
||||
static const char * table;
|
||||
|
||||
static const char * db_names;
|
||||
|
||||
static const char * db_bootstrap;
|
||||
|
||||
/**
|
||||
* Inserts or update a log record in the database
|
||||
* @param index of the log entry
|
||||
* @param term for the log entry
|
||||
* @param sql command to modify DB state
|
||||
* @param ts timestamp of record application to DB state
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int insert_replace(int index, int term, const std::string& sql, time_t ts);
|
||||
|
||||
/**
|
||||
* Inserts a new log record in the database. If the record is successfully
|
||||
* inserted the index is incremented
|
||||
* @param term for the record
|
||||
* @param sql command of the record
|
||||
* @param timestamp associated to this record
|
||||
*
|
||||
* @return -1 on failure, index of the inserted record on success
|
||||
*/
|
||||
int insert_log_record(unsigned int term, std::ostringstream& sql,
|
||||
time_t timestamp);
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// This is a LogDB decoration, it replicates the DB write commands on slaves
|
||||
// It should be passed as DB for federated pools.
|
||||
// -----------------------------------------------------------------------------
|
||||
class FedLogDB: public SqlDB
|
||||
{
|
||||
public:
|
||||
FedLogDB(LogDB *db):_logdb(db){};
|
||||
|
||||
virtual ~FedLogDB(){};
|
||||
|
||||
int exec_wr(ostringstream& cmd);
|
||||
|
||||
int exec_local_wr(ostringstream& cmd)
|
||||
{
|
||||
return _logdb->exec_local_wr(cmd);
|
||||
}
|
||||
|
||||
int exec_rd(ostringstream& cmd, Callbackable* obj)
|
||||
{
|
||||
return _logdb->exec_rd(cmd, obj);
|
||||
}
|
||||
|
||||
char * escape_str(const string& str)
|
||||
{
|
||||
return _logdb->escape_str(str);
|
||||
}
|
||||
|
||||
void free_str(char * str)
|
||||
{
|
||||
_logdb->free_str(str);
|
||||
}
|
||||
|
||||
bool multiple_values_support()
|
||||
{
|
||||
return _logdb->multiple_values_support();
|
||||
}
|
||||
|
||||
protected:
|
||||
int exec(std::ostringstream& cmd, Callbackable* obj, bool quiet)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
LogDB * _logdb;
|
||||
};
|
||||
|
||||
#endif /*LOG_DB_H_*/
|
||||
|
@ -221,7 +221,7 @@ private:
|
||||
{
|
||||
ostringstream oss(db_bootstrap);
|
||||
|
||||
return db->exec(oss);
|
||||
return db->exec_local_wr(oss);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -393,7 +393,7 @@ private:
|
||||
{
|
||||
ostringstream oss(db_bootstrap);
|
||||
|
||||
return db->exec(oss);
|
||||
return db->exec_local_wr(oss);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -30,6 +30,7 @@ class ImagePool;
|
||||
class DatastorePool;
|
||||
|
||||
class ImageManager;
|
||||
class RaftManager;
|
||||
|
||||
class MarketPlaceManager : public MadManager, public ActionListener
|
||||
{
|
||||
@ -175,6 +176,11 @@ private:
|
||||
*/
|
||||
ImageManager * imagem;
|
||||
|
||||
/**
|
||||
* Pointer to the Raft Manger
|
||||
*/
|
||||
RaftManager * raftm;
|
||||
|
||||
/**
|
||||
* Action engine for the Manager
|
||||
*/
|
||||
|
@ -52,14 +52,6 @@ public:
|
||||
|
||||
~MySqlDB();
|
||||
|
||||
/**
|
||||
* Wraps the mysql_query function call
|
||||
* @param cmd the SQL command
|
||||
* @param obj Callbackable obj to call if the query succeeds
|
||||
* @return 0 on success
|
||||
*/
|
||||
int exec(ostringstream& cmd, Callbackable* obj=0, bool quiet=false);
|
||||
|
||||
/**
|
||||
* This function returns a legal SQL string that can be used in an SQL
|
||||
* statement. The string is encoded to an escaped SQL string, taking into
|
||||
@ -83,6 +75,15 @@ public:
|
||||
*/
|
||||
bool multiple_values_support();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Wraps the mysql_query function call
|
||||
* @param cmd the SQL command
|
||||
* @param obj Callbackable obj to call if the query succeeds
|
||||
* @return 0 on success
|
||||
*/
|
||||
int exec(ostringstream& cmd, Callbackable* obj, bool quiet);
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
@ -151,13 +152,15 @@ public:
|
||||
|
||||
~MySqlDB(){};
|
||||
|
||||
int exec(ostringstream& cmd, Callbackable* obj=0, bool quiet=false){return -1;};
|
||||
|
||||
char * escape_str(const string& str){return 0;};
|
||||
|
||||
void free_str(char * str){};
|
||||
|
||||
bool multiple_values_support(){return true;};
|
||||
|
||||
protected:
|
||||
int exec(ostringstream& cmd, Callbackable* obj, bool quiet){return -1;};
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
#ifndef NEBULA_H_
|
||||
#define NEBULA_H_
|
||||
|
||||
#include "SqlDB.h"
|
||||
#include "LogDB.h"
|
||||
#include "SystemDB.h"
|
||||
|
||||
#include "NebulaTemplate.h"
|
||||
@ -51,6 +51,8 @@
|
||||
#include "ImageManager.h"
|
||||
#include "MarketPlaceManager.h"
|
||||
#include "IPAMManager.h"
|
||||
#include "RaftManager.h"
|
||||
#include "FedReplicaManager.h"
|
||||
|
||||
#include "DefaultQuotas.h"
|
||||
|
||||
@ -76,6 +78,10 @@ public:
|
||||
// --------------------------------------------------------------
|
||||
// Pool Accessors
|
||||
// --------------------------------------------------------------
|
||||
LogDB * get_logdb()
|
||||
{
|
||||
return logdb;
|
||||
};
|
||||
|
||||
VirtualMachinePool * get_vmpool()
|
||||
{
|
||||
@ -221,6 +227,16 @@ public:
|
||||
return ipamm;
|
||||
};
|
||||
|
||||
RaftManager * get_raftm()
|
||||
{
|
||||
return raftm;
|
||||
};
|
||||
|
||||
FedReplicaManager * get_frm()
|
||||
{
|
||||
return frm;
|
||||
};
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Environment & Configuration
|
||||
// --------------------------------------------------------------
|
||||
@ -400,6 +416,11 @@ public:
|
||||
return zone_id;
|
||||
};
|
||||
|
||||
int get_server_id()
|
||||
{
|
||||
return server_id;
|
||||
};
|
||||
|
||||
const string& get_master_oned()
|
||||
{
|
||||
return master_oned;
|
||||
@ -660,12 +681,12 @@ private:
|
||||
"/DEFAULT_GROUP_QUOTAS/NETWORK_QUOTA",
|
||||
"/DEFAULT_GROUP_QUOTAS/IMAGE_QUOTA",
|
||||
"/DEFAULT_GROUP_QUOTAS/VM_QUOTA"),
|
||||
system_db(0), db(0),
|
||||
system_db(0), logdb(0), fed_logdb(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), vrouterpool(0), marketpool(0), apppool(0), vmgrouppool(0),
|
||||
lcm(0), vmm(0), im(0), tm(0), dm(0), rm(0), hm(0), authm(0), aclm(0),
|
||||
imagem(0), marketm(0), ipamm(0)
|
||||
imagem(0), marketm(0), ipamm(0), raftm(0), frm(0)
|
||||
{
|
||||
const char * nl = getenv("ONE_LOCATION");
|
||||
|
||||
@ -729,8 +750,11 @@ private:
|
||||
delete imagem;
|
||||
delete marketm;
|
||||
delete ipamm;
|
||||
delete raftm;
|
||||
delete frm;
|
||||
delete nebula_configuration;
|
||||
delete db;
|
||||
delete logdb;
|
||||
delete fed_logdb;
|
||||
delete system_db;
|
||||
};
|
||||
|
||||
@ -759,12 +783,13 @@ private:
|
||||
OpenNebulaTemplate * nebula_configuration;
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Federation
|
||||
// Federation - HA
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
bool federation_enabled;
|
||||
bool federation_master;
|
||||
int zone_id;
|
||||
int server_id;
|
||||
string master_oned;
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
@ -784,7 +809,8 @@ private:
|
||||
// Nebula Pools
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
SqlDB * db;
|
||||
LogDB * logdb;
|
||||
FedLogDB * fed_logdb;
|
||||
VirtualMachinePool * vmpool;
|
||||
HostPool * hpool;
|
||||
VirtualNetworkPool * vnpool;
|
||||
@ -819,6 +845,8 @@ private:
|
||||
ImageManager * imagem;
|
||||
MarketPlaceManager * marketm;
|
||||
IPAMManager * ipamm;
|
||||
RaftManager * raftm;
|
||||
FedReplicaManager * frm;
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Implementation functions
|
||||
|
@ -328,44 +328,22 @@ protected:
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Interface to access the lastOID assigned by the pool */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Gets the value of the last identifier assigned by the pool
|
||||
* @return the lastOID of the pool
|
||||
*/
|
||||
int get_lastOID()
|
||||
{
|
||||
return lastOID;
|
||||
};
|
||||
int get_lastOID();
|
||||
|
||||
/**
|
||||
* Sets the lastOID of the pool and updates the control database
|
||||
* @param _lastOID for the pool
|
||||
*/
|
||||
void set_update_lastOID(int _lastOID)
|
||||
{
|
||||
lastOID = _lastOID;
|
||||
|
||||
update_lastOID();
|
||||
};
|
||||
void set_lastOID(int _lastOID);
|
||||
|
||||
private:
|
||||
|
||||
pthread_mutex_t mutex;
|
||||
|
||||
/**
|
||||
* Max size for the pool, to control the memory footprint of the pool. This
|
||||
* number MUST be greater than the max. number of objects that are
|
||||
* accessed simultaneously.
|
||||
*/
|
||||
static const unsigned int MAX_POOL_SIZE;
|
||||
|
||||
/**
|
||||
* Last object ID assigned to an object. It must be initialized by the
|
||||
* target pool.
|
||||
*/
|
||||
int lastOID;
|
||||
|
||||
/**
|
||||
* Tablename for this pool
|
||||
*/
|
||||
@ -377,11 +355,6 @@ private:
|
||||
*/
|
||||
map<int,PoolObjectSQL *> pool;
|
||||
|
||||
/**
|
||||
* Whether or not this pool uses the cache
|
||||
*/
|
||||
bool cache;
|
||||
|
||||
/**
|
||||
* Whether or not this pool uses the name_pool index
|
||||
*/
|
||||
@ -399,12 +372,6 @@ private:
|
||||
*/
|
||||
virtual PoolObjectSQL * create() = 0;
|
||||
|
||||
/**
|
||||
* OID queue to implement a FIFO-like replacement policy for the pool
|
||||
* cache.
|
||||
*/
|
||||
queue<int> oid_queue;
|
||||
|
||||
/**
|
||||
* Function to lock the pool
|
||||
*/
|
||||
@ -421,14 +388,6 @@ private:
|
||||
pthread_mutex_unlock(&mutex);
|
||||
};
|
||||
|
||||
/**
|
||||
* FIFO-like replacement policy function. Before removing an object (pop)
|
||||
* from the cache its lock is checked. The object is removed only if
|
||||
* the associated mutex IS NOT blocked. Otherwise the oid is sent to the
|
||||
* back of the queue.
|
||||
*/
|
||||
void replace();
|
||||
|
||||
/**
|
||||
* Cleans all the objects in the cache, except the ones locked.
|
||||
* The object with the given oid will not be ignored if locked, the
|
||||
@ -462,19 +421,8 @@ private:
|
||||
return key.str();
|
||||
};
|
||||
|
||||
/**
|
||||
* Inserts the last oid into the pool_control table
|
||||
*/
|
||||
void update_lastOID();
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Callback to set the lastOID (PoolSQL::PoolSQL)
|
||||
*/
|
||||
int init_cb(void *nil, int num, char **values, char **names);
|
||||
|
||||
/**
|
||||
* Callback to store the IDs of pool objects (PoolSQL::search)
|
||||
*/
|
||||
|
@ -167,7 +167,7 @@ public:
|
||||
{
|
||||
ostringstream oss_quota(GroupQuotas::db_bootstrap);
|
||||
|
||||
return db->exec(oss_quota);
|
||||
return db->exec_local_wr(oss_quota);
|
||||
};
|
||||
|
||||
protected:
|
||||
@ -220,7 +220,7 @@ public:
|
||||
{
|
||||
ostringstream oss_quota(UserQuotas::db_bootstrap);
|
||||
|
||||
return db->exec(oss_quota);
|
||||
return db->exec_local_wr(oss_quota);
|
||||
};
|
||||
|
||||
protected:
|
||||
|
54
include/RaftHook.h
Normal file
54
include/RaftHook.h
Normal file
@ -0,0 +1,54 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2016, 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 RAFT_HOOK_H_
|
||||
#define RAFT_HOOK_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Hook.h"
|
||||
|
||||
class RaftHook : public Hook
|
||||
{
|
||||
public:
|
||||
RaftHook(const std::string& name,
|
||||
const std::string& command):
|
||||
Hook(name, command, "", Hook::UPDATE, false){};
|
||||
|
||||
~RaftHook(){};
|
||||
|
||||
void do_hook(void *arg);
|
||||
};
|
||||
|
||||
class RaftLeaderHook : public RaftHook
|
||||
{
|
||||
public:
|
||||
RaftLeaderHook(const std::string& command):
|
||||
RaftHook("RAFT_LEADER_HOOK", command){};
|
||||
|
||||
~RaftLeaderHook(){};
|
||||
};
|
||||
|
||||
class RaftFollowerHook : public RaftHook
|
||||
{
|
||||
public:
|
||||
RaftFollowerHook(const std::string& command):
|
||||
RaftHook("RAFT_FOLLOWER_HOOK", command){};
|
||||
|
||||
~RaftFollowerHook(){};
|
||||
};
|
||||
|
||||
#endif
|
435
include/RaftManager.h
Normal file
435
include/RaftManager.h
Normal file
@ -0,0 +1,435 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2016, 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 RAFT_MANAGER_H_
|
||||
#define RAFT_MANAGER_H_
|
||||
|
||||
#include "ActionManager.h"
|
||||
#include "ReplicaManager.h"
|
||||
#include "ReplicaRequest.h"
|
||||
#include "Template.h"
|
||||
#include "RaftHook.h"
|
||||
|
||||
extern "C" void * raft_manager_loop(void *arg);
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
class RaftManager : public ActionListener
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* State of this server
|
||||
*/
|
||||
enum State {
|
||||
SOLO = 0,
|
||||
CANDIDATE = 1,
|
||||
FOLLOWER = 2,
|
||||
LEADER = 3
|
||||
};
|
||||
|
||||
/**
|
||||
* Raft manager constructor
|
||||
* @param server_id of this server
|
||||
* @param leader_hook_mad to be executed when follower->leader
|
||||
* @param follower_hook_mad to be executed when leader->follower
|
||||
* @param log_purge period to purge logDB records
|
||||
* @param bcast heartbeat broadcast timeout
|
||||
* @param election timeout
|
||||
* @param xmlrpc timeout for RAFT related xmlrpc API calls
|
||||
**/
|
||||
RaftManager(int server_id, const VectorAttribute * leader_hook_mad,
|
||||
const VectorAttribute * follower_hook_mad, time_t log_purge,
|
||||
long long bcast, long long election, time_t xmlrpc,
|
||||
const string& remotes_location);
|
||||
|
||||
~RaftManager()
|
||||
{
|
||||
delete leader_hook;
|
||||
delete follower_hook;
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Raft associated actions (synchronous)
|
||||
// -------------------------------------------------------------------------
|
||||
/**
|
||||
* Follower successfully replicated a log entry:
|
||||
* - Increment next entry to send to follower
|
||||
* - Update match entry on follower
|
||||
* - Evaluate majority to apply changes to DB
|
||||
*/
|
||||
void replicate_success(int follower_id);
|
||||
|
||||
/**
|
||||
* Follower failed to replicate a log entry because an inconsistency was
|
||||
* detected (same index, different term):
|
||||
* - Decrease follower next_index
|
||||
* - Retry (do not wait for replica events)
|
||||
*/
|
||||
void replicate_failure(int follower_id);
|
||||
|
||||
/**
|
||||
* Triggers a REPLICATE event, it will notify the replica threads to
|
||||
* send the log to the followers
|
||||
*/
|
||||
void replicate_log(ReplicaRequest * rr);
|
||||
|
||||
|
||||
/**
|
||||
* Finalizes the Raft Consensus Manager
|
||||
*/
|
||||
void finalize()
|
||||
{
|
||||
am.finalize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the Raft Consensus Manager
|
||||
*/
|
||||
int start();
|
||||
|
||||
pthread_t get_thread_id() const
|
||||
{
|
||||
return raft_thread;
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Raft state query functions
|
||||
// -------------------------------------------------------------------------
|
||||
/**
|
||||
* Return the Raft status in XML format
|
||||
* @return xml document with the raft state
|
||||
*/
|
||||
std::string& to_xml(std::string& state_xml);
|
||||
|
||||
/**
|
||||
* Makes this server follower. Stop associated replication facilities
|
||||
*/
|
||||
void follower(unsigned int term);
|
||||
|
||||
unsigned int get_term()
|
||||
{
|
||||
unsigned int _term;
|
||||
|
||||
pthread_mutex_lock(&mutex);
|
||||
|
||||
_term = term;
|
||||
|
||||
pthread_mutex_unlock(&mutex);
|
||||
|
||||
return _term;
|
||||
}
|
||||
|
||||
unsigned int get_commit()
|
||||
{
|
||||
unsigned int _commit;
|
||||
|
||||
pthread_mutex_lock(&mutex);
|
||||
|
||||
_commit = commit;
|
||||
|
||||
pthread_mutex_unlock(&mutex);
|
||||
|
||||
return _commit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the commit index = min(leader_commit, log index).
|
||||
* @param leader_commit index sent by leader in a replicate xml-rpc call
|
||||
* @param index of the last record inserted in the database
|
||||
* @return the updated commit index
|
||||
*/
|
||||
unsigned int update_commit(unsigned int leader_commit, unsigned int index);
|
||||
|
||||
/**
|
||||
* Evaluates a vote request. It is granted if no vote has been granted in
|
||||
* this term or it is requested by the same candidate.
|
||||
* @param _votedfor the candidate id
|
||||
* @return -1 if vote is not granted
|
||||
*/
|
||||
int update_votedfor(int _votedfor);
|
||||
|
||||
/**
|
||||
* Update the last_heartbeat time recieved from server. It stores the id
|
||||
* of the leader.
|
||||
* @param leader_id id of server, -1 if there is no leader set (e.g.
|
||||
* during a election because a vote request was received)
|
||||
*/
|
||||
void update_last_heartbeat(int leader_id);
|
||||
|
||||
/**
|
||||
* @return true if the server is the leader of the zone, runs in solo mode
|
||||
* or is a follower
|
||||
*/
|
||||
bool is_leader()
|
||||
{
|
||||
return test_state(LEADER);
|
||||
}
|
||||
|
||||
bool is_follower()
|
||||
{
|
||||
return test_state(FOLLOWER);
|
||||
}
|
||||
|
||||
bool is_candidate()
|
||||
{
|
||||
return test_state(CANDIDATE);
|
||||
}
|
||||
|
||||
bool is_solo()
|
||||
{
|
||||
return test_state(SOLO);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get next index to send to the follower
|
||||
* @param follower server id
|
||||
* @return -1 on failure, the next index if success
|
||||
*/
|
||||
int get_next_index(int follower_id)
|
||||
{
|
||||
std::map<int, unsigned int>::iterator it;
|
||||
unsigned int _index = -1;
|
||||
|
||||
pthread_mutex_lock(&mutex);
|
||||
|
||||
it = next.find(follower_id);
|
||||
|
||||
if ( it != next.end() )
|
||||
{
|
||||
_index = it->second;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&mutex);
|
||||
|
||||
return _index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the endpoint for xml-rpc calls of the current leader
|
||||
* @param endpoint
|
||||
* @return 0 on success, -1 if no leader found
|
||||
*/
|
||||
int get_leader_endpoint(std::string& endpoint);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XML-RPC Raft API calls
|
||||
// -------------------------------------------------------------------------
|
||||
/**
|
||||
* Calls the follower xml-rpc method
|
||||
* @param follower_id to make the call
|
||||
* @param lr the record to replicate
|
||||
* @param success of the xml-rpc method
|
||||
* @param ft term in the follower as returned by the replicate call
|
||||
* @param error describing error if any
|
||||
* @return -1 if a XMl-RPC (network) error occurs, 0 otherwise
|
||||
*/
|
||||
int xmlrpc_replicate_log(int follower_id, LogDBRecord * lr, bool& success,
|
||||
unsigned int& ft, std::string& error);
|
||||
|
||||
/**
|
||||
* Calls the request vote xml-rpc method
|
||||
* @param follower_id to make the call
|
||||
* @param lindex highest last log index
|
||||
* @param lterm highest last log term
|
||||
* @param success of the xml-rpc method
|
||||
* @param ft term in the follower as returned by the replicate call
|
||||
* @param error describing error if any
|
||||
* @return -1 if a XMl-RPC (network) error occurs, 0 otherwise
|
||||
*/
|
||||
int xmlrpc_request_vote(int follower_id, unsigned int lindex,
|
||||
unsigned int lterm, bool& success, unsigned int& fterm,
|
||||
std::string& error);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Server related interface
|
||||
// -------------------------------------------------------------------------
|
||||
/**
|
||||
* Adds a new server to the follower list and starts associated replica
|
||||
* thread.
|
||||
* @param follower_id id of new server
|
||||
* @param xmlep xmlrpc endpoint for new server
|
||||
*/
|
||||
void add_server(int follower_id, const std::string& xmlep);
|
||||
|
||||
/**
|
||||
* Deletes a new server to the follower list and stops associated replica
|
||||
* thread.
|
||||
* @param follower_id id of server
|
||||
*/
|
||||
void delete_server(int follower_id);
|
||||
|
||||
private:
|
||||
friend void * raft_manager_loop(void *arg);
|
||||
|
||||
/**
|
||||
* Thread id of the main event loop
|
||||
*/
|
||||
pthread_t raft_thread;
|
||||
|
||||
pthread_mutex_t mutex;
|
||||
|
||||
/**
|
||||
* Event engine for the RaftManager
|
||||
*/
|
||||
ActionManager am;
|
||||
|
||||
/**
|
||||
* Clients waiting for a log replication
|
||||
*/
|
||||
std::map<int, ReplicaRequest *> requests;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Raft state
|
||||
// -------------------------------------------------------------------------
|
||||
/**
|
||||
* Server state
|
||||
*/
|
||||
State state;
|
||||
|
||||
/**
|
||||
* Server id
|
||||
*/
|
||||
int server_id;
|
||||
|
||||
/**
|
||||
* Current term
|
||||
*/
|
||||
unsigned int term;
|
||||
|
||||
/**
|
||||
* Number of servers in zone
|
||||
*/
|
||||
unsigned int num_servers;
|
||||
|
||||
/**
|
||||
* Time when the last heartbeat was sent (LEADER) or received (FOLLOWER)
|
||||
*/
|
||||
struct timespec last_heartbeat;
|
||||
|
||||
/**
|
||||
* ID of the last candidate we voted for ( -1 if none )
|
||||
*/
|
||||
int votedfor;
|
||||
|
||||
/**
|
||||
* ID of leader for the current term
|
||||
*/
|
||||
int leader_id;
|
||||
|
||||
/**
|
||||
* This is the raft persistent state: votedfor and current term. It is
|
||||
* stored along the log in a special record (0, -1 , TEMPLATE, 0)
|
||||
*/
|
||||
Template raft_state;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Timers
|
||||
// - timer_period_ms. Base timer to wake up the manager (10ms)
|
||||
// - purge_period_ms. How often the LogDB is purged (600s)
|
||||
// - xmlrpc_timeout. To timeout xml-rpc api calls to replicate log
|
||||
// - election_timeout. Timeout leader heartbeats (followers)
|
||||
// - broadcast_timeout. To send heartbeat to followers (leader)
|
||||
//--------------------------------------------------------------------------
|
||||
static const time_t timer_period_ms;
|
||||
|
||||
time_t purge_period_ms;
|
||||
|
||||
time_t xmlrpc_timeout_ms;
|
||||
|
||||
struct timespec election_timeout;
|
||||
|
||||
struct timespec broadcast_timeout;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Volatile log index variables
|
||||
// - commit, highest log known to be committed
|
||||
// - applied, highest log applied to DB (in LogDB)
|
||||
//
|
||||
//---------------------------- LEADER VARIABLES ----------------------------
|
||||
//
|
||||
// - next, next log to send to each follower <follower, next>
|
||||
// - match, highest log replicated in this server <follower, match>
|
||||
// - servers, list of servers in zone and xml-rpc edp <follower, edp>
|
||||
// -------------------------------------------------------------------------
|
||||
RaftReplicaManager replica_manager;
|
||||
|
||||
unsigned int commit;
|
||||
|
||||
std::map<int, unsigned int> next;
|
||||
|
||||
std::map<int, unsigned int> match;
|
||||
|
||||
std::map<int, std::string> servers;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Hooks
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
RaftLeaderHook * leader_hook;
|
||||
RaftFollowerHook * follower_hook;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Action Listener interface
|
||||
// -------------------------------------------------------------------------
|
||||
/**
|
||||
* Termination function
|
||||
*/
|
||||
void finalize_action(const ActionRequest& ar);
|
||||
|
||||
/**
|
||||
* This function is executed periodically to purge the state log
|
||||
*/
|
||||
void timer_action(const ActionRequest& ar);
|
||||
|
||||
/**
|
||||
* @param s the state to check
|
||||
* @return true if the server states matches the provided one
|
||||
*/
|
||||
bool test_state(State s)
|
||||
{
|
||||
bool _is_state;
|
||||
|
||||
pthread_mutex_lock(&mutex);
|
||||
|
||||
_is_state = state == s;
|
||||
|
||||
pthread_mutex_unlock(&mutex);
|
||||
|
||||
return _is_state;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Internal Raft functions
|
||||
// -------------------------------------------------------------------------
|
||||
/**
|
||||
* Send the heartbeat to the followers.
|
||||
*/
|
||||
void send_heartbeat();
|
||||
|
||||
/**
|
||||
* Request votes of followers
|
||||
*/
|
||||
void request_vote();
|
||||
|
||||
/**
|
||||
* Makes this server leader, and start replica threads
|
||||
*/
|
||||
void leader();
|
||||
};
|
||||
|
||||
#endif /*RAFT_MANAGER_H_*/
|
||||
|
108
include/ReplicaManager.h
Normal file
108
include/ReplicaManager.h
Normal file
@ -0,0 +1,108 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2016, 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 REPLICA_MANAGER_H_
|
||||
#define REPLICA_MANAGER_H_
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
class ReplicaThread;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
// Replication Manager. This is a generic replication manager it starts, stops
|
||||
// and send control events to replica threads.
|
||||
// -----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
class ReplicaManager
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Start the replication threads, one for each server in the zone
|
||||
*/
|
||||
void start_replica_threads(std::vector<int>& fids);
|
||||
|
||||
/**
|
||||
* Stop the replication threads (leader becomes follower)
|
||||
*/
|
||||
void stop_replica_threads();
|
||||
|
||||
/**
|
||||
* Triggers a replication event on the replica threads
|
||||
*/
|
||||
void replicate();
|
||||
|
||||
/**
|
||||
* Triggers a replication event on the follower thread
|
||||
* @param follower id
|
||||
*/
|
||||
void replicate(int follower);
|
||||
|
||||
/**
|
||||
* Deletes a replication thread for a follower (e.g. server deleted)
|
||||
* @param follower_id server id
|
||||
*/
|
||||
void delete_replica_thread(int follower_id);
|
||||
|
||||
/**
|
||||
* Adds a replication thread for a follower (e.g. server add)
|
||||
* @param follower_id server id
|
||||
*/
|
||||
void add_replica_thread(int follower_id);
|
||||
|
||||
protected:
|
||||
ReplicaManager(){};
|
||||
|
||||
virtual ~ReplicaManager()
|
||||
{
|
||||
stop_replica_threads();
|
||||
};
|
||||
|
||||
virtual ReplicaThread * thread_factory(int follower_id) = 0;
|
||||
|
||||
private:
|
||||
/**
|
||||
* The replication thread pool
|
||||
*/
|
||||
std::map<int, ReplicaThread *> thread_pool;
|
||||
|
||||
/**
|
||||
* @param server_id of the follower
|
||||
* @return pointer to the replica thread associated to a follower
|
||||
*/
|
||||
ReplicaThread * get_thread(int server_id);
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
// RaftReplicaManager to manage the raft replication thread pool
|
||||
// -----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
class RaftReplicaManager : public ReplicaManager
|
||||
{
|
||||
public:
|
||||
RaftReplicaManager():ReplicaManager(){};
|
||||
|
||||
virtual ~RaftReplicaManager(){};
|
||||
|
||||
private:
|
||||
ReplicaThread * thread_factory(int follower_id);
|
||||
};
|
||||
|
||||
#endif /*REPLICA_MANAGER_H_*/
|
||||
|
106
include/ReplicaRequest.h
Normal file
106
include/ReplicaRequest.h
Normal file
@ -0,0 +1,106 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2016, 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 REPLICA_REQUEST_H_
|
||||
#define REPLICA_REQUEST_H_
|
||||
|
||||
#include "SyncRequest.h"
|
||||
|
||||
/**
|
||||
* This class represents a log entry replication request. The replication request
|
||||
* is synchronous: once it has been replicated in a majority of followers the
|
||||
* client is notified (SqlDB::exec_wr() call) and DB updated.
|
||||
*/
|
||||
class ReplicaRequest : public SyncRequest
|
||||
{
|
||||
public:
|
||||
ReplicaRequest(unsigned int i):_index(i), _to_commit(-1), _replicas(1){};
|
||||
|
||||
~ReplicaRequest(){};
|
||||
|
||||
/**
|
||||
* This function updates the number of replicas of the record and decrement
|
||||
* the number of servers left to reach majority consensus. If it reaches 0,
|
||||
* the client is notified
|
||||
* @return number of replicas for this log
|
||||
*/
|
||||
int inc_replicas()
|
||||
{
|
||||
int __replicas;
|
||||
|
||||
_replicas++;
|
||||
|
||||
if ( _to_commit > 0 )
|
||||
{
|
||||
_to_commit--;
|
||||
}
|
||||
|
||||
__replicas = _replicas;
|
||||
|
||||
if ( _to_commit == 0 )
|
||||
{
|
||||
result = true;
|
||||
timeout = false;
|
||||
|
||||
notify();
|
||||
}
|
||||
|
||||
return __replicas;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Class access methods */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
int index()
|
||||
{
|
||||
return _index;
|
||||
}
|
||||
|
||||
int replicas()
|
||||
{
|
||||
return _replicas;
|
||||
}
|
||||
|
||||
int to_commit()
|
||||
{
|
||||
return _to_commit;
|
||||
}
|
||||
|
||||
void to_commit(int c)
|
||||
{
|
||||
_to_commit = c;
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* Index for this log entry
|
||||
*/
|
||||
unsigned int _index;
|
||||
|
||||
/**
|
||||
* Remaining number of servers that need to replicate this record to commit
|
||||
* it. Initialized to ( Number_Servers - 1 ) / 2
|
||||
*/
|
||||
int _to_commit;
|
||||
|
||||
/**
|
||||
* Total number of replicas for this entry
|
||||
*/
|
||||
int _replicas;
|
||||
};
|
||||
|
||||
#endif /*REPLICA_REQUEST_H_*/
|
||||
|
158
include/ReplicaThread.h
Normal file
158
include/ReplicaThread.h
Normal file
@ -0,0 +1,158 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2016, 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 REPLICA_THREAD_H_
|
||||
#define REPLICA_THREAD_H_
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
extern "C" void * replication_thread(void *arg);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
// Replication thread class. This is a generic replicaton thread, it is used
|
||||
// to send information to a given server (follower). This class needs to be
|
||||
// specialized to implement the specific replication logic.
|
||||
// -----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
class ReplicaThread
|
||||
{
|
||||
public:
|
||||
ReplicaThread(int _follower_id):follower_id(_follower_id), _finalize(false),
|
||||
_pending_requests(false), retry_timeout(2)
|
||||
{
|
||||
pthread_mutex_init(&mutex, 0);
|
||||
|
||||
pthread_cond_init(&cond, 0);
|
||||
};
|
||||
|
||||
|
||||
virtual ~ReplicaThread(){};
|
||||
|
||||
/**
|
||||
* Notify this replica thread that are new records in the log to replicate
|
||||
*/
|
||||
void add_request();
|
||||
|
||||
/**
|
||||
* Exists the replication thread
|
||||
*/
|
||||
void finalize();
|
||||
|
||||
/**
|
||||
* @return the ID of the thread
|
||||
*/
|
||||
pthread_t thread_id() const
|
||||
{
|
||||
return _thread_id;
|
||||
}
|
||||
protected:
|
||||
/**
|
||||
* Specific logic for the replicate process
|
||||
*/
|
||||
virtual int replicate() = 0;
|
||||
|
||||
/**
|
||||
* ID of follower to replicate state to
|
||||
*/
|
||||
int follower_id;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Wrapper function to handle the replication loop and timeouts. It makes
|
||||
* use of the virtual function to replicate to actually start the replica-
|
||||
* tion process.
|
||||
*/
|
||||
void do_replication();
|
||||
|
||||
/**
|
||||
* C linkage function to start the thread
|
||||
* @param arg pointer to "this"
|
||||
*/
|
||||
friend void * replication_thread(void *arg);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// pthread synchronization variables
|
||||
// -------------------------------------------------------------------------
|
||||
pthread_t _thread_id;
|
||||
|
||||
pthread_mutex_t mutex;
|
||||
|
||||
pthread_cond_t cond;
|
||||
|
||||
bool _finalize;
|
||||
|
||||
bool _pending_requests;
|
||||
|
||||
time_t retry_timeout;
|
||||
|
||||
static const time_t max_retry_timeout;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Raft replication thread, it implements the Ratf replication algorithm on
|
||||
// followers
|
||||
// -----------------------------------------------------------------------------
|
||||
class LogDB;
|
||||
class RaftManager;
|
||||
|
||||
class RaftReplicaThread : public ReplicaThread
|
||||
{
|
||||
public:
|
||||
RaftReplicaThread(int follower_id);
|
||||
|
||||
virtual ~RaftReplicaThread(){};
|
||||
|
||||
private:
|
||||
/**
|
||||
* Specific logic for the replicate process
|
||||
*/
|
||||
int replicate();
|
||||
|
||||
/**
|
||||
* Pointers to other components
|
||||
*/
|
||||
LogDB * logdb;
|
||||
|
||||
RaftManager * raftm;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Federation replica thread. It replicates SQL commands on zone slaves for
|
||||
// federated pools
|
||||
// -----------------------------------------------------------------------------
|
||||
class FedReplicaManager;
|
||||
|
||||
class FedReplicaThread : public ReplicaThread
|
||||
{
|
||||
public:
|
||||
FedReplicaThread(int zone_id);
|
||||
|
||||
virtual ~FedReplicaThread(){};
|
||||
|
||||
private:
|
||||
/**
|
||||
* Specific logic for the replicate process
|
||||
*/
|
||||
int replicate();
|
||||
|
||||
/**
|
||||
* Pointers to other components
|
||||
*/
|
||||
FedReplicaManager * frm;
|
||||
};
|
||||
|
||||
#endif
|
@ -58,6 +58,8 @@ public:
|
||||
RequestAttributes()
|
||||
{
|
||||
resp_obj = PoolObjectSQL::NONE;
|
||||
resp_id = -1;
|
||||
resp_msg = "";
|
||||
};
|
||||
|
||||
RequestAttributes(const RequestAttributes& ra)
|
||||
@ -173,6 +175,12 @@ protected:
|
||||
|
||||
static string format_str;
|
||||
|
||||
bool log_method_call; //Write method call and result to the log
|
||||
|
||||
bool leader_only; //Method can be only execute by leaders or solo servers
|
||||
|
||||
static const long long xmlrpc_timeout; //Timeout (ms) for request forwarding
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Class Constructors */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -183,6 +191,10 @@ protected:
|
||||
_help = help;
|
||||
|
||||
hidden_params.clear();
|
||||
|
||||
log_method_call = true;
|
||||
|
||||
leader_only = true;
|
||||
};
|
||||
|
||||
virtual ~Request(){};
|
||||
|
@ -60,7 +60,7 @@ class AclAddRule : public RequestManagerAcl
|
||||
{
|
||||
public:
|
||||
AclAddRule():
|
||||
RequestManagerAcl("AclAddRule",
|
||||
RequestManagerAcl("one.acl.addrule",
|
||||
"Adds a new ACL rule",
|
||||
"A:ssss")
|
||||
{};
|
||||
@ -78,7 +78,7 @@ class AclDelRule : public RequestManagerAcl
|
||||
{
|
||||
public:
|
||||
AclDelRule():
|
||||
RequestManagerAcl("AclDelRule",
|
||||
RequestManagerAcl("one.acl.delrule",
|
||||
"Deletes an existing ACL rule",
|
||||
"A:si")
|
||||
{};
|
||||
@ -96,7 +96,7 @@ class AclInfo: public RequestManagerAcl
|
||||
{
|
||||
public:
|
||||
AclInfo():
|
||||
RequestManagerAcl("AclInfo",
|
||||
RequestManagerAcl("one.acl.info",
|
||||
"Returns the ACL rule set",
|
||||
"A:s")
|
||||
{};
|
||||
|
@ -126,7 +126,7 @@ class VirtualMachineAllocate: public RequestManagerAllocate
|
||||
{
|
||||
public:
|
||||
VirtualMachineAllocate():
|
||||
RequestManagerAllocate("VirtualMachineAllocate",
|
||||
RequestManagerAllocate("one.vm.allocate",
|
||||
"Allocates a new virtual machine",
|
||||
"A:ssb",
|
||||
true)
|
||||
@ -162,7 +162,7 @@ class VirtualNetworkAllocate: public RequestManagerAllocate
|
||||
{
|
||||
public:
|
||||
VirtualNetworkAllocate():
|
||||
RequestManagerAllocate("VirtualNetworkAllocate",
|
||||
RequestManagerAllocate("one.vn.allocate",
|
||||
"Allocates a new virtual network",
|
||||
"A:ssi",
|
||||
true)
|
||||
@ -209,7 +209,7 @@ class ImageAllocate: public RequestManagerAllocate
|
||||
{
|
||||
public:
|
||||
ImageAllocate():
|
||||
RequestManagerAllocate("ImageAllocate",
|
||||
RequestManagerAllocate("one.image.allocate",
|
||||
"Allocates a new image",
|
||||
"A:ssi",
|
||||
true)
|
||||
@ -234,7 +234,7 @@ class TemplateAllocate : public RequestManagerAllocate
|
||||
{
|
||||
public:
|
||||
TemplateAllocate():
|
||||
RequestManagerAllocate("TemplateAllocate",
|
||||
RequestManagerAllocate("one.template.allocate",
|
||||
"Allocates a new virtual machine template",
|
||||
"A:ss",
|
||||
true)
|
||||
@ -270,7 +270,7 @@ class HostAllocate : public RequestManagerAllocate
|
||||
{
|
||||
public:
|
||||
HostAllocate():
|
||||
RequestManagerAllocate("HostAllocate",
|
||||
RequestManagerAllocate("one.host.allocate",
|
||||
"Allocates a new host",
|
||||
"A:ssssi",
|
||||
false)
|
||||
@ -312,7 +312,7 @@ class UserAllocate: public RequestManagerAllocate
|
||||
{
|
||||
public:
|
||||
UserAllocate():
|
||||
RequestManagerAllocate("UserAllocate",
|
||||
RequestManagerAllocate("one.user.allocate",
|
||||
"Returns user information",
|
||||
"A:ssssA",
|
||||
false)
|
||||
@ -346,7 +346,7 @@ class GroupAllocate: public RequestManagerAllocate
|
||||
{
|
||||
public:
|
||||
GroupAllocate():
|
||||
RequestManagerAllocate("GroupAllocate",
|
||||
RequestManagerAllocate("one.group.allocate",
|
||||
"Allocates a new group",
|
||||
"A:ss",
|
||||
false)
|
||||
@ -376,7 +376,7 @@ class DatastoreAllocate: public RequestManagerAllocate
|
||||
{
|
||||
public:
|
||||
DatastoreAllocate():
|
||||
RequestManagerAllocate("DatastoreAllocate",
|
||||
RequestManagerAllocate("one.datastore.allocate",
|
||||
"Allocates a new Datastore",
|
||||
"A:ssi",
|
||||
true)
|
||||
@ -423,7 +423,7 @@ class ClusterAllocate: public RequestManagerAllocate
|
||||
{
|
||||
public:
|
||||
ClusterAllocate():
|
||||
RequestManagerAllocate("ClusterAllocate",
|
||||
RequestManagerAllocate("one.cluster.allocate",
|
||||
"Allocates a new cluster",
|
||||
"A:ss",
|
||||
false)
|
||||
@ -448,7 +448,7 @@ class DocumentAllocate : public RequestManagerAllocate
|
||||
{
|
||||
public:
|
||||
DocumentAllocate():
|
||||
RequestManagerAllocate("DocumentAllocate",
|
||||
RequestManagerAllocate("one.document.allocate",
|
||||
"Allocates a new generic document",
|
||||
"A:ssi",
|
||||
true)
|
||||
@ -480,7 +480,7 @@ class ZoneAllocate: public RequestManagerAllocate
|
||||
{
|
||||
public:
|
||||
ZoneAllocate():
|
||||
RequestManagerAllocate("ZoneAllocate",
|
||||
RequestManagerAllocate("one.zone.allocate",
|
||||
"Allocates a new zone",
|
||||
"A:ss",
|
||||
true)
|
||||
@ -515,7 +515,7 @@ class SecurityGroupAllocate : public RequestManagerAllocate
|
||||
{
|
||||
public:
|
||||
SecurityGroupAllocate():
|
||||
RequestManagerAllocate("SecurityGroupAllocate",
|
||||
RequestManagerAllocate("one.secgroup.allocate",
|
||||
"Allocates a new security group",
|
||||
"A:ss",
|
||||
true)
|
||||
@ -547,7 +547,7 @@ class VdcAllocate : public RequestManagerAllocate
|
||||
{
|
||||
public:
|
||||
VdcAllocate():
|
||||
RequestManagerAllocate("VdcAllocate",
|
||||
RequestManagerAllocate("one.vdc.allocate",
|
||||
"Allocates a new VDC",
|
||||
"A:ss",
|
||||
true)
|
||||
@ -580,7 +580,7 @@ class VirtualRouterAllocate : public RequestManagerAllocate
|
||||
{
|
||||
public:
|
||||
VirtualRouterAllocate():
|
||||
RequestManagerAllocate("VirtualRouterAllocate",
|
||||
RequestManagerAllocate("one.vrouter.allocate",
|
||||
"Allocates a new virtual router",
|
||||
"A:ss",
|
||||
true)
|
||||
@ -616,7 +616,7 @@ class MarketPlaceAllocate : public RequestManagerAllocate
|
||||
{
|
||||
public:
|
||||
MarketPlaceAllocate():
|
||||
RequestManagerAllocate("MarketPlaceAllocate",
|
||||
RequestManagerAllocate("one.market.allocate",
|
||||
"Allocates a new marketplace",
|
||||
"A:ss",
|
||||
true)
|
||||
@ -648,7 +648,7 @@ class MarketPlaceAppAllocate : public RequestManagerAllocate
|
||||
{
|
||||
public:
|
||||
MarketPlaceAppAllocate():
|
||||
RequestManagerAllocate("MarketPlaceAppAllocate",
|
||||
RequestManagerAllocate("one.marketapp.allocate",
|
||||
"Allocates a new marketplace app",
|
||||
"A:ssi",
|
||||
true)
|
||||
@ -683,7 +683,7 @@ class VMGroupAllocate : public RequestManagerAllocate
|
||||
{
|
||||
public:
|
||||
VMGroupAllocate():
|
||||
RequestManagerAllocate("VMGroupAllocate",
|
||||
RequestManagerAllocate("one.vmgroup.allocate",
|
||||
"Allocates a new vm group",
|
||||
"A:ss",
|
||||
true)
|
||||
|
@ -25,7 +25,7 @@
|
||||
class RequestManagerAllocateDB: public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerAllocateDB(): Request("AllocateDB", "A:ss",
|
||||
RequestManagerAllocateDB(const string& name): Request(name, "A:ss",
|
||||
"Allocates a new object from its template representation")
|
||||
{
|
||||
auth_op = AuthRequest::MANAGE;
|
||||
@ -69,7 +69,7 @@ protected:
|
||||
class MarketPlaceAppAllocateDB: public RequestManagerAllocateDB
|
||||
{
|
||||
public:
|
||||
MarketPlaceAppAllocateDB(): RequestManagerAllocateDB()
|
||||
MarketPlaceAppAllocateDB():RequestManagerAllocateDB("one.marketapp.allocatedb")
|
||||
{
|
||||
auth_object = PoolObjectSQL::MARKETPLACEAPP;
|
||||
pool = Nebula::instance().get_apppool();
|
||||
@ -95,7 +95,7 @@ public:
|
||||
class MarketPlaceAllocateDB: public RequestManagerAllocateDB
|
||||
{
|
||||
public:
|
||||
MarketPlaceAllocateDB(): RequestManagerAllocateDB()
|
||||
MarketPlaceAllocateDB(): RequestManagerAllocateDB("one.market.allocatedb")
|
||||
{
|
||||
auth_object = PoolObjectSQL::MARKETPLACE;
|
||||
pool = Nebula::instance().get_marketpool();
|
||||
|
@ -52,7 +52,7 @@ class VirtualMachineChmod : public RequestManagerChmod
|
||||
{
|
||||
public:
|
||||
VirtualMachineChmod():
|
||||
RequestManagerChmod("VirtualMachineChmod",
|
||||
RequestManagerChmod("one.vm.chmod",
|
||||
"Changes permission bits of a virtual machine")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -70,7 +70,7 @@ class TemplateChmod : public RequestManagerChmod
|
||||
{
|
||||
public:
|
||||
TemplateChmod():
|
||||
RequestManagerChmod("TemplateChmod", "Changes permission bits of a "
|
||||
RequestManagerChmod("one.template.chmod", "Changes permission bits of a "
|
||||
"virtual machine template", "A:siiiiiiiiiib")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -102,7 +102,7 @@ class VirtualNetworkChmod: public RequestManagerChmod
|
||||
{
|
||||
public:
|
||||
VirtualNetworkChmod():
|
||||
RequestManagerChmod("VirtualNetworkChmod",
|
||||
RequestManagerChmod("one.vn.chmod",
|
||||
"Changes permission bits of a virtual network")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -120,7 +120,7 @@ class ImageChmod: public RequestManagerChmod
|
||||
{
|
||||
public:
|
||||
ImageChmod():
|
||||
RequestManagerChmod("ImageChmod",
|
||||
RequestManagerChmod("one.image.chmod",
|
||||
"Changes permission bits of an image")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -146,7 +146,7 @@ class DatastoreChmod: public RequestManagerChmod
|
||||
{
|
||||
public:
|
||||
DatastoreChmod():
|
||||
RequestManagerChmod("DatastoreChmod",
|
||||
RequestManagerChmod("one.datastore.chmod",
|
||||
"Changes permission bits of a datastore")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -164,7 +164,7 @@ class DocumentChmod : public RequestManagerChmod
|
||||
{
|
||||
public:
|
||||
DocumentChmod():
|
||||
RequestManagerChmod("DocumentChmod",
|
||||
RequestManagerChmod("one.document.chmod",
|
||||
"Changes permission bits of a generic document")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -182,7 +182,7 @@ class SecurityGroupChmod: public RequestManagerChmod
|
||||
{
|
||||
public:
|
||||
SecurityGroupChmod():
|
||||
RequestManagerChmod("SecurityGroupChmod",
|
||||
RequestManagerChmod("one.secgroup.chmod",
|
||||
"Changes permission bits of a security group")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -200,7 +200,7 @@ class VirtualRouterChmod: public RequestManagerChmod
|
||||
{
|
||||
public:
|
||||
VirtualRouterChmod():
|
||||
RequestManagerChmod("VirtualRouterChmod",
|
||||
RequestManagerChmod("one.vrouter.chmod",
|
||||
"Changes permission bits of a virtual router")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -218,7 +218,7 @@ class MarketPlaceChmod: public RequestManagerChmod
|
||||
{
|
||||
public:
|
||||
MarketPlaceChmod():
|
||||
RequestManagerChmod("MarketPlaceChmod",
|
||||
RequestManagerChmod("one.market.chmod",
|
||||
"Changes permission bits of a marketplace")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -236,7 +236,7 @@ class MarketPlaceAppChmod: public RequestManagerChmod
|
||||
{
|
||||
public:
|
||||
MarketPlaceAppChmod():
|
||||
RequestManagerChmod("MarketPlaceAppChmod",
|
||||
RequestManagerChmod("one.marketapp.chmod",
|
||||
"Changes permission bits of a marketplace app")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -254,7 +254,7 @@ class VMGroupChmod: public RequestManagerChmod
|
||||
{
|
||||
public:
|
||||
VMGroupChmod():
|
||||
RequestManagerChmod("VMGroupChmod",
|
||||
RequestManagerChmod("one.vmgroup.chmod",
|
||||
"Changes permission bits of a vm group")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
@ -80,7 +80,7 @@ class VirtualMachineChown : public RequestManagerChown
|
||||
{
|
||||
public:
|
||||
VirtualMachineChown():
|
||||
RequestManagerChown("VirtualMachineChown",
|
||||
RequestManagerChown("one.vm.chown",
|
||||
"Changes ownership of a virtual machine")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -108,7 +108,7 @@ class TemplateChown : public RequestManagerChown
|
||||
{
|
||||
public:
|
||||
TemplateChown():
|
||||
RequestManagerChown("TemplateChown",
|
||||
RequestManagerChown("one.template.chown",
|
||||
"Changes ownership of a virtual machine template")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -132,7 +132,7 @@ class VirtualNetworkChown: public RequestManagerChown
|
||||
{
|
||||
public:
|
||||
VirtualNetworkChown():
|
||||
RequestManagerChown("VirtualNetworkChown",
|
||||
RequestManagerChown("one.vn.chown",
|
||||
"Changes ownership of a virtual network")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -155,7 +155,7 @@ class ImageChown: public RequestManagerChown
|
||||
{
|
||||
public:
|
||||
ImageChown():
|
||||
RequestManagerChown("ImageChown",
|
||||
RequestManagerChown("one.image.chown",
|
||||
"Changes ownership of an image")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -178,7 +178,7 @@ class UserChown : public RequestManagerChown
|
||||
{
|
||||
public:
|
||||
UserChown():
|
||||
RequestManagerChown("UserChown",
|
||||
RequestManagerChown("one.user.chgrp",
|
||||
"Changes ownership of a user",
|
||||
"A:sii")
|
||||
{
|
||||
@ -207,7 +207,7 @@ class DatastoreChown: public RequestManagerChown
|
||||
{
|
||||
public:
|
||||
DatastoreChown():
|
||||
RequestManagerChown("Datastore",
|
||||
RequestManagerChown("one.datastore.chown",
|
||||
"Changes ownership of a datastore")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -230,7 +230,7 @@ class DocumentChown : public RequestManagerChown
|
||||
{
|
||||
public:
|
||||
DocumentChown():
|
||||
RequestManagerChown("DocumentChown",
|
||||
RequestManagerChown("one.document.chown",
|
||||
"Changes ownership of a generic document")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -253,7 +253,7 @@ class SecurityGroupChown: public RequestManagerChown
|
||||
{
|
||||
public:
|
||||
SecurityGroupChown():
|
||||
RequestManagerChown("SecurityGroupChown",
|
||||
RequestManagerChown("one.secgroup.chown",
|
||||
"Changes ownership of a security group")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -276,7 +276,7 @@ class VirtualRouterChown: public RequestManagerChown
|
||||
{
|
||||
public:
|
||||
VirtualRouterChown():
|
||||
RequestManagerChown("VirtualRouterChown",
|
||||
RequestManagerChown("one.vrouter.chown",
|
||||
"Changes ownership of a virtual router")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -299,7 +299,7 @@ class MarketPlaceChown: public RequestManagerChown
|
||||
{
|
||||
public:
|
||||
MarketPlaceChown():
|
||||
RequestManagerChown("MarketPlaceChown",
|
||||
RequestManagerChown("one.market.chown",
|
||||
"Changes ownership of a marketplace")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -322,7 +322,7 @@ class MarketPlaceAppChown: public RequestManagerChown
|
||||
{
|
||||
public:
|
||||
MarketPlaceAppChown():
|
||||
RequestManagerChown("MarketPlaceAppChown",
|
||||
RequestManagerChown("one.marketapp.chown",
|
||||
"Changes ownership of a marketplace app")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -345,7 +345,7 @@ class VMGroupChown: public RequestManagerChown
|
||||
{
|
||||
public:
|
||||
VMGroupChown():
|
||||
RequestManagerChown("VMGroupChown",
|
||||
RequestManagerChown("one.vmgroup.chown",
|
||||
"Changes ownership of a vm group")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
@ -79,8 +79,8 @@ class VMTemplateClone : public RequestManagerClone
|
||||
{
|
||||
public:
|
||||
VMTemplateClone():
|
||||
RequestManagerClone("VMTemplateClone","Clone a virtual machine template",
|
||||
"A:sisb")
|
||||
RequestManagerClone("one.template.clone",
|
||||
"Clone a virtual machine template", "A:sisb")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_tpool();
|
||||
@ -132,7 +132,7 @@ class DocumentClone : public RequestManagerClone
|
||||
{
|
||||
public:
|
||||
DocumentClone():
|
||||
RequestManagerClone("DocumentClone", "Clone existing document")
|
||||
RequestManagerClone("one.document.clone", "Clone existing document")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_docpool();
|
||||
@ -176,7 +176,7 @@ class SecurityGroupClone : public RequestManagerClone
|
||||
{
|
||||
public:
|
||||
SecurityGroupClone():
|
||||
RequestManagerClone("SecurityGroupClone", "Clone a security group")
|
||||
RequestManagerClone("one.secgroup.clone", "Clone a security group")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_secgrouppool();
|
||||
|
@ -144,7 +144,7 @@ class ClusterAddHost : public RequestManagerClusterHost
|
||||
{
|
||||
public:
|
||||
ClusterAddHost():
|
||||
RequestManagerClusterHost("ClusterAddHost",
|
||||
RequestManagerClusterHost("one.cluster.addhost",
|
||||
"Adds a host to the cluster",
|
||||
"A:sii"){};
|
||||
|
||||
@ -167,7 +167,7 @@ class ClusterDelHost : public RequestManagerClusterHost
|
||||
{
|
||||
public:
|
||||
ClusterDelHost():
|
||||
RequestManagerClusterHost("ClusterDelHost",
|
||||
RequestManagerClusterHost("one.cluster.delhost",
|
||||
"Deletes a host from its cluster",
|
||||
"A:sii"){};
|
||||
|
||||
@ -228,7 +228,7 @@ class ClusterAddDatastore : public RequestManagerClusterDatastore
|
||||
{
|
||||
public:
|
||||
ClusterAddDatastore():
|
||||
RequestManagerClusterDatastore("ClusterAddDatastore",
|
||||
RequestManagerClusterDatastore("one.cluster.adddatastore",
|
||||
"Adds a datastore to the cluster",
|
||||
"A:sii"){};
|
||||
|
||||
@ -252,7 +252,7 @@ class ClusterDelDatastore : public RequestManagerClusterDatastore
|
||||
{
|
||||
public:
|
||||
ClusterDelDatastore():
|
||||
RequestManagerClusterDatastore("ClusterDelDatastore",
|
||||
RequestManagerClusterDatastore("one.cluster.deldatastore",
|
||||
"Deletes a datastore from its cluster",
|
||||
"A:sii"){};
|
||||
|
||||
@ -313,7 +313,7 @@ class ClusterAddVNet : public RequestManagerClusterVNet
|
||||
{
|
||||
public:
|
||||
ClusterAddVNet():
|
||||
RequestManagerClusterVNet("ClusterAddVNet",
|
||||
RequestManagerClusterVNet("one.cluster.addvnet",
|
||||
"Adds a virtual network to the cluster",
|
||||
"A:sii"){};
|
||||
|
||||
@ -337,7 +337,7 @@ class ClusterDelVNet : public RequestManagerClusterVNet
|
||||
{
|
||||
public:
|
||||
ClusterDelVNet():
|
||||
RequestManagerClusterVNet("ClusterDelVNet",
|
||||
RequestManagerClusterVNet("one.cluster.delvnet",
|
||||
"Deletes a virtual network from its cluster",
|
||||
"A:sii"){};
|
||||
|
||||
|
@ -55,9 +55,8 @@ protected:
|
||||
class DatastoreEnable : public RequestManagerDatastore
|
||||
{
|
||||
public:
|
||||
DatastoreEnable():
|
||||
RequestManagerDatastore("DatastoreEnable", "Enables or disables an datastore",
|
||||
"A:sib"){};
|
||||
DatastoreEnable(): RequestManagerDatastore("one.datastore.enable",
|
||||
"Enables or disables an datastore", "A:sib"){};
|
||||
|
||||
~DatastoreEnable(){};
|
||||
|
||||
|
@ -92,7 +92,7 @@ class TemplateDelete : public RequestManagerDelete
|
||||
{
|
||||
public:
|
||||
TemplateDelete():
|
||||
RequestManagerDelete("TemplateDelete",
|
||||
RequestManagerDelete("one.template.delete",
|
||||
"A:sib"
|
||||
"Deletes a virtual machine template")
|
||||
{
|
||||
@ -120,7 +120,7 @@ class VirtualNetworkDelete: public RequestManagerDelete
|
||||
{
|
||||
public:
|
||||
VirtualNetworkDelete():
|
||||
RequestManagerDelete("VirtualNetworkDelete",
|
||||
RequestManagerDelete("one.vn.delete",
|
||||
"Deletes a virtual network")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -152,7 +152,7 @@ class ImageDelete: public RequestManagerDelete
|
||||
{
|
||||
public:
|
||||
ImageDelete():
|
||||
RequestManagerDelete("ImageDelete", "Deletes an image")
|
||||
RequestManagerDelete("one.image.delete", "Deletes an image")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_ipool();
|
||||
@ -178,7 +178,7 @@ class HostDelete : public RequestManagerDelete
|
||||
{
|
||||
public:
|
||||
HostDelete():
|
||||
RequestManagerDelete("HostDelete", "Deletes a host")
|
||||
RequestManagerDelete("one.host.delete", "Deletes a host")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_hpool();
|
||||
@ -214,7 +214,7 @@ class GroupDelete: public RequestManagerDelete
|
||||
{
|
||||
public:
|
||||
GroupDelete():
|
||||
RequestManagerDelete("GroupDelete", "Deletes a group")
|
||||
RequestManagerDelete("one.group.delete", "Deletes a group")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_gpool();
|
||||
@ -237,7 +237,7 @@ class UserDelete: public RequestManagerDelete
|
||||
{
|
||||
public:
|
||||
UserDelete():
|
||||
RequestManagerDelete("UserDelete", "Deletes a user")
|
||||
RequestManagerDelete("one.user.delete", "Deletes a user")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_upool();
|
||||
@ -263,7 +263,7 @@ class DatastoreDelete: public RequestManagerDelete
|
||||
{
|
||||
public:
|
||||
DatastoreDelete():
|
||||
RequestManagerDelete("DatastoreDelete", "Deletes a datastore")
|
||||
RequestManagerDelete("one.datastore.delete", "Deletes a datastore")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_dspool();
|
||||
@ -293,7 +293,7 @@ class ClusterDelete: public RequestManagerDelete
|
||||
{
|
||||
public:
|
||||
ClusterDelete():
|
||||
RequestManagerDelete("ClusterDelete", "Deletes a cluster")
|
||||
RequestManagerDelete("one.cluster.delete", "Deletes a cluster")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_clpool();
|
||||
@ -315,7 +315,7 @@ class DocumentDelete : public RequestManagerDelete
|
||||
{
|
||||
public:
|
||||
DocumentDelete():
|
||||
RequestManagerDelete("DocumentDelete",
|
||||
RequestManagerDelete("one.document.delete",
|
||||
"Deletes a generic document")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -333,7 +333,7 @@ class ZoneDelete: public RequestManagerDelete
|
||||
{
|
||||
public:
|
||||
ZoneDelete():
|
||||
RequestManagerDelete("ZoneDelete", "Deletes a zone")
|
||||
RequestManagerDelete("one.zone.delete", "Deletes a zone")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_zonepool();
|
||||
@ -355,7 +355,7 @@ class SecurityGroupDelete : public RequestManagerDelete
|
||||
{
|
||||
public:
|
||||
SecurityGroupDelete():
|
||||
RequestManagerDelete("SecurityGroupDelete",
|
||||
RequestManagerDelete("one.secgroup.delete",
|
||||
"Deletes a security group")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -377,7 +377,7 @@ class VdcDelete: public RequestManagerDelete
|
||||
{
|
||||
public:
|
||||
VdcDelete():
|
||||
RequestManagerDelete("VdcDelete", "Deletes a VDC")
|
||||
RequestManagerDelete("one.vdc.delete", "Deletes a VDC")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_vdcpool();
|
||||
@ -395,7 +395,7 @@ class VirtualRouterDelete : public RequestManagerDelete
|
||||
{
|
||||
public:
|
||||
VirtualRouterDelete():
|
||||
RequestManagerDelete("VirtualRouterDelete",
|
||||
RequestManagerDelete("one.vrouter.delete",
|
||||
"Deletes a virtual router")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -416,7 +416,7 @@ class MarketPlaceDelete : public RequestManagerDelete
|
||||
{
|
||||
public:
|
||||
MarketPlaceDelete():
|
||||
RequestManagerDelete("MarketPlaceDelete",
|
||||
RequestManagerDelete("one.market.delete",
|
||||
"Deletes a marketplace")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -438,7 +438,7 @@ class MarketPlaceAppDelete : public RequestManagerDelete
|
||||
{
|
||||
public:
|
||||
MarketPlaceAppDelete():
|
||||
RequestManagerDelete("MarketPlaceAppDelete",
|
||||
RequestManagerDelete("one.marketapp.delete",
|
||||
"Deletes a marketplace app")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -460,7 +460,7 @@ class VMGroupDelete : public RequestManagerDelete
|
||||
{
|
||||
public:
|
||||
VMGroupDelete():
|
||||
RequestManagerDelete("VMGroupDelete",
|
||||
RequestManagerDelete("one.vmgroup.delete",
|
||||
"Deletes a vm group")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
@ -25,7 +25,7 @@
|
||||
class RequestManagerDropDB: public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerDropDB(): Request("DropDB", "A:si",
|
||||
RequestManagerDropDB(const string& name): Request(name, "A:si",
|
||||
"Drops an object from DB")
|
||||
{
|
||||
auth_op = AuthRequest::MANAGE;
|
||||
@ -75,7 +75,7 @@ protected:
|
||||
class MarketPlaceAppDropDB : public RequestManagerDropDB
|
||||
{
|
||||
public:
|
||||
MarketPlaceAppDropDB():RequestManagerDropDB()
|
||||
MarketPlaceAppDropDB():RequestManagerDropDB("one.marketapp.dropdb")
|
||||
{
|
||||
auth_object = PoolObjectSQL::MARKETPLACEAPP;
|
||||
pool = Nebula::instance().get_apppool();
|
||||
|
@ -53,7 +53,7 @@ class GroupSetQuota : public RequestManagerGroup
|
||||
{
|
||||
public:
|
||||
GroupSetQuota():
|
||||
RequestManagerGroup("GroupSetQuota",
|
||||
RequestManagerGroup("one.group.quota",
|
||||
"Sets group quota limits",
|
||||
"A:sis")
|
||||
{
|
||||
@ -101,7 +101,7 @@ class GroupAddAdmin : public GroupEditAdmin
|
||||
{
|
||||
public:
|
||||
GroupAddAdmin():
|
||||
GroupEditAdmin( "GroupAddAdmin",
|
||||
GroupEditAdmin( "one.group.addadmin",
|
||||
"Adds a user to the group admin set",
|
||||
"A:sii"){};
|
||||
|
||||
@ -117,7 +117,7 @@ class GroupDelAdmin : public GroupEditAdmin
|
||||
{
|
||||
public:
|
||||
GroupDelAdmin():
|
||||
GroupEditAdmin( "GroupDelAdmin",
|
||||
GroupEditAdmin( "one.group.deladmin",
|
||||
"Removes a user from the group admin set",
|
||||
"A:sii"){};
|
||||
|
||||
|
@ -62,7 +62,7 @@ public:
|
||||
};
|
||||
|
||||
HostStatus():
|
||||
RequestManagerHost("HostStatus", "Sets the status of the host", "A:sii")
|
||||
RequestManagerHost("one.host.status", "Sets the status of the host", "A:sii")
|
||||
{
|
||||
auth_op = AuthRequest::ADMIN;
|
||||
};
|
||||
@ -80,7 +80,7 @@ class HostMonitoring : public RequestManagerHost
|
||||
{
|
||||
public:
|
||||
HostMonitoring():
|
||||
RequestManagerHost("HostMonitoring",
|
||||
RequestManagerHost("one.host.monitoring",
|
||||
"Returns the host monitoring records",
|
||||
"A:si")
|
||||
{
|
||||
|
@ -56,7 +56,7 @@ class ImageEnable : public RequestManagerImage
|
||||
{
|
||||
public:
|
||||
ImageEnable():
|
||||
RequestManagerImage("ImageEnable", "Enables or disables an image",
|
||||
RequestManagerImage("one.image.enable", "Enables or disables an image",
|
||||
"A:sib"){};
|
||||
|
||||
~ImageEnable(){};
|
||||
@ -74,7 +74,7 @@ class ImagePersistent : public RequestManagerImage
|
||||
{
|
||||
public:
|
||||
ImagePersistent():
|
||||
RequestManagerImage("ImagePersistent",
|
||||
RequestManagerImage("one.image.persistent",
|
||||
"Makes an image persistent or non-persistent",
|
||||
"A:sib"){};
|
||||
|
||||
@ -95,7 +95,7 @@ class ImageChangeType : public RequestManagerImage
|
||||
{
|
||||
public:
|
||||
ImageChangeType():
|
||||
RequestManagerImage("ImageChangeType", "Changes the type of an image",
|
||||
RequestManagerImage("one.image.chtype", "Changes the type of an image",
|
||||
"A:sis"){};
|
||||
|
||||
~ImageChangeType(){};
|
||||
@ -113,7 +113,7 @@ class ImageClone : public RequestManagerImage
|
||||
{
|
||||
public:
|
||||
ImageClone():
|
||||
RequestManagerImage("ImageClone", "Clones an existing image", "A:sis")
|
||||
RequestManagerImage("one.image.clone", "Clones an existing image", "A:sis")
|
||||
{
|
||||
auth_op = AuthRequest::USE;
|
||||
};
|
||||
@ -136,7 +136,7 @@ class ImageSnapshotRevert : public RequestManagerImage
|
||||
{
|
||||
public:
|
||||
ImageSnapshotRevert():
|
||||
RequestManagerImage("ImageSnapshotRevert",
|
||||
RequestManagerImage("one.image.snapshotrevert",
|
||||
"Reverts image state to a previous snapshot", "A:sii"){};
|
||||
|
||||
~ImageSnapshotRevert(){};
|
||||
@ -154,7 +154,7 @@ class ImageSnapshotFlatten : public RequestManagerImage
|
||||
{
|
||||
public:
|
||||
ImageSnapshotFlatten():
|
||||
RequestManagerImage("ImageSnapshotFlatten",
|
||||
RequestManagerImage("one.image.snapshotflatten",
|
||||
"Flattens the selected image snapshot", "A:sii"){};
|
||||
|
||||
~ImageSnapshotFlatten(){};
|
||||
@ -172,7 +172,7 @@ class ImageSnapshotDelete : public RequestManagerImage
|
||||
{
|
||||
public:
|
||||
ImageSnapshotDelete():
|
||||
RequestManagerImage("ImageSnapshotDelete",
|
||||
RequestManagerImage("one.image.snapshotdelete",
|
||||
"Deletes a snapshot from image", "A:sii"){};
|
||||
|
||||
~ImageSnapshotDelete(){};
|
||||
|
@ -34,6 +34,8 @@ protected:
|
||||
:Request(method_name, "A:si", help)
|
||||
{
|
||||
auth_op = AuthRequest::USE;
|
||||
|
||||
leader_only = false;
|
||||
};
|
||||
|
||||
~RequestManagerInfo(){};
|
||||
@ -59,7 +61,7 @@ class VirtualMachineInfo : public RequestManagerInfo
|
||||
{
|
||||
public:
|
||||
VirtualMachineInfo():
|
||||
RequestManagerInfo("VirtualMachineInfo",
|
||||
RequestManagerInfo("one.vm.info",
|
||||
"Returns virtual machine instance information")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -84,7 +86,7 @@ class TemplateInfo : public RequestManagerInfo
|
||||
{
|
||||
public:
|
||||
TemplateInfo():
|
||||
RequestManagerInfo("TemplateInfo",
|
||||
RequestManagerInfo("one.template.info",
|
||||
"Returns virtual machine template information")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -108,7 +110,7 @@ class VirtualNetworkInfo: public RequestManagerInfo
|
||||
{
|
||||
public:
|
||||
VirtualNetworkInfo():
|
||||
RequestManagerInfo("VirtualNetworkInfo",
|
||||
RequestManagerInfo("one.vn.info",
|
||||
"Returns virtual network information")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -130,7 +132,7 @@ class ImageInfo: public RequestManagerInfo
|
||||
{
|
||||
public:
|
||||
ImageInfo():
|
||||
RequestManagerInfo("ImageInfo",
|
||||
RequestManagerInfo("one.image.info",
|
||||
"Returns image information")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -149,7 +151,7 @@ class HostInfo : public RequestManagerInfo
|
||||
{
|
||||
public:
|
||||
HostInfo():
|
||||
RequestManagerInfo("HostInfo",
|
||||
RequestManagerInfo("one.host.info",
|
||||
"Returns host information")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -167,7 +169,7 @@ class GroupInfo: public RequestManagerInfo
|
||||
{
|
||||
public:
|
||||
GroupInfo():
|
||||
RequestManagerInfo("GroupInfo",
|
||||
RequestManagerInfo("one.group.info",
|
||||
"Returns group information")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -192,7 +194,7 @@ class UserInfo: public RequestManagerInfo
|
||||
{
|
||||
public:
|
||||
UserInfo():
|
||||
RequestManagerInfo("UserInfo",
|
||||
RequestManagerInfo("one.user.info",
|
||||
"Returns user information")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -217,7 +219,7 @@ class DatastoreInfo: public RequestManagerInfo
|
||||
{
|
||||
public:
|
||||
DatastoreInfo():
|
||||
RequestManagerInfo("DatastoreInfo",
|
||||
RequestManagerInfo("one.datastore.info",
|
||||
"Returns datastore information")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -235,7 +237,7 @@ class ClusterInfo: public RequestManagerInfo
|
||||
{
|
||||
public:
|
||||
ClusterInfo():
|
||||
RequestManagerInfo("ClusterInfo",
|
||||
RequestManagerInfo("one.cluster.info",
|
||||
"Returns cluster information")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -253,7 +255,7 @@ class DocumentInfo : public RequestManagerInfo
|
||||
{
|
||||
public:
|
||||
DocumentInfo():
|
||||
RequestManagerInfo("DocumentInfo",
|
||||
RequestManagerInfo("one.document.info",
|
||||
"Returns generic document information")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -271,7 +273,7 @@ class ZoneInfo: public RequestManagerInfo
|
||||
{
|
||||
public:
|
||||
ZoneInfo():
|
||||
RequestManagerInfo("ZoneInfo",
|
||||
RequestManagerInfo("one.zone.info",
|
||||
"Returns zone information")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -289,7 +291,7 @@ class SecurityGroupInfo : public RequestManagerInfo
|
||||
{
|
||||
public:
|
||||
SecurityGroupInfo():
|
||||
RequestManagerInfo("SecurityGroupInfo",
|
||||
RequestManagerInfo("one.secgroup.info",
|
||||
"Returns security group information")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -307,7 +309,7 @@ class VdcInfo: public RequestManagerInfo
|
||||
{
|
||||
public:
|
||||
VdcInfo():
|
||||
RequestManagerInfo("VdcInfo",
|
||||
RequestManagerInfo("one.vdc.info",
|
||||
"Returns VDC information")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -325,7 +327,7 @@ class VirtualRouterInfo : public RequestManagerInfo
|
||||
{
|
||||
public:
|
||||
VirtualRouterInfo():
|
||||
RequestManagerInfo("VirtualRouterInfo",
|
||||
RequestManagerInfo("one.vrouter.info",
|
||||
"Returns virtual router information")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -343,7 +345,7 @@ class MarketPlaceInfo : public RequestManagerInfo
|
||||
{
|
||||
public:
|
||||
MarketPlaceInfo():
|
||||
RequestManagerInfo("MarketPlaceInfo",
|
||||
RequestManagerInfo("one.market.info",
|
||||
"Returns marketplace information")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -361,7 +363,7 @@ class MarketPlaceAppInfo : public RequestManagerInfo
|
||||
{
|
||||
public:
|
||||
MarketPlaceAppInfo():
|
||||
RequestManagerInfo("MarketPlaceAppInfo",
|
||||
RequestManagerInfo("one.marketapp.info",
|
||||
"Returns marketplace app information")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -379,7 +381,7 @@ class VMGroupInfo : public RequestManagerInfo
|
||||
{
|
||||
public:
|
||||
VMGroupInfo():
|
||||
RequestManagerInfo("VMGroupInfo",
|
||||
RequestManagerInfo("one.vmgroup.info",
|
||||
"Returns vm group information")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
@ -76,7 +76,7 @@ class DocumentLock : public RequestManagerLock
|
||||
{
|
||||
public:
|
||||
DocumentLock():
|
||||
RequestManagerLock("DocumentLock",
|
||||
RequestManagerLock("one.document.lock",
|
||||
"Tries to acquire the object's lock")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -99,7 +99,7 @@ class DocumentUnlock : public RequestManagerUnlock
|
||||
{
|
||||
public:
|
||||
DocumentUnlock():
|
||||
RequestManagerUnlock("DocumentUnlock",
|
||||
RequestManagerUnlock("one.document.unlock",
|
||||
"Unlocks the object")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
@ -51,7 +51,7 @@ protected:
|
||||
class MarketPlaceAppEnable : public RequestManagerMarketPlaceApp
|
||||
{
|
||||
public:
|
||||
MarketPlaceAppEnable(): RequestManagerMarketPlaceApp("MarketPlaceAppEnable",
|
||||
MarketPlaceAppEnable(): RequestManagerMarketPlaceApp("one.marketapp.enable",
|
||||
"Enables or disables a marketplace app", "A:sib"){};
|
||||
|
||||
~MarketPlaceAppEnable(){};
|
||||
|
@ -63,7 +63,9 @@ protected:
|
||||
const string& help,
|
||||
const string& signature)
|
||||
:Request(method_name,signature,help)
|
||||
{};
|
||||
{
|
||||
leader_only = false;
|
||||
};
|
||||
|
||||
~RequestManagerPoolInfoFilter(){};
|
||||
|
||||
@ -109,7 +111,7 @@ public:
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
VirtualMachinePoolInfo():
|
||||
RequestManagerPoolInfoFilter("VirtualMachinePoolInfo",
|
||||
RequestManagerPoolInfoFilter("one.vmpool.info",
|
||||
"Returns the virtual machine instances pool",
|
||||
"A:siiii")
|
||||
{
|
||||
@ -134,7 +136,7 @@ class VirtualMachinePoolAccounting : public RequestManagerPoolInfoFilter
|
||||
public:
|
||||
|
||||
VirtualMachinePoolAccounting():
|
||||
RequestManagerPoolInfoFilter("VirtualMachinePoolAccounting",
|
||||
RequestManagerPoolInfoFilter("one.vmpool.accounting",
|
||||
"Returns the virtual machine history records",
|
||||
"A:siii")
|
||||
{
|
||||
@ -159,7 +161,7 @@ class VirtualMachinePoolShowback : public RequestManagerPoolInfoFilter
|
||||
public:
|
||||
|
||||
VirtualMachinePoolShowback():
|
||||
RequestManagerPoolInfoFilter("VirtualMachinePoolShowback",
|
||||
RequestManagerPoolInfoFilter("one.vmpool.showback",
|
||||
"Returns the virtual machine showback records",
|
||||
"A:siiiii")
|
||||
{
|
||||
@ -184,7 +186,7 @@ class VirtualMachinePoolMonitoring : public RequestManagerPoolInfoFilter
|
||||
public:
|
||||
|
||||
VirtualMachinePoolMonitoring():
|
||||
RequestManagerPoolInfoFilter("VirtualMachinePoolMonitoring",
|
||||
RequestManagerPoolInfoFilter("one.vmpool.monitoring",
|
||||
"Returns the virtual machine monitoring records",
|
||||
"A:si")
|
||||
{
|
||||
@ -208,7 +210,7 @@ class TemplatePoolInfo : public RequestManagerPoolInfoFilter
|
||||
{
|
||||
public:
|
||||
TemplatePoolInfo():
|
||||
RequestManagerPoolInfoFilter("TemplatePoolInfo",
|
||||
RequestManagerPoolInfoFilter("one.templatepool.info",
|
||||
"Returns the virtual machine template pool",
|
||||
"A:siii")
|
||||
{
|
||||
@ -227,7 +229,7 @@ class VirtualNetworkPoolInfo: public RequestManagerPoolInfoFilter
|
||||
{
|
||||
public:
|
||||
VirtualNetworkPoolInfo():
|
||||
RequestManagerPoolInfoFilter("VirtualNetworkPoolInfo",
|
||||
RequestManagerPoolInfoFilter("one.vnpool.info",
|
||||
"Returns the virtual network pool",
|
||||
"A:siii")
|
||||
{
|
||||
@ -249,7 +251,7 @@ class ImagePoolInfo: public RequestManagerPoolInfoFilter
|
||||
{
|
||||
public:
|
||||
ImagePoolInfo():
|
||||
RequestManagerPoolInfoFilter("ImagePoolInfo",
|
||||
RequestManagerPoolInfoFilter("one.imagepool.info",
|
||||
"Returns the image pool",
|
||||
"A:siii")
|
||||
{
|
||||
@ -268,7 +270,7 @@ class HostPoolInfo : public RequestManagerPoolInfoFilter
|
||||
{
|
||||
public:
|
||||
HostPoolInfo():
|
||||
RequestManagerPoolInfoFilter("HostPoolInfo",
|
||||
RequestManagerPoolInfoFilter("one.hostpool.info",
|
||||
"Returns the host pool",
|
||||
"A:s")
|
||||
{
|
||||
@ -293,7 +295,7 @@ class HostPoolMonitoring : public RequestManagerPoolInfoFilter
|
||||
public:
|
||||
|
||||
HostPoolMonitoring():
|
||||
RequestManagerPoolInfoFilter("HostPoolMonitoring",
|
||||
RequestManagerPoolInfoFilter("one.hostpool.monitoring",
|
||||
"Returns the host monitoring records",
|
||||
"A:s")
|
||||
{
|
||||
@ -317,7 +319,7 @@ class GroupPoolInfo: public RequestManagerPoolInfoFilter
|
||||
{
|
||||
public:
|
||||
GroupPoolInfo():
|
||||
RequestManagerPoolInfoFilter("GroupPoolInfo",
|
||||
RequestManagerPoolInfoFilter("one.grouppool.info",
|
||||
"Returns the group pool",
|
||||
"A:s")
|
||||
{
|
||||
@ -341,7 +343,7 @@ class UserPoolInfo: public RequestManagerPoolInfoFilter
|
||||
{
|
||||
public:
|
||||
UserPoolInfo():
|
||||
RequestManagerPoolInfoFilter("UserPoolInfo",
|
||||
RequestManagerPoolInfoFilter("one.userpool.info",
|
||||
"Returns the user pool",
|
||||
"A:s")
|
||||
{
|
||||
@ -365,7 +367,7 @@ class DatastorePoolInfo: public RequestManagerPoolInfoFilter
|
||||
{
|
||||
public:
|
||||
DatastorePoolInfo():
|
||||
RequestManagerPoolInfoFilter("DatastorePoolInfo",
|
||||
RequestManagerPoolInfoFilter("one.datastorepool.info",
|
||||
"Returns the datastore pool",
|
||||
"A:s")
|
||||
{
|
||||
@ -389,7 +391,7 @@ class ClusterPoolInfo: public RequestManagerPoolInfoFilter
|
||||
{
|
||||
public:
|
||||
ClusterPoolInfo():
|
||||
RequestManagerPoolInfoFilter("ClusterPoolInfo",
|
||||
RequestManagerPoolInfoFilter("one.clusterpool.info",
|
||||
"Returns the cluster pool",
|
||||
"A:s")
|
||||
{
|
||||
@ -413,7 +415,7 @@ class DocumentPoolInfo : public RequestManagerPoolInfoFilter
|
||||
{
|
||||
public:
|
||||
DocumentPoolInfo():
|
||||
RequestManagerPoolInfoFilter("DocumentPoolInfo",
|
||||
RequestManagerPoolInfoFilter("one.documentpool.info",
|
||||
"Returns the generic document pool",
|
||||
"A:siiii")
|
||||
{
|
||||
@ -437,7 +439,7 @@ class ZonePoolInfo : public RequestManagerPoolInfoFilter
|
||||
{
|
||||
public:
|
||||
ZonePoolInfo():
|
||||
RequestManagerPoolInfoFilter("ZonePoolInfo",
|
||||
RequestManagerPoolInfoFilter("one.zonepool.info",
|
||||
"Returns the zone pool",
|
||||
"A:s")
|
||||
{
|
||||
@ -461,7 +463,7 @@ class SecurityGroupPoolInfo : public RequestManagerPoolInfoFilter
|
||||
{
|
||||
public:
|
||||
SecurityGroupPoolInfo():
|
||||
RequestManagerPoolInfoFilter("SecurityGroupPoolInfo",
|
||||
RequestManagerPoolInfoFilter("one.secgrouppool.info",
|
||||
"Returns the security group pool",
|
||||
"A:siii")
|
||||
{
|
||||
@ -480,7 +482,7 @@ class VdcPoolInfo : public RequestManagerPoolInfoFilter
|
||||
{
|
||||
public:
|
||||
VdcPoolInfo():
|
||||
RequestManagerPoolInfoFilter("VdcPoolInfo",
|
||||
RequestManagerPoolInfoFilter("one.vdcpool.info",
|
||||
"Returns the VDC pool",
|
||||
"A:s")
|
||||
{
|
||||
@ -501,7 +503,7 @@ class VirtualRouterPoolInfo : public RequestManagerPoolInfoFilter
|
||||
{
|
||||
public:
|
||||
VirtualRouterPoolInfo():
|
||||
RequestManagerPoolInfoFilter("VirtualRouterPoolInfo",
|
||||
RequestManagerPoolInfoFilter("one.vrouterpool.info",
|
||||
"Returns the virtual router pool",
|
||||
"A:siii")
|
||||
{
|
||||
@ -520,7 +522,7 @@ class MarketPlacePoolInfo : public RequestManagerPoolInfoFilter
|
||||
{
|
||||
public:
|
||||
MarketPlacePoolInfo():
|
||||
RequestManagerPoolInfoFilter("MarketPlacePoolInfo",
|
||||
RequestManagerPoolInfoFilter("one.marketpool.info",
|
||||
"Returns the marketplace pool",
|
||||
"A:s")
|
||||
{
|
||||
@ -541,7 +543,7 @@ class MarketPlaceAppPoolInfo : public RequestManagerPoolInfoFilter
|
||||
{
|
||||
public:
|
||||
MarketPlaceAppPoolInfo():
|
||||
RequestManagerPoolInfoFilter("MarketPlacePoolInfo",
|
||||
RequestManagerPoolInfoFilter("one.marketapppool.info",
|
||||
"Returns the market place pool",
|
||||
"A:siii")
|
||||
{
|
||||
@ -560,7 +562,7 @@ class VMGroupPoolInfo : public RequestManagerPoolInfoFilter
|
||||
{
|
||||
public:
|
||||
VMGroupPoolInfo():
|
||||
RequestManagerPoolInfoFilter("VMGroupPoolInfo",
|
||||
RequestManagerPoolInfoFilter("one.vmgrouppool.info",
|
||||
"Returns the vm group pool",
|
||||
"A:siii")
|
||||
{
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
RequestManagerProxy(string _method): Request("RequestManagerProxy", "?",
|
||||
"Forwards the request to another OpenNebula"), method(_method)
|
||||
{
|
||||
method_name = ("RequestManagerProxy." + method);
|
||||
method_name = method;
|
||||
};
|
||||
|
||||
~RequestManagerProxy(){};
|
||||
|
@ -109,7 +109,7 @@ class VirtualMachineRename : public RequestManagerRename
|
||||
{
|
||||
public:
|
||||
VirtualMachineRename():
|
||||
RequestManagerRename("VirtualMachineRename","Renames a virtual machine")
|
||||
RequestManagerRename("one.vm.rename","Renames a virtual machine")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_vmpool();
|
||||
@ -128,7 +128,7 @@ class TemplateRename : public RequestManagerRename
|
||||
{
|
||||
public:
|
||||
TemplateRename():
|
||||
RequestManagerRename("TemplateRename",
|
||||
RequestManagerRename("one.template.rename",
|
||||
"Renames a virtual machine template")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -152,7 +152,7 @@ class VirtualNetworkRename: public RequestManagerRename
|
||||
{
|
||||
public:
|
||||
VirtualNetworkRename():
|
||||
RequestManagerRename("VirtualNetworkRename","Renames a virtual network")
|
||||
RequestManagerRename("one.vn.rename","Renames a virtual network")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_vnpool();
|
||||
@ -174,7 +174,7 @@ class ImageRename: public RequestManagerRename
|
||||
{
|
||||
public:
|
||||
ImageRename():
|
||||
RequestManagerRename("ImageRename", "Renames an image")
|
||||
RequestManagerRename("one.image.rename", "Renames an image")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_ipool();
|
||||
@ -196,7 +196,7 @@ class DocumentRename : public RequestManagerRename
|
||||
{
|
||||
public:
|
||||
DocumentRename():
|
||||
RequestManagerRename("DocumentRename", "Renames a generic document")
|
||||
RequestManagerRename("one.document.rename", "Renames a generic document")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_docpool();
|
||||
@ -213,7 +213,7 @@ class ClusterRename: public RequestManagerRename
|
||||
{
|
||||
public:
|
||||
ClusterRename():
|
||||
RequestManagerRename("ClusterRename", "Renames a cluster")
|
||||
RequestManagerRename("one.cluster.rename", "Renames a cluster")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_clpool();
|
||||
@ -237,7 +237,7 @@ class DatastoreRename: public RequestManagerRename
|
||||
{
|
||||
public:
|
||||
DatastoreRename():
|
||||
RequestManagerRename("DatastoreRename", "Renames a datastore")
|
||||
RequestManagerRename("one.datastore.rename", "Renames a datastore")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_dspool();
|
||||
@ -261,7 +261,7 @@ class HostRename: public RequestManagerRename
|
||||
{
|
||||
public:
|
||||
HostRename():
|
||||
RequestManagerRename("HostRename", "Renames a host")
|
||||
RequestManagerRename("one.host.rename", "Renames a host")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_hpool();
|
||||
@ -287,7 +287,7 @@ class ZoneRename : public RequestManagerRename
|
||||
{
|
||||
public:
|
||||
ZoneRename():
|
||||
RequestManagerRename("ZoneRename", "Renames a zone")
|
||||
RequestManagerRename("one.zone.rename", "Renames a zone")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_zonepool();
|
||||
@ -304,7 +304,7 @@ class SecurityGroupRename: public RequestManagerRename
|
||||
{
|
||||
public:
|
||||
SecurityGroupRename():
|
||||
RequestManagerRename("SecurityGroupRename", "Renames a security group")
|
||||
RequestManagerRename("one.secgroup.rename", "Renames a security group")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_secgrouppool();
|
||||
@ -326,7 +326,7 @@ class VdcRename : public RequestManagerRename
|
||||
{
|
||||
public:
|
||||
VdcRename():
|
||||
RequestManagerRename("VdcRename", "Renames a VDC")
|
||||
RequestManagerRename("one.vdc.rename", "Renames a VDC")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_vdcpool();
|
||||
@ -343,7 +343,7 @@ class VirtualRouterRename: public RequestManagerRename
|
||||
{
|
||||
public:
|
||||
VirtualRouterRename():
|
||||
RequestManagerRename("VirtualRouterRename", "Renames a virtual router")
|
||||
RequestManagerRename("one.vrouter.rename", "Renames a virtual router")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_vrouterpool();
|
||||
@ -365,7 +365,7 @@ class MarketPlaceRename: public RequestManagerRename
|
||||
{
|
||||
public:
|
||||
MarketPlaceRename():
|
||||
RequestManagerRename("MarketPlaceRename", "Renames a marketplace")
|
||||
RequestManagerRename("one.market.rename", "Renames a marketplace")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_marketpool();
|
||||
@ -389,7 +389,7 @@ class MarketPlaceAppRename: public RequestManagerRename
|
||||
{
|
||||
public:
|
||||
MarketPlaceAppRename():
|
||||
RequestManagerRename("MarketPlaceRename", "Renames a marketplace app")
|
||||
RequestManagerRename("one.marketapp.rename", "Renames a marketplace app")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_apppool();
|
||||
@ -411,7 +411,7 @@ class VMGroupRename: public RequestManagerRename
|
||||
{
|
||||
public:
|
||||
VMGroupRename():
|
||||
RequestManagerRename("VMGroupRename", "Renames a vm group")
|
||||
RequestManagerRename("one.vmgroup.rename", "Renames a vm group")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_vmgrouppool();
|
||||
|
@ -23,7 +23,7 @@
|
||||
class SecurityGroupCommit : public Request
|
||||
{
|
||||
public:
|
||||
SecurityGroupCommit() : Request("SecurityGroupCommit", "A:sib",
|
||||
SecurityGroupCommit() : Request("one.secgroup.commit", "A:sib",
|
||||
"Commit security group changes to VMs")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
@ -50,7 +50,7 @@ class SystemVersion : public RequestManagerSystem
|
||||
{
|
||||
public:
|
||||
SystemVersion():
|
||||
RequestManagerSystem("SystemVersion",
|
||||
RequestManagerSystem("one.system.version",
|
||||
"Returns the OpenNebula version",
|
||||
"A:s")
|
||||
{};
|
||||
@ -68,7 +68,7 @@ class SystemConfig : public RequestManagerSystem
|
||||
{
|
||||
public:
|
||||
SystemConfig():
|
||||
RequestManagerSystem("SystemConfig",
|
||||
RequestManagerSystem("one.system.config",
|
||||
"Returns the OpenNebula configuration",
|
||||
"A:s")
|
||||
{};
|
||||
@ -86,7 +86,7 @@ class UserQuotaInfo : public RequestManagerSystem
|
||||
{
|
||||
public:
|
||||
UserQuotaInfo():
|
||||
RequestManagerSystem("UserQuotaInfo",
|
||||
RequestManagerSystem("one.userquota.info",
|
||||
"Returns the default user quota limits",
|
||||
"A:s")
|
||||
{
|
||||
@ -106,7 +106,7 @@ class GroupQuotaInfo : public RequestManagerSystem
|
||||
{
|
||||
public:
|
||||
GroupQuotaInfo():
|
||||
RequestManagerSystem("GroupQuotaInfo",
|
||||
RequestManagerSystem("one.groupquota.info",
|
||||
"Returns the default group quota limits",
|
||||
"A:s")
|
||||
{
|
||||
@ -124,7 +124,7 @@ public:
|
||||
|
||||
class QuotaUpdate : public RequestManagerSystem
|
||||
{
|
||||
public:
|
||||
protected:
|
||||
QuotaUpdate(const string& method_name,
|
||||
const string& help):
|
||||
RequestManagerSystem(method_name,
|
||||
@ -151,7 +151,7 @@ class UserQuotaUpdate : public QuotaUpdate
|
||||
{
|
||||
public:
|
||||
UserQuotaUpdate():
|
||||
QuotaUpdate("UserQuotaUpdate",
|
||||
QuotaUpdate("one.userquota.update",
|
||||
"Updates the default user quota limits")
|
||||
{
|
||||
auth_op = AuthRequest::ADMIN;
|
||||
@ -169,7 +169,7 @@ class GroupQuotaUpdate : public QuotaUpdate
|
||||
{
|
||||
public:
|
||||
GroupQuotaUpdate():
|
||||
QuotaUpdate("GroupQuotaUpdate",
|
||||
QuotaUpdate("one.groupquota.update",
|
||||
"Updates the default group quota limits")
|
||||
{
|
||||
auth_op = AuthRequest::ADMIN;
|
||||
|
@ -25,7 +25,7 @@
|
||||
class RequestManagerUpdateDB: public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerUpdateDB(): Request("UpdateDB", "A:sis",
|
||||
RequestManagerUpdateDB(const string& name): Request(name, "A:sis",
|
||||
"Updates the DB object from a XML document")
|
||||
{
|
||||
auth_op = AuthRequest::MANAGE;
|
||||
@ -33,9 +33,10 @@ protected:
|
||||
|
||||
virtual ~RequestManagerUpdateDB(){};
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void request_execute(xmlrpc_c::paramList const& pl, RequestAttributes& att)
|
||||
virtual void request_execute(xmlrpc_c::paramList const& pl,
|
||||
RequestAttributes& att)
|
||||
{
|
||||
int oid = xmlrpc_c::value_int(pl.getInt(1));
|
||||
std::string xml = xmlrpc_c::value_string(pl.getString(2));
|
||||
@ -46,13 +47,30 @@ protected:
|
||||
return;
|
||||
}
|
||||
|
||||
ErrorCode ec = request_execute(oid, xml, att);
|
||||
|
||||
if ( ec == SUCCESS )
|
||||
{
|
||||
success_response(oid, att);
|
||||
}
|
||||
else
|
||||
{
|
||||
failure_response(ec, att);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ErrorCode request_execute(int oid, const std::string& xml,
|
||||
RequestAttributes& att)
|
||||
{
|
||||
PoolObjectSQL * object = pool->get(oid,true);
|
||||
|
||||
if ( object == 0 )
|
||||
{
|
||||
att.resp_id = oid;
|
||||
failure_response(NO_EXISTS, att);
|
||||
return;
|
||||
return NO_EXISTS;
|
||||
}
|
||||
|
||||
string old_xml;
|
||||
@ -62,39 +80,36 @@ protected:
|
||||
if ( object->from_xml(xml) != 0 )
|
||||
{
|
||||
object->from_xml(old_xml);
|
||||
object->unlock();
|
||||
|
||||
att.resp_msg = "Cannot update object from XML";
|
||||
failure_response(INTERNAL, att);
|
||||
|
||||
object->unlock();
|
||||
return;
|
||||
return INTERNAL;
|
||||
}
|
||||
|
||||
if ( object->get_oid() != oid )
|
||||
{
|
||||
object->from_xml(old_xml);
|
||||
object->unlock();
|
||||
|
||||
att.resp_msg = "Consistency check failed";
|
||||
failure_response(INTERNAL, att);
|
||||
|
||||
object->unlock();
|
||||
return;
|
||||
return INTERNAL;
|
||||
}
|
||||
|
||||
pool->update(object);
|
||||
|
||||
object->unlock();
|
||||
|
||||
success_response(oid, att);
|
||||
|
||||
return;
|
||||
return SUCCESS;
|
||||
}
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
class MarketPlaceAppUpdateDB : public RequestManagerUpdateDB
|
||||
{
|
||||
public:
|
||||
MarketPlaceAppUpdateDB():RequestManagerUpdateDB()
|
||||
MarketPlaceAppUpdateDB():RequestManagerUpdateDB("one.marketapp.updatedb")
|
||||
{
|
||||
auth_object = PoolObjectSQL::MARKETPLACEAPP;
|
||||
pool = Nebula::instance().get_apppool();
|
||||
@ -103,10 +118,12 @@ public:
|
||||
~MarketPlaceAppUpdateDB(){};
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
class MarketPlaceUpdateDB : public RequestManagerUpdateDB
|
||||
{
|
||||
public:
|
||||
MarketPlaceUpdateDB():RequestManagerUpdateDB()
|
||||
MarketPlaceUpdateDB():RequestManagerUpdateDB("one.market.updatedb")
|
||||
{
|
||||
auth_object = PoolObjectSQL::MARKETPLACE;
|
||||
pool = Nebula::instance().get_marketpool();
|
||||
@ -115,4 +132,45 @@ public:
|
||||
~MarketPlaceUpdateDB(){};
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
class ZoneUpdateDB : public RequestManagerUpdateDB
|
||||
{
|
||||
public:
|
||||
ZoneUpdateDB():RequestManagerUpdateDB("one.zone.updatedb")
|
||||
{
|
||||
auth_object = PoolObjectSQL::ZONE;
|
||||
pool = Nebula::instance().get_zonepool();
|
||||
}
|
||||
|
||||
~ZoneUpdateDB(){};
|
||||
|
||||
virtual void request_execute(xmlrpc_c::paramList const& pl,
|
||||
RequestAttributes& att)
|
||||
{
|
||||
int oid = xmlrpc_c::value_int(pl.getInt(1));
|
||||
std::string xml = xmlrpc_c::value_string(pl.getString(2));
|
||||
|
||||
if ( att.uid != UserPool::ONEADMIN_ID )
|
||||
{
|
||||
failure_response(AUTHORIZATION, att);
|
||||
return;
|
||||
}
|
||||
|
||||
ErrorCode ec = RequestManagerUpdateDB::request_execute(oid, xml, att);
|
||||
|
||||
if ( ec == SUCCESS )
|
||||
{
|
||||
std::vector<int> zids;
|
||||
success_response(oid, att);
|
||||
|
||||
Nebula::instance().get_frm()->update_zones(zids);
|
||||
}
|
||||
else
|
||||
{
|
||||
failure_response(ec, att);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* REQUEST_MANAGER_UPDATE_DB_H */
|
||||
|
@ -57,7 +57,7 @@ class TemplateUpdateTemplate: public RequestManagerUpdateTemplate
|
||||
{
|
||||
public:
|
||||
TemplateUpdateTemplate():
|
||||
RequestManagerUpdateTemplate("TemplateUpdateTemplate",
|
||||
RequestManagerUpdateTemplate("one.template.update",
|
||||
"Updates a virtual machine template")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -75,7 +75,7 @@ class VirtualMachineUpdateTemplate: public RequestManagerUpdateTemplate
|
||||
{
|
||||
public:
|
||||
VirtualMachineUpdateTemplate():
|
||||
RequestManagerUpdateTemplate("VirtualMachineUpdateTemplate",
|
||||
RequestManagerUpdateTemplate("one.vm.update",
|
||||
"Updates a virtual machine user template")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -95,7 +95,7 @@ class ImageUpdateTemplate: public RequestManagerUpdateTemplate
|
||||
{
|
||||
public:
|
||||
ImageUpdateTemplate():
|
||||
RequestManagerUpdateTemplate("ImageUpdateTemplate",
|
||||
RequestManagerUpdateTemplate("one.image.update",
|
||||
"Updates an image template")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -113,7 +113,7 @@ class HostUpdateTemplate : public RequestManagerUpdateTemplate
|
||||
{
|
||||
public:
|
||||
HostUpdateTemplate():
|
||||
RequestManagerUpdateTemplate("HostUpdateTemplate",
|
||||
RequestManagerUpdateTemplate("one.host.update",
|
||||
"Updates a host template")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -132,7 +132,7 @@ class VirtualNetworkUpdateTemplate : public RequestManagerUpdateTemplate
|
||||
{
|
||||
public:
|
||||
VirtualNetworkUpdateTemplate():
|
||||
RequestManagerUpdateTemplate("VirtualNetworkUpdateTemplate",
|
||||
RequestManagerUpdateTemplate("one.vn.update",
|
||||
"Updates a vnet template")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -151,7 +151,7 @@ class UserUpdateTemplate : public RequestManagerUpdateTemplate
|
||||
{
|
||||
public:
|
||||
UserUpdateTemplate():
|
||||
RequestManagerUpdateTemplate("UserUpdateTemplate",
|
||||
RequestManagerUpdateTemplate("one.user.update",
|
||||
"Updates a user template")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -169,7 +169,7 @@ class DatastoreUpdateTemplate : public RequestManagerUpdateTemplate
|
||||
{
|
||||
public:
|
||||
DatastoreUpdateTemplate():
|
||||
RequestManagerUpdateTemplate("DatastoreUpdateTemplate",
|
||||
RequestManagerUpdateTemplate("one.datastore.update",
|
||||
"Updates a datastore template")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -187,7 +187,7 @@ class DocumentUpdateTemplate : public RequestManagerUpdateTemplate
|
||||
{
|
||||
public:
|
||||
DocumentUpdateTemplate():
|
||||
RequestManagerUpdateTemplate("DocumentUpdateTemplate",
|
||||
RequestManagerUpdateTemplate("one.document.update",
|
||||
"Updates a document template")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -205,7 +205,7 @@ class ClusterUpdateTemplate : public RequestManagerUpdateTemplate
|
||||
{
|
||||
public:
|
||||
ClusterUpdateTemplate():
|
||||
RequestManagerUpdateTemplate("ClusterUpdateTemplate",
|
||||
RequestManagerUpdateTemplate("one.cluster.update",
|
||||
"Updates a cluster template")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -223,7 +223,7 @@ class ZoneUpdateTemplate : public RequestManagerUpdateTemplate
|
||||
{
|
||||
public:
|
||||
ZoneUpdateTemplate():
|
||||
RequestManagerUpdateTemplate("ZoneUpdateTemplate",
|
||||
RequestManagerUpdateTemplate("one.zone.update",
|
||||
"Updates a zone template")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -241,7 +241,7 @@ class GroupUpdateTemplate : public RequestManagerUpdateTemplate
|
||||
{
|
||||
public:
|
||||
GroupUpdateTemplate():
|
||||
RequestManagerUpdateTemplate("GroupUpdateTemplate",
|
||||
RequestManagerUpdateTemplate("one.group.update",
|
||||
"Updates a Group template")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -259,7 +259,7 @@ class SecurityGroupUpdateTemplate : public RequestManagerUpdateTemplate
|
||||
{
|
||||
public:
|
||||
SecurityGroupUpdateTemplate():
|
||||
RequestManagerUpdateTemplate("SecurityGroupUpdateTemplate",
|
||||
RequestManagerUpdateTemplate("one.secgroup.update",
|
||||
"Updates a security group template")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -277,7 +277,7 @@ class VdcUpdateTemplate : public RequestManagerUpdateTemplate
|
||||
{
|
||||
public:
|
||||
VdcUpdateTemplate():
|
||||
RequestManagerUpdateTemplate("VdcUpdateTemplate",
|
||||
RequestManagerUpdateTemplate("one.vdc.update",
|
||||
"Updates a VDC template")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -295,7 +295,7 @@ class VirtualRouterUpdateTemplate : public RequestManagerUpdateTemplate
|
||||
{
|
||||
public:
|
||||
VirtualRouterUpdateTemplate():
|
||||
RequestManagerUpdateTemplate("VirtualRouterUpdateTemplate",
|
||||
RequestManagerUpdateTemplate("one.vrouter.update",
|
||||
"Updates a virtual router template")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -313,7 +313,7 @@ class MarketPlaceUpdateTemplate : public RequestManagerUpdateTemplate
|
||||
{
|
||||
public:
|
||||
MarketPlaceUpdateTemplate():
|
||||
RequestManagerUpdateTemplate("MarketPlaceUpdateTemplate",
|
||||
RequestManagerUpdateTemplate("one.market.update",
|
||||
"Updates a marketplace template")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -331,7 +331,7 @@ class MarketPlaceAppUpdateTemplate : public RequestManagerUpdateTemplate
|
||||
{
|
||||
public:
|
||||
MarketPlaceAppUpdateTemplate():
|
||||
RequestManagerUpdateTemplate("MarketPlaceUpdateTemplate",
|
||||
RequestManagerUpdateTemplate("one.marketapp.update",
|
||||
"Updates a marketplace app template")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -349,7 +349,7 @@ class VMGroupUpdateTemplate : public RequestManagerUpdateTemplate
|
||||
{
|
||||
public:
|
||||
VMGroupUpdateTemplate():
|
||||
RequestManagerUpdateTemplate("VMGroupUpdateTemplate",
|
||||
RequestManagerUpdateTemplate("one.vmgroup.update",
|
||||
"Updates a vm group template")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
@ -63,7 +63,7 @@ class UserChangePassword : public RequestManagerUser
|
||||
{
|
||||
public:
|
||||
UserChangePassword():
|
||||
RequestManagerUser("UserChangePassword",
|
||||
RequestManagerUser("one.user.passwd",
|
||||
"Changes user's password",
|
||||
"A:sis")
|
||||
{
|
||||
@ -86,7 +86,7 @@ class UserChangeAuth: public RequestManagerUser
|
||||
{
|
||||
public:
|
||||
UserChangeAuth():
|
||||
RequestManagerUser("UserChangeAuth",
|
||||
RequestManagerUser("one.user.chauth",
|
||||
"Changes user's authentication driver",
|
||||
"A:siss")
|
||||
{
|
||||
@ -109,7 +109,7 @@ class UserSetQuota : public RequestManagerUser
|
||||
{
|
||||
public:
|
||||
UserSetQuota():
|
||||
RequestManagerUser("UserSetQuota",
|
||||
RequestManagerUser("one.user.quota",
|
||||
"Sets user quota limits",
|
||||
"A:sis")
|
||||
{
|
||||
@ -130,7 +130,8 @@ public:
|
||||
class UserLogin : public Request
|
||||
{
|
||||
public:
|
||||
UserLogin(): Request("UserLogin", "A:sssii", "Generates or sets a login token")
|
||||
UserLogin(): Request("one.user.login", "A:sssii",
|
||||
"Generates or sets a login token")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_upool();
|
||||
@ -194,7 +195,7 @@ class UserAddGroup : public UserEditGroup
|
||||
{
|
||||
public:
|
||||
UserAddGroup():
|
||||
UserEditGroup("UserAddGroup",
|
||||
UserEditGroup("one.user.addgroup",
|
||||
"Adds the user to a secondary group",
|
||||
"A:sii"){};
|
||||
|
||||
@ -214,7 +215,7 @@ class UserDelGroup : public UserEditGroup
|
||||
{
|
||||
public:
|
||||
UserDelGroup():
|
||||
UserEditGroup("UserDelGroup",
|
||||
UserEditGroup("one.user.delgroup",
|
||||
"Deletes the user from a secondary group",
|
||||
"A:sii"){};
|
||||
|
||||
|
@ -55,7 +55,7 @@ class VMTemplateInstantiate : public RequestManagerVMTemplate
|
||||
{
|
||||
public:
|
||||
VMTemplateInstantiate():
|
||||
RequestManagerVMTemplate("TemplateInstantiate", "Instantiates a new "
|
||||
RequestManagerVMTemplate("one.template.instantiate", "Instantiates a new "
|
||||
"virtual machine using a template", "A:sisbs")
|
||||
{
|
||||
auth_op = AuthRequest::USE;
|
||||
|
@ -64,11 +64,8 @@ protected:
|
||||
class VdcAddGroup : public VdcEditGroup
|
||||
{
|
||||
public:
|
||||
VdcAddGroup():
|
||||
VdcEditGroup( "VdcAddGroup",
|
||||
"Adds a group to the VDC",
|
||||
"A:sii",
|
||||
true){};
|
||||
VdcAddGroup():VdcEditGroup("one.vdc.addgroup", "Adds a group to the VDC",
|
||||
"A:sii", true){};
|
||||
|
||||
~VdcAddGroup(){};
|
||||
|
||||
@ -82,11 +79,8 @@ public:
|
||||
class VdcDelGroup : public VdcEditGroup
|
||||
{
|
||||
public:
|
||||
VdcDelGroup():
|
||||
VdcEditGroup( "VdcDelGroup",
|
||||
"Deletes a group from the VDC",
|
||||
"A:sii",
|
||||
false){};
|
||||
VdcDelGroup():VdcEditGroup("one.vdc.delgroup","Deletes a group from the VDC",
|
||||
"A:sii", false){};
|
||||
|
||||
~VdcDelGroup(){};
|
||||
|
||||
@ -133,8 +127,8 @@ protected:
|
||||
|
||||
PoolObjectSQL::ObjectType res_obj_type;
|
||||
|
||||
virtual int edit_resource(
|
||||
Vdc* vdc, int zone_id, int res_id, string& error_msg) = 0;
|
||||
virtual int edit_resource(Vdc* vdc, int zone_id, int res_id,
|
||||
string& error_msg) = 0;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -143,18 +137,13 @@ protected:
|
||||
class VdcAddCluster : public VdcEditResource
|
||||
{
|
||||
public:
|
||||
VdcAddCluster():
|
||||
VdcEditResource("VdcAddCluster",
|
||||
"Adds a cluster to the VDC",
|
||||
"A:siii",
|
||||
true,
|
||||
Nebula::instance().get_clpool(),
|
||||
PoolObjectSQL::CLUSTER){};
|
||||
VdcAddCluster():VdcEditResource("one.vdc.addcluster",
|
||||
"Adds a cluster to the VDC", "A:siii", true,
|
||||
Nebula::instance().get_clpool(), PoolObjectSQL::CLUSTER){};
|
||||
|
||||
~VdcAddCluster(){};
|
||||
|
||||
int edit_resource(
|
||||
Vdc* vdc, int zone_id, int res_id, string& error_msg);
|
||||
int edit_resource(Vdc* vdc, int zone_id, int res_id, string& error_msg);
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -163,18 +152,13 @@ public:
|
||||
class VdcDelCluster : public VdcEditResource
|
||||
{
|
||||
public:
|
||||
VdcDelCluster():
|
||||
VdcEditResource("VdcDelCluster",
|
||||
"Deletes a cluster from the VDC",
|
||||
"A:siii",
|
||||
false,
|
||||
Nebula::instance().get_clpool(),
|
||||
PoolObjectSQL::CLUSTER){};
|
||||
VdcDelCluster():VdcEditResource("one.vdc.delcluster",
|
||||
"Deletes a cluster from the VDC", "A:siii", false,
|
||||
Nebula::instance().get_clpool(), PoolObjectSQL::CLUSTER){};
|
||||
|
||||
~VdcDelCluster(){};
|
||||
|
||||
int edit_resource(
|
||||
Vdc* vdc, int zone_id, int res_id, string& error_msg);
|
||||
int edit_resource(Vdc* vdc, int zone_id, int res_id, string& error_msg);
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -183,18 +167,12 @@ public:
|
||||
class VdcAddHost : public VdcEditResource
|
||||
{
|
||||
public:
|
||||
VdcAddHost():
|
||||
VdcEditResource( "VdcAddHost",
|
||||
"Adds a host to the VDC",
|
||||
"A:siii",
|
||||
true,
|
||||
Nebula::instance().get_hpool(),
|
||||
PoolObjectSQL::HOST){};
|
||||
VdcAddHost(): VdcEditResource("one.vdc.addhost", "Adds a host to the VDC",
|
||||
"A:siii", true, Nebula::instance().get_hpool(), PoolObjectSQL::HOST){};
|
||||
|
||||
~VdcAddHost(){};
|
||||
|
||||
int edit_resource(
|
||||
Vdc* vdc, int zone_id, int res_id, string& error_msg);
|
||||
int edit_resource(Vdc* vdc, int zone_id, int res_id, string& error_msg);
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -203,18 +181,12 @@ public:
|
||||
class VdcDelHost : public VdcEditResource
|
||||
{
|
||||
public:
|
||||
VdcDelHost():
|
||||
VdcEditResource( "VdcDelHost",
|
||||
"Deletes a host from the VDC",
|
||||
"A:siii",
|
||||
false,
|
||||
Nebula::instance().get_hpool(),
|
||||
PoolObjectSQL::HOST){};
|
||||
VdcDelHost():VdcEditResource("one.vdc.delhost", "Deletes a host from the VDC",
|
||||
"A:siii", false, Nebula::instance().get_hpool(), PoolObjectSQL::HOST){};
|
||||
|
||||
~VdcDelHost(){};
|
||||
|
||||
int edit_resource(
|
||||
Vdc* vdc, int zone_id, int res_id, string& error_msg);
|
||||
int edit_resource(Vdc* vdc, int zone_id, int res_id, string& error_msg);
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -223,18 +195,13 @@ public:
|
||||
class VdcAddDatastore : public VdcEditResource
|
||||
{
|
||||
public:
|
||||
VdcAddDatastore():
|
||||
VdcEditResource( "VdcAddDatastore",
|
||||
"Adds a datastore to the VDC",
|
||||
"A:siii",
|
||||
true,
|
||||
Nebula::instance().get_dspool(),
|
||||
PoolObjectSQL::DATASTORE){};
|
||||
VdcAddDatastore():VdcEditResource("one.vdc.adddatastore",
|
||||
"Adds a datastore to the VDC", "A:siii", true,
|
||||
Nebula::instance().get_dspool(), PoolObjectSQL::DATASTORE){};
|
||||
|
||||
~VdcAddDatastore(){};
|
||||
|
||||
int edit_resource(
|
||||
Vdc* vdc, int zone_id, int res_id, string& error_msg);
|
||||
int edit_resource(Vdc* vdc, int zone_id, int res_id, string& error_msg);
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -243,18 +210,13 @@ public:
|
||||
class VdcDelDatastore : public VdcEditResource
|
||||
{
|
||||
public:
|
||||
VdcDelDatastore():
|
||||
VdcEditResource( "VdcDelDatastore",
|
||||
"Deletes a datastore from the VDC",
|
||||
"A:siii",
|
||||
false,
|
||||
Nebula::instance().get_dspool(),
|
||||
PoolObjectSQL::DATASTORE){};
|
||||
VdcDelDatastore():VdcEditResource("one.vdc.deldatastore",
|
||||
"Deletes a datastore from the VDC", "A:siii", false,
|
||||
Nebula::instance().get_dspool(), PoolObjectSQL::DATASTORE){};
|
||||
|
||||
~VdcDelDatastore(){};
|
||||
|
||||
int edit_resource(
|
||||
Vdc* vdc, int zone_id, int res_id, string& error_msg);
|
||||
int edit_resource(Vdc* vdc, int zone_id, int res_id, string& error_msg);
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -263,18 +225,13 @@ public:
|
||||
class VdcAddVNet : public VdcEditResource
|
||||
{
|
||||
public:
|
||||
VdcAddVNet():
|
||||
VdcEditResource( "VdcAddVNet",
|
||||
"Adds a virtual network to the VDC",
|
||||
"A:siii",
|
||||
true,
|
||||
Nebula::instance().get_vnpool(),
|
||||
PoolObjectSQL::NET){};
|
||||
VdcAddVNet():VdcEditResource("one.vdc.addvnet",
|
||||
"Adds a virtual network to the VDC", "A:siii", true,
|
||||
Nebula::instance().get_vnpool(), PoolObjectSQL::NET){};
|
||||
|
||||
~VdcAddVNet(){};
|
||||
|
||||
int edit_resource(
|
||||
Vdc* vdc, int zone_id, int res_id, string& error_msg);
|
||||
int edit_resource(Vdc* vdc, int zone_id, int res_id, string& error_msg);
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -283,22 +240,16 @@ public:
|
||||
class VdcDelVNet : public VdcEditResource
|
||||
{
|
||||
public:
|
||||
VdcDelVNet():
|
||||
VdcEditResource( "VdcDelVNet",
|
||||
"Deletes a virtual network from the VDC",
|
||||
"A:siii",
|
||||
false,
|
||||
Nebula::instance().get_vnpool(),
|
||||
PoolObjectSQL::NET){};
|
||||
VdcDelVNet(): VdcEditResource("one.vdc.delvnet",
|
||||
"Deletes a virtual network from the VDC", "A:siii", false,
|
||||
Nebula::instance().get_vnpool(), PoolObjectSQL::NET){};
|
||||
|
||||
~VdcDelVNet(){};
|
||||
|
||||
int edit_resource(
|
||||
Vdc* vdc, int zone_id, int res_id, string& error_msg);
|
||||
int edit_resource(Vdc* vdc, int zone_id, int res_id, string& error_msg);
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -115,7 +115,7 @@ public:
|
||||
//auth_op is MANAGE for all actions but "resched" and "unresched"
|
||||
//this is dynamically set for each request in the execute method
|
||||
VirtualMachineAction():
|
||||
RequestManagerVirtualMachine("VirtualMachineAction",
|
||||
RequestManagerVirtualMachine("one.vm.action",
|
||||
"Performs an action on a virtual machine",
|
||||
"A:ssi"){};
|
||||
~VirtualMachineAction(){};
|
||||
@ -131,7 +131,7 @@ class VirtualMachineDeploy : public RequestManagerVirtualMachine
|
||||
{
|
||||
public:
|
||||
VirtualMachineDeploy():
|
||||
RequestManagerVirtualMachine("VirtualMachineDeploy",
|
||||
RequestManagerVirtualMachine("one.vm.deploy",
|
||||
"Deploys a virtual machine",
|
||||
"A:siibi")
|
||||
{
|
||||
@ -151,7 +151,7 @@ class VirtualMachineMigrate : public RequestManagerVirtualMachine
|
||||
{
|
||||
public:
|
||||
VirtualMachineMigrate():
|
||||
RequestManagerVirtualMachine("VirtualMachineMigrate",
|
||||
RequestManagerVirtualMachine("one.vm.migrate",
|
||||
"Migrates a virtual machine",
|
||||
"A:siibbi"){
|
||||
auth_op = Nebula::instance().get_vm_auth_op(History::MIGRATE_ACTION);
|
||||
@ -170,7 +170,7 @@ class VirtualMachineDiskSaveas : public RequestManagerVirtualMachine
|
||||
{
|
||||
public:
|
||||
VirtualMachineDiskSaveas():
|
||||
RequestManagerVirtualMachine("VirtualMachineDiskSaveas",
|
||||
RequestManagerVirtualMachine("one.vm.disksaveas",
|
||||
"Save a disk from virtual machine as a new image",
|
||||
"A:siissi"){
|
||||
auth_op= Nebula::instance().get_vm_auth_op(History::DISK_SAVEAS_ACTION);
|
||||
@ -190,7 +190,7 @@ class VirtualMachineMonitoring : public RequestManagerVirtualMachine
|
||||
public:
|
||||
|
||||
VirtualMachineMonitoring():
|
||||
RequestManagerVirtualMachine("VirtualMachineMonitoring",
|
||||
RequestManagerVirtualMachine("one.vm.monitoring",
|
||||
"Returns the virtual machine monitoring records",
|
||||
"A:si"){
|
||||
auth_op = AuthRequest::USE;
|
||||
@ -209,7 +209,7 @@ class VirtualMachineAttach : public RequestManagerVirtualMachine
|
||||
{
|
||||
public:
|
||||
VirtualMachineAttach():
|
||||
RequestManagerVirtualMachine("VirtualMachineAttach",
|
||||
RequestManagerVirtualMachine("one.vm.attach",
|
||||
"Attaches a new disk to the virtual machine",
|
||||
"A:sis"){
|
||||
auth_op= Nebula::instance().get_vm_auth_op(History::DISK_ATTACH_ACTION);
|
||||
@ -228,7 +228,7 @@ class VirtualMachineDetach : public RequestManagerVirtualMachine
|
||||
{
|
||||
public:
|
||||
VirtualMachineDetach():
|
||||
RequestManagerVirtualMachine("VirtualMachineDetach",
|
||||
RequestManagerVirtualMachine("one.vm.detach",
|
||||
"Detaches a disk from a virtual machine",
|
||||
"A:sii"){
|
||||
//Attach & detach are set to the same auth op in OpenNebulaTemplate
|
||||
@ -248,7 +248,7 @@ class VirtualMachineAttachNic : public RequestManagerVirtualMachine
|
||||
{
|
||||
public:
|
||||
VirtualMachineAttachNic():
|
||||
RequestManagerVirtualMachine("VirtualMachineAttachNic",
|
||||
RequestManagerVirtualMachine("one.vm.attachnic",
|
||||
"Attaches a new NIC to the virtual machine",
|
||||
"A:sis"){
|
||||
auth_op = Nebula::instance().get_vm_auth_op(History::NIC_ATTACH_ACTION);
|
||||
@ -279,7 +279,7 @@ class VirtualMachineDetachNic : public RequestManagerVirtualMachine
|
||||
{
|
||||
public:
|
||||
VirtualMachineDetachNic():
|
||||
RequestManagerVirtualMachine("VirtualMachineDetachNic",
|
||||
RequestManagerVirtualMachine("one.vm.detachnic",
|
||||
"Detaches a NIC from a virtual machine",
|
||||
"A:sii"){
|
||||
//Attach & detach are set to the same auth op in OpenNebulaTemplate
|
||||
@ -308,7 +308,7 @@ class VirtualMachineResize : public RequestManagerVirtualMachine
|
||||
{
|
||||
public:
|
||||
VirtualMachineResize():
|
||||
RequestManagerVirtualMachine("VirtualMachineResize",
|
||||
RequestManagerVirtualMachine("one.vm.resize",
|
||||
"Changes the capacity of the virtual machine",
|
||||
"A:sisb"){
|
||||
auth_op = Nebula::instance().get_vm_auth_op(History::RESIZE_ACTION);
|
||||
@ -327,7 +327,7 @@ class VirtualMachineSnapshotCreate: public RequestManagerVirtualMachine
|
||||
{
|
||||
public:
|
||||
VirtualMachineSnapshotCreate():
|
||||
RequestManagerVirtualMachine("VirtualMachineSnapshotCreate",
|
||||
RequestManagerVirtualMachine("one.vm.snapshotcreate",
|
||||
"Creates a new virtual machine snapshot",
|
||||
"A:sis"){
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -349,7 +349,7 @@ class VirtualMachineSnapshotRevert: public RequestManagerVirtualMachine
|
||||
{
|
||||
public:
|
||||
VirtualMachineSnapshotRevert():
|
||||
RequestManagerVirtualMachine("VirtualMachineSnapshotRevert",
|
||||
RequestManagerVirtualMachine("one.vm.snapshotrevert",
|
||||
"Reverts a virtual machine to a snapshot",
|
||||
"A:sii"){
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -371,7 +371,7 @@ class VirtualMachineSnapshotDelete: public RequestManagerVirtualMachine
|
||||
{
|
||||
public:
|
||||
VirtualMachineSnapshotDelete():
|
||||
RequestManagerVirtualMachine("VirtualMachineSnapshotDelete",
|
||||
RequestManagerVirtualMachine("one.vm.snapshotdelete",
|
||||
"Deletes a virtual machine snapshot",
|
||||
"A:sii"){
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -393,7 +393,7 @@ class VirtualMachineRecover: public RequestManagerVirtualMachine
|
||||
{
|
||||
public:
|
||||
VirtualMachineRecover():
|
||||
RequestManagerVirtualMachine("VirtualMachineRecover",
|
||||
RequestManagerVirtualMachine("one.vm.recover",
|
||||
"Recovers a virtual machine",
|
||||
"A:sii"){};
|
||||
~VirtualMachineRecover(){};
|
||||
@ -410,7 +410,7 @@ class VirtualMachinePoolCalculateShowback : public RequestManagerVirtualMachine
|
||||
public:
|
||||
|
||||
VirtualMachinePoolCalculateShowback():
|
||||
RequestManagerVirtualMachine("VirtualMachinePoolCalculateShowback",
|
||||
RequestManagerVirtualMachine("one.vmpool.calculateshowback",
|
||||
"Processes all the history records, and stores the monthly cost"
|
||||
" for each VM", "A:sii")
|
||||
{
|
||||
@ -435,7 +435,7 @@ class VirtualMachineDiskSnapshotCreate: public RequestManagerVirtualMachine
|
||||
{
|
||||
public:
|
||||
VirtualMachineDiskSnapshotCreate():
|
||||
RequestManagerVirtualMachine("VirtualMachineDiskSnapshotCreate",
|
||||
RequestManagerVirtualMachine("one.vm.disksnapshotcreate",
|
||||
"Creates a new virtual machine disk snapshot",
|
||||
"A:siis"){
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -461,7 +461,7 @@ class VirtualMachineDiskSnapshotRevert: public RequestManagerVirtualMachine
|
||||
{
|
||||
public:
|
||||
VirtualMachineDiskSnapshotRevert():
|
||||
RequestManagerVirtualMachine("VirtualMachineDiskSnapshotRevert",
|
||||
RequestManagerVirtualMachine("one.vm.disksnapshotrevert",
|
||||
"Reverts disk state to a snapshot",
|
||||
"A:siii"){
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -483,7 +483,7 @@ class VirtualMachineDiskSnapshotDelete: public RequestManagerVirtualMachine
|
||||
{
|
||||
public:
|
||||
VirtualMachineDiskSnapshotDelete():
|
||||
RequestManagerVirtualMachine("VirtualMachineDiskSnapshotDelete",
|
||||
RequestManagerVirtualMachine("one.vm.disksnapshotdelete",
|
||||
"Deletes a disk snapshot",
|
||||
"A:siii"){
|
||||
Nebula& nd = Nebula::instance();
|
||||
@ -509,7 +509,7 @@ class VirtualMachineUpdateConf: public RequestManagerVirtualMachine
|
||||
{
|
||||
public:
|
||||
VirtualMachineUpdateConf():
|
||||
RequestManagerVirtualMachine("VirtualMachineUpdateConf",
|
||||
RequestManagerVirtualMachine("one.vm.updateconf",
|
||||
"Updates several configuration attributes of a VM",
|
||||
"A:sis"){
|
||||
auth_op = Nebula::instance().get_vm_auth_op(History::UPDATECONF_ACTION);
|
||||
@ -528,7 +528,7 @@ class VirtualMachineDiskResize : public RequestManagerVirtualMachine
|
||||
{
|
||||
public:
|
||||
VirtualMachineDiskResize():
|
||||
RequestManagerVirtualMachine("VirtualMachineDiskResize",
|
||||
RequestManagerVirtualMachine("one.vm.diskresize",
|
||||
"Resizes a disk from a virtual machine",
|
||||
"A:siis"){
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
@ -63,7 +63,7 @@ class VirtualNetworkAddAddressRange: public RequestManagerVirtualNetwork
|
||||
{
|
||||
public:
|
||||
VirtualNetworkAddAddressRange():
|
||||
RequestManagerVirtualNetwork("VirtualNetworkAddAddressRange",
|
||||
RequestManagerVirtualNetwork("one.vn.add_ar",
|
||||
"Adds address ranges to a virtual network")
|
||||
{
|
||||
auth_op = AuthRequest::ADMIN;
|
||||
@ -86,8 +86,10 @@ public:
|
||||
class VirtualNetworkRmAddressRange : public Request
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
VirtualNetworkRmAddressRange(
|
||||
const string& name = "VirtualNetworkRmAddressRange",
|
||||
const string& name = "one.vn.rm_ar",
|
||||
const string& sign = "A:sii",
|
||||
const string& help = "Removes an address range from a virtual network")
|
||||
: Request(name, sign, help)
|
||||
@ -112,7 +114,7 @@ class VirtualNetworkFreeAddressRange : public VirtualNetworkRmAddressRange
|
||||
{
|
||||
public:
|
||||
VirtualNetworkFreeAddressRange():VirtualNetworkRmAddressRange(
|
||||
"VirtualNetworkFreeAddressRange",
|
||||
"one.vn.free_ar",
|
||||
"A:sii",
|
||||
"Frees a reserved address range from a virtual network")
|
||||
{
|
||||
@ -139,7 +141,7 @@ class VirtualNetworkUpdateAddressRange: public RequestManagerVirtualNetwork
|
||||
{
|
||||
public:
|
||||
VirtualNetworkUpdateAddressRange():
|
||||
RequestManagerVirtualNetwork("VirtualNetworkUpdateAddressRange",
|
||||
RequestManagerVirtualNetwork("one.vn.update_ar",
|
||||
"Updates address ranges to a virtual network")
|
||||
{
|
||||
auth_op = AuthRequest::MANAGE;
|
||||
@ -170,7 +172,7 @@ class VirtualNetworkHold : public RequestManagerVirtualNetwork
|
||||
{
|
||||
public:
|
||||
VirtualNetworkHold():
|
||||
RequestManagerVirtualNetwork("VirtualNetworkHold",
|
||||
RequestManagerVirtualNetwork("one.vn.hold",
|
||||
"Holds a virtual network Lease as used"){};
|
||||
~VirtualNetworkHold(){};
|
||||
|
||||
@ -190,7 +192,7 @@ class VirtualNetworkRelease : public RequestManagerVirtualNetwork
|
||||
{
|
||||
public:
|
||||
VirtualNetworkRelease():
|
||||
RequestManagerVirtualNetwork("VirtualNetworkRelease",
|
||||
RequestManagerVirtualNetwork("one.vn.release",
|
||||
"Releases a virtual network Lease on hold"){};
|
||||
~VirtualNetworkRelease(){};
|
||||
|
||||
@ -209,7 +211,7 @@ public:
|
||||
class VirtualNetworkReserve: public Request
|
||||
{
|
||||
public:
|
||||
VirtualNetworkReserve():Request("VirtualNetworkReserve", "A:sis",
|
||||
VirtualNetworkReserve():Request("one.vn.reserve", "A:sis",
|
||||
"Reserve network addresses")
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
@ -54,10 +54,9 @@ protected:
|
||||
class VirtualRouterInstantiate : public RequestManagerVirtualRouter
|
||||
{
|
||||
public:
|
||||
VirtualRouterInstantiate():
|
||||
RequestManagerVirtualRouter("VirtualRouterInstantiate",
|
||||
"Instantiates a new virtual machine associated to a virtual router",
|
||||
"A:siiisbs")
|
||||
VirtualRouterInstantiate() : RequestManagerVirtualRouter(
|
||||
"one.vrouter.instantiate", "Instantiates a new virtual machine "
|
||||
"associated to a virtual router", "A:siiisbs")
|
||||
{
|
||||
auth_op = AuthRequest::MANAGE;
|
||||
};
|
||||
@ -75,10 +74,9 @@ public:
|
||||
class VirtualRouterAttachNic : public RequestManagerVirtualRouter
|
||||
{
|
||||
public:
|
||||
VirtualRouterAttachNic():
|
||||
RequestManagerVirtualRouter("VirtualRouterAttachNic",
|
||||
"Attaches a new NIC to the virtual router, and its virtual machines",
|
||||
"A:sis")
|
||||
VirtualRouterAttachNic():RequestManagerVirtualRouter("one.vrouter.attachnic",
|
||||
"Attaches a new NIC to the virtual router, and its virtual machines",
|
||||
"A:sis")
|
||||
{
|
||||
auth_op = AuthRequest::MANAGE;
|
||||
};
|
||||
@ -96,10 +94,8 @@ public:
|
||||
class VirtualRouterDetachNic : public RequestManagerVirtualRouter
|
||||
{
|
||||
public:
|
||||
VirtualRouterDetachNic():
|
||||
RequestManagerVirtualRouter("VirtualRouterDetachNic",
|
||||
"Detaches a NIC from a virtual router, and its virtual machines",
|
||||
"A:sii")
|
||||
VirtualRouterDetachNic():RequestManagerVirtualRouter("one.vrouter.detachnic",
|
||||
"Detaches a NIC from a virtual router, and its virtual machines","A:sii")
|
||||
{
|
||||
auth_op = AuthRequest::MANAGE;
|
||||
};
|
||||
|
159
include/RequestManagerZone.h
Normal file
159
include/RequestManagerZone.h
Normal file
@ -0,0 +1,159 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2016, 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 REQUEST_MANAGER_ZONE_H
|
||||
#define REQUEST_MANAGER_ZONE_H
|
||||
|
||||
#include "Request.h"
|
||||
#include "Nebula.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
class RequestManagerZone: public Request
|
||||
{
|
||||
protected:
|
||||
RequestManagerZone(const string& method_name,
|
||||
const string& help,
|
||||
const string& params)
|
||||
:Request(method_name,params,help)
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
pool = nd.get_zonepool();
|
||||
|
||||
auth_object = PoolObjectSQL::ZONE;
|
||||
auth_op = AuthRequest::ADMIN;
|
||||
};
|
||||
|
||||
~RequestManagerZone(){};
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
virtual void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att) = 0;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
class ZoneAddServer : public RequestManagerZone
|
||||
{
|
||||
public:
|
||||
ZoneAddServer():
|
||||
RequestManagerZone("one.zone.addserver", "Add a server to zone",
|
||||
"A:sis"){};
|
||||
|
||||
~ZoneAddServer(){};
|
||||
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att);
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
class ZoneDeleteServer : public RequestManagerZone
|
||||
{
|
||||
public:
|
||||
ZoneDeleteServer():
|
||||
RequestManagerZone("one.zone.delserver", "Delete a server from zone",
|
||||
"A:sii"){};
|
||||
|
||||
~ZoneDeleteServer(){};
|
||||
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att);
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
class ZoneReplicateLog : public RequestManagerZone
|
||||
{
|
||||
public:
|
||||
ZoneReplicateLog():
|
||||
RequestManagerZone("one.zone.replicate", "Replicate a log record",
|
||||
"A:siiiiiiis")
|
||||
{
|
||||
log_method_call = false;
|
||||
leader_only = false;
|
||||
};
|
||||
|
||||
~ZoneReplicateLog(){};
|
||||
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att);
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
class ZoneVoteRequest : public RequestManagerZone
|
||||
{
|
||||
public:
|
||||
ZoneVoteRequest(): RequestManagerZone("one.zone.voterequest",
|
||||
"Request vote from a candidate", "A:siiii")
|
||||
{
|
||||
leader_only = false;
|
||||
};
|
||||
|
||||
~ZoneVoteRequest(){};
|
||||
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att);
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
class ZoneRaftStatus : public RequestManagerZone
|
||||
{
|
||||
public:
|
||||
ZoneRaftStatus(): RequestManagerZone("one.zone.raftstatus",
|
||||
"Returns Raft status", "A:s")
|
||||
{
|
||||
leader_only = false;
|
||||
};
|
||||
|
||||
~ZoneRaftStatus(){};
|
||||
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att);
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
class ZoneReplicateFedLog : public RequestManagerZone
|
||||
{
|
||||
public:
|
||||
ZoneReplicateFedLog():
|
||||
RequestManagerZone("one.zone.fedreplicate", "Replicate a fed log record",
|
||||
"A:sis")
|
||||
{
|
||||
log_method_call = false;
|
||||
};
|
||||
|
||||
~ZoneReplicateFedLog(){};
|
||||
|
||||
void request_execute(xmlrpc_c::paramList const& _paramList,
|
||||
RequestAttributes& att);
|
||||
};
|
||||
|
||||
#endif
|
@ -217,7 +217,7 @@ private:
|
||||
{
|
||||
ostringstream oss(SecurityGroup::db_bootstrap);
|
||||
|
||||
return db->exec(oss);
|
||||
return db->exec_local_wr(oss);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -33,14 +33,33 @@ public:
|
||||
|
||||
virtual ~SqlDB(){};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Database Operations */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Performs a DB transaction
|
||||
* Operations on the database:
|
||||
* - exec_local_wr, perform modifications locally, without replication
|
||||
* - exec_rd, read only access to local DB
|
||||
* - exec_wr, update DB and replicate changes
|
||||
* @param sql_cmd the SQL command
|
||||
* @param callbak function to execute on each data returned
|
||||
* @param quiet True to log errors with DDEBUG level instead of ERROR
|
||||
* @return 0 on success
|
||||
*/
|
||||
virtual int exec(ostringstream& cmd, Callbackable* obj=0, bool quiet=false) = 0;
|
||||
virtual int exec_local_wr(ostringstream& cmd)
|
||||
{
|
||||
return exec(cmd, 0, false);
|
||||
}
|
||||
|
||||
virtual int exec_rd(ostringstream& cmd, Callbackable* obj)
|
||||
{
|
||||
return exec(cmd, obj, false);
|
||||
}
|
||||
|
||||
virtual int exec_wr(ostringstream& cmd)
|
||||
{
|
||||
return exec(cmd, 0, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns a legal SQL string that can be used in an SQL
|
||||
@ -63,6 +82,16 @@ public:
|
||||
* @return true if supported
|
||||
*/
|
||||
virtual bool multiple_values_support() = 0;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Performs a DB transaction
|
||||
* @param sql_cmd the SQL command
|
||||
* @param callbak function to execute on each data returned
|
||||
* @param quiet True to log errors with DDEBUG level instead of ERROR
|
||||
* @return 0 on success
|
||||
*/
|
||||
virtual int exec(ostringstream& cmd, Callbackable* obj, bool quiet) = 0;
|
||||
};
|
||||
|
||||
#endif /*SQL_DB_H_*/
|
||||
|
@ -49,16 +49,6 @@ public:
|
||||
|
||||
~SqliteDB();
|
||||
|
||||
/**
|
||||
* Wraps the sqlite3_exec function call, and locks the DB mutex.
|
||||
* @param sql_cmd the SQL command
|
||||
* @param callbak function to execute on each data returned, watch the
|
||||
* mutex you block in the callback.
|
||||
* @param arg to pass to the callback function
|
||||
* @return 0 on success
|
||||
*/
|
||||
int exec(ostringstream& cmd, Callbackable* obj=0, bool quiet=false);
|
||||
|
||||
/**
|
||||
* This function returns a legal SQL string that can be used in an SQL
|
||||
* statement.
|
||||
@ -81,6 +71,17 @@ public:
|
||||
*/
|
||||
bool multiple_values_support();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Wraps the sqlite3_exec function call, and locks the DB mutex.
|
||||
* @param sql_cmd the SQL command
|
||||
* @param callbak function to execute on each data returned, watch the
|
||||
* mutex you block in the callback.
|
||||
* @param arg to pass to the callback function
|
||||
* @return 0 on success
|
||||
*/
|
||||
int exec(ostringstream& cmd, Callbackable* obj, bool quiet);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Fine-grain mutex for DB access
|
||||
@ -121,13 +122,14 @@ public:
|
||||
|
||||
~SqliteDB(){};
|
||||
|
||||
int exec(ostringstream& cmd, Callbackable* obj=0, bool quiet=false){return -1;};
|
||||
|
||||
char * escape_str(const string& str){return 0;};
|
||||
|
||||
void free_str(char * str){};
|
||||
|
||||
bool multiple_values_support(){return true;};
|
||||
|
||||
protected:
|
||||
int exec(ostringstream& cmd, Callbackable* obj, bool quiet){return -1;};
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -48,7 +48,7 @@ public:
|
||||
/**
|
||||
* Error message for negative results
|
||||
*/
|
||||
string message;
|
||||
std::string message;
|
||||
|
||||
/**
|
||||
* Time out, true if the request ended because of a time out
|
||||
@ -78,6 +78,14 @@ public:
|
||||
am.loop();
|
||||
};
|
||||
|
||||
/**
|
||||
* Wait for the AuthRequest to be completed
|
||||
*/
|
||||
void wait(time_t t)
|
||||
{
|
||||
am.loop(t);
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
friend class MadManager;
|
||||
@ -91,6 +99,18 @@ protected:
|
||||
* The ActionManager that will be notify when the request is ready.
|
||||
*/
|
||||
ActionManager am;
|
||||
|
||||
/**
|
||||
* Timer action to finalize time-out waits
|
||||
*/
|
||||
void timer_action(const ActionRequest& ar)
|
||||
{
|
||||
result = false;
|
||||
timeout = true;
|
||||
message = "Operation time out";
|
||||
|
||||
am.finalize();
|
||||
};
|
||||
};
|
||||
|
||||
#endif /*SYNC_REQUEST_H_*/
|
||||
|
@ -309,7 +309,7 @@ private:
|
||||
{
|
||||
ostringstream oss_user(User::db_bootstrap);
|
||||
|
||||
return db->exec(oss_user);
|
||||
return db->exec_local_wr(oss_user);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -166,7 +166,7 @@ private:
|
||||
{
|
||||
ostringstream oss(VMGroup::db_bootstrap);
|
||||
|
||||
return db->exec(oss);
|
||||
return db->exec_local_wr(oss);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -149,7 +149,7 @@ private:
|
||||
{
|
||||
ostringstream oss(VMTemplate::db_bootstrap);
|
||||
|
||||
return db->exec(oss);
|
||||
return db->exec_local_wr(oss);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -343,7 +343,7 @@ private:
|
||||
{
|
||||
ostringstream oss(Vdc::db_bootstrap);
|
||||
|
||||
return db->exec(oss);
|
||||
return db->exec_local_wr(oss);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1750,10 +1750,10 @@ private:
|
||||
ostringstream oss_hist(History::db_bootstrap);
|
||||
ostringstream oss_showback(VirtualMachine::showback_db_bootstrap);
|
||||
|
||||
rc = db->exec(oss_vm);
|
||||
rc += db->exec(oss_monit);
|
||||
rc += db->exec(oss_hist);
|
||||
rc += db->exec(oss_showback);
|
||||
rc = db->exec_local_wr(oss_vm);
|
||||
rc += db->exec_local_wr(oss_monit);
|
||||
rc += db->exec_local_wr(oss_hist);
|
||||
rc += db->exec_local_wr(oss_showback);
|
||||
|
||||
return rc;
|
||||
};
|
||||
|
@ -17,11 +17,7 @@
|
||||
#ifndef VIRTUAL_MACHINE_ATTRIBUTE_H_
|
||||
#define VIRTUAL_MACHINE_ATTRIBUTE_H_
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include "Attribute.h"
|
||||
#include "Template.h"
|
||||
#include "ExtendedAttribute.h"
|
||||
|
||||
/**
|
||||
* This class represents a generic VirtualMachine attribute, it exposes the
|
||||
@ -31,49 +27,8 @@
|
||||
* The attribute operates directly on the VirtualMachineTemplate attribute. IT
|
||||
* IS NOT CLONED OR COPIED
|
||||
*/
|
||||
class VirtualMachineAttribute: public Attribute
|
||||
class VirtualMachineAttribute: public ExtendedAttribute
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Return the associated VectorAttribute to interface with vector attribute
|
||||
* functions
|
||||
*/
|
||||
VectorAttribute * vector_attribute()
|
||||
{
|
||||
return va;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* VectorAttribute Interface */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
template<typename T>
|
||||
int vector_value(const std::string& name, T& value) const
|
||||
{
|
||||
return va->vector_value(name, value);
|
||||
}
|
||||
|
||||
string vector_value(const std::string& name) const
|
||||
{
|
||||
return va->vector_value(name);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void replace(const std::string& name, T value)
|
||||
{
|
||||
va->replace(name, value);
|
||||
}
|
||||
|
||||
void remove(const std::string& name)
|
||||
{
|
||||
va->remove(name);
|
||||
}
|
||||
|
||||
|
||||
void merge(VectorAttribute* vattr, bool replace)
|
||||
{
|
||||
va->merge(vattr, replace);
|
||||
}
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Creates the attribute with a reference to a VectorAttribute. The object
|
||||
@ -81,41 +36,13 @@ protected:
|
||||
* @param va pointer to the VectorAttribute.
|
||||
*/
|
||||
VirtualMachineAttribute(VectorAttribute *_va):
|
||||
Attribute(_va->name()) ,va(_va), id(-1) {};
|
||||
ExtendedAttribute(_va){};
|
||||
|
||||
VirtualMachineAttribute(VectorAttribute *_va, int _id):
|
||||
Attribute(_va->name()) ,va(_va), id(_id) {};
|
||||
ExtendedAttribute(_va, _id) {};
|
||||
|
||||
virtual ~VirtualMachineAttribute(){};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Attribute Interface */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
string * marshall(const char * _sep = 0) const
|
||||
{
|
||||
return va->marshall(_sep);
|
||||
};
|
||||
|
||||
string * to_xml() const
|
||||
{
|
||||
return va->to_xml();
|
||||
};
|
||||
|
||||
void unmarshall(const std::string& sattr, const char * _sep = 0)
|
||||
{
|
||||
va->unmarshall(sattr, _sep);
|
||||
}
|
||||
|
||||
AttributeType type()
|
||||
{
|
||||
return va->type();
|
||||
};
|
||||
|
||||
Attribute* clone() const
|
||||
{
|
||||
return va->clone();
|
||||
};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* VirtualMachineAttribute Interface */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -139,49 +66,29 @@ protected:
|
||||
{
|
||||
bool value;
|
||||
|
||||
va->vector_value(flag, value);
|
||||
vector_value(flag, value);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
int get_id() const
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
friend class VirtualMachineAttributeSet;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/**
|
||||
* The associated VectorAttribute
|
||||
*/
|
||||
VectorAttribute * va;
|
||||
|
||||
/**
|
||||
* Set if the attribute can be addressed by an identifier, -1 otherwise
|
||||
*/
|
||||
int id;
|
||||
};
|
||||
|
||||
/**
|
||||
* This class represents a set of VirtualMachineAttributes it provides fast
|
||||
* access to individual elements (by ID) and implement collective operations
|
||||
*/
|
||||
class VirtualMachineAttributeSet
|
||||
class VirtualMachineAttributeSet : public ExtendedAttributeSet
|
||||
{
|
||||
protected:
|
||||
/**
|
||||
* Creates the VirtualMachineAttribute set
|
||||
* @param dispose elements upon set destruction
|
||||
*/
|
||||
VirtualMachineAttributeSet(bool _dispose):dispose(_dispose){};
|
||||
VirtualMachineAttributeSet(bool _dispose):ExtendedAttributeSet(_dispose){};
|
||||
|
||||
virtual ~VirtualMachineAttributeSet();
|
||||
virtual ~VirtualMachineAttributeSet(){};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Methods to access attributes */
|
||||
@ -189,7 +96,10 @@ protected:
|
||||
/**
|
||||
* @return attribute by id or 0 if not found
|
||||
*/
|
||||
VirtualMachineAttribute * get_attribute(int id) const;
|
||||
VirtualMachineAttribute * get_attribute(int id) const
|
||||
{
|
||||
return static_cast<VirtualMachineAttribute *>(get_attribute(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return attribute with the given flag set or 0 if not found
|
||||
@ -216,96 +126,14 @@ protected:
|
||||
*/
|
||||
VirtualMachineAttribute * clear_flag(const string& flag_name);
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Iterators */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/**
|
||||
* Generic iterator for the set. Wraps the STL iterator for map, can be
|
||||
* used to iterate over the attributes
|
||||
*/
|
||||
class AttributeIterator
|
||||
{
|
||||
public:
|
||||
AttributeIterator& operator=(const AttributeIterator& rhs)
|
||||
{
|
||||
map_it = rhs.map_it;
|
||||
return *this;
|
||||
}
|
||||
|
||||
AttributeIterator& operator++()
|
||||
{
|
||||
++map_it;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator!=(const AttributeIterator& rhs)
|
||||
{
|
||||
return map_it != rhs.map_it;
|
||||
}
|
||||
|
||||
AttributeIterator(){};
|
||||
AttributeIterator(const AttributeIterator& ait):map_it(ait.map_it){};
|
||||
AttributeIterator(const std::map<int,
|
||||
VirtualMachineAttribute *>::iterator& _map_it):map_it(_map_it){};
|
||||
|
||||
virtual ~AttributeIterator(){};
|
||||
|
||||
protected:
|
||||
std::map<int, VirtualMachineAttribute *>::iterator map_it;
|
||||
};
|
||||
|
||||
AttributeIterator begin()
|
||||
{
|
||||
AttributeIterator it(a_set.begin());
|
||||
return it;
|
||||
}
|
||||
|
||||
AttributeIterator end()
|
||||
{
|
||||
AttributeIterator it(a_set.end());
|
||||
return it;
|
||||
}
|
||||
|
||||
typedef class AttributeIterator attribute_iterator;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Attribute map interface */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/**
|
||||
* Adds a new VirtualMachine attribute to the set
|
||||
*/
|
||||
void add_attribute(VirtualMachineAttribute * a, int id)
|
||||
{
|
||||
a_set.insert(make_pair(id, a));
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the attribute set from a vector
|
||||
* @param id_name with the ID of the attribute
|
||||
* @param auto_ids automatically generate ids for the attributes
|
||||
* @param vas vector of attribute to use
|
||||
*/
|
||||
void init_attribute_map(const std::string& id_name,
|
||||
std::vector<VectorAttribute *>& vas);
|
||||
/**
|
||||
* Abstract method to create the VirtualMachineAttributes for this set
|
||||
*/
|
||||
virtual VirtualMachineAttribute * attribute_factory(VectorAttribute * va,
|
||||
virtual ExtendedAttribute * attribute_factory(VectorAttribute * va,
|
||||
int id) const = 0;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Map with the disk attributes
|
||||
*/
|
||||
std::map<int, VirtualMachineAttribute *> a_set;
|
||||
|
||||
/**
|
||||
* Frees the VectorAttribute associated with each VirtualMachineAttribute
|
||||
* upon object destruction
|
||||
*/
|
||||
bool dispose;
|
||||
};
|
||||
|
||||
#endif /*VIRTUAL_MACHINE_ATTRIBUTE_H_*/
|
||||
|
@ -379,13 +379,13 @@ public:
|
||||
|
||||
DiskIterator begin()
|
||||
{
|
||||
DiskIterator it(VirtualMachineAttributeSet::begin());
|
||||
DiskIterator it(ExtendedAttributeSet::begin());
|
||||
return it;
|
||||
}
|
||||
|
||||
DiskIterator end()
|
||||
{
|
||||
DiskIterator it(VirtualMachineAttributeSet::end());
|
||||
DiskIterator it(ExtendedAttributeSet::end());
|
||||
return it;
|
||||
}
|
||||
|
||||
|
@ -200,13 +200,13 @@ public:
|
||||
|
||||
NicIterator begin()
|
||||
{
|
||||
NicIterator it(VirtualMachineAttributeSet::begin());
|
||||
NicIterator it(ExtendedAttributeSet::begin());
|
||||
return it;
|
||||
}
|
||||
|
||||
NicIterator end()
|
||||
{
|
||||
NicIterator it(VirtualMachineAttributeSet::end());
|
||||
NicIterator it(ExtendedAttributeSet::end());
|
||||
return it;
|
||||
}
|
||||
|
||||
|
@ -236,7 +236,7 @@ public:
|
||||
ostringstream oss_import(import_db_bootstrap);
|
||||
|
||||
rc = VirtualMachine::bootstrap(_db);
|
||||
rc += _db->exec(oss_import);
|
||||
rc += _db->exec_local_wr(oss_import);
|
||||
|
||||
return rc;
|
||||
};
|
||||
|
@ -596,7 +596,7 @@ private:
|
||||
{
|
||||
ostringstream oss_vnet(VirtualNetwork::db_bootstrap);
|
||||
|
||||
return db->exec(oss_vnet);
|
||||
return db->exec_local_wr(oss_vnet);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -122,7 +122,7 @@ public:
|
||||
int rc;
|
||||
|
||||
rc = VirtualNetwork::bootstrap(_db);
|
||||
rc += _db->exec(BitMap<0>::bootstrap(vlan_table, oss));
|
||||
rc += _db->exec_local_wr(BitMap<0>::bootstrap(vlan_table, oss));
|
||||
|
||||
return rc;
|
||||
};
|
||||
|
@ -216,7 +216,7 @@ private:
|
||||
{
|
||||
ostringstream oss(VirtualRouter::db_bootstrap);
|
||||
|
||||
return db->exec(oss);
|
||||
return db->exec_local_wr(oss);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -22,6 +22,8 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
class ZoneServers;
|
||||
class ZoneServer;
|
||||
/**
|
||||
* The Zone class.
|
||||
*/
|
||||
@ -44,26 +46,68 @@ public:
|
||||
*/
|
||||
int from_xml(const string &xml_str);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Add servers to this zone
|
||||
* @param tmpl with SERVER definitions
|
||||
* @param sid id of the new sever
|
||||
* @param xmlep endpoint of the new server
|
||||
* @param error
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int add_server(Template& tmpl, int& sid, string& xmlep, string& error);
|
||||
|
||||
/**
|
||||
* Delete a server from this zone
|
||||
* @param it of the SERVER
|
||||
* @param error if any
|
||||
*
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
int delete_server(int id, string& error);
|
||||
|
||||
/**
|
||||
* @return the servers in this zone
|
||||
*/
|
||||
ZoneServers * get_servers()
|
||||
{
|
||||
return servers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param server_id
|
||||
* @return the server
|
||||
*/
|
||||
ZoneServer * get_server(int server_id);
|
||||
|
||||
/**
|
||||
* @return the number of servers in this zone
|
||||
*/
|
||||
unsigned int servers_size();
|
||||
|
||||
private:
|
||||
// -------------------------------------------------------------------------
|
||||
// Friends
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
friend class ZonePool;
|
||||
|
||||
// *************************************************************************
|
||||
// -------------------------------------------------------------------------
|
||||
// Constructor
|
||||
// *************************************************************************
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
Zone(int id, Template* zone_template);
|
||||
|
||||
~Zone();
|
||||
|
||||
// *************************************************************************
|
||||
// DataBase implementation (Private)
|
||||
// *************************************************************************
|
||||
// -------------------------------------------------------------------------
|
||||
// Zone servers
|
||||
// -------------------------------------------------------------------------
|
||||
Template servers_template;
|
||||
|
||||
ZoneServers * servers;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// DataBase implementation (Private)
|
||||
// -------------------------------------------------------------------------
|
||||
static const char * db_names;
|
||||
|
||||
static const char * db_bootstrap;
|
||||
@ -87,7 +131,7 @@ private:
|
||||
{
|
||||
ostringstream oss(Zone::db_bootstrap);
|
||||
|
||||
return db->exec(oss);
|
||||
return db->exec_local_wr(oss);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -127,10 +127,29 @@ public:
|
||||
return PoolSQL::dump(oss, "ZONE_POOL", Zone::table, where, limit);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the servers of a zone
|
||||
* @param zone_id of the zone
|
||||
* @param _serv list of servers and associated xml-rpc endpoints
|
||||
* @return the number of servers in the zone
|
||||
*/
|
||||
unsigned int get_zone_servers(int zone_id, std::map<int, std::string>& srv);
|
||||
|
||||
/**
|
||||
* Return the list of zones defined
|
||||
* @param zone_ids of the zones
|
||||
* @return 0 on success
|
||||
*/
|
||||
int list_zones(vector<int>& zone_ids)
|
||||
{
|
||||
return list( zone_ids, Zone::table);
|
||||
}
|
||||
|
||||
/**
|
||||
* ID for the special local zone in stand-alone mode
|
||||
*/
|
||||
static const int STANDALONE_ZONE_ID;
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
|
214
include/ZoneServer.h
Normal file
214
include/ZoneServer.h
Normal file
@ -0,0 +1,214 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2016, 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 ZONE_SERVER_H_
|
||||
#define ZONE_SERVER_H_
|
||||
|
||||
#include <queue>
|
||||
#include <set>
|
||||
|
||||
#include "ExtendedAttribute.h"
|
||||
|
||||
/**
|
||||
* The VirtualMachine DISK attribute
|
||||
*/
|
||||
class ZoneServer : public ExtendedAttribute
|
||||
{
|
||||
public:
|
||||
|
||||
ZoneServer(VectorAttribute *va, int id):ExtendedAttribute(va, id){};
|
||||
|
||||
virtual ~ZoneServer(){};
|
||||
|
||||
/**
|
||||
* Initialized server metadata:
|
||||
* - NAME
|
||||
* - ENDPOINT
|
||||
* @param error string if any
|
||||
* @return -1 if server data could not be initialized, 0 on success
|
||||
*/
|
||||
int init(string& error)
|
||||
{
|
||||
if ( vector_value("NAME").empty() )
|
||||
{
|
||||
error = "Missing NAME in SERVER";
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( vector_value("ENDPOINT").empty() )
|
||||
{
|
||||
error = "Missing ENDPOINT in SERVER";
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Server attributes
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* @return the ID of the server
|
||||
*/
|
||||
int get_id() const
|
||||
{
|
||||
return ExtendedAttribute::get_id();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set of Zone servers
|
||||
*/
|
||||
class ZoneServers : public ExtendedAttributeSet
|
||||
{
|
||||
public:
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Constructor and Initialization functions */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/**
|
||||
* Creates the ZoneServers set from a zone template with SERVER=[...]
|
||||
* attributes
|
||||
* @param tmpl template with SERVER
|
||||
*/
|
||||
ZoneServers(Template * tmpl):ExtendedAttributeSet(false), next_id(-1)
|
||||
{
|
||||
std::vector<VectorAttribute *> vas;
|
||||
|
||||
tmpl->get(SERVER_NAME, vas);
|
||||
|
||||
init_attribute_map(SERVER_ID_NAME, vas);
|
||||
|
||||
for ( zone_iterator it = begin() ; it != end() ; ++it )
|
||||
{
|
||||
string error;
|
||||
|
||||
int i = (*it)->get_id();
|
||||
|
||||
if ( i > next_id )
|
||||
{
|
||||
next_id = i;
|
||||
}
|
||||
|
||||
(*it)->init(error);
|
||||
}
|
||||
|
||||
next_id += 1;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates an empty zone server set
|
||||
*/
|
||||
ZoneServers():ExtendedAttributeSet(false){};
|
||||
|
||||
virtual ~ZoneServers(){};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Iterators */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
class ZoneIterator : public AttributeIterator
|
||||
{
|
||||
public:
|
||||
ZoneIterator():AttributeIterator(){};
|
||||
ZoneIterator(const AttributeIterator& dit):AttributeIterator(dit){};
|
||||
virtual ~ZoneIterator(){};
|
||||
|
||||
ZoneServer * operator*() const
|
||||
{
|
||||
return static_cast<ZoneServer *>(map_it->second);
|
||||
}
|
||||
};
|
||||
|
||||
ZoneIterator begin()
|
||||
{
|
||||
ZoneIterator it(ExtendedAttributeSet::begin());
|
||||
return it;
|
||||
}
|
||||
|
||||
ZoneIterator end()
|
||||
{
|
||||
ZoneIterator it(ExtendedAttributeSet::end());
|
||||
return it;
|
||||
}
|
||||
|
||||
typedef class ZoneIterator zone_iterator;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* ZoneServer interface */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/**
|
||||
* Returns the SERVER attribute for a zone server
|
||||
* @param disk_id of the DISK
|
||||
* @return pointer to the attribute ir null if not found
|
||||
*/
|
||||
ZoneServer * get_server(int id) const
|
||||
{
|
||||
return static_cast<ZoneServer *>(get_attribute(id));
|
||||
}
|
||||
|
||||
int add_server(VectorAttribute * va, int& sid, string& error)
|
||||
{
|
||||
ZoneServer * server = new ZoneServer(va, next_id);
|
||||
|
||||
if ( server->init(error) != 0 )
|
||||
{
|
||||
delete server;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
va->replace(SERVER_ID_NAME, next_id);
|
||||
|
||||
add_attribute(server, next_id);
|
||||
|
||||
sid = next_id;
|
||||
|
||||
next_id += 1;
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
ZoneServer * delete_server(int id)
|
||||
{
|
||||
return static_cast<ZoneServer *>(delete_attribute(id));
|
||||
};
|
||||
|
||||
/**
|
||||
* @return servers in zone
|
||||
*/
|
||||
unsigned int size()
|
||||
{
|
||||
return ExtendedAttributeSet::size();
|
||||
}
|
||||
|
||||
protected:
|
||||
ExtendedAttribute * attribute_factory(VectorAttribute * va, int id) const
|
||||
{
|
||||
return new ZoneServer(va, id);
|
||||
};
|
||||
|
||||
private:
|
||||
friend class Zone;
|
||||
|
||||
static const char * SERVER_NAME; //"SERVER"
|
||||
|
||||
static const char * SERVER_ID_NAME; //"ID"
|
||||
|
||||
int next_id;
|
||||
};
|
||||
|
||||
#endif /*ZONE_SERVER_H_*/
|
||||
|
16
install.sh
16
install.sh
@ -272,6 +272,7 @@ VAR_DIRS="$VAR_LOCATION/remotes \
|
||||
$VAR_LOCATION/remotes/tm/iscsi_libvirt \
|
||||
$VAR_LOCATION/remotes/hooks \
|
||||
$VAR_LOCATION/remotes/hooks/ft \
|
||||
$VAR_LOCATION/remotes/hooks/raft \
|
||||
$VAR_LOCATION/remotes/datastore \
|
||||
$VAR_LOCATION/remotes/datastore/dummy \
|
||||
$VAR_LOCATION/remotes/datastore/fs \
|
||||
@ -422,6 +423,7 @@ INSTALL_FILES=(
|
||||
INSTALL_GEMS_SHARE_FILES:$SHARE_LOCATION
|
||||
ONETOKEN_SHARE_FILE:$SHARE_LOCATION
|
||||
HOOK_FT_FILES:$VAR_LOCATION/remotes/hooks/ft
|
||||
HOOK_RAFT_FILES:$VAR_LOCATION/remotes/hooks/raft
|
||||
COMMON_CLOUD_LIB_FILES:$LIB_LOCATION/ruby/cloud
|
||||
CLOUD_AUTH_LIB_FILES:$LIB_LOCATION/ruby/cloud/CloudAuth
|
||||
ECO_LIB_FILES:$LIB_LOCATION/ruby/cloud/econe
|
||||
@ -1269,12 +1271,18 @@ WEBSOCKIFY_SHARE_FILES="share/websockify/websocketproxy.py \
|
||||
share/websockify/websockify"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# HOOK scripts, to be installed under $VAR_LOCATION/remotes/hooks
|
||||
# HOOK scripts, to be installed under $VAR_LOCATION/remotes/hooks/ft
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
HOOK_FT_FILES="share/hooks/host_error.rb \
|
||||
share/hooks/fence_host.sh \
|
||||
share/hooks/delete_poweroff_vms.rb"
|
||||
HOOK_FT_FILES="share/hooks/ft/host_error.rb \
|
||||
share/hooks/ft/fence_host.sh \
|
||||
share/hooks/ft/delete_poweroff_vms.rb"
|
||||
#-------------------------------------------------------------------------------
|
||||
# HOOK RAFT scripts, to be installed under $VAR_LOCATION/remotes/hooks/raft
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
HOOK_RAFT_FILES="share/hooks/raft/leader.sh \
|
||||
share/hooks/raft/follower.sh"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Installation scripts, to be installed under $SHARE_LOCATION
|
||||
|
@ -97,7 +97,7 @@ VNC_PORTS = [
|
||||
#VM_SUBMIT_ON_HOLD = "NO"
|
||||
|
||||
#*******************************************************************************
|
||||
# Federation configuration attributes
|
||||
# Federation & HA configuration attributes
|
||||
#-------------------------------------------------------------------------------
|
||||
# Control the federation capabilities of oned. Operation in a federated setup
|
||||
# requires a special DB configuration.
|
||||
@ -108,14 +108,44 @@ VNC_PORTS = [
|
||||
# MASTER this oned is the master zone of the federation
|
||||
# SLAVE this oned is a slave zone
|
||||
# ZONE_ID: The zone ID as returned by onezone command
|
||||
# SERVER_ID: ID identifying this server in the zone as returned by the
|
||||
# onezone server-add command. This ID controls the HA configuration of
|
||||
# OpenNebula:
|
||||
# -1 (default) OpenNebula will operate in "solo" mode no HA
|
||||
# <id> Operate in HA (leader election and state replication)
|
||||
# MASTER_ONED: The xml-rpc endpoint of the master oned, e.g.
|
||||
# http://master.one.org:2633/RPC2
|
||||
#
|
||||
#
|
||||
# RAFT: Algorithm attributes
|
||||
# LOG_RETENTION: Number of DB log records kept, it determines the
|
||||
# synchronization window across servers and extra storage space needed.
|
||||
# LOG_PURGE_TIMEOUT: How often applied records are purged according the log
|
||||
# retention value. (in seconds)
|
||||
# ELECTION_TIMEOUT_MS: Timeout to start a election process if no hearbeat or
|
||||
# log is received from leader.
|
||||
# BROADCAST_TIMEOUT_MS: How often heartbeats are sent to followers.
|
||||
# XMLRPC_TIMEOUT_MS: To timeout raft related API calls
|
||||
#
|
||||
# NOTE: Timeout tunning depends on the latency of the servers (network and load)
|
||||
# as well as the max downtime tolerated by the system. Timeouts needs to be
|
||||
# greater than 10ms
|
||||
#
|
||||
#*******************************************************************************
|
||||
|
||||
FEDERATION = [
|
||||
MODE = "STANDALONE",
|
||||
ZONE_ID = 0,
|
||||
MASTER_ONED = ""
|
||||
MODE = "STANDALONE",
|
||||
ZONE_ID = 0,
|
||||
SERVER_ID = -1,
|
||||
MASTER_ONED = ""
|
||||
]
|
||||
|
||||
RAFT = [
|
||||
LOG_RETENTION = 500000,
|
||||
LOG_PURGE_TIMEOUT = 600,
|
||||
ELECTION_TIMEOUT_MS = 1500,
|
||||
BROADCAST_TIMEOUT_MS = 500,
|
||||
XMLRPC_TIMEOUT_MS = 100
|
||||
]
|
||||
|
||||
#*******************************************************************************
|
||||
@ -712,6 +742,17 @@ IPAM_MAD = [
|
||||
# Please note: In a Federation, User and Group hooks can only be defined in
|
||||
# the master OpenNebula.
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# Executed when a server transit from follower->leader
|
||||
RAFT_LEADER_HOOK = [
|
||||
COMMAND = "raft/leader.sh"
|
||||
]
|
||||
|
||||
# Executed when a server transit from leader->follower
|
||||
RAFT_FOLLOWER_HOOK = [
|
||||
COMMAND = "raft/follower.sh"
|
||||
]
|
||||
|
||||
HM_MAD = [
|
||||
EXECUTABLE = "one_hm" ]
|
||||
|
||||
|
11
share/hooks/raft/follower.sh
Executable file
11
share/hooks/raft/follower.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
DIR=`dirname $0`
|
||||
cd $DIR
|
||||
cd ../../../../
|
||||
|
||||
SERVER=$(basename `pwd`)
|
||||
|
||||
echo "`date +'%F %H:%M:%S'` [$SERVER] FOLLOWER HOOK" >> /tmp/raft_hooks.log
|
||||
|
||||
exit 0
|
11
share/hooks/raft/leader.sh
Executable file
11
share/hooks/raft/leader.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
DIR=`dirname $0`
|
||||
cd $DIR
|
||||
cd ../../../../
|
||||
|
||||
SERVER=$(basename `pwd`)
|
||||
|
||||
echo "`date +'%F %H:%M:%S'` [$SERVER] LEADER HOOK" >> /tmp/raft_hooks.log
|
||||
|
||||
exit 0
|
@ -33,16 +33,36 @@ const char * AclManager::db_bootstrap = "CREATE TABLE IF NOT EXISTS "
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int AclManager::init_cb(void *nil, int num, char **values, char **names)
|
||||
static int get_lastOID(SqlDB * db)
|
||||
{
|
||||
lastOID = -1;
|
||||
ostringstream oss;
|
||||
|
||||
if ( values[0] != 0 )
|
||||
{
|
||||
lastOID = atoi(values[0]);
|
||||
}
|
||||
int _last_oid = -1;
|
||||
|
||||
return 0;
|
||||
single_cb<int> cb;
|
||||
|
||||
cb.set_callback(&_last_oid);
|
||||
|
||||
oss << "SELECT last_oid FROM pool_control WHERE tablename='acl'";
|
||||
|
||||
db->exec_rd(oss, &cb);
|
||||
|
||||
cb.unset_callback();
|
||||
|
||||
return _last_oid;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
static void set_lastOID(SqlDB * db, int lastOID)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
oss << "REPLACE INTO pool_control (tablename, last_oid) VALUES ('acl',"
|
||||
<< lastOID << ")";
|
||||
|
||||
db->exec_wr(oss);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@ -52,22 +72,13 @@ AclManager::AclManager(
|
||||
int _zone_id,
|
||||
bool _is_federation_slave,
|
||||
time_t _timer_period)
|
||||
:zone_id(_zone_id), db(_db), lastOID(-1),
|
||||
is_federation_slave(_is_federation_slave), timer_period(_timer_period)
|
||||
:zone_id(_zone_id), db(_db), is_federation_slave(_is_federation_slave),
|
||||
timer_period(_timer_period)
|
||||
{
|
||||
ostringstream oss;
|
||||
int lastOID;
|
||||
|
||||
pthread_mutex_init(&mutex, 0);
|
||||
|
||||
set_callback(static_cast<Callbackable::Callback> (&AclManager::init_cb));
|
||||
|
||||
oss << "SELECT last_oid FROM pool_control WHERE tablename='" << table
|
||||
<< "'";
|
||||
|
||||
db->exec(oss, this);
|
||||
|
||||
unset_callback();
|
||||
|
||||
am.addListener(this);
|
||||
|
||||
//Federation slaves do not need to init the pool
|
||||
@ -76,6 +87,8 @@ AclManager::AclManager(
|
||||
return;
|
||||
}
|
||||
|
||||
lastOID = get_lastOID(db);
|
||||
|
||||
if (lastOID == -1)
|
||||
{
|
||||
// Add a default rules for the ACL engine
|
||||
@ -564,6 +577,8 @@ int AclManager::add_rule(long long user, long long resource, long long rights,
|
||||
|
||||
lock();
|
||||
|
||||
int lastOID = get_lastOID(db);
|
||||
|
||||
if (lastOID == INT_MAX)
|
||||
{
|
||||
lastOID = -1;
|
||||
@ -607,7 +622,7 @@ int AclManager::add_rule(long long user, long long resource, long long rights,
|
||||
acl_rules.insert( make_pair(rule->user, rule) );
|
||||
acl_rules_oids.insert( make_pair(rule->oid, rule) );
|
||||
|
||||
update_lastOID();
|
||||
set_lastOID(db, lastOID);
|
||||
|
||||
unlock();
|
||||
|
||||
@ -636,7 +651,6 @@ error_common:
|
||||
error_str = oss.str();
|
||||
|
||||
delete rule;
|
||||
lastOID--;
|
||||
|
||||
unlock();
|
||||
|
||||
@ -1094,25 +1108,9 @@ int AclManager::bootstrap(SqlDB * _db)
|
||||
{
|
||||
ostringstream oss(db_bootstrap);
|
||||
|
||||
return _db->exec(oss);
|
||||
return _db->exec_local_wr(oss);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void AclManager::update_lastOID()
|
||||
{
|
||||
// db->escape_str is not used for 'table' since its name can't be set in
|
||||
// any way by the user, it is hardcoded.
|
||||
|
||||
ostringstream oss;
|
||||
|
||||
oss << "REPLACE INTO pool_control (tablename, last_oid) VALUES ("
|
||||
<< "'" << table << "',"
|
||||
<< lastOID << ")";
|
||||
|
||||
db->exec(oss);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@ -1186,7 +1184,7 @@ int AclManager::select()
|
||||
acl_rules.clear();
|
||||
acl_rules_oids.clear();
|
||||
|
||||
rc = db->exec(oss,this);
|
||||
rc = db->exec_rd(oss,this);
|
||||
|
||||
unlock();
|
||||
|
||||
@ -1212,7 +1210,7 @@ int AclManager::insert(AclRule * rule, SqlDB * db)
|
||||
<< rule->rights << ","
|
||||
<< rule->zone << ")";
|
||||
|
||||
rc = db->exec(oss);
|
||||
rc = db->exec_wr(oss);
|
||||
|
||||
return rc;
|
||||
}
|
||||
@ -1229,7 +1227,7 @@ int AclManager::drop(int oid)
|
||||
oss << "DELETE FROM " << table << " WHERE "
|
||||
<< "oid=" << oid;
|
||||
|
||||
rc = db->exec(oss);
|
||||
rc = db->exec_wr(oss);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
@ -18,6 +18,22 @@ require 'one_helper'
|
||||
|
||||
class OneZoneHelper < OpenNebulaHelper::OneHelper
|
||||
|
||||
SERVER_NAME={
|
||||
:name => "server_name",
|
||||
:short => "-n server_name",
|
||||
:large => "--name",
|
||||
:format => String,
|
||||
:description => "Zone server name"
|
||||
}
|
||||
|
||||
SERVER_ENDPOINT={
|
||||
:name => "server_rpc",
|
||||
:short => "-r rpc endpoint",
|
||||
:large => "--rpc",
|
||||
:format => String,
|
||||
:description => "Zone server RPC endpoint"
|
||||
}
|
||||
|
||||
def self.rname
|
||||
"ZONE"
|
||||
end
|
||||
@ -98,6 +114,86 @@ class OneZoneHelper < OpenNebulaHelper::OneHelper
|
||||
puts str % ["NAME", zone.name]
|
||||
puts
|
||||
|
||||
zone_hash=zone.to_hash
|
||||
|
||||
if zone.has_elements?("/ZONE/SERVER_POOL/SERVER")
|
||||
servers = zone_hash["ZONE"]["SERVER_POOL"]["SERVER"]
|
||||
|
||||
[servers].flatten.each { |s|
|
||||
endpoint = s["ENDPOINT"]
|
||||
|
||||
next if endpoint.nil?
|
||||
|
||||
client = OpenNebula::Client.new(nil, endpoint)
|
||||
|
||||
xml_doc = client.call("zone.raftstatus")
|
||||
|
||||
if OpenNebula::is_error?(xml_doc)
|
||||
s["STATE"] = "error"
|
||||
s["TERM"] = "-"
|
||||
s["VOTEDFOR"] = "-"
|
||||
s["COMMIT" ] = "-"
|
||||
s["LOG_INDEX"] = "-"
|
||||
|
||||
next
|
||||
end
|
||||
|
||||
xml_doc = Nokogiri::XML(xml_doc)
|
||||
|
||||
s["STATE"] = case xml_doc.root.at_xpath("STATE").text
|
||||
when "0" then "solo"
|
||||
when "1" then "candidate"
|
||||
when "2" then "follower"
|
||||
when "3" then "leader"
|
||||
else "-"
|
||||
end
|
||||
s["TERM"] = xml_doc.root.at_xpath("TERM").text
|
||||
s["VOTEDFOR"] = xml_doc.root.at_xpath("VOTEDFOR").text
|
||||
s["COMMIT"] = xml_doc.root.at_xpath("COMMIT").text
|
||||
s["LOG_INDEX"] = xml_doc.root.at_xpath("LOG_INDEX").text
|
||||
}
|
||||
|
||||
puts
|
||||
CLIHelper.print_header(str_h1 % "SERVERS",false)
|
||||
|
||||
CLIHelper::ShowTable.new(nil, self) do
|
||||
|
||||
column :"ID", "", :size=>2 do |d|
|
||||
d["ID"] if !d.nil?
|
||||
end
|
||||
|
||||
column :"NAME", "", :left, :size=>15 do |d|
|
||||
d["NAME"] if !d.nil?
|
||||
end
|
||||
|
||||
column :"STATE", "", :left, :size=>10 do |d|
|
||||
d["STATE"] if !d.nil?
|
||||
end
|
||||
|
||||
column :"TERM", "", :left, :size=>10 do |d|
|
||||
d["TERM"] if !d.nil?
|
||||
end
|
||||
|
||||
column :"INDEX", "", :left, :size=>10 do |d|
|
||||
d["LOG_INDEX"] if !d.nil?
|
||||
end
|
||||
|
||||
column :"COMMIT", "", :left, :size=>10 do |d|
|
||||
d["COMMIT"] if !d.nil?
|
||||
end
|
||||
|
||||
column :"VOTE", "", :left, :size=>5 do |d|
|
||||
d["VOTEDFOR"] if !d.nil?
|
||||
end
|
||||
|
||||
column :"ENDPOINT", "", :left, :size=>18 do |d|
|
||||
d["ENDPOINT"] if !d.nil?
|
||||
end
|
||||
end.show([zone_hash['ZONE']['SERVER_POOL']['SERVER']].flatten, {})
|
||||
end
|
||||
|
||||
puts
|
||||
|
||||
CLIHelper.print_header(str_h1 % "ZONE TEMPLATE", false)
|
||||
puts zone.template_str
|
||||
end
|
||||
|
@ -91,6 +91,43 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
end
|
||||
end
|
||||
|
||||
addserver_desc = <<-EOT.unindent
|
||||
Add an OpenNebula server to this zone.
|
||||
EOT
|
||||
|
||||
command :"server-add", addserver_desc, :zoneid, :options =>
|
||||
[ OneZoneHelper::SERVER_NAME, OneZoneHelper::SERVER_ENDPOINT] do
|
||||
|
||||
if options[:server_name].nil? || options[:server_rpc].nil?
|
||||
STDERR.puts "To add a server set:"
|
||||
STDERR.puts "\t-n <server name>"
|
||||
STDERR.puts "\t-r <RPC endpoint>"
|
||||
exit -1
|
||||
end
|
||||
|
||||
template = <<-EOT
|
||||
SERVER = [
|
||||
NAME="#{options[:server_name]}",
|
||||
ENDPOINT="#{options[:server_rpc]}"
|
||||
]
|
||||
EOT
|
||||
|
||||
helper.perform_action(args[0], options, "server added") do |o|
|
||||
o.add_servers(template)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
delserver_desc = <<-EOT.unindent
|
||||
Delete an OpenNebula server from this zone.
|
||||
EOT
|
||||
|
||||
command :"server-del", delserver_desc, :zoneid, :serverid do
|
||||
helper.perform_action(args[0], options, "server deleted") do |o|
|
||||
o.delete_servers(args[1].to_i)
|
||||
end
|
||||
|
||||
end
|
||||
update_desc = <<-EOT.unindent
|
||||
Update the template contents. If a path is not provided the editor will
|
||||
be launched to modify the current content.
|
||||
|
@ -223,3 +223,52 @@ void Client::call(const std::string& method, const xmlrpc_c::paramList& plist,
|
||||
girerr::error(failure.getDescription());
|
||||
}
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int Client::call(const std::string& endpoint, const std::string& method,
|
||||
const xmlrpc_c::paramList& plist, long long _timeout,
|
||||
xmlrpc_c::value * const result, std::string& error)
|
||||
{
|
||||
xmlrpc_c::carriageParm_curl0 carriage(endpoint);
|
||||
xmlrpc_c::clientXmlTransport_curl transport;
|
||||
xmlrpc_c::client_xml client(&transport);
|
||||
|
||||
xmlrpc_c::rpcPtr rpc_client(method, plist);
|
||||
|
||||
int xml_rc = 0;
|
||||
|
||||
try
|
||||
{
|
||||
rpc_client->start(&client, &carriage);
|
||||
|
||||
client.finishAsync(xmlrpc_c::timeout(_timeout));
|
||||
|
||||
if (!rpc_client->isFinished())
|
||||
{
|
||||
rpc_client->finishErr(girerr::error("XMLRPC method "+ method
|
||||
+ " timeout, resetting call"));
|
||||
}
|
||||
|
||||
if ( rpc_client->isSuccessful() )
|
||||
{
|
||||
*result = rpc_client->getResult();
|
||||
}
|
||||
else //RPC failed
|
||||
{
|
||||
xmlrpc_c::fault failure = rpc_client->getFault();
|
||||
|
||||
error = failure.getDescription();
|
||||
xml_rc = -1;
|
||||
}
|
||||
}
|
||||
catch (exception const& e)
|
||||
{
|
||||
error = e.what();
|
||||
xml_rc = -1;
|
||||
}
|
||||
|
||||
return xml_rc;
|
||||
}
|
||||
|
||||
|
@ -237,7 +237,7 @@ int Cluster::insert_replace(SqlDB *db, bool replace, string& error_str)
|
||||
<< other_u << ")";
|
||||
|
||||
|
||||
rc = db->exec(oss);
|
||||
rc = db->exec_wr(oss);
|
||||
|
||||
db->free_str(sql_name);
|
||||
db->free_str(sql_xml);
|
||||
@ -252,11 +252,11 @@ int Cluster::insert_replace(SqlDB *db, bool replace, string& error_str)
|
||||
|
||||
oss.str("");
|
||||
oss << "DELETE FROM " << network_table << " WHERE cid = " << oid;
|
||||
rc += db->exec(oss);
|
||||
rc += db->exec_wr(oss);
|
||||
|
||||
oss.str("");
|
||||
oss << "DELETE FROM " << datastore_table<< " WHERE cid = " << oid;
|
||||
rc += db->exec(oss);
|
||||
rc += db->exec_wr(oss);
|
||||
|
||||
set<int> datastore_set = datastores.get_collection();
|
||||
|
||||
@ -275,7 +275,7 @@ int Cluster::insert_replace(SqlDB *db, bool replace, string& error_str)
|
||||
oss << ", (" << oid << "," << *i << ")";
|
||||
}
|
||||
|
||||
rc += db->exec(oss);
|
||||
rc += db->exec_wr(oss);
|
||||
}
|
||||
|
||||
set<int> vnet_set = vnets.get_collection();
|
||||
@ -295,7 +295,7 @@ int Cluster::insert_replace(SqlDB *db, bool replace, string& error_str)
|
||||
oss << ", (" << oid << "," << *i << ")";
|
||||
}
|
||||
|
||||
rc += db->exec(oss);
|
||||
rc += db->exec_wr(oss);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -330,7 +330,7 @@ int Cluster::insert_replace(SqlDB *db, bool replace, string& error_str)
|
||||
|
||||
oss << "COMMIT";
|
||||
|
||||
rc = db->exec(oss);
|
||||
rc = db->exec_wr(oss);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ ClusterPool::ClusterPool(SqlDB * db, const VectorAttribute * _vnc_conf):
|
||||
cluster->unlock();
|
||||
|
||||
// User created clusters will start from ID 100
|
||||
set_update_lastOID(99);
|
||||
set_lastOID(99);
|
||||
}
|
||||
|
||||
return;
|
||||
@ -223,7 +223,7 @@ int ClusterPool::query_datastore_clusters(int oid, set<int> &cluster_ids)
|
||||
|
||||
oss << "SELECT cid FROM " << Cluster::datastore_table << " WHERE oid = " << oid;
|
||||
|
||||
int rc = db->exec(oss, this);
|
||||
int rc = db->exec_rd(oss, this);
|
||||
|
||||
unset_callback();
|
||||
|
||||
@ -247,7 +247,7 @@ int ClusterPool::query_vnet_clusters(int oid, set<int> &cluster_ids)
|
||||
|
||||
oss << "SELECT cid FROM " << Cluster::network_table << " WHERE oid = " << oid;
|
||||
|
||||
int rc = db->exec(oss, this);
|
||||
int rc = db->exec_rd(oss, this);
|
||||
|
||||
unset_callback();
|
||||
|
||||
|
@ -55,7 +55,21 @@ void ActionManager::trigger(const ActionRequest& ar )
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void ActionManager::loop(time_t timer, const ActionRequest& trequest)
|
||||
static void set_timeout(struct timespec& timeout, struct timespec& _tout)
|
||||
{
|
||||
clock_gettime(CLOCK_REALTIME, &timeout);
|
||||
|
||||
timeout.tv_sec += _tout.tv_sec;
|
||||
timeout.tv_nsec += _tout.tv_nsec;
|
||||
|
||||
while ( timeout.tv_nsec >= 1000000000 )
|
||||
{
|
||||
timeout.tv_sec += 1;
|
||||
timeout.tv_nsec -= 1000000000;
|
||||
}
|
||||
}
|
||||
|
||||
void ActionManager::loop(struct timespec& _tout, const ActionRequest& trequest)
|
||||
{
|
||||
struct timespec timeout;
|
||||
|
||||
@ -64,8 +78,7 @@ void ActionManager::loop(time_t timer, const ActionRequest& trequest)
|
||||
|
||||
ActionRequest * action;
|
||||
|
||||
timeout.tv_sec = time(NULL) + timer;
|
||||
timeout.tv_nsec = 0;
|
||||
set_timeout(timeout, _tout);
|
||||
|
||||
//Action Loop, end when a finalize action is triggered to this manager
|
||||
while (finalize == 0)
|
||||
@ -74,9 +87,9 @@ void ActionManager::loop(time_t timer, const ActionRequest& trequest)
|
||||
|
||||
while ( actions.empty() == true )
|
||||
{
|
||||
if ( timer != 0 )
|
||||
if ( _tout.tv_sec != 0 || _tout.tv_nsec != 0 )
|
||||
{
|
||||
rc = pthread_cond_timedwait(&cond,&mutex, &timeout);
|
||||
rc = pthread_cond_timedwait(&cond, &mutex, &timeout);
|
||||
|
||||
if ( rc == ETIMEDOUT )
|
||||
actions.push(trequest.clone());
|
||||
@ -95,8 +108,7 @@ void ActionManager::loop(time_t timer, const ActionRequest& trequest)
|
||||
switch(action->type())
|
||||
{
|
||||
case ActionRequest::TIMER:
|
||||
timeout.tv_sec = time(NULL) + timer;
|
||||
timeout.tv_nsec = 0;
|
||||
set_timeout(timeout, _tout);
|
||||
break;
|
||||
|
||||
case ActionRequest::FINALIZE:
|
||||
|
94
src/common/ExtendedAttribute.cc
Normal file
94
src/common/ExtendedAttribute.cc
Normal file
@ -0,0 +1,94 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2016, 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. */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#include "ExtendedAttribute.h"
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
ExtendedAttributeSet::~ExtendedAttributeSet()
|
||||
{
|
||||
std::map<int, ExtendedAttribute *>::iterator it;
|
||||
|
||||
for (it = a_set.begin(); it != a_set.end(); ++it)
|
||||
{
|
||||
if ( dispose )
|
||||
{
|
||||
delete it->second->va;
|
||||
}
|
||||
|
||||
delete it->second;
|
||||
}
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
ExtendedAttribute * ExtendedAttributeSet::get_attribute(int id) const
|
||||
{
|
||||
std::map<int, ExtendedAttribute*>::const_iterator it = a_set.find(id);
|
||||
|
||||
if ( it == a_set.end() )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void ExtendedAttributeSet::init_attribute_map(const std::string& id_name,
|
||||
std::vector<VectorAttribute *>& vas)
|
||||
{
|
||||
std::vector<VectorAttribute *>::iterator it;
|
||||
int id, auto_id;
|
||||
|
||||
for (it = vas.begin(), auto_id = 0; it != vas.end(); ++it, ++auto_id)
|
||||
{
|
||||
if (id_name.empty())
|
||||
{
|
||||
id = auto_id;
|
||||
}
|
||||
else if ( (*it)->vector_value(id_name, id) != 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ExtendedAttribute * a = attribute_factory(*it, id);
|
||||
|
||||
a_set.insert(make_pair(id, a));
|
||||
}
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
ExtendedAttribute * ExtendedAttributeSet::delete_attribute(int id)
|
||||
{
|
||||
std::map<int, ExtendedAttribute*>::iterator it = a_set.find(id);
|
||||
|
||||
if ( it == a_set.end() )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
a_set.erase(it);
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ lib_name='nebula_common'
|
||||
source_files=[
|
||||
'ActionManager.cc',
|
||||
'Attribute.cc',
|
||||
'ExtendedAttribute.cc',
|
||||
'mem_collector.c',
|
||||
'NebulaUtil.cc'
|
||||
]
|
||||
|
@ -626,7 +626,7 @@ int Datastore::insert_replace(SqlDB *db, bool replace, string& error_str)
|
||||
<< group_u << ","
|
||||
<< other_u << ")";
|
||||
|
||||
rc = db->exec(oss);
|
||||
rc = db->exec_wr(oss);
|
||||
|
||||
db->free_str(sql_name);
|
||||
db->free_str(sql_xml);
|
||||
|
@ -160,7 +160,7 @@ DatastorePool::DatastorePool(
|
||||
}
|
||||
|
||||
// User created datastores will start from ID 100
|
||||
set_update_lastOID(99);
|
||||
set_lastOID(99);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -154,7 +154,7 @@ int Document::insert_replace(SqlDB *db, bool replace, string& error_str)
|
||||
<< group_u << ","
|
||||
<< other_u << ")";
|
||||
|
||||
rc = db->exec(oss);
|
||||
rc = db->exec_wr(oss);
|
||||
|
||||
db->free_str(sql_name);
|
||||
db->free_str(sql_xml);
|
||||
|
@ -161,7 +161,7 @@ int Group::insert_replace(SqlDB *db, bool replace, string& error_str)
|
||||
<< other_u << ")";
|
||||
|
||||
|
||||
rc = db->exec(oss);
|
||||
rc = db->exec_wr(oss);
|
||||
|
||||
db->free_str(sql_name);
|
||||
db->free_str(sql_xml);
|
||||
|
@ -77,7 +77,7 @@ GroupPool::GroupPool(SqlDB * db, vector<const VectorAttribute *> hook_mads,
|
||||
goto error_groups;
|
||||
}
|
||||
|
||||
set_update_lastOID(99);
|
||||
set_lastOID(99);
|
||||
}
|
||||
|
||||
register_hooks(hook_mads, remotes_location);
|
||||
@ -249,7 +249,7 @@ int GroupPool::dump(ostringstream& oss, const string& where, const string& limit
|
||||
set_callback(static_cast<Callbackable::Callback>(&GroupPool::dump_cb),
|
||||
static_cast<void *>(&oss));
|
||||
|
||||
rc = db->exec(cmd, this);
|
||||
rc = db->exec_rd(cmd, this);
|
||||
|
||||
unset_callback();
|
||||
|
||||
|
@ -140,7 +140,7 @@ int Host::insert_replace(SqlDB *db, bool replace, string& error_str)
|
||||
<< other_u << ","
|
||||
<< cluster_id << ")";
|
||||
|
||||
rc = db->exec(oss);
|
||||
rc = db->exec_wr(oss);
|
||||
|
||||
db->free_str(sql_hostname);
|
||||
db->free_str(sql_xml);
|
||||
@ -553,7 +553,7 @@ int Host::update_monitoring(SqlDB * db)
|
||||
|
||||
db->free_str(sql_xml);
|
||||
|
||||
rc = db->exec(oss);
|
||||
rc = db->exec_local_wr(oss);
|
||||
|
||||
return rc;
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user