1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-30 22:50:10 +03:00

feature : Formatting, indenting and commenting hosts clases

This commit is contained in:
Constantino Vázquez Blanco 2010-04-27 17:42:37 +02:00
parent 26c3d5b331
commit 5cf9d453e1
6 changed files with 187 additions and 177 deletions

@ -1,18 +1,18 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------*/
#ifndef HOST_H_
#define HOST_H_
@ -30,9 +30,9 @@ class Host : public PoolObjectSQL
{
public:
// ------------------------------------------------------------------------
// ----------------------------------------------------------------------
// Host States
// ------------------------------------------------------------------------
// ----------------------------------------------------------------------
enum HostState
{
@ -135,7 +135,8 @@ public:
int update_info(string &parse_str);
/**
*
* Retrives host state
* @return HostState code number
*/
HostState get_state() const
{
@ -143,7 +144,8 @@ public:
};
/**
*
* Retrives VMM mad name
* @return string vmm mad name
*/
const string& get_vmm_mad() const
{
@ -151,7 +153,8 @@ public:
};
/**
*
* Retrives TM mad name
* @return string tm mad name
*/
const string& get_tm_mad() const
{
@ -159,7 +162,8 @@ public:
};
/**
*
* Retrives IM mad name
* @return string im mad name
*/
const string& get_im_mad() const
{
@ -167,7 +171,8 @@ public:
};
/**
*
* Sets host state
* @param HostState state that applies to this host
*/
void set_state(HostState state)
{
@ -175,7 +180,8 @@ public:
};
/**
*
* Retrives last time the host was monitored
* @return time_t last monitored time
*/
time_t get_last_monitored() const
{

@ -1,18 +1,18 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* ------------------------------------------------------------------------ */
#ifndef HOST_SHARE_H_
#define HOST_SHARE_H_
@ -23,8 +23,8 @@
using namespace std;
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
/**
* The HostShare class. It represents a logical partition of a host...

@ -1,18 +1,18 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* ------------------------------------------------------------------------ */
#ifndef TEMPLATE_SQL_H_
#define TEMPLATE_SQL_H_
@ -88,8 +88,8 @@ protected:
/**
* Removes a template attribute from the DB. If there are multiple
* attributes with the same name, only one will be replaced. The attribute
* MUST be allocated in the heap.
* attributes with the same name, only one will be replaced. The
* attribute MUST be allocated in the heap.
* @param db pointer to the database.
* @param attribute pointer to the new attribute.
*/
@ -114,7 +114,7 @@ protected:
int select_cb(void *nil, int num, char **values, char **names);
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
#endif /*TEMPLATE_SQL_H_*/

@ -1,18 +1,18 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* ------------------------------------------------------------------------ */
#include <limits.h>
#include <string.h>
@ -23,9 +23,9 @@
#include "Host.h"
#include "NebulaLog.h"
/* ************************************************************************** */
/* Host :: Constructor/Destructor */
/* ************************************************************************** */
/* ************************************************************************ */
/* Host :: Constructor/Destructor */
/* ************************************************************************ */
Host::Host(
int id,
@ -46,9 +46,9 @@ Host::Host(
Host::~Host(){};
/* ************************************************************************** */
/* Host :: Database Access Functions */
/* ************************************************************************** */
/* ************************************************************************ */
/* Host :: Database Access Functions */
/* ************************************************************************ */
const char * Host::table = "host_pool";
@ -60,8 +60,8 @@ const char * Host::db_bootstrap = "CREATE TABLE host_pool ("
"im_mad TEXT,vm_mad TEXT,tm_mad TEXT,last_mon_time INTEGER, "
"UNIQUE(host_name, im_mad, vm_mad, tm_mad) )";
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
int Host::select_cb(void * nil, int num, char **values, char ** names)
{
@ -93,7 +93,7 @@ int Host::select_cb(void * nil, int num, char **values, char ** names)
return 0;
}
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
int Host::select(SqlDB *db)
{
@ -136,8 +136,9 @@ int Host::select(SqlDB *db)
return 0;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
int Host::insert(SqlDB *db)
{
@ -159,7 +160,7 @@ int Host::insert(SqlDB *db)
}
//Insert the Host and its template
rc = update(db);
rc = insert_replace(db, false);
if ( rc != 0 )
{
@ -261,8 +262,8 @@ error_hostname:
return -1;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
int Host::dump(ostringstream& oss, int num, char **values, char **names)
{
@ -295,8 +296,8 @@ int Host::dump(ostringstream& oss, int num, char **values, char **names)
return 0;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
int Host::drop(SqlDB * db)
{
@ -319,8 +320,8 @@ int Host::drop(SqlDB * db)
return rc;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
int Host::update_info(string &parse_str)
{
@ -349,9 +350,9 @@ int Host::update_info(string &parse_str)
return 0;
}
/* ************************************************************************** */
/* Host :: Misc */
/* ************************************************************************** */
/* ************************************************************************ */
/* Host :: Misc */
/* ************************************************************************ */
ostream& operator<<(ostream& os, Host& host)
{
@ -363,8 +364,8 @@ ostream& operator<<(ostream& os, Host& host)
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
string& Host::to_xml(string& xml) const
{
@ -390,8 +391,8 @@ string& Host::to_xml(string& xml) const
return xml;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
string& Host::to_str(string& str) const
{
@ -417,9 +418,9 @@ string& Host::to_str(string& str) const
}
/* ************************************************************************** */
/* Host :: Parse functions to compute rank and evaluate requirements */
/* ************************************************************************** */
/* ************************************************************************ */
/* Host :: Parse functions to compute rank and evaluate requirements */
/* ************************************************************************ */
pthread_mutex_t Host::lex_mutex = PTHREAD_MUTEX_INITIALIZER;
@ -438,8 +439,8 @@ extern "C"
void host__delete_buffer(YY_BUFFER_STATE);
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
int Host::match(const string& requirements, bool& result, char **errmsg)
{
@ -479,8 +480,8 @@ error_yy:
return -1;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
int Host::rank(const string& rank, int& result, char **errmsg)
{
@ -520,5 +521,5 @@ error_yy:
return -1;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */

@ -1,18 +1,19 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------*/
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.*/
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* ------------------------------------------------------------------------*/
#include <limits.h>
#include <string.h>
@ -22,9 +23,9 @@
#include "HostShare.h"
/* ************************************************************************** */
/* HostShare :: Constructor/Destructor */
/* ************************************************************************** */
/* ************************************************************************ */
/* HostShare :: Constructor/Destructor */
/* ************************************************************************ */
HostShare::HostShare(
int _hsid,
@ -49,9 +50,9 @@ HostShare::HostShare(
{
}
/* ************************************************************************** */
/* HostShare :: Database Access Functions */
/* ************************************************************************** */
/* ************************************************************************ */
/* HostShare :: Database Access Functions */
/* ************************************************************************ */
const char * HostShare::table = "host_shares";
@ -70,8 +71,8 @@ const char * HostShare::db_bootstrap = "CREATE TABLE host_shares ("
"used_disk INTEGER, used_mem INTEGER, used_cpu INTEGER,"
"running_vms INTEGER)";
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
int HostShare::select_cb(void * nil, int num, char **values, char **names)
{
@ -117,8 +118,8 @@ int HostShare::select_cb(void * nil, int num, char **values, char **names)
return 0;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
int HostShare::dump(ostringstream& oss,
int num,
@ -165,8 +166,8 @@ int HostShare::dump(ostringstream& oss,
return 0;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
int HostShare::select(SqlDB * db)
{
@ -229,8 +230,8 @@ int HostShare::update(SqlDB * db)
return rc;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
int HostShare::drop(SqlDB * db)
{
@ -241,9 +242,9 @@ int HostShare::drop(SqlDB * db)
return db->exec(oss);
}
/* ************************************************************************** */
/* HostShare :: Misc */
/* ************************************************************************** */
/* ************************************************************************ */
/* HostShare :: Misc */
/* ************************************************************************ */
ostream& operator<<(ostream& os, HostShare& hs)
{
@ -254,8 +255,8 @@ ostream& operator<<(ostream& os, HostShare& hs)
return os;
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
string& HostShare::to_xml(string& xml) const
{
@ -284,8 +285,8 @@ string& HostShare::to_xml(string& xml) const
return xml;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
string& HostShare::to_str(string& str) const
{
@ -312,5 +313,5 @@ string& HostShare::to_str(string& str) const
return str;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */

@ -1,31 +1,31 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------*/
#include "TemplateSQL.h"
#include <iostream>
#include <sstream>
/* ************************************************************************** */
/* SQL Template */
/* ************************************************************************** */
/* ************************************************************************ */
/* SQL Template */
/* ************************************************************************ */
const char * TemplateSQL::db_names = "(id,name,type,value)";
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
int TemplateSQL::insert_cb(void *nil, int num, char **values, char **names)
{
@ -46,7 +46,7 @@ int TemplateSQL::insert_cb(void *nil, int num, char **values, char **names)
return 0;
}
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
int TemplateSQL::insert(SqlDB * db)
{
@ -54,7 +54,8 @@ int TemplateSQL::insert(SqlDB * db)
int rc;
// Get next id from the DB table
set_callback(static_cast<Callbackable::Callback>(&TemplateSQL::insert_cb));
set_callback(
static_cast<Callbackable::Callback>(&TemplateSQL::insert_cb));
oss << "SELECT MAX(id) FROM " << table;
@ -189,7 +190,8 @@ int TemplateSQL::select_cb(void *nil, int num, char **values, char **names)
return 0;
}
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
int TemplateSQL::select(SqlDB * db)
{
@ -210,8 +212,8 @@ int TemplateSQL::select(SqlDB * db)
return rc;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
int TemplateSQL::drop(SqlDB * db)
{
@ -227,8 +229,8 @@ int TemplateSQL::drop(SqlDB * db)
return db->exec(oss);
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
int TemplateSQL::replace_attribute(SqlDB * db, Attribute * attribute)
{
@ -285,8 +287,8 @@ int TemplateSQL::replace_attribute(SqlDB * db, Attribute * attribute)
return insert_attribute(db,attribute);
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
int TemplateSQL::insert_attribute(SqlDB * db, Attribute * attribute)
{
@ -335,5 +337,5 @@ int TemplateSQL::insert_attribute(SqlDB * db, Attribute * attribute)
return rc;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */