mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-11 04:58:16 +03:00
F #2489: Improve performance of oned:
* Reduce memory footprint * Improve connection handling in the RequestManager * Reduce the number of locking calls * Reduce the size of the VM pool
This commit is contained in:
parent
a69baeee1a
commit
f54e066949
@ -22,6 +22,8 @@
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
@ -275,6 +277,46 @@ private:
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
class string_cb : public Callbackable
|
||||
{
|
||||
public:
|
||||
string_cb(int _total):total_values(_total){};
|
||||
|
||||
void set_callback(std::string * _str)
|
||||
{
|
||||
str = _str;
|
||||
|
||||
Callbackable::set_callback(
|
||||
static_cast<Callbackable::Callback>(&string_cb::callback));
|
||||
};
|
||||
|
||||
int callback(void * nil, int num, char **values, char **names)
|
||||
{
|
||||
if ( (!values[0]) || (num != total_values) )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (int i=0; i < total_values; i++)
|
||||
{
|
||||
if ( values[i] != NULL )
|
||||
{
|
||||
str->append(values[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
private:
|
||||
int total_values;
|
||||
|
||||
std::string * str;
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
class stream_cb : public Callbackable
|
||||
{
|
||||
public:
|
||||
@ -327,5 +369,4 @@ public:
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
#endif /*CALLBACKABLE_H_*/
|
||||
|
@ -152,6 +152,19 @@ public:
|
||||
return static_cast<Cluster *>(PoolSQL::get(oid));
|
||||
};
|
||||
|
||||
/**
|
||||
* Function to get a read onlycluster from the pool, if the object is not
|
||||
* in memory it is loaded from the DB
|
||||
* @param oid cluster unique id
|
||||
*
|
||||
* @return a pointer to the cluster, 0 if the cluster could not be loaded
|
||||
*/
|
||||
|
||||
Cluster * get_ro(int oid)
|
||||
{
|
||||
return static_cast<Cluster *>(PoolSQL::get_ro(oid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops the Cluster from the data base. The object mutex SHOULD be
|
||||
* locked.
|
||||
@ -190,10 +203,10 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump(ostringstream& oss, const string& where, const string& limit,
|
||||
int dump(string& oss, const string& where, const string& limit,
|
||||
bool desc)
|
||||
{
|
||||
return PoolSQL::dump(oss, "CLUSTER_POOL", Cluster::table, where,
|
||||
return PoolSQL::dump(oss, "CLUSTER_POOL", "body", Cluster::table, where,
|
||||
limit, desc);
|
||||
};
|
||||
|
||||
|
@ -106,6 +106,17 @@ public:
|
||||
return static_cast<Datastore *>(PoolSQL::get(oid));
|
||||
};
|
||||
|
||||
/**
|
||||
* Function to get a read only Datastore from the pool, if the object is not in memory
|
||||
* it is loaded from the DB
|
||||
* @param oid Datastore unique id
|
||||
* @return a pointer to the Datastore, 0 if the Datastore could not be loaded
|
||||
*/
|
||||
Datastore * get_ro(int oid)
|
||||
{
|
||||
return static_cast<Datastore *>(PoolSQL::get_ro(oid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops the Datastore data in the data base. The object mutex SHOULD be
|
||||
* locked.
|
||||
@ -135,10 +146,10 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump(ostringstream& oss, const string& where, const string& limit,
|
||||
int dump(string& oss, const string& where, const string& limit,
|
||||
bool desc)
|
||||
{
|
||||
return PoolSQL::dump(oss, "DATASTORE_POOL", Datastore::table, where,
|
||||
return PoolSQL::dump(oss, "DATASTORE_POOL", "body", Datastore::table, where,
|
||||
limit, desc);
|
||||
};
|
||||
|
||||
|
@ -76,6 +76,19 @@ public:
|
||||
return static_cast<Document *>(PoolSQL::get(oid));
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets a read only object from the pool (if needed the object is loaded from the
|
||||
* database).
|
||||
* @param oid the object unique identifier
|
||||
* @param lock locks the object if true
|
||||
*
|
||||
* @return a pointer to the object, 0 in case of failure
|
||||
*/
|
||||
Document * get_ro(int oid)
|
||||
{
|
||||
return static_cast<Document *>(PoolSQL::get_ro(oid));
|
||||
};
|
||||
|
||||
/**
|
||||
* Dumps the pool in XML format. A filter can be also added to the
|
||||
* query
|
||||
@ -86,10 +99,10 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump(ostringstream& oss, const string& where, const string& limit,
|
||||
int dump(string& oss, const string& where, const string& limit,
|
||||
bool desc)
|
||||
{
|
||||
return PoolSQL::dump(oss, "DOCUMENT_POOL", Document::table, where,
|
||||
return PoolSQL::dump(oss, "DOCUMENT_POOL", "body", Document::table, where,
|
||||
limit, desc);
|
||||
};
|
||||
|
||||
|
@ -84,23 +84,35 @@ public:
|
||||
return static_cast<Group *>(PoolSQL::get(oid));
|
||||
};
|
||||
|
||||
/**
|
||||
* Function to get a read only group from the pool, if the object is not in memory
|
||||
* it is loaded from the DB
|
||||
* @param oid group unique id
|
||||
* @param lock locks the group mutex
|
||||
* @return a pointer to the group, 0 if the group could not be loaded
|
||||
*/
|
||||
Group * get_ro(int oid)
|
||||
{
|
||||
return static_cast<Group *>(PoolSQL::get_ro(oid));
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the name of a group
|
||||
* @param id of the group
|
||||
* @return name of the group
|
||||
*/
|
||||
const string& get_name(int gid)
|
||||
const string get_name(int gid)
|
||||
{
|
||||
static string error_str = "";
|
||||
|
||||
Group * group = get(gid);
|
||||
Group * group = get_ro(gid);
|
||||
|
||||
if ( group == 0 )
|
||||
{
|
||||
return error_str;
|
||||
}
|
||||
|
||||
const string& gname = group->get_name();
|
||||
const string gname = group->get_name();
|
||||
|
||||
group->unlock();
|
||||
|
||||
@ -152,7 +164,7 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump(ostringstream& oss, const string& where, const string& limit,
|
||||
int dump(string& oss, const string& where, const string& limit,
|
||||
bool desc);
|
||||
|
||||
private:
|
||||
|
@ -111,6 +111,14 @@ public:
|
||||
*/
|
||||
string& to_xml(string& xml) const;
|
||||
|
||||
/**
|
||||
* Function to print the History object into a string in
|
||||
* XML format with reduce information
|
||||
* @param xml the resulting XML string
|
||||
* @return a reference to the generated string
|
||||
*/
|
||||
string& to_xml_short(string& xml) const;
|
||||
|
||||
private:
|
||||
friend class VirtualMachine;
|
||||
friend class VirtualMachinePool;
|
||||
|
@ -81,6 +81,44 @@ public:
|
||||
return h;
|
||||
};
|
||||
|
||||
void update_prev_rediscovered_vms(int hoid,
|
||||
const set<int>& prev_rediscovered_vms)
|
||||
{
|
||||
|
||||
if (hoid < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
HostVM * hv = get_host_vm(hoid);
|
||||
|
||||
hv->prev_rediscovered_vms = prev_rediscovered_vms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get a read only Host from the pool, if the object is not in memory
|
||||
* it is loaded from the DB
|
||||
* @param oid Host unique id
|
||||
* @return a pointer to the Host, 0 if the Host could not be loaded
|
||||
*/
|
||||
Host * get_ro(
|
||||
int oid)
|
||||
{
|
||||
Host * h = static_cast<Host *>(PoolSQL::get_ro(oid));
|
||||
|
||||
if ( h != 0 )
|
||||
{
|
||||
HostVM * hv = get_host_vm(oid);
|
||||
|
||||
h->tmp_lost_vms = &(hv->tmp_lost_vms);
|
||||
h->tmp_zombie_vms = &(hv->tmp_zombie_vms);
|
||||
|
||||
h->prev_rediscovered_vms = &(hv->prev_rediscovered_vms);
|
||||
}
|
||||
|
||||
return h;
|
||||
};
|
||||
|
||||
/**
|
||||
* Function to get a Host from the pool, if the object is not in memory
|
||||
* it is loaded from the DB
|
||||
@ -106,6 +144,31 @@ public:
|
||||
return h;
|
||||
};
|
||||
|
||||
/**
|
||||
* Function to get a Host from the pool, if the object is not in memory
|
||||
* it is loaded from the DB
|
||||
* @param hostname
|
||||
* @param lock locks the Host mutex
|
||||
* @return a pointer to the Host, 0 if the Host could not be loaded
|
||||
*/
|
||||
Host * get_ro(string name)
|
||||
{
|
||||
// The owner is set to -1, because it is not used in the key() method
|
||||
Host * h = static_cast<Host *>(PoolSQL::get_ro(name,-1));
|
||||
|
||||
if ( h != 0 )
|
||||
{
|
||||
HostVM * hv = get_host_vm(h->oid);
|
||||
|
||||
h->tmp_lost_vms = &(hv->tmp_lost_vms);
|
||||
h->tmp_zombie_vms = &(hv->tmp_zombie_vms);
|
||||
|
||||
h->prev_rediscovered_vms = &(hv->prev_rediscovered_vms);
|
||||
}
|
||||
|
||||
return h;
|
||||
};
|
||||
|
||||
/**
|
||||
* Generate an index key for the object
|
||||
* @param name of the object
|
||||
@ -225,10 +288,10 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump(ostringstream& oss, const string& where, const string& limit,
|
||||
int dump(string& oss, const string& where, const string& limit,
|
||||
bool desc)
|
||||
{
|
||||
return PoolSQL::dump(oss, "HOST_POOL", Host::table, where, limit, desc);
|
||||
return PoolSQL::dump(oss, "HOST_POOL", "body", Host::table, where, limit, desc);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -253,8 +316,7 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump_monitoring(ostringstream& oss,
|
||||
const string& where);
|
||||
int dump_monitoring(string& oss, const string& where);
|
||||
|
||||
/**
|
||||
* Dumps the HOST monitoring information for a single HOST
|
||||
@ -264,8 +326,7 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump_monitoring(ostringstream& oss,
|
||||
int hostid)
|
||||
int dump_monitoring(string& oss, int hostid)
|
||||
{
|
||||
ostringstream filter;
|
||||
|
||||
|
@ -101,6 +101,17 @@ public:
|
||||
* @return a pointer to the Image, 0 if the Image could not be loaded
|
||||
*/
|
||||
Image * get(int oid)
|
||||
{
|
||||
return static_cast<Image *>(PoolSQL::get(oid));
|
||||
};
|
||||
|
||||
/**
|
||||
** Function to get a read only Image from the pool, if the object is not in memory
|
||||
* it is loaded from the DB
|
||||
* @param oid Image unique id
|
||||
* @return a pointer to the Image, 0 if the Image could not be loaded
|
||||
*/
|
||||
Image * get_ro(int oid)
|
||||
{
|
||||
return static_cast<Image *>(PoolSQL::get(oid));
|
||||
};
|
||||
@ -119,6 +130,19 @@ public:
|
||||
return static_cast<Image *>(PoolSQL::get(name,uid));
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets a read only object from the pool (if needed the object is loaded from the
|
||||
* database).
|
||||
* @param name of the object
|
||||
* @param uid id of owner
|
||||
*
|
||||
* @return a pointer to the object, 0 in case of failure
|
||||
*/
|
||||
Image * get_ro(const string& name, int uid)
|
||||
{
|
||||
return static_cast<Image *>(PoolSQL::get_ro(name,uid));
|
||||
};
|
||||
|
||||
/**
|
||||
* Bootstraps the database table(s) associated to the Image pool
|
||||
* @return 0 on success
|
||||
@ -138,10 +162,10 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump(ostringstream& oss, const string& where, const string& limit,
|
||||
int dump(string& oss, const string& where, const string& limit,
|
||||
bool desc)
|
||||
{
|
||||
return PoolSQL::dump(oss, "IMAGE_POOL", Image::table, where, limit,
|
||||
return PoolSQL::dump(oss, "IMAGE_POOL", "body", Image::table, where, limit,
|
||||
desc);
|
||||
}
|
||||
|
||||
|
@ -93,6 +93,16 @@ public:
|
||||
return static_cast<MarketPlaceApp *>(PoolSQL::get(oid));
|
||||
};
|
||||
|
||||
/**
|
||||
* Function to get a read only MarketPlaceApp from the pool
|
||||
* @param oid MarketPlaceApp unique id
|
||||
* @return a pointer to the MarketPlaceApp, 0 if not loaded
|
||||
*/
|
||||
MarketPlaceApp * get_ro(int oid)
|
||||
{
|
||||
return static_cast<MarketPlaceApp *>(PoolSQL::get_ro(oid));
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets an object from the pool (if needed the object is loaded from the
|
||||
* database).
|
||||
@ -107,6 +117,19 @@ public:
|
||||
return static_cast<MarketPlaceApp *>(PoolSQL::get(name, uid));
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets a read only object from the pool (if needed the object is loaded from the
|
||||
* database).
|
||||
* @param name of the object
|
||||
* @param uid id of owner
|
||||
*
|
||||
* @return a pointer to the object, 0 in case of failure
|
||||
*/
|
||||
MarketPlaceApp * get_ro(const std::string& name, int uid)
|
||||
{
|
||||
return static_cast<MarketPlaceApp *>(PoolSQL::get_ro(name, uid));
|
||||
};
|
||||
|
||||
/**
|
||||
* Bootstraps the database table(s) associated to the MarketPlace pool
|
||||
* @return 0 on success
|
||||
@ -126,10 +149,10 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump(std::ostringstream& oss, const std::string& where,
|
||||
int dump(std::string& oss, const std::string& where,
|
||||
const std::string& limit, bool desc)
|
||||
{
|
||||
return PoolSQL::dump(oss, "MARKETPLACEAPP_POOL", MarketPlaceApp::table,
|
||||
return PoolSQL::dump(oss, "MARKETPLACEAPP_POOL", "body", MarketPlaceApp::table,
|
||||
where, limit, desc);
|
||||
};
|
||||
|
||||
|
@ -72,6 +72,18 @@ public:
|
||||
return static_cast<MarketPlace *>(PoolSQL::get(oid));
|
||||
};
|
||||
|
||||
/**
|
||||
* Function to get a read only MarketPlace from the pool, the object is loaded if not
|
||||
* in memory
|
||||
* @param oid MarketPlace unique id
|
||||
* @param lock locks the MarketPlace mutex
|
||||
* @return a pointer to the MarketPlace, 0 if not loaded
|
||||
*/
|
||||
MarketPlace * get_ro(int oid)
|
||||
{
|
||||
return static_cast<MarketPlace *>(PoolSQL::get_ro(oid));
|
||||
};
|
||||
|
||||
/** Update a particular MarketPlace
|
||||
* @param objsql points to the market
|
||||
* @return 0 on success
|
||||
@ -106,10 +118,10 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump(std::ostringstream& oss, const std::string& where,
|
||||
int dump(std::string& oss, const std::string& where,
|
||||
const std::string& limit, bool desc)
|
||||
{
|
||||
return PoolSQL::dump(oss, "MARKETPLACE_POOL", MarketPlace::table, where,
|
||||
return PoolSQL::dump(oss, "MARKETPLACE_POOL", "body", MarketPlace::table, where,
|
||||
limit, desc);
|
||||
};
|
||||
|
||||
|
@ -458,7 +458,7 @@ public:
|
||||
{
|
||||
if ( uid != -1 )
|
||||
{
|
||||
User * user = upool->get(uid);
|
||||
User * user = upool->get_ro(uid);
|
||||
|
||||
if ( user == 0 )
|
||||
{
|
||||
@ -481,7 +481,7 @@ public:
|
||||
user->unlock();
|
||||
}
|
||||
|
||||
Group * group = gpool->get(gid);
|
||||
Group * group = gpool->get_ro(gid);
|
||||
|
||||
if ( group == 0 )
|
||||
{
|
||||
|
@ -177,18 +177,14 @@ public:
|
||||
lock_owner(-1),
|
||||
lock_req_id(-1),
|
||||
lock_time(0),
|
||||
mutex(0),
|
||||
table(_table)
|
||||
{
|
||||
pthread_mutex_init(&mutex,0);
|
||||
};
|
||||
|
||||
virtual ~PoolObjectSQL()
|
||||
{
|
||||
delete obj_template;
|
||||
|
||||
pthread_mutex_unlock(&mutex);
|
||||
|
||||
pthread_mutex_destroy(&mutex);
|
||||
};
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
@ -317,30 +313,18 @@ public:
|
||||
string& error_str);
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Function to lock the object
|
||||
*/
|
||||
void lock()
|
||||
{
|
||||
pthread_mutex_lock(&mutex);
|
||||
};
|
||||
|
||||
/**
|
||||
* Function to unlock the object
|
||||
* Function to unlock the object. It also frees associated resources. Object
|
||||
* cannot be access after unlocking it
|
||||
*/
|
||||
void unlock()
|
||||
{
|
||||
pthread_mutex_unlock(&mutex);
|
||||
};
|
||||
if (!ro && mutex != 0)
|
||||
{
|
||||
pthread_mutex_unlock(mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to lock the object
|
||||
* @return 0 on success or error_code
|
||||
*/
|
||||
int trylock()
|
||||
{
|
||||
return pthread_mutex_trylock(&mutex);
|
||||
delete this;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -814,6 +798,11 @@ protected:
|
||||
*/
|
||||
time_t lock_time;
|
||||
|
||||
/**
|
||||
* Attribute for check if is a read only object
|
||||
*/
|
||||
bool ro;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Characters that can not be in a name
|
||||
@ -834,7 +823,7 @@ private:
|
||||
* The mutex for the PoolObject. This implementation assumes that the mutex
|
||||
* IS LOCKED when the class destructor is called.
|
||||
*/
|
||||
pthread_mutex_t mutex;
|
||||
pthread_mutex_t * mutex;
|
||||
|
||||
/**
|
||||
* Pointer to the SQL table for the PoolObjectSQL
|
||||
|
@ -62,12 +62,20 @@ public:
|
||||
* Gets an object from the pool (if needed the object is loaded from the
|
||||
* database).
|
||||
* @param oid the object unique identifier
|
||||
* @param lock locks the object if true
|
||||
*
|
||||
* @return a pointer to the object, 0 in case of failure
|
||||
*/
|
||||
PoolObjectSQL * get(int oid);
|
||||
|
||||
/**
|
||||
* Gets a read only object from the pool (if needed the object is loaded from the
|
||||
* database).
|
||||
* @param oid the object unique identifier
|
||||
*
|
||||
* @return a pointer to the object, 0 in case of failure
|
||||
*/
|
||||
PoolObjectSQL * get_ro(int oid);
|
||||
|
||||
/**
|
||||
* Check if there is an object with the same for a given user
|
||||
* @param name of object
|
||||
@ -172,7 +180,7 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump(ostringstream& oss, const string& where, bool desc)
|
||||
int dump(string& oss, const string& where, bool desc)
|
||||
{
|
||||
return dump(oss, where, "", desc);
|
||||
}
|
||||
@ -188,7 +196,7 @@ public:
|
||||
* @return 0 on success
|
||||
*/
|
||||
|
||||
virtual int dump(ostringstream& oss, const string& where,
|
||||
virtual int dump(string& oss, const string& where,
|
||||
const string& limit, bool desc) = 0;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@ -259,12 +267,21 @@ protected:
|
||||
* database).
|
||||
* @param name of the object
|
||||
* @param uid id of owner
|
||||
* @param lock locks the object if true
|
||||
*
|
||||
* @return a pointer to the object, 0 in case of failure
|
||||
*/
|
||||
PoolObjectSQL * get(const string& name, int uid);
|
||||
|
||||
/**
|
||||
* Gets a read only object from the pool (if needed the object is loaded from the
|
||||
* database).
|
||||
* @param name of the object
|
||||
* @param uid id of owner
|
||||
*
|
||||
* @return a pointer to the object, 0 in case of failure
|
||||
*/
|
||||
PoolObjectSQL * get_ro(const string& name, int uid);
|
||||
|
||||
/**
|
||||
* Pointer to the database.
|
||||
*/
|
||||
@ -282,8 +299,9 @@ protected:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump(ostringstream& oss,
|
||||
int dump(string& oss,
|
||||
const string& elem_name,
|
||||
const string& column,
|
||||
const char * table,
|
||||
const string& where,
|
||||
const string& limit,
|
||||
@ -300,13 +318,13 @@ protected:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump(ostringstream& oss,
|
||||
int dump(string& oss,
|
||||
const string& elem_name,
|
||||
const char * table,
|
||||
const string& where,
|
||||
bool desc)
|
||||
{
|
||||
return dump(oss, elem_name, table, where, "", desc);
|
||||
return dump(oss, elem_name, "body", table, where, "", desc);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -318,18 +336,10 @@ protected:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump(ostringstream& oss,
|
||||
int dump(string& oss,
|
||||
const string& root_elem_name,
|
||||
ostringstream& sql_query);
|
||||
|
||||
/**
|
||||
* Child classes can add extra elements to the dump xml, right after all the
|
||||
* pool objects
|
||||
*
|
||||
* @param oss The output stream to dump the xml contents
|
||||
*/
|
||||
virtual void add_extra_xml(ostringstream& oss){};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Interface to access the lastOID assigned by the pool */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
@ -50,19 +50,7 @@ public:
|
||||
*
|
||||
* @param oid of the object
|
||||
*/
|
||||
void lock_line(int oid);
|
||||
|
||||
/**
|
||||
* Sets the reference of the active object and unlocks the cache line. The
|
||||
* mutex of the object MUST be locked
|
||||
*
|
||||
* @param oid of the object
|
||||
* @param object to be inserted int the cache
|
||||
*
|
||||
* @return 0 on success
|
||||
*
|
||||
*/
|
||||
int set_line(int oid, PoolObjectSQL * object);
|
||||
pthread_mutex_t * lock_line(int oid);
|
||||
|
||||
private:
|
||||
/**
|
||||
@ -71,15 +59,13 @@ private:
|
||||
*/
|
||||
struct CacheLine
|
||||
{
|
||||
CacheLine(PoolObjectSQL * o):active(0), object(o)
|
||||
CacheLine():active(0)
|
||||
{
|
||||
pthread_mutex_init(&mutex, 0);
|
||||
};
|
||||
|
||||
~CacheLine()
|
||||
{
|
||||
delete object;
|
||||
|
||||
pthread_mutex_destroy(&mutex);
|
||||
}
|
||||
|
||||
@ -99,7 +85,7 @@ private:
|
||||
}
|
||||
|
||||
/**
|
||||
* Concurrent access to cache line
|
||||
* Concurrent access to object
|
||||
*/
|
||||
pthread_mutex_t mutex;
|
||||
|
||||
@ -107,11 +93,6 @@ private:
|
||||
* Number of threads waiting on the line mutex
|
||||
*/
|
||||
int active;
|
||||
|
||||
/**
|
||||
* Reference to the object
|
||||
*/
|
||||
PoolObjectSQL * object;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -74,13 +74,17 @@ public:
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* Stops the main RM thread.
|
||||
*/
|
||||
void finalize()
|
||||
{
|
||||
am.finalize();
|
||||
};
|
||||
|
||||
/**
|
||||
* @return an AbyssServer to run xmlrpc connections
|
||||
*/
|
||||
xmlrpc_c::serverAbyss * create_abyss();
|
||||
|
||||
private:
|
||||
|
||||
@ -95,12 +99,12 @@ private:
|
||||
/**
|
||||
* Thread id for the RequestManager
|
||||
*/
|
||||
pthread_t rm_thread;
|
||||
pthread_t rm_thread;
|
||||
|
||||
/**
|
||||
* Thread id for the XML Server
|
||||
*/
|
||||
pthread_t rm_xml_server_thread;
|
||||
pthread_t rm_xml_server_thread;
|
||||
|
||||
/**
|
||||
* Port number where the connection will be open
|
||||
@ -150,18 +154,13 @@ private:
|
||||
/**
|
||||
* Action engine for the Manager
|
||||
*/
|
||||
ActionManager am;
|
||||
ActionManager am;
|
||||
|
||||
/**
|
||||
* To register XML-RPC methods
|
||||
*/
|
||||
xmlrpc_c::registry RequestManagerRegistry;
|
||||
|
||||
/**
|
||||
* The XML-RPC server
|
||||
*/
|
||||
xmlrpc_c::serverAbyss * AbyssServer;
|
||||
|
||||
/**
|
||||
* Register the XML-RPC API Calls
|
||||
*/
|
||||
@ -182,8 +181,6 @@ private:
|
||||
|
||||
NebulaLog::log("ReM",Log::INFO,"XML-RPC server stopped.");
|
||||
|
||||
delete AbyssServer;
|
||||
|
||||
if ( socket_fd != -1 )
|
||||
{
|
||||
close(socket_fd);
|
||||
@ -191,9 +188,5 @@ private:
|
||||
};
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -153,7 +153,7 @@ protected:
|
||||
int pool_allocate(int sid, Template * tmpl, int& id, RequestAttributes& att)
|
||||
{
|
||||
DocumentPool * docpool = static_cast<DocumentPool *>(pool);
|
||||
Document * doc = docpool->get(sid);
|
||||
Document * doc = docpool->get_ro(sid);
|
||||
|
||||
if ( doc == 0 )
|
||||
{
|
||||
|
122
include/RequestManagerConnection.h
Normal file
122
include/RequestManagerConnection.h
Normal file
@ -0,0 +1,122 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2018, 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_CONNECTION_H_
|
||||
#define REQUEST_MANAGER_CONNECTION_H_
|
||||
|
||||
#include "RequestManager.h"
|
||||
|
||||
|
||||
/**
|
||||
* The connection manager class synchronizes the connection and manager threads
|
||||
*/
|
||||
class ConnectionManager
|
||||
{
|
||||
public:
|
||||
ConnectionManager(RequestManager *_rm, int mc):rm(_rm), max_connections(mc)
|
||||
{
|
||||
pthread_mutex_init(&mutex,0);
|
||||
|
||||
pthread_cond_init(&cond,0);
|
||||
};
|
||||
|
||||
~ConnectionManager()
|
||||
{
|
||||
pthread_mutex_destroy(&mutex);
|
||||
|
||||
pthread_cond_destroy(&cond);
|
||||
};
|
||||
|
||||
/**
|
||||
* Increments number of active connections
|
||||
*/
|
||||
int add()
|
||||
{
|
||||
pthread_mutex_lock(&mutex);
|
||||
|
||||
++connections;
|
||||
|
||||
pthread_mutex_unlock(&mutex);
|
||||
|
||||
return connections;
|
||||
};
|
||||
|
||||
/**
|
||||
* Decrements number of active connections and signals management thread
|
||||
*/
|
||||
void del()
|
||||
{
|
||||
pthread_mutex_lock(&mutex);
|
||||
|
||||
--connections;
|
||||
|
||||
pthread_cond_signal(&cond);
|
||||
|
||||
pthread_mutex_unlock(&mutex);
|
||||
};
|
||||
|
||||
/**
|
||||
* Waits for active connections to be under the max_connection threshold
|
||||
*/
|
||||
void wait()
|
||||
{
|
||||
pthread_mutex_lock(&mutex);
|
||||
|
||||
while ( connections >= max_connections )
|
||||
{
|
||||
pthread_cond_wait(&cond, &mutex);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&mutex);
|
||||
};
|
||||
|
||||
/**
|
||||
* Run an xmlrpc connection
|
||||
* @param fd connected socket
|
||||
*/
|
||||
void run_connection(int fd)
|
||||
{
|
||||
xmlrpc_c::serverAbyss * as = rm->create_abyss();
|
||||
|
||||
as->runConn(fd);
|
||||
|
||||
delete as;
|
||||
};
|
||||
|
||||
private:
|
||||
/**
|
||||
* Synchronization for connection threads and listener thread
|
||||
*/
|
||||
pthread_mutex_t mutex;
|
||||
pthread_cond_t cond;
|
||||
|
||||
/**
|
||||
* RequestManager to create an AbyssSever class to handle each request
|
||||
*/
|
||||
RequestManager * rm;
|
||||
|
||||
/**
|
||||
* Number of active connections
|
||||
*/
|
||||
int connections;
|
||||
|
||||
/**
|
||||
* Max number of active connections
|
||||
*/
|
||||
int max_connections;
|
||||
};
|
||||
|
||||
#endif
|
@ -72,6 +72,17 @@ public:
|
||||
return static_cast<SecurityGroup *>(PoolSQL::get(oid));
|
||||
};
|
||||
|
||||
/**
|
||||
* Function to get a read only SecurityGroup from the pool, if the object is not in memory
|
||||
* it is loaded from the DB
|
||||
* @param oid SecurityGroup unique id
|
||||
* @return a pointer to the SecurityGroup, 0 if the SecurityGroup could not be loaded
|
||||
*/
|
||||
SecurityGroup * get_ro(int oid)
|
||||
{
|
||||
return static_cast<SecurityGroup *>(PoolSQL::get_ro(oid));
|
||||
};
|
||||
|
||||
/** Update a particular SecurityGroup
|
||||
* @param securitygroup pointer to SecurityGroup
|
||||
* @return 0 on success
|
||||
@ -100,10 +111,10 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump(ostringstream& oss, const string& where, const string& limit,
|
||||
int dump(string& oss, const string& where, const string& limit,
|
||||
bool desc)
|
||||
{
|
||||
return PoolSQL::dump(oss, "SECURITY_GROUP_POOL", SecurityGroup::table,
|
||||
return PoolSQL::dump(oss, "SECURITY_GROUP_POOL", "body", SecurityGroup::table,
|
||||
where, limit, desc);
|
||||
};
|
||||
|
||||
|
@ -92,6 +92,24 @@ public:
|
||||
return u;
|
||||
};
|
||||
|
||||
/**
|
||||
* Function to get a read only User from the pool, if the object is not in memory
|
||||
* it is loaded from the DB
|
||||
* @param oid User unique id
|
||||
* @return a pointer to the User, 0 if the User could not be loaded
|
||||
*/
|
||||
User * get_ro(int oid)
|
||||
{
|
||||
User * u = static_cast<User *>(PoolSQL::get_ro(oid));
|
||||
|
||||
if ( u != 0 )
|
||||
{
|
||||
u->session = get_session_token(oid);
|
||||
}
|
||||
|
||||
return u;
|
||||
};
|
||||
|
||||
/**
|
||||
* Function to get a User from the pool, if the object is not in memory
|
||||
* it is loaded from the DB
|
||||
@ -112,6 +130,25 @@ public:
|
||||
return u;
|
||||
};
|
||||
|
||||
/**
|
||||
* Function to get a read only User from the pool, if the object is not in memory
|
||||
* it is loaded from the DB
|
||||
* @param username
|
||||
* @return a pointer to the User, 0 if the User could not be loaded
|
||||
*/
|
||||
User * get_ro(string name)
|
||||
{
|
||||
// The owner is set to -1, because it is not used in the key() method
|
||||
User * u = static_cast<User *>(PoolSQL::get_ro(name,-1));
|
||||
|
||||
if ( u != 0 )
|
||||
{
|
||||
u->session = get_session_token(u->oid);
|
||||
}
|
||||
|
||||
return u;
|
||||
};
|
||||
|
||||
/**
|
||||
* Function to get the token password of an user from the pool
|
||||
* @param uid creator of the object
|
||||
@ -182,7 +219,7 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump(ostringstream& oss, const string& where, const string& limit,
|
||||
int dump(string& oss, const string& where, const string& limit,
|
||||
bool desc);
|
||||
|
||||
/**
|
||||
|
@ -104,10 +104,10 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump(std::ostringstream& os, const std::string& where,
|
||||
int dump(std::string& os, const std::string& where,
|
||||
const std::string& limit, bool desc)
|
||||
{
|
||||
return PoolSQL::dump(os, "VM_GROUP_POOL", VMGroup::table, where, limit,
|
||||
return PoolSQL::dump(os, "VM_GROUP_POOL", "body", VMGroup::table, where, limit,
|
||||
desc);
|
||||
};
|
||||
|
||||
|
@ -67,6 +67,18 @@ public:
|
||||
return static_cast<VMTemplate *>(PoolSQL::get(oid));
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets an object from the pool (if needed the object is loaded from the
|
||||
* database).
|
||||
* @param oid the object unique identifier
|
||||
*
|
||||
* @return a pointer to the object, 0 in case of failure
|
||||
*/
|
||||
VMTemplate * get_ro(int oid)
|
||||
{
|
||||
return static_cast<VMTemplate *>(PoolSQL::get_ro(oid));
|
||||
};
|
||||
|
||||
/**
|
||||
* Dumps the pool in XML format. A filter can be also added to the
|
||||
* query
|
||||
@ -77,10 +89,10 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump(ostringstream& oss, const string& where, const string& limit,
|
||||
int dump(string& oss, const string& where, const string& limit,
|
||||
bool desc)
|
||||
{
|
||||
return PoolSQL::dump(oss, "VMTEMPLATE_POOL", VMTemplate::table, where,
|
||||
return PoolSQL::dump(oss, "VMTEMPLATE_POOL", "body", VMTemplate::table, where,
|
||||
limit, desc);
|
||||
};
|
||||
|
||||
|
@ -95,10 +95,10 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump(ostringstream& oss, const string& where, const string& limit,
|
||||
int dump(string& oss, const string& where, const string& limit,
|
||||
bool desc)
|
||||
{
|
||||
return PoolSQL::dump(oss, "VDC_POOL", Vdc::table, where, limit, desc);
|
||||
return PoolSQL::dump(oss, "VDC_POOL", "body", Vdc::table, where, limit, desc);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -874,6 +874,14 @@ public:
|
||||
return to_xml_extended(xml, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to print the VirtualMachine object into a string in
|
||||
* XML format, with reduced information
|
||||
* @param xml the resulting XML string
|
||||
* @return a reference to the generated string
|
||||
*/
|
||||
string& to_xml_short(string& xml);
|
||||
|
||||
/**
|
||||
* Function to print the VirtualMachine object into a string in
|
||||
* XML format, with extended information (full history records)
|
||||
|
@ -333,6 +333,12 @@ public:
|
||||
*/
|
||||
void set_types(const string& ds_name);
|
||||
|
||||
/**
|
||||
* Marshall disk attributes in XML format with just essential information
|
||||
* @param stream to write the disk XML description
|
||||
*/
|
||||
void to_xml_short(std::ostringstream& oss) const;
|
||||
|
||||
private:
|
||||
|
||||
Snapshots * snapshots;
|
||||
@ -743,6 +749,12 @@ public:
|
||||
void delete_non_persistent_snapshots(Template **vm_quotas,
|
||||
vector<Template *> &ds_quotas);
|
||||
|
||||
/**
|
||||
* Marshall disks in XML format with just essential information
|
||||
* @param xml string to write the disk XML description
|
||||
*/
|
||||
std::string& to_xml_short(std::string& xml);
|
||||
|
||||
protected:
|
||||
|
||||
VirtualMachineAttribute * attribute_factory(VectorAttribute * va,
|
||||
|
@ -44,9 +44,9 @@ public:
|
||||
VirtualMachineMonitorInfo new_info;
|
||||
|
||||
char * error_c = 0;
|
||||
|
||||
|
||||
remove_state();
|
||||
|
||||
|
||||
if (new_info.parse(monitor_data, &error_c) != 0)
|
||||
{
|
||||
error = error_c;
|
||||
@ -76,6 +76,32 @@ public:
|
||||
|
||||
return state_str[0];
|
||||
};
|
||||
|
||||
string& to_xml_short(string& xml) const
|
||||
{
|
||||
ostringstream oss;
|
||||
string cpu, memory, state;
|
||||
|
||||
if (attributes.empty())
|
||||
{
|
||||
oss << "<MONITORING/>";
|
||||
}
|
||||
else
|
||||
{
|
||||
get("CPU", cpu);
|
||||
get("MEMORY", memory);
|
||||
get("STATE", state);
|
||||
|
||||
oss << "<MONITORING>"
|
||||
<< "<CPU>" << one_util::escape_xml(cpu) << "</CPU>"
|
||||
<< "<MEMORY>" << one_util::escape_xml(memory) << "</MEMORY>"
|
||||
<< "<STATE>" << one_util::escape_xml(state) << "</STATE>"
|
||||
<< "</MONITORING>";
|
||||
}
|
||||
|
||||
xml = oss.str();
|
||||
return xml;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -95,6 +95,12 @@ public:
|
||||
*/
|
||||
int release_network_leases(int vmid);
|
||||
|
||||
/**
|
||||
* Marshall disk attributes in XML format with just essential information
|
||||
* @param stream to write the disk XML description
|
||||
*/
|
||||
void to_xml_short(std::ostringstream& oss) const;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Fills the authorization request for this NIC based on the VNET and SG
|
||||
@ -298,12 +304,11 @@ public:
|
||||
int set_up_attach_nic(int vmid, int uid, int cluster_id,
|
||||
VectorAttribute * vnic, VectorAttribute * nic_default,
|
||||
vector<VectorAttribute*>& sgs, std::string& error_str);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Marshall NICs in XML format with just essential information
|
||||
* @param xml string to write the NIC XML description
|
||||
*/
|
||||
std::string& to_xml_short(std::string& xml);
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -83,6 +83,18 @@ public:
|
||||
return static_cast<VirtualMachine *>(PoolSQL::get(oid));
|
||||
};
|
||||
|
||||
/**
|
||||
* Function to get a read only VM from the pool, if the object is not
|
||||
* in memory it is loade from the DB
|
||||
* @param oid VM unique id
|
||||
* @return a pointer to the VM, 0 if the VM could not be loaded
|
||||
*/
|
||||
VirtualMachine * get_ro(
|
||||
int oid)
|
||||
{
|
||||
return static_cast<VirtualMachine *>(PoolSQL::get_ro(oid));
|
||||
};
|
||||
|
||||
/**
|
||||
* Function to get a VM from the pool, string version for VM ID
|
||||
*/
|
||||
@ -102,6 +114,25 @@ public:
|
||||
return static_cast<VirtualMachine *>(PoolSQL::get(oid));
|
||||
};
|
||||
|
||||
/**
|
||||
* Function to get a read only VM from the pool, string version for VM ID
|
||||
*/
|
||||
VirtualMachine * get_ro(
|
||||
const string& oid_s)
|
||||
{
|
||||
istringstream iss(oid_s);
|
||||
int oid;
|
||||
|
||||
iss >> oid;
|
||||
|
||||
if ( iss.fail() )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return static_cast<VirtualMachine *>(PoolSQL::get_ro(oid));
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates a VM in the data base. The VM SHOULD be locked. It also updates
|
||||
* the previous state after executing the hooks.
|
||||
@ -250,10 +281,10 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump(ostringstream& oss, const string& where, const string& limit,
|
||||
int dump(string& oss, const string& where, const string& limit,
|
||||
bool desc)
|
||||
{
|
||||
return PoolSQL::dump(oss, "VM_POOL", VirtualMachine::table, where,
|
||||
return PoolSQL::dump(oss, "VM_POOL", "short_body", VirtualMachine::table, where,
|
||||
limit, desc);
|
||||
};
|
||||
|
||||
@ -265,7 +296,7 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump_acct(ostringstream& oss,
|
||||
int dump_acct(string& oss,
|
||||
const string& where,
|
||||
int time_start,
|
||||
int time_end);
|
||||
@ -286,7 +317,7 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump_showback(ostringstream& oss,
|
||||
int dump_showback(string& oss,
|
||||
const string& where,
|
||||
int start_month,
|
||||
int start_year,
|
||||
@ -302,8 +333,7 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump_monitoring(ostringstream& oss,
|
||||
const string& where);
|
||||
int dump_monitoring(string& oss, const string& where);
|
||||
|
||||
/**
|
||||
* Dumps the VM monitoring information for a single VM
|
||||
@ -313,8 +343,7 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump_monitoring(ostringstream& oss,
|
||||
int vmid)
|
||||
int dump_monitoring(string& oss, int vmid)
|
||||
{
|
||||
ostringstream filter;
|
||||
|
||||
|
@ -76,6 +76,8 @@ public:
|
||||
Template::parse_restricted(ra, restricted);
|
||||
}
|
||||
|
||||
string& to_xml_short(string& xml) const;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Restricted attribute list for VirtualMachineTemplates
|
||||
|
@ -97,6 +97,18 @@ public:
|
||||
return static_cast<VirtualNetwork *>(PoolSQL::get(oid));
|
||||
};
|
||||
|
||||
/**
|
||||
* Function to get a read only VN from the pool, if the object is not in memory
|
||||
* it is loaded from the DB
|
||||
* @param oid VN unique id
|
||||
* @param lock locks the VN mutex
|
||||
* @return a pointer to the VN, 0 if the VN could not be loaded
|
||||
*/
|
||||
VirtualNetwork * get_ro(int oid)
|
||||
{
|
||||
return static_cast<VirtualNetwork *>(PoolSQL::get_ro(oid));
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets an object from the pool (if needed the object is loaded from the
|
||||
* database).
|
||||
@ -111,6 +123,20 @@ public:
|
||||
return static_cast<VirtualNetwork *>(PoolSQL::get(name,uid));
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets a read only object from the pool (if needed the object is loaded from the
|
||||
* database).
|
||||
* @param name of the object
|
||||
* @param uid id of owner
|
||||
* @param lock locks the object if true
|
||||
*
|
||||
* @return a pointer to the object, 0 in case of failure
|
||||
*/
|
||||
VirtualNetwork * get_ro(const string& name, int uid)
|
||||
{
|
||||
return static_cast<VirtualNetwork *>(PoolSQL::get_ro(name,uid));
|
||||
};
|
||||
|
||||
/**
|
||||
* Bootstraps the database table(s) associated to the VirtualNetwork pool
|
||||
* @return 0 on success
|
||||
@ -137,10 +163,10 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump(ostringstream& oss, const string& where, const string& limit,
|
||||
int dump(string& oss, const string& where, const string& limit,
|
||||
bool desc)
|
||||
{
|
||||
return PoolSQL::dump(oss, "VNET_POOL", VirtualNetwork::table, where,
|
||||
return PoolSQL::dump(oss, "VNET_POOL", "body", VirtualNetwork::table, where,
|
||||
limit, desc);
|
||||
}
|
||||
|
||||
@ -302,11 +328,12 @@ private:
|
||||
VirtualNetwork * get_nic_by_name(VirtualMachineNic * nic,
|
||||
const string& name,
|
||||
int _uidi,
|
||||
bool ro,
|
||||
string& error);
|
||||
/**
|
||||
* Function to get a VirtualNetwork by its id, as provided by a VM template
|
||||
*/
|
||||
VirtualNetwork * get_nic_by_id(const string& id_s, string& error);
|
||||
VirtualNetwork * get_nic_by_id(const string& id_s, bool ro, string& error);
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// VLAN ID management functions
|
||||
|
@ -73,11 +73,24 @@ public:
|
||||
*
|
||||
* @return a pointer to the object, 0 in case of failure
|
||||
*/
|
||||
VirtualRouter * get(int oid)
|
||||
VirtualRouter * get(int oid)
|
||||
{
|
||||
return static_cast<VirtualRouter *>(PoolSQL::get(oid));
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets a read only object from the pool (if needed the object is loaded from the
|
||||
* database).
|
||||
* @param oid the object unique identifier
|
||||
* @param lock locks the object if true
|
||||
*
|
||||
* @return a pointer to the object, 0 in case of failure
|
||||
*/
|
||||
VirtualRouter * get_ro(int oid)
|
||||
{
|
||||
return static_cast<VirtualRouter *>(PoolSQL::get_ro(oid));
|
||||
};
|
||||
|
||||
/**
|
||||
* Dumps the pool in XML format. A filter can be also added to the
|
||||
* query
|
||||
@ -88,10 +101,10 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump(ostringstream& oss, const string& where, const string& limit,
|
||||
int dump(string& oss, const string& where, const string& limit,
|
||||
bool desc)
|
||||
{
|
||||
return PoolSQL::dump(oss, "VROUTER_POOL", VirtualRouter::table, where,
|
||||
return PoolSQL::dump(oss, "VROUTER_POOL", "body", VirtualRouter::table, where,
|
||||
limit, desc);
|
||||
};
|
||||
|
||||
|
@ -96,10 +96,10 @@ public:
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int dump(ostringstream& oss, const string& where, const string& limit,
|
||||
int dump(string& oss, const string& where, const string& limit,
|
||||
bool desc)
|
||||
{
|
||||
return PoolSQL::dump(oss, "ZONE_POOL", Zone::table, where, limit, desc);
|
||||
return PoolSQL::dump(oss, "ZONE_POOL", "body", Zone::table, where, limit, desc);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -157,7 +157,7 @@ int Cluster::get_default_system_ds(const set<int>& ds_set)
|
||||
|
||||
for (set<int>::const_iterator it = ds_set.begin(); it != ds_set.end(); it++)
|
||||
{
|
||||
ds = dspool->get(*it);
|
||||
ds = dspool->get_ro(*it);
|
||||
|
||||
if (ds == 0)
|
||||
{
|
||||
|
@ -277,7 +277,7 @@ int DatastorePool::drop(PoolObjectSQL * objsql, string& error_msg)
|
||||
|
||||
int DatastorePool::disk_attribute(int ds_id, VirtualMachineDisk * disk)
|
||||
{
|
||||
Datastore * ds = get(ds_id);
|
||||
Datastore * ds = get_ro(ds_id);
|
||||
|
||||
if (ds == 0)
|
||||
{
|
||||
|
@ -462,7 +462,7 @@ int DispatchManager::undeploy(int vid, bool hard, const RequestAttributes& ra,
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
VirtualMachine * vm = vmpool->get(vid);
|
||||
VirtualMachine * vm = vmpool->get_ro(vid);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
@ -517,7 +517,7 @@ int DispatchManager::poweroff (int vid, bool hard, const RequestAttributes& ra,
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
VirtualMachine * vm = vmpool->get(vid);
|
||||
VirtualMachine * vm = vmpool->get_ro(vid);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
@ -688,7 +688,7 @@ int DispatchManager::stop(int vid, const RequestAttributes& ra,
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
VirtualMachine * vm = vmpool->get(vid);
|
||||
VirtualMachine * vm = vmpool->get_ro(vid);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
@ -735,7 +735,7 @@ int DispatchManager::suspend(int vid, const RequestAttributes& ra,
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
VirtualMachine * vm = vmpool->get(vid);
|
||||
VirtualMachine * vm = vmpool->get_ro(vid);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
@ -1078,7 +1078,7 @@ int DispatchManager::delete_vm(VirtualMachine * vm, const RequestAttributes& ra,
|
||||
|
||||
if(host_id != -1)
|
||||
{
|
||||
Host * host = hpool->get(host_id);
|
||||
Host * host = hpool->get_ro(host_id);
|
||||
|
||||
if ( host == 0 )
|
||||
{
|
||||
|
@ -222,7 +222,7 @@ int GroupPool::drop(PoolObjectSQL * objsql, string& error_msg)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int GroupPool::dump(ostringstream& oss, const string& where,
|
||||
int GroupPool::dump(string& oss, const string& where,
|
||||
const string& limit, bool desc)
|
||||
{
|
||||
int rc;
|
||||
@ -252,9 +252,9 @@ int GroupPool::dump(ostringstream& oss, const string& where,
|
||||
cmd << " LIMIT " << limit;
|
||||
}
|
||||
|
||||
oss << "<GROUP_POOL>";
|
||||
oss.append("<GROUP_POOL>");
|
||||
|
||||
stream_cb cb(2);
|
||||
string_cb cb(2);
|
||||
|
||||
cb.set_callback(&oss);
|
||||
|
||||
@ -262,9 +262,9 @@ int GroupPool::dump(ostringstream& oss, const string& where,
|
||||
|
||||
cb.unset_callback();
|
||||
|
||||
oss << Nebula::instance().get_default_group_quota().to_xml(def_quota_xml);
|
||||
oss.append(Nebula::instance().get_default_group_quota().to_xml(def_quota_xml));
|
||||
|
||||
oss << "</GROUP_POOL>";
|
||||
oss.append("</GROUP_POOL>");
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ int HostPool::discover(
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int HostPool::dump_monitoring(
|
||||
ostringstream& oss,
|
||||
string& oss,
|
||||
const string& where)
|
||||
{
|
||||
ostringstream cmd;
|
||||
|
@ -146,7 +146,7 @@ void MonitorThread::do_message()
|
||||
|
||||
if (cid != -1)
|
||||
{
|
||||
Cluster *cluster = cpool->get(cid);
|
||||
Cluster * cluster = cpool->get_ro(cid);
|
||||
|
||||
if (cluster != 0)
|
||||
{
|
||||
@ -158,7 +158,7 @@ void MonitorThread::do_message()
|
||||
|
||||
for (itm = datastores.begin(); itm != datastores.end(); itm++)
|
||||
{
|
||||
ds = dspool->get(itm->first);
|
||||
ds = dspool->get_ro(itm->first);
|
||||
|
||||
if (ds == 0)
|
||||
{
|
||||
@ -226,7 +226,7 @@ void MonitorThread::do_message()
|
||||
|
||||
for (its = lost.begin(); its != lost.end(); its++)
|
||||
{
|
||||
VirtualMachine * vm = vmpool->get(*its);
|
||||
VirtualMachine * vm = vmpool->get_ro(*its);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -288,14 +288,8 @@ void MonitorThread::do_message()
|
||||
|
||||
// The rediscovered set is not stored in the DB, the update method
|
||||
// is not needed
|
||||
host = hpool->get(host_id);
|
||||
|
||||
if ( host != 0 )
|
||||
{
|
||||
host->set_prev_rediscovered_vms(rediscovered_vms);
|
||||
|
||||
host->unlock();
|
||||
}
|
||||
hpool->update_prev_rediscovered_vms(host_id, rediscovered_vms);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -191,7 +191,7 @@ void ImageManager::monitor_datastore(int ds_id)
|
||||
return;
|
||||
}
|
||||
|
||||
Datastore * ds = dspool->get(ds_id);
|
||||
Datastore * ds = dspool->get_ro(ds_id);
|
||||
|
||||
if ( ds == 0 )
|
||||
{
|
||||
|
@ -459,7 +459,7 @@ int ImageManager::delete_image(int iid, string& error_str)
|
||||
|
||||
ostringstream oss;
|
||||
|
||||
img = ipool->get(iid);
|
||||
img = ipool->get_ro(iid);
|
||||
|
||||
if ( img == 0 )
|
||||
{
|
||||
@ -471,7 +471,7 @@ int ImageManager::delete_image(int iid, string& error_str)
|
||||
|
||||
img->unlock();
|
||||
|
||||
ds = dspool->get(ds_id);
|
||||
ds = dspool->get_ro(ds_id);
|
||||
|
||||
if ( ds == 0 )
|
||||
{
|
||||
@ -646,7 +646,7 @@ int ImageManager::can_clone_image(int cloning_id, ostringstream& oss_error)
|
||||
{
|
||||
Image * img;
|
||||
|
||||
img = ipool->get(cloning_id);
|
||||
img = ipool->get_ro(cloning_id);
|
||||
|
||||
if (img == 0)
|
||||
{
|
||||
@ -770,7 +770,7 @@ int ImageManager::clone_image(int new_id,
|
||||
return -1;
|
||||
}
|
||||
|
||||
img = ipool->get(new_id);
|
||||
img = ipool->get_ro(new_id);
|
||||
|
||||
if (img == 0)
|
||||
{
|
||||
@ -1105,7 +1105,7 @@ int ImageManager::delete_snapshot(int iid, int sid, string& error)
|
||||
return -1;
|
||||
}
|
||||
|
||||
Image * img = ipool->get(iid);
|
||||
Image * img = ipool->get_ro(iid);
|
||||
|
||||
if ( img == 0 )
|
||||
{
|
||||
@ -1122,7 +1122,7 @@ int ImageManager::delete_snapshot(int iid, int sid, string& error)
|
||||
|
||||
string ds_data;
|
||||
|
||||
Datastore * ds = dspool->get(ds_id);
|
||||
Datastore * ds = dspool->get_ro(ds_id);
|
||||
|
||||
if ( ds == 0 )
|
||||
{
|
||||
@ -1198,7 +1198,7 @@ int ImageManager::revert_snapshot(int iid, int sid, string& error)
|
||||
return -1;
|
||||
}
|
||||
|
||||
Image * img = ipool->get(iid);
|
||||
Image * img = ipool->get_ro(iid);
|
||||
|
||||
if ( img == 0 )
|
||||
{
|
||||
@ -1215,7 +1215,7 @@ int ImageManager::revert_snapshot(int iid, int sid, string& error)
|
||||
|
||||
string ds_data;
|
||||
|
||||
Datastore * ds = dspool->get(ds_id);
|
||||
Datastore * ds = dspool->get_ro(ds_id);
|
||||
|
||||
if ( ds == 0 )
|
||||
{
|
||||
@ -1302,7 +1302,7 @@ int ImageManager::flatten_snapshot(int iid, int sid, string& error)
|
||||
return -1;
|
||||
}
|
||||
|
||||
Image * img = ipool->get(iid);
|
||||
Image * img = ipool->get_ro(iid);
|
||||
|
||||
if ( img == 0 )
|
||||
{
|
||||
@ -1319,7 +1319,7 @@ int ImageManager::flatten_snapshot(int iid, int sid, string& error)
|
||||
|
||||
string ds_data;
|
||||
|
||||
Datastore * ds = dspool->get(ds_id);
|
||||
Datastore * ds = dspool->get_ro(ds_id);
|
||||
|
||||
if ( ds == 0 )
|
||||
{
|
||||
|
@ -442,7 +442,7 @@ void ImagePool::disk_attribute(
|
||||
|
||||
if ( disk->vector_value("IMAGE_ID", iid) == 0 )
|
||||
{
|
||||
img = get(iid);
|
||||
img = get_ro(iid);
|
||||
}
|
||||
else if ( disk->vector_value("IMAGE", source) == 0 )
|
||||
{
|
||||
@ -450,7 +450,7 @@ void ImagePool::disk_attribute(
|
||||
|
||||
if ( uiid != -1)
|
||||
{
|
||||
img = get(source, uiid);
|
||||
img = get_ro(source, uiid);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -968,7 +968,7 @@ void LifeCycleManager::cleanup_callback_action(int vid)
|
||||
|
||||
VirtualMachine::LcmState state;
|
||||
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
@ -1951,7 +1951,7 @@ void LifeCycleManager::disk_snapshot_success(int vid)
|
||||
{
|
||||
if ( img_owner )
|
||||
{
|
||||
Image* img = ipool->get(img_id);
|
||||
Image* img = ipool->get_ro(img_id);
|
||||
|
||||
if(img != 0)
|
||||
{
|
||||
@ -2095,7 +2095,7 @@ void LifeCycleManager::disk_snapshot_failure(int vid)
|
||||
{
|
||||
if ( img_owner )
|
||||
{
|
||||
Image* img = ipool->get(img_id);
|
||||
Image* img = ipool->get_ro(img_id);
|
||||
|
||||
if(img != 0)
|
||||
{
|
||||
@ -2154,7 +2154,7 @@ void LifeCycleManager::disk_snapshot_failure(int vid)
|
||||
|
||||
void LifeCycleManager::disk_lock_success(int vid)
|
||||
{
|
||||
VirtualMachine * vm = vmpool->get(vid);
|
||||
VirtualMachine * vm = vmpool->get_ro(vid);
|
||||
Image * image;
|
||||
|
||||
if ( vm == 0 )
|
||||
@ -2182,7 +2182,7 @@ void LifeCycleManager::disk_lock_success(int vid)
|
||||
|
||||
for (set<int>::iterator id = ids.begin(); id != ids.end(); id++)
|
||||
{
|
||||
image = ipool->get(*id);
|
||||
image = ipool->get_ro(*id);
|
||||
|
||||
if (image != 0)
|
||||
{
|
||||
@ -2402,7 +2402,7 @@ void LifeCycleManager::disk_resize_failure(int vid)
|
||||
// Restore quotas
|
||||
if ( img_quota && img_id != -1 )
|
||||
{
|
||||
Image* img = ipool->get(img_id);
|
||||
Image* img = ipool->get_ro(img_id);
|
||||
|
||||
if(img != 0)
|
||||
{
|
||||
|
@ -202,7 +202,6 @@ int MarketPlaceAppPool::import(const std::string& t64, int mp_id,
|
||||
|
||||
if ( app->from_template64(t64, error_str) != 0 )
|
||||
{
|
||||
app->lock();
|
||||
delete app;
|
||||
|
||||
return -1;
|
||||
@ -240,7 +239,6 @@ int MarketPlaceAppPool::import(const std::string& t64, int mp_id,
|
||||
|
||||
mp_aux->unlock();
|
||||
|
||||
app->lock();
|
||||
delete app;
|
||||
|
||||
return -2;
|
||||
@ -253,7 +251,6 @@ int MarketPlaceAppPool::import(const std::string& t64, int mp_id,
|
||||
{
|
||||
app_id = master_allocate(app, error_str);
|
||||
|
||||
app->lock();
|
||||
delete app;
|
||||
|
||||
return app_id;
|
||||
|
@ -45,7 +45,7 @@ int MarketPlaceManager::import_app(
|
||||
|
||||
const MarketPlaceManagerDriver* mpmd;
|
||||
|
||||
MarketPlaceApp * app = apppool->get(appid);
|
||||
MarketPlaceApp * app = apppool->get_ro(appid);
|
||||
|
||||
if ( app == 0 )
|
||||
{
|
||||
@ -65,7 +65,7 @@ int MarketPlaceManager::import_app(
|
||||
switch (type)
|
||||
{
|
||||
case MarketPlaceApp::IMAGE:
|
||||
image = ipool->get(origin_id);
|
||||
image = ipool->get_ro(origin_id);
|
||||
|
||||
if ( image == 0 )
|
||||
{
|
||||
@ -78,7 +78,7 @@ int MarketPlaceManager::import_app(
|
||||
|
||||
image->unlock();
|
||||
|
||||
ds = dspool->get(ds_id);
|
||||
ds = dspool->get_ro(ds_id);
|
||||
|
||||
if ( ds == 0 )
|
||||
{
|
||||
@ -158,7 +158,7 @@ error_common:
|
||||
|
||||
void MarketPlaceManager::release_app_resources(int appid)
|
||||
{
|
||||
MarketPlaceApp * app = apppool->get(appid);
|
||||
MarketPlaceApp * app = apppool->get_ro(appid);
|
||||
|
||||
if (app == 0)
|
||||
{
|
||||
@ -204,7 +204,7 @@ int MarketPlaceManager::delete_app(int appid, const std::string& market_data,
|
||||
return -1;
|
||||
}
|
||||
|
||||
app = apppool->get(appid);
|
||||
app = apppool->get_ro(appid);
|
||||
|
||||
if (app == 0)
|
||||
{
|
||||
|
@ -41,7 +41,7 @@ MarketPlacePool::MarketPlacePool(SqlDB * db, bool is_federation_slave)
|
||||
|
||||
Nebula& nd = Nebula::instance();
|
||||
UserPool * upool = nd.get_upool();
|
||||
User * oneadmin = upool->get(0);
|
||||
User * oneadmin = upool->get_ro(0);
|
||||
|
||||
string error;
|
||||
|
||||
|
@ -86,10 +86,16 @@ class OneDBBacKEnd
|
||||
"UNIQUE(name)"
|
||||
},
|
||||
"5.4.0" => {},
|
||||
"5.6.0" => {}
|
||||
"5.6.0" => {},
|
||||
"5.7.8" => {
|
||||
vm_pool: "oid INTEGER PRIMARY KEY, name VARCHAR(128), " <<
|
||||
"body MEDIUMTEXT, uid INTEGER, gid INTEGER, " <<
|
||||
"last_poll INTEGER, state INTEGER, lcm_state INTEGER, " <<
|
||||
"owner_u INTEGER, group_u INTEGER, other_u INTEGER, short_body MEDIUMTEXT",
|
||||
}
|
||||
}
|
||||
|
||||
LATEST_DB_VERSION = "5.6.0"
|
||||
LATEST_DB_VERSION = "5.7.8"
|
||||
|
||||
def get_schema(type, version = nil)
|
||||
if !version
|
||||
@ -118,7 +124,7 @@ class OneDBBacKEnd
|
||||
# Find latest type definition
|
||||
versions.each do |v|
|
||||
schema = VERSION_SCHEMA[v][type]
|
||||
next if schema
|
||||
break if schema
|
||||
end
|
||||
|
||||
schema = SCHEMA[type] if !schema
|
||||
|
@ -1,8 +1,8 @@
|
||||
/* A Bison parser, made by GNU Bison 3.0.4. */
|
||||
/* A Bison parser, made by GNU Bison 3.1. */
|
||||
|
||||
/* Bison implementation for Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
|
||||
Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -44,7 +44,7 @@
|
||||
#define YYBISON 1
|
||||
|
||||
/* Bison version. */
|
||||
#define YYBISON_VERSION "3.0.4"
|
||||
#define YYBISON_VERSION "3.1"
|
||||
|
||||
/* Skeleton name. */
|
||||
#define YYSKELETON_NAME "yacc.c"
|
||||
@ -224,13 +224,13 @@ typedef signed char yytype_int8;
|
||||
#ifdef YYTYPE_UINT16
|
||||
typedef YYTYPE_UINT16 yytype_uint16;
|
||||
#else
|
||||
typedef unsigned short int yytype_uint16;
|
||||
typedef unsigned short yytype_uint16;
|
||||
#endif
|
||||
|
||||
#ifdef YYTYPE_INT16
|
||||
typedef YYTYPE_INT16 yytype_int16;
|
||||
#else
|
||||
typedef short int yytype_int16;
|
||||
typedef short yytype_int16;
|
||||
#endif
|
||||
|
||||
#ifndef YYSIZE_T
|
||||
@ -242,7 +242,7 @@ typedef short int yytype_int16;
|
||||
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
|
||||
# define YYSIZE_T size_t
|
||||
# else
|
||||
# define YYSIZE_T unsigned int
|
||||
# define YYSIZE_T unsigned
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@ -294,7 +294,7 @@ typedef short int yytype_int16;
|
||||
# define YYUSE(E) /* empty */
|
||||
#endif
|
||||
|
||||
#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
|
||||
#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
|
||||
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
|
||||
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
|
||||
_Pragma ("GCC diagnostic push") \
|
||||
@ -464,7 +464,7 @@ union yyalloc
|
||||
#define YYMAXUTOK 260
|
||||
|
||||
#define YYTRANSLATE(YYX) \
|
||||
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
|
||||
((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
|
||||
|
||||
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
|
||||
as returned by yylex, without out-of-bounds checking. */
|
||||
@ -811,7 +811,7 @@ do { \
|
||||
static void
|
||||
yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, mem_collector * mc, ObjectXML * oxml, int& result, char ** error_msg, yyscan_t scanner)
|
||||
{
|
||||
unsigned long int yylno = yyrline[yyrule];
|
||||
unsigned long yylno = yyrline[yyrule];
|
||||
int yynrhs = yyr2[yyrule];
|
||||
int yyi;
|
||||
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
|
||||
@ -1037,6 +1037,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
|
||||
case N: \
|
||||
yyformat = S; \
|
||||
break
|
||||
default: /* Avoid compiler warnings. */
|
||||
YYCASE_(0, YY_("syntax error"));
|
||||
YYCASE_(1, YY_("syntax error, unexpected %s"));
|
||||
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
|
||||
@ -1277,7 +1278,7 @@ YYLTYPE yylloc = yyloc_default;
|
||||
yylsp = yyls + yysize - 1;
|
||||
|
||||
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
|
||||
(unsigned long int) yystacksize));
|
||||
(unsigned long) yystacksize));
|
||||
|
||||
if (yyss + yystacksize - 1 <= yyssp)
|
||||
YYABORT;
|
||||
@ -1383,79 +1384,80 @@ yyreduce:
|
||||
GCC warning that YYVAL may be used uninitialized. */
|
||||
yyval = yyvsp[1-yylen];
|
||||
|
||||
/* Default location. */
|
||||
/* Default location. */
|
||||
YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
|
||||
yyerror_range[1] = yyloc;
|
||||
YY_REDUCE_PRINT (yyn);
|
||||
switch (yyn)
|
||||
{
|
||||
case 2:
|
||||
#line 99 "expr_arith.y" /* yacc.c:1646 */
|
||||
#line 99 "expr_arith.y" /* yacc.c:1651 */
|
||||
{ result = static_cast<int>((yyvsp[0].val_float));}
|
||||
#line 1395 "expr_arith.cc" /* yacc.c:1646 */
|
||||
#line 1397 "expr_arith.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 3:
|
||||
#line 100 "expr_arith.y" /* yacc.c:1646 */
|
||||
#line 100 "expr_arith.y" /* yacc.c:1651 */
|
||||
{ result = 0; }
|
||||
#line 1401 "expr_arith.cc" /* yacc.c:1646 */
|
||||
#line 1403 "expr_arith.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 4:
|
||||
#line 103 "expr_arith.y" /* yacc.c:1646 */
|
||||
#line 103 "expr_arith.y" /* yacc.c:1651 */
|
||||
{ float val; oxml->search((yyvsp[0].val_str), val); (yyval.val_float) = val; }
|
||||
#line 1407 "expr_arith.cc" /* yacc.c:1646 */
|
||||
#line 1409 "expr_arith.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 5:
|
||||
#line 104 "expr_arith.y" /* yacc.c:1646 */
|
||||
#line 104 "expr_arith.y" /* yacc.c:1651 */
|
||||
{ (yyval.val_float) = (yyvsp[0].val_float); }
|
||||
#line 1413 "expr_arith.cc" /* yacc.c:1646 */
|
||||
#line 1415 "expr_arith.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 6:
|
||||
#line 105 "expr_arith.y" /* yacc.c:1646 */
|
||||
#line 105 "expr_arith.y" /* yacc.c:1651 */
|
||||
{ (yyval.val_float) = static_cast<float>((yyvsp[0].val_int)); }
|
||||
#line 1419 "expr_arith.cc" /* yacc.c:1646 */
|
||||
#line 1421 "expr_arith.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 7:
|
||||
#line 106 "expr_arith.y" /* yacc.c:1646 */
|
||||
#line 106 "expr_arith.y" /* yacc.c:1651 */
|
||||
{ (yyval.val_float) = (yyvsp[-2].val_float) + (yyvsp[0].val_float);}
|
||||
#line 1425 "expr_arith.cc" /* yacc.c:1646 */
|
||||
#line 1427 "expr_arith.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 8:
|
||||
#line 107 "expr_arith.y" /* yacc.c:1646 */
|
||||
#line 107 "expr_arith.y" /* yacc.c:1651 */
|
||||
{ (yyval.val_float) = (yyvsp[-2].val_float) - (yyvsp[0].val_float);}
|
||||
#line 1431 "expr_arith.cc" /* yacc.c:1646 */
|
||||
#line 1433 "expr_arith.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 9:
|
||||
#line 108 "expr_arith.y" /* yacc.c:1646 */
|
||||
#line 108 "expr_arith.y" /* yacc.c:1651 */
|
||||
{ (yyval.val_float) = (yyvsp[-2].val_float) * (yyvsp[0].val_float);}
|
||||
#line 1437 "expr_arith.cc" /* yacc.c:1646 */
|
||||
#line 1439 "expr_arith.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 10:
|
||||
#line 109 "expr_arith.y" /* yacc.c:1646 */
|
||||
#line 109 "expr_arith.y" /* yacc.c:1651 */
|
||||
{ (yyval.val_float) = (yyvsp[-2].val_float) / (yyvsp[0].val_float);}
|
||||
#line 1443 "expr_arith.cc" /* yacc.c:1646 */
|
||||
#line 1445 "expr_arith.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 11:
|
||||
#line 110 "expr_arith.y" /* yacc.c:1646 */
|
||||
#line 110 "expr_arith.y" /* yacc.c:1651 */
|
||||
{ (yyval.val_float) = - (yyvsp[0].val_float);}
|
||||
#line 1449 "expr_arith.cc" /* yacc.c:1646 */
|
||||
#line 1451 "expr_arith.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 12:
|
||||
#line 111 "expr_arith.y" /* yacc.c:1646 */
|
||||
#line 111 "expr_arith.y" /* yacc.c:1651 */
|
||||
{ (yyval.val_float) = (yyvsp[-1].val_float);}
|
||||
#line 1455 "expr_arith.cc" /* yacc.c:1646 */
|
||||
#line 1457 "expr_arith.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
|
||||
#line 1459 "expr_arith.cc" /* yacc.c:1646 */
|
||||
#line 1461 "expr_arith.cc" /* yacc.c:1651 */
|
||||
default: break;
|
||||
}
|
||||
/* User semantic actions sometimes alter yychar, and that requires
|
||||
@ -1578,7 +1580,6 @@ yyerrorlab:
|
||||
if (/*CONSTCOND*/ 0)
|
||||
goto yyerrorlab;
|
||||
|
||||
yyerror_range[1] = yylsp[1-yylen];
|
||||
/* Do not reclaim the symbols of the rule whose action triggered
|
||||
this YYERROR. */
|
||||
YYPOPSTACK (yylen);
|
||||
@ -1690,7 +1691,7 @@ yyreturn:
|
||||
#endif
|
||||
return yyresult;
|
||||
}
|
||||
#line 114 "expr_arith.y" /* yacc.c:1906 */
|
||||
#line 114 "expr_arith.y" /* yacc.c:1910 */
|
||||
|
||||
|
||||
void expr_arith_error(
|
||||
|
@ -1,8 +1,8 @@
|
||||
/* A Bison parser, made by GNU Bison 3.0.4. */
|
||||
/* A Bison parser, made by GNU Bison 3.1. */
|
||||
|
||||
/* Bison interface for Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
|
||||
Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -40,7 +40,7 @@
|
||||
extern int expr_arith_debug;
|
||||
#endif
|
||||
/* "%code requires" blocks. */
|
||||
#line 47 "expr_arith.y" /* yacc.c:1909 */
|
||||
#line 47 "expr_arith.y" /* yacc.c:1913 */
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
@ -61,7 +61,7 @@ typedef void * yyscan_t;
|
||||
int expr_arith_parse(ObjectXML *oxml, int& result, char ** errmsg,
|
||||
yyscan_t scanner);
|
||||
|
||||
#line 65 "expr_arith.hh" /* yacc.c:1909 */
|
||||
#line 65 "expr_arith.hh" /* yacc.c:1913 */
|
||||
|
||||
/* Token type. */
|
||||
#ifndef YYTOKENTYPE
|
||||
@ -79,13 +79,13 @@ int expr_arith_parse(ObjectXML *oxml, int& result, char ** errmsg,
|
||||
|
||||
union YYSTYPE
|
||||
{
|
||||
#line 77 "expr_arith.y" /* yacc.c:1909 */
|
||||
#line 77 "expr_arith.y" /* yacc.c:1913 */
|
||||
|
||||
char * val_str;
|
||||
int val_int;
|
||||
float val_float;
|
||||
|
||||
#line 89 "expr_arith.hh" /* yacc.c:1909 */
|
||||
#line 89 "expr_arith.hh" /* yacc.c:1913 */
|
||||
};
|
||||
|
||||
typedef union YYSTYPE YYSTYPE;
|
||||
|
@ -1,8 +1,8 @@
|
||||
/* A Bison parser, made by GNU Bison 3.0.4. */
|
||||
/* A Bison parser, made by GNU Bison 3.1. */
|
||||
|
||||
/* Bison implementation for Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
|
||||
Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -44,7 +44,7 @@
|
||||
#define YYBISON 1
|
||||
|
||||
/* Bison version. */
|
||||
#define YYBISON_VERSION "3.0.4"
|
||||
#define YYBISON_VERSION "3.1"
|
||||
|
||||
/* Skeleton name. */
|
||||
#define YYSKELETON_NAME "yacc.c"
|
||||
@ -225,13 +225,13 @@ typedef signed char yytype_int8;
|
||||
#ifdef YYTYPE_UINT16
|
||||
typedef YYTYPE_UINT16 yytype_uint16;
|
||||
#else
|
||||
typedef unsigned short int yytype_uint16;
|
||||
typedef unsigned short yytype_uint16;
|
||||
#endif
|
||||
|
||||
#ifdef YYTYPE_INT16
|
||||
typedef YYTYPE_INT16 yytype_int16;
|
||||
#else
|
||||
typedef short int yytype_int16;
|
||||
typedef short yytype_int16;
|
||||
#endif
|
||||
|
||||
#ifndef YYSIZE_T
|
||||
@ -243,7 +243,7 @@ typedef short int yytype_int16;
|
||||
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
|
||||
# define YYSIZE_T size_t
|
||||
# else
|
||||
# define YYSIZE_T unsigned int
|
||||
# define YYSIZE_T unsigned
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@ -295,7 +295,7 @@ typedef short int yytype_int16;
|
||||
# define YYUSE(E) /* empty */
|
||||
#endif
|
||||
|
||||
#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
|
||||
#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
|
||||
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
|
||||
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
|
||||
_Pragma ("GCC diagnostic push") \
|
||||
@ -465,7 +465,7 @@ union yyalloc
|
||||
#define YYMAXUTOK 260
|
||||
|
||||
#define YYTRANSLATE(YYX) \
|
||||
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
|
||||
((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
|
||||
|
||||
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
|
||||
as returned by yylex, without out-of-bounds checking. */
|
||||
@ -824,7 +824,7 @@ do { \
|
||||
static void
|
||||
yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, mem_collector * mc, ObjectXML * oxml, bool& result, char ** error_msg, yyscan_t scanner)
|
||||
{
|
||||
unsigned long int yylno = yyrline[yyrule];
|
||||
unsigned long yylno = yyrline[yyrule];
|
||||
int yynrhs = yyr2[yyrule];
|
||||
int yyi;
|
||||
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
|
||||
@ -1050,6 +1050,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
|
||||
case N: \
|
||||
yyformat = S; \
|
||||
break
|
||||
default: /* Avoid compiler warnings. */
|
||||
YYCASE_(0, YY_("syntax error"));
|
||||
YYCASE_(1, YY_("syntax error, unexpected %s"));
|
||||
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
|
||||
@ -1290,7 +1291,7 @@ YYLTYPE yylloc = yyloc_default;
|
||||
yylsp = yyls + yysize - 1;
|
||||
|
||||
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
|
||||
(unsigned long int) yystacksize));
|
||||
(unsigned long) yystacksize));
|
||||
|
||||
if (yyss + yystacksize - 1 <= yyssp)
|
||||
YYABORT;
|
||||
@ -1396,25 +1397,26 @@ yyreduce:
|
||||
GCC warning that YYVAL may be used uninitialized. */
|
||||
yyval = yyvsp[1-yylen];
|
||||
|
||||
/* Default location. */
|
||||
/* Default location. */
|
||||
YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
|
||||
yyerror_range[1] = yyloc;
|
||||
YY_REDUCE_PRINT (yyn);
|
||||
switch (yyn)
|
||||
{
|
||||
case 2:
|
||||
#line 99 "expr_bool.y" /* yacc.c:1646 */
|
||||
#line 99 "expr_bool.y" /* yacc.c:1651 */
|
||||
{ result=(yyvsp[0].val_int); }
|
||||
#line 1408 "expr_bool.cc" /* yacc.c:1646 */
|
||||
#line 1410 "expr_bool.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 3:
|
||||
#line 100 "expr_bool.y" /* yacc.c:1646 */
|
||||
#line 100 "expr_bool.y" /* yacc.c:1651 */
|
||||
{ result=true; }
|
||||
#line 1414 "expr_bool.cc" /* yacc.c:1646 */
|
||||
#line 1416 "expr_bool.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 4:
|
||||
#line 103 "expr_bool.y" /* yacc.c:1646 */
|
||||
#line 103 "expr_bool.y" /* yacc.c:1651 */
|
||||
{
|
||||
int val = (yyvsp[0].val_int);
|
||||
int rc;
|
||||
@ -1423,11 +1425,11 @@ yyreduce:
|
||||
|
||||
(yyval.val_int) = (rc == 0 && val == (yyvsp[0].val_int));
|
||||
}
|
||||
#line 1427 "expr_bool.cc" /* yacc.c:1646 */
|
||||
#line 1429 "expr_bool.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 5:
|
||||
#line 112 "expr_bool.y" /* yacc.c:1646 */
|
||||
#line 112 "expr_bool.y" /* yacc.c:1651 */
|
||||
{
|
||||
int val = (yyvsp[0].val_int);
|
||||
int rc;
|
||||
@ -1436,33 +1438,33 @@ yyreduce:
|
||||
|
||||
(yyval.val_int) = (rc == 0 && val != (yyvsp[0].val_int));
|
||||
}
|
||||
#line 1440 "expr_bool.cc" /* yacc.c:1646 */
|
||||
#line 1442 "expr_bool.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 6:
|
||||
#line 121 "expr_bool.y" /* yacc.c:1646 */
|
||||
#line 121 "expr_bool.y" /* yacc.c:1651 */
|
||||
{
|
||||
int val, rc;
|
||||
|
||||
rc = oxml->search((yyvsp[-2].val_str),val);
|
||||
(yyval.val_int) = (rc == 0 && val > (yyvsp[0].val_int));
|
||||
}
|
||||
#line 1451 "expr_bool.cc" /* yacc.c:1646 */
|
||||
#line 1453 "expr_bool.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 7:
|
||||
#line 128 "expr_bool.y" /* yacc.c:1646 */
|
||||
#line 128 "expr_bool.y" /* yacc.c:1651 */
|
||||
{
|
||||
int val, rc;
|
||||
|
||||
rc = oxml->search((yyvsp[-2].val_str),val);
|
||||
(yyval.val_int) = (rc == 0 && val < (yyvsp[0].val_int));
|
||||
}
|
||||
#line 1462 "expr_bool.cc" /* yacc.c:1646 */
|
||||
#line 1464 "expr_bool.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 8:
|
||||
#line 135 "expr_bool.y" /* yacc.c:1646 */
|
||||
#line 135 "expr_bool.y" /* yacc.c:1651 */
|
||||
{
|
||||
std::vector<int> val;
|
||||
std::vector<int>::iterator it;
|
||||
@ -1480,55 +1482,55 @@ yyreduce:
|
||||
}
|
||||
}
|
||||
}
|
||||
#line 1484 "expr_bool.cc" /* yacc.c:1646 */
|
||||
#line 1486 "expr_bool.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 9:
|
||||
#line 153 "expr_bool.y" /* yacc.c:1646 */
|
||||
#line 153 "expr_bool.y" /* yacc.c:1651 */
|
||||
{
|
||||
float val, rc;
|
||||
|
||||
rc = oxml->search((yyvsp[-2].val_str),val);
|
||||
(yyval.val_int) = (rc == 0 && val == (yyvsp[0].val_float));
|
||||
}
|
||||
#line 1495 "expr_bool.cc" /* yacc.c:1646 */
|
||||
#line 1497 "expr_bool.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 10:
|
||||
#line 160 "expr_bool.y" /* yacc.c:1646 */
|
||||
#line 160 "expr_bool.y" /* yacc.c:1651 */
|
||||
{
|
||||
float val, rc;
|
||||
|
||||
rc = oxml->search((yyvsp[-3].val_str),val);
|
||||
(yyval.val_int) = (rc == 0 && val != (yyvsp[0].val_float));
|
||||
}
|
||||
#line 1506 "expr_bool.cc" /* yacc.c:1646 */
|
||||
#line 1508 "expr_bool.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 11:
|
||||
#line 167 "expr_bool.y" /* yacc.c:1646 */
|
||||
#line 167 "expr_bool.y" /* yacc.c:1651 */
|
||||
{
|
||||
float val, rc;
|
||||
|
||||
rc = oxml->search((yyvsp[-2].val_str),val);
|
||||
(yyval.val_int) = (rc == 0 && val > (yyvsp[0].val_float));
|
||||
}
|
||||
#line 1517 "expr_bool.cc" /* yacc.c:1646 */
|
||||
#line 1519 "expr_bool.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 12:
|
||||
#line 174 "expr_bool.y" /* yacc.c:1646 */
|
||||
#line 174 "expr_bool.y" /* yacc.c:1651 */
|
||||
{
|
||||
float val, rc;
|
||||
|
||||
rc = oxml->search((yyvsp[-2].val_str),val);
|
||||
(yyval.val_int) = (rc == 0 && val < (yyvsp[0].val_float));
|
||||
}
|
||||
#line 1528 "expr_bool.cc" /* yacc.c:1646 */
|
||||
#line 1530 "expr_bool.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 13:
|
||||
#line 181 "expr_bool.y" /* yacc.c:1646 */
|
||||
#line 181 "expr_bool.y" /* yacc.c:1651 */
|
||||
{
|
||||
std::vector<float> val;
|
||||
std::vector<float>::iterator it;
|
||||
@ -1546,11 +1548,11 @@ yyreduce:
|
||||
}
|
||||
}
|
||||
}
|
||||
#line 1550 "expr_bool.cc" /* yacc.c:1646 */
|
||||
#line 1552 "expr_bool.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 14:
|
||||
#line 199 "expr_bool.y" /* yacc.c:1646 */
|
||||
#line 199 "expr_bool.y" /* yacc.c:1651 */
|
||||
{
|
||||
std::string val;
|
||||
int rc;
|
||||
@ -1558,11 +1560,11 @@ yyreduce:
|
||||
rc = oxml->search((yyvsp[-2].val_str),val);
|
||||
(yyval.val_int) = (rc != 0 || (yyvsp[0].val_str)==0) ? false : fnmatch((yyvsp[0].val_str),val.c_str(),0)==0;
|
||||
}
|
||||
#line 1562 "expr_bool.cc" /* yacc.c:1646 */
|
||||
#line 1564 "expr_bool.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 15:
|
||||
#line 207 "expr_bool.y" /* yacc.c:1646 */
|
||||
#line 207 "expr_bool.y" /* yacc.c:1651 */
|
||||
{
|
||||
std::string val;
|
||||
int rc;
|
||||
@ -1570,11 +1572,11 @@ yyreduce:
|
||||
rc = oxml->search((yyvsp[-3].val_str),val);
|
||||
(yyval.val_int) = (rc != 0 || (yyvsp[0].val_str)==0) ? false : fnmatch((yyvsp[0].val_str),val.c_str(),0)!=0;
|
||||
}
|
||||
#line 1574 "expr_bool.cc" /* yacc.c:1646 */
|
||||
#line 1576 "expr_bool.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 16:
|
||||
#line 215 "expr_bool.y" /* yacc.c:1646 */
|
||||
#line 215 "expr_bool.y" /* yacc.c:1651 */
|
||||
{
|
||||
std::vector<std::string> val;
|
||||
std::vector<std::string>::iterator it;
|
||||
@ -1595,35 +1597,35 @@ yyreduce:
|
||||
}
|
||||
}
|
||||
}
|
||||
#line 1599 "expr_bool.cc" /* yacc.c:1646 */
|
||||
#line 1601 "expr_bool.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 17:
|
||||
#line 236 "expr_bool.y" /* yacc.c:1646 */
|
||||
#line 236 "expr_bool.y" /* yacc.c:1651 */
|
||||
{ (yyval.val_int) = (yyvsp[-2].val_int) && (yyvsp[0].val_int); }
|
||||
#line 1605 "expr_bool.cc" /* yacc.c:1646 */
|
||||
#line 1607 "expr_bool.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 18:
|
||||
#line 237 "expr_bool.y" /* yacc.c:1646 */
|
||||
#line 237 "expr_bool.y" /* yacc.c:1651 */
|
||||
{ (yyval.val_int) = (yyvsp[-2].val_int) || (yyvsp[0].val_int); }
|
||||
#line 1611 "expr_bool.cc" /* yacc.c:1646 */
|
||||
#line 1613 "expr_bool.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 19:
|
||||
#line 238 "expr_bool.y" /* yacc.c:1646 */
|
||||
#line 238 "expr_bool.y" /* yacc.c:1651 */
|
||||
{ (yyval.val_int) = ! (yyvsp[0].val_int); }
|
||||
#line 1617 "expr_bool.cc" /* yacc.c:1646 */
|
||||
#line 1619 "expr_bool.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 20:
|
||||
#line 239 "expr_bool.y" /* yacc.c:1646 */
|
||||
#line 239 "expr_bool.y" /* yacc.c:1651 */
|
||||
{ (yyval.val_int) = (yyvsp[-1].val_int); }
|
||||
#line 1623 "expr_bool.cc" /* yacc.c:1646 */
|
||||
#line 1625 "expr_bool.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
|
||||
#line 1627 "expr_bool.cc" /* yacc.c:1646 */
|
||||
#line 1629 "expr_bool.cc" /* yacc.c:1651 */
|
||||
default: break;
|
||||
}
|
||||
/* User semantic actions sometimes alter yychar, and that requires
|
||||
@ -1746,7 +1748,6 @@ yyerrorlab:
|
||||
if (/*CONSTCOND*/ 0)
|
||||
goto yyerrorlab;
|
||||
|
||||
yyerror_range[1] = yylsp[1-yylen];
|
||||
/* Do not reclaim the symbols of the rule whose action triggered
|
||||
this YYERROR. */
|
||||
YYPOPSTACK (yylen);
|
||||
@ -1858,7 +1859,7 @@ yyreturn:
|
||||
#endif
|
||||
return yyresult;
|
||||
}
|
||||
#line 242 "expr_bool.y" /* yacc.c:1906 */
|
||||
#line 242 "expr_bool.y" /* yacc.c:1910 */
|
||||
|
||||
|
||||
void expr_bool_error(
|
||||
|
@ -1,8 +1,8 @@
|
||||
/* A Bison parser, made by GNU Bison 3.0.4. */
|
||||
/* A Bison parser, made by GNU Bison 3.1. */
|
||||
|
||||
/* Bison interface for Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
|
||||
Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -40,7 +40,7 @@
|
||||
extern int expr_bool_debug;
|
||||
#endif
|
||||
/* "%code requires" blocks. */
|
||||
#line 48 "expr_bool.y" /* yacc.c:1909 */
|
||||
#line 48 "expr_bool.y" /* yacc.c:1913 */
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
@ -62,7 +62,7 @@ typedef void * yyscan_t;
|
||||
int expr_bool_parse(ObjectXML *oxml, bool& result, char ** errmsg,
|
||||
yyscan_t scanner);
|
||||
|
||||
#line 66 "expr_bool.hh" /* yacc.c:1909 */
|
||||
#line 66 "expr_bool.hh" /* yacc.c:1913 */
|
||||
|
||||
/* Token type. */
|
||||
#ifndef YYTOKENTYPE
|
||||
@ -80,13 +80,13 @@ int expr_bool_parse(ObjectXML *oxml, bool& result, char ** errmsg,
|
||||
|
||||
union YYSTYPE
|
||||
{
|
||||
#line 79 "expr_bool.y" /* yacc.c:1909 */
|
||||
#line 79 "expr_bool.y" /* yacc.c:1913 */
|
||||
|
||||
char * val_str;
|
||||
int val_int;
|
||||
float val_float;
|
||||
|
||||
#line 90 "expr_bool.hh" /* yacc.c:1909 */
|
||||
#line 90 "expr_bool.hh" /* yacc.c:1913 */
|
||||
};
|
||||
|
||||
typedef union YYSTYPE YYSTYPE;
|
||||
|
@ -1,8 +1,8 @@
|
||||
/* A Bison parser, made by GNU Bison 3.0.4. */
|
||||
/* A Bison parser, made by GNU Bison 3.1. */
|
||||
|
||||
/* Bison implementation for Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
|
||||
Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -44,7 +44,7 @@
|
||||
#define YYBISON 1
|
||||
|
||||
/* Bison version. */
|
||||
#define YYBISON_VERSION "3.0.4"
|
||||
#define YYBISON_VERSION "3.1"
|
||||
|
||||
/* Skeleton name. */
|
||||
#define YYSKELETON_NAME "yacc.c"
|
||||
@ -226,13 +226,13 @@ typedef signed char yytype_int8;
|
||||
#ifdef YYTYPE_UINT16
|
||||
typedef YYTYPE_UINT16 yytype_uint16;
|
||||
#else
|
||||
typedef unsigned short int yytype_uint16;
|
||||
typedef unsigned short yytype_uint16;
|
||||
#endif
|
||||
|
||||
#ifdef YYTYPE_INT16
|
||||
typedef YYTYPE_INT16 yytype_int16;
|
||||
#else
|
||||
typedef short int yytype_int16;
|
||||
typedef short yytype_int16;
|
||||
#endif
|
||||
|
||||
#ifndef YYSIZE_T
|
||||
@ -244,7 +244,7 @@ typedef short int yytype_int16;
|
||||
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
|
||||
# define YYSIZE_T size_t
|
||||
# else
|
||||
# define YYSIZE_T unsigned int
|
||||
# define YYSIZE_T unsigned
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@ -296,7 +296,7 @@ typedef short int yytype_int16;
|
||||
# define YYUSE(E) /* empty */
|
||||
#endif
|
||||
|
||||
#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
|
||||
#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
|
||||
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
|
||||
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
|
||||
_Pragma ("GCC diagnostic push") \
|
||||
@ -466,7 +466,7 @@ union yyalloc
|
||||
#define YYMAXUTOK 265
|
||||
|
||||
#define YYTRANSLATE(YYX) \
|
||||
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
|
||||
((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
|
||||
|
||||
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
|
||||
as returned by yylex, without out-of-bounds checking. */
|
||||
@ -814,7 +814,7 @@ do { \
|
||||
static void
|
||||
yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, mem_collector * mc, Template * tmpl, char ** error_msg, yyscan_t scanner)
|
||||
{
|
||||
unsigned long int yylno = yyrline[yyrule];
|
||||
unsigned long yylno = yyrline[yyrule];
|
||||
int yynrhs = yyr2[yyrule];
|
||||
int yyi;
|
||||
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
|
||||
@ -1040,6 +1040,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
|
||||
case N: \
|
||||
yyformat = S; \
|
||||
break
|
||||
default: /* Avoid compiler warnings. */
|
||||
YYCASE_(0, YY_("syntax error"));
|
||||
YYCASE_(1, YY_("syntax error, unexpected %s"));
|
||||
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
|
||||
@ -1279,7 +1280,7 @@ YYLTYPE yylloc = yyloc_default;
|
||||
yylsp = yyls + yysize - 1;
|
||||
|
||||
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
|
||||
(unsigned long int) yystacksize));
|
||||
(unsigned long) yystacksize));
|
||||
|
||||
if (yyss + yystacksize - 1 <= yyssp)
|
||||
YYABORT;
|
||||
@ -1385,13 +1386,14 @@ yyreduce:
|
||||
GCC warning that YYVAL may be used uninitialized. */
|
||||
yyval = yyvsp[1-yylen];
|
||||
|
||||
/* Default location. */
|
||||
/* Default location. */
|
||||
YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
|
||||
yyerror_range[1] = yyloc;
|
||||
YY_REDUCE_PRINT (yyn);
|
||||
switch (yyn)
|
||||
{
|
||||
case 6:
|
||||
#line 103 "template_syntax.y" /* yacc.c:1646 */
|
||||
#line 103 "template_syntax.y" /* yacc.c:1651 */
|
||||
{
|
||||
Attribute * pattr;
|
||||
string name((yyvsp[-2].val_str));
|
||||
@ -1401,11 +1403,11 @@ yyreduce:
|
||||
|
||||
tmpl->set(pattr);
|
||||
}
|
||||
#line 1405 "template_syntax.cc" /* yacc.c:1646 */
|
||||
#line 1407 "template_syntax.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 7:
|
||||
#line 113 "template_syntax.y" /* yacc.c:1646 */
|
||||
#line 113 "template_syntax.y" /* yacc.c:1651 */
|
||||
{
|
||||
Attribute * pattr;
|
||||
string name((yyvsp[-4].val_str));
|
||||
@ -1418,11 +1420,11 @@ yyreduce:
|
||||
|
||||
delete amap;
|
||||
}
|
||||
#line 1422 "template_syntax.cc" /* yacc.c:1646 */
|
||||
#line 1424 "template_syntax.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 8:
|
||||
#line 126 "template_syntax.y" /* yacc.c:1646 */
|
||||
#line 126 "template_syntax.y" /* yacc.c:1651 */
|
||||
{
|
||||
Attribute * pattr;
|
||||
string name((yyvsp[-3].val_str));
|
||||
@ -1431,11 +1433,11 @@ yyreduce:
|
||||
|
||||
tmpl->set(pattr);
|
||||
}
|
||||
#line 1435 "template_syntax.cc" /* yacc.c:1646 */
|
||||
#line 1437 "template_syntax.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 9:
|
||||
#line 135 "template_syntax.y" /* yacc.c:1646 */
|
||||
#line 135 "template_syntax.y" /* yacc.c:1651 */
|
||||
{
|
||||
Attribute * pattr;
|
||||
string name((yyvsp[-1].val_str));
|
||||
@ -1445,19 +1447,19 @@ yyreduce:
|
||||
|
||||
tmpl->set(pattr);
|
||||
}
|
||||
#line 1449 "template_syntax.cc" /* yacc.c:1646 */
|
||||
#line 1451 "template_syntax.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 10:
|
||||
#line 145 "template_syntax.y" /* yacc.c:1646 */
|
||||
#line 145 "template_syntax.y" /* yacc.c:1651 */
|
||||
{
|
||||
YYABORT;
|
||||
}
|
||||
#line 1457 "template_syntax.cc" /* yacc.c:1646 */
|
||||
#line 1459 "template_syntax.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 11:
|
||||
#line 151 "template_syntax.y" /* yacc.c:1646 */
|
||||
#line 151 "template_syntax.y" /* yacc.c:1651 */
|
||||
{
|
||||
map<string,string>* vattr;
|
||||
string name((yyvsp[-2].val_str));
|
||||
@ -1470,11 +1472,11 @@ yyreduce:
|
||||
|
||||
(yyval.val_attr) = static_cast<void *>(vattr);
|
||||
}
|
||||
#line 1474 "template_syntax.cc" /* yacc.c:1646 */
|
||||
#line 1476 "template_syntax.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 12:
|
||||
#line 164 "template_syntax.y" /* yacc.c:1646 */
|
||||
#line 164 "template_syntax.y" /* yacc.c:1651 */
|
||||
{
|
||||
string name((yyvsp[-2].val_str));
|
||||
string value((yyvsp[0].val_str));
|
||||
@ -1487,11 +1489,11 @@ yyreduce:
|
||||
attrmap->insert(make_pair(name,unescape(value)));
|
||||
(yyval.val_attr) = (yyvsp[-4].val_attr);
|
||||
}
|
||||
#line 1491 "template_syntax.cc" /* yacc.c:1646 */
|
||||
#line 1493 "template_syntax.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
|
||||
#line 1495 "template_syntax.cc" /* yacc.c:1646 */
|
||||
#line 1497 "template_syntax.cc" /* yacc.c:1651 */
|
||||
default: break;
|
||||
}
|
||||
/* User semantic actions sometimes alter yychar, and that requires
|
||||
@ -1614,7 +1616,6 @@ yyerrorlab:
|
||||
if (/*CONSTCOND*/ 0)
|
||||
goto yyerrorlab;
|
||||
|
||||
yyerror_range[1] = yylsp[1-yylen];
|
||||
/* Do not reclaim the symbols of the rule whose action triggered
|
||||
this YYERROR. */
|
||||
YYPOPSTACK (yylen);
|
||||
@ -1726,7 +1727,7 @@ yyreturn:
|
||||
#endif
|
||||
return yyresult;
|
||||
}
|
||||
#line 177 "template_syntax.y" /* yacc.c:1906 */
|
||||
#line 177 "template_syntax.y" /* yacc.c:1910 */
|
||||
|
||||
|
||||
string& unescape (string &str)
|
||||
|
@ -1,8 +1,8 @@
|
||||
/* A Bison parser, made by GNU Bison 3.0.4. */
|
||||
/* A Bison parser, made by GNU Bison 3.1. */
|
||||
|
||||
/* Bison interface for Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
|
||||
Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -40,7 +40,7 @@
|
||||
extern int template_debug;
|
||||
#endif
|
||||
/* "%code requires" blocks. */
|
||||
#line 47 "template_syntax.y" /* yacc.c:1909 */
|
||||
#line 47 "template_syntax.y" /* yacc.c:1913 */
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@ -59,7 +59,7 @@ typedef void * yyscan_t;
|
||||
|
||||
int template_parse(Template * tmpl, char ** errmsg, yyscan_t scanner);
|
||||
|
||||
#line 63 "template_syntax.hh" /* yacc.c:1909 */
|
||||
#line 63 "template_syntax.hh" /* yacc.c:1913 */
|
||||
|
||||
/* Token type. */
|
||||
#ifndef YYTOKENTYPE
|
||||
@ -82,12 +82,12 @@ int template_parse(Template * tmpl, char ** errmsg, yyscan_t scanner);
|
||||
|
||||
union YYSTYPE
|
||||
{
|
||||
#line 74 "template_syntax.y" /* yacc.c:1909 */
|
||||
#line 74 "template_syntax.y" /* yacc.c:1913 */
|
||||
|
||||
char * val_str;
|
||||
void * val_attr;
|
||||
|
||||
#line 91 "template_syntax.hh" /* yacc.c:1909 */
|
||||
#line 91 "template_syntax.hh" /* yacc.c:1913 */
|
||||
};
|
||||
|
||||
typedef union YYSTYPE YYSTYPE;
|
||||
|
@ -1,8 +1,8 @@
|
||||
/* A Bison parser, made by GNU Bison 3.0.4. */
|
||||
/* A Bison parser, made by GNU Bison 3.1. */
|
||||
|
||||
/* Bison implementation for Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
|
||||
Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -44,7 +44,7 @@
|
||||
#define YYBISON 1
|
||||
|
||||
/* Bison version. */
|
||||
#define YYBISON_VERSION "3.0.4"
|
||||
#define YYBISON_VERSION "3.1"
|
||||
|
||||
/* Skeleton name. */
|
||||
#define YYSKELETON_NAME "yacc.c"
|
||||
@ -145,7 +145,7 @@ int get_image_path(VirtualMachine * vm,
|
||||
delete vfile;
|
||||
}
|
||||
|
||||
img = ipool->get(val1, uid);
|
||||
img = ipool->get_ro(val1, uid);
|
||||
|
||||
if ( img == 0 )
|
||||
{
|
||||
@ -166,7 +166,7 @@ int get_image_path(VirtualMachine * vm,
|
||||
|
||||
if ( !is.fail() )
|
||||
{
|
||||
img = ipool->get(iid);
|
||||
img = ipool->get_ro(iid);
|
||||
}
|
||||
|
||||
if ( img == 0 )
|
||||
@ -189,11 +189,11 @@ int get_image_path(VirtualMachine * vm,
|
||||
|
||||
img->get_permissions(perm);
|
||||
|
||||
img->unlock();
|
||||
img->unlock();;
|
||||
|
||||
set<int> gids;
|
||||
|
||||
user = upool->get(vm->get_uid());
|
||||
user = upool->get_ro(vm->get_uid());
|
||||
|
||||
if (user != 0)
|
||||
{
|
||||
@ -358,13 +358,13 @@ typedef signed char yytype_int8;
|
||||
#ifdef YYTYPE_UINT16
|
||||
typedef YYTYPE_UINT16 yytype_uint16;
|
||||
#else
|
||||
typedef unsigned short int yytype_uint16;
|
||||
typedef unsigned short yytype_uint16;
|
||||
#endif
|
||||
|
||||
#ifdef YYTYPE_INT16
|
||||
typedef YYTYPE_INT16 yytype_int16;
|
||||
#else
|
||||
typedef short int yytype_int16;
|
||||
typedef short yytype_int16;
|
||||
#endif
|
||||
|
||||
#ifndef YYSIZE_T
|
||||
@ -376,7 +376,7 @@ typedef short int yytype_int16;
|
||||
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
|
||||
# define YYSIZE_T size_t
|
||||
# else
|
||||
# define YYSIZE_T unsigned int
|
||||
# define YYSIZE_T unsigned
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@ -428,7 +428,7 @@ typedef short int yytype_int16;
|
||||
# define YYUSE(E) /* empty */
|
||||
#endif
|
||||
|
||||
#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
|
||||
#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
|
||||
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
|
||||
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
|
||||
_Pragma ("GCC diagnostic push") \
|
||||
@ -598,7 +598,7 @@ union yyalloc
|
||||
#define YYMAXUTOK 266
|
||||
|
||||
#define YYTRANSLATE(YYX) \
|
||||
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
|
||||
((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
|
||||
|
||||
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
|
||||
as returned by yylex, without out-of-bounds checking. */
|
||||
@ -941,7 +941,7 @@ do { \
|
||||
static void
|
||||
yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, mem_collector * mc, VirtualMachine * vm, vector<int> * img_ids, char ** errmsg, yyscan_t scanner)
|
||||
{
|
||||
unsigned long int yylno = yyrline[yyrule];
|
||||
unsigned long yylno = yyrline[yyrule];
|
||||
int yynrhs = yyr2[yyrule];
|
||||
int yyi;
|
||||
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
|
||||
@ -1167,6 +1167,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
|
||||
case N: \
|
||||
yyformat = S; \
|
||||
break
|
||||
default: /* Avoid compiler warnings. */
|
||||
YYCASE_(0, YY_("syntax error"));
|
||||
YYCASE_(1, YY_("syntax error, unexpected %s"));
|
||||
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
|
||||
@ -1407,7 +1408,7 @@ YYLTYPE yylloc = yyloc_default;
|
||||
yylsp = yyls + yysize - 1;
|
||||
|
||||
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
|
||||
(unsigned long int) yystacksize));
|
||||
(unsigned long) yystacksize));
|
||||
|
||||
if (yyss + yystacksize - 1 <= yyssp)
|
||||
YYABORT;
|
||||
@ -1513,13 +1514,14 @@ yyreduce:
|
||||
GCC warning that YYVAL may be used uninitialized. */
|
||||
yyval = yyvsp[1-yylen];
|
||||
|
||||
/* Default location. */
|
||||
/* Default location. */
|
||||
YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
|
||||
yyerror_range[1] = yyloc;
|
||||
YY_REDUCE_PRINT (yyn);
|
||||
switch (yyn)
|
||||
{
|
||||
case 4:
|
||||
#line 235 "vm_file_var_syntax.y" /* yacc.c:1646 */
|
||||
#line 235 "vm_file_var_syntax.y" /* yacc.c:1651 */
|
||||
{
|
||||
string file((yyvsp[-6].val_str));
|
||||
string var1((yyvsp[-4].val_str));
|
||||
@ -1537,11 +1539,11 @@ yyreduce:
|
||||
YYABORT;
|
||||
}
|
||||
}
|
||||
#line 1541 "vm_file_var_syntax.cc" /* yacc.c:1646 */
|
||||
#line 1543 "vm_file_var_syntax.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 5:
|
||||
#line 253 "vm_file_var_syntax.y" /* yacc.c:1646 */
|
||||
#line 253 "vm_file_var_syntax.y" /* yacc.c:1651 */
|
||||
{
|
||||
string file((yyvsp[-10].val_str));
|
||||
string var1((yyvsp[-8].val_str));
|
||||
@ -1562,11 +1564,11 @@ yyreduce:
|
||||
YYABORT;
|
||||
}
|
||||
}
|
||||
#line 1566 "vm_file_var_syntax.cc" /* yacc.c:1646 */
|
||||
#line 1568 "vm_file_var_syntax.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
|
||||
#line 1570 "vm_file_var_syntax.cc" /* yacc.c:1646 */
|
||||
#line 1572 "vm_file_var_syntax.cc" /* yacc.c:1651 */
|
||||
default: break;
|
||||
}
|
||||
/* User semantic actions sometimes alter yychar, and that requires
|
||||
@ -1689,7 +1691,6 @@ yyerrorlab:
|
||||
if (/*CONSTCOND*/ 0)
|
||||
goto yyerrorlab;
|
||||
|
||||
yyerror_range[1] = yylsp[1-yylen];
|
||||
/* Do not reclaim the symbols of the rule whose action triggered
|
||||
this YYERROR. */
|
||||
YYPOPSTACK (yylen);
|
||||
@ -1801,7 +1802,7 @@ yyreturn:
|
||||
#endif
|
||||
return yyresult;
|
||||
}
|
||||
#line 274 "vm_file_var_syntax.y" /* yacc.c:1906 */
|
||||
#line 274 "vm_file_var_syntax.y" /* yacc.c:1910 */
|
||||
|
||||
|
||||
void vm_file_var_error(
|
||||
|
@ -1,8 +1,8 @@
|
||||
/* A Bison parser, made by GNU Bison 3.0.4. */
|
||||
/* A Bison parser, made by GNU Bison 3.1. */
|
||||
|
||||
/* Bison interface for Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
|
||||
Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -40,7 +40,7 @@
|
||||
extern int vm_file_var_debug;
|
||||
#endif
|
||||
/* "%code requires" blocks. */
|
||||
#line 17 "vm_file_var_syntax.y" /* yacc.c:1909 */
|
||||
#line 17 "vm_file_var_syntax.y" /* yacc.c:1913 */
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
@ -63,7 +63,7 @@ typedef void * yyscan_t;
|
||||
int vm_file_var_parse (VirtualMachine * vm, vector<int> * img_ids,
|
||||
char ** errmsg, yyscan_t scanner);
|
||||
|
||||
#line 67 "vm_file_var_syntax.hh" /* yacc.c:1909 */
|
||||
#line 67 "vm_file_var_syntax.hh" /* yacc.c:1913 */
|
||||
|
||||
/* Token type. */
|
||||
#ifndef YYTOKENTYPE
|
||||
@ -87,13 +87,13 @@ int vm_file_var_parse (VirtualMachine * vm, vector<int> * img_ids,
|
||||
|
||||
union YYSTYPE
|
||||
{
|
||||
#line 205 "vm_file_var_syntax.y" /* yacc.c:1909 */
|
||||
#line 205 "vm_file_var_syntax.y" /* yacc.c:1913 */
|
||||
|
||||
char * val_str;
|
||||
int val_int;
|
||||
char val_char;
|
||||
|
||||
#line 97 "vm_file_var_syntax.hh" /* yacc.c:1909 */
|
||||
#line 97 "vm_file_var_syntax.hh" /* yacc.c:1913 */
|
||||
};
|
||||
|
||||
typedef union YYSTYPE YYSTYPE;
|
||||
|
@ -113,7 +113,7 @@ int get_image_path(VirtualMachine * vm,
|
||||
delete vfile;
|
||||
}
|
||||
|
||||
img = ipool->get(val1, uid);
|
||||
img = ipool->get_ro(val1, uid);
|
||||
|
||||
if ( img == 0 )
|
||||
{
|
||||
@ -134,7 +134,7 @@ int get_image_path(VirtualMachine * vm,
|
||||
|
||||
if ( !is.fail() )
|
||||
{
|
||||
img = ipool->get(iid);
|
||||
img = ipool->get_ro(iid);
|
||||
}
|
||||
|
||||
if ( img == 0 )
|
||||
@ -157,11 +157,11 @@ int get_image_path(VirtualMachine * vm,
|
||||
|
||||
img->get_permissions(perm);
|
||||
|
||||
img->unlock();
|
||||
img->unlock();;
|
||||
|
||||
set<int> gids;
|
||||
|
||||
user = upool->get(vm->get_uid());
|
||||
user = upool->get_ro(vm->get_uid());
|
||||
|
||||
if (user != 0)
|
||||
{
|
||||
|
@ -1,8 +1,8 @@
|
||||
/* A Bison parser, made by GNU Bison 3.0.4. */
|
||||
/* A Bison parser, made by GNU Bison 3.1. */
|
||||
|
||||
/* Bison implementation for Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
|
||||
Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -44,7 +44,7 @@
|
||||
#define YYBISON 1
|
||||
|
||||
/* Bison version. */
|
||||
#define YYBISON_VERSION "3.0.4"
|
||||
#define YYBISON_VERSION "3.1"
|
||||
|
||||
/* Skeleton name. */
|
||||
#define YYSKELETON_NAME "yacc.c"
|
||||
@ -155,7 +155,7 @@ void get_image_attribute(VirtualMachine * vm,
|
||||
// ----------------------------------------------
|
||||
// Get the attribute template from the image
|
||||
// ----------------------------------------------
|
||||
img = ipool->get(iid);
|
||||
img = ipool->get_ro(iid);
|
||||
|
||||
if ( img == 0 )
|
||||
{
|
||||
@ -232,7 +232,7 @@ void get_network_attribute(VirtualMachine * vm,
|
||||
// ----------------------------------------------
|
||||
// Get the attribute template from the image
|
||||
// ----------------------------------------------
|
||||
vn = vnpool->get(vnet_id);
|
||||
vn = vnpool->get_ro(vnet_id);
|
||||
|
||||
if ( vn == 0 )
|
||||
{
|
||||
@ -265,7 +265,7 @@ void get_user_attribute(VirtualMachine * vm,
|
||||
|
||||
attr_value.clear();
|
||||
|
||||
user = upool->get(vm->get_uid());
|
||||
user = upool->get_ro(vm->get_uid());
|
||||
|
||||
if ( user == 0 )
|
||||
{
|
||||
@ -557,13 +557,13 @@ typedef signed char yytype_int8;
|
||||
#ifdef YYTYPE_UINT16
|
||||
typedef YYTYPE_UINT16 yytype_uint16;
|
||||
#else
|
||||
typedef unsigned short int yytype_uint16;
|
||||
typedef unsigned short yytype_uint16;
|
||||
#endif
|
||||
|
||||
#ifdef YYTYPE_INT16
|
||||
typedef YYTYPE_INT16 yytype_int16;
|
||||
#else
|
||||
typedef short int yytype_int16;
|
||||
typedef short yytype_int16;
|
||||
#endif
|
||||
|
||||
#ifndef YYSIZE_T
|
||||
@ -575,7 +575,7 @@ typedef short int yytype_int16;
|
||||
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
|
||||
# define YYSIZE_T size_t
|
||||
# else
|
||||
# define YYSIZE_T unsigned int
|
||||
# define YYSIZE_T unsigned
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@ -627,7 +627,7 @@ typedef short int yytype_int16;
|
||||
# define YYUSE(E) /* empty */
|
||||
#endif
|
||||
|
||||
#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
|
||||
#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
|
||||
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
|
||||
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
|
||||
_Pragma ("GCC diagnostic push") \
|
||||
@ -797,7 +797,7 @@ union yyalloc
|
||||
#define YYMAXUTOK 266
|
||||
|
||||
#define YYTRANSLATE(YYX) \
|
||||
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
|
||||
((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
|
||||
|
||||
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
|
||||
as returned by yylex, without out-of-bounds checking. */
|
||||
@ -1140,7 +1140,7 @@ do { \
|
||||
static void
|
||||
yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, mem_collector * mc, VirtualMachine * vm, ostringstream * parsed, char ** errmsg, yyscan_t scanner)
|
||||
{
|
||||
unsigned long int yylno = yyrline[yyrule];
|
||||
unsigned long yylno = yyrline[yyrule];
|
||||
int yynrhs = yyr2[yyrule];
|
||||
int yyi;
|
||||
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
|
||||
@ -1366,6 +1366,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
|
||||
case N: \
|
||||
yyformat = S; \
|
||||
break
|
||||
default: /* Avoid compiler warnings. */
|
||||
YYCASE_(0, YY_("syntax error"));
|
||||
YYCASE_(1, YY_("syntax error, unexpected %s"));
|
||||
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
|
||||
@ -1606,7 +1607,7 @@ YYLTYPE yylloc = yyloc_default;
|
||||
yylsp = yyls + yysize - 1;
|
||||
|
||||
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
|
||||
(unsigned long int) yystacksize));
|
||||
(unsigned long) yystacksize));
|
||||
|
||||
if (yyss + yystacksize - 1 <= yyssp)
|
||||
YYABORT;
|
||||
@ -1712,21 +1713,22 @@ yyreduce:
|
||||
GCC warning that YYVAL may be used uninitialized. */
|
||||
yyval = yyvsp[1-yylen];
|
||||
|
||||
/* Default location. */
|
||||
/* Default location. */
|
||||
YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
|
||||
yyerror_range[1] = yyloc;
|
||||
YY_REDUCE_PRINT (yyn);
|
||||
switch (yyn)
|
||||
{
|
||||
case 4:
|
||||
#line 433 "vm_var_syntax.y" /* yacc.c:1646 */
|
||||
#line 433 "vm_var_syntax.y" /* yacc.c:1651 */
|
||||
{
|
||||
(*parsed) << (yyvsp[0].val_str);
|
||||
}
|
||||
#line 1726 "vm_var_syntax.cc" /* yacc.c:1646 */
|
||||
#line 1728 "vm_var_syntax.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 5:
|
||||
#line 437 "vm_var_syntax.y" /* yacc.c:1646 */
|
||||
#line 437 "vm_var_syntax.y" /* yacc.c:1651 */
|
||||
{
|
||||
string name((yyvsp[-1].val_str));
|
||||
|
||||
@ -1739,11 +1741,11 @@ yyreduce:
|
||||
(*parsed) << (yyvsp[0].val_char);
|
||||
}
|
||||
}
|
||||
#line 1743 "vm_var_syntax.cc" /* yacc.c:1646 */
|
||||
#line 1745 "vm_var_syntax.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 6:
|
||||
#line 450 "vm_var_syntax.y" /* yacc.c:1646 */
|
||||
#line 450 "vm_var_syntax.y" /* yacc.c:1651 */
|
||||
{
|
||||
string name((yyvsp[-4].val_str));
|
||||
string vname((yyvsp[-2].val_str));
|
||||
@ -1758,11 +1760,11 @@ yyreduce:
|
||||
(*parsed) << (yyvsp[0].val_char);
|
||||
}
|
||||
}
|
||||
#line 1762 "vm_var_syntax.cc" /* yacc.c:1646 */
|
||||
#line 1764 "vm_var_syntax.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
case 7:
|
||||
#line 465 "vm_var_syntax.y" /* yacc.c:1646 */
|
||||
#line 465 "vm_var_syntax.y" /* yacc.c:1651 */
|
||||
{
|
||||
string name((yyvsp[-8].val_str));
|
||||
string vname((yyvsp[-6].val_str));
|
||||
@ -1780,11 +1782,11 @@ yyreduce:
|
||||
(*parsed) << (yyvsp[0].val_char);
|
||||
}
|
||||
}
|
||||
#line 1784 "vm_var_syntax.cc" /* yacc.c:1646 */
|
||||
#line 1786 "vm_var_syntax.cc" /* yacc.c:1651 */
|
||||
break;
|
||||
|
||||
|
||||
#line 1788 "vm_var_syntax.cc" /* yacc.c:1646 */
|
||||
#line 1790 "vm_var_syntax.cc" /* yacc.c:1651 */
|
||||
default: break;
|
||||
}
|
||||
/* User semantic actions sometimes alter yychar, and that requires
|
||||
@ -1907,7 +1909,6 @@ yyerrorlab:
|
||||
if (/*CONSTCOND*/ 0)
|
||||
goto yyerrorlab;
|
||||
|
||||
yyerror_range[1] = yylsp[1-yylen];
|
||||
/* Do not reclaim the symbols of the rule whose action triggered
|
||||
this YYERROR. */
|
||||
YYPOPSTACK (yylen);
|
||||
@ -2019,7 +2020,7 @@ yyreturn:
|
||||
#endif
|
||||
return yyresult;
|
||||
}
|
||||
#line 483 "vm_var_syntax.y" /* yacc.c:1906 */
|
||||
#line 483 "vm_var_syntax.y" /* yacc.c:1910 */
|
||||
|
||||
|
||||
void vm_var_error(
|
||||
|
@ -1,8 +1,8 @@
|
||||
/* A Bison parser, made by GNU Bison 3.0.4. */
|
||||
/* A Bison parser, made by GNU Bison 3.1. */
|
||||
|
||||
/* Bison interface for Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
|
||||
Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -40,7 +40,7 @@
|
||||
extern int vm_var_debug;
|
||||
#endif
|
||||
/* "%code requires" blocks. */
|
||||
#line 17 "vm_var_syntax.y" /* yacc.c:1909 */
|
||||
#line 17 "vm_var_syntax.y" /* yacc.c:1913 */
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
@ -62,7 +62,7 @@ typedef void * yyscan_t;
|
||||
int vm_var_parse (VirtualMachine * vm, ostringstream * parsed, char ** errmsg,
|
||||
yyscan_t scanner);
|
||||
|
||||
#line 66 "vm_var_syntax.hh" /* yacc.c:1909 */
|
||||
#line 66 "vm_var_syntax.hh" /* yacc.c:1913 */
|
||||
|
||||
/* Token type. */
|
||||
#ifndef YYTOKENTYPE
|
||||
@ -86,13 +86,13 @@ int vm_var_parse (VirtualMachine * vm, ostringstream * parsed, char ** errmsg,
|
||||
|
||||
union YYSTYPE
|
||||
{
|
||||
#line 404 "vm_var_syntax.y" /* yacc.c:1909 */
|
||||
#line 404 "vm_var_syntax.y" /* yacc.c:1913 */
|
||||
|
||||
char * val_str;
|
||||
int val_int;
|
||||
char val_char;
|
||||
|
||||
#line 96 "vm_var_syntax.hh" /* yacc.c:1909 */
|
||||
#line 96 "vm_var_syntax.hh" /* yacc.c:1913 */
|
||||
};
|
||||
|
||||
typedef union YYSTYPE YYSTYPE;
|
||||
|
@ -122,7 +122,7 @@ void get_image_attribute(VirtualMachine * vm,
|
||||
// ----------------------------------------------
|
||||
// Get the attribute template from the image
|
||||
// ----------------------------------------------
|
||||
img = ipool->get(iid);
|
||||
img = ipool->get_ro(iid);
|
||||
|
||||
if ( img == 0 )
|
||||
{
|
||||
@ -199,7 +199,7 @@ void get_network_attribute(VirtualMachine * vm,
|
||||
// ----------------------------------------------
|
||||
// Get the attribute template from the image
|
||||
// ----------------------------------------------
|
||||
vn = vnpool->get(vnet_id);
|
||||
vn = vnpool->get_ro(vnet_id);
|
||||
|
||||
if ( vn == 0 )
|
||||
{
|
||||
@ -232,7 +232,7 @@ void get_user_attribute(VirtualMachine * vm,
|
||||
|
||||
attr_value.clear();
|
||||
|
||||
user = upool->get(vm->get_uid());
|
||||
user = upool->get_ro(vm->get_uid());
|
||||
|
||||
if ( user == 0 )
|
||||
{
|
||||
|
@ -123,8 +123,6 @@ int PoolSQL::allocate(PoolObjectSQL *objsql, string& error_str)
|
||||
lastOID = -1;
|
||||
}
|
||||
|
||||
objsql->lock();
|
||||
|
||||
objsql->oid = ++lastOID;
|
||||
|
||||
if ( _set_lastOID(lastOID, db, table) == -1 )
|
||||
@ -168,28 +166,52 @@ PoolObjectSQL * PoolSQL::get(int oid)
|
||||
return 0;
|
||||
}
|
||||
|
||||
PoolObjectSQL * objectsql;
|
||||
pthread_mutex_t * object_lock = cache.lock_line(oid);
|
||||
|
||||
cache.lock_line(oid);
|
||||
|
||||
objectsql = create();
|
||||
PoolObjectSQL * objectsql = create();
|
||||
|
||||
objectsql->oid = oid;
|
||||
|
||||
objectsql->ro = false;
|
||||
|
||||
objectsql->mutex = object_lock;
|
||||
|
||||
int rc = objectsql->select(db);
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
delete objectsql;
|
||||
|
||||
cache.set_line(oid, 0);
|
||||
objectsql->unlock(); //Free object and unlock cache line mutex
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
objectsql->lock();
|
||||
return objectsql;
|
||||
}
|
||||
|
||||
cache.set_line(oid, objectsql);
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
PoolObjectSQL * PoolSQL::get_ro(int oid)
|
||||
{
|
||||
if ( oid < 0 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
PoolObjectSQL * objectsql = create();
|
||||
|
||||
objectsql->oid = oid;
|
||||
|
||||
objectsql->ro = true;
|
||||
|
||||
int rc = objectsql->select(db);
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
objectsql->unlock(); //Free object;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return objectsql;
|
||||
}
|
||||
@ -213,12 +235,27 @@ PoolObjectSQL * PoolSQL::get(const string& name, int ouid)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int PoolSQL::dump(ostringstream& oss, const string& elem_name, const char* table,
|
||||
PoolObjectSQL * PoolSQL::get_ro(const string& name, int uid)
|
||||
{
|
||||
int oid = PoolObjectSQL::select_oid(db, table.c_str(), name, uid);
|
||||
|
||||
if ( oid == -1 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return get_ro(oid);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int PoolSQL::dump(string& oss, const string& elem_name, const string& column, const char* table,
|
||||
const string& where, const string& limit, bool desc)
|
||||
{
|
||||
ostringstream cmd;
|
||||
|
||||
cmd << "SELECT body FROM " << table;
|
||||
cmd << "SELECT " << column << " FROM " << table;
|
||||
|
||||
if ( !where.empty() )
|
||||
{
|
||||
@ -243,25 +280,31 @@ int PoolSQL::dump(ostringstream& oss, const string& elem_name, const char* table
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int PoolSQL::dump(ostringstream& oss, const string& root_elem_name,
|
||||
int PoolSQL::dump(string& oss, const string& root_elem_name,
|
||||
ostringstream& sql_query)
|
||||
{
|
||||
int rc;
|
||||
|
||||
stream_cb cb(1);
|
||||
string_cb cb(1);
|
||||
|
||||
oss << "<" << root_elem_name << ">";
|
||||
ostringstream oelem;
|
||||
|
||||
oelem << "<" << root_elem_name << ">";
|
||||
|
||||
oss.append(oelem.str());
|
||||
|
||||
cb.set_callback(&oss);
|
||||
|
||||
rc = db->exec_rd(sql_query, &cb);
|
||||
|
||||
add_extra_xml(oss);
|
||||
|
||||
oss << "</" << root_elem_name << ">";
|
||||
|
||||
cb.unset_callback();
|
||||
|
||||
oelem.str("");
|
||||
|
||||
oelem << "</" << root_elem_name << ">";
|
||||
|
||||
oss.append(oelem.str());
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -27,8 +27,10 @@ PoolSQLCache::PoolSQLCache()
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void PoolSQLCache::lock_line(int oid)
|
||||
pthread_mutex_t * PoolSQLCache::lock_line(int oid)
|
||||
{
|
||||
static unsigned int num_locks = 0;
|
||||
|
||||
std::map<int, CacheLine *>::iterator it;
|
||||
|
||||
CacheLine * cl;
|
||||
@ -39,7 +41,7 @@ void PoolSQLCache::lock_line(int oid)
|
||||
|
||||
if ( it == cache.end() )
|
||||
{
|
||||
cl = new CacheLine(0);
|
||||
cl = new CacheLine();
|
||||
|
||||
cache.insert(make_pair(oid, cl));
|
||||
}
|
||||
@ -54,51 +56,24 @@ void PoolSQLCache::lock_line(int oid)
|
||||
|
||||
cl->lock();
|
||||
|
||||
if ( cl->object != 0 )
|
||||
{
|
||||
cl->object->lock();
|
||||
|
||||
delete cl->object;
|
||||
|
||||
cl->object = 0;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int PoolSQLCache::set_line(int oid, PoolObjectSQL * object)
|
||||
{
|
||||
std::map<int, CacheLine *>::iterator it;
|
||||
|
||||
lock();
|
||||
|
||||
it = cache.find(oid);
|
||||
cl->active--;
|
||||
|
||||
if ( it == cache.end() )
|
||||
if ( ++num_locks > MAX_ELEMENTS )
|
||||
{
|
||||
unlock();
|
||||
num_locks = 0;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
it->second->active--;
|
||||
|
||||
it->second->object = object;
|
||||
|
||||
it->second->unlock();
|
||||
|
||||
if ( cache.size() > MAX_ELEMENTS )
|
||||
{
|
||||
flush_cache_lines();
|
||||
if ( cache.size() > MAX_ELEMENTS )
|
||||
{
|
||||
flush_cache_lines();
|
||||
}
|
||||
}
|
||||
|
||||
unlock();
|
||||
|
||||
return 0;
|
||||
};
|
||||
return &(cl->mutex);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@ -125,20 +100,7 @@ void PoolSQLCache::flush_cache_lines()
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( cl->object != 0 )
|
||||
{
|
||||
rc = cl->object->trylock();
|
||||
|
||||
if ( rc == EBUSY ) //object int use
|
||||
{
|
||||
cl->unlock();
|
||||
|
||||
++it;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
delete it->second; // cache line & pool object locked & active == 0
|
||||
delete it->second; // cache line locked & active == 0
|
||||
|
||||
it = cache.erase(it);
|
||||
}
|
||||
|
@ -840,7 +840,7 @@ void Request::success_response(const string& val, RequestAttributes& att)
|
||||
vector<xmlrpc_c::value> arrayData;
|
||||
|
||||
arrayData.push_back(xmlrpc_c::value_boolean(true));
|
||||
arrayData.push_back(xmlrpc_c::value_string(val));
|
||||
arrayData.push_back(static_cast<xmlrpc_c::value_string>(val));
|
||||
arrayData.push_back(xmlrpc_c::value_int(SUCCESS));
|
||||
|
||||
xmlrpc_c::value_array arrayresult(arrayData);
|
||||
|
@ -14,10 +14,13 @@
|
||||
/* limitations under the License. */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#include "RequestManager.h"
|
||||
#include "NebulaLog.h"
|
||||
#include <cerrno>
|
||||
|
||||
#include "NebulaLog.h"
|
||||
|
||||
#include "RequestManager.h"
|
||||
#include "RequestManagerConnection.h"
|
||||
|
||||
#include "RequestManagerPoolInfoFilter.h"
|
||||
#include "RequestManagerInfo.h"
|
||||
#include "RequestManagerDelete.h"
|
||||
@ -117,47 +120,96 @@ extern "C" void * rm_action_loop(void *arg)
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Connection class is used to pass arguments to connection threads.
|
||||
*/
|
||||
struct Connection
|
||||
{
|
||||
Connection(int c, ConnectionManager * cm):conn_fd(c), conn_manager(cm){};
|
||||
|
||||
int conn_fd;
|
||||
|
||||
ConnectionManager * conn_manager;
|
||||
};
|
||||
|
||||
/**
|
||||
* Connection Thread runs a xml-rpc method for a connected client
|
||||
*/
|
||||
extern "C" void * rm_do_connection(void *arg)
|
||||
{
|
||||
Connection * rc = static_cast<Connection *>(arg);
|
||||
|
||||
rc->conn_manager->run_connection(rc->conn_fd);
|
||||
|
||||
rc->conn_manager->del();
|
||||
|
||||
close(rc->conn_fd);
|
||||
|
||||
pthread_exit(0);
|
||||
|
||||
delete rc;
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Connection Manager Thread waits for client connections and starts a new
|
||||
* thread to handle the request.
|
||||
*/
|
||||
extern "C" void * rm_xml_server_loop(void *arg)
|
||||
{
|
||||
RequestManager * rm;
|
||||
|
||||
if ( arg == 0 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
rm = static_cast<RequestManager *>(arg);
|
||||
RequestManager * rm = static_cast<RequestManager *>(arg);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Set cancel state for the thread
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,0);
|
||||
|
||||
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS,0);
|
||||
|
||||
//Start the server
|
||||
listen(rm->socket_fd, rm->max_conn_backlog);
|
||||
|
||||
xmlrpc_c::serverAbyss::constrOpt opt = xmlrpc_c::serverAbyss::constrOpt();
|
||||
pthread_attr_t pattr;
|
||||
pthread_t thread_id;
|
||||
|
||||
opt.registryP(&rm->RequestManagerRegistry);
|
||||
opt.keepaliveTimeout(rm->keepalive_timeout);
|
||||
opt.keepaliveMaxConn(rm->keepalive_max_conn);
|
||||
opt.timeout(rm->timeout);
|
||||
opt.socketFd(rm->socket_fd);
|
||||
pthread_attr_init (&pattr);
|
||||
pthread_attr_setdetachstate (&pattr, PTHREAD_CREATE_DETACHED);
|
||||
|
||||
if (!rm->xml_log_file.empty())
|
||||
// -------------------------------------------------------------------------
|
||||
// Main connection loop
|
||||
// -------------------------------------------------------------------------
|
||||
ConnectionManager *cm =new ConnectionManager(rm, rm->max_conn);
|
||||
|
||||
while (true)
|
||||
{
|
||||
opt.logFileName(rm->xml_log_file);
|
||||
ostringstream oss;
|
||||
|
||||
cm->wait();
|
||||
|
||||
struct sockaddr_storage addr;
|
||||
|
||||
socklen_t addr_len = sizeof(struct sockaddr_storage);
|
||||
|
||||
int client_fd = accept(rm->socket_fd, (struct sockaddr*) &addr,
|
||||
&addr_len);
|
||||
|
||||
int nc = cm->add();
|
||||
|
||||
oss << "Number of active connections: " << nc;
|
||||
|
||||
NebulaLog::log("ReM", Log::ERROR, oss);
|
||||
|
||||
Connection * rc = new Connection(client_fd, cm);
|
||||
|
||||
pthread_create(&thread_id, &pattr, rm_do_connection, (void *) rc);
|
||||
}
|
||||
|
||||
#ifndef OLD_XMLRPC
|
||||
opt.maxConn(rm->max_conn);
|
||||
opt.maxConnBacklog(rm->max_conn_backlog);
|
||||
#endif
|
||||
|
||||
rm->AbyssServer = new xmlrpc_c::serverAbyss(opt);
|
||||
|
||||
rm->AbyssServer->run();
|
||||
delete cm;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -165,6 +217,26 @@ extern "C" void * rm_xml_server_loop(void *arg)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
xmlrpc_c::serverAbyss * RequestManager::create_abyss()
|
||||
{
|
||||
xmlrpc_c::serverAbyss::constrOpt opt = xmlrpc_c::serverAbyss::constrOpt();
|
||||
|
||||
opt.registryP(&RequestManagerRegistry);
|
||||
opt.keepaliveTimeout(keepalive_timeout);
|
||||
opt.keepaliveMaxConn(keepalive_max_conn);
|
||||
opt.timeout(timeout);
|
||||
|
||||
if (!xml_log_file.empty())
|
||||
{
|
||||
opt.logFileName(xml_log_file);
|
||||
}
|
||||
|
||||
return new xmlrpc_c::serverAbyss(opt);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int RequestManager::setup_socket()
|
||||
{
|
||||
int rc;
|
||||
|
@ -422,7 +422,7 @@ void ImageAllocate::request_execute(xmlrpc_c::paramList const& params,
|
||||
|
||||
// ------------------------- Check Datastore exists ------------------------
|
||||
|
||||
if ((ds = dspool->get(ds_id)) == 0 )
|
||||
if ((ds = dspool->get_ro(ds_id)) == 0 )
|
||||
{
|
||||
att.resp_id = ds_id;
|
||||
att.resp_obj = PoolObjectSQL::DATASTORE;
|
||||
@ -466,7 +466,7 @@ void ImageAllocate::request_execute(xmlrpc_c::paramList const& params,
|
||||
{
|
||||
// This image comes from a MarketPlaceApp. Get the Market info and
|
||||
// the size.
|
||||
app = apppool->get(app_id);
|
||||
app = apppool->get_ro(app_id);
|
||||
|
||||
if ( app == 0 )
|
||||
{
|
||||
@ -484,7 +484,7 @@ void ImageAllocate::request_execute(xmlrpc_c::paramList const& params,
|
||||
|
||||
app->unlock();
|
||||
|
||||
market = marketpool->get(market_id);
|
||||
market = marketpool->get_ro(market_id);
|
||||
|
||||
if ( market == 0 )
|
||||
{
|
||||
@ -755,7 +755,7 @@ bool UserAllocate::allocate_authorization(
|
||||
{
|
||||
int tmp_gid = xmlrpc_c::value_int(*it);
|
||||
|
||||
Group* group = gpool->get(tmp_gid);
|
||||
Group* group = gpool->get_ro(tmp_gid);
|
||||
|
||||
if (group == 0)
|
||||
{
|
||||
@ -1167,7 +1167,7 @@ Request::ErrorCode MarketPlaceAppAllocate::pool_allocate(
|
||||
// ---------------------------------------------------------------------- //
|
||||
// Get Marketplace information for this app //
|
||||
// ---------------------------------------------------------------------- //
|
||||
MarketPlace * mp = mppool->get(mp_id);
|
||||
MarketPlace * mp = mppool->get_ro(mp_id);
|
||||
|
||||
if ( mp == 0 )
|
||||
{
|
||||
|
@ -210,7 +210,7 @@ Request::ErrorCode TemplateChmod::chmod(
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
VMTemplate* tmpl = static_cast<VMTemplatePool*>(pool)->get(oid);
|
||||
VMTemplate* tmpl = static_cast<VMTemplatePool*>(pool)->get_ro(oid);
|
||||
|
||||
vector<VectorAttribute *> vdisks;
|
||||
vector<VectorAttribute *>::iterator i;
|
||||
@ -296,7 +296,7 @@ void VirtualRouterChmod::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
recursive = xmlrpc_c::value_boolean(paramList.getBoolean(11));
|
||||
}
|
||||
|
||||
vrouter = vrpool->get(oid);
|
||||
vrouter = vrpool->get_ro(oid);
|
||||
|
||||
if ( vrouter == 0 )
|
||||
{
|
||||
|
@ -488,7 +488,7 @@ void UserChown::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
return;
|
||||
}
|
||||
|
||||
if ((user = upool->get(oid)) == 0 )
|
||||
if ((user = upool->get_ro(oid)) == 0 )
|
||||
{
|
||||
att.resp_obj = PoolObjectSQL::USER;
|
||||
att.resp_id = oid;
|
||||
|
@ -157,7 +157,7 @@ Request::ErrorCode VMTemplateClone::clone(int source_id, const string &name,
|
||||
RequestAttributes img_att(att);
|
||||
img_att.resp_obj = PoolObjectSQL::IMAGE;
|
||||
|
||||
VMTemplate * vmtmpl = tpool->get(new_id);
|
||||
VMTemplate * vmtmpl = tpool->get_ro(new_id);
|
||||
|
||||
if (vmtmpl == 0)
|
||||
{
|
||||
|
@ -531,7 +531,7 @@ int MarketPlaceAppDelete::drop(PoolObjectSQL * object, bool recursive,
|
||||
return -1;
|
||||
}
|
||||
|
||||
MarketPlace * mp = marketpool->get(mp_id);
|
||||
MarketPlace * mp = marketpool->get_ro(mp_id);
|
||||
|
||||
if ( mp == 0 )
|
||||
{
|
||||
|
@ -79,7 +79,7 @@ void HostMonitoring::request_execute(
|
||||
int id = xmlrpc_c::value_int(paramList.getInt(1));
|
||||
int rc;
|
||||
|
||||
ostringstream oss;
|
||||
std::string oss;
|
||||
|
||||
if ( basic_authorization(id, att) == false )
|
||||
{
|
||||
@ -95,7 +95,7 @@ void HostMonitoring::request_execute(
|
||||
return;
|
||||
}
|
||||
|
||||
success_response(oss.str(), att);
|
||||
success_response(oss, att);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ Request::ErrorCode ImagePersistent::request_execute(
|
||||
return ec;
|
||||
}
|
||||
|
||||
image = ipool->get(id);
|
||||
image = ipool->get_ro(id);
|
||||
|
||||
if ( image == 0 )
|
||||
{
|
||||
@ -129,7 +129,7 @@ Request::ErrorCode ImagePersistent::request_execute(
|
||||
|
||||
image->unlock();
|
||||
|
||||
ds = dspool->get(ds_id);
|
||||
ds = dspool->get_ro(ds_id);
|
||||
|
||||
if ( ds == 0 )
|
||||
{
|
||||
@ -345,7 +345,7 @@ Request::ErrorCode ImageClone::request_execute(
|
||||
|
||||
// ------------------------- Get source Image info -------------------------
|
||||
|
||||
img = ipool->get(clone_id);
|
||||
img = ipool->get_ro(clone_id);
|
||||
|
||||
if ( img == 0 )
|
||||
{
|
||||
@ -406,7 +406,7 @@ Request::ErrorCode ImageClone::request_execute(
|
||||
|
||||
// ----------------------- Get target Datastore info -----------------------
|
||||
|
||||
ds = dspool->get(ds_id);
|
||||
ds = dspool->get_ro(ds_id);
|
||||
|
||||
if ( ds == 0 )
|
||||
{
|
||||
@ -442,7 +442,7 @@ Request::ErrorCode ImageClone::request_execute(
|
||||
|
||||
if (ds_id != ds_id_orig) //check same DS_MAD
|
||||
{
|
||||
ds = dspool->get(ds_id_orig);
|
||||
ds = dspool->get_ro(ds_id_orig);
|
||||
|
||||
if (ds == 0)
|
||||
{
|
||||
|
@ -47,7 +47,7 @@ void RequestManagerInfo::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
return;
|
||||
}
|
||||
|
||||
object = pool->get(oid);
|
||||
object = pool->get_ro(oid);
|
||||
|
||||
if ( object == 0 )
|
||||
{
|
||||
@ -86,7 +86,7 @@ void TemplateInfo::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
extended = xmlrpc_c::value_boolean(paramList.getBoolean(2));
|
||||
}
|
||||
|
||||
vm_tmpl = tpool->get(oid);
|
||||
vm_tmpl = tpool->get_ro(oid);
|
||||
|
||||
if ( vm_tmpl == 0 )
|
||||
{
|
||||
@ -124,7 +124,7 @@ void TemplateInfo::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
return;
|
||||
}
|
||||
|
||||
vm_tmpl = tpool->get(oid);
|
||||
vm_tmpl = tpool->get_ro(oid);
|
||||
|
||||
if ( vm_tmpl == 0 )
|
||||
{
|
||||
|
@ -134,9 +134,9 @@ void VirtualMachinePoolAccounting::request_execute(
|
||||
int time_start = xmlrpc_c::value_int(paramList.getInt(2));
|
||||
int time_end = xmlrpc_c::value_int(paramList.getInt(3));
|
||||
|
||||
ostringstream oss;
|
||||
string where;
|
||||
int rc;
|
||||
string oss;
|
||||
string where;
|
||||
int rc;
|
||||
|
||||
if ( filter_flag < GROUP )
|
||||
{
|
||||
@ -158,7 +158,7 @@ void VirtualMachinePoolAccounting::request_execute(
|
||||
return;
|
||||
}
|
||||
|
||||
success_response(oss.str(), att);
|
||||
success_response(oss, att);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -176,7 +176,7 @@ void VirtualMachinePoolShowback::request_execute(
|
||||
int end_month = xmlrpc_c::value_int(paramList.getInt(4));
|
||||
int end_year = xmlrpc_c::value_int(paramList.getInt(5));
|
||||
|
||||
ostringstream oss;
|
||||
string oss;
|
||||
string where;
|
||||
int rc;
|
||||
|
||||
@ -202,7 +202,7 @@ void VirtualMachinePoolShowback::request_execute(
|
||||
return;
|
||||
}
|
||||
|
||||
success_response(oss.str(), att);
|
||||
success_response(oss, att);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -216,7 +216,7 @@ void VirtualMachinePoolMonitoring::request_execute(
|
||||
{
|
||||
int filter_flag = xmlrpc_c::value_int(paramList.getInt(1));
|
||||
|
||||
ostringstream oss;
|
||||
string oss;
|
||||
string where;
|
||||
int rc;
|
||||
|
||||
@ -238,7 +238,7 @@ void VirtualMachinePoolMonitoring::request_execute(
|
||||
return;
|
||||
}
|
||||
|
||||
success_response(oss.str(), att);
|
||||
success_response(oss, att);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -260,9 +260,10 @@ void HostPoolMonitoring::request_execute(
|
||||
xmlrpc_c::paramList const& paramList,
|
||||
RequestAttributes& att)
|
||||
{
|
||||
ostringstream oss;
|
||||
string where;
|
||||
int rc;
|
||||
string oss;
|
||||
string where;
|
||||
|
||||
int rc;
|
||||
|
||||
where_filter(att, ALL, -1, -1, "", "", false, false, false, where);
|
||||
|
||||
@ -275,7 +276,7 @@ void HostPoolMonitoring::request_execute(
|
||||
return;
|
||||
}
|
||||
|
||||
success_response(oss.str(), att);
|
||||
success_response(oss, att);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -437,7 +438,9 @@ void RequestManagerPoolInfoFilter::dump(
|
||||
const string& and_clause,
|
||||
const string& or_clause)
|
||||
{
|
||||
ostringstream oss;
|
||||
std::string str;
|
||||
|
||||
std::ostringstream oss;
|
||||
|
||||
std::string where_string, limit_clause;
|
||||
std::string desc;
|
||||
@ -466,13 +469,12 @@ void RequestManagerPoolInfoFilter::dump(
|
||||
{
|
||||
oss << start_id << "," << -end_id;
|
||||
limit_clause = oss.str();
|
||||
oss.str("");
|
||||
}
|
||||
|
||||
Nebula::instance().get_configuration_attribute(att.uid, att.gid,
|
||||
"API_LIST_ORDER", desc);
|
||||
|
||||
rc = pool->dump(oss, where_string, limit_clause,
|
||||
rc = pool->dump(str, where_string, limit_clause,
|
||||
one_util::toupper(desc) == "DESC");
|
||||
|
||||
if ( rc != 0 )
|
||||
@ -482,7 +484,7 @@ void RequestManagerPoolInfoFilter::dump(
|
||||
return;
|
||||
}
|
||||
|
||||
success_response(oss.str(), att);
|
||||
success_response(str, att);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -535,8 +537,8 @@ void VirtualNetworkPoolInfo::request_execute(
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Get the VNET pool */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
ostringstream pool_oss;
|
||||
std::string desc;
|
||||
std::string pool_oss;
|
||||
std::string desc;
|
||||
|
||||
Nebula::instance().get_configuration_attribute(att.uid, att.gid,
|
||||
"API_LIST_ORDER", desc);
|
||||
@ -551,7 +553,7 @@ void VirtualNetworkPoolInfo::request_execute(
|
||||
return;
|
||||
}
|
||||
|
||||
success_response(pool_oss.str(), att);
|
||||
success_response(pool_oss, att);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ void RequestManagerRename::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
|
||||
void ClusterRename::batch_rename(int oid)
|
||||
{
|
||||
Cluster * cluster = static_cast<ClusterPool *>(pool)->get(oid);
|
||||
Cluster * cluster = static_cast<ClusterPool *>(pool)->get_ro(oid);
|
||||
|
||||
if (cluster == 0)
|
||||
{
|
||||
@ -172,7 +172,7 @@ void ClusterRename::batch_rename(int oid)
|
||||
|
||||
void DatastoreRename::batch_rename(int oid)
|
||||
{
|
||||
Datastore * datastore = static_cast<DatastorePool*>(pool)->get(oid);
|
||||
Datastore * datastore = static_cast<DatastorePool*>(pool)->get_ro(oid);
|
||||
|
||||
if (datastore == 0)
|
||||
{
|
||||
@ -212,14 +212,14 @@ void DatastoreRename::batch_rename(int oid)
|
||||
|
||||
void HostRename::batch_rename(int oid)
|
||||
{
|
||||
Host * host = static_cast<HostPool*>(pool)->get(oid);
|
||||
Host * host = static_cast<HostPool*>(pool)->get_ro(oid);
|
||||
|
||||
if (host == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const set<int> & vms = host->get_vm_ids();
|
||||
set<int> vms = host->get_vm_ids();
|
||||
|
||||
set<int>::iterator it;
|
||||
|
||||
@ -252,14 +252,14 @@ void HostRename::batch_rename(int oid)
|
||||
|
||||
void MarketPlaceRename::batch_rename(int oid)
|
||||
{
|
||||
MarketPlace * market = static_cast<MarketPlacePool*>(pool)->get(oid);
|
||||
MarketPlace * market = static_cast<MarketPlacePool*>(pool)->get_ro(oid);
|
||||
|
||||
if (market == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const std::set<int> & apps = market->get_marketapp_ids();
|
||||
std::set<int> apps = market->get_marketapp_ids();
|
||||
|
||||
std::set<int>::iterator it;
|
||||
|
||||
|
@ -206,7 +206,7 @@ void UserEditGroup::
|
||||
PoolObjectAuth uperms;
|
||||
PoolObjectAuth gperms;
|
||||
|
||||
User* user = upool->get(user_id);
|
||||
User* user = upool->get_ro(user_id);
|
||||
|
||||
if ( user == 0 )
|
||||
{
|
||||
@ -416,7 +416,7 @@ void UserLogin::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
|
||||
PoolObjectAuth perms;
|
||||
|
||||
user = static_cast<UserPool *>(pool)->get(uname);
|
||||
user = static_cast<UserPool *>(pool)->get_ro(uname);
|
||||
|
||||
if ( user == 0 )
|
||||
{
|
||||
|
@ -43,7 +43,7 @@ void VMTemplateInstantiate::request_execute(xmlrpc_c::paramList const& paramList
|
||||
clone_template = xmlrpc_c::value_boolean(paramList.getBoolean(5));
|
||||
}
|
||||
|
||||
VMTemplate * tmpl = static_cast<VMTemplatePool* > (pool)->get(id);
|
||||
VMTemplate * tmpl = static_cast<VMTemplatePool* > (pool)->get_ro(id);
|
||||
|
||||
if ( tmpl == 0 )
|
||||
{
|
||||
@ -146,7 +146,7 @@ Request::ErrorCode VMTemplateInstantiate::request_execute(int id, string name,
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Get, check and clone the template */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
rtmpl = tpool->get(id);
|
||||
rtmpl = tpool->get_ro(id);
|
||||
|
||||
if ( rtmpl == 0 )
|
||||
{
|
||||
|
@ -102,7 +102,7 @@ bool RequestManagerVirtualMachine::quota_resize_authorization(
|
||||
RequestAttributes& att)
|
||||
{
|
||||
PoolObjectAuth vm_perms;
|
||||
VirtualMachine * vm = Nebula::instance().get_vmpool()->get(oid);
|
||||
VirtualMachine * vm = Nebula::instance().get_vmpool()->get_ro(oid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -220,7 +220,7 @@ int RequestManagerVirtualMachine::get_default_ds_information(
|
||||
|
||||
ds_id = -1;
|
||||
|
||||
cluster = clpool->get(cluster_id);
|
||||
cluster = clpool->get_ro(cluster_id);
|
||||
|
||||
if (cluster == 0)
|
||||
{
|
||||
@ -269,7 +269,7 @@ int RequestManagerVirtualMachine::get_ds_information(int ds_id,
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
||||
Datastore * ds = nd.get_dspool()->get(ds_id);
|
||||
Datastore * ds = nd.get_dspool()->get_ro(ds_id);
|
||||
|
||||
ds_cluster_ids.clear();
|
||||
|
||||
@ -327,7 +327,7 @@ int RequestManagerVirtualMachine::get_host_information(
|
||||
Nebula& nd = Nebula::instance();
|
||||
HostPool * hpool = nd.get_hpool();
|
||||
|
||||
Host * host = hpool->get(hid);
|
||||
Host * host = hpool->get_ro(hid);
|
||||
|
||||
if ( host == 0 )
|
||||
{
|
||||
@ -379,7 +379,7 @@ bool RequestManagerVirtualMachine::check_host(
|
||||
|
||||
vm->get_requirements(cpu, mem, disk, pci);
|
||||
|
||||
host = hpool->get(hid);
|
||||
host = hpool->get_ro(hid);
|
||||
|
||||
if (host == 0)
|
||||
{
|
||||
@ -846,7 +846,7 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
}
|
||||
else
|
||||
{
|
||||
Datastore * ds = dspool->get(ds_id);
|
||||
Datastore * ds = dspool->get_ro(ds_id);
|
||||
|
||||
if (ds == 0 )
|
||||
{
|
||||
@ -1026,7 +1026,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
|
||||
}
|
||||
else
|
||||
{
|
||||
Datastore * ds = dspool->get(ds_id);
|
||||
Datastore * ds = dspool->get_ro(ds_id);
|
||||
|
||||
if (ds == 0 )
|
||||
{
|
||||
@ -1148,7 +1148,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
|
||||
vm->unlock();
|
||||
|
||||
// Check we are migrating to a compatible cluster
|
||||
Host * host = nd.get_hpool()->get(c_hid);
|
||||
Host * host = nd.get_hpool()->get_ro(c_hid);
|
||||
|
||||
if (host == 0)
|
||||
{
|
||||
@ -1359,7 +1359,7 @@ void VirtualMachineDiskSaveas::request_execute(
|
||||
// -------------------------------------------------------------------------
|
||||
// Get the data of the Image to be saved
|
||||
// -------------------------------------------------------------------------
|
||||
img = ipool->get(iid_orig);
|
||||
img = ipool->get_ro(iid_orig);
|
||||
|
||||
if ( img == 0 )
|
||||
{
|
||||
@ -1396,7 +1396,7 @@ void VirtualMachineDiskSaveas::request_execute(
|
||||
// -------------------------------------------------------------------------
|
||||
// Get the data of the DataStore for the new image & size
|
||||
// -------------------------------------------------------------------------
|
||||
if ((ds = dspool->get(ds_id)) == 0 )
|
||||
if ((ds = dspool->get_ro(ds_id)) == 0 )
|
||||
{
|
||||
goto error_ds;
|
||||
}
|
||||
@ -1590,7 +1590,7 @@ void VirtualMachineMonitoring::request_execute(
|
||||
int id = xmlrpc_c::value_int(paramList.getInt(1));
|
||||
int rc;
|
||||
|
||||
ostringstream oss;
|
||||
string oss;
|
||||
|
||||
bool auth = vm_authorization(id, 0, 0, att, 0, 0, 0, auth_op);
|
||||
|
||||
@ -1608,7 +1608,7 @@ void VirtualMachineMonitoring::request_execute(
|
||||
return;
|
||||
}
|
||||
|
||||
success_response(oss.str(), att);
|
||||
success_response(oss, att);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -1898,7 +1898,7 @@ void VirtualMachineResize::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
tmpl.get("VCPU", nvcpu);
|
||||
tmpl.get("MEMORY", nmemory);
|
||||
|
||||
vm = vmpool->get(id);
|
||||
vm = vmpool->get_ro(id);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -2313,7 +2313,7 @@ Request::ErrorCode VirtualMachineAttachNic::request_execute(int id,
|
||||
// -------------------------------------------------------------------------
|
||||
// Authorize the operation, restricted attributes & check quotas
|
||||
// -------------------------------------------------------------------------
|
||||
vm = vmpool->get(id);
|
||||
vm = vmpool->get_ro(id);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
@ -2434,7 +2434,7 @@ Request::ErrorCode VirtualMachineDetachNic::request_execute(int id, int nic_id,
|
||||
// -------------------------------------------------------------------------
|
||||
// Authorize the operation
|
||||
// -------------------------------------------------------------------------
|
||||
vm = vmpool->get(id);
|
||||
vm = vmpool->get_ro(id);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
@ -2676,7 +2676,7 @@ void VirtualMachineDiskSnapshotCreate::request_execute(
|
||||
{
|
||||
PoolObjectAuth img_perms;
|
||||
|
||||
Image* img = ipool->get(img_id);
|
||||
Image* img = ipool->get_ro(img_id);
|
||||
|
||||
if (img == 0)
|
||||
{
|
||||
@ -2857,7 +2857,7 @@ void VirtualMachineDiskSnapshotDelete::request_execute(
|
||||
{
|
||||
PoolObjectAuth img_perms;
|
||||
|
||||
Image* img = ipool->get(img_id);
|
||||
Image* img = ipool->get_ro(img_id);
|
||||
|
||||
if (img == 0)
|
||||
{
|
||||
@ -3103,7 +3103,7 @@ void VirtualMachineDiskResize::request_execute(
|
||||
|
||||
if ( img_id != -1 )
|
||||
{
|
||||
Image* img = ipool->get(img_id);
|
||||
Image* img = ipool->get_ro(img_id);
|
||||
|
||||
if (img == 0)
|
||||
{
|
||||
|
@ -235,7 +235,7 @@ void VirtualNetworkReserve::request_execute(
|
||||
return;
|
||||
}
|
||||
|
||||
rvn = vnpool->get(rid);
|
||||
rvn = vnpool->get_ro(rid);
|
||||
|
||||
if (rvn == 0)
|
||||
{
|
||||
@ -319,7 +319,7 @@ void VirtualNetworkReserve::request_execute(
|
||||
// -------------------------------------------------------------------------
|
||||
// Authorize the operation Parent:USE Reservation:MANAGE
|
||||
// -------------------------------------------------------------------------
|
||||
vn = vnpool->get(id);
|
||||
vn = vnpool->get_ro(id);
|
||||
|
||||
if ( vn == 0 )
|
||||
{
|
||||
@ -381,7 +381,7 @@ void VirtualNetworkReserve::request_execute(
|
||||
}
|
||||
}
|
||||
|
||||
rvn = vnpool->get(rid);
|
||||
rvn = vnpool->get_ro(rid);
|
||||
|
||||
if (rvn == 0)
|
||||
{
|
||||
|
@ -54,7 +54,7 @@ void VirtualRouterInstantiate::request_execute(
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* Get the Virtual Router NICs */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
vr = vrpool->get(vrid);
|
||||
vr = vrpool->get_ro(vrid);
|
||||
|
||||
if (vr == 0)
|
||||
{
|
||||
@ -94,7 +94,7 @@ void VirtualRouterInstantiate::request_execute(
|
||||
return;
|
||||
}
|
||||
|
||||
VMTemplate * tmpl = tpool->get(tmpl_id);
|
||||
VMTemplate * tmpl = tpool->get_ro(tmpl_id);
|
||||
|
||||
if ( tmpl == 0 )
|
||||
{
|
||||
@ -207,7 +207,7 @@ void VirtualRouterAttachNic::request_execute(
|
||||
// -------------------------------------------------------------------------
|
||||
// Authorize the operation & check quotas
|
||||
// -------------------------------------------------------------------------
|
||||
vr = vrpool->get(vrid);
|
||||
vr = vrpool->get_ro(vrid);
|
||||
|
||||
if (vr == 0)
|
||||
{
|
||||
@ -312,7 +312,7 @@ void VirtualRouterDetachNic::request_execute(
|
||||
// -------------------------------------------------------------------------
|
||||
// Authorize the operation
|
||||
// -------------------------------------------------------------------------
|
||||
vr = vrpool->get(vrid);
|
||||
vr = vrpool->get_ro(vrid);
|
||||
|
||||
if (vr == 0)
|
||||
{
|
||||
|
@ -38,7 +38,7 @@ SecurityGroupPool::SecurityGroupPool(SqlDB * db):PoolSQL(db,SecurityGroup::table
|
||||
|
||||
Nebula& nd = Nebula::instance();
|
||||
UserPool * upool = nd.get_upool();
|
||||
User * oneadmin = upool->get(0);
|
||||
User * oneadmin = upool->get_ro(0);
|
||||
|
||||
string error;
|
||||
|
||||
@ -169,7 +169,7 @@ void SecurityGroupPool::get_security_group_rules(int vmid, int sgid,
|
||||
|
||||
VectorAttribute* rule = *rule_it;
|
||||
|
||||
VirtualNetwork* vnet = vnet_pool->get(vnet_id);
|
||||
VirtualNetwork* vnet = vnet_pool->get_ro(vnet_id);
|
||||
|
||||
if (vnet == 0)
|
||||
{
|
||||
|
@ -86,7 +86,7 @@ void TransferManager::user_action(const ActionRequest& ar)
|
||||
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
||||
VirtualMachine * vm = vmpool->get(vid);
|
||||
VirtualMachine * vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -574,26 +574,18 @@ void TransferManager::prolog_action(int vid)
|
||||
// -------------------------------------------------------------------------
|
||||
// Setup & Transfer script
|
||||
// -------------------------------------------------------------------------
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int uid = vm->get_created_by_uid();
|
||||
int uid = vm->get_created_by_uid();
|
||||
int owner_id = vm->get_uid();
|
||||
vm->unlock();
|
||||
|
||||
token_password = Nebula::instance().get_upool()->get_token_password(uid, owner_id);
|
||||
|
||||
vm = vmpool->get(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
VirtualMachineDisks& disks = vm->get_disks();
|
||||
|
||||
if (!vm->hasHistory())
|
||||
@ -676,6 +668,14 @@ void TransferManager::prolog_action(int vid)
|
||||
|
||||
if ( update )
|
||||
{
|
||||
vm->unlock();
|
||||
|
||||
vm = vmpool->get(vid);
|
||||
if (vm == 0)
|
||||
{
|
||||
goto error_attributes;
|
||||
}
|
||||
|
||||
vmpool->update(vm);
|
||||
}
|
||||
}
|
||||
@ -737,7 +737,7 @@ void TransferManager::prolog_migr_action(int vid)
|
||||
// -------------------------------------------------------------------------
|
||||
// Setup & Transfer script
|
||||
// -------------------------------------------------------------------------
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -868,26 +868,18 @@ void TransferManager::prolog_resume_action(int vid)
|
||||
// -------------------------------------------------------------------------
|
||||
// Setup & Transfer script
|
||||
// -------------------------------------------------------------------------
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int uid = vm->get_created_by_uid();
|
||||
int uid = vm->get_created_by_uid();
|
||||
int owner_id = vm->get_uid();
|
||||
vm->unlock();
|
||||
|
||||
token_password = Nebula::instance().get_upool()->get_token_password(uid, owner_id);
|
||||
|
||||
vm = vmpool->get(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
VirtualMachineDisks& disks = vm->get_disks();
|
||||
|
||||
if (!vm->hasHistory())
|
||||
@ -1010,7 +1002,7 @@ void TransferManager::prolog_attach_action(int vid)
|
||||
// Setup & Transfer script
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -1192,7 +1184,7 @@ void TransferManager::epilog_action(bool local, int vid)
|
||||
// ------------------------------------------------------------------------
|
||||
// Setup & Transfer script
|
||||
// ------------------------------------------------------------------------
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -1301,7 +1293,7 @@ void TransferManager::epilog_stop_action(int vid)
|
||||
// ------------------------------------------------------------------------
|
||||
// Setup & Transfer script
|
||||
// ------------------------------------------------------------------------
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -1550,7 +1542,7 @@ void TransferManager::epilog_delete_action(bool local, int vid)
|
||||
// ------------------------------------------------------------------------
|
||||
// Setup & Transfer script
|
||||
// ------------------------------------------------------------------------
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -1623,7 +1615,7 @@ void TransferManager::epilog_delete_previous_action(int vid)
|
||||
// ------------------------------------------------------------------------
|
||||
// Setup & Transfer script
|
||||
// ------------------------------------------------------------------------
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -1696,7 +1688,7 @@ void TransferManager::epilog_delete_both_action(int vid)
|
||||
// ------------------------------------------------------------------------
|
||||
// Setup & Transfer script
|
||||
// ------------------------------------------------------------------------
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -1771,7 +1763,7 @@ void TransferManager::epilog_detach_action(int vid)
|
||||
// ------------------------------------------------------------------------
|
||||
// Setup & Transfer script
|
||||
// ------------------------------------------------------------------------
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -1870,7 +1862,7 @@ void TransferManager::driver_cancel_action(int vid)
|
||||
return;
|
||||
}
|
||||
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -1920,7 +1912,7 @@ void TransferManager::saveas_hot_action(int vid)
|
||||
// ------------------------------------------------------------------------
|
||||
// Setup & Transfer script
|
||||
// ------------------------------------------------------------------------
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -2071,7 +2063,7 @@ void TransferManager::do_snapshot_action(int vid, const char * snap_action)
|
||||
goto error_driver;
|
||||
}
|
||||
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -2195,7 +2187,7 @@ void TransferManager::resize_action(int vid)
|
||||
goto error_driver;
|
||||
}
|
||||
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
|
@ -357,7 +357,7 @@ void Quotas::ds_del_recreate(int uid, int gid, vector<Template *>& ds_quotas)
|
||||
|
||||
if ( img_owner )
|
||||
{
|
||||
Image* img = ipool->get(image_id);
|
||||
Image* img = ipool->get_ro(image_id);
|
||||
|
||||
if(img != 0)
|
||||
{
|
||||
|
@ -76,7 +76,7 @@ UserPool::UserPool(SqlDB * db,
|
||||
|
||||
_session_expiration_time = __session_expiration_time;
|
||||
|
||||
User * oneadmin_user = get(0);
|
||||
User * oneadmin_user = get_ro(0);
|
||||
|
||||
//Slaves do not need to init the pool, just the oneadmin username
|
||||
if (is_federation_slave)
|
||||
@ -941,7 +941,7 @@ bool UserPool::authenticate_server(User * user,
|
||||
goto wrong_server_token;
|
||||
}
|
||||
|
||||
user = get(target_username);
|
||||
user = get_ro(target_username);
|
||||
|
||||
if ( user == 0 )
|
||||
{
|
||||
@ -1275,7 +1275,7 @@ int UserPool::authorize(AuthRequest& ar)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int UserPool::dump(ostringstream& oss, const string& where, const string& limit,
|
||||
int UserPool::dump(string& oss, const string& where, const string& limit,
|
||||
bool desc)
|
||||
{
|
||||
int rc;
|
||||
@ -1305,9 +1305,9 @@ int UserPool::dump(ostringstream& oss, const string& where, const string& limit,
|
||||
cmd << " LIMIT " << limit;
|
||||
}
|
||||
|
||||
oss << "<USER_POOL>";
|
||||
oss.append("<USER_POOL>");
|
||||
|
||||
stream_cb cb(2);
|
||||
string_cb cb(2);
|
||||
|
||||
cb.set_callback(&oss);
|
||||
|
||||
@ -1315,9 +1315,9 @@ int UserPool::dump(ostringstream& oss, const string& where, const string& limit,
|
||||
|
||||
cb.unset_callback();
|
||||
|
||||
oss << Nebula::instance().get_default_user_quota().to_xml(def_quota_xml);
|
||||
oss.append(Nebula::instance().get_default_user_quota().to_xml(def_quota_xml));
|
||||
|
||||
oss << "</USER_POOL>";
|
||||
oss.append("</USER_POOL>");
|
||||
|
||||
return rc;
|
||||
}
|
||||
@ -1328,15 +1328,17 @@ int UserPool::dump(ostringstream& oss, const string& where, const string& limit,
|
||||
string UserPool::get_token_password(int oid, int bck_oid){
|
||||
|
||||
string token_password = "";
|
||||
User * user = get(oid);
|
||||
User * user = get_ro(oid);
|
||||
|
||||
if (user != 0)
|
||||
{
|
||||
user->get_template_attribute("TOKEN_PASSWORD", token_password);
|
||||
user->unlock();
|
||||
}
|
||||
else{
|
||||
user = get(bck_oid);
|
||||
else
|
||||
{
|
||||
user = get_ro(bck_oid);
|
||||
|
||||
if (user != 0)
|
||||
{
|
||||
user->get_template_attribute("TOKEN_PASSWORD", token_password);
|
||||
|
@ -341,6 +341,29 @@ string& History::to_xml(string& xml, bool database) const
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
string& History::to_xml_short(string& xml) const
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
oss <<
|
||||
"<HISTORY>" <<
|
||||
"<OID>" << oid << "</OID>" <<
|
||||
"<SEQ>" << seq << "</SEQ>" <<
|
||||
"<HOSTNAME>" << one_util::escape_xml(hostname) << "</HOSTNAME>" <<
|
||||
"<HID>" << hid << "</HID>" <<
|
||||
"<CID>" << cid << "</CID>" <<
|
||||
"<DS_ID>" << ds_id << "</DS_ID>" <<
|
||||
"<ACTION>" << one_util::escape_xml(action) << "</ACTION>" <<
|
||||
"</HISTORY>";
|
||||
|
||||
xml = oss.str();
|
||||
|
||||
return xml;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int History::rebuild_attributes()
|
||||
{
|
||||
vector<xmlNodePtr> content;
|
||||
|
@ -457,12 +457,12 @@ const char * VirtualMachine::table = "vm_pool";
|
||||
|
||||
const char * VirtualMachine::db_names =
|
||||
"oid, name, body, uid, gid, last_poll, state, lcm_state, "
|
||||
"owner_u, group_u, other_u";
|
||||
"owner_u, group_u, other_u, short_body";
|
||||
|
||||
const char * VirtualMachine::db_bootstrap = "CREATE TABLE IF NOT EXISTS "
|
||||
"vm_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body MEDIUMTEXT, uid INTEGER, "
|
||||
"gid INTEGER, last_poll INTEGER, state INTEGER, lcm_state INTEGER, "
|
||||
"owner_u INTEGER, group_u INTEGER, other_u INTEGER)";
|
||||
"owner_u INTEGER, group_u INTEGER, other_u INTEGER, short_body MEDIUMTEXT)";
|
||||
|
||||
|
||||
const char * VirtualMachine::monit_table = "vm_monitoring";
|
||||
@ -1659,9 +1659,10 @@ int VirtualMachine::insert_replace(SqlDB *db, bool replace, string& error_str)
|
||||
ostringstream oss;
|
||||
int rc;
|
||||
|
||||
string xml_body;
|
||||
string xml_body, short_xml_body;
|
||||
char * sql_name;
|
||||
char * sql_xml;
|
||||
char * sql_short_xml;
|
||||
|
||||
sql_name = db->escape_str(name.c_str());
|
||||
|
||||
@ -1682,6 +1683,18 @@ int VirtualMachine::insert_replace(SqlDB *db, bool replace, string& error_str)
|
||||
goto error_xml;
|
||||
}
|
||||
|
||||
sql_short_xml = db->escape_str(to_xml_short(short_xml_body).c_str());
|
||||
|
||||
if ( sql_short_xml == 0 )
|
||||
{
|
||||
goto error_body_short;
|
||||
}
|
||||
|
||||
if ( validate_xml(sql_short_xml) != 0 )
|
||||
{
|
||||
goto error_xml_short;
|
||||
}
|
||||
|
||||
if(replace)
|
||||
{
|
||||
oss << "REPLACE";
|
||||
@ -1702,15 +1715,20 @@ int VirtualMachine::insert_replace(SqlDB *db, bool replace, string& error_str)
|
||||
<< lcm_state << ","
|
||||
<< owner_u << ","
|
||||
<< group_u << ","
|
||||
<< other_u << ")";
|
||||
<< other_u << ","
|
||||
<< "'" << sql_short_xml << "'"
|
||||
<< ")";
|
||||
|
||||
db->free_str(sql_name);
|
||||
db->free_str(sql_xml);
|
||||
db->free_str(sql_short_xml);
|
||||
|
||||
rc = db->exec_wr(oss);
|
||||
|
||||
return rc;
|
||||
|
||||
error_xml_short:
|
||||
db->free_str(sql_short_xml);
|
||||
error_xml:
|
||||
db->free_str(sql_name);
|
||||
db->free_str(sql_xml);
|
||||
@ -1719,6 +1737,8 @@ error_xml:
|
||||
|
||||
goto error_common;
|
||||
|
||||
error_body_short:
|
||||
db->free_str(sql_xml);
|
||||
error_body:
|
||||
db->free_str(sql_name);
|
||||
goto error_generic;
|
||||
@ -2192,6 +2212,95 @@ string& VirtualMachine::to_xml_extended(string& xml, int n_history) const
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
string& VirtualMachine::to_xml_short(string& xml)
|
||||
{
|
||||
string disks_xml, monitoring_xml, user_template_xml, history_xml, nics_xml;
|
||||
ostringstream oss;
|
||||
string cpu_tmpl, mem_tmpl, auto_reqs, auto_ds_reqs;
|
||||
|
||||
obj_template->get("CPU", cpu_tmpl);
|
||||
obj_template->get("MEMORY", mem_tmpl);
|
||||
obj_template->get("AUTOMATIC_REQUIREMENTS", auto_reqs);
|
||||
obj_template->get("AUTOMATIC_DS_REQUIREMENTS", auto_ds_reqs);
|
||||
|
||||
oss << "<VM>"
|
||||
<< "<ID>" << oid << "</ID>"
|
||||
<< "<UID>" << uid << "</UID>"
|
||||
<< "<GID>" << gid << "</GID>"
|
||||
<< "<UNAME>" << uname << "</UNAME>"
|
||||
<< "<GNAME>" << gname << "</GNAME>"
|
||||
<< "<NAME>" << name << "</NAME>"
|
||||
<< "<LAST_POLL>" << last_poll << "</LAST_POLL>"
|
||||
<< "<STATE>" << state << "</STATE>"
|
||||
<< "<LCM_STATE>" << lcm_state << "</LCM_STATE>"
|
||||
<< "<RESCHED>" << resched << "</RESCHED>"
|
||||
<< "<STIME>" << stime << "</STIME>"
|
||||
<< "<ETIME>" << etime << "</ETIME>"
|
||||
<< "<DEPLOY_ID>" << deploy_id << "</DEPLOY_ID>";
|
||||
|
||||
oss << "<TEMPLATE>"
|
||||
<< "<CPU>" << cpu_tmpl << "</CPU>"
|
||||
<< "<MEMORY>" << mem_tmpl << "</MEMORY>"
|
||||
<< disks.to_xml_short(disks_xml)
|
||||
<< nics.to_xml_short(nics_xml);
|
||||
|
||||
VectorAttribute * graph = obj_template->get("GRAPHICS");
|
||||
|
||||
if ( graph != 0 )
|
||||
{
|
||||
graph->to_xml(oss);
|
||||
}
|
||||
|
||||
if (!auto_reqs.empty())
|
||||
{
|
||||
oss << "<AUTOMATIC_REQUIREMENTS>";
|
||||
oss << one_util::escape_xml(auto_reqs);
|
||||
oss << "</AUTOMATIC_REQUIREMENTS>";
|
||||
}
|
||||
|
||||
if (!auto_ds_reqs.empty())
|
||||
{
|
||||
oss << "<AUTOMATIC_DS_REQUIREMENTS>";
|
||||
oss << one_util::escape_xml(auto_ds_reqs);
|
||||
oss << "</AUTOMATIC_DS_REQUIREMENTS>";
|
||||
}
|
||||
|
||||
oss << "</TEMPLATE>"
|
||||
<< monitoring.to_xml_short(monitoring_xml)
|
||||
<< user_obj_template->to_xml_short(user_template_xml);
|
||||
|
||||
if ( hasHistory() )
|
||||
{
|
||||
oss << "<HISTORY_RECORDS>";
|
||||
oss << history_records[history_records.size() - 1]->to_xml_short(history_xml);
|
||||
oss << "</HISTORY_RECORDS>";
|
||||
}
|
||||
else
|
||||
{
|
||||
oss << "<HISTORY_RECORDS/>";
|
||||
}
|
||||
|
||||
std::vector<VectorAttribute *> vm_groups;
|
||||
|
||||
if (obj_template->get("VMGROUP", vm_groups) > 0)
|
||||
{
|
||||
for (std::vector<VectorAttribute *>::iterator it = vm_groups.begin();
|
||||
it != vm_groups.end() ; it++)
|
||||
{
|
||||
(*it)->to_xml(oss);
|
||||
}
|
||||
}
|
||||
|
||||
oss << "</VM>";
|
||||
|
||||
xml = oss.str();
|
||||
|
||||
return xml;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int VirtualMachine::from_xml(const string &xml_str)
|
||||
{
|
||||
vector<xmlNodePtr> content;
|
||||
|
@ -492,7 +492,7 @@ int VirtualMachine::parse_context(string& error_str)
|
||||
|
||||
for ( it=img_ids.begin() ; it < img_ids.end(); it++ )
|
||||
{
|
||||
img = ipool->get(*it);
|
||||
img = ipool->get_ro(*it);
|
||||
|
||||
if ( img != 0 )
|
||||
{
|
||||
|
@ -81,7 +81,7 @@ int VirtualMachineDisk::get_uid(int _uid)
|
||||
Nebula& nd = Nebula::instance();
|
||||
UserPool * upool = nd.get_upool();
|
||||
|
||||
user = upool->get(uname);
|
||||
user = upool->get_ro(uname);
|
||||
|
||||
if ( user == 0 )
|
||||
{
|
||||
@ -122,7 +122,7 @@ int VirtualMachineDisk::get_image_id(int &id, int uid)
|
||||
return -1;
|
||||
}
|
||||
|
||||
Image * image = ipool->get(iname, uiid);
|
||||
Image * image = ipool->get_ro(iname, uiid);
|
||||
|
||||
if ( image != 0 )
|
||||
{
|
||||
@ -185,7 +185,7 @@ void VirtualMachineDisk::authorize(int uid, AuthRequest* ar, bool check_lock)
|
||||
return;
|
||||
}
|
||||
|
||||
img = ipool->get(source , uiid);
|
||||
img = ipool->get_ro(source , uiid);
|
||||
|
||||
if ( img != 0 )
|
||||
{
|
||||
@ -194,7 +194,7 @@ void VirtualMachineDisk::authorize(int uid, AuthRequest* ar, bool check_lock)
|
||||
}
|
||||
else if ( vector_value("IMAGE_ID", iid) == 0 )
|
||||
{
|
||||
img = ipool->get(iid);
|
||||
img = ipool->get_ro(iid);
|
||||
}
|
||||
|
||||
if (img == 0)
|
||||
@ -558,6 +558,28 @@ void VirtualMachineDisk::set_types(const string& ds_name)
|
||||
replace("DISK_TYPE", ds_name);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
#define XML_DISK_ATTR(Y,X) ( Y << "<" << X << ">" << \
|
||||
one_util::escape_xml(vector_value(X)) << "</" << X << ">")
|
||||
|
||||
void VirtualMachineDisk::to_xml_short(std::ostringstream& oss) const
|
||||
{
|
||||
oss << "<DISK>" ;
|
||||
XML_DISK_ATTR(oss, "DISK_ID");
|
||||
XML_DISK_ATTR(oss, "DATASTORE");
|
||||
XML_DISK_ATTR(oss, "DATASTORE_ID");
|
||||
XML_DISK_ATTR(oss, "IMAGE");
|
||||
XML_DISK_ATTR(oss, "IMAGE_ID");
|
||||
XML_DISK_ATTR(oss, "SIZE");
|
||||
XML_DISK_ATTR(oss, "TYPE");
|
||||
XML_DISK_ATTR(oss, "CLONE");
|
||||
XML_DISK_ATTR(oss, "CLONE_TARGET");
|
||||
XML_DISK_ATTR(oss, "LN_TARGET");
|
||||
XML_DISK_ATTR(oss, "DISK_SNAPSHOT_TOTAL_SIZE");
|
||||
oss << "</DISK>";
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@ -1561,3 +1583,17 @@ int VirtualMachineDisks::get_saveas_info(int& disk_id, string& source,
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
std::string& VirtualMachineDisks::to_xml_short(std::string& xml)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
|
||||
for ( disk_iterator disk = begin() ; disk != end() ; ++disk )
|
||||
{
|
||||
(*disk)->to_xml_short(oss);
|
||||
}
|
||||
|
||||
xml = oss.str();
|
||||
|
||||
return xml;
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ int VirtualMachineNic::get_uid(int _uid, string& error)
|
||||
else if ( !(uname = vector_value("NETWORK_UNAME")).empty() )
|
||||
{
|
||||
UserPool * upool = Nebula::instance().get_upool();
|
||||
User * user = upool->get(uname);
|
||||
User * user = upool->get_ro(uname);
|
||||
|
||||
if ( user == 0 )
|
||||
{
|
||||
@ -136,7 +136,7 @@ void VirtualMachineNic::authorize(PoolObjectSQL::ObjectType ot, int uid,
|
||||
|
||||
for(set<int>::iterator it = sgroups.begin(); it != sgroups.end(); it++)
|
||||
{
|
||||
SecurityGroup * sgroup = sgpool->get(*it);
|
||||
SecurityGroup * sgroup = sgpool->get_ro(*it);
|
||||
|
||||
if(sgroup != 0)
|
||||
{
|
||||
@ -158,6 +158,44 @@ void VirtualMachineNic::authorize(PoolObjectSQL::ObjectType ot, int uid,
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#define XML_NIC_ATTR(Y,X) ( Y << "<" << X << ">" << \
|
||||
one_util::escape_xml(vector_value(X)) << "</" << X << ">")
|
||||
|
||||
void VirtualMachineNic::to_xml_short(std::ostringstream& oss) const
|
||||
{
|
||||
std::string ip = vector_value("IP");
|
||||
std::string ip6 = vector_value("IP6");
|
||||
std::string ip6_ula = vector_value("IP6_ULA");
|
||||
|
||||
oss << "<NIC>";
|
||||
|
||||
if (!ip.empty())
|
||||
{
|
||||
oss << "<IP>" << one_util::escape_xml(ip) << "</IP>";
|
||||
}
|
||||
|
||||
if (!ip6.empty())
|
||||
{
|
||||
oss << "<IP6>" << one_util::escape_xml(ip6) << "</IP6>";
|
||||
}
|
||||
|
||||
if (!ip6_ula.empty())
|
||||
{
|
||||
oss << "<IP6_ULA>" << one_util::escape_xml(ip6_ula) << "</IP6_ULA>";
|
||||
}
|
||||
|
||||
XML_NIC_ATTR(oss, "MAC");
|
||||
XML_NIC_ATTR(oss, "NETWORK");
|
||||
XML_NIC_ATTR(oss, "NETWORK_ID");
|
||||
XML_NIC_ATTR(oss, "NIC_ID");
|
||||
XML_NIC_ATTR(oss, "SECURITY_GROUPS");
|
||||
|
||||
oss << "</NIC>";
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@ -338,3 +376,21 @@ int VirtualMachineNics::set_up_attach_nic(int vmid, int uid, int cluster_id,
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
std::string& VirtualMachineNics::to_xml_short(std::string& xml)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
|
||||
for ( nic_iterator nic = begin() ; nic != end() ; ++nic )
|
||||
{
|
||||
(*nic)->to_xml_short(oss);
|
||||
}
|
||||
|
||||
xml = oss.str();
|
||||
|
||||
return xml;
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ int VirtualMachine::set_os_file(VectorAttribute* os, const string& base_name,
|
||||
|
||||
img_id = img_ids.back();
|
||||
|
||||
img = ipool->get(img_id);
|
||||
img = ipool->get_ro(img_id);
|
||||
|
||||
if ( img == 0 )
|
||||
{
|
||||
@ -157,7 +157,7 @@ int VirtualMachine::set_os_file(VectorAttribute* os, const string& base_name,
|
||||
return -1;
|
||||
}
|
||||
|
||||
ds = ds_pool->get(ds_id);
|
||||
ds = ds_pool->get_ro(ds_id);
|
||||
|
||||
if ( ds == 0 )
|
||||
{
|
||||
|
@ -373,10 +373,8 @@ int VirtualMachinePool::get_pending(
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int VirtualMachinePool::dump_acct(ostringstream& oss,
|
||||
const string& where,
|
||||
int time_start,
|
||||
int time_end)
|
||||
int VirtualMachinePool::dump_acct(string& oss, const string& where,
|
||||
int time_start, int time_end)
|
||||
{
|
||||
ostringstream cmd;
|
||||
|
||||
@ -410,7 +408,7 @@ int VirtualMachinePool::dump_acct(ostringstream& oss,
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int VirtualMachinePool::dump_showback(ostringstream& oss,
|
||||
int VirtualMachinePool::dump_showback(string& oss,
|
||||
const string& where,
|
||||
int start_month,
|
||||
int start_year,
|
||||
@ -493,7 +491,7 @@ int VirtualMachinePool::clean_all_monitoring()
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int VirtualMachinePool::dump_monitoring(
|
||||
ostringstream& oss,
|
||||
string& oss,
|
||||
const string& where)
|
||||
{
|
||||
ostringstream cmd;
|
||||
@ -710,10 +708,11 @@ int VirtualMachinePool::calculate_showback(
|
||||
// Get accounting history records
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
oss.str("");
|
||||
rc = dump_acct(oss, "", start_time, end_time);
|
||||
std::string acct_str;
|
||||
|
||||
ObjectXML xml(oss.str());
|
||||
rc = dump_acct(acct_str, "", start_time, end_time);
|
||||
|
||||
ObjectXML xml(acct_str);
|
||||
|
||||
#ifdef SBDEBUG
|
||||
time_t debug_t_1 = time(0);
|
||||
@ -890,7 +889,7 @@ int VirtualMachinePool::calculate_showback(
|
||||
{
|
||||
int vmid = vm_it->first;
|
||||
|
||||
vm = get(vmid);
|
||||
vm = get_ro(vmid);
|
||||
|
||||
int uid = 0;
|
||||
int gid = 0;
|
||||
|
@ -79,3 +79,106 @@ int VirtualMachineTemplate::replace_disk_image(int target_id, const string&
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
string& VirtualMachineTemplate::to_xml_short(string& xml) const
|
||||
{
|
||||
ostringstream oss;
|
||||
string labels;
|
||||
|
||||
string schd_rank, schd_ds_rank;
|
||||
string schd_req, schd_ds_req;
|
||||
|
||||
string user_prio;
|
||||
|
||||
vector<const VectorAttribute*> attrs;
|
||||
|
||||
if (attributes.empty())
|
||||
{
|
||||
oss << "<USER_TEMPLATE/>";
|
||||
}
|
||||
else
|
||||
{
|
||||
oss << "<USER_TEMPLATE>";
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Attributes required by Sunstone */
|
||||
/* - LABELS */
|
||||
/* ------------------------------------------------------------------ */
|
||||
if (get("LABELS", labels))
|
||||
{
|
||||
oss << "<LABELS>" << one_util::escape_xml(labels) << "</LABELS>";
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Attributes required by Scheduler */
|
||||
/* - SCHED_RANK (RANK - deprecated) */
|
||||
/* - SCHED_DS_RANK */
|
||||
/* - SCHED_REQUIREMENTS */
|
||||
/* - SCHED_DS_REQUIREMENTS */
|
||||
/* */
|
||||
/* - SCHED_ACTION */
|
||||
/* - PUBLIC_CLOUD */
|
||||
/* ------------------------------------------------------------------ */
|
||||
if (get("SCHED_RANK", schd_rank))
|
||||
{
|
||||
oss << "<SCHED_RANK>" << one_util::escape_xml(schd_rank)
|
||||
<< "</SCHED_RANK>";
|
||||
}
|
||||
|
||||
if (get("SCHED_DS_RANK", schd_ds_rank))
|
||||
{
|
||||
oss << "<SCHED_DS_RANK>" << one_util::escape_xml(schd_ds_rank)
|
||||
<< "</SCHED_DS_RANK>";
|
||||
}
|
||||
|
||||
if (get("SCHED_REQUIREMENTS", schd_req))
|
||||
{
|
||||
oss << "<SCHED_REQUIREMENTS>" << one_util::escape_xml(schd_req)
|
||||
<< "</SCHED_REQUIREMENTS>";
|
||||
}
|
||||
|
||||
if (get("SCHED_DS_REQUIREMENTS", schd_ds_req))
|
||||
{
|
||||
oss << "<SCHED_DS_REQUIREMENTS>" << one_util::escape_xml(schd_ds_req)
|
||||
<< "</SCHED_DS_REQUIREMENTS>";
|
||||
}
|
||||
|
||||
if (get("USER_PRIORITY", user_prio))
|
||||
{
|
||||
oss << "<USER_PRIORITY>" << one_util::escape_xml(user_prio)
|
||||
<< "</USER_PRIORITY>";
|
||||
}
|
||||
|
||||
if ( get("PUBLIC_CLOUD", attrs) > 0 )
|
||||
{
|
||||
vector<const VectorAttribute *>::const_iterator it;
|
||||
|
||||
for (it = attrs.begin(); it != attrs.end(); it++)
|
||||
{
|
||||
(*it)->to_xml(oss);
|
||||
}
|
||||
}
|
||||
|
||||
attrs.clear();
|
||||
|
||||
if ( get("SCHED_ACTION", attrs) > 0 )
|
||||
{
|
||||
vector<const VectorAttribute *>::const_iterator it;
|
||||
|
||||
for (it = attrs.begin(); it != attrs.end(); it++)
|
||||
{
|
||||
(*it)->to_xml(oss);
|
||||
}
|
||||
}
|
||||
|
||||
oss << "</USER_TEMPLATE>";
|
||||
}
|
||||
|
||||
xml = oss.str();
|
||||
|
||||
return xml;
|
||||
}
|
||||
|
||||
|
@ -202,7 +202,7 @@ string * VirtualMachineManager::format_message(
|
||||
ostringstream oss;
|
||||
|
||||
string ds_tmpl = "";
|
||||
Datastore * ds = ds_pool->get(ds_id);
|
||||
Datastore * ds = ds_pool->get_ro(ds_id);
|
||||
|
||||
if ( ds != 0 )
|
||||
{
|
||||
@ -346,7 +346,7 @@ void VirtualMachineManager::deploy_action(int vid)
|
||||
string vm_tmpl;
|
||||
string * drv_msg;
|
||||
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -355,6 +355,7 @@ void VirtualMachineManager::deploy_action(int vid)
|
||||
|
||||
int uid = vm->get_created_by_uid();
|
||||
int owner_id = vm->get_uid();
|
||||
|
||||
vm->unlock();
|
||||
|
||||
password = Nebula::instance().get_upool()->get_token_password(uid, owner_id);
|
||||
@ -467,7 +468,7 @@ void VirtualMachineManager::save_action(
|
||||
ostringstream os;
|
||||
|
||||
// Get the VM from the pool
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -565,7 +566,7 @@ void VirtualMachineManager::shutdown_action(
|
||||
ostringstream os;
|
||||
|
||||
// Get the VM from the pool
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -640,7 +641,7 @@ void VirtualMachineManager::reboot_action(
|
||||
ostringstream os;
|
||||
|
||||
// Get the VM from the pool
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -710,7 +711,7 @@ void VirtualMachineManager::reset_action(
|
||||
ostringstream os;
|
||||
|
||||
// Get the VM from the pool
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -781,7 +782,7 @@ void VirtualMachineManager::cancel_action(
|
||||
const VirtualMachineManagerDriver * vmd;
|
||||
|
||||
// Get the VM from the pool
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -857,7 +858,7 @@ void VirtualMachineManager::cancel_previous_action(
|
||||
const VirtualMachineManagerDriver * vmd;
|
||||
|
||||
// Get the VM from the pool
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -933,7 +934,7 @@ void VirtualMachineManager::cleanup_action(
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
||||
// Get the VM from the pool
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -1027,7 +1028,7 @@ void VirtualMachineManager::cleanup_previous_action(int vid)
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
||||
// Get the VM from the pool
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -1110,7 +1111,7 @@ void VirtualMachineManager::migrate_action(
|
||||
string * drv_msg;
|
||||
|
||||
// Get the VM from the pool
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -1201,7 +1202,7 @@ void VirtualMachineManager::restore_action(
|
||||
|
||||
string* drv_msg;
|
||||
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -1210,6 +1211,7 @@ void VirtualMachineManager::restore_action(
|
||||
|
||||
int uid = vm->get_created_by_uid();
|
||||
int owner_id = vm->get_uid();
|
||||
|
||||
vm->unlock();
|
||||
|
||||
password = Nebula::instance().get_upool()->get_token_password(uid, owner_id);
|
||||
@ -1300,7 +1302,7 @@ void VirtualMachineManager::poll_action(
|
||||
string * drv_msg;
|
||||
|
||||
// Get the VM from the pool
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -1368,7 +1370,7 @@ void VirtualMachineManager::driver_cancel_action(
|
||||
const VirtualMachineManagerDriver * vmd;
|
||||
|
||||
// Get the VM from the pool
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -1548,7 +1550,7 @@ void VirtualMachineManager::attach_action(
|
||||
TransferManager * tm = nd.get_tm();
|
||||
|
||||
// Get the VM from the pool
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -1689,7 +1691,7 @@ void VirtualMachineManager::detach_action(
|
||||
TransferManager * tm = nd.get_tm();
|
||||
|
||||
// Get the VM from the pool
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -1793,7 +1795,7 @@ void VirtualMachineManager::snapshot_create_action(int vid)
|
||||
string* drv_msg;
|
||||
|
||||
// Get the VM from the pool
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -1871,7 +1873,7 @@ void VirtualMachineManager::snapshot_revert_action(int vid)
|
||||
string* drv_msg;
|
||||
|
||||
// Get the VM from the pool
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -1949,7 +1951,7 @@ void VirtualMachineManager::snapshot_delete_action(int vid)
|
||||
string* drv_msg;
|
||||
|
||||
// Get the VM from the pool
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -2148,7 +2150,7 @@ void VirtualMachineManager::disk_resize_action(int vid)
|
||||
Nebula& nd = Nebula::instance();
|
||||
TransferManager * tm = nd.get_tm();
|
||||
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
@ -2361,7 +2363,7 @@ void VirtualMachineManager::detach_nic_action(
|
||||
string error_str;
|
||||
|
||||
// Get the VM from the pool
|
||||
vm = vmpool->get(vid);
|
||||
vm = vmpool->get_ro(vid);
|
||||
|
||||
if (vm == 0)
|
||||
{
|
||||
|
@ -181,7 +181,7 @@ error_name:
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
VirtualNetwork * VirtualNetworkPool::get_nic_by_name(VirtualMachineNic * nic,
|
||||
const string& name, int _uid, string& error)
|
||||
const string& name, int _uid, bool ro, string& error)
|
||||
{
|
||||
int uid = nic->get_uid(_uid, error);
|
||||
|
||||
@ -190,7 +190,15 @@ VirtualNetwork * VirtualNetworkPool::get_nic_by_name(VirtualMachineNic * nic,
|
||||
return 0;
|
||||
}
|
||||
|
||||
VirtualNetwork * vnet = get(name, uid);
|
||||
VirtualNetwork * vnet;
|
||||
|
||||
if (ro)
|
||||
{
|
||||
vnet = get_ro(name, uid);
|
||||
}
|
||||
else{
|
||||
vnet = get(name, uid);
|
||||
}
|
||||
|
||||
if (vnet == 0)
|
||||
{
|
||||
@ -206,7 +214,7 @@ VirtualNetwork * VirtualNetworkPool::get_nic_by_name(VirtualMachineNic * nic,
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
VirtualNetwork * VirtualNetworkPool::get_nic_by_id(const string& id_s,
|
||||
VirtualNetwork * VirtualNetworkPool::get_nic_by_id(const string& id_s, bool ro,
|
||||
string& error)
|
||||
{
|
||||
istringstream is;
|
||||
@ -219,7 +227,15 @@ VirtualNetwork * VirtualNetworkPool::get_nic_by_id(const string& id_s,
|
||||
|
||||
if( !is.fail() )
|
||||
{
|
||||
vnet = get(id);
|
||||
if (ro)
|
||||
{
|
||||
vnet = get_ro(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
vnet = get(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (vnet == 0)
|
||||
@ -252,11 +268,11 @@ int VirtualNetworkPool::nic_attribute(
|
||||
|
||||
if (!(network = nic->vector_value("NETWORK_ID")).empty())
|
||||
{
|
||||
vnet = get_nic_by_id(network, error);
|
||||
vnet = get_nic_by_id(network, false, error);
|
||||
}
|
||||
else if (!(network = nic->vector_value("NETWORK")).empty())
|
||||
{
|
||||
vnet = get_nic_by_name (nic, network, uid, error);
|
||||
vnet = get_nic_by_name (nic, network, uid, false, error);
|
||||
}
|
||||
else //Not using a pre-defined network
|
||||
{
|
||||
@ -314,11 +330,11 @@ void VirtualNetworkPool::authorize_nic(
|
||||
|
||||
if (!(network = nic->vector_value("NETWORK_ID")).empty())
|
||||
{
|
||||
vnet = get_nic_by_id(network, error);
|
||||
vnet = get_nic_by_id(network, true, error);
|
||||
}
|
||||
else if (!(network = nic->vector_value("NETWORK")).empty())
|
||||
{
|
||||
vnet = get_nic_by_name(nic, network, uid, error);
|
||||
vnet = get_nic_by_name(nic, network, uid, true, error);
|
||||
|
||||
if ( vnet != 0 )
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user