mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-29 18:50:08 +03:00
Merge branch 'feature-1004' into feature-992
Conflicts: src/cloud/occi/etc/occi-server.conf src/cloud/occi/lib/OCCIServer.rb
This commit is contained in:
commit
ef13f05ca7
6
NOTICE
6
NOTICE
@ -1,6 +1,8 @@
|
||||
OpenNebula Open Source Project
|
||||
--------------------------------------------------------------------------------
|
||||
Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org)
|
||||
-----------------------------------------
|
||||
Copyright 2010-2011, C12G Labs S.L. (C12G.com)
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
You can find more information about the project, release notes and
|
||||
documentation at www.OpenNebula.org
|
||||
@ -20,6 +22,8 @@ The following people have contributed to the development of the technology
|
||||
- Daniel Molina Aranda (dmolina@opennebula.org)
|
||||
- Hector Sanjuan Redondo (hsanjuan@opennebula.org)
|
||||
|
||||
OpenNebula Project also acknowledges the contributions of C12G Labs developers.
|
||||
|
||||
LICENSE
|
||||
|
||||
OpenNebula is licensed under the Apache License, Version 2.0 (the
|
||||
|
@ -189,6 +189,7 @@ build_scripts=[
|
||||
'src/host/SConstruct',
|
||||
'src/group/SConstruct',
|
||||
'src/mad/SConstruct',
|
||||
'src/mad/utils/SConstruct',
|
||||
'src/nebula/SConstruct',
|
||||
'src/pool/SConstruct',
|
||||
'src/vm/SConstruct',
|
||||
|
@ -44,8 +44,7 @@ public:
|
||||
FixedLeases(SqlDB * db,
|
||||
int _oid,
|
||||
unsigned int _mac_prefix):
|
||||
Leases(db,_oid,0),
|
||||
mac_prefix(_mac_prefix),
|
||||
Leases(db,_oid,0,_mac_prefix),
|
||||
current(leases.begin()){};
|
||||
|
||||
~FixedLeases(){};
|
||||
@ -112,11 +111,6 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* The default MAC prefix for the Leases
|
||||
*/
|
||||
unsigned int mac_prefix;
|
||||
|
||||
/**
|
||||
* Current lease pointer
|
||||
*/
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
const string& hostname,
|
||||
const string& vm_dir,
|
||||
const string& vmm,
|
||||
const string& vnm,
|
||||
const string& tm);
|
||||
|
||||
~History(){};
|
||||
@ -91,6 +92,7 @@ private:
|
||||
int hid;
|
||||
|
||||
string vmm_mad_name;
|
||||
string vnm_mad_name;
|
||||
string tm_mad_name;
|
||||
|
||||
time_t stime;
|
||||
|
@ -130,6 +130,15 @@ public:
|
||||
return vmm_mad_name;
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrives VNM mad name
|
||||
* @return string vnm mad name
|
||||
*/
|
||||
const string& get_vnm_mad() const
|
||||
{
|
||||
return vnm_mad_name;
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrives TM mad name
|
||||
* @return string tm mad name
|
||||
@ -311,6 +320,11 @@ private:
|
||||
*/
|
||||
string vmm_mad_name;
|
||||
|
||||
/**
|
||||
* Name of the VN driver used to manage networking in this host
|
||||
*/
|
||||
string vnm_mad_name;
|
||||
|
||||
/**
|
||||
* Name of the TM driver used to transfer file to and from this host
|
||||
*/
|
||||
@ -338,6 +352,7 @@ private:
|
||||
const string& hostname="",
|
||||
const string& im_mad_name="",
|
||||
const string& vmm_mad_name="",
|
||||
const string& vnm_mad_name="",
|
||||
const string& tm_mad_name="");
|
||||
|
||||
virtual ~Host();
|
||||
|
@ -51,6 +51,7 @@ public:
|
||||
const string& hostname,
|
||||
const string& im_mad_name,
|
||||
const string& vmm_mad_name,
|
||||
const string& vnm_mad_name,
|
||||
const string& tm_mad_name,
|
||||
string& error_str);
|
||||
|
||||
|
@ -40,9 +40,9 @@ public:
|
||||
* @param _oid the virtual network unique identifier
|
||||
* @param _size the max number of leases
|
||||
*/
|
||||
Leases(SqlDB * _db, int _oid, unsigned long _size):
|
||||
Leases(SqlDB * _db, int _oid, unsigned long _size, unsigned int _mac_prefix):
|
||||
ObjectSQL(),
|
||||
oid(_oid), size(_size), n_used(0), db(_db){};
|
||||
oid(_oid), size(_size), n_used(0), mac_prefix(_mac_prefix), db(_db){};
|
||||
|
||||
virtual ~Leases()
|
||||
{
|
||||
@ -102,6 +102,26 @@ public:
|
||||
virtual int remove_leases(vector<const Attribute*>& vector_leases,
|
||||
string& error_msg) = 0;
|
||||
|
||||
/**
|
||||
* Holds a Lease, marking it as used
|
||||
* @param vector_leases vector of VectorAttribute objects. For the
|
||||
* moment, the vector can only contain one LEASE.
|
||||
* @param error_msg If the action fails, this message contains
|
||||
* the reason.
|
||||
* @return 0 on success
|
||||
*/
|
||||
int hold_leases(vector<const Attribute*>& vector_leases, string& error_msg);
|
||||
|
||||
/**
|
||||
* Releases a Lease on hold
|
||||
* @param vector_leases vector of VectorAttribute objects. For the
|
||||
* moment, the vector can only contain one LEASE.
|
||||
* @param error_msg If the action fails, this message contains
|
||||
* the reason.
|
||||
* @return 0 on success
|
||||
*/
|
||||
int free_leases(vector<const Attribute*>& vector_leases, string& error_msg);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@ -230,13 +250,13 @@ protected:
|
||||
// Leases fields
|
||||
// -------------------------------------------------------------------------
|
||||
/**
|
||||
* Leases indentifier. Connects it to a Virtual Network
|
||||
*/
|
||||
* Leases identifier. Connects it to a Virtual Network
|
||||
*/
|
||||
int oid;
|
||||
|
||||
/**
|
||||
* Number of possible leases (free + asigned)
|
||||
*/
|
||||
* Number of possible leases (free + assigned)
|
||||
*/
|
||||
unsigned int size;
|
||||
|
||||
/**
|
||||
@ -249,6 +269,11 @@ protected:
|
||||
*/
|
||||
int n_used;
|
||||
|
||||
/**
|
||||
* The default MAC prefix for the Leases
|
||||
*/
|
||||
unsigned int mac_prefix;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// DataBase implementation variables
|
||||
// -------------------------------------------------------------------------
|
||||
@ -286,11 +311,11 @@ protected:
|
||||
friend ostream& operator<<(ostream& os, Lease& _lease);
|
||||
|
||||
/**
|
||||
* Function to print the Leases object into a string in
|
||||
* XML format
|
||||
* @param xml the resulting XML string
|
||||
* @return a reference to the generated string
|
||||
*/
|
||||
* Function to print the Leases object into a string in
|
||||
* XML format
|
||||
* @param xml the resulting XML string
|
||||
* @return a reference to the generated string
|
||||
*/
|
||||
string& to_xml(string& xml) const;
|
||||
|
||||
private:
|
||||
|
@ -228,12 +228,12 @@ public:
|
||||
|
||||
static string version()
|
||||
{
|
||||
return "OpenNebula 3.1.0";
|
||||
return "OpenNebula 3.1.80";
|
||||
};
|
||||
|
||||
static string db_version()
|
||||
{
|
||||
return "3.1.0";
|
||||
return "3.1.80";
|
||||
}
|
||||
|
||||
void start();
|
||||
|
@ -259,9 +259,9 @@ public:
|
||||
* Generates a XML string for the template of the Object
|
||||
* @param xml the string to store the XML description.
|
||||
*/
|
||||
void template_to_xml(string &xml) const
|
||||
string& template_to_xml(string &xml) const
|
||||
{
|
||||
obj_template->to_xml(xml);
|
||||
return obj_template->to_xml(xml);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -18,6 +18,7 @@
|
||||
#define RANGED_LEASES_H_
|
||||
|
||||
#include "Leases.h"
|
||||
#include "VirtualNetwork.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -30,12 +31,23 @@ public:
|
||||
// *************************************************************************
|
||||
RangedLeases(SqlDB * db,
|
||||
int _oid,
|
||||
unsigned long _size,
|
||||
unsigned int _mac_prefix,
|
||||
const string& _network_address);
|
||||
unsigned int _ip_start,
|
||||
unsigned int _ip_end);
|
||||
|
||||
~RangedLeases(){};
|
||||
|
||||
/**
|
||||
* Reads (and clears) the necessary attributes to define a Ranged VNet
|
||||
* @param vn Virtual Network
|
||||
* @param ip_start First IP of the range
|
||||
* @param ip_end Last IP of the range
|
||||
* @param error_str Error reason, if any
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
static int process_template(VirtualNetwork * vn,
|
||||
unsigned int& ip_start, unsigned int& ip_end, string& error_str);
|
||||
|
||||
/**
|
||||
* Returns an unused lease, which becomes used
|
||||
* @param vid identifier of the VM getting this lease
|
||||
@ -105,15 +117,9 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* The default MAC prefix for the Leases
|
||||
*/
|
||||
unsigned int mac_prefix;
|
||||
|
||||
/**
|
||||
* The Network address to generate leases
|
||||
*/
|
||||
unsigned int network_address;
|
||||
unsigned int ip_start;
|
||||
unsigned int ip_end;
|
||||
|
||||
unsigned int current;
|
||||
|
||||
|
@ -51,13 +51,14 @@ protected:
|
||||
bool vm_authorization(int id, int hid, ImageTemplate *tmpl,
|
||||
RequestAttributes& att);
|
||||
|
||||
int get_host_information(int hid, string& name, string& vmm, string& tm,
|
||||
RequestAttributes& att);
|
||||
int get_host_information(int hid, string& name, string& vmm, string& vnm,
|
||||
string& tm, RequestAttributes& att);
|
||||
|
||||
int add_history(VirtualMachine * vm,
|
||||
int hid,
|
||||
const string& hostname,
|
||||
const string& vmm_mad,
|
||||
const string& vnm_mad,
|
||||
const string& tm_mad,
|
||||
RequestAttributes& att);
|
||||
|
||||
@ -107,12 +108,9 @@ class VirtualMachineMigrate : public RequestManagerVirtualMachine
|
||||
{
|
||||
public:
|
||||
VirtualMachineMigrate():
|
||||
RequestManagerVirtualMachine("VirtualMachineDeploy",
|
||||
RequestManagerVirtualMachine("VirtualMachineMigrate",
|
||||
"Migrates a virtual machine",
|
||||
"A:siib")
|
||||
{
|
||||
auth_op = AuthRequest::DEPLOY;
|
||||
};
|
||||
"A:siib"){};
|
||||
|
||||
~VirtualMachineMigrate(){};
|
||||
|
||||
|
@ -93,6 +93,44 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
class VirtualNetworkHold : public RequestManagerVirtualNetwork
|
||||
{
|
||||
public:
|
||||
VirtualNetworkHold():
|
||||
RequestManagerVirtualNetwork("VirtualNetworkHold",
|
||||
"Holds a virtual network Lease as used"){};
|
||||
~VirtualNetworkHold(){};
|
||||
|
||||
int leases_action(VirtualNetwork * vn,
|
||||
VirtualNetworkTemplate * tmpl,
|
||||
string& error_str)
|
||||
{
|
||||
return vn->hold_leases(tmpl, error_str);
|
||||
}
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
class VirtualNetworkRelease : public RequestManagerVirtualNetwork
|
||||
{
|
||||
public:
|
||||
VirtualNetworkRelease():
|
||||
RequestManagerVirtualNetwork("VirtualNetworkRelease",
|
||||
"Releases a virtual network Lease on hold"){};
|
||||
~VirtualNetworkRelease(){};
|
||||
|
||||
int leases_action(VirtualNetwork * vn,
|
||||
VirtualNetworkTemplate * tmpl,
|
||||
string& error_str)
|
||||
{
|
||||
return vn->free_leases(tmpl, error_str);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -217,6 +217,7 @@ public:
|
||||
const string& hostname,
|
||||
const string& vm_dir,
|
||||
const string& vmm_mad,
|
||||
const string& vnm_mad,
|
||||
const string& tm_mad);
|
||||
|
||||
/**
|
||||
@ -273,6 +274,26 @@ public:
|
||||
return previous_history->vmm_mad_name;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the VNM driver name for the current host. The hasHistory()
|
||||
* function MUST be called before this one.
|
||||
* @return the VNM mad name
|
||||
*/
|
||||
const string & get_vnm_mad() const
|
||||
{
|
||||
return history->vnm_mad_name;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the VNM driver name for the previous host. The hasPreviousHistory()
|
||||
* function MUST be called before this one.
|
||||
* @return the VNM mad name
|
||||
*/
|
||||
const string & get_previous_vnm_mad() const
|
||||
{
|
||||
return previous_history->vnm_mad_name;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the TM driver name for the current host. The hasHistory()
|
||||
* function MUST be called before this one.
|
||||
|
@ -175,6 +175,41 @@ private:
|
||||
const string & action,
|
||||
void * arg);
|
||||
|
||||
/**
|
||||
* Function to format a VMM Driver message in the form:
|
||||
* <VMM_DRIVER_ACTION_DATA>
|
||||
* <HOST> hostname </HOST>
|
||||
* <NET_DRV> net_drv </NET_DRV>
|
||||
* <MIGR_HOST> m_hostname </MIGR_HOST>
|
||||
* <MIGR_NET_DRV> m_net_drv </MIGR_NET_DRV>
|
||||
* <DOMAIN> domain_id </DOMAIN>
|
||||
* <DEPLOYMENT_FILE> dfile </DEPLOYMENT_FILE>
|
||||
* <CHECKPOINT_FILE> cfile </CHECKPOINT_FILE>
|
||||
* <VM>
|
||||
* VM representation in XML
|
||||
* </VM>
|
||||
* </VMM_DRIVER_ACTION_DATA>
|
||||
*
|
||||
* @param hostname of the host to perform the action
|
||||
* @param net_drv name of the vlan driver
|
||||
* @param m_hostname name of the host to migrate the VM
|
||||
* @param m_net_drv name of the vlan driver
|
||||
* @param domain domain id as returned by the hypervisor
|
||||
* @param dfile deployment file to boot the VM
|
||||
* @param cfile checkpoint file to save the VM
|
||||
* @param tmpl the VM information in XML
|
||||
*/
|
||||
string * format_message(
|
||||
const string& hostname,
|
||||
const string& net_drv,
|
||||
const string& m_hostname,
|
||||
const string& m_net_drv,
|
||||
const string& domain,
|
||||
const string& ldfile,
|
||||
const string& rdfile,
|
||||
const string& cfile,
|
||||
const string& tmpl);
|
||||
|
||||
/**
|
||||
* Function executed when a DEPLOY action is received. It deploys a VM on
|
||||
* a Host.
|
||||
|
@ -110,108 +110,76 @@ private:
|
||||
friend class VirtualMachineManager;
|
||||
|
||||
/**
|
||||
* Sends a deploy request to the MAD: "DEPLOY ID HOST CONF -"
|
||||
* Sends a deploy request to the MAD: "DEPLOY ID XML_DRV_MSG"
|
||||
* @param oid the virtual machine id.
|
||||
* @param host the hostname
|
||||
* @param conf the filename of the deployment file
|
||||
* @param drv_msg xml data for the mad operation
|
||||
*/
|
||||
void deploy (
|
||||
const int oid,
|
||||
const string& host,
|
||||
const string& conf) const;
|
||||
const string& drv_msg) const;
|
||||
|
||||
/**
|
||||
* Sends a shutdown request to the MAD: "SHUTDOWN ID HOST NAME -"
|
||||
* Sends a shutdown request to the MAD: "SHUTDOWN ID XML_DRV_MSG"
|
||||
* @param oid the virtual machine id.
|
||||
* @param host the hostname
|
||||
* @param name of the Virtual Machine (deployment id), as returned by the
|
||||
* driver
|
||||
* @param drv_msg xml data for the mad operation
|
||||
*/
|
||||
void shutdown (
|
||||
const int oid,
|
||||
const string& host,
|
||||
const string& name) const;
|
||||
const string& drv_msg) const;
|
||||
|
||||
/**
|
||||
* Sends a cancel request to the MAD: "CANCEL ID HOST NAME -"
|
||||
* Sends a cancel request to the MAD: "CANCEL ID XML_DRV_MSG"
|
||||
* @param oid the virtual machine id.
|
||||
* @param host the hostname
|
||||
* @param name of the Virtual Machine (deployment id), as returned by the
|
||||
* driver
|
||||
* @param drv_msg xml data for the mad operation
|
||||
*/
|
||||
void cancel (
|
||||
const int oid,
|
||||
const string& host,
|
||||
const string& name) const;
|
||||
const string& drv_msg) const;
|
||||
|
||||
/**
|
||||
* Sends a checkpoint request to the MAD: "CHECKPOINT ID HOST NAME FILE"
|
||||
* Sends a checkpoint request to the MAD: "CHECKPOINT ID XML_DRV_MSG"
|
||||
* @param oid the virtual machine id.
|
||||
* @param host the hostname
|
||||
* @param name of the Virtual Machine (deployment id), as returned by the
|
||||
* driver
|
||||
* @param file the filename to generate the checkpoint file
|
||||
* @param drv_msg xml data for the mad operation
|
||||
*/
|
||||
void checkpoint (
|
||||
const int oid,
|
||||
const string& host,
|
||||
const string& name,
|
||||
const string& file) const;
|
||||
const string& drv_msg) const;
|
||||
|
||||
/**
|
||||
* Sends a save request to the MAD: "SAVE ID HOST NAME FILE"
|
||||
* Sends a save request to the MAD: "SAVE ID XML_DRV_MSG"
|
||||
* @param oid the virtual machine id.
|
||||
* @param host the hostname
|
||||
* @param name of the Virtual Machine (deployment id), as returned by the
|
||||
* driver
|
||||
* @param file the filename to generate the checkpoint file
|
||||
* @param drv_msg xml data for the mad operation
|
||||
*/
|
||||
void save (
|
||||
const int oid,
|
||||
const string& host,
|
||||
const string& name,
|
||||
const string& file) const;
|
||||
const string& drv_msg) const;
|
||||
|
||||
/**
|
||||
* Sends a save request to the MAD: "RESTORE ID HOST FILE -"
|
||||
* Sends a save request to the MAD: "RESTORE ID XML_DRV_MSG"
|
||||
* @param oid the virtual machine id.
|
||||
* @param host the hostname
|
||||
* @param name of the Virtual Machine (deployment id), as returned by the
|
||||
* driver
|
||||
* @param file the filename of the checkpoint file to restore the VM
|
||||
* from
|
||||
* @param drv_msg xml data for the mad operation
|
||||
*/
|
||||
void restore (
|
||||
const int oid,
|
||||
const string& host,
|
||||
const string& name,
|
||||
const string& file) const;
|
||||
const string& drv_msg) const;
|
||||
|
||||
/**
|
||||
* Sends a migrate request to the MAD: "MIGRATE ID HOST NAME DEST"
|
||||
* Sends a migrate request to the MAD: "MIGRATE ID XML_DRV_MSG"
|
||||
* @param oid the virtual machine id.
|
||||
* @param shost the original host (source)
|
||||
* @param name of the Virtual Machine (deployment id), as returned by the
|
||||
* driver
|
||||
* @param dhost the destination host
|
||||
* @param drv_msg xml data for the mad operation
|
||||
*/
|
||||
void migrate (
|
||||
const int oid,
|
||||
const string& shost,
|
||||
const string& name,
|
||||
const string& dhost) const;
|
||||
const string& drv_msg) const;
|
||||
|
||||
/**
|
||||
* Sends a poll request to the MAD: "POLL ID HOST NAME -"
|
||||
* Sends a poll request to the MAD: "POLL ID XML_DRV_MSG"
|
||||
* @param oid the virtual machine id.
|
||||
* @param host the hostname
|
||||
* @param name of the Virtual Machine (deployment id), as returned by the
|
||||
* driver
|
||||
* @param drv_msg xml data for the mad operation
|
||||
*/
|
||||
void poll (
|
||||
const int oid,
|
||||
const string& host,
|
||||
const string& name) const;
|
||||
const string& drv_msg) const;
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -85,7 +85,7 @@ public:
|
||||
|
||||
/**
|
||||
* Adds Leases to the virtual network (Only implemented for FIXED networks)
|
||||
* @param leases_template template in the form LEASES = [IP=XX, MAC=XX].
|
||||
* @param leases template in the form LEASES = [IP=XX, MAC=XX].
|
||||
* MAC is optional. The template can only contain one LEASE
|
||||
* definition.
|
||||
* @param error_msg If the action fails, this message contains the reason.
|
||||
@ -96,7 +96,7 @@ public:
|
||||
/**
|
||||
* Removes Leases from the virtual network; if they are not used.(Only
|
||||
* implemented for FIXED networks)
|
||||
* @param leases_template template in the form LEASES = [IP=XX].
|
||||
* @param leases template in the form LEASES = [IP=XX].
|
||||
* The template can only contain one LEASE definition.
|
||||
* @param error_msg If the action fails, this message contains
|
||||
* the reason.
|
||||
@ -104,6 +104,25 @@ public:
|
||||
*/
|
||||
int remove_leases(VirtualNetworkTemplate* leases, string& error_msg);
|
||||
|
||||
/**
|
||||
* Holds a Lease, marking it as used
|
||||
* @param leases template in the form LEASES = [IP=XX].
|
||||
* The template can only contain one LEASE definition.
|
||||
* @param error_msg If the action fails, this message contains the reason.
|
||||
* @return 0 on success
|
||||
*/
|
||||
int hold_leases(VirtualNetworkTemplate * leases, string& error_msg);
|
||||
|
||||
/**
|
||||
* Releases a Lease on hold
|
||||
* @param leases template in the form LEASES = [IP=XX].
|
||||
* The template can only contain one LEASE definition.
|
||||
* @param error_msg If the action fails, this message contains
|
||||
* the reason.
|
||||
* @return 0 on success
|
||||
*/
|
||||
int free_leases(VirtualNetworkTemplate* leases, string& error_msg);
|
||||
|
||||
/**
|
||||
* Gets a new lease for a specific VM
|
||||
* @param vid VM identifier
|
||||
@ -208,6 +227,11 @@ private:
|
||||
*/
|
||||
string vlan_id;
|
||||
|
||||
/**
|
||||
* Whether or not to isolate this network with the vnm driver
|
||||
*/
|
||||
int vlan;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Virtual Network Description
|
||||
// -------------------------------------------------------------------------
|
||||
@ -222,6 +246,9 @@ private:
|
||||
*/
|
||||
Leases * leases;
|
||||
|
||||
unsigned int ip_start;
|
||||
unsigned int ip_end;
|
||||
|
||||
// *************************************************************************
|
||||
// DataBase implementation (Private)
|
||||
// *************************************************************************
|
||||
|
242
install.sh
242
install.sh
@ -122,9 +122,9 @@ if [ -z "$ROOT" ] ; then
|
||||
elif [ "$OZONES" = "yes" ]; then
|
||||
MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $VAR_LOCATION $OZONES_LOCATION \
|
||||
$ETC_LOCATION"
|
||||
|
||||
|
||||
DELETE_DIRS="$MAKE_DIRS"
|
||||
|
||||
|
||||
CHOWN_DIRS=""
|
||||
else
|
||||
MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $ETC_LOCATION $VAR_LOCATION \
|
||||
@ -162,8 +162,8 @@ else
|
||||
elif [ "$OZONES" = "yes" ]; then
|
||||
MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $VAR_LOCATION $OZONES_LOCATION \
|
||||
$ETC_LOCATION"
|
||||
|
||||
DELETE_DIRS="$MAKE_DIRS"
|
||||
|
||||
DELETE_DIRS="$MAKE_DIRS"
|
||||
else
|
||||
MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $ETC_LOCATION $VAR_LOCATION \
|
||||
$INCLUDE_LOCATION $SHARE_LOCATION $IMAGES_LOCATION \
|
||||
@ -180,14 +180,13 @@ fi
|
||||
SHARE_DIRS="$SHARE_LOCATION/examples \
|
||||
$SHARE_LOCATION/examples/tm"
|
||||
|
||||
ETC_DIRS="$ETC_LOCATION/im_kvm \
|
||||
$ETC_LOCATION/im_xen \
|
||||
$ETC_LOCATION/im_ec2 \
|
||||
ETC_DIRS="$ETC_LOCATION/im_ec2 \
|
||||
$ETC_LOCATION/vmm_ec2 \
|
||||
$ETC_LOCATION/vmm_exec \
|
||||
$ETC_LOCATION/tm_shared \
|
||||
$ETC_LOCATION/tm_ssh \
|
||||
$ETC_LOCATION/tm_dummy \
|
||||
$ETC_LOCATION/tm_vmware \
|
||||
$ETC_LOCATION/tm_lvm \
|
||||
$ETC_LOCATION/hm \
|
||||
$ETC_LOCATION/auth \
|
||||
@ -210,6 +209,7 @@ LIB_DIRS="$LIB_LOCATION/ruby \
|
||||
$LIB_LOCATION/tm_commands/ssh \
|
||||
$LIB_LOCATION/tm_commands/dummy \
|
||||
$LIB_LOCATION/tm_commands/lvm \
|
||||
$LIB_LOCATION/tm_commands/vmware \
|
||||
$LIB_LOCATION/mads \
|
||||
$LIB_LOCATION/sh \
|
||||
$LIB_LOCATION/ruby/cli \
|
||||
@ -220,11 +220,18 @@ VAR_DIRS="$VAR_LOCATION/remotes \
|
||||
$VAR_LOCATION/remotes/im \
|
||||
$VAR_LOCATION/remotes/im/kvm.d \
|
||||
$VAR_LOCATION/remotes/im/xen.d \
|
||||
$VAR_LOCATION/remotes/im/vmware.d \
|
||||
$VAR_LOCATION/remotes/im/ganglia.d \
|
||||
$VAR_LOCATION/remotes/vmm/xen \
|
||||
$VAR_LOCATION/remotes/vmm/kvm \
|
||||
$VAR_LOCATION/remotes/vnm \
|
||||
$VAR_LOCATION/remotes/vnm/802.1Q \
|
||||
$VAR_LOCATION/remotes/vnm/dummy \
|
||||
$VAR_LOCATION/remotes/vnm/ebtables \
|
||||
$VAR_LOCATION/remotes/vnm/fw \
|
||||
$VAR_LOCATION/remotes/vnm/ovswitch \
|
||||
$VAR_LOCATION/remotes/vmm/xen \
|
||||
$VAR_LOCATION/remotes/vmm/vmware \
|
||||
$VAR_LOCATION/remotes/hooks \
|
||||
$VAR_LOCATION/remotes/hooks/vnm \
|
||||
$VAR_LOCATION/remotes/hooks/ft \
|
||||
$VAR_LOCATION/remotes/image \
|
||||
$VAR_LOCATION/remotes/image/fs \
|
||||
@ -232,6 +239,7 @@ VAR_DIRS="$VAR_LOCATION/remotes \
|
||||
$VAR_LOCATION/remotes/auth/plain \
|
||||
$VAR_LOCATION/remotes/auth/ssh \
|
||||
$VAR_LOCATION/remotes/auth/x509 \
|
||||
$VAR_LOCATION/remotes/auth/ldap \
|
||||
$VAR_LOCATION/remotes/auth/server_x509 \
|
||||
$VAR_LOCATION/remotes/auth/server_cipher \
|
||||
$VAR_LOCATION/remotes/auth/quota \
|
||||
@ -244,17 +252,21 @@ SUNSTONE_DIRS="$SUNSTONE_LOCATION/models \
|
||||
$SUNSTONE_LOCATION/public/js/plugins \
|
||||
$SUNSTONE_LOCATION/public/js/user-plugins \
|
||||
$SUNSTONE_LOCATION/public/css \
|
||||
$SUNSTONE_LOCATION/public/locale \
|
||||
$SUNSTONE_LOCATION/public/locale/en_US \
|
||||
$SUNSTONE_LOCATION/public/locale/ru \
|
||||
$SUNSTONE_LOCATION/public/vendor \
|
||||
$SUNSTONE_LOCATION/public/vendor/jQueryLayout \
|
||||
$SUNSTONE_LOCATION/public/vendor/dataTables \
|
||||
$SUNSTONE_LOCATION/public/vendor/jQueryUI \
|
||||
$SUNSTONE_LOCATION/public/vendor/jQueryUI/images \
|
||||
$SUNSTONE_LOCATION/public/vendor/jQuery \
|
||||
$SUNSTONE_LOCATION/public/vendor/jGrowl \
|
||||
$SUNSTONE_LOCATION/public/vendor/flot \
|
||||
$SUNSTONE_LOCATION/public/images \
|
||||
$SUNSTONE_LOCATION/templates \
|
||||
$SUNSTONE_LOCATION/views"
|
||||
|
||||
|
||||
OZONES_DIRS="$OZONES_LOCATION/lib \
|
||||
$OZONES_LOCATION/lib/OZones \
|
||||
$OZONES_LOCATION/models \
|
||||
@ -265,6 +277,7 @@ OZONES_DIRS="$OZONES_LOCATION/lib \
|
||||
$OZONES_LOCATION/public/vendor/jQueryLayout \
|
||||
$OZONES_LOCATION/public/vendor/dataTables \
|
||||
$OZONES_LOCATION/public/vendor/jQueryUI \
|
||||
$OZONES_LOCATION/public/vendor/jQueryUI/images \
|
||||
$OZONES_LOCATION/public/vendor/jGrowl \
|
||||
$OZONES_LOCATION/public/js \
|
||||
$OZONES_LOCATION/public/js/plugins \
|
||||
@ -327,28 +340,36 @@ INSTALL_FILES=(
|
||||
IM_PROBES_FILES:$VAR_LOCATION/remotes/im
|
||||
IM_PROBES_KVM_FILES:$VAR_LOCATION/remotes/im/kvm.d
|
||||
IM_PROBES_XEN_FILES:$VAR_LOCATION/remotes/im/xen.d
|
||||
IM_PROBES_VMWARE_FILES:$VAR_LOCATION/remotes/im/vmware.d
|
||||
IM_PROBES_GANGLIA_FILES:$VAR_LOCATION/remotes/im/ganglia.d
|
||||
AUTH_SSH_FILES:$VAR_LOCATION/remotes/auth/ssh
|
||||
AUTH_X509_FILES:$VAR_LOCATION/remotes/auth/x509
|
||||
AUTH_LDAP_FILES:$VAR_LOCATION/remotes/auth/ldap
|
||||
AUTH_SERVER_X509_FILES:$VAR_LOCATION/remotes/auth/server_x509
|
||||
AUTH_SERVER_CIPHER_FILES:$VAR_LOCATION/remotes/auth/server_cipher
|
||||
AUTH_DUMMY_FILES:$VAR_LOCATION/remotes/auth/dummy
|
||||
AUTH_PLAIN_FILES:$VAR_LOCATION/remotes/auth/plain
|
||||
AUTH_QUOTA_FILES:$VAR_LOCATION/remotes/auth/quota
|
||||
AUTH_PLAIN_FILES:$VAR_LOCATION/remotes/auth/plain
|
||||
AUTH_QUOTA_FILES:$VAR_LOCATION/remotes/auth/quota
|
||||
VMM_EXEC_KVM_SCRIPTS:$VAR_LOCATION/remotes/vmm/kvm
|
||||
VMM_EXEC_XEN_SCRIPTS:$VAR_LOCATION/remotes/vmm/xen
|
||||
VMM_EXEC_VMWARE_SCRIPTS:$VAR_LOCATION/remotes/vmm/vmware
|
||||
SHARED_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/shared
|
||||
SSH_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/ssh
|
||||
VMWARE_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/vmware
|
||||
DUMMY_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/dummy
|
||||
LVM_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/lvm
|
||||
IMAGE_DRIVER_FS_SCRIPTS:$VAR_LOCATION/remotes/image/fs
|
||||
NETWORK_HOOK_SCRIPTS:$VAR_LOCATION/remotes/vnm
|
||||
NETWORK_FILES:$VAR_LOCATION/remotes/vnm
|
||||
NETWORK_8021Q_FILES:$VAR_LOCATION/remotes/vnm/802.1Q
|
||||
NETWORK_DUMMY_FILES:$VAR_LOCATION/remotes/vnm/dummy
|
||||
NETWORK_EBTABLES_FILES:$VAR_LOCATION/remotes/vnm/ebtables
|
||||
NETWORK_FW_FILES:$VAR_LOCATION/remotes/vnm/fw
|
||||
NETWORK_OVSWITCH_FILES:$VAR_LOCATION/remotes/vnm/ovswitch
|
||||
EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples
|
||||
INSTALL_NOVNC_SHARE_FILE:$SHARE_LOCATION
|
||||
INSTALL_GEMS_SHARE_FILE:$SHARE_LOCATION
|
||||
TM_EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples/tm
|
||||
HOOK_FT_FILES:$VAR_LOCATION/remotes/hooks/ft
|
||||
HOOK_NETWORK_FILES:$VAR_LOCATION/remotes/hooks/vnm
|
||||
COMMON_CLOUD_LIB_FILES:$LIB_LOCATION/ruby/cloud
|
||||
CLOUD_AUTH_LIB_FILES:$LIB_LOCATION/ruby/cloud/CloudAuth
|
||||
ECO_LIB_FILES:$LIB_LOCATION/ruby/cloud/econe
|
||||
@ -403,9 +424,12 @@ INSTALL_SUNSTONE_FILES=(
|
||||
SUNSTONE_PUBLIC_VENDOR_JGROWL:$SUNSTONE_LOCATION/public/vendor/jGrowl
|
||||
SUNSTONE_PUBLIC_VENDOR_JQUERY:$SUNSTONE_LOCATION/public/vendor/jQuery
|
||||
SUNSTONE_PUBLIC_VENDOR_JQUERYUI:$SUNSTONE_LOCATION/public/vendor/jQueryUI
|
||||
SUNSTONE_PUBLIC_VENDOR_JQUERYUIIMAGES:$SUNSTONE_LOCATION/public/vendor/jQueryUI/images
|
||||
SUNSTONE_PUBLIC_VENDOR_JQUERYLAYOUT:$SUNSTONE_LOCATION/public/vendor/jQueryLayout
|
||||
SUNSTONE_PUBLIC_VENDOR_FLOT:$SUNSTONE_LOCATION/public/vendor/flot
|
||||
SUNSTONE_PUBLIC_IMAGES_FILES:$SUNSTONE_LOCATION/public/images
|
||||
SUNSTONE_PUBLIC_LOCALE_EN_US:$SUNSTONE_LOCATION/public/locale/en_US
|
||||
SUNSTONE_PUBLIC_LOCALE_RU:$SUNSTONE_LOCATION/public/locale/ru
|
||||
)
|
||||
|
||||
INSTALL_SUNSTONE_ETC_FILES=(
|
||||
@ -428,6 +452,7 @@ INSTALL_OZONES_FILES=(
|
||||
OZONES_PUBLIC_VENDOR_DATATABLES:$OZONES_LOCATION/public/vendor/dataTables
|
||||
OZONES_PUBLIC_VENDOR_JGROWL:$OZONES_LOCATION/public/vendor/jGrowl
|
||||
OZONES_PUBLIC_VENDOR_JQUERYUI:$OZONES_LOCATION/public/vendor/jQueryUI
|
||||
OZONES_PUBLIC_VENDOR_JQUERYUIIMAGES:$OZONES_LOCATION/public/vendor/jQueryUI/images
|
||||
OZONES_PUBLIC_VENDOR_JQUERYLAYOUT:$OZONES_LOCATION/public/vendor/jQueryLayout
|
||||
OZONES_PUBLIC_JS_FILES:$OZONES_LOCATION/public/js
|
||||
OZONES_PUBLIC_IMAGES_FILES:$OZONES_LOCATION/public/images
|
||||
@ -446,6 +471,7 @@ INSTALL_OZONES_ETC_FILES=(
|
||||
|
||||
INSTALL_ETC_FILES=(
|
||||
ETC_FILES:$ETC_LOCATION
|
||||
VMWARE_ETC_FILES:$ETC_LOCATION
|
||||
VMM_EC2_ETC_FILES:$ETC_LOCATION/vmm_ec2
|
||||
VMM_EXEC_ETC_FILES:$ETC_LOCATION/vmm_exec
|
||||
IM_EC2_ETC_FILES:$ETC_LOCATION/im_ec2
|
||||
@ -453,6 +479,7 @@ INSTALL_ETC_FILES=(
|
||||
TM_SSH_ETC_FILES:$ETC_LOCATION/tm_ssh
|
||||
TM_DUMMY_ETC_FILES:$ETC_LOCATION/tm_dummy
|
||||
TM_LVM_ETC_FILES:$ETC_LOCATION/tm_lvm
|
||||
TM_VMWARE_ETC_FILES:$ETC_LOCATION/tm_vmware
|
||||
HM_ETC_FILES:$ETC_LOCATION/hm
|
||||
AUTH_ETC_FILES:$ETC_LOCATION/auth
|
||||
ECO_ETC_FILES:$ETC_LOCATION
|
||||
@ -470,6 +497,7 @@ INSTALL_ETC_FILES=(
|
||||
BIN_FILES="src/nebula/oned \
|
||||
src/scheduler/src/sched/mm_sched \
|
||||
src/cli/onevm \
|
||||
src/cli/oneacct \
|
||||
src/cli/onehost \
|
||||
src/cli/onevnet \
|
||||
src/cli/oneuser \
|
||||
@ -479,6 +507,7 @@ BIN_FILES="src/nebula/oned \
|
||||
src/cli/oneacl \
|
||||
src/onedb/onedb \
|
||||
src/authm_mad/remotes/quota/onequota \
|
||||
src/mad/utils/tty_expect \
|
||||
share/scripts/one"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
@ -498,13 +527,18 @@ RUBY_LIB_FILES="src/mad/ruby/ActionManager.rb \
|
||||
src/mad/ruby/CommandManager.rb \
|
||||
src/mad/ruby/OpenNebulaDriver.rb \
|
||||
src/mad/ruby/VirtualMachineDriver.rb \
|
||||
src/mad/ruby/DriverExecHelper.rb \
|
||||
src/mad/ruby/ssh_stream.rb \
|
||||
src/vnm_mad/one_vnm.rb \
|
||||
src/mad/ruby/Ganglia.rb \
|
||||
src/mad/ruby/vmwarelib.rb \
|
||||
src/oca/ruby/OpenNebula.rb \
|
||||
src/tm_mad/TMScript.rb \
|
||||
src/authm_mad/remotes/ssh/ssh_auth.rb \
|
||||
src/authm_mad/remotes/quota/quota.rb \
|
||||
src/authm_mad/remotes/server_x509/server_x509_auth.rb \
|
||||
src/authm_mad/remotes/server_cipher/server_cipher_auth.rb \
|
||||
src/authm_mad/remotes/ldap/ldap_auth.rb \
|
||||
src/authm_mad/remotes/x509/x509_auth.rb"
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
@ -575,21 +609,36 @@ VMM_EXEC_XEN_SCRIPTS="src/vmm_mad/remotes/xen/cancel \
|
||||
src/vmm_mad/remotes/xen/poll_ganglia \
|
||||
src/vmm_mad/remotes/xen/shutdown"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# VMM Driver VMWARE scripts, to be installed under $REMOTES_LOCATION/vmm/vmware
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
VMM_EXEC_VMWARE_SCRIPTS="src/vmm_mad/remotes/vmware/cancel \
|
||||
src/vmm_mad/remotes/vmware/deploy \
|
||||
src/vmm_mad/remotes/vmware/migrate \
|
||||
src/vmm_mad/remotes/vmware/restore \
|
||||
src/vmm_mad/remotes/vmware/save \
|
||||
src/vmm_mad/remotes/vmware/poll \
|
||||
src/vmm_mad/remotes/vmware/checkpoint \
|
||||
src/vmm_mad/remotes/vmware/shutdown"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Information Manager Probes, to be installed under $REMOTES_LOCATION/im
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
IM_PROBES_FILES="src/im_mad/remotes/run_probes"
|
||||
|
||||
IM_PROBES_XEN_FILES="src/im_mad/remotes/xen.d/xen.rb \
|
||||
src/im_mad/remotes/xen.d/architecture.sh \
|
||||
src/im_mad/remotes/xen.d/cpu.sh \
|
||||
src/im_mad/remotes/xen.d/name.sh"
|
||||
|
||||
IM_PROBES_KVM_FILES="src/im_mad/remotes/kvm.d/kvm.rb \
|
||||
src/im_mad/remotes/kvm.d/architecture.sh \
|
||||
src/im_mad/remotes/kvm.d/cpu.sh \
|
||||
src/im_mad/remotes/kvm.d/name.sh"
|
||||
src/im_mad/remotes/kvm.d/architecture.sh \
|
||||
src/im_mad/remotes/kvm.d/cpu.sh \
|
||||
src/im_mad/remotes/kvm.d/name.sh"
|
||||
|
||||
IM_PROBES_XEN_FILES="src/im_mad/remotes/xen.d/xen.rb \
|
||||
src/im_mad/remotes/xen.d/architecture.sh \
|
||||
src/im_mad/remotes/xen.d/cpu.sh \
|
||||
src/im_mad/remotes/xen.d/name.sh"
|
||||
|
||||
IM_PROBES_VMWARE_FILES="src/im_mad/remotes/vmware.d/vmware.rb"
|
||||
|
||||
IM_PROBES_GANGLIA_FILES="src/im_mad/remotes/ganglia.d/ganglia_probe"
|
||||
|
||||
@ -603,6 +652,8 @@ AUTH_SERVER_X509_FILES="src/authm_mad/remotes/server_x509/authenticate"
|
||||
|
||||
AUTH_X509_FILES="src/authm_mad/remotes/x509/authenticate"
|
||||
|
||||
AUTH_LDAP_FILES="src/authm_mad/remotes/ldap/authenticate"
|
||||
|
||||
AUTH_SSH_FILES="src/authm_mad/remotes/ssh/authenticate"
|
||||
|
||||
AUTH_DUMMY_FILES="src/authm_mad/remotes/dummy/authenticate"
|
||||
@ -611,6 +662,38 @@ AUTH_PLAIN_FILES="src/authm_mad/remotes/plain/authenticate"
|
||||
|
||||
AUTH_QUOTA_FILES="src/authm_mad/remotes/quota/authorize"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Virtual Network Manager drivers to be installed under $REMOTES_LOCATION/vnm
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
NETWORK_FILES="src/vnm_mad/remotes/OpenNebulaNetwork.rb \
|
||||
src/vnm_mad/remotes/Firewall.rb \
|
||||
src/vnm_mad/remotes/OpenNebulaNic.rb"
|
||||
|
||||
NETWORK_8021Q_FILES="src/vnm_mad/remotes/802.1Q/clean \
|
||||
src/vnm_mad/remotes/802.1Q/post \
|
||||
src/vnm_mad/remotes/802.1Q/pre \
|
||||
src/vnm_mad/remotes/802.1Q/HostManaged.rb"
|
||||
|
||||
NETWORK_DUMMY_FILES="src/vnm_mad/remotes/dummy/clean \
|
||||
src/vnm_mad/remotes/dummy/post \
|
||||
src/vnm_mad/remotes/dummy/pre"
|
||||
|
||||
NETWORK_EBTABLES_FILES="src/vnm_mad/remotes/ebtables/clean \
|
||||
src/vnm_mad/remotes/ebtables/post \
|
||||
src/vnm_mad/remotes/ebtables/pre \
|
||||
src/vnm_mad/remotes/ebtables/Ebtables.rb"
|
||||
|
||||
NETWORK_FW_FILES="src/vnm_mad/remotes/fw/post \
|
||||
src/vnm_mad/remotes/fw/pre \
|
||||
src/vnm_mad/remotes/fw/clean"
|
||||
|
||||
NETWORK_OVSWITCH_FILES="src/vnm_mad/remotes/ovswitch/clean \
|
||||
src/vnm_mad/remotes/ovswitch/post \
|
||||
src/vnm_mad/remotes/ovswitch/pre \
|
||||
src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb"
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Transfer Manager commands, to be installed under $LIB_LOCATION/tm_commands
|
||||
# - SHARED TM, $LIB_LOCATION/tm_commands/shared
|
||||
@ -645,8 +728,12 @@ LVM_TM_COMMANDS_LIB_FILES="src/tm_mad/lvm/tm_clone.sh \
|
||||
src/tm_mad/lvm/tm_mv.sh \
|
||||
src/tm_mad/lvm/tm_context.sh"
|
||||
|
||||
VMWARE_TM_COMMANDS_LIB_FILES="src/tm_mad/vmware/tm_clone.sh \
|
||||
src/tm_mad/vmware/tm_ln.sh \
|
||||
src/tm_mad/vmware/tm_mv.sh"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Image Repository drivers, to be installed under $REMOTES_LOCTION/image
|
||||
# Image Repository drivers, to be installed under $REMOTES_LOCATION/image
|
||||
# - FS based Image Repository, $REMOTES_LOCATION/image/fs
|
||||
#-------------------------------------------------------------------------------
|
||||
IMAGE_DRIVER_FS_SCRIPTS="src/image_mad/remotes/fs/cp \
|
||||
@ -664,6 +751,7 @@ ONEDB_MIGRATOR_FILES="src/onedb/2.0_to_2.9.80.rb \
|
||||
src/onedb/2.9.85_to_2.9.90.rb \
|
||||
src/onedb/2.9.90_to_3.0.0.rb \
|
||||
src/onedb/3.0.0_to_3.1.0.rb \
|
||||
src/onedb/3.1.0_to_3.1.80.rb \
|
||||
src/onedb/onedb.rb \
|
||||
src/onedb/onedb_backend.rb"
|
||||
|
||||
@ -675,6 +763,8 @@ ETC_FILES="share/etc/oned.conf \
|
||||
share/etc/defaultrc \
|
||||
src/cli/etc/group.default"
|
||||
|
||||
VMWARE_ETC_FILES="src/vmm_mad/remotes/vmware/vmwarerc"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Virtualization drivers config. files, to be installed under $ETC_LOCATION
|
||||
# - ec2, $ETC_LOCATION/vmm_ec2
|
||||
@ -686,7 +776,8 @@ VMM_EC2_ETC_FILES="src/vmm_mad/ec2/vmm_ec2rc \
|
||||
|
||||
VMM_EXEC_ETC_FILES="src/vmm_mad/exec/vmm_execrc \
|
||||
src/vmm_mad/exec/vmm_exec_kvm.conf \
|
||||
src/vmm_mad/exec/vmm_exec_xen.conf"
|
||||
src/vmm_mad/exec/vmm_exec_xen.conf \
|
||||
src/vmm_mad/exec/vmm_exec_vmware.conf"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Information drivers config. files, to be installed under $ETC_LOCATION
|
||||
@ -716,6 +807,8 @@ TM_DUMMY_ETC_FILES="src/tm_mad/dummy/tm_dummy.conf \
|
||||
TM_LVM_ETC_FILES="src/tm_mad/lvm/tm_lvm.conf \
|
||||
src/tm_mad/lvm/tm_lvmrc"
|
||||
|
||||
TM_VMWARE_ETC_FILES="src/tm_mad/vmware/tm_vmware.conf"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Hook Manager driver config. files, to be installed under $ETC_LOCATION/hm
|
||||
#-------------------------------------------------------------------------------
|
||||
@ -728,6 +821,7 @@ HM_ETC_FILES="src/hm_mad/hmrc"
|
||||
|
||||
AUTH_ETC_FILES="src/authm_mad/remotes/server_x509/server_x509_auth.conf \
|
||||
src/authm_mad/remotes/quota/quota.conf \
|
||||
src/authm_mad/remotes/ldap/ldap_auth.conf \
|
||||
src/authm_mad/remotes/x509/x509_auth.conf"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
@ -756,20 +850,9 @@ TM_EXAMPLE_SHARE_FILES="share/examples/tm/tm_clone.sh \
|
||||
HOOK_FT_FILES="share/hooks/host_error.rb"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Network Hook scripts, to be installed under $VAR_LOCATION/remotes/hooks
|
||||
# Installation scripts, to be installed under $SHARE_LOCATION
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
HOOK_NETWORK_FILES="src/vnm_mad/hm-vlan \
|
||||
src/vnm_mad/ebtables-vlan \
|
||||
src/vnm_mad/firewall \
|
||||
src/vnm_mad/HostManaged.rb \
|
||||
src/vnm_mad/OpenNebulaNetwork.rb \
|
||||
src/vnm_mad/OpenNebulaNic.rb \
|
||||
src/vnm_mad/OpenvSwitch.rb \
|
||||
src/vnm_mad/openvswitch-vlan \
|
||||
src/vnm_mad/Firewall.rb \
|
||||
src/vnm_mad/Ebtables.rb"
|
||||
|
||||
INSTALL_NOVNC_SHARE_FILE="share/install_novnc.sh"
|
||||
INSTALL_GEMS_SHARE_FILE="share/install_gems/install_gems"
|
||||
|
||||
@ -881,6 +964,7 @@ OCCI_ETC_TEMPLATE_FILES="src/cloud/occi/etc/templates/common.erb \
|
||||
src/cloud/occi/etc/templates/custom.erb \
|
||||
src/cloud/occi/etc/templates/small.erb \
|
||||
src/cloud/occi/etc/templates/medium.erb \
|
||||
src/cloud/occi/etc/templates/network.erb \
|
||||
src/cloud/occi/etc/templates/large.erb"
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
@ -956,7 +1040,8 @@ SUNSTONE_PUBLIC_JS_FILES="src/sunstone/public/js/layout.js \
|
||||
src/sunstone/public/js/login.js \
|
||||
src/sunstone/public/js/sunstone.js \
|
||||
src/sunstone/public/js/sunstone-util.js \
|
||||
src/sunstone/public/js/opennebula.js"
|
||||
src/sunstone/public/js/opennebula.js \
|
||||
src/sunstone/public/js/locale.js"
|
||||
|
||||
SUNSTONE_PUBLIC_JS_PLUGINS_FILES="\
|
||||
src/sunstone/public/js/plugins/dashboard-tab.js \
|
||||
@ -986,34 +1071,36 @@ SUNSTONE_PUBLIC_VENDOR_JGROWL="\
|
||||
src/sunstone/public/vendor/jGrowl/NOTICE"
|
||||
|
||||
SUNSTONE_PUBLIC_VENDOR_JQUERY="\
|
||||
src/sunstone/public/vendor/jQuery/jquery-1.4.4.min.js \
|
||||
src/sunstone/public/vendor/jQuery/jquery-1.7.1.min.js \
|
||||
src/sunstone/public/vendor/jQuery/MIT-LICENSE.txt \
|
||||
src/sunstone/public/vendor/jQuery/NOTICE"
|
||||
|
||||
SUNSTONE_PUBLIC_VENDOR_JQUERYUI="\
|
||||
src/sunstone/public/vendor/jQueryUI/ui-bg_glass_75_dadada_1x400.png \
|
||||
src/sunstone/public/vendor/jQueryUI/ui-icons_cd0a0a_256x240.png \
|
||||
src/sunstone/public/vendor/jQueryUI/jquery-ui-1.8.7.custom.css \
|
||||
src/sunstone/public/vendor/jQueryUI/ui-bg_flat_0_aaaaaa_40x100.png \
|
||||
src/sunstone/public/vendor/jQueryUI/ui-bg_flat_0_8f9392_40x100.png \
|
||||
src/sunstone/public/vendor/jQueryUI/jquery-ui-1.8.16.custom.css \
|
||||
src/sunstone/public/vendor/jQueryUI/MIT-LICENSE.txt \
|
||||
src/sunstone/public/vendor/jQueryUI/jquery-ui-1.8.7.custom.min.js \
|
||||
src/sunstone/public/vendor/jQueryUI/ui-bg_highlight-soft_75_cccccc_1x100.png \
|
||||
src/sunstone/public/vendor/jQueryUI/ui-bg_glass_95_fef1ec_1x400.png \
|
||||
src/sunstone/public/vendor/jQueryUI/ui-bg_glass_55_fbf9ee_1x400.png \
|
||||
src/sunstone/public/vendor/jQueryUI/ui-icons_888888_256x240.png \
|
||||
src/sunstone/public/vendor/jQueryUI/ui-bg_glass_75_e6e6e6_1x400.png \
|
||||
src/sunstone/public/vendor/jQueryUI/ui-bg_flat_0_575c5b_40x100.png \
|
||||
src/sunstone/public/vendor/jQueryUI/ui-bg_glass_65_ffffff_1x400.png \
|
||||
src/sunstone/public/vendor/jQueryUI/ui-bg_flat_75_ffffff_40x100.png \
|
||||
src/sunstone/public/vendor/jQueryUI/ui-icons_2e83ff_256x240.png \
|
||||
src/sunstone/public/vendor/jQueryUI/ui-icons_454545_256x240.png \
|
||||
src/sunstone/public/vendor/jQueryUI/jquery-ui-1.8.16.custom.min.js \
|
||||
src/sunstone/public/vendor/jQueryUI/NOTICE \
|
||||
src/sunstone/public/vendor/jQueryUI/ui-icons_222222_256x240.png \
|
||||
"
|
||||
|
||||
SUNSTONE_PUBLIC_VENDOR_JQUERYUIIMAGES="\
|
||||
src/sunstone/public/vendor/jQueryUI/images/ui-bg_flat_0_aaaaaa_40x100.png \
|
||||
src/sunstone/public/vendor/jQueryUI/images/ui-bg_flat_75_ffffff_40x100.png \
|
||||
src/sunstone/public/vendor/jQueryUI/images/ui-bg_glass_55_fbf9ee_1x400.png \
|
||||
src/sunstone/public/vendor/jQueryUI/images/ui-bg_glass_65_ffffff_1x400.png \
|
||||
src/sunstone/public/vendor/jQueryUI/images/ui-bg_glass_75_dadada_1x400.png \
|
||||
src/sunstone/public/vendor/jQueryUI/images/ui-bg_glass_75_e6e6e6_1x400.png \
|
||||
src/sunstone/public/vendor/jQueryUI/images/ui-bg_glass_95_fef1ec_1x400.png \
|
||||
src/sunstone/public/vendor/jQueryUI/images/ui-bg_highlight-soft_75_cccccc_1x100.png \
|
||||
src/sunstone/public/vendor/jQueryUI/images/ui-icons_222222_256x240.png \
|
||||
src/sunstone/public/vendor/jQueryUI/images/ui-icons_2e83ff_256x240.png \
|
||||
src/sunstone/public/vendor/jQueryUI/images/ui-icons_454545_256x240.png \
|
||||
src/sunstone/public/vendor/jQueryUI/images/ui-icons_888888_256x240.png \
|
||||
src/sunstone/public/vendor/jQueryUI/images/ui-icons_cd0a0a_256x240.png \
|
||||
"
|
||||
|
||||
SUNSTONE_PUBLIC_VENDOR_JQUERYLAYOUT="\
|
||||
src/sunstone/public/vendor/jQueryLayout/layout-default-latest.css \
|
||||
src/sunstone/public/vendor/jQueryLayout/jquery.layout.min-1.2.0.js \
|
||||
src/sunstone/public/vendor/jQueryLayout/jquery.layout-latest.min.js \
|
||||
src/sunstone/public/vendor/jQueryLayout/NOTICE"
|
||||
|
||||
SUNSTONE_PUBLIC_VENDOR_FLOT="\
|
||||
@ -1032,9 +1119,22 @@ SUNSTONE_PUBLIC_IMAGES_FILES="src/sunstone/public/images/ajax-loader.gif \
|
||||
src/sunstone/public/images/panel_short.png \
|
||||
src/sunstone/public/images/pbar.gif \
|
||||
src/sunstone/public/images/Refresh-icon.png \
|
||||
src/sunstone/public/images/red_bullet.png \
|
||||
src/sunstone/public/images/yellow_bullet.png \
|
||||
src/sunstone/public/images/green_bullet.png \
|
||||
src/sunstone/public/images/vnc_off.png \
|
||||
src/sunstone/public/images/vnc_on.png"
|
||||
|
||||
SUNSTONE_PUBLIC_LOCALE_EN_US="\
|
||||
src/sunstone/public/locale/en_US/en_US.js \
|
||||
"
|
||||
|
||||
SUNSTONE_PUBLIC_LOCALE_RU="
|
||||
src/sunstone/public/locale/ru/ru.js \
|
||||
src/sunstone/public/locale/ru/ru_datatable.txt"
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Ozones files
|
||||
#-----------------------------------------------------------------------------
|
||||
@ -1049,10 +1149,10 @@ OZONES_ETC_FILES="src/ozones/Server/etc/ozones-server.conf"
|
||||
OZONES_MODELS_FILES="src/ozones/Server/models/OzonesServer.rb \
|
||||
src/ozones/Server/models/Auth.rb \
|
||||
src/sunstone/models/OpenNebulaJSON/JSONUtils.rb"
|
||||
|
||||
|
||||
OZONES_TEMPLATE_FILES="src/ozones/Server/templates/index.html \
|
||||
src/ozones/Server/templates/login.html"
|
||||
|
||||
|
||||
OZONES_LIB_FILES="src/ozones/Server/lib/OZones.rb"
|
||||
|
||||
OZONES_LIB_ZONE_FILES="src/ozones/Server/lib/OZones/Zones.rb \
|
||||
@ -1066,7 +1166,7 @@ OZONES_LIB_ZONE_FILES="src/ozones/Server/lib/OZones/Zones.rb \
|
||||
src/ozones/Server/lib/OZones/AggregatedPool.rb \
|
||||
src/ozones/Server/lib/OZones/AggregatedImages.rb \
|
||||
src/ozones/Server/lib/OZones/AggregatedTemplates.rb"
|
||||
|
||||
|
||||
OZONES_LIB_API_FILES="src/ozones/Client/lib/zona.rb"
|
||||
|
||||
OZONES_LIB_API_ZONA_FILES="src/ozones/Client/lib/zona/ZoneElement.rb \
|
||||
@ -1078,26 +1178,29 @@ OZONES_LIB_API_ZONA_FILES="src/ozones/Client/lib/zona/ZoneElement.rb \
|
||||
src/ozones/Client/lib/zona/ZonePool.rb"
|
||||
|
||||
OZONES_PUBLIC_VENDOR_JQUERY=$SUNSTONE_PUBLIC_VENDOR_JQUERY
|
||||
|
||||
|
||||
OZONES_PUBLIC_VENDOR_DATATABLES=$SUNSTONE_PUBLIC_VENDOR_DATATABLES
|
||||
|
||||
OZONES_PUBLIC_VENDOR_JGROWL=$SUNSTONE_PUBLIC_VENDOR_JGROWL
|
||||
|
||||
OZONES_PUBLIC_VENDOR_JQUERYUI=$SUNSTONE_PUBLIC_VENDOR_JQUERYUI
|
||||
|
||||
OZONES_PUBLIC_VENDOR_JQUERYUIIMAGES=$SUNSTONE_PUBLIC_VENDOR_JQUERYUIIMAGES
|
||||
|
||||
OZONES_PUBLIC_VENDOR_JQUERYLAYOUT=$SUNSTONE_PUBLIC_VENDOR_JQUERYLAYOUT
|
||||
|
||||
|
||||
OZONES_PUBLIC_JS_FILES="src/ozones/Server/public/js/ozones.js \
|
||||
src/ozones/Server/public/js/login.js \
|
||||
src/ozones/Server/public/js/ozones-util.js \
|
||||
src/sunstone/public/js/layout.js \
|
||||
src/sunstone/public/js/sunstone.js \
|
||||
src/sunstone/public/js/sunstone-util.js"
|
||||
src/sunstone/public/js/sunstone-util.js \
|
||||
src/sunstone/public/js/locale.js"
|
||||
|
||||
OZONES_PUBLIC_CSS_FILES="src/ozones/Server/public/css/application.css \
|
||||
src/ozones/Server/public/css/layout.css \
|
||||
src/ozones/Server/public/css/login.css"
|
||||
|
||||
|
||||
OZONES_PUBLIC_IMAGES_FILES="src/ozones/Server/public/images/panel.png \
|
||||
src/ozones/Server/public/images/login.png \
|
||||
src/ozones/Server/public/images/login_over.png \
|
||||
@ -1111,16 +1214,16 @@ OZONES_PUBLIC_JS_PLUGINS_FILES="src/ozones/Server/public/js/plugins/zones-tab.js
|
||||
src/ozones/Server/public/js/plugins/vdcs-tab.js \
|
||||
src/ozones/Server/public/js/plugins/aggregated-tab.js \
|
||||
src/ozones/Server/public/js/plugins/dashboard-tab.js"
|
||||
|
||||
OZONES_LIB_CLIENT_CLI_FILES="src/ozones/Client/lib/cli/ozones_helper.rb"
|
||||
|
||||
|
||||
OZONES_LIB_CLIENT_CLI_FILES="src/ozones/Client/lib/cli/ozones_helper.rb"
|
||||
|
||||
OZONES_LIB_CLIENT_CLI_HELPER_FILES="\
|
||||
src/ozones/Client/lib/cli/ozones_helper/vdc_helper.rb \
|
||||
src/ozones/Client/lib/cli/ozones_helper/zones_helper.rb"
|
||||
src/ozones/Client/lib/cli/ozones_helper/zones_helper.rb"
|
||||
|
||||
OZONES_BIN_CLIENT_FILES="src/ozones/Client/bin/onevdc \
|
||||
src/ozones/Client/bin/onezone"
|
||||
|
||||
|
||||
OZONES_RUBY_LIB_FILES="src/oca/ruby/OpenNebula.rb"
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
@ -1132,6 +1235,7 @@ ACCT_BIN_FILES="src/acct/oneacctd"
|
||||
ACCT_LIB_FILES="src/acct/monitoring.rb \
|
||||
src/acct/accounting.rb \
|
||||
src/acct/acctd.rb \
|
||||
src/acct/oneacct.rb \
|
||||
src/acct/watch_helper.rb \
|
||||
src/acct/watch_client.rb"
|
||||
|
||||
@ -1197,7 +1301,7 @@ if [ "$CLIENT" = "yes" ]; then
|
||||
elif [ "$SUNSTONE" = "yes" ]; then
|
||||
INSTALL_SET="${INSTALL_SUNSTONE_RUBY_FILES[@]} ${INSTALL_SUNSTONE_FILES[@]}"
|
||||
elif [ "$OZONES" = "yes" ]; then
|
||||
INSTALL_SET="${INSTALL_OZONES_RUBY_FILES[@]} ${INSTALL_OZONES_FILES[@]}"
|
||||
INSTALL_SET="${INSTALL_OZONES_RUBY_FILES[@]} ${INSTALL_OZONES_FILES[@]}"
|
||||
else
|
||||
INSTALL_SET="${INSTALL_FILES[@]} ${INSTALL_OZONES_FILES[@]} \
|
||||
${INSTALL_SUNSTONE_FILES[@]}"
|
||||
|
@ -139,6 +139,17 @@ IM_MAD = [
|
||||
# arguments = "xen" ]
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# VMware Information Driver Manager Configuration
|
||||
# -r number of retries when monitoring a host
|
||||
# -t number of threads, i.e. number of hosts monitored at the same time
|
||||
#-------------------------------------------------------------------------------
|
||||
#IM_MAD = [
|
||||
# name = "im_vmware",
|
||||
# executable = "one_im_sh",
|
||||
# arguments = "-t 15 -r 0 vmware" ]
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# EC2 Information Driver Manager Configuration
|
||||
#-------------------------------------------------------------------------------
|
||||
@ -218,6 +229,19 @@ VM_MAD = [
|
||||
# type = "xen" ]
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# VMware Virtualization Driver Manager Configuration
|
||||
# -r number of retries when monitoring a host
|
||||
# -t number of threads, i.e. number of hosts monitored at the same time
|
||||
#-------------------------------------------------------------------------------
|
||||
#VM_MAD = [
|
||||
# name = "vmm_vmware",
|
||||
# executable = "one_vmm_sh",
|
||||
# arguments = "-t 15 -r 0 vmware",
|
||||
# default = "vmm_exec/vmm_exec_vmware.conf",
|
||||
# type = "vmware" ]
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# EC2 Virtualization Driver Manager Configuration
|
||||
# arguments: default values for the EC2 driver, can be an absolute path or
|
||||
@ -289,6 +313,15 @@ TM_MAD = [
|
||||
# arguments = "tm_lvm/tm_lvm.conf" ]
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# VMware DataStore Transfer Manager Driver Configuration
|
||||
#-------------------------------------------------------------------------------
|
||||
#TM_MAD = [
|
||||
# name = "tm_vmware",
|
||||
# executable = "one_tm",
|
||||
# arguments = "tm_vmware/tm_vmware.conf" ]
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#*******************************************************************************
|
||||
# Image Manager Driver Configuration
|
||||
#*******************************************************************************
|
||||
@ -405,136 +438,6 @@ HM_MAD = [
|
||||
# arguments = "$VMID" ]
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#*******************************************************************************
|
||||
# Networking Hooks
|
||||
#*******************************************************************************
|
||||
# The following network hooks can be activated in order to manage network
|
||||
# isolation and firewalls.
|
||||
#*******************************************************************************
|
||||
#-------------------------------------------------------------------------------
|
||||
# Firewall
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# Firewalling rules activated in the physical host executing the VM. Can be used
|
||||
# to filter TCP and UDP ports, and to define a policy for ICMP connections. To
|
||||
# use it specify under the NIC section of the VM one or more of the following
|
||||
# attributes:
|
||||
#
|
||||
# - WHITE_PORTS_TCP = iptables_range
|
||||
# Permits access to the VM only through the specified ports in the TCP
|
||||
# protocol. Supersedes BLACK_PORTS_TCP if defined.
|
||||
#
|
||||
# - BLACK_PORTS_TCP = iptables_range
|
||||
# Doesn't permit access to the VM through the specified ports in the TCP
|
||||
# protocol. Superseded by WHITE_PORTS_TCP if defined.
|
||||
#
|
||||
# - WHITE_PORTS_UDP = iptables_range
|
||||
# Permits access to the VM only through the specified ports in the UDP
|
||||
# protocol. Supersedes BLACK_PORTS_UDP if defined.
|
||||
#
|
||||
# - BLACK_PORTS_UDP = iptables_range
|
||||
# Doesn't permit access to the VM through the specified ports in the UDP
|
||||
# protocol. Superseded by WHITE_PORTS_UDP if defined.
|
||||
#
|
||||
# - ICMP = no | drop
|
||||
# Blocks ICMP connections to the VM. By default it's enabled.
|
||||
#
|
||||
# This hook requires the sudoers file to be configured so oneadmin can execute
|
||||
# iptables without a password.
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# VM_HOOK = [
|
||||
# name = "firewall-on",
|
||||
# on = "RUNNING",
|
||||
# command = "vnm/firewall",
|
||||
# arguments = "on $TEMPLATE",
|
||||
# remote = "yes" ]
|
||||
#
|
||||
# VM_HOOK = [
|
||||
# name = "firewall-off",
|
||||
# on = "DONE",
|
||||
# command = "vnm/firewall",
|
||||
# arguments = "off $TEMPLATE",
|
||||
# remote = "yes" ]
|
||||
#-------------------------------------------------------------------------------
|
||||
# Host-managed VLANs
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# Network isolation provided through host-managed vlans. This hook will create a
|
||||
# bridge for each OpenNebula virtual network and attach a tagged network
|
||||
# interface to the bridge.
|
||||
#
|
||||
# For this hook to be effective you need to specify the attribute PHYDEV in your
|
||||
# VNET template, which should contain the name of the physical network interface
|
||||
# each VM should be attached to. If BRIDGE is not defined it will be
|
||||
# automatically generated.
|
||||
#
|
||||
# In order to use this hook you need to:
|
||||
# - load module 8021q
|
||||
# - install vconfig
|
||||
# - configure passwordless sudo in the worker nodes for oneadmin for these
|
||||
# commands: brctl, ip, vconfig.
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# VM_HOOK = [
|
||||
# name = "hm-vlan",
|
||||
# on = "PROLOG",
|
||||
# command = "vnm/hm-vlan",
|
||||
# arguments = "$TEMPLATE",
|
||||
# remote = "yes" ]
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
# Ebtables Network Isolation
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# Network isolation provided through ebtables rules applied on the bridges. This
|
||||
# method will only permit isolation with a mask of 255.255.255.0.
|
||||
#
|
||||
# This hook requires the sudoers file to be configured so oneadmin can execute
|
||||
# ebtables without a password, and the ebtables package to be installed.
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# VM_HOOK = [
|
||||
# name = "ebtables-vlan-on",
|
||||
# on = "RUNNING",
|
||||
# command = "vnm/ebtables-vlan",
|
||||
# arguments = "on $TEMPLATE",
|
||||
# remote = "yes" ]
|
||||
#
|
||||
# VM_HOOK = [
|
||||
# name = "ebtables-vlan-off",
|
||||
# on = "DONE",
|
||||
# command = "vnm/ebtables-vlan",
|
||||
# arguments = "off $TEMPLATE",
|
||||
# remote = "yes" ]
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
# Open vSwitch Network Isolation
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# Network isolation provided through Open vSwitch. Each virtual network
|
||||
# interface will receive an VLAN tag enabling network isolation.
|
||||
#
|
||||
# This hook requires Open vSwitch to be installed along with the Open vSwitch
|
||||
# compatibility layer for Linux bridging, on each worker node.
|
||||
# See http://openvswitch.org/ for more information.
|
||||
#
|
||||
# Passwordless sudo permissions for oneadmin to execute ovs_vsctl.
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# VM_HOOK = [
|
||||
# name = "openvswitch-vlan",
|
||||
# on = "RUNNING",
|
||||
# command = "vnm/openvswitch-vlan",
|
||||
# arguments = "$TEMPLATE",
|
||||
# remote = "yes" ]
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#*******************************************************************************
|
||||
# Auth Manager Configuration
|
||||
#*******************************************************************************
|
||||
@ -558,8 +461,8 @@ HM_MAD = [
|
||||
|
||||
AUTH_MAD = [
|
||||
executable = "one_auth_mad",
|
||||
arguments = "--authn ssh,x509,server_cipher,server_x509"
|
||||
# arguments = "--authz quota --authn ssh,x509,server_cipher,server_x509"
|
||||
arguments = "--authn ssh,x509,ldap,server_cipher,server_x509"
|
||||
# arguments = "--authz quota --authn ssh,x509,ldap,server_cipher,server_x509"
|
||||
]
|
||||
|
||||
SESSION_EXPIRATION_TIME = 900
|
||||
|
@ -2,16 +2,17 @@
|
||||
|
||||
require 'pp'
|
||||
|
||||
PACKAGES=%w{optional sunstone quota cloud ozones_client ozones_server
|
||||
ozones_server_mysql ozones_server_sqlite}
|
||||
|
||||
DEFAULT=%w{optional sunstone quota cloud ozones_server acct}
|
||||
DEFAULT=%w{optional sunstone quota cloud ozones_server acct auth_ldap}
|
||||
|
||||
if defined?(RUBY_VERSION) && RUBY_VERSION>="1.8.7"
|
||||
SQLITE='sqlite3'
|
||||
|
||||
# xmlparser gem is not compatible with ruby 1.9
|
||||
OPTIONAL=%w{nokogiri}
|
||||
|
||||
if RUBY_VERSION=='1.8.7'
|
||||
OPTIONAL << 'xmlparser'
|
||||
end
|
||||
else
|
||||
SQLITE='sqlite3-ruby --version 1.2.0'
|
||||
OPTIONAL=%w{nokogiri xmlparser}
|
||||
@ -21,7 +22,7 @@ GROUPS={
|
||||
:optional => OPTIONAL,
|
||||
:quota => [SQLITE, 'sequel'],
|
||||
:sunstone => ['json', 'rack', 'sinatra', 'thin', 'sequel', SQLITE],
|
||||
:cloud => %w{amazon-ec2 rack sinatra thin uuid curb},
|
||||
:cloud => %w{amazon-ec2 rack sinatra thin uuidtools curb},
|
||||
:ozones_client => %w{json},
|
||||
:ozones_server => %w{json data_mapper dm-sqlite-adapter dm-mysql-adapter}+[
|
||||
SQLITE, 'mysql'
|
||||
@ -30,9 +31,12 @@ GROUPS={
|
||||
:ozones_server_mysql => %w{json data_mapper dm-mysql-adapter mysql},
|
||||
:acct => ['sequel', SQLITE, 'mysql'],
|
||||
:acct_sqlite => ['sequel', SQLITE],
|
||||
:acct_mysql => ['sequel', 'mysql']
|
||||
:acct_mysql => ['sequel', 'mysql'],
|
||||
:auth_ldap => 'net-ldap'
|
||||
}
|
||||
|
||||
PACKAGES=GROUPS.keys
|
||||
|
||||
DISTRIBUTIONS={
|
||||
:debian => {
|
||||
:id => ['Ubuntu', 'Debian'],
|
||||
@ -82,6 +86,15 @@ class String
|
||||
end
|
||||
end
|
||||
|
||||
def installed_gems
|
||||
text=`gem list --no-versions --no-details`
|
||||
if $?.exitstatus!=0
|
||||
nil
|
||||
else
|
||||
text.split(/\s+/)
|
||||
end
|
||||
end
|
||||
|
||||
def try_library(name, error_message)
|
||||
begin
|
||||
require name.to_s
|
||||
@ -107,12 +120,14 @@ def help
|
||||
puts
|
||||
puts "If no parameters are specified then this list will be used:"
|
||||
puts DEFAULT.join(' ')
|
||||
puts
|
||||
puts "Use --check parameter to search for non installed libraries."
|
||||
end
|
||||
|
||||
def get_gems(packages)
|
||||
packages.map do |package|
|
||||
GROUPS[package.to_sym]
|
||||
end.flatten.uniq
|
||||
end.flatten.uniq-installed_gems
|
||||
end
|
||||
|
||||
def detect_distro
|
||||
@ -191,6 +206,88 @@ def install_dependencies(gems, distro)
|
||||
end
|
||||
end
|
||||
|
||||
def run_command(cmd)
|
||||
puts cmd
|
||||
system cmd
|
||||
#system "true"
|
||||
|
||||
if $?!=0
|
||||
puts "Error executing #{cmd}"
|
||||
exit(-1)
|
||||
end
|
||||
end
|
||||
|
||||
def install_gems(packages)
|
||||
gems_list=get_gems(packages)
|
||||
|
||||
if gems_list.empty?
|
||||
puts "Gems already installed"
|
||||
exit(0)
|
||||
end
|
||||
|
||||
dist=detect_distro
|
||||
|
||||
install_dependencies(gems_list, dist)
|
||||
|
||||
packages_string=gems_list.join(' ')
|
||||
|
||||
prefix=""
|
||||
|
||||
if dist && dist.last[:gem_env]
|
||||
prefix=dist.last[:gem_env].collect do |name, value|
|
||||
"#{name}=\"#{value}\""
|
||||
end.join(' ')+' '
|
||||
end
|
||||
|
||||
command_string = "#{prefix}gem install --no-ri --no-rdoc"
|
||||
|
||||
install_warning(packages)
|
||||
|
||||
simple_gems=gems_list.select {|g| !(g.match(/\s/)) }
|
||||
if simple_gems and !simple_gems.empty?
|
||||
cmd=command_string+" " << simple_gems.join(' ')
|
||||
run_command(cmd)
|
||||
end
|
||||
|
||||
special_gems=gems_list.select {|g| g.match(/\s/) }
|
||||
special_gems.each do |gem|
|
||||
cmd=command_string+" "<<gem
|
||||
run_command(cmd)
|
||||
end
|
||||
end
|
||||
|
||||
def check_lib(lib)
|
||||
begin
|
||||
require lib
|
||||
true
|
||||
rescue LoadError, Exception
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def check_gems(packages)
|
||||
list=get_gems(packages).compact
|
||||
gems=list.map {|g| g.strip.split(/\s+/).first }
|
||||
|
||||
not_installed=Array.new
|
||||
|
||||
gems.each do |lib_name|
|
||||
if !check_lib(lib_name)
|
||||
not_installed << lib_name
|
||||
end
|
||||
end
|
||||
|
||||
if not_installed.empty?
|
||||
puts "All ruby libraries installed"
|
||||
exit(0)
|
||||
else
|
||||
puts "These ruby libraries are not installed:"
|
||||
puts ""
|
||||
puts "* "+not_installed.join("\n* ")
|
||||
exit(-1)
|
||||
end
|
||||
end
|
||||
|
||||
try_library :rubygems, <<-EOT.unindent
|
||||
rubygems required to use this tool
|
||||
|
||||
@ -224,45 +321,37 @@ try_library :mkmf, <<-EOT.unindent
|
||||
* Install the ruby development package for your distro
|
||||
EOT
|
||||
|
||||
if ARGV.include?('-h')
|
||||
help
|
||||
exit(0)
|
||||
|
||||
command=''
|
||||
params=ARGV
|
||||
|
||||
if params.include?('-h')
|
||||
params-=['-h']
|
||||
command='help'
|
||||
elsif params.include?('--check')
|
||||
params-=['--check']
|
||||
command='check'
|
||||
else
|
||||
command='install'
|
||||
end
|
||||
|
||||
if ARGV.length>0
|
||||
packages=ARGV
|
||||
if params.length>0
|
||||
packages=params
|
||||
else
|
||||
packages=DEFAULT
|
||||
end
|
||||
|
||||
gems_list=get_gems(packages)
|
||||
|
||||
dist=detect_distro
|
||||
|
||||
install_dependencies(gems_list, dist)
|
||||
|
||||
packages_string=gems_list.join(' ')
|
||||
|
||||
prefix=""
|
||||
|
||||
if dist && dist.last[:gem_env]
|
||||
prefix=dist.last[:gem_env].collect do |name, value|
|
||||
"#{name}=\"#{value}\""
|
||||
end.join(' ')+' '
|
||||
case command
|
||||
when 'help'
|
||||
help
|
||||
exit(0)
|
||||
when 'check'
|
||||
check_gems(packages)
|
||||
when 'install'
|
||||
install_gems(packages)
|
||||
end
|
||||
|
||||
command_string = "#{prefix}gem install --no-ri --no-rdoc"
|
||||
|
||||
install_warning(packages)
|
||||
|
||||
gems_list.each do |gem|
|
||||
cmd=command_string+" "<<gem
|
||||
puts cmd
|
||||
system cmd
|
||||
|
||||
if $?!=0
|
||||
puts "Error installing #{gem}"
|
||||
exit(-1)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
|
||||
.TH OPENNEBULA "1" "September 2011" "OpenNebula 3.0.0" "User Commands"
|
||||
.TH OPENNEBULA "1" "December 2011" "OpenNebula 3.1.80" "User Commands"
|
||||
.SH NAME
|
||||
OpenNebula \- OpenNebula econe-describe-images
|
||||
.SH SYNOPSIS
|
||||
|
@ -1,5 +1,5 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
|
||||
.TH OPENNEBULA "1" "September 2011" "OpenNebula 3.0.0" "User Commands"
|
||||
.TH OPENNEBULA "1" "December 2011" "OpenNebula 3.1.80" "User Commands"
|
||||
.SH NAME
|
||||
OpenNebula \- OpenNebula econe-describe-instances
|
||||
.SH SYNOPSIS
|
||||
|
@ -1,5 +1,5 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
|
||||
.TH OPENNEBULA "1" "September 2011" "OpenNebula 3.0.0" "User Commands"
|
||||
.TH OPENNEBULA "1" "December 2011" "OpenNebula 3.1.80" "User Commands"
|
||||
.SH NAME
|
||||
OpenNebula \- OpenNebula econe-register
|
||||
.SH SYNOPSIS
|
||||
|
@ -1,5 +1,5 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
|
||||
.TH OPENNEBULA "1" "September 2011" "OpenNebula 3.0.0" "User Commands"
|
||||
.TH OPENNEBULA "1" "December 2011" "OpenNebula 3.1.80" "User Commands"
|
||||
.SH NAME
|
||||
OpenNebula \- OpenNebula econe-run-instances
|
||||
.SH SYNOPSIS
|
||||
|
@ -1,5 +1,5 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
|
||||
.TH OPENNEBULA "1" "September 2011" "OpenNebula 3.0.0" "User Commands"
|
||||
.TH OPENNEBULA "1" "December 2011" "OpenNebula 3.1.80" "User Commands"
|
||||
.SH NAME
|
||||
OpenNebula \- OpenNebula econe-terminate-instances
|
||||
.SH SYNOPSIS
|
||||
|
@ -1,5 +1,5 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
|
||||
.TH OPENNEBULA "1" "September 2011" "OpenNebula 3.0.0" "User Commands"
|
||||
.TH OPENNEBULA "1" "September 2011" "OpenNebula 3.1.80" "User Commands"
|
||||
.SH NAME
|
||||
OpenNebula \- OpenNebula econe-upload
|
||||
.SH SYNOPSIS
|
||||
|
@ -1,5 +1,5 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
|
||||
.TH OPENNEBULA "1" "September 2011" "OpenNebula 3.0.0" "User Commands"
|
||||
.TH OPENNEBULA "1" "December 2011" "OpenNebula 3.1.80" "User Commands"
|
||||
.SH NAME
|
||||
OpenNebula \- OpenNebula occi-compute
|
||||
.SH SYNOPSIS
|
||||
|
@ -1,5 +1,5 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
|
||||
.TH OPENNEBULA "1" "September 2011" "OpenNebula 3.0.0" "User Commands"
|
||||
.TH OPENNEBULA "1" "December 2011" "OpenNebula 3.1.80" "User Commands"
|
||||
.SH NAME
|
||||
OpenNebula \- OpenNebula occi-network
|
||||
.SH SYNOPSIS
|
||||
|
@ -1,5 +1,5 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
|
||||
.TH OPENNEBULA "1" "September 2011" "OpenNebula 3.0.0" "User Commands"
|
||||
.TH OPENNEBULA "1" "December 2011" "OpenNebula 3.1.80" "User Commands"
|
||||
.SH NAME
|
||||
OpenNebula \- OpenNebula occi-storage
|
||||
.SH SYNOPSIS
|
||||
|
@ -1,7 +1,7 @@
|
||||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "ONEACL" "1" "September 2011" "" "oneacl(1) -- manages OpenNebula ACLs"
|
||||
.TH "ONEACL" "1" "December 2011" "" "oneacl(1) -- manages OpenNebula ACLs"
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBoneacl\fR
|
||||
@ -128,7 +128,7 @@ Comma\-separated list of OpenNebula ACL names or ids
|
||||
.IP "" 0
|
||||
.
|
||||
.SH "LICENSE"
|
||||
OpenNebula 3\.0\.0 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
|
||||
OpenNebula 3\.1\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
|
||||
.
|
||||
.P
|
||||
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
|
||||
|
@ -1,21 +1,12 @@
|
||||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "ONEDB" "1" "September 2011" "" "onedb(1) -- OpenNebula database migration tool"
|
||||
.TH "ONEDB" "1" "December 2011" "" "onedb(1) -- OpenNebula database migration tool"
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBonedb\fR
|
||||
.
|
||||
.P
|
||||
DB Connection options:
|
||||
.
|
||||
.P
|
||||
By default, onedb reads the connection data from oned\.conf If any of these options is set, oned\.conf is ignored (i\.e\. if you set MySQL\'s port onedb won\'t look for the rest of the options in oned\.conf)
|
||||
.
|
||||
.P
|
||||
Description:
|
||||
.
|
||||
.P
|
||||
This command enables the user to manage the OpenNebula database\. It provides information about the DB version, means to upgrade it to the latest version, and backup tools\.
|
||||
.
|
||||
.SH "OPTIONS"
|
||||
|
@ -1,7 +1,7 @@
|
||||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "ONEGROUP" "1" "September 2011" "" "onegroup(1) -- manages OpenNebula groups"
|
||||
.TH "ONEGROUP" "1" "December 2011" "" "onegroup(1) -- manages OpenNebula groups"
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBonegroup\fR
|
||||
@ -160,7 +160,7 @@ Comma\-separated list of OpenNebula GROUP names or ids
|
||||
.IP "" 0
|
||||
.
|
||||
.SH "LICENSE"
|
||||
OpenNebula 3\.0\.0 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
|
||||
OpenNebula 3\.1\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
|
||||
.
|
||||
.P
|
||||
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
|
||||
|
@ -1,7 +1,7 @@
|
||||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "ONEHOST" "1" "September 2011" "" "onehost(1) -- manages OpenNebula hosts"
|
||||
.TH "ONEHOST" "1" "December 2011" "" "onehost(1) -- manages OpenNebula hosts"
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBonehost\fR
|
||||
@ -27,7 +27,7 @@
|
||||
.SH "COMMANDS"
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
create \fIhostname\fR \fIim_mad\fR \fIvmm_mad\fR \fItm_mad\fR
|
||||
create \fIhostname\fR \fIim_mad\fR \fIvmm_mad\fR \fItm_mad\fR \fIvnm_mad\fR
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
@ -234,7 +234,7 @@ Comma\-separated list of OpenNebula HOST names or ids
|
||||
.IP "" 0
|
||||
.
|
||||
.SH "LICENSE"
|
||||
OpenNebula 3\.0\.0 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
|
||||
OpenNebula 3\.1\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
|
||||
.
|
||||
.P
|
||||
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
|
||||
|
@ -1,7 +1,7 @@
|
||||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "ONEIMAGE" "1" "September 2011" "" "oneimage(1) -- manages OpenNebula images"
|
||||
.TH "ONEIMAGE" "1" "December 2011" "" "oneimage(1) -- manages OpenNebula images"
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBoneimage\fR
|
||||
@ -141,6 +141,20 @@ Enables the given Image
|
||||
.
|
||||
.IP "" 0
|
||||
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
chtype \fIrange|imageid_list\fR \fItype\fR
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
Changes the Image\'s type
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
disable \fIrange|imageid_list\fR
|
||||
@ -353,7 +367,7 @@ user IMAGE of the user identified by the username
|
||||
.IP "" 0
|
||||
.
|
||||
.SH "LICENSE"
|
||||
OpenNebula 3\.0\.0 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
|
||||
OpenNebula 3\.1\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
|
||||
.
|
||||
.P
|
||||
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
|
||||
|
@ -1,7 +1,7 @@
|
||||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "ONETEMPLATE" "1" "September 2011" "" "onetemplate(1) -- manages OpenNebula templates"
|
||||
.TH "ONETEMPLATE" "1" "December 2011" "" "onetemplate(1) -- manages OpenNebula templates"
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBonetemplate\fR
|
||||
@ -312,7 +312,7 @@ user VMTEMPLATE of the user identified by the username
|
||||
.IP "" 0
|
||||
.
|
||||
.SH "LICENSE"
|
||||
OpenNebula 3\.0\.0 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
|
||||
OpenNebula 3\.1\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
|
||||
.
|
||||
.P
|
||||
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
|
||||
|
@ -1,7 +1,7 @@
|
||||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "ONEUSER" "1" "September 2011" "" "oneuser(1) -- manages OpenNebula users"
|
||||
.TH "ONEUSER" "1" "December 2011" "" "oneuser(1) -- manages OpenNebula users"
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBoneuser\fR
|
||||
@ -14,11 +14,12 @@
|
||||
.nf
|
||||
|
||||
\-r, \-\-read\-file Read password from file
|
||||
\-p, \-\-plain Store plain password
|
||||
\-\-sha1 The password will be hashed using the sha1 algorithm
|
||||
\-\-ssh SSH Auth system
|
||||
\-\-x509 x509 Auth system for x509 certificates
|
||||
\-k, \-\-key path_to_private_key_pem Path to the Private Key of the User
|
||||
\-c, \-\-cert path_to_user_cert_pem Path to the Certificate of the User
|
||||
\-\-driver driver Driver to autehnticate this user
|
||||
\-\-x509_proxy x509 Auth system based on x509 proxy certificates
|
||||
\-\-proxy path_to_user_proxy_pem Path to the user proxy certificate
|
||||
\-\-time x Token duration in seconds, defaults to 3600 (1 h)
|
||||
@ -44,11 +45,25 @@ create \fIusername\fR [\fIpassword\fR]
|
||||
Creates a new User
|
||||
Examples:
|
||||
oneuser create my_user my_password
|
||||
oneuser create my_user /tmp/mypass \-r
|
||||
oneuser create my_user \-r /tmp/mypass
|
||||
oneuser create my_user \-\-ssh \-\-key /tmp/id_rsa
|
||||
oneuser create my_user \-\-ssh \-r /tmp/public_key
|
||||
oneuser create my_user \-\-x509 \-\-cert /tmp/my_cert\.pem
|
||||
valid options: read_file, plain, ssh, x509, key, cert
|
||||
valid options: read_file, sha1, ssh, x509, key, cert, driver
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
update \fIuserid\fR
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
Launches the system editor to modify and update the template contents
|
||||
.
|
||||
.fi
|
||||
.
|
||||
@ -112,7 +127,7 @@ passwd \fIuserid\fR [\fIpassword\fR]
|
||||
.nf
|
||||
|
||||
Changes the given User\'s password
|
||||
valid options: read_file, plain, ssh, x509, key, cert
|
||||
valid options: read_file, sha1, ssh, x509, key, cert, driver
|
||||
.
|
||||
.fi
|
||||
.
|
||||
@ -132,6 +147,28 @@ Changes the User\'s main group
|
||||
.
|
||||
.IP "" 0
|
||||
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
chauth \fIuserid\fR [\fIauth\fR] [\fIpassword\fR]
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
Changes the User\'s auth driver and its password (optional)
|
||||
Examples:
|
||||
oneuser chauth my_user core
|
||||
oneuser chauth my_user core new_password
|
||||
oneuser chauth my_user core \-r /tmp/mypass
|
||||
oneuser chauth my_user \-\-ssh \-\-key /home/oneadmin/\.ssh/id_rsa
|
||||
oneuser chauth my_user \-\-ssh \-r /tmp/public_key
|
||||
oneuser chauth my_user \-\-x509 \-\-cert /tmp/my_cert\.pem
|
||||
valid options: read_file, sha1, ssh, x509, key, cert, driver
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
list
|
||||
@ -268,7 +305,7 @@ User password
|
||||
.IP "" 0
|
||||
.
|
||||
.SH "LICENSE"
|
||||
OpenNebula 3\.0\.0 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
|
||||
OpenNebula 3\.1\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
|
||||
.
|
||||
.P
|
||||
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
|
||||
|
@ -1,184 +1,7 @@
|
||||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "ONEVDC" "1" "September 2011" "" "onevdc(1) -- manages OpenNebula Virtual DataCenters"
|
||||
.TH "ONEVDC" "1" "December 2011" "" "onevdc(1) -- manages OpenNebula Virtual DataCenters"
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBonevdc\fR
|
||||
.
|
||||
.SH "SYNOPSIS"
|
||||
\fBonevdc\fR command [\fIargs\fR] [\fIoptions\fR]
|
||||
.
|
||||
.SH "OPTIONS"
|
||||
.
|
||||
.nf
|
||||
|
||||
\-f, \-\-force Force the usage of Hosts in more than one VDC
|
||||
\-l, \-\-list x,y,z Selects columns to display with list command
|
||||
\-d, \-\-delay x Sets the delay in seconds for top command
|
||||
\-x, \-\-xml Show the resource in xml format
|
||||
\-n, \-\-numeric Do not translate user and group IDs
|
||||
\-k, \-\-kilobytes Show units in kilobytes
|
||||
\-v, \-\-verbose Verbose mode
|
||||
\-h, \-\-help Show this message
|
||||
\-V, \-\-version Show version and copyright information
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.SH "COMMANDS"
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
create \fIfile\fR
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
Create a new VDC
|
||||
valid options: force
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
show \fIvdcid\fR
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
Show information of a particular VDC
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
list
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
Lists VDCs in the pool
|
||||
valid options: list, delay, xml, numeric, kilobytes
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
delete \fIvdcid\fR
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
Deletes a VDC
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
addhost \fIvdcid\fR \fIrange\fR
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
Adds the set of hosts to the VDC
|
||||
valid options: force
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
delhost \fIvdcid\fR \fIrange\fR
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
Deletes the set of hosts from the VDC
|
||||
valid options: force
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SH "ARGUMENT FORMATS"
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
file
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
Path to a file
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
range
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
List of id\'s in the form 1,8\.\.15
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
text
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
String
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
vdcid
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
VDC ID
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SH "LICENSE"
|
||||
OpenNebula 3\.0\.0 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
|
||||
.
|
||||
.P
|
||||
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
|
||||
|
@ -1,7 +1,7 @@
|
||||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "ONEVM" "1" "September 2011" "" "onevm(1) -- manages OpenNebula virtual machines"
|
||||
.TH "ONEVM" "1" "December 2011" "" "onevm(1) -- manages OpenNebula virtual machines"
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBonevm\fR
|
||||
@ -17,6 +17,7 @@
|
||||
\-x, \-\-xml Show the resource in xml format
|
||||
\-n, \-\-numeric Do not translate user and group IDs
|
||||
\-k, \-\-kilobytes Show units in kilobytes
|
||||
\-t, \-\-type type Type of the new Image
|
||||
\-l, \-\-list x,y,z Selects columns to display with list command
|
||||
\-d, \-\-delay x Sets the delay in seconds for top command
|
||||
\-v, \-\-verbose Verbose mode
|
||||
@ -106,6 +107,7 @@ shut down gracefuly (i\.e\., using \'onevm shutdown\' and not
|
||||
\'onevm delete\')
|
||||
|
||||
States: ANY
|
||||
valid options: type
|
||||
.
|
||||
.fi
|
||||
.
|
||||
@ -493,7 +495,7 @@ user VM of the user identified by the username
|
||||
.IP "" 0
|
||||
.
|
||||
.SH "LICENSE"
|
||||
OpenNebula 3\.0\.0 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
|
||||
OpenNebula 3\.1\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
|
||||
.
|
||||
.P
|
||||
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
|
||||
|
@ -1,7 +1,7 @@
|
||||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "ONEVNET" "1" "September 2011" "" "onevnet(1) -- manages OpenNebula networks"
|
||||
.TH "ONEVNET" "1" "December 2011" "" "onevnet(1) -- manages OpenNebula networks"
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBonevnet\fR
|
||||
@ -81,6 +81,34 @@ Removes a lease from the Virtual Network
|
||||
.
|
||||
.IP "" 0
|
||||
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
hold \fIvnetid\fR \fIip\fR
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
Holds a Virtual Network lease, marking it as used
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
release \fIvnetid\fR \fIip\fR
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
Releases a Virtual Network lease on hold
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
publish \fIrange|vnetid_list\fR
|
||||
@ -113,7 +141,7 @@ can\'t be used by any other User
|
||||
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
chgrp \fIrange|vnid_list\fR \fIgroupid\fR
|
||||
chgrp \fIrange|vnetid_list\fR \fIgroupid\fR
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
@ -127,7 +155,7 @@ Changes the Virtual Network group
|
||||
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
chown \fIrange|vnid_list\fR \fIuserid\fR [\fIgroupid\fR]
|
||||
chown \fIrange|vnetid_list\fR \fIuserid\fR [\fIgroupid\fR]
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
@ -169,6 +197,20 @@ valid options: xml
|
||||
.
|
||||
.IP "" 0
|
||||
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
update \fIvnetid\fR
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
Launches the system editor to modify and update the template contents
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
@ -294,7 +336,7 @@ user VNET of the user identified by the username
|
||||
.IP "" 0
|
||||
.
|
||||
.SH "LICENSE"
|
||||
OpenNebula 3\.0\.0 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
|
||||
OpenNebula 3\.1\.80 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
|
||||
.
|
||||
.P
|
||||
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
|
||||
|
@ -1,156 +1,7 @@
|
||||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "ONEZONE" "1" "September 2011" "" "onezone(1) -- manages OpenNebula zones"
|
||||
.TH "ONEZONE" "1" "December 2011" "" "onezone(1) -- manages OpenNebula zones"
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBonezone\fR
|
||||
.
|
||||
.SH "SYNOPSIS"
|
||||
\fBonezone\fR \fIcommand\fR [\fIargs\fR] [\fIoptions\fR]
|
||||
.
|
||||
.SH "OPTIONS"
|
||||
.
|
||||
.nf
|
||||
|
||||
\-l, \-\-list x,y,z Selects columns to display with list command
|
||||
\-d, \-\-delay x Sets the delay in seconds for top command
|
||||
\-x, \-\-xml Show the resource in xml format
|
||||
\-n, \-\-numeric Do not translate user and group IDs
|
||||
\-k, \-\-kilobytes Show units in kilobytes
|
||||
\-v, \-\-verbose Verbose mode
|
||||
\-h, \-\-help Show this message
|
||||
\-V, \-\-version Show version and copyright information
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.SH "COMMANDS"
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
create \fIfile\fR
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
Create a new Zone
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
show \fIzoneid\fR [\fIresource\fR]
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
Show information of a particular Zone
|
||||
Available resources: host, vm, image, vn, template, user
|
||||
Examples:
|
||||
onezone show 4
|
||||
onezone show 4 host
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
list
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
Lists Zones in the pool
|
||||
valid options: list, delay, xml, numeric, kilobytes
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
delete \fIzoneid\fR
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
Deletes a Zone
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SH "ARGUMENT FORMATS"
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
file
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
Path to a file
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
range
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
List of id\'s in the form 1,8\.\.15
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
text
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
String
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
zoneid
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
Zone ID
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SH "LICENSE"
|
||||
OpenNebula 3\.0\.0 Copyright 2002\-2011, OpenNebula Project Leads (OpenNebula\.org)
|
||||
.
|
||||
.P
|
||||
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
|
||||
|
183
src/acct/oneacct.rb
Normal file
183
src/acct/oneacct.rb
Normal file
@ -0,0 +1,183 @@
|
||||
# --------------------------------------------------------------------------
|
||||
# Copyright 2010-2011, C12G Labs S.L.
|
||||
#
|
||||
# This file is part of OpenNebula addons.
|
||||
#
|
||||
# OpenNebula addons are free software: you can redistribute it
|
||||
# and/or modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation, either version 3 of
|
||||
# the License, or the hope That it will be useful, but (at your
|
||||
# option) any later version.
|
||||
#
|
||||
# OpenNebula addons are distributed in WITHOUT ANY WARRANTY;
|
||||
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with OpenNebula addons. If not, see
|
||||
# <http://www.gnu.org/licenses/>
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
require 'acct/watch_helper'
|
||||
|
||||
class AcctClient
|
||||
def initialize(filters={})
|
||||
@filters=filters
|
||||
@deltas=[]
|
||||
@users={}
|
||||
end
|
||||
|
||||
def account(time_start=nil, time_end=nil, user_id=nil)
|
||||
@filters[:start]=time_start if time_start
|
||||
@filters[:end]=time_end if time_end
|
||||
@filters[:user]=user_id if user_id
|
||||
|
||||
get_users_consumption
|
||||
|
||||
@users
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def get_users_consumption
|
||||
# Get all the deltas that match the filters
|
||||
@deltas=calculate_deltas.map {|q| q.values }
|
||||
|
||||
@users=slices_by_user
|
||||
|
||||
user_slices_and_deltas_to_vms
|
||||
end
|
||||
|
||||
def slices_by_user
|
||||
# Get all VM slices that match the filters
|
||||
query=get_vm_slices(@filters)
|
||||
|
||||
# This hash will hold the users with the resources consumed
|
||||
users={}
|
||||
|
||||
query.each do |reg|
|
||||
vm=reg.vm
|
||||
uid=vm.uid.to_i
|
||||
|
||||
# Create a new user register if it still does not exist
|
||||
user=users[uid]||={
|
||||
:vm_slices => [],
|
||||
}
|
||||
|
||||
user[:vm_slices] << reg.values
|
||||
end
|
||||
|
||||
users
|
||||
end
|
||||
|
||||
def user_slices_and_deltas_to_vms
|
||||
@users.each do |user, data|
|
||||
# Get the VM ids array for this user
|
||||
vms=data[:vm_slices].map {|vm| vm[:id] }.sort.uniq
|
||||
|
||||
data[:vms]={}
|
||||
|
||||
vms.each do |vm|
|
||||
# Get the slices array for this VM
|
||||
slices=data[:vm_slices].select {|slice| slice[:id]==vm }
|
||||
|
||||
data[:vms][vm]={
|
||||
:slices => [],
|
||||
:time => 0,
|
||||
}
|
||||
|
||||
# Get the deltas sum for this VM
|
||||
vm_delta=@deltas.find {|d| d[:vm_id]==vm }
|
||||
|
||||
data[:vms][vm][:network]=vm_delta
|
||||
data[:vms][vm][:vmid]=vm
|
||||
|
||||
# Calculate the time consumed by the VM
|
||||
slices.each do |slice|
|
||||
data[:vms][vm][:slices] << slice
|
||||
|
||||
time=calculate_time(slice,
|
||||
@filters[:start], @filters[:end])
|
||||
data[:vms][vm][:time]+=time
|
||||
end
|
||||
end
|
||||
|
||||
# Delete redundant slices data
|
||||
data.delete(:vm_slices)
|
||||
end
|
||||
end
|
||||
|
||||
def get_vm_slices(filters={})
|
||||
vms=WatchHelper::Register
|
||||
|
||||
query=vms.join(:vms, :id => :vm_id)
|
||||
query=query.filter({:vms__uid => filters[:user]}) if filters[:user]
|
||||
query=query.filter(
|
||||
{:retime => 0} | (:retime > filters[:start])) if filters[:start]
|
||||
query=query.filter(:rstime <= filters[:end]) if filters[:end]
|
||||
|
||||
query
|
||||
end
|
||||
|
||||
def get_deltas(filters={})
|
||||
if filters[:data]
|
||||
query=filters[:data]
|
||||
else
|
||||
query=WatchHelper::VmDelta
|
||||
end
|
||||
|
||||
query=query.filter( :ptimestamp >= filters[:start] ) if filters[:start]
|
||||
query=query.filter( :ptimestamp <= filters[:end] ) if filters[:end]
|
||||
query=query.filter( { :vm_id => filters[:vmid] } ) if filters[:vmid]
|
||||
|
||||
query
|
||||
end
|
||||
|
||||
def calculate_deltas
|
||||
query=WatchHelper::VmDelta.select(
|
||||
:ptimestamp, :vm_id,
|
||||
'sum(net_tx) AS net_tx'.lit, 'sum(net_rx) AS net_rx'.lit)
|
||||
|
||||
query=query.group(:vm_id)
|
||||
|
||||
new_filters=@filters.merge(:data => query)
|
||||
|
||||
get_deltas(new_filters)
|
||||
end
|
||||
|
||||
def calculate_time(slice, period_start, period_end)
|
||||
ts=slice[:rstime].to_i
|
||||
te=slice[:retime].to_i
|
||||
|
||||
pstart=period_start.to_i
|
||||
pend=period_end.to_i
|
||||
|
||||
pend=Time.now.to_i if pend==0
|
||||
|
||||
ts=pstart if ts<pstart
|
||||
if te>pend or te==0
|
||||
te=pend
|
||||
end
|
||||
|
||||
te-ts
|
||||
end
|
||||
end
|
||||
|
||||
if $0 == __FILE__
|
||||
|
||||
require 'json'
|
||||
|
||||
acct=AcctClient.new(
|
||||
:start => 1319476322,
|
||||
:end => 1319637455
|
||||
)
|
||||
|
||||
a=acct.account()
|
||||
|
||||
puts JSON.pretty_generate(a)
|
||||
|
||||
end
|
||||
|
@ -107,11 +107,15 @@ class AuthDriver < OpenNebulaDriver
|
||||
#build path for the auth action
|
||||
#/var/lib/one/remotes/auth/<driver>/authenticate
|
||||
authN_path = File.join(@local_scripts_path, driver)
|
||||
|
||||
command = File.join(authN_path,ACTION[:authN].downcase)
|
||||
command << ' ' << user << ' ' << password << ' ' << secret
|
||||
|
||||
local_action(command, request_id, ACTION[:authN])
|
||||
command = File.join(authN_path, ACTION[:authN].downcase)
|
||||
command << " '" << user.gsub("'", '\'"\'"\'') << "' '" << password.gsub("'", '\'"\'"\'') << "' " << secret
|
||||
|
||||
rc = LocalCommand.run(command, log_method(request_id))
|
||||
|
||||
result , info = get_info_from_execution(rc)
|
||||
|
||||
send_message(ACTION[:authN], result, request_id, info)
|
||||
end
|
||||
|
||||
# Authenticate a user based in a string of the form user:secret when using the
|
||||
@ -136,12 +140,16 @@ class AuthDriver < OpenNebulaDriver
|
||||
result = RESULT[:failure]
|
||||
end
|
||||
|
||||
send_message(ACTION[:authZ],result,request_id,"-")
|
||||
send_message(ACTION[:authZ], result, request_id, "-")
|
||||
else
|
||||
command = @authZ_cmd.clone
|
||||
command << ' ' << user_id << ' ' << requests.join(' ')
|
||||
|
||||
local_action(command, request_id, ACTION[:authZ])
|
||||
rc = LocalCommand.run(command, log_method(request_id))
|
||||
|
||||
result , info = get_info_from_execution(rc)
|
||||
|
||||
send_message(ACTION[:authZ], result, request_id, info)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
63
src/authm_mad/remotes/ldap/authenticate
Executable file
63
src/authm_mad/remotes/ldap/authenticate
Executable file
@ -0,0 +1,63 @@
|
||||
#!/usr/bin/ruby
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Copyright 2010-2011, C12G Labs S.L #
|
||||
# #
|
||||
# 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. #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
ONE_LOCATION=ENV["ONE_LOCATION"]
|
||||
|
||||
if !ONE_LOCATION
|
||||
RUBY_LIB_LOCATION="/usr/lib/one/ruby"
|
||||
ETC_LOCATION="/etc/one/"
|
||||
else
|
||||
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
|
||||
ETC_LOCATION=ONE_LOCATION+"/etc/"
|
||||
end
|
||||
|
||||
$: << RUBY_LIB_LOCATION
|
||||
|
||||
require 'yaml'
|
||||
require 'ldap_auth'
|
||||
|
||||
user=ARGV[0]
|
||||
pass=ARGV[1]
|
||||
secret=ARGV[2]
|
||||
|
||||
options=YAML.load(File.read(ETC_LOCATION+'/auth/ldap_auth.conf'))
|
||||
|
||||
ldap=LdapAuth.new(options)
|
||||
|
||||
user_name=ldap.find_user(user)
|
||||
|
||||
if !user_name
|
||||
STDERR.puts "User #{user} not found"
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
if options[:group]
|
||||
if !ldap.is_in_group?(user_name, options[:group])
|
||||
STDERR.puts "User #{user} is not in group #{options[:group]}"
|
||||
exit(-1)
|
||||
end
|
||||
end
|
||||
|
||||
if ldap.authenticate(user_name, secret)
|
||||
puts "ldap #{user} #{user_name}"
|
||||
exit(0)
|
||||
else
|
||||
STDERR.puts "Bad user/password"
|
||||
exit(-1)
|
||||
end
|
||||
|
35
src/authm_mad/remotes/ldap/ldap_auth.conf
Normal file
35
src/authm_mad/remotes/ldap/ldap_auth.conf
Normal file
@ -0,0 +1,35 @@
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Copyright 2010-2011, C12G Labs S.L #
|
||||
# #
|
||||
# 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. #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
# Ldap user able to query, if not set connects as anonymous
|
||||
#:user: 'admin'
|
||||
#:password: 'password'
|
||||
|
||||
# Ldap authentication method
|
||||
:auth_method: :simple
|
||||
|
||||
# Ldap server
|
||||
:host: localhost
|
||||
:port: 389
|
||||
|
||||
# base hierarchy where to search for users and groups
|
||||
:base: 'dc=domain'
|
||||
|
||||
# group the users need to belong to. If not set any user will do
|
||||
:group: 'cn=cloud,ou=groups,dc=domain'
|
||||
|
||||
# field that holds the user name, if not set 'cn' will be used
|
||||
:user_field: 'cn'
|
96
src/authm_mad/remotes/ldap/ldap_auth.rb
Normal file
96
src/authm_mad/remotes/ldap/ldap_auth.rb
Normal file
@ -0,0 +1,96 @@
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Copyright 2010-2011, C12G Labs S.L #
|
||||
# #
|
||||
# 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. #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
require 'rubygems'
|
||||
require 'net/ldap'
|
||||
|
||||
class LdapAuth
|
||||
def initialize(options)
|
||||
@options={
|
||||
:host => 'localhost',
|
||||
:port => 389,
|
||||
:user => nil,
|
||||
:password => nil,
|
||||
:base => nil,
|
||||
:auth_method => :simple,
|
||||
:user_field => 'cn'
|
||||
}.merge(options)
|
||||
|
||||
ops={}
|
||||
|
||||
if @options[:user]
|
||||
ops[:auth] = {
|
||||
:method => @options[:auth_method],
|
||||
:username => @options[:user],
|
||||
:password => @options[:password]
|
||||
}
|
||||
end
|
||||
|
||||
ops[:host]=@options[:host] if @options[:host]
|
||||
ops[:port]=@options[:port].to_i if @options[:port]
|
||||
|
||||
@ldap=Net::LDAP.new(ops)
|
||||
end
|
||||
|
||||
def find_user(name)
|
||||
begin
|
||||
result=@ldap.search(
|
||||
:base => @options[:base],
|
||||
:filter => "#{@options[:user_field]}=#{name}")
|
||||
|
||||
if result && result.first
|
||||
result.first.dn
|
||||
else
|
||||
result=@ldap.search(:base => name)
|
||||
|
||||
if result && result.first
|
||||
name
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
def is_in_group?(user, group)
|
||||
result=@ldap.search(:base => group, :filter => "(member=#{user})")
|
||||
|
||||
if result && result.first
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def authenticate(user, password)
|
||||
ldap=@ldap.clone
|
||||
|
||||
auth={
|
||||
:method => @options[:auth_method],
|
||||
:username => user,
|
||||
:password => password
|
||||
}
|
||||
|
||||
if ldap.bind(auth)
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
70
src/authm_mad/remotes/ldap/test/ldap_auth_spec.rb
Normal file
70
src/authm_mad/remotes/ldap/test/ldap_auth_spec.rb
Normal file
@ -0,0 +1,70 @@
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Copyright 2010-2011, C12G Labs S.L #
|
||||
# #
|
||||
# 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. #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
$: << ".."
|
||||
|
||||
require 'ldap_auth'
|
||||
|
||||
options={
|
||||
:host => 'ubuntu-test',
|
||||
:base => 'dc=localdomain'
|
||||
}
|
||||
|
||||
describe LdapAuth do
|
||||
before(:all) do
|
||||
@ldap=LdapAuth.new(options)
|
||||
end
|
||||
|
||||
it 'should find user dn' do
|
||||
name=@ldap.find_user('user01')
|
||||
name.should=='cn=user01,dc=localdomain'
|
||||
|
||||
name=@ldap.find_user('user02')
|
||||
name.should=='cn=user02,dc=localdomain'
|
||||
|
||||
name=@ldap.find_user('user03')
|
||||
name.should==nil
|
||||
|
||||
name=@ldap.find_user('cn=user01,dc=localdomain')
|
||||
name.should=='cn=user01,dc=localdomain'
|
||||
end
|
||||
|
||||
it 'should tell if a user is in a group' do
|
||||
group='cn=cloud,ou=groups,dc=localdomain'
|
||||
|
||||
result=@ldap.is_in_group?('cn=user01,dc=localdomain', group)
|
||||
result.should==true
|
||||
|
||||
result=@ldap.is_in_group?('cn=user02,dc=localdomain', group)
|
||||
result.should==false
|
||||
end
|
||||
|
||||
it 'should authenticate user' do
|
||||
result=@ldap.authenticate('cn=user01,dc=localdomain', 'password01')
|
||||
result.should==true
|
||||
|
||||
result=@ldap.authenticate('cn=user02,dc=localdomain', 'password02')
|
||||
result.should==true
|
||||
|
||||
result=@ldap.authenticate('cn=user01,dc=localdomain', 'password02')
|
||||
result.should==false
|
||||
|
||||
result=@ldap.authenticate('user01,dc=localdomain', 'password01')
|
||||
result.should==false
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -78,7 +78,29 @@ class Quota
|
||||
|
||||
IMAGE_USAGE = {
|
||||
:STORAGE => {
|
||||
:proc_info => lambda {|template| File.size(template['PATH']) },
|
||||
:proc_info => lambda {|template|
|
||||
if template['TYPE'] == 'DATABLOCK'
|
||||
template['SIZE'].to_i
|
||||
elsif template['PATH']
|
||||
File.size(template['PATH'])
|
||||
elsif template['SAVED_VM_ID']
|
||||
vm_id = template['SAVED_VM_ID'].to_i
|
||||
disk_id = template['SAVED_DISK_ID'].to_i
|
||||
|
||||
client = OpenNebula::Client.new
|
||||
vm = OpenNebula::VirtualMachine.new_with_id(vm_id, client)
|
||||
vm.info
|
||||
|
||||
im_id = vm["DISK[DISK_ID=#{disk_id}]/IMAGE_ID"].to_i
|
||||
|
||||
im = OpenNebula::Image.new_with_id(im_id, client)
|
||||
im.info
|
||||
|
||||
im['SIZE'].to_i
|
||||
else
|
||||
0
|
||||
end
|
||||
},
|
||||
:xpath => 'SIZE'
|
||||
}
|
||||
}
|
||||
@ -91,7 +113,15 @@ class Quota
|
||||
def initialize
|
||||
conf = YAML.load_file(CONF_FILE)
|
||||
@conf=CONF.merge(conf) {|key,h1,h2|
|
||||
h1.merge(h2) if h1.instance_of?(Hash) && h2.instance_of?(Hash)
|
||||
if h1.instance_of?(Hash) && h2.instance_of?(Hash)
|
||||
h1.merge(h2)
|
||||
else
|
||||
if h2
|
||||
h2
|
||||
else
|
||||
h1
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
@client = OpenNebula::Client.new
|
||||
|
@ -21,7 +21,7 @@ include OpenNebula
|
||||
|
||||
module OpenNebulaHelper
|
||||
ONE_VERSION=<<-EOT
|
||||
OpenNebula 3.1.0
|
||||
OpenNebula 3.1.80
|
||||
Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org)
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
|
@ -59,6 +59,7 @@ class OneHostHelper < OpenNebulaHelper::OneHelper
|
||||
puts str % ["STATE", host.state_str]
|
||||
puts str % ["IM_MAD", host['IM_MAD']]
|
||||
puts str % ["VM_MAD", host['VM_MAD']]
|
||||
puts str % ["VN_MAD", host['VN_MAD']]
|
||||
puts str % ["TM_MAD", host['TM_MAD']]
|
||||
puts str % ["LAST MONITORING TIME", host['LAST_MON_TIME']]
|
||||
puts
|
||||
|
@ -37,14 +37,14 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
|
||||
return -1, "Can not read file: #{arg}"
|
||||
end
|
||||
else
|
||||
password = arg
|
||||
password = arg.dup
|
||||
end
|
||||
|
||||
if options[:driver] == OpenNebula::User::X509_AUTH
|
||||
password.delete!("\s")
|
||||
end
|
||||
|
||||
if options[:sha1]
|
||||
if options[:sha1] || options[:driver] == OpenNebula::User::CIPHER_AUTH
|
||||
require 'digest/sha1'
|
||||
password = Digest::SHA1.hexdigest(password)
|
||||
end
|
||||
@ -166,7 +166,7 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
|
||||
CLIHelper.print_header(str_h1 % "USER #{user['ID']} INFORMATION")
|
||||
puts str % ["ID", user.id.to_s]
|
||||
puts str % ["NAME", user.name]
|
||||
puts str % ["GROUP", user.gid]
|
||||
puts str % ["GROUP", user['GNAME']]
|
||||
puts str % ["PASSWORD", user['PASSWORD']]
|
||||
puts str % ["AUTH_DRIVER", user['AUTH_DRIVER']]
|
||||
|
||||
|
@ -99,9 +99,10 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
||||
CLIHelper.print_header(str_h1 % "VIRTUAL MACHINE TEMPLATE",false)
|
||||
puts vm.template_str
|
||||
|
||||
if vm['/VM/HISTORY_RECORDS/HISTORY']
|
||||
if vm.has_elements?("/VM/HISTORY_RECORDS")
|
||||
puts
|
||||
|
||||
|
||||
CLIHelper.print_header(str_h1 % "VIRTUAL MACHINE HISTORY",false)
|
||||
format_history(vm)
|
||||
end
|
||||
|
@ -59,6 +59,9 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
|
||||
puts str % ["PUBLIC", OpenNebulaHelper.boolean_to_str(vn['PUBLIC'])]
|
||||
puts str % ["TYPE", vn.type_str]
|
||||
puts str % ["BRIDGE", vn["BRIDGE"]]
|
||||
puts str % ["VLAN", OpenNebulaHelper.boolean_to_str(vn['VLAN'])]
|
||||
puts str % ["PHYSICAL DEVICE", vn["PHYDEV"]] if vn["PHYDEV"]
|
||||
puts str % ["VLAN ID", vn["VLAN_ID"]] if vn["VLAN_ID"]
|
||||
puts str % ["USED LEASES", vn['TOTAL_LEASES']]
|
||||
|
||||
puts
|
||||
@ -66,13 +69,26 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
|
||||
|
||||
puts vn.template_str(false)
|
||||
|
||||
leases_str = vn.template_like_str('/VNET/LEASES', false)
|
||||
|
||||
if !leases_str.empty?
|
||||
if vn.type_str == "RANGED"
|
||||
puts
|
||||
CLIHelper.print_header(str_h1 % ["LEASES INFORMATION"], false)
|
||||
puts leases_str
|
||||
CLIHelper.print_header(str_h1 % ["RANGE"], false)
|
||||
puts str % ["IP_START", vn['RANGE/IP_START']]
|
||||
puts str % ["IP_END", vn['RANGE/IP_END']]
|
||||
end
|
||||
|
||||
lease_types = [ ["LEASES ON HOLD", 'LEASE[USED=1 and VID=-1]'],
|
||||
["USED LEASES", 'LEASE[USED=1 and VID>-1]'],
|
||||
["FREE LEASES", 'LEASE[USED=0]'] ]
|
||||
|
||||
lease_types.each { |pair|
|
||||
leases_str = vn.template_like_str('/VNET/LEASES', false, pair[1])
|
||||
|
||||
if !leases_str.empty?
|
||||
puts
|
||||
CLIHelper.print_header(str_h1 % [pair[0]], false)
|
||||
puts leases_str
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
def format_pool(options)
|
||||
@ -126,4 +142,4 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
|
||||
|
||||
table
|
||||
end
|
||||
end
|
||||
end
|
||||
|
235
src/cli/oneacct
Executable file
235
src/cli/oneacct
Executable file
@ -0,0 +1,235 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Copyright 2010-2011, C12G Labs S.L.
|
||||
#
|
||||
# This file is part of OpenNebula addons.
|
||||
#
|
||||
# OpenNebula addons are free software: you can redistribute it
|
||||
# and/or modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation, either version 3 of
|
||||
# the License, or the hope That it will be useful, but (at your
|
||||
# option) any later version.
|
||||
#
|
||||
# OpenNebula addons are distributed in WITHOUT ANY WARRANTY;
|
||||
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with OpenNebula addons. If not, see
|
||||
# <http://www.gnu.org/licenses/>
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
|
||||
ONE_LOCATION=ENV['ONE_LOCATION']
|
||||
|
||||
$: << ONE_LOCATION+'/lib/ruby'
|
||||
$: << ONE_LOCATION+'/lib/ruby/cli'
|
||||
|
||||
require 'rubygems'
|
||||
|
||||
require 'acct/oneacct'
|
||||
require 'cli/one_helper'
|
||||
require 'cli/command_parser'
|
||||
require 'json'
|
||||
|
||||
require 'optparse'
|
||||
require 'optparse/time'
|
||||
|
||||
REG_DATE=/((\d{4})\/)?(\d\d?)(\/(\d\d?))?/
|
||||
REG_TIME=/(\d\d?):(\d\d?)(:(\d\d?))?/
|
||||
|
||||
class AcctHelper
|
||||
|
||||
def format_vm(options=nil)
|
||||
table = CLIHelper::ShowTable.new(nil, nil) do
|
||||
column :VMID, "VM ID", :size=>4 do |d|
|
||||
d[:vmid]
|
||||
end
|
||||
|
||||
column :MEMORY, "Consumed memory", :right, :size=>8 do |d|
|
||||
OpenNebulaHelper.unit_to_str(
|
||||
d[:slices].first[:mem]*1024,
|
||||
{})
|
||||
end
|
||||
|
||||
column :CPU, "Group of the User", :right, :size=>8 do |d|
|
||||
d[:slices].first[:cpu]
|
||||
end
|
||||
|
||||
column :NETRX, "Group of the User", :right, :size=>10 do |d|
|
||||
OpenNebulaHelper.unit_to_str(
|
||||
d[:network][:net_rx]/1024.0,
|
||||
{})
|
||||
end
|
||||
|
||||
column :NETTX, "Group of the User", :right, :size=>10 do |d|
|
||||
OpenNebulaHelper.unit_to_str(
|
||||
d[:network][:net_tx]/1024.0,
|
||||
{})
|
||||
end
|
||||
|
||||
column :TIME, "Group of the User", :right, :size=>15 do |d|
|
||||
OpenNebulaHelper.time_to_str(d[:time])
|
||||
end
|
||||
|
||||
default :VMID, :MEMORY, :CPU, :NETRX, :NETTX, :TIME
|
||||
end
|
||||
|
||||
table
|
||||
end
|
||||
|
||||
def list_vms(data)
|
||||
format_vm().show(data)
|
||||
end
|
||||
|
||||
def list_users(filters)
|
||||
a=gen_accounting(filters)
|
||||
|
||||
a.each do |user, data|
|
||||
|
||||
CLIHelper.scr_bold
|
||||
CLIHelper.scr_underline
|
||||
puts "# User #{user}"
|
||||
CLIHelper.scr_restore
|
||||
puts
|
||||
|
||||
vms=data[:vms].map do |k, v|
|
||||
v
|
||||
end
|
||||
|
||||
self.list_vms(vms)
|
||||
|
||||
puts
|
||||
puts
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def gen_accounting(filters)
|
||||
acct=AcctClient.new(filters)
|
||||
acct.account()
|
||||
end
|
||||
|
||||
def gen_json(filters)
|
||||
begin
|
||||
require 'json'
|
||||
rescue LoadError
|
||||
STDERR.puts "JSON gem is needed to give the result in this format"
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
acct=gen_accounting(filters)
|
||||
acct.to_json
|
||||
end
|
||||
|
||||
def xml_tag(tag, value)
|
||||
"<#{tag}>#{value}</#{tag}>\n"
|
||||
end
|
||||
|
||||
def gen_xml(filters)
|
||||
acct=gen_accounting(filters)
|
||||
|
||||
xml=""
|
||||
|
||||
acct.each do |user, data|
|
||||
xml<<"<user id=\"#{user}\">\n"
|
||||
|
||||
data[:vms].each do |vmid, vm|
|
||||
xml<<" <vm id=\"#{vmid}\">\n"
|
||||
|
||||
xml<<" "<<xml_tag(:name, vm[:name])
|
||||
xml<<" "<<xml_tag(:time, vm[:time])
|
||||
xml<<" "<<xml_tag(:cpu, vm[:slices].first[:cpu])
|
||||
xml<<" "<<xml_tag(:mem, vm[:slices].first[:mem])
|
||||
xml<<" "<<xml_tag(:net_rx, vm[:network][:net_rx])
|
||||
xml<<" "<<xml_tag(:net_tx, vm[:network][:net_tx])
|
||||
|
||||
vm[:slices].each do |slice|
|
||||
xml<<" <slice seq=\"#{slice[:seq]}\">\n"
|
||||
|
||||
slice.each do |key, value|
|
||||
xml<<" "<<xml_tag(key, value)
|
||||
end
|
||||
|
||||
xml<<" </slice>\n"
|
||||
end
|
||||
|
||||
xml<<" </vm>\n"
|
||||
end
|
||||
|
||||
xml<<"</user>\n"
|
||||
end
|
||||
|
||||
xml
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@options=Hash.new
|
||||
|
||||
@options[:format]=:table
|
||||
|
||||
opts=OptionParser.new do |opts|
|
||||
opts.on('-s', '--start TIME', Time,
|
||||
'Start date and time to take into account') do |ext|
|
||||
@options[:start]=ext
|
||||
end
|
||||
|
||||
opts.on("-e", "--end TIME", Time,
|
||||
"End date and time" ) do |ext|
|
||||
@options[:end]=ext
|
||||
end
|
||||
|
||||
opts.on("-u", "--user user", Integer,
|
||||
"User id to make accounting" ) do |ext|
|
||||
@options[:user]=ext.to_i
|
||||
end
|
||||
|
||||
opts.on("-j", "--json",
|
||||
"Output in json format" ) do |ext|
|
||||
@options[:format]=:json
|
||||
end
|
||||
|
||||
opts.on("-x", "--xml",
|
||||
"Output in xml format" ) do |ext|
|
||||
@options[:format]=:xml
|
||||
end
|
||||
|
||||
opts.on()
|
||||
end
|
||||
|
||||
|
||||
begin
|
||||
opts.parse!(ARGV)
|
||||
rescue OptionParser::ParseError => e
|
||||
STDERR.puts "Error: " << e.message
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
|
||||
acct_helper=AcctHelper.new
|
||||
|
||||
|
||||
filters=Hash.new
|
||||
|
||||
filters[:start]=@options[:start].to_i if @options[:start]
|
||||
filters[:end]=@options[:end].to_i if @options[:end]
|
||||
filters[:user]=@options[:user].to_i if @options[:user]
|
||||
|
||||
|
||||
case @options[:format]
|
||||
when :table
|
||||
acct_helper.list_users(filters)
|
||||
when :json
|
||||
puts acct_helper.gen_json(filters)
|
||||
when :xml
|
||||
puts acct_helper.gen_xml(filters)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -60,9 +60,10 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
Creates a new Host
|
||||
EOT
|
||||
|
||||
command :create, create_desc, :hostname, :im_mad, :vmm_mad, :tm_mad do
|
||||
command :create, create_desc, :hostname, :im_mad, :vmm_mad,
|
||||
:tm_mad, :vnm_mad do
|
||||
helper.create_resource(options) do |host|
|
||||
host.allocate(args[0], args[1], args[2], args[3])
|
||||
host.allocate(args[0], args[1], args[2], args[4], args[3])
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -275,11 +275,25 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
end
|
||||
|
||||
chauth_desc = <<-EOT.unindent
|
||||
Changes the User's auth driver
|
||||
Changes the User's auth driver and its password (optional)
|
||||
Examples:
|
||||
oneuser chauth my_user core
|
||||
oneuser chauth my_user core new_password
|
||||
oneuser chauth my_user core -r /tmp/mypass
|
||||
oneuser chauth my_user --ssh --key /home/oneadmin/.ssh/id_rsa
|
||||
oneuser chauth my_user --ssh -r /tmp/public_key
|
||||
oneuser chauth my_user --x509 --cert /tmp/my_cert.pem
|
||||
EOT
|
||||
|
||||
command :chauth, chauth_desc, :userid, :auth, [:password, nil],
|
||||
command :chauth, chauth_desc, :userid, [:auth, nil], [:password, nil],
|
||||
:options=>create_options do
|
||||
if options[:driver]
|
||||
driver = options[:driver]
|
||||
elsif args[1]
|
||||
driver = args[1]
|
||||
else
|
||||
exit_with_code 0, "An Auth driver should be specified"
|
||||
end
|
||||
|
||||
helper = OneUserHelper.new
|
||||
|
||||
@ -297,7 +311,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
helper.perform_action(args[0],
|
||||
options,
|
||||
"Auth driver and password changed") do |user|
|
||||
user.chauth(args[1], pass)
|
||||
user.chauth(driver, pass)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -93,8 +93,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
Adds a lease to the Virtual Network
|
||||
EOT
|
||||
|
||||
command :addleases, 'Adds a lease to the Virtual Network', :vnetid, :ip,
|
||||
[:mac, nil] do
|
||||
command :addleases, addleases_desc, :vnetid, :ip, [:mac, nil] do
|
||||
helper.perform_action(args[0],options,"lease added") do |vn|
|
||||
vn.addleases(args[1], args[2])
|
||||
end
|
||||
@ -110,6 +109,26 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
end
|
||||
end
|
||||
|
||||
hold_desc = <<-EOT.unindent
|
||||
Holds a Virtual Network lease, marking it as used
|
||||
EOT
|
||||
|
||||
command :hold, hold_desc, :vnetid, :ip do
|
||||
helper.perform_action(args[0],options,"lease on hold") do |vn|
|
||||
vn.hold(args[1])
|
||||
end
|
||||
end
|
||||
|
||||
release_desc = <<-EOT.unindent
|
||||
Releases a Virtual Network lease on hold
|
||||
EOT
|
||||
|
||||
command :release, release_desc, :vnetid, :ip do
|
||||
helper.perform_action(args[0],options,"lease released") do |vn|
|
||||
vn.release(args[1])
|
||||
end
|
||||
end
|
||||
|
||||
publish_desc = <<-EOT.unindent
|
||||
Publishes the given Virtual Network. A public Virtual Network can be
|
||||
seen and used by other Users in the Virtual Network's group
|
||||
@ -136,7 +155,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
Changes the Virtual Network group
|
||||
EOT
|
||||
|
||||
command :chgrp, chgrp_desc,[:range, :vnid_list], :groupid do
|
||||
command :chgrp, chgrp_desc,[:range, :vnetid_list], :groupid do
|
||||
helper.perform_actions(args[0],options,"Group changed") do |vn|
|
||||
vn.chown(-1, args[1].to_i)
|
||||
end
|
||||
@ -146,7 +165,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
|
||||
Changes the Virtual Network owner and group
|
||||
EOT
|
||||
|
||||
command :chown, chown_desc, [:range, :vnid_list], :userid,
|
||||
command :chown, chown_desc, [:range, :vnetid_list], :userid,
|
||||
[:groupid,nil] do
|
||||
gid = args[2].nil? ? -1 : args[2].to_i
|
||||
helper.perform_actions(args[0],options,"Owner/Group changed") do |vn|
|
||||
|
@ -33,7 +33,8 @@ class CloudAuth
|
||||
|
||||
# Default interval for timestamps. Tokens will be generated using the same
|
||||
# timestamp for this interval of time.
|
||||
EXPIRE_DELTA = 36000
|
||||
# THIS VALUE CANNOT BE LOWER THAN EXPIRE_MARGIN
|
||||
EXPIRE_DELTA = 1800
|
||||
|
||||
# Tokens will be generated if time > EXPIRE_TIME - EXPIRE_MARGIN
|
||||
EXPIRE_MARGIN = 300
|
||||
@ -44,8 +45,7 @@ class CloudAuth
|
||||
def initialize(conf)
|
||||
@conf = conf
|
||||
|
||||
@token_expiration_delta = @conf[:token_expiration_delta] || EXPIRE_DELTA
|
||||
@token_expiration_time = Time.now.to_i + @token_expiration_delta
|
||||
@token_expiration_time = Time.now.to_i + EXPIRE_DELTA
|
||||
|
||||
if AUTH_MODULES.include?(@conf[:auth])
|
||||
require 'CloudAuth/' + AUTH_MODULES[@conf[:auth]]
|
||||
@ -64,27 +64,47 @@ class CloudAuth
|
||||
begin
|
||||
require core_auth[0]
|
||||
@server_auth = Kernel.const_get(core_auth[1]).new_client
|
||||
|
||||
token = @server_auth.login_token(expiration_time)
|
||||
@oneadmin_client ||= OpenNebula::Client.new(token, @conf[:one_xmlrpc])
|
||||
rescue => e
|
||||
raise e.message
|
||||
end
|
||||
end
|
||||
|
||||
def client(username)
|
||||
# Generate a new OpenNebula client for the target User, if the username
|
||||
# is nil the Client is generated for the server_admin
|
||||
# ussername:: _String_ Name of the User
|
||||
# [return] _Client_
|
||||
def client(username=nil)
|
||||
token = @server_auth.login_token(expiration_time,username)
|
||||
Client.new(token,@conf[:one_xmlrpc])
|
||||
end
|
||||
|
||||
def update_userpool_cache
|
||||
@user_pool = OpenNebula::UserPool.new(client)
|
||||
|
||||
rc = @user_pool.info
|
||||
if OpenNebula.is_error?(rc)
|
||||
raise rc.message
|
||||
end
|
||||
end
|
||||
|
||||
def auth(env, params={})
|
||||
username = do_auth(env, params)
|
||||
|
||||
if username.nil?
|
||||
update_userpool_cache
|
||||
do_auth(env, params)
|
||||
else
|
||||
username
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def expiration_time
|
||||
time_now = Time.now.to_i
|
||||
|
||||
if time_now > @token_expiration_time - EXPIRE_MARGIN
|
||||
update_userpool_cache
|
||||
@token_expiration_time = time_now + @token_expiration_delta
|
||||
@token_expiration_time = time_now + EXPIRE_DELTA
|
||||
end
|
||||
|
||||
@token_expiration_time
|
||||
@ -96,15 +116,6 @@ class CloudAuth
|
||||
@user_pool
|
||||
end
|
||||
|
||||
def update_userpool_cache
|
||||
@user_pool ||= OpenNebula::UserPool.new(@oneadmin_client)
|
||||
|
||||
rc = @user_pool.info
|
||||
if OpenNebula.is_error?(rc)
|
||||
raise rc.message
|
||||
end
|
||||
end
|
||||
|
||||
def get_password(username, non_public_user=false)
|
||||
if non_public_user == true
|
||||
xp="USER[NAME=\"#{username}\" and AUTH_DRIVER!=\"public\"]/PASSWORD"
|
||||
|
@ -15,7 +15,7 @@
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
module EC2CloudAuth
|
||||
def auth(env, params={})
|
||||
def do_auth(env, params={})
|
||||
username = params['AWSAccessKeyId']
|
||||
one_pass = get_password(username)
|
||||
return nil unless one_pass
|
||||
|
@ -15,7 +15,7 @@
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
module OCCICloudAuth
|
||||
def auth(env, params={})
|
||||
def do_auth(env, params={})
|
||||
auth = Rack::Auth::Basic::Request.new(env)
|
||||
|
||||
if auth.provided? && auth.basic?
|
||||
@ -28,6 +28,6 @@ module OCCICloudAuth
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
return nil
|
||||
end
|
||||
end
|
@ -15,7 +15,7 @@
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
module SunstoneCloudAuth
|
||||
def auth(env, params={})
|
||||
def do_auth(env, params={})
|
||||
auth = Rack::Auth::Basic::Request.new(env)
|
||||
|
||||
if auth.provided? && auth.basic?
|
||||
@ -28,6 +28,6 @@ module SunstoneCloudAuth
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
return nil
|
||||
end
|
||||
end
|
@ -15,7 +15,7 @@
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
module X509CloudAuth
|
||||
def auth(env, params={})
|
||||
def do_auth(env, params={})
|
||||
# For https, the web service should be set to include the user cert in the environment.
|
||||
cert_line = env['HTTP_SSL_CLIENT_CERT']
|
||||
cert_line = nil if cert_line == '(null)' # For Apache mod_ssl
|
||||
|
@ -173,7 +173,7 @@ module CloudCLI
|
||||
|
||||
def version_text
|
||||
version=<<EOT
|
||||
OpenNebula 3.1.0
|
||||
OpenNebula 3.1.80
|
||||
Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org)
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
|
@ -33,8 +33,6 @@
|
||||
# cipher, for symmetric cipher encryption of tokens
|
||||
# x509, for x509 certificate encryption of tokens
|
||||
:core_auth: cipher
|
||||
# Life-time in seconds for token renewal (that used to handle OpenNebula auths)
|
||||
:token_expiration_delta: 1800
|
||||
|
||||
# VM types allowed and its template file (inside templates directory)
|
||||
:instance_types:
|
||||
|
@ -24,9 +24,6 @@
|
||||
# SSL proxy that serves the API (set if is being used)
|
||||
#:ssl_server: fqdm.of.the.server
|
||||
|
||||
# Configuration for OpenNebula's Virtual Networks
|
||||
#:bridge: NAME_OF_DEFAULT_BRIDGE
|
||||
|
||||
# Authentication driver for incomming requests
|
||||
# occi, for OpenNebula's user-password scheme
|
||||
# x509, for x509 certificates based authentication
|
||||
|
25
src/cloud/occi/etc/templates/network.erb
Normal file
25
src/cloud/occi/etc/templates/network.erb
Normal file
@ -0,0 +1,25 @@
|
||||
#
|
||||
# This template is processed by the OCCI Server to include specific data for
|
||||
# the VNET, you should not need to modify the ruby code.
|
||||
# You can add common attributes for your VNET templates (e.g. VLAN, PHYDEV)
|
||||
#
|
||||
|
||||
NAME = "<%= @vnet_info['NAME'] %>"
|
||||
TYPE = RANGED
|
||||
|
||||
NETWORK_ADDRESS = <%= @vnet_info['ADDRESS'] %>
|
||||
<% if @vnet_info['SIZE'] != nil %>
|
||||
NETWORK_SIZE = <%= @vnet_info['SIZE']%>
|
||||
<% end %>
|
||||
|
||||
<% if @vnet_info['DESCRIPTION'] != nil %>
|
||||
DESCRIPTION = "<%= @vnet_info['DESCRIPTION'] %>"
|
||||
<% end %>
|
||||
|
||||
<% if @vnet_info['PUBLIC'] != nil %>
|
||||
PUBLIC = "<%= @vnet_info['PUBLIC'] %>"
|
||||
<% end %>
|
||||
|
||||
#BRIDGE = NAME_OF_DEFAULT_BRIDGE
|
||||
#PHYDEV = NAME_OF_PHYSICAL_DEVICE
|
||||
#VLAN = YES|NO
|
@ -23,17 +23,15 @@ class ImageOCCI < Image
|
||||
<STORAGE href="<%= base_url %>/storage/<%= self.id.to_s %>">
|
||||
<ID><%= self.id.to_s %></ID>
|
||||
<NAME><%= self.name %></NAME>
|
||||
<% if self['TEMPLATE/TYPE'] != nil %>
|
||||
<TYPE><%= self['TEMPLATE/TYPE'] %></TYPE>
|
||||
<% if self['TYPE'] != nil %>
|
||||
<TYPE><%= self['TYPE'] %></TYPE>
|
||||
<% end %>
|
||||
<% if self['TEMPLATE/DESCRIPTION'] != nil %>
|
||||
<DESCRIPTION><%= self['TEMPLATE/DESCRIPTION'] %></DESCRIPTION>
|
||||
<% end %>
|
||||
<% if size != nil %>
|
||||
<SIZE><%= size.to_i / 1024 %></SIZE>
|
||||
<% end %>
|
||||
<% if fstype != nil %>
|
||||
<FSTYPE><%= fstype %></FSTYPE>
|
||||
<SIZE><%= self['SIZE'] %></SIZE>
|
||||
<% if self['FSTYPE'] != nil and !self['FSTYPE'].empty? %>
|
||||
<FSTYPE><%= self['FSTYPE'] %></FSTYPE>
|
||||
<% end %>
|
||||
<PUBLIC><%= self['PUBLIC'] == "0" ? "NO" : "YES"%></PUBLIC>
|
||||
<PERSISTENT><%= self['PERSISTENT'] == "0" ? "NO" : "YES"%></PERSISTENT>
|
||||
@ -84,25 +82,18 @@ class ImageOCCI < Image
|
||||
|
||||
# Creates the OCCI representation of an Image
|
||||
def to_occi(base_url)
|
||||
size = nil
|
||||
|
||||
begin
|
||||
if self['SOURCE'] != nil and File.exists?(self['SOURCE'])
|
||||
size = File.stat(self['SOURCE']).size
|
||||
size = size / 1024
|
||||
end
|
||||
|
||||
fstype = self['TEMPLATE/FSTYPE'] if self['TEMPLATE/FSTYPE']
|
||||
occi_im = ERB.new(OCCI_IMAGE)
|
||||
occi_im_text = occi_im.result(binding)
|
||||
rescue Exception => e
|
||||
error = OpenNebula::Error.new(e.message)
|
||||
return error
|
||||
end
|
||||
|
||||
occi = ERB.new(OCCI_IMAGE)
|
||||
return occi.result(binding).gsub(/\n\s*/,'')
|
||||
return occi_im_text.gsub(/\n\s*/,'')
|
||||
end
|
||||
|
||||
def to_one_template()
|
||||
def to_one_template
|
||||
if @image_info == nil
|
||||
error_msg = "Missing STORAGE section in the XML body"
|
||||
error = OpenNebula::Error.new(error_msg)
|
||||
|
@ -40,6 +40,9 @@ require 'pp'
|
||||
|
||||
COLLECTIONS = ["compute", "instance_type", "network", "storage"]
|
||||
|
||||
# FLAG that will filter the elements retrieved from the Pools
|
||||
POOL_FILTER = Pool::INFO_GROUP
|
||||
|
||||
class OCCIServer < CloudServer
|
||||
# Server initializer
|
||||
# config_file:: _String_ path of the config file
|
||||
@ -109,21 +112,14 @@ class OCCIServer < CloudServer
|
||||
# [return] _String_,_Integer_ Pool Representation or error, status code
|
||||
def get_computes(request)
|
||||
# --- Get User's VMs ---
|
||||
user_flag = -1
|
||||
|
||||
vmpool = VirtualMachinePoolOCCI.new(
|
||||
@client,
|
||||
user_flag)
|
||||
POOL_FILTER)
|
||||
|
||||
# --- Prepare XML Response ---
|
||||
rc = vmpool.info
|
||||
|
||||
if OpenNebula.is_error?(rc)
|
||||
if rc.message.match("Error getting")
|
||||
return rc, 404
|
||||
else
|
||||
return rc, 500
|
||||
end
|
||||
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
|
||||
end
|
||||
|
||||
return to_occi_xml(vmpool, 200)
|
||||
@ -136,21 +132,14 @@ class OCCIServer < CloudServer
|
||||
# => status code
|
||||
def get_networks(request)
|
||||
# --- Get User's VNETs ---
|
||||
user_flag = -1
|
||||
|
||||
network_pool = VirtualNetworkPoolOCCI.new(
|
||||
@client,
|
||||
user_flag)
|
||||
POOL_FILTER)
|
||||
|
||||
# --- Prepare XML Response ---
|
||||
rc = network_pool.info
|
||||
|
||||
if OpenNebula.is_error?(rc)
|
||||
if rc.message.match("Error getting")
|
||||
return rc, 404
|
||||
else
|
||||
return rc, 500
|
||||
end
|
||||
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
|
||||
end
|
||||
|
||||
return to_occi_xml(network_pool, 200)
|
||||
@ -162,21 +151,14 @@ class OCCIServer < CloudServer
|
||||
# status code
|
||||
def get_storages(request)
|
||||
# --- Get User's Images ---
|
||||
user_flag = -1
|
||||
|
||||
image_pool = ImagePoolOCCI.new(
|
||||
@client,
|
||||
user_flag)
|
||||
POOL_FILTER)
|
||||
|
||||
# --- Prepare XML Response ---
|
||||
rc = image_pool.info
|
||||
|
||||
if OpenNebula.is_error?(rc)
|
||||
if rc.message.match("Error getting")
|
||||
return rc, 404
|
||||
else
|
||||
return rc, 500
|
||||
end
|
||||
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
|
||||
end
|
||||
|
||||
return to_occi_xml(image_pool, 200)
|
||||
@ -192,7 +174,6 @@ class OCCIServer < CloudServer
|
||||
|
||||
# --- Prepare XML Response ---
|
||||
rc = user_pool.info
|
||||
|
||||
if OpenNebula.is_error?(rc)
|
||||
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
|
||||
end
|
||||
@ -227,7 +208,9 @@ class OCCIServer < CloudServer
|
||||
return template, 500 if OpenNebula.is_error?(template)
|
||||
|
||||
rc = vm.allocate(template)
|
||||
return rc, 500 if OpenNebula.is_error?(rc)
|
||||
if OpenNebula.is_error?(rc)
|
||||
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
|
||||
end
|
||||
|
||||
# --- Prepare XML Response ---
|
||||
vm.info
|
||||
@ -246,13 +229,8 @@ class OCCIServer < CloudServer
|
||||
|
||||
# --- Prepare XML Response ---
|
||||
rc = vm.info
|
||||
|
||||
if OpenNebula.is_error?(rc)
|
||||
if rc.message.match("Error getting")
|
||||
return rc, 404
|
||||
else
|
||||
return rc, 500
|
||||
end
|
||||
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
|
||||
end
|
||||
|
||||
return to_occi_xml(vm, 200)
|
||||
@ -269,12 +247,11 @@ class OCCIServer < CloudServer
|
||||
VirtualMachine.build_xml(params[:id]),
|
||||
@client)
|
||||
|
||||
rc = vm.info
|
||||
return rc, 404 if OpenNebula::is_error?(rc)
|
||||
|
||||
# --- Finalize the VM ---
|
||||
result = vm.finalize
|
||||
return result, 500 if OpenNebula::is_error?(result)
|
||||
if OpenNebula.is_error?(result)
|
||||
return result, CloudServer::HTTP_ERROR_CODE[result.errno]
|
||||
end
|
||||
|
||||
return "", 204
|
||||
end
|
||||
@ -317,14 +294,16 @@ class OCCIServer < CloudServer
|
||||
VirtualNetwork.build_xml,
|
||||
@client,
|
||||
request.body,
|
||||
@config[:bridge])
|
||||
@config[:template_location])
|
||||
|
||||
# --- Generate the template and Allocate the new Instance ---
|
||||
template = network.to_one_template
|
||||
return template, 500 if OpenNebula.is_error?(template)
|
||||
|
||||
rc = network.allocate(template)
|
||||
return rc, 500 if OpenNebula.is_error?(rc)
|
||||
if OpenNebula.is_error?(rc)
|
||||
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
|
||||
end
|
||||
|
||||
# --- Prepare XML Response ---
|
||||
network.info
|
||||
@ -342,13 +321,8 @@ class OCCIServer < CloudServer
|
||||
|
||||
# --- Prepare XML Response ---
|
||||
rc = network.info
|
||||
|
||||
if OpenNebula.is_error?(rc)
|
||||
if rc.message.match("Error getting")
|
||||
return rc, 404
|
||||
else
|
||||
return rc, 500
|
||||
end
|
||||
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
|
||||
end
|
||||
|
||||
return to_occi_xml(network, 200)
|
||||
@ -363,12 +337,11 @@ class OCCIServer < CloudServer
|
||||
VirtualNetwork.build_xml(params[:id]),
|
||||
@client)
|
||||
|
||||
rc = network.info
|
||||
return rc, 404 if OpenNebula::is_error?(rc)
|
||||
|
||||
# --- Delete the VNET ---
|
||||
rc = network.delete
|
||||
return rc, 500 if OpenNebula::is_error?(rc)
|
||||
if OpenNebula.is_error?(rc)
|
||||
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
|
||||
end
|
||||
|
||||
return "", 204
|
||||
end
|
||||
@ -385,15 +358,15 @@ class OCCIServer < CloudServer
|
||||
VirtualNetwork.build_xml(params[:id]),
|
||||
@client)
|
||||
|
||||
rc = vnet.info
|
||||
return rc, 400 if OpenNebula.is_error?(rc)
|
||||
|
||||
rc = nil
|
||||
if vnet_info['PUBLIC'] == 'YES'
|
||||
rc = vnet.publish
|
||||
return rc, 400 if OpenNebula.is_error?(rc)
|
||||
elsif vnet_info['PUBLIC'] == 'NO'
|
||||
rc = vnet.unpublish
|
||||
return rc, 400 if OpenNebula.is_error?(rc)
|
||||
end
|
||||
|
||||
if OpenNebula.is_error?(rc)
|
||||
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
|
||||
end
|
||||
|
||||
# --- Prepare XML Response ---
|
||||
@ -432,7 +405,9 @@ class OCCIServer < CloudServer
|
||||
return template, 500 if OpenNebula.is_error?(template)
|
||||
|
||||
rc = image.allocate(template)
|
||||
return rc, 500 if OpenNebula.is_error?(rc)
|
||||
if OpenNebula.is_error?(rc)
|
||||
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
|
||||
end
|
||||
|
||||
# --- Prepare XML Response ---
|
||||
image.info
|
||||
@ -450,13 +425,8 @@ class OCCIServer < CloudServer
|
||||
@client)
|
||||
|
||||
rc = image.info
|
||||
|
||||
if OpenNebula.is_error?(rc)
|
||||
if rc.message.match("Error getting")
|
||||
return rc, 404
|
||||
else
|
||||
return rc, 500
|
||||
end
|
||||
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
|
||||
end
|
||||
|
||||
# --- Prepare XML Response ---
|
||||
@ -473,12 +443,11 @@ class OCCIServer < CloudServer
|
||||
Image.build_xml(params[:id]),
|
||||
@client)
|
||||
|
||||
rc = image.info
|
||||
return rc, 404 if OpenNebula::is_error?(rc)
|
||||
|
||||
# --- Delete the Image ---
|
||||
rc = image.delete
|
||||
return rc, 500 if OpenNebula::is_error?(rc)
|
||||
if OpenNebula.is_error?(rc)
|
||||
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
|
||||
end
|
||||
|
||||
return "", 204
|
||||
end
|
||||
@ -495,24 +464,22 @@ class OCCIServer < CloudServer
|
||||
Image.build_xml(params[:id]),
|
||||
@client)
|
||||
|
||||
rc = image.info
|
||||
return rc, 400 if OpenNebula.is_error?(rc)
|
||||
|
||||
rc = nil
|
||||
if image_info['PERSISTENT'] && image_info['PUBLIC']
|
||||
error_msg = "It is not allowed more than one change per request"
|
||||
return OpenNebula::Error.new(error_msg), 400
|
||||
elsif image_info['PERSISTENT'] == 'YES'
|
||||
rc = image.persistent
|
||||
return rc, 400 if OpenNebula.is_error?(rc)
|
||||
elsif image_info['PERSISTENT'] == 'NO'
|
||||
rc = image.nonpersistent
|
||||
return rc, 400 if OpenNebula.is_error?(rc)
|
||||
elsif image_info['PUBLIC'] == 'YES'
|
||||
rc = image.publish
|
||||
return rc, 400 if OpenNebula.is_error?(rc)
|
||||
elsif image_info['PUBLIC'] == 'NO'
|
||||
rc = image.unpublish
|
||||
return rc, 400 if OpenNebula.is_error?(rc)
|
||||
end
|
||||
|
||||
if OpenNebula.is_error?(rc)
|
||||
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
|
||||
end
|
||||
|
||||
# --- Prepare XML Response ---
|
||||
@ -532,7 +499,6 @@ class OCCIServer < CloudServer
|
||||
|
||||
# --- Prepare XML Response ---
|
||||
rc = user.info
|
||||
|
||||
if OpenNebula.is_error?(rc)
|
||||
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
|
||||
end
|
||||
|
@ -100,11 +100,11 @@ class VirtualMachineOCCI < VirtualMachine
|
||||
def to_one_template()
|
||||
if @vm_info == nil
|
||||
error_msg = "Missing COMPUTE section in the XML body"
|
||||
return OpenNebula::Error.new(error_msg), 400
|
||||
return OpenNebula::Error.new(error_msg)
|
||||
end
|
||||
|
||||
if @template == nil
|
||||
return OpenNebula::Error.new("Bad instance type"), 500
|
||||
return OpenNebula::Error.new("Bad instance type")
|
||||
end
|
||||
|
||||
begin
|
||||
|
@ -15,6 +15,7 @@
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
require 'OpenNebula'
|
||||
require 'ipaddr'
|
||||
|
||||
include OpenNebula
|
||||
|
||||
@ -26,35 +27,23 @@ class VirtualNetworkOCCI < VirtualNetwork
|
||||
<% if self['TEMPLATE/DESCRIPTION'] != nil %>
|
||||
<DESCRIPTION><%= self['TEMPLATE/DESCRIPTION'] %></DESCRIPTION>
|
||||
<% end %>
|
||||
<ADDRESS><%= self['TEMPLATE/NETWORK_ADDRESS'] %></ADDRESS>
|
||||
<% if self['TEMPLATE/NETWORK_SIZE'] %>
|
||||
<SIZE><%= self['TEMPLATE/NETWORK_SIZE'] %></SIZE>
|
||||
<% if network_address != nil %>
|
||||
<ADDRESS><%= network_address %></ADDRESS>
|
||||
<% end %>
|
||||
<% if network_size != nil %>
|
||||
<SIZE><%= network_size %></SIZE>
|
||||
<% end %>
|
||||
<USED_LEASES><%= self['TOTAL_LEASES'] %></USED_LEASES>
|
||||
<PUBLIC><%= self['PUBLIC'] == "0" ? "NO" : "YES"%></PUBLIC>
|
||||
</NETWORK>
|
||||
}
|
||||
|
||||
ONE_NETWORK = %q{
|
||||
NAME = "<%= @vnet_info['NAME'] %>"
|
||||
TYPE = RANGED
|
||||
<% if @vnet_info['DESCRIPTION'] != nil %>
|
||||
DESCRIPTION = "<%= @vnet_info['DESCRIPTION'] %>"
|
||||
<% end %>
|
||||
<% if @vnet_info['PUBLIC'] != nil %>
|
||||
PUBLIC = "<%= @vnet_info['PUBLIC'] %>"
|
||||
<% end %>
|
||||
<% if @bridge %>
|
||||
BRIDGE = <%= @bridge %>
|
||||
<% end %>
|
||||
NETWORK_ADDRESS = <%= @vnet_info['ADDRESS'] %>
|
||||
NETWORK_SIZE = <%= @vnet_info['SIZE']%>
|
||||
}.gsub(/^ /, '')
|
||||
|
||||
# Class constructor
|
||||
def initialize(xml, client, xml_info=nil, bridge=nil)
|
||||
#
|
||||
def initialize(xml, client, xml_info=nil, base=nil)
|
||||
super(xml, client)
|
||||
@bridge = bridge
|
||||
@vnet_info = nil
|
||||
@common_template = base + '/network.erb' if base
|
||||
|
||||
if xml_info != nil
|
||||
xmldoc = XMLElement.build_xml(xml_info, 'NETWORK')
|
||||
@ -64,6 +53,18 @@ class VirtualNetworkOCCI < VirtualNetwork
|
||||
|
||||
# Creates the OCCI representation of a Virtual Network
|
||||
def to_occi(base_url)
|
||||
network_address = nil
|
||||
network_size = nil
|
||||
|
||||
if self['RANGE/IP_START']
|
||||
network_address = self['RANGE/IP_START']
|
||||
|
||||
ip_start = IPAddr.new(network_address, Socket::AF_INET)
|
||||
ip_end = IPAddr.new(self['RANGE/IP_END'], Socket::AF_INET)
|
||||
|
||||
network_size = ip_end.to_i - ip_start.to_i
|
||||
end
|
||||
|
||||
begin
|
||||
occi = ERB.new(OCCI_NETWORK)
|
||||
occi_text = occi.result(binding)
|
||||
@ -78,11 +79,16 @@ class VirtualNetworkOCCI < VirtualNetwork
|
||||
def to_one_template()
|
||||
if @vnet_info == nil
|
||||
error_msg = "Missing NETWORK section in the XML body"
|
||||
error = OpenNebula::Error.new(error_msg)
|
||||
return OpenNebula::Error.new(error_msg), 400
|
||||
end
|
||||
|
||||
begin
|
||||
template = ERB.new(File.read(@common_template)).result(binding)
|
||||
rescue Exception => e
|
||||
error = OpenNebula::Error.new(e.message)
|
||||
return error
|
||||
end
|
||||
|
||||
one = ERB.new(ONE_NETWORK)
|
||||
return one.result(binding)
|
||||
return template
|
||||
end
|
||||
end
|
||||
|
@ -33,11 +33,13 @@ Host::Host(
|
||||
const string& _hostname,
|
||||
const string& _im_mad_name,
|
||||
const string& _vmm_mad_name,
|
||||
const string& _vnm_mad_name,
|
||||
const string& _tm_mad_name):
|
||||
PoolObjectSQL(id,_hostname,-1,-1,"","",table),
|
||||
state(INIT),
|
||||
im_mad_name(_im_mad_name),
|
||||
vmm_mad_name(_vmm_mad_name),
|
||||
vnm_mad_name(_vnm_mad_name),
|
||||
tm_mad_name(_tm_mad_name),
|
||||
last_monitored(0)
|
||||
{
|
||||
@ -200,6 +202,7 @@ string& Host::to_xml(string& xml) const
|
||||
"<STATE>" << state << "</STATE>" <<
|
||||
"<IM_MAD>" << im_mad_name << "</IM_MAD>" <<
|
||||
"<VM_MAD>" << vmm_mad_name << "</VM_MAD>" <<
|
||||
"<VN_MAD>" << vnm_mad_name << "</VN_MAD>" <<
|
||||
"<TM_MAD>" << tm_mad_name << "</TM_MAD>" <<
|
||||
"<LAST_MON_TIME>" << last_monitored << "</LAST_MON_TIME>" <<
|
||||
host_share.to_xml(share_xml) <<
|
||||
@ -231,6 +234,7 @@ int Host::from_xml(const string& xml)
|
||||
|
||||
rc += xpath(im_mad_name, "/HOST/IM_MAD", "not_found");
|
||||
rc += xpath(vmm_mad_name, "/HOST/VM_MAD", "not_found");
|
||||
rc += xpath(vnm_mad_name, "/HOST/VN_MAD", "not_found");
|
||||
rc += xpath(tm_mad_name, "/HOST/TM_MAD", "not_found");
|
||||
|
||||
rc += xpath(last_monitored, "/HOST/LAST_MON_TIME", 0);
|
||||
|
@ -139,6 +139,7 @@ int HostPool::allocate (
|
||||
const string& hostname,
|
||||
const string& im_mad_name,
|
||||
const string& vmm_mad_name,
|
||||
const string& vnm_mad_name,
|
||||
const string& tm_mad_name,
|
||||
string& error_str)
|
||||
{
|
||||
@ -165,6 +166,11 @@ int HostPool::allocate (
|
||||
goto error_vmm;
|
||||
}
|
||||
|
||||
if ( vnm_mad_name.empty() )
|
||||
{
|
||||
goto error_vnm;
|
||||
}
|
||||
|
||||
if ( tm_mad_name.empty() )
|
||||
{
|
||||
goto error_tm;
|
||||
@ -179,7 +185,8 @@ int HostPool::allocate (
|
||||
|
||||
// Build a new Host object
|
||||
|
||||
host = new Host(-1, hostname, im_mad_name, vmm_mad_name, tm_mad_name);
|
||||
host = new Host(-1, hostname, im_mad_name, vmm_mad_name, vnm_mad_name,
|
||||
tm_mad_name);
|
||||
|
||||
// Insert the Object in the pool
|
||||
|
||||
@ -204,6 +211,10 @@ error_vmm:
|
||||
oss << "VMM_MAD_NAME cannot be empty.";
|
||||
goto error_common;
|
||||
|
||||
error_vnm:
|
||||
oss << "VNM_MAD_NAME cannot be empty.";
|
||||
goto error_common;
|
||||
|
||||
error_tm:
|
||||
oss << "TM_MAD_NAME cannot be empty.";
|
||||
goto error_common;
|
||||
|
@ -96,7 +96,7 @@ public:
|
||||
{
|
||||
string err;
|
||||
|
||||
hpool->allocate(&oid, "host_test", "im_mad", "vmm_mad", "tm_mad", err);
|
||||
hpool->allocate(&oid, "host_test", "im_mad", "vmm_mad", "vnm_mad", "tm_mad", err);
|
||||
CPPUNIT_ASSERT( oid >= 0 );
|
||||
|
||||
sleep(1);
|
||||
@ -114,7 +114,7 @@ public:
|
||||
{
|
||||
string err;
|
||||
|
||||
hpool->allocate(&oid, "host_test", "im_mad", "vmm_mad", "tm_mad", err);
|
||||
hpool->allocate(&oid, "host_test", "im_mad", "vmm_mad", "vnm_mad", "tm_mad", err);
|
||||
CPPUNIT_ASSERT( oid >= 0 );
|
||||
|
||||
host = hpool->get(oid, true);
|
||||
@ -140,7 +140,7 @@ public:
|
||||
{
|
||||
string err;
|
||||
|
||||
hpool->allocate(&oid, "host_test", "im_mad", "vmm_mad", "tm_mad", err);
|
||||
hpool->allocate(&oid, "host_test", "im_mad", "vmm_mad", "vnm_mad", "tm_mad", err);
|
||||
CPPUNIT_ASSERT( oid >= 0 );
|
||||
|
||||
host = hpool->get(oid, true);
|
||||
@ -166,7 +166,7 @@ public:
|
||||
{
|
||||
string err;
|
||||
|
||||
hpool->allocate(&oid, "host_test", "im_mad", "vmm_mad", "tm_mad", err);
|
||||
hpool->allocate(&oid, "host_test", "im_mad", "vmm_mad", "vnm_mad", "tm_mad", err);
|
||||
CPPUNIT_ASSERT( oid >= 0 );
|
||||
|
||||
host = hpool->get(oid, true);
|
||||
|
@ -25,6 +25,7 @@ using namespace std;
|
||||
|
||||
const string im_mad = "im_mad";
|
||||
const string vmm_mad = "vmm_mad";
|
||||
const string vnm_mad = "vnm_mad";
|
||||
const string tm_mad = "tm_mad";
|
||||
|
||||
const string names[] = {"Host one", "Second host"};
|
||||
@ -32,7 +33,7 @@ const string names[] = {"Host one", "Second host"};
|
||||
const string xmls[] =
|
||||
{
|
||||
"<HOST><ID>0</ID><NAME>Host one</NAME><STATE>0</STATE>"
|
||||
"<IM_MAD>im_mad</IM_MAD><VM_MAD>vmm_mad</VM_MAD><TM_MAD>tm_mad</TM_MAD>"
|
||||
"<IM_MAD>im_mad</IM_MAD><VM_MAD>vmm_mad</VM_MAD><VN_MAD>vnm_mad</VN_MAD><TM_MAD>tm_mad</TM_MAD>"
|
||||
"<LAST_MON_TIME>0</LAST_MON_TIME><HOST_SHARE>"
|
||||
"<DISK_USAGE>0</DISK_USAGE><MEM_USAGE>0</MEM_USAGE><CPU_USAGE>0</CPU_USAGE>"
|
||||
"<MAX_DISK>0</MAX_DISK><MAX_MEM>0</MAX_MEM><MAX_CPU>0</MAX_CPU>"
|
||||
@ -41,7 +42,7 @@ const string xmls[] =
|
||||
"<RUNNING_VMS>0</RUNNING_VMS></HOST_SHARE><TEMPLATE></TEMPLATE></HOST>",
|
||||
|
||||
"<HOST><ID>1</ID><NAME>Second host</NAME><STATE>0</STATE>"
|
||||
"<IM_MAD>im_mad</IM_MAD><VM_MAD>vmm_mad</VM_MAD><TM_MAD>tm_mad</TM_MAD>"
|
||||
"<IM_MAD>im_mad</IM_MAD><VM_MAD>vmm_mad</VM_MAD><VN_MAD>vnm_mad</VN_MAD><TM_MAD>tm_mad</TM_MAD>"
|
||||
"<LAST_MON_TIME>0</LAST_MON_TIME><HOST_SHARE>"
|
||||
"<DISK_USAGE>0</DISK_USAGE><MEM_USAGE>0</MEM_USAGE><CPU_USAGE>0</CPU_USAGE>"
|
||||
"<MAX_DISK>0</MAX_DISK><MAX_MEM>0</MAX_MEM><MAX_CPU>0</MAX_CPU>"
|
||||
@ -53,34 +54,34 @@ const string xmls[] =
|
||||
// This xml dump result has the LAST_MON_TIMEs modified to 0000000000
|
||||
const string xml_dump =
|
||||
"<HOST_POOL><HOST><ID>0</ID><NAME>a</NAME><STATE>0</STATE><IM_MAD>im_mad</I"
|
||||
"M_MAD><VM_MAD>vmm_mad</VM_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0"
|
||||
"M_MAD><VM_MAD>vmm_mad</VM_MAD><VN_MAD>vnm_mad</VN_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0"
|
||||
"</LAST_MON_TIME><HOST_SHARE><DISK_USAGE>0</DISK_USAGE><MEM"
|
||||
"_USAGE>0</MEM_USAGE><CPU_USAGE>0</CPU_USAGE><MAX_DISK>0</MAX_DISK><MAX_MEM"
|
||||
">0</MAX_MEM><MAX_CPU>0</MAX_CPU><FREE_DISK>0</FREE_DISK><FREE_MEM>0</FREE_"
|
||||
"MEM><FREE_CPU>0</FREE_CPU><USED_DISK>0</USED_DISK><USED_MEM>0</USED_MEM><U"
|
||||
"SED_CPU>0</USED_CPU><RUNNING_VMS>0</RUNNING_VMS></HOST_SHARE><TEMPLATE></TEMPLATE></HOST><HOST>"
|
||||
"<ID>1</ID><NAME>a name</NAME><STATE>0</STATE><IM_MAD>im_mad</IM_MAD><VM_MA"
|
||||
"D>vmm_mad</VM_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_M"
|
||||
"D>vmm_mad</VM_MAD><VN_MAD>vnm_mad</VN_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_M"
|
||||
"ON_TIME><HOST_SHARE><DISK_USAGE>0</DISK_USAGE><MEM_USAGE>0</ME"
|
||||
"M_USAGE><CPU_USAGE>0</CPU_USAGE><MAX_DISK>0</MAX_DISK><MAX_MEM>0</MAX_MEM>"
|
||||
"<MAX_CPU>0</MAX_CPU><FREE_DISK>0</FREE_DISK><FREE_MEM>0</FREE_MEM><FREE_CP"
|
||||
"U>0</FREE_CPU><USED_DISK>0</USED_DISK><USED_MEM>0</USED_MEM><USED_CPU>0</U"
|
||||
"SED_CPU><RUNNING_VMS>0</RUNNING_VMS></HOST_SHARE><TEMPLATE></TEMPLATE></HOST><HOST><ID>2</ID><N"
|
||||
"AME>a_name</NAME><STATE>0</STATE><IM_MAD>im_mad</IM_MAD><VM_MAD>vmm_mad</V"
|
||||
"M_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_MON_TIME><HOS"
|
||||
"M_MAD><VN_MAD>vnm_mad</VN_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_MON_TIME><HOS"
|
||||
"T_SHARE><DISK_USAGE>0</DISK_USAGE><MEM_USAGE>0</MEM_USAGE><CPU"
|
||||
"_USAGE>0</CPU_USAGE><MAX_DISK>0</MAX_DISK><MAX_MEM>0</MAX_MEM><MAX_CPU>0</"
|
||||
"MAX_CPU><FREE_DISK>0</FREE_DISK><FREE_MEM>0</FREE_MEM><FREE_CPU>0</FREE_CP"
|
||||
"U><USED_DISK>0</USED_DISK><USED_MEM>0</USED_MEM><USED_CPU>0</USED_CPU><RUN"
|
||||
"NING_VMS>0</RUNNING_VMS></HOST_SHARE><TEMPLATE></TEMPLATE></HOST><HOST><ID>3</ID><NAME>another "
|
||||
"name</NAME><STATE>0</STATE><IM_MAD>im_mad</IM_MAD><VM_MAD>vmm_mad</VM_MAD>"
|
||||
"<TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_MON_TIME><HOST_SHAR"
|
||||
"<VN_MAD>vnm_mad</VN_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_MON_TIME><HOST_SHAR"
|
||||
"E><DISK_USAGE>0</DISK_USAGE><MEM_USAGE>0</MEM_USAGE><CPU_USAGE"
|
||||
">0</CPU_USAGE><MAX_DISK>0</MAX_DISK><MAX_MEM>0</MAX_MEM><MAX_CPU>0</MAX_CP"
|
||||
"U><FREE_DISK>0</FREE_DISK><FREE_MEM>0</FREE_MEM><FREE_CPU>0</FREE_CPU><USE"
|
||||
"D_DISK>0</USED_DISK><USED_MEM>0</USED_MEM><USED_CPU>0</USED_CPU><RUNNING_V"
|
||||
"MS>0</RUNNING_VMS></HOST_SHARE><TEMPLATE></TEMPLATE></HOST><HOST><ID>4</ID><NAME>host</NAME><ST"
|
||||
"ATE>0</STATE><IM_MAD>im_mad</IM_MAD><VM_MAD>vmm_mad</VM_MAD><TM_MAD>tm_mad"
|
||||
"ATE>0</STATE><IM_MAD>im_mad</IM_MAD><VM_MAD>vmm_mad</VM_MAD><VN_MAD>vnm_mad</VN_MAD><TM_MAD>tm_mad"
|
||||
"</TM_MAD><LAST_MON_TIME>0</LAST_MON_TIME><HOST_SHARE>"
|
||||
"<DISK_USAGE>0</DISK_USAGE><MEM_USAGE>0</MEM_USAGE><CPU_USAGE>0</CPU_USAGE>"
|
||||
"<MAX_DISK>0</MAX_DISK><MAX_MEM>0</MAX_MEM><MAX_CPU>0</MAX_CPU><FREE_DISK>0"
|
||||
@ -90,28 +91,28 @@ const string xml_dump =
|
||||
|
||||
const string xml_dump_like_a =
|
||||
"<HOST_POOL><HOST><ID>0</ID><NAME>a</NAME><STATE>0</STATE><IM_MAD>im_mad</I"
|
||||
"M_MAD><VM_MAD>vmm_mad</VM_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0"
|
||||
"M_MAD><VM_MAD>vmm_mad</VM_MAD><VN_MAD>vnm_mad</VN_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0"
|
||||
"</LAST_MON_TIME><HOST_SHARE><DISK_USAGE>0</DISK_USAGE><MEM"
|
||||
"_USAGE>0</MEM_USAGE><CPU_USAGE>0</CPU_USAGE><MAX_DISK>0</MAX_DISK><MAX_MEM"
|
||||
">0</MAX_MEM><MAX_CPU>0</MAX_CPU><FREE_DISK>0</FREE_DISK><FREE_MEM>0</FREE_"
|
||||
"MEM><FREE_CPU>0</FREE_CPU><USED_DISK>0</USED_DISK><USED_MEM>0</USED_MEM><U"
|
||||
"SED_CPU>0</USED_CPU><RUNNING_VMS>0</RUNNING_VMS></HOST_SHARE><TEMPLATE></TEMPLATE></HOST><HOST>"
|
||||
"<ID>1</ID><NAME>a name</NAME><STATE>0</STATE><IM_MAD>im_mad</IM_MAD><VM_MA"
|
||||
"D>vmm_mad</VM_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_M"
|
||||
"D>vmm_mad</VM_MAD><VN_MAD>vnm_mad</VN_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_M"
|
||||
"ON_TIME><HOST_SHARE><DISK_USAGE>0</DISK_USAGE><MEM_USAGE>0</ME"
|
||||
"M_USAGE><CPU_USAGE>0</CPU_USAGE><MAX_DISK>0</MAX_DISK><MAX_MEM>0</MAX_MEM>"
|
||||
"<MAX_CPU>0</MAX_CPU><FREE_DISK>0</FREE_DISK><FREE_MEM>0</FREE_MEM><FREE_CP"
|
||||
"U>0</FREE_CPU><USED_DISK>0</USED_DISK><USED_MEM>0</USED_MEM><USED_CPU>0</U"
|
||||
"SED_CPU><RUNNING_VMS>0</RUNNING_VMS></HOST_SHARE><TEMPLATE></TEMPLATE></HOST><HOST><ID>2</ID><N"
|
||||
"AME>a_name</NAME><STATE>0</STATE><IM_MAD>im_mad</IM_MAD><VM_MAD>vmm_mad</V"
|
||||
"M_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_MON_TIME><HOS"
|
||||
"M_MAD><VN_MAD>vnm_mad</VN_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_MON_TIME><HOS"
|
||||
"T_SHARE><DISK_USAGE>0</DISK_USAGE><MEM_USAGE>0</MEM_USAGE><CPU"
|
||||
"_USAGE>0</CPU_USAGE><MAX_DISK>0</MAX_DISK><MAX_MEM>0</MAX_MEM><MAX_CPU>0</"
|
||||
"MAX_CPU><FREE_DISK>0</FREE_DISK><FREE_MEM>0</FREE_MEM><FREE_CPU>0</FREE_CP"
|
||||
"U><USED_DISK>0</USED_DISK><USED_MEM>0</USED_MEM><USED_CPU>0</USED_CPU><RUN"
|
||||
"NING_VMS>0</RUNNING_VMS></HOST_SHARE><TEMPLATE></TEMPLATE></HOST><HOST><ID>3</ID><NAME>another "
|
||||
"name</NAME><STATE>0</STATE><IM_MAD>im_mad</IM_MAD><VM_MAD>vmm_mad</VM_MAD>"
|
||||
"<TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_MON_TIME><HOST_SHAR"
|
||||
"<VN_MAD>vnm_mad</VN_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_MON_TIME><HOST_SHAR"
|
||||
"E><DISK_USAGE>0</DISK_USAGE><MEM_USAGE>0</MEM_USAGE><CPU_USAGE"
|
||||
">0</CPU_USAGE><MAX_DISK>0</MAX_DISK><MAX_MEM>0</MAX_MEM><MAX_CPU>0</MAX_CP"
|
||||
"U><FREE_DISK>0</FREE_DISK><FREE_MEM>0</FREE_MEM><FREE_CPU>0</FREE_CPU><USE"
|
||||
@ -119,10 +120,10 @@ const string xml_dump_like_a =
|
||||
"MS>0</RUNNING_VMS></HOST_SHARE><TEMPLATE></TEMPLATE></HOST></HOST_POOL>";
|
||||
|
||||
const string host0_updated =
|
||||
"<HOST><ID>0</ID><NAME>Host one</NAME><STATE>0</STATE><IM_MAD>im_mad</IM_MAD><VM_MAD>vmm_mad</VM_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_MON_TIME><HOST_SHARE><DISK_USAGE>0</DISK_USAGE><MEM_USAGE>0</MEM_USAGE><CPU_USAGE>0</CPU_USAGE><MAX_DISK>0</MAX_DISK><MAX_MEM>0</MAX_MEM><MAX_CPU>0</MAX_CPU><FREE_DISK>0</FREE_DISK><FREE_MEM>0</FREE_MEM><FREE_CPU>0</FREE_CPU><USED_DISK>0</USED_DISK><USED_MEM>0</USED_MEM><USED_CPU>0</USED_CPU><RUNNING_VMS>0</RUNNING_VMS></HOST_SHARE><TEMPLATE><ATT_A><![CDATA[VALUE_A]]></ATT_A><ATT_B><![CDATA[VALUE_B]]></ATT_B></TEMPLATE></HOST>";
|
||||
"<HOST><ID>0</ID><NAME>Host one</NAME><STATE>0</STATE><IM_MAD>im_mad</IM_MAD><VM_MAD>vmm_mad</VM_MAD><VN_MAD>vnm_mad</VN_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_MON_TIME><HOST_SHARE><DISK_USAGE>0</DISK_USAGE><MEM_USAGE>0</MEM_USAGE><CPU_USAGE>0</CPU_USAGE><MAX_DISK>0</MAX_DISK><MAX_MEM>0</MAX_MEM><MAX_CPU>0</MAX_CPU><FREE_DISK>0</FREE_DISK><FREE_MEM>0</FREE_MEM><FREE_CPU>0</FREE_CPU><USED_DISK>0</USED_DISK><USED_MEM>0</USED_MEM><USED_CPU>0</USED_CPU><RUNNING_VMS>0</RUNNING_VMS></HOST_SHARE><TEMPLATE><ATT_A><![CDATA[VALUE_A]]></ATT_A><ATT_B><![CDATA[VALUE_B]]></ATT_B></TEMPLATE></HOST>";
|
||||
|
||||
const string host_0_cluster =
|
||||
"<HOST><ID>0</ID><NAME>Host one</NAME><STATE>0</STATE><IM_MAD>im_mad</IM_MAD><VM_MAD>vmm_mad</VM_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_MON_TIME><CLUSTER>cluster_a</CLUSTER><HOST_SHARE><DISK_USAGE>0</DISK_USAGE><MEM_USAGE>0</MEM_USAGE><CPU_USAGE>0</CPU_USAGE><MAX_DISK>0</MAX_DISK><MAX_MEM>0</MAX_MEM><MAX_CPU>0</MAX_CPU><FREE_DISK>0</FREE_DISK><FREE_MEM>0</FREE_MEM><FREE_CPU>0</FREE_CPU><USED_DISK>0</USED_DISK><USED_MEM>0</USED_MEM><USED_CPU>0</USED_CPU><RUNNING_VMS>0</RUNNING_VMS></HOST_SHARE><TEMPLATE></TEMPLATE></HOST>";
|
||||
"<HOST><ID>0</ID><NAME>Host one</NAME><STATE>0</STATE><IM_MAD>im_mad</IM_MAD><VM_MAD>vmm_mad</VM_MAD><VN_MAD>vnm_mad</VN_MAD><TM_MAD>tm_mad</TM_MAD><LAST_MON_TIME>0</LAST_MON_TIME><CLUSTER>cluster_a</CLUSTER><HOST_SHARE><DISK_USAGE>0</DISK_USAGE><MEM_USAGE>0</MEM_USAGE><CPU_USAGE>0</CPU_USAGE><MAX_DISK>0</MAX_DISK><MAX_MEM>0</MAX_MEM><MAX_CPU>0</MAX_CPU><FREE_DISK>0</FREE_DISK><FREE_MEM>0</FREE_MEM><FREE_CPU>0</FREE_CPU><USED_DISK>0</USED_DISK><USED_MEM>0</USED_MEM><USED_CPU>0</USED_CPU><RUNNING_VMS>0</RUNNING_VMS></HOST_SHARE><TEMPLATE></TEMPLATE></HOST>";
|
||||
/* ************************************************************************* */
|
||||
/* ************************************************************************* */
|
||||
|
||||
@ -162,7 +163,7 @@ protected:
|
||||
int oid;
|
||||
string err;
|
||||
return ((HostPool*)pool)->allocate(&oid, names[index], im_mad,
|
||||
vmm_mad, tm_mad, err);
|
||||
vmm_mad, vnm_mad, tm_mad, err);
|
||||
};
|
||||
|
||||
void check(int index, PoolObjectSQL* obj)
|
||||
@ -184,7 +185,7 @@ protected:
|
||||
if( xml_str != xmls[index] )
|
||||
{
|
||||
cout << endl << xml_str << endl << "========"
|
||||
<< endl << xmls[index];
|
||||
<< endl << xmls[index] << endl;
|
||||
}
|
||||
//*/
|
||||
CPPUNIT_ASSERT( xml_str == xmls[index]);
|
||||
@ -242,16 +243,16 @@ public:
|
||||
|
||||
// If we try to allocate two hosts with the same name and drivers,
|
||||
// should fail
|
||||
rc = hp->allocate(&oid_0, names[0], im_mad, vmm_mad, tm_mad, err);
|
||||
rc = hp->allocate(&oid_0, names[0], im_mad, vmm_mad, vnm_mad, tm_mad, err);
|
||||
CPPUNIT_ASSERT( oid_0 == 0 );
|
||||
CPPUNIT_ASSERT( rc == oid_0 );
|
||||
|
||||
rc = hp->allocate(&oid_1, names[0], im_mad, vmm_mad, tm_mad, err);
|
||||
rc = hp->allocate(&oid_1, names[0], im_mad, vmm_mad, vnm_mad, tm_mad, err);
|
||||
CPPUNIT_ASSERT( oid_1 == -1 );
|
||||
CPPUNIT_ASSERT( rc == oid_1 );
|
||||
|
||||
// the hostname can not be repeated if the drivers change
|
||||
rc = hp->allocate(&oid_1, names[0], im_mad, vmm_mad, tm_mad_2, err);
|
||||
rc = hp->allocate(&oid_1, names[0], im_mad, vmm_mad, vnm_mad, tm_mad_2, err);
|
||||
CPPUNIT_ASSERT( oid_1 == -1 );
|
||||
CPPUNIT_ASSERT( rc == oid_1 );
|
||||
|
||||
@ -272,7 +273,7 @@ public:
|
||||
for(int i=0; i<5; i++)
|
||||
{
|
||||
((HostPool*)pool)->allocate(&oid, names[i],
|
||||
im_mad, vmm_mad, tm_mad, err);
|
||||
im_mad, vmm_mad, vnm_mad, tm_mad, err);
|
||||
}
|
||||
|
||||
ostringstream oss;
|
||||
@ -287,7 +288,7 @@ public:
|
||||
if( result != xml_dump )
|
||||
{
|
||||
cout << endl << result << endl << "========"
|
||||
<< endl << xml_dump;
|
||||
<< endl << xml_dump << endl;
|
||||
}
|
||||
//*/
|
||||
|
||||
@ -305,7 +306,7 @@ public:
|
||||
for(int i=0; i<5; i++)
|
||||
{
|
||||
((HostPool*)pool)->allocate(&oid, names[i],
|
||||
im_mad, vmm_mad, tm_mad, err);
|
||||
im_mad, vmm_mad, vnm_mad, tm_mad, err);
|
||||
}
|
||||
|
||||
|
||||
@ -321,7 +322,7 @@ public:
|
||||
if( result != xml_dump_like_a )
|
||||
{
|
||||
cout << endl << result << endl << "========"
|
||||
<< endl << xml_dump_like_a;
|
||||
<< endl << xml_dump_like_a << endl;
|
||||
}
|
||||
//*/
|
||||
|
||||
@ -346,7 +347,7 @@ public:
|
||||
{
|
||||
oss << "host" << i;
|
||||
|
||||
hp->allocate(&oid, oss.str().c_str(), im_mad, vmm_mad, tm_mad, err);
|
||||
hp->allocate(&oid, oss.str().c_str(), im_mad, vmm_mad, vnm_mad, tm_mad, err);
|
||||
CPPUNIT_ASSERT(oid == i);
|
||||
|
||||
if (i >=8 )
|
||||
@ -404,7 +405,7 @@ public:
|
||||
{
|
||||
oss << "host" << j;
|
||||
|
||||
hp->allocate(&oid, oss.str().c_str(),im_mad,vmm_mad,tm_mad,err);
|
||||
hp->allocate(&oid, oss.str().c_str(),im_mad,vmm_mad,vnm_mad,tm_mad,err);
|
||||
}
|
||||
|
||||
the_time2 = time(0) - the_time;
|
||||
@ -433,7 +434,7 @@ public:
|
||||
for (i=10000,oss.str(""); i<30000 ; i++,oss.str(""))
|
||||
{
|
||||
oss << "host" << i;
|
||||
hp->allocate(&oid,oss.str().c_str(),im_mad,vmm_mad,tm_mad,err);
|
||||
hp->allocate(&oid,oss.str().c_str(),im_mad,vmm_mad,vnm_mad,tm_mad,err);
|
||||
|
||||
host = hp->get(oid, false);
|
||||
|
||||
|
118
src/im_mad/remotes/vmware.d/vmware.rb
Executable file
118
src/im_mad/remotes/vmware.d/vmware.rb
Executable file
@ -0,0 +1,118 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Copyright 2010-2011, C12G Labs S.L #
|
||||
# #
|
||||
# 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. #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
ONE_LOCATION=ENV["ONE_LOCATION"] if !defined?(ONE_LOCATION)
|
||||
|
||||
if !ONE_LOCATION
|
||||
ETC_LOCATION = "/etc/one" if !defined?(ETC_LOCATION)
|
||||
RUBY_LIB_LOCATION = "/usr/lib/one/ruby" if !defined?(RUBY_LIB_LOCATION)
|
||||
else
|
||||
ETC_LOCATION = ONE_LOCATION+"/etc" if !defined?(ETC_LOCATION)
|
||||
RUBY_LIB_LOCATION = ONE_LOCATION+"/lib/ruby" if !defined?(RUBY_LIB_LOCATION)
|
||||
end
|
||||
|
||||
$: << RUBY_LIB_LOCATION
|
||||
|
||||
require 'OpenNebula'
|
||||
include OpenNebula
|
||||
|
||||
begin
|
||||
client = Client.new()
|
||||
rescue Exception => e
|
||||
puts "Error: #{e}"
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
def add_info(name, value)
|
||||
value = "0" if value.nil? or value.to_s.empty?
|
||||
@result_str << "#{name}=#{value} "
|
||||
end
|
||||
|
||||
def print_info
|
||||
puts @result_str
|
||||
end
|
||||
|
||||
@result_str = ""
|
||||
|
||||
@host = ARGV[2]
|
||||
|
||||
if !@host
|
||||
exit -1
|
||||
end
|
||||
|
||||
load ETC_LOCATION + "/vmwarerc"
|
||||
|
||||
if USERNAME.class!=String || PASSWORD.class!=String
|
||||
warn "Bad ESX credentials, aborting"
|
||||
exit -1
|
||||
end
|
||||
|
||||
data = perform_action("virsh -c #{LIBVIRT_URI} --readonly nodeinfo")
|
||||
|
||||
data.split(/\n/).each{|line|
|
||||
if line.match('^CPU\(s\)')
|
||||
$total_cpu = line.split(":")[1].strip.to_i * 100
|
||||
elsif line.match('^CPU frequency')
|
||||
$cpu_speed = line.split(":")[1].strip.split(" ")[0]
|
||||
elsif line.match('^Memory size')
|
||||
$total_memory = line.split(":")[1].strip.split(" ")[0]
|
||||
end
|
||||
}
|
||||
|
||||
# Loop through all vms
|
||||
used_memory = 0
|
||||
used_cpu = 0
|
||||
|
||||
vms = VirtualMachinePool.new(client)
|
||||
|
||||
rc = vms.info
|
||||
if OpenNebula.is_error?(rc)
|
||||
warn "Couldn't reach OpenNebula, aborting."
|
||||
exit -1
|
||||
end
|
||||
|
||||
vm_ids_array = vms.retrieve_elements("/VM_POOL/VM[STATE=3 or STATE=5]/HISTORY_RECORDS/HISTORY[HOSTNAME=\"#{@host}\"]/../ID")
|
||||
|
||||
if vm_ids_array
|
||||
vm_ids_array.each do |vm_id|
|
||||
vm=OpenNebula::VirtualMachine.new_with_id(vm_id, client)
|
||||
rc = vm.info
|
||||
|
||||
if OpenNebula.is_error?(rc)
|
||||
warn "Couldn't reach OpenNebula, aborting."
|
||||
exit -1
|
||||
end
|
||||
|
||||
used_memory = used_memory + (vm['TEMPLATE/MEMORY'].to_i * 1024)
|
||||
used_cpu = used_cpu + (vm['TEMPLATE/CPU'].to_f * 100)
|
||||
end
|
||||
end
|
||||
|
||||
# 80% of the total free calculated memory to take hypervisor into account
|
||||
free_memory = ($total_memory.to_i - used_memory) * 0.8
|
||||
# assume all the host's CPU is devoted to running Virtual Machines
|
||||
free_cpu = ($total_cpu.to_f - used_cpu)
|
||||
|
||||
add_info("HYPERVISOR","vmware")
|
||||
add_info("TOTALCPU",$total_cpu)
|
||||
add_info("FREECPU",free_cpu.to_i)
|
||||
add_info("CPUSPEED",$cpu_speed)
|
||||
add_info("TOTALMEMORY",$total_memory)
|
||||
add_info("FREEMEMORY",free_memory.to_i)
|
||||
|
||||
print_info
|
@ -54,12 +54,16 @@ class ImageDriver < OpenNebulaDriver
|
||||
@options={
|
||||
:concurrency => 10,
|
||||
:threaded => true,
|
||||
:retries => 0
|
||||
:retries => 0,
|
||||
:local_actions => {
|
||||
'MV' => nil,
|
||||
'CP' => nil,
|
||||
'RM' => nil,
|
||||
'MKFS' => nil
|
||||
}
|
||||
}.merge!(options)
|
||||
|
||||
super('', @options)
|
||||
|
||||
@actions_path = "#{VAR_LOCATION}/remotes/image/#{fs_type}"
|
||||
super("image/#{fs_type}", @options)
|
||||
|
||||
register_action(ACTION[:mv].to_sym, method("mv"))
|
||||
register_action(ACTION[:cp].to_sym, method("cp"))
|
||||
@ -69,19 +73,21 @@ class ImageDriver < OpenNebulaDriver
|
||||
|
||||
# Image Manager Protocol Actions (generic implementation
|
||||
def mv(id, src, dst)
|
||||
local_action("#{@actions_path}/mv #{src} #{dst} #{id}",id,ACTION[:mv])
|
||||
do_action("#{src} #{dst} #{id}", id, nil,
|
||||
ACTION[:mv])
|
||||
end
|
||||
|
||||
def cp(id, src)
|
||||
local_action("#{@actions_path}/cp #{src} #{id}",id,ACTION[:cp])
|
||||
do_action("#{src} #{id}", id, nil, ACTION[:cp])
|
||||
end
|
||||
|
||||
def rm(id, dst)
|
||||
local_action("#{@actions_path}/rm #{dst} #{id}",id,ACTION[:rm])
|
||||
do_action("#{dst} #{id}", id, nil, ACTION[:rm])
|
||||
end
|
||||
|
||||
def mkfs(id, fs, size)
|
||||
local_action("#{@actions_path}/mkfs #{fs} #{size} #{id}",id,ACTION[:mkfs])
|
||||
do_action("#{fs} #{size} #{id}", id, nil,
|
||||
ACTION[:mkfs])
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -41,8 +41,28 @@ DST=`generate_image_path`
|
||||
case $SRC in
|
||||
http://*)
|
||||
log "Downloading $SRC to the image repository"
|
||||
|
||||
exec_and_log "$WGET -O $DST $SRC" \
|
||||
"Error downloading $SRC"
|
||||
|
||||
exec_and_log "chmod 0660 $DST"
|
||||
;;
|
||||
|
||||
vmware://*)
|
||||
SRC=`echo $SRC|sed 's/vmware:\/\///g'`
|
||||
|
||||
if [ `check_restricted $SRC` -eq 1 ]; then
|
||||
log_error "Not allowed to copy images from $RESTRICTED_DIRS"
|
||||
error_message "Not allowed to copy image file $SRC"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
log "Copying local disk folder $SRC to the image repository"
|
||||
|
||||
exec_and_log "cp -rf $SRC $DST" \
|
||||
"Error copying $SRC to $DST"
|
||||
|
||||
exec_and_log "chmod 0770 $DST"
|
||||
;;
|
||||
|
||||
*)
|
||||
@ -53,13 +73,16 @@ http://*)
|
||||
fi
|
||||
|
||||
log "Copying local image $SRC to the image repository"
|
||||
|
||||
exec_and_log "cp -f $SRC $DST" \
|
||||
"Error copying $SRC to $DST"
|
||||
|
||||
exec_and_log "chmod 0660 $DST"
|
||||
;;
|
||||
esac
|
||||
|
||||
# ---------------- Get the size of the image & fix perms ------------
|
||||
exec_and_log "chmod 0660 $DST"
|
||||
|
||||
|
||||
SIZE=`fs_du $DST`
|
||||
|
||||
|
@ -82,4 +82,14 @@ function check_restricted {
|
||||
done
|
||||
|
||||
echo 0
|
||||
}
|
||||
|
||||
# Change the permissions of all the files inside directoriers (= VMware disks)
|
||||
function fix_owner_perms {
|
||||
|
||||
find $IMAGE_REPOSITORY_PATH -type d \
|
||||
-mindepth 1 \
|
||||
-maxdepth 1 \
|
||||
-execdir chown \
|
||||
-R $SUDO_USER '{}' \;
|
||||
}
|
@ -44,7 +44,6 @@ fi
|
||||
|
||||
# ------------ Move the image to the repository ------------
|
||||
|
||||
|
||||
case $SRC in
|
||||
http://*)
|
||||
log "Downloading $SRC to the image repository"
|
||||
@ -62,7 +61,12 @@ http://*)
|
||||
;;
|
||||
esac
|
||||
|
||||
exec_and_log "chmod 0660 $DST"
|
||||
if [ -d $DST ]; then
|
||||
exec_and_log "chmod 0770 $DST"
|
||||
fix_owner_perms
|
||||
else
|
||||
exec_and_log "chmod 0660 $DST"
|
||||
fi
|
||||
|
||||
# ---------------- Get the size of the image ------------
|
||||
SIZE=`fs_du $DST`
|
||||
|
@ -37,6 +37,6 @@ SRC=$1
|
||||
|
||||
if [ -e $SRC ] ; then
|
||||
log "Removing $SRC from the image repository"
|
||||
exec_and_log "rm $SRC" \
|
||||
exec_and_log "rm -r $SRC" \
|
||||
"Error deleting $SRC"
|
||||
fi
|
||||
|
@ -47,6 +47,7 @@ const string templates[] =
|
||||
static int hid = 123;
|
||||
static string hostname = "test_hostname";
|
||||
static string vmm_mad = "vmm_mad";
|
||||
static string vnm_mad = "vnm_mad";
|
||||
static string tm_mad = "tm_mad";
|
||||
static string vmdir = "vmdir";
|
||||
|
||||
@ -225,7 +226,7 @@ private:
|
||||
|
||||
vm->lock();
|
||||
|
||||
vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad);
|
||||
vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad);
|
||||
rc = vmpool->update_history(vm);
|
||||
CPPUNIT_ASSERT( rc == 0 );
|
||||
|
||||
@ -489,7 +490,7 @@ public:
|
||||
{
|
||||
vm = allocate_running(0);
|
||||
|
||||
vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad);
|
||||
vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad);
|
||||
|
||||
rc = vmpool->update_history(vm);
|
||||
CPPUNIT_ASSERT( rc == 0 );
|
||||
@ -573,7 +574,7 @@ public:
|
||||
{
|
||||
vm = allocate_running(0);
|
||||
|
||||
vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad);
|
||||
vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad);
|
||||
|
||||
rc = vmpool->update_history(vm);
|
||||
CPPUNIT_ASSERT( rc == 0 );
|
||||
@ -594,7 +595,7 @@ public:
|
||||
{
|
||||
vm = allocate_running(0);
|
||||
|
||||
vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad);
|
||||
vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad);
|
||||
|
||||
rc = vmpool->update_history(vm);
|
||||
CPPUNIT_ASSERT( rc == 0 );
|
||||
@ -615,7 +616,7 @@ public:
|
||||
{
|
||||
vm = allocate_running(0);
|
||||
|
||||
vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad);
|
||||
vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad);
|
||||
|
||||
rc = vmpool->update_history(vm);
|
||||
CPPUNIT_ASSERT( rc == 0 );
|
||||
@ -637,7 +638,7 @@ public:
|
||||
{
|
||||
vm = allocate_running(0);
|
||||
|
||||
vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad);
|
||||
vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad);
|
||||
|
||||
rc = vmpool->update_history(vm);
|
||||
CPPUNIT_ASSERT( rc == 0 );
|
||||
@ -661,7 +662,7 @@ public:
|
||||
{
|
||||
vm = allocate_running(0);
|
||||
|
||||
vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad);
|
||||
vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad);
|
||||
|
||||
rc = vmpool->update_history(vm);
|
||||
CPPUNIT_ASSERT( rc == 0 );
|
||||
@ -685,7 +686,7 @@ public:
|
||||
{
|
||||
vm = allocate_running(0);
|
||||
|
||||
vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad);
|
||||
vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad);
|
||||
|
||||
rc = vmpool->update_history(vm);
|
||||
CPPUNIT_ASSERT( rc == 0 );
|
||||
@ -749,7 +750,7 @@ public:
|
||||
{
|
||||
vm = allocate_running(0);
|
||||
|
||||
vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad);
|
||||
vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad);
|
||||
rc = vmpool->update_history(vm);
|
||||
CPPUNIT_ASSERT( rc == 0 );
|
||||
|
||||
@ -772,7 +773,7 @@ public:
|
||||
{
|
||||
vm = allocate_running(0);
|
||||
|
||||
vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad);
|
||||
vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad);
|
||||
rc = vmpool->update_history(vm);
|
||||
CPPUNIT_ASSERT( rc == 0 );
|
||||
|
||||
@ -795,7 +796,7 @@ public:
|
||||
{
|
||||
vm = allocate_running(0);
|
||||
|
||||
vm->add_history(hid,hostname,vmdir,vmm_mad,tm_mad);
|
||||
vm->add_history(hid,hostname,vmdir,vmm_mad,vnm_mad,tm_mad);
|
||||
rc = vmpool->update_history(vm);
|
||||
CPPUNIT_ASSERT( rc == 0 );
|
||||
|
||||
|
@ -16,7 +16,6 @@
|
||||
require 'thread'
|
||||
|
||||
=begin rdoc
|
||||
Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org)
|
||||
|
||||
This class provides support to handle actions. Class methods, or actions, can be
|
||||
registered in the action manager. The manager will wait for actions to be
|
||||
|
194
src/mad/ruby/DriverExecHelper.rb
Normal file
194
src/mad/ruby/DriverExecHelper.rb
Normal file
@ -0,0 +1,194 @@
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
# This module provides an abstraction to generate an execution context for
|
||||
# OpenNebula Drivers. The module has been designed to be included as part
|
||||
# of a driver and not to be used standalone.
|
||||
module DriverExecHelper
|
||||
# Action result strings for messages
|
||||
RESULT = {
|
||||
:success => "SUCCESS",
|
||||
:failure => "FAILURE"
|
||||
}
|
||||
|
||||
def self.failed?(rc_str)
|
||||
return rc_str == RESULT[:failure]
|
||||
end
|
||||
|
||||
#Initialize module variables
|
||||
def initialize_helper(directory, options)
|
||||
@config = read_configuration
|
||||
@remote_scripts_base_path = @config['SCRIPTS_REMOTE_DIR']
|
||||
|
||||
@local_actions = options[:local_actions]
|
||||
|
||||
if ENV['ONE_LOCATION'] == nil
|
||||
@local_scripts_base_path = "/var/lib/one/remotes"
|
||||
else
|
||||
@local_scripts_base_path = "#{ENV['ONE_LOCATION']}/var/remotes"
|
||||
end
|
||||
|
||||
# dummy paths
|
||||
@remote_scripts_path = File.join(@remote_scripts_base_path, directory)
|
||||
@local_scripts_path = File.join(@local_scripts_base_path, directory)
|
||||
end
|
||||
|
||||
#
|
||||
# METHODS FOR COMMAND LINE & ACTION PATHS
|
||||
#
|
||||
# Given the action name and the parameter returns full path of the script
|
||||
# and appends its parameters. It uses @local_actions hash to know if the
|
||||
# actions is remote or local. If the local actions has defined an special
|
||||
# script name this is used, otherwise the action name in downcase is
|
||||
# used as the script name.
|
||||
#
|
||||
# @param [String, Symbol] action name of the action
|
||||
# @param [String] parameters arguments for the script
|
||||
# @param [String, nil] default_name alternative name for the script
|
||||
# @return [String] command line needed to execute the action
|
||||
def action_command_line(action, parameters, default_name=nil)
|
||||
if action_is_local? action
|
||||
script_path=@local_scripts_path
|
||||
else
|
||||
script_path=@remote_scripts_path
|
||||
end
|
||||
|
||||
File.join(script_path, action_script_name(action, default_name))+
|
||||
" "+parameters
|
||||
end
|
||||
|
||||
# True if the action is meant to be executed locally
|
||||
#
|
||||
# @param [String, Symbol] action name of the action
|
||||
def action_is_local?(action)
|
||||
@local_actions.include? action.to_s.upcase
|
||||
end
|
||||
|
||||
# Name of the script file for the given action
|
||||
#
|
||||
# @param [String, Symbol] action name of the action
|
||||
# @param [String, nil] default_name alternative name for the script
|
||||
def action_script_name(action, default_name=nil)
|
||||
name=@local_actions[action.to_s.upcase]
|
||||
|
||||
if name
|
||||
name
|
||||
else
|
||||
default_name || action.to_s.downcase
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
# METHODS FOR LOGS & COMMAND OUTPUT
|
||||
#
|
||||
# Sends a log message to ONE. The +message+ can be multiline, it will
|
||||
# be automatically splitted by lines.
|
||||
def log(number, message)
|
||||
in_error_message=false
|
||||
msg=message.strip
|
||||
msg.each_line {|line|
|
||||
severity='I'
|
||||
|
||||
l=line.strip
|
||||
|
||||
if l=='ERROR MESSAGE --8<------'
|
||||
in_error_message=true
|
||||
next
|
||||
elsif l=='ERROR MESSAGE ------>8--'
|
||||
in_error_message=false
|
||||
next
|
||||
else
|
||||
if in_error_message
|
||||
severity='E'
|
||||
elsif line.match(/^(ERROR|DEBUG|INFO):(.*)$/)
|
||||
line=$2
|
||||
case $1
|
||||
when 'ERROR'
|
||||
severity='E'
|
||||
when 'DEBUG'
|
||||
severity='D'
|
||||
when 'INFO'
|
||||
severity='I'
|
||||
else
|
||||
severity='I'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
send_message("LOG", severity, number, line.strip)
|
||||
}
|
||||
end
|
||||
|
||||
# Generates a proc with that calls log with a hardcoded number. It will
|
||||
# be used to add loging to command actions
|
||||
def log_method(num)
|
||||
lambda {|message|
|
||||
log(num, message)
|
||||
}
|
||||
end
|
||||
|
||||
#This method returns the result in terms
|
||||
def get_info_from_execution(command_exe)
|
||||
if command_exe.code == 0
|
||||
result = RESULT[:success]
|
||||
info = command_exe.stdout
|
||||
else
|
||||
result = RESULT[:failure]
|
||||
info = command_exe.get_error_message
|
||||
end
|
||||
|
||||
info = "-" if info == nil || info.empty?
|
||||
|
||||
[result, info]
|
||||
end
|
||||
|
||||
#
|
||||
#
|
||||
# Simple parser for the config file generated by OpenNebula
|
||||
def read_configuration
|
||||
one_config=nil
|
||||
|
||||
if ENV['ONE_LOCATION']
|
||||
one_config = ENV['ONE_LOCATION']+'/var/config'
|
||||
else
|
||||
one_config = '/var/lib/one/config'
|
||||
end
|
||||
|
||||
config=Hash.new
|
||||
cfg=''
|
||||
|
||||
begin
|
||||
open(one_config) do |file|
|
||||
cfg=file.read
|
||||
end
|
||||
|
||||
cfg.split(/\n/).each do |line|
|
||||
m=line.match(/^([^=]+)=(.*)$/)
|
||||
|
||||
if m
|
||||
name=m[1].strip.upcase
|
||||
value=m[2].strip
|
||||
config[name]=value
|
||||
end
|
||||
end
|
||||
rescue Exception => e
|
||||
STDERR.puts "Error reading config: #{e.inspect}"
|
||||
STDERR.flush
|
||||
end
|
||||
|
||||
config
|
||||
end
|
||||
end
|
@ -17,9 +17,7 @@
|
||||
require "ActionManager"
|
||||
require "CommandManager"
|
||||
|
||||
# Author:: dsa-research.org
|
||||
# Copyright:: (c) OpenNebula Project Leads (OpenNebula.org)
|
||||
# License:: Apache License
|
||||
require "DriverExecHelper"
|
||||
|
||||
# This class provides basic messaging and logging functionality
|
||||
# to implement OpenNebula Drivers. A driver is a program that
|
||||
@ -30,11 +28,116 @@ require "CommandManager"
|
||||
# for each action it wants to receive. The method must be associated
|
||||
# with the action name through the register_action function
|
||||
class OpenNebulaDriver < ActionManager
|
||||
include DriverExecHelper
|
||||
|
||||
# @return [String] Base path for scripts
|
||||
attr_reader :local_scripts_base_path, :remote_scripts_base_path
|
||||
# @return [String] Path for scripts
|
||||
attr_reader :local_scripts_path, :remote_scripts_path
|
||||
|
||||
# Initialize OpenNebulaDriver object
|
||||
#
|
||||
# @param [String] directory path inside the remotes directory where the
|
||||
# scripts are located
|
||||
# @param [Hash] options named options to change the object's behaviour
|
||||
# @option options [Number] :concurrency (10) max number of threads
|
||||
# @option options [Boolean] :threaded (true) enables or disables threads
|
||||
# @option options [Number] :retries (0) number of retries to copy scripts
|
||||
# to the remote host
|
||||
# @option options [Hash] :local_actions ({}) hash with the actions
|
||||
# executed locally and the name of the script if it differs from the
|
||||
# default one. This hash can be constructed using {parse_actions_list}
|
||||
def initialize(directory, options={})
|
||||
@options={
|
||||
:concurrency => 10,
|
||||
:threaded => true,
|
||||
:retries => 0,
|
||||
:local_actions => {}
|
||||
}.merge!(options)
|
||||
|
||||
super(@options[:concurrency], @options[:threaded])
|
||||
|
||||
@retries = @options[:retries]
|
||||
|
||||
@send_mutex = Mutex.new
|
||||
|
||||
#Set default values
|
||||
initialize_helper(directory, @options)
|
||||
|
||||
register_action(:INIT, method("init"))
|
||||
end
|
||||
|
||||
# Sends a message to the OpenNebula core through stdout
|
||||
def send_message(action="-", result=RESULT[:failure], id="-", info="-")
|
||||
@send_mutex.synchronize {
|
||||
STDOUT.puts "#{action} #{result} #{id} #{info}"
|
||||
STDOUT.flush
|
||||
}
|
||||
end
|
||||
|
||||
# Calls remotes or local action checking the action name and
|
||||
# @local_actions. Optional arguments can be specified as a hash
|
||||
#
|
||||
# @param [String] parameters arguments passed to the script
|
||||
# @param [Number, String] id action identifier
|
||||
# @param [String] host hostname where the action is going to be executed
|
||||
# @param [String, Symbol] aname name of the action
|
||||
# @param [Hash] ops extra options for the command
|
||||
# @option ops [String] :stdin text to be writen to stdin
|
||||
# @option ops [String] :script_name default script name for the action,
|
||||
# action name is used by defaults
|
||||
# @option ops [String] :respond if defined will send result to ONE core
|
||||
def do_action(parameters, id, host, aname, ops={})
|
||||
options={
|
||||
:stdin => nil,
|
||||
:script_name => nil,
|
||||
:respond => true,
|
||||
:ssh_stream => nil
|
||||
}.merge(ops)
|
||||
|
||||
params = parameters+" #{id} #{host}"
|
||||
command = action_command_line(aname, params, options[:script_name])
|
||||
|
||||
if action_is_local?(aname)
|
||||
execution = LocalCommand.run(command, log_method(id))
|
||||
elsif options[:ssh_stream]
|
||||
if options[:stdin]
|
||||
cmdin = "cat << EOT | #{command}"
|
||||
stdin = "#{options[:stdin]}\nEOT\n"
|
||||
else
|
||||
cmdin = command
|
||||
stdin = nil
|
||||
end
|
||||
|
||||
execution = options[:ssh_stream].run(cmdin, stdin, command)
|
||||
|
||||
else
|
||||
execution = RemotesCommand.run(command,
|
||||
host,
|
||||
@remote_scripts_base_path,
|
||||
log_method(id),
|
||||
options[:stdin],
|
||||
@retries)
|
||||
end
|
||||
|
||||
result, info = get_info_from_execution(execution)
|
||||
|
||||
if options[:respond]
|
||||
send_message(aname,result,id,info)
|
||||
end
|
||||
|
||||
[result, info]
|
||||
end
|
||||
|
||||
|
||||
# Start the driver. Reads from STDIN and executes methods associated with
|
||||
# the messages
|
||||
def start_driver
|
||||
loop_thread = Thread.new { loop }
|
||||
start_listener
|
||||
loop_thread.kill
|
||||
end
|
||||
|
||||
# This function parses a string with this form:
|
||||
#
|
||||
# 'deploy,shutdown,poll=poll_ganglia, cancel '
|
||||
@ -69,238 +172,6 @@ class OpenNebulaDriver < ActionManager
|
||||
actions
|
||||
end
|
||||
|
||||
# Action result strings for messages
|
||||
RESULT = {
|
||||
:success => "SUCCESS",
|
||||
:failure => "FAILURE"
|
||||
}
|
||||
|
||||
# Initialize OpenNebulaDriver object
|
||||
#
|
||||
# @param [String] directory path inside the remotes directory where the
|
||||
# scripts are located
|
||||
# @param [Hash] options named options to change the object's behaviour
|
||||
# @option options [Number] :concurrency (10) max number of threads
|
||||
# @option options [Boolean] :threaded (true) enables or disables threads
|
||||
# @option options [Number] :retries (0) number of retries to copy scripts
|
||||
# to the remote host
|
||||
# @option options [Hash] :local_actions ({}) hash with the actions
|
||||
# executed locally and the name of the script if it differs from the
|
||||
# default one. This hash can be constructed using {parse_actions_list}
|
||||
def initialize(directory, options={})
|
||||
@options={
|
||||
:concurrency => 10,
|
||||
:threaded => true,
|
||||
:retries => 0,
|
||||
:local_actions => {}
|
||||
}.merge!(options)
|
||||
|
||||
super(@options[:concurrency], @options[:threaded])
|
||||
|
||||
@retries = @options[:retries]
|
||||
@local_actions = @options[:local_actions]
|
||||
|
||||
@send_mutex = Mutex.new
|
||||
|
||||
# set default values
|
||||
@config = read_configuration
|
||||
@remote_scripts_base_path = @config['SCRIPTS_REMOTE_DIR']
|
||||
|
||||
if ENV['ONE_LOCATION'] == nil
|
||||
@local_scripts_base_path = "/var/lib/one/remotes"
|
||||
else
|
||||
@local_scripts_base_path = "#{ENV['ONE_LOCATION']}/var/remotes"
|
||||
end
|
||||
|
||||
# dummy paths
|
||||
@remote_scripts_path = File.join(@remote_scripts_base_path, directory)
|
||||
@local_scripts_path = File.join(@local_scripts_base_path, directory)
|
||||
|
||||
register_action(:INIT, method("init"))
|
||||
end
|
||||
|
||||
# Sends a message to the OpenNebula core through stdout
|
||||
def send_message(action="-", result=RESULT[:failure], id="-", info="-")
|
||||
@send_mutex.synchronize {
|
||||
STDOUT.puts "#{action} #{result} #{id} #{info}"
|
||||
STDOUT.flush
|
||||
}
|
||||
end
|
||||
|
||||
# Calls remotes or local action checking the action name and
|
||||
# @local_actions. Optional arguments can be specified as a hash
|
||||
#
|
||||
# @param [String] parameters arguments passed to the script
|
||||
# @param [Number, String] id action identifier
|
||||
# @param [String] host hostname where the action is going to be executed
|
||||
# @param [String, Symbol] aname name of the action
|
||||
# @param [Hash] ops extra options for the command
|
||||
# @option ops [String] :stdin text to be writen to stdin
|
||||
# @option ops [String] :script_name default script name for the action,
|
||||
# action name is used by defaults
|
||||
def do_action(parameters, id, host, aname, ops={})
|
||||
options={
|
||||
:stdin => nil,
|
||||
:script_name => nil
|
||||
}.merge(ops)
|
||||
|
||||
params=parameters+" #{id} #{host}"
|
||||
|
||||
command=action_command_line(aname, params, options[:script_name])
|
||||
|
||||
if action_is_local? aname
|
||||
local_action(command, id, aname)
|
||||
else
|
||||
remotes_action(command, id, host, aname, @remote_scripts_base_path,
|
||||
options[:stdin])
|
||||
end
|
||||
end
|
||||
|
||||
# Given the action name and the parameter returns full path of the script
|
||||
# and appends its parameters. It uses @local_actions hash to know if the
|
||||
# actions is remote or local. If the local actions has defined an special
|
||||
# script name this is used, otherwise the action name in downcase is
|
||||
# used as the script name.
|
||||
#
|
||||
# @param [String, Symbol] action name of the action
|
||||
# @param [String] parameters arguments for the script
|
||||
# @param [String, nil] default_name alternative name for the script
|
||||
# @return [String] command line needed to execute the action
|
||||
def action_command_line(action, parameters, default_name=nil)
|
||||
if action_is_local? action
|
||||
script_path=@local_scripts_path
|
||||
else
|
||||
script_path=@remote_scripts_path
|
||||
end
|
||||
|
||||
File.join(script_path, action_script_name(action, default_name))+
|
||||
" "+parameters
|
||||
end
|
||||
|
||||
# True if the action is meant to be executed locally
|
||||
#
|
||||
# @param [String, Symbol] action name of the action
|
||||
def action_is_local?(action)
|
||||
@local_actions.include? action.to_s.upcase
|
||||
end
|
||||
|
||||
# Name of the script file for the given action
|
||||
#
|
||||
# @param [String, Symbol] action name of the action
|
||||
# @param [String, nil] default_name alternative name for the script
|
||||
def action_script_name(action, default_name=nil)
|
||||
name=@local_actions[action.to_s.upcase]
|
||||
|
||||
if name
|
||||
name
|
||||
else
|
||||
default_name || action.to_s.downcase
|
||||
end
|
||||
end
|
||||
|
||||
# Execute a command associated to an action and id in a remote host.
|
||||
#
|
||||
# @param [String] command command line to execute the script
|
||||
# @param [Number, String] id action identifier
|
||||
# @param [String] host hostname where the action is going to be executed
|
||||
# @param [String, Symbol] aname name of the action
|
||||
# @param [String] remote_dir path where the remotes reside
|
||||
# @param [String, nil] std_in input of the string from the STDIN
|
||||
def remotes_action(command, id, host, aname, remote_dir, std_in=nil)
|
||||
command_exe = RemotesCommand.run(command,
|
||||
host,
|
||||
remote_dir,
|
||||
log_method(id),
|
||||
std_in,
|
||||
@retries)
|
||||
if command_exe.code == 0
|
||||
result = RESULT[:success]
|
||||
info = command_exe.stdout
|
||||
else
|
||||
result = RESULT[:failure]
|
||||
info = command_exe.get_error_message
|
||||
end
|
||||
|
||||
info = "-" if info == nil || info.empty?
|
||||
|
||||
send_message(aname,result,id,info)
|
||||
end
|
||||
|
||||
# Execute a command associated to an action and id on localhost
|
||||
#
|
||||
# @param [String] command command line to execute the script
|
||||
# @param [Number, String] id action identifier
|
||||
# @param [String, Symbol] aname name of the action
|
||||
def local_action(command, id, aname)
|
||||
command_exe = LocalCommand.run(command, log_method(id))
|
||||
|
||||
if command_exe.code == 0
|
||||
result = RESULT[:success]
|
||||
info = command_exe.stdout
|
||||
else
|
||||
result = RESULT[:failure]
|
||||
info = command_exe.get_error_message
|
||||
end
|
||||
|
||||
info = "-" if info == nil || info.empty?
|
||||
|
||||
send_message(aname,result,id,info)
|
||||
end
|
||||
|
||||
# Sends a log message to ONE. The +message+ can be multiline, it will
|
||||
# be automatically splitted by lines.
|
||||
def log(number, message)
|
||||
in_error_message=false
|
||||
msg=message.strip
|
||||
msg.each_line {|line|
|
||||
severity='I'
|
||||
|
||||
l=line.strip
|
||||
|
||||
if l=='ERROR MESSAGE --8<------'
|
||||
in_error_message=true
|
||||
next
|
||||
elsif l=='ERROR MESSAGE ------>8--'
|
||||
in_error_message=false
|
||||
next
|
||||
else
|
||||
if in_error_message
|
||||
severity='E'
|
||||
elsif line.match(/^(ERROR|DEBUG|INFO):(.*)$/)
|
||||
line=$2
|
||||
case $1
|
||||
when 'ERROR'
|
||||
severity='E'
|
||||
when 'DEBUG'
|
||||
severity='D'
|
||||
when 'INFO'
|
||||
severity='I'
|
||||
else
|
||||
severity='I'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
send_message("LOG", severity, number, line.strip)
|
||||
}
|
||||
end
|
||||
|
||||
# Generates a proc with that calls log with a hardcoded number. It will
|
||||
# be used to add loging to command actions
|
||||
def log_method(num)
|
||||
lambda {|message|
|
||||
log(num, message)
|
||||
}
|
||||
end
|
||||
|
||||
# Start the driver. Reads from STDIN and executes methods associated with
|
||||
# the messages
|
||||
def start_driver
|
||||
loop_thread = Thread.new { loop }
|
||||
start_listener
|
||||
loop_thread.kill
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def init
|
||||
@ -333,40 +204,6 @@ private
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def read_configuration
|
||||
one_config=nil
|
||||
|
||||
if ENV['ONE_LOCATION']
|
||||
one_config=ENV['ONE_LOCATION']+'/var/config'
|
||||
else
|
||||
one_config='/var/lib/one/config'
|
||||
end
|
||||
|
||||
config=Hash.new
|
||||
cfg=''
|
||||
|
||||
begin
|
||||
open(one_config) do |file|
|
||||
cfg=file.read
|
||||
end
|
||||
|
||||
cfg.split(/\n/).each do |line|
|
||||
m=line.match(/^([^=]+)=(.*)$/)
|
||||
|
||||
if m
|
||||
name=m[1].strip.upcase
|
||||
value=m[2].strip
|
||||
config[name]=value
|
||||
end
|
||||
end
|
||||
rescue Exception => e
|
||||
STDERR.puts "Error reading config: #{e.inspect}"
|
||||
STDERR.flush
|
||||
end
|
||||
|
||||
config
|
||||
end
|
||||
end
|
||||
|
||||
################################################################
|
||||
|
@ -15,6 +15,8 @@
|
||||
#--------------------------------------------------------------------------- #
|
||||
require "OpenNebulaDriver"
|
||||
require "CommandManager"
|
||||
require 'base64'
|
||||
require 'rexml/document'
|
||||
|
||||
# Author:: dsa-research.org
|
||||
# Copyright:: (c) 2011 Universidad Computense de Madrid
|
||||
@ -85,26 +87,15 @@ class VirtualMachineDriver < OpenNebulaDriver
|
||||
register_action(ACTION[:poll].to_sym, method("poll"))
|
||||
end
|
||||
|
||||
# Converts a deployment file from its remote path to the local (front-end)
|
||||
# path
|
||||
def get_local_deployment_file(rfile)
|
||||
lfile = nil
|
||||
# Decodes the encoded XML driver message received from the core
|
||||
#
|
||||
# @param [String] drv_message the driver message
|
||||
# @return [REXML::Element] the root element of the decoded XML message
|
||||
def decode(drv_message)
|
||||
message = Base64.decode64(drv_message)
|
||||
xml_doc = REXML::Document.new(message)
|
||||
|
||||
one_location = ENV["ONE_LOCATION"]
|
||||
|
||||
if one_location == nil
|
||||
var_location = "/var/lib/one/"
|
||||
else
|
||||
var_location = one_location + "/var/"
|
||||
end
|
||||
|
||||
m = rfile.match(/.*?\/(\d+)\/images\/(deployment.\d+)$/)
|
||||
|
||||
lfile = "#{var_location}#{m[1]}/#{m[2]}" if m
|
||||
|
||||
lfile = nil if lfile and !File.exists?(lfile)
|
||||
|
||||
return lfile
|
||||
xml_doc.root
|
||||
end
|
||||
|
||||
# Execute a command associated to an action and id in a remote host.
|
||||
@ -118,37 +109,37 @@ class VirtualMachineDriver < OpenNebulaDriver
|
||||
end
|
||||
|
||||
# Virtual Machine Manager Protocol Actions (generic implementation)
|
||||
def deploy(id, host, remote_dfile, not_used)
|
||||
def deploy(id, drv_message)
|
||||
error = "Action not implemented by driver #{self.class}"
|
||||
send_message(ACTION[:deploy],RESULT[:failure],id,error)
|
||||
end
|
||||
|
||||
def shutdown(id, host, deploy_id, not_used)
|
||||
def shutdown(id, drv_message)
|
||||
error = "Action not implemented by driver #{self.class}"
|
||||
send_message(ACTION[:shutdown],RESULT[:failure],id,error)
|
||||
end
|
||||
|
||||
def cancel(id, host, deploy_id, not_used)
|
||||
def cancel(id, drv_message)
|
||||
error = "Action not implemented by driver #{self.class}"
|
||||
send_message(ACTION[:cancel],RESULT[:failure],id,error)
|
||||
end
|
||||
|
||||
def save(id, host, deploy_id, file)
|
||||
def save(id, drv_message)
|
||||
error = "Action not implemented by driver #{self.class}"
|
||||
send_message(ACTION[:save],RESULT[:failure],id,error)
|
||||
end
|
||||
|
||||
def restore(id, host, deploy_id, file)
|
||||
def restore(id, drv_message)
|
||||
error = "Action not implemented by driver #{self.class}"
|
||||
send_message(ACTION[:restore],RESULT[:failure],id,error)
|
||||
end
|
||||
|
||||
def migrate(id, host, deploy_id, dest_host)
|
||||
def migrate(id, drv_message)
|
||||
error = "Action not implemented by driver #{self.class}"
|
||||
send_message(ACTION[:migrate],RESULT[:failure],id,error)
|
||||
end
|
||||
|
||||
def poll(id, host, deploy_id, not_used)
|
||||
def poll(id, drv_message)
|
||||
error = "Action not implemented by driver #{self.class}"
|
||||
send_message(ACTION[:poll],RESULT[:failure],id,error)
|
||||
end
|
||||
|
@ -43,11 +43,18 @@ module OpenNebula
|
||||
|
||||
# This function is used to pass error message to the mad
|
||||
def self.error_message(message)
|
||||
STDERR.puts "ERROR MESSAGE --8<------"
|
||||
STDERR.puts message
|
||||
STDERR.puts "ERROR MESSAGE ------>8--"
|
||||
STDERR.puts format_error_message(message)
|
||||
end
|
||||
|
||||
#This function formats an error message for OpenNebula Copyright e
|
||||
def self.format_error_message(message)
|
||||
error_str = "ERROR MESSAGE --8<------\n"
|
||||
error_str << message
|
||||
error_str << "\nERROR MESSAGE ------>8--"
|
||||
|
||||
return error_str
|
||||
end
|
||||
|
||||
# Executes a command, if it fails returns error message and exits
|
||||
# If a second parameter is present it is used as the error message when
|
||||
# the command fails
|
||||
|
238
src/mad/ruby/ssh_stream.rb
Normal file
238
src/mad/ruby/ssh_stream.rb
Normal file
@ -0,0 +1,238 @@
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
require 'CommandManager'
|
||||
require 'open3'
|
||||
require 'scripts_common'
|
||||
|
||||
class SshStream
|
||||
attr_reader :stream_out, :stream_err, :stdin
|
||||
attr_reader :out, :err
|
||||
|
||||
#
|
||||
#
|
||||
EOF_ERR = "EOF_ERR"
|
||||
EOF_OUT = "EOF_OUT"
|
||||
RC_STR = "ExitCode: "
|
||||
SSH_RC_STR = "ExitSSHCode: "
|
||||
|
||||
EOF_CMD = "echo \"#{RC_STR}$? #{EOF_ERR}\" 1>&2; echo \"#{EOF_OUT}\""
|
||||
SSH_CMD = "ssh"
|
||||
#
|
||||
#
|
||||
#
|
||||
def initialize(host)
|
||||
@host = host
|
||||
end
|
||||
|
||||
def opened?
|
||||
defined?(@stdin)
|
||||
end
|
||||
|
||||
def alive?
|
||||
@alive == true
|
||||
end
|
||||
|
||||
def open
|
||||
@stdin, @stdout, @stderr=Open3::popen3("#{SSH_CMD} #{@host} bash -s ; echo #{SSH_RC_STR} $? 1>&2")
|
||||
|
||||
@stream_out = ""
|
||||
@stream_err = ""
|
||||
|
||||
@out = ""
|
||||
@err = ""
|
||||
|
||||
@alive = true
|
||||
end
|
||||
|
||||
def close
|
||||
begin
|
||||
@stdin.puts "\nexit"
|
||||
rescue #rescue from EPIPE if ssh command exited already
|
||||
end
|
||||
|
||||
@stdin.close if not @stdin.closed?
|
||||
@stdout.close if not @stdout.closed?
|
||||
@stderr.close if not @stderr.closed?
|
||||
|
||||
@alive = false
|
||||
end
|
||||
|
||||
def exec(command)
|
||||
return if ! @alive
|
||||
|
||||
@out = ""
|
||||
@err = ""
|
||||
|
||||
begin
|
||||
cmd="(#{command}); #{EOF_CMD}"
|
||||
|
||||
sliced=cmd.scan(/.{1,100}/)
|
||||
|
||||
sliced.each do |slice|
|
||||
@stdin.write slice
|
||||
@stdin.flush
|
||||
end
|
||||
|
||||
@stdin.write "\n"
|
||||
@stdin.flush
|
||||
rescue
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def wait_for_command
|
||||
done_out = false
|
||||
done_err = false
|
||||
|
||||
code = -1
|
||||
|
||||
while not (done_out and done_err ) and @alive
|
||||
rc, rw, re= IO.select([@stdout, @stderr],[],[])
|
||||
|
||||
rc.each { |fd|
|
||||
begin
|
||||
c = fd.read_nonblock(100)
|
||||
next if !c
|
||||
rescue #rescue from EOF if ssh command finishes and closes fds
|
||||
next
|
||||
end
|
||||
|
||||
if fd == @stdout
|
||||
@out << c
|
||||
done_out = true if @out.slice!("#{EOF_OUT}\n")
|
||||
else
|
||||
@err << c
|
||||
|
||||
tmp = @err.scan(/^#{SSH_RC_STR}(\d+)$/)
|
||||
|
||||
if tmp[0]
|
||||
message = "Error connecting to #{@host}"
|
||||
code = tmp[0][0].to_i
|
||||
|
||||
@err << OpenNebula.format_error_message(message)
|
||||
|
||||
@alive = false
|
||||
break
|
||||
end
|
||||
|
||||
tmp = @err.scan(/^#{RC_STR}(\d*) #{EOF_ERR}\n/)
|
||||
|
||||
if tmp[0]
|
||||
code = tmp[0][0].to_i
|
||||
done_err = true
|
||||
|
||||
@err.slice!(" #{EOF_ERR}\n")
|
||||
end
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
@stream_out << @out
|
||||
@stream_err << @err
|
||||
|
||||
return code
|
||||
end
|
||||
|
||||
def exec_and_wait(command)
|
||||
exec(command)
|
||||
wait_for_command
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
class SshStreamCommand < RemotesCommand
|
||||
def initialize(host, remote_dir, logger=nil, stdin=nil)
|
||||
super('true', host, logger, stdin)
|
||||
|
||||
@remote_dir = remote_dir
|
||||
@stream = SshStream.new(host)
|
||||
|
||||
@stream.open
|
||||
end
|
||||
|
||||
def run(command, stdin=nil, base_cmd = nil)
|
||||
@stream.open unless @stream.opened?
|
||||
|
||||
if base_cmd #Check if base command is on remote host
|
||||
chk_cmd = "if [ ! -x \"#{base_cmd.match(/\S*/)[0]}\" ]; \
|
||||
then exit #{MAGIC_RC} 1>&2; \
|
||||
fi"
|
||||
|
||||
if @stream.exec_and_wait(chk_cmd) == MAGIC_RC
|
||||
RemotesCommand.update_remotes(@host, @remote_dir, @logger)
|
||||
end
|
||||
end
|
||||
|
||||
@stream.exec(command)
|
||||
@stream.stdin.write(stdin) if stdin
|
||||
|
||||
@code = @stream.wait_for_command
|
||||
|
||||
@stdout = @stream.out
|
||||
@stderr = @stream.err
|
||||
|
||||
if @code != 0
|
||||
log("Command execution fail: #{command}")
|
||||
end
|
||||
|
||||
log(@stderr)
|
||||
|
||||
return self
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if $0 == __FILE__
|
||||
|
||||
ssh=SshStream.new('localhost')
|
||||
|
||||
ssh.open
|
||||
|
||||
ssh.exec("date | tee /tmp/test.javi")
|
||||
code=ssh.wait_for_command
|
||||
|
||||
puts "Code: #{code}"
|
||||
puts "output: #{ssh.out}"
|
||||
|
||||
ssh.exec "cat << EOT | cat"
|
||||
ssh.stdin.puts "blah blah\nmas blah\nrequeteblah"
|
||||
ssh.stdin.puts "EOT"
|
||||
|
||||
code=ssh.wait_for_command
|
||||
|
||||
puts "Code: #{code}"
|
||||
puts "output: #{ssh.out}"
|
||||
|
||||
code=ssh.exec_and_wait("whoami")
|
||||
|
||||
puts "Code: #{code}"
|
||||
puts "output: #{ssh.out}"
|
||||
|
||||
code=ssh.exec_and_wait("touch /etc/pepe.txt")
|
||||
|
||||
puts "Code: #{code}"
|
||||
puts "output: #{ssh.out}"
|
||||
puts "output err: #{ssh.err}"
|
||||
|
||||
ssh.close
|
||||
|
||||
cssh = SshStreamCommand.new('no_host',
|
||||
'/tmp',
|
||||
lambda { |e| STDOUT.puts "error: #{e}" },
|
||||
nil)
|
||||
cssh.run('whoami')
|
||||
end
|
60
src/mad/ruby/vmwarelib.rb
Normal file
60
src/mad/ruby/vmwarelib.rb
Normal file
@ -0,0 +1,60 @@
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Copyright 2010-2011, C12G Labs S.L #
|
||||
# #
|
||||
# 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. #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Set up the environment for the driver #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
ONE_LOCATION = ENV["ONE_LOCATION"] if !defined?(ONE_LOCATION)
|
||||
|
||||
if !ONE_LOCATION
|
||||
BIN_LOCATION = "/usr/bin" if !defined?(BIN_LOCATION)
|
||||
ETC_LOCATION = "/etc/one/" if !defined?(ETC_LOCATION)
|
||||
RUBY_LIB_LOCATION = "/usr/lib/one/ruby" if !defined?(RUBY_LIB_LOCATION)
|
||||
else
|
||||
BIN_LOCATION = ONE_LOCATION + "/bin" if !defined?(BIN_LOCATION)
|
||||
ETC_LOCATION = ONE_LOCATION + "/etc/" if !defined?(ETC_LOCATION)
|
||||
if !defined?(RUBY_LIB_LOCATION)
|
||||
RUBY_LIB_LOCATION = ONE_LOCATION + "/lib/ruby"
|
||||
end
|
||||
end
|
||||
|
||||
$: << RUBY_LIB_LOCATION
|
||||
|
||||
require "OpenNebulaDriver"
|
||||
require "CommandManager"
|
||||
|
||||
# Do host sustitution in the libvirt URI
|
||||
LIBVIRT_URI.gsub!('@HOST@', @host)
|
||||
|
||||
# Common functions
|
||||
def perform_action(command)
|
||||
command = BIN_LOCATION + "/tty_expect -u " + USERNAME + " -p " + PASSWORD + " " + command
|
||||
|
||||
action_result = LocalCommand.run(command)
|
||||
|
||||
if action_result.code == 0
|
||||
return action_result.stdout
|
||||
else
|
||||
log(command, action_result.stderr, action_result.stdout)
|
||||
return action_result.code
|
||||
end
|
||||
end
|
||||
|
||||
def log(cmd, stdout, stderr)
|
||||
STDERR.puts "[VMWARE] cmd failed [" + cmd +
|
||||
"]. Stderr: " + stderr + ". Stdout: " + stdout
|
||||
end
|
22
src/mad/utils/SConstruct
Normal file
22
src/mad/utils/SConstruct
Normal file
@ -0,0 +1,22 @@
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Copyright 2010-2011, C12G Labs S.L #
|
||||
# #
|
||||
# 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. #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
Import('env')
|
||||
import os
|
||||
|
||||
env['LIBS'] = "util"
|
||||
|
||||
env.Program('tty_expect.c')
|
168
src/mad/utils/tty_expect.c
Normal file
168
src/mad/utils/tty_expect.c
Normal file
@ -0,0 +1,168 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2010-2011, C12G Labs S.L. */
|
||||
/* */
|
||||
/* 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 <pty.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
int expect_char(int pty, char * expected, int seconds)
|
||||
{
|
||||
fd_set rfds;
|
||||
struct timeval tv;
|
||||
|
||||
int rc;
|
||||
char c;
|
||||
|
||||
do
|
||||
{
|
||||
if (seconds != 0)
|
||||
{
|
||||
FD_ZERO(&rfds);
|
||||
FD_SET(pty, &rfds);
|
||||
|
||||
tv.tv_sec = seconds;
|
||||
tv.tv_usec = 0;
|
||||
|
||||
rc = select(pty+1,&rfds,0,0, &tv);
|
||||
|
||||
if ( rc <= 0 ) // timeout
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
rc = read(pty, (void *) &c, sizeof(char));
|
||||
|
||||
if ( rc > 0 )
|
||||
{
|
||||
if(expected == 0)
|
||||
{
|
||||
write(1,&c,sizeof(char));
|
||||
}
|
||||
|
||||
if (expected != 0 && c == *expected)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
while ( rc > 0 );
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void write_answer(int pty, const char * answer)
|
||||
{
|
||||
int len, i;
|
||||
|
||||
len = strlen(answer);
|
||||
|
||||
for (i=0; i<len; i++)
|
||||
{
|
||||
write(pty,(void *) &(answer[i]),sizeof(char));
|
||||
}
|
||||
|
||||
write(pty,(void *)"\n",sizeof(char));
|
||||
}
|
||||
|
||||
static const char * myexpect_usage =
|
||||
"\n myexpect [-h] <-p password> <-u username> <command>\n\n"
|
||||
"SYNOPSIS\n"
|
||||
" Wraps the execution of a command and sends username & password\n\n"
|
||||
"OPTIONS\n"
|
||||
"\t-h\tprints this help.\n"
|
||||
"\t-p\tthe password\n"
|
||||
"\t-u\tthe username\n"
|
||||
"\t<virsh command>\tcomplete virsh command\n";
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
char * password = 0;
|
||||
char * username = 0;
|
||||
|
||||
char expect = ':';
|
||||
|
||||
int opt, pty, pid, rc;
|
||||
|
||||
while((opt = getopt(argc,argv,"+hp:u:")) != -1)
|
||||
switch(opt)
|
||||
{
|
||||
case 'h':
|
||||
printf("%s",myexpect_usage);
|
||||
exit(0);
|
||||
break;
|
||||
case 'p':
|
||||
password = strdup(optarg);
|
||||
break;
|
||||
case 'u':
|
||||
username = strdup(optarg);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"Wrong option. Check usage\n");
|
||||
fprintf(stderr,"%s",myexpect_usage);
|
||||
exit(-1);
|
||||
break;
|
||||
}
|
||||
|
||||
if (password == 0 || username == 0 || optind >= argc )
|
||||
{
|
||||
fprintf(stderr,"Wrong number of arguments. Check usage\n");
|
||||
fprintf(stderr,"%s",myexpect_usage);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
pid = forkpty(&pty,0,0,0);
|
||||
|
||||
if(pid == 0)
|
||||
{
|
||||
struct termios tios;
|
||||
|
||||
tcgetattr(pty, &tios);
|
||||
|
||||
tios.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL);
|
||||
tios.c_oflag &= ~(ONLCR);
|
||||
|
||||
tcsetattr(pty, TCSANOW, &tios);
|
||||
|
||||
execvp(argv[optind],&(argv[optind]));
|
||||
|
||||
exit(-1);
|
||||
}
|
||||
else if (pid == -1)
|
||||
{
|
||||
perror("fork\n");
|
||||
}
|
||||
|
||||
expect_char(pty,&expect,1);
|
||||
sleep(1);
|
||||
write_answer(pty,username);
|
||||
expect_char(pty,&expect,1);
|
||||
sleep(1);
|
||||
write_answer(pty,password);
|
||||
|
||||
expect_char(pty,0,0);
|
||||
|
||||
wait(&rc);
|
||||
|
||||
return WEXITSTATUS(rc);
|
||||
}
|
@ -72,6 +72,9 @@ public class Host extends PoolElement{
|
||||
* @param vmm The name of the virtual machine manager mad name
|
||||
* (vmm_mad_name), this values are taken from the oned.conf with the
|
||||
* tag name VM_MAD (name)
|
||||
* @param vnm The name of the virtual network manager mad name
|
||||
* (vnm_mad_name), this values are taken from the oned.conf with the
|
||||
* tag name VN_MAD (name)
|
||||
* @param tm The transfer manager mad name to be used with this host
|
||||
* @return If successful the message contains the associated
|
||||
* id generated for this host
|
||||
@ -80,9 +83,10 @@ public class Host extends PoolElement{
|
||||
String hostname,
|
||||
String im,
|
||||
String vmm,
|
||||
String vnm,
|
||||
String tm)
|
||||
{
|
||||
return client.call(ALLOCATE, hostname, im, vmm, tm);
|
||||
return client.call(ALLOCATE, hostname, im, vmm, vnm, tm);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -36,7 +36,8 @@ public class VirtualNetwork extends PoolElement{
|
||||
private static final String RMLEASES = METHOD_PREFIX + "rmleases";
|
||||
private static final String CHOWN = METHOD_PREFIX + "chown";
|
||||
private static final String UPDATE = METHOD_PREFIX + "update";
|
||||
|
||||
private static final String HOLD = METHOD_PREFIX + "hold";
|
||||
private static final String RELEASE = METHOD_PREFIX + "release";
|
||||
|
||||
/**
|
||||
* Creates a new virtual network representation.
|
||||
@ -140,6 +141,32 @@ public class VirtualNetwork extends PoolElement{
|
||||
return client.call(RMLEASES, id, template);
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds a VirtualNetwork lease, marking it as used
|
||||
*
|
||||
* @param client XML-RPC Client.
|
||||
* @param id The virtual network id (nid) of the target network.
|
||||
* @param template IP to hold, e.g. "LEASES = [ IP = 192.168.0.5 ]"
|
||||
* @return A encapsulated response.
|
||||
*/
|
||||
public static OneResponse hold(Client client, int id, String template)
|
||||
{
|
||||
return client.call(HOLD, id, template);
|
||||
}
|
||||
|
||||
/**
|
||||
* Releases a VirtualNetwork lease on hold
|
||||
*
|
||||
* @param client XML-RPC Client.
|
||||
* @param id The virtual network id (nid) of the target network.
|
||||
* @param template IP to release, e.g. "LEASES = [ IP = 192.168.0.5 ]"
|
||||
* @return A encapsulated response.
|
||||
*/
|
||||
public static OneResponse release(Client client, int id, String template)
|
||||
{
|
||||
return client.call(RELEASE, id, template);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the owner/group
|
||||
*
|
||||
@ -271,6 +298,30 @@ public class VirtualNetwork extends PoolElement{
|
||||
return rmLeases(client, id, lease_template);
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds a VirtualNetwork lease, marking it as used
|
||||
*
|
||||
* @param ip IP to hold, e.g. "192.168.0.5"
|
||||
* @return A encapsulated response.
|
||||
*/
|
||||
public OneResponse hold(String ip)
|
||||
{
|
||||
String lease_template = "LEASES = [ IP = " + ip + " ]";
|
||||
return hold(client, id, lease_template);
|
||||
}
|
||||
|
||||
/**
|
||||
* Releases a VirtualNetwork lease on hold
|
||||
*
|
||||
* @param ip IP to release, e.g. "192.168.0.5"
|
||||
* @return A encapsulated response.
|
||||
*/
|
||||
public OneResponse release(String ip)
|
||||
{
|
||||
String lease_template = "LEASES = [ IP = " + ip + " ]";
|
||||
return release(client, id, lease_template);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the owner/group
|
||||
*
|
||||
|
@ -63,7 +63,8 @@ public class HostTest
|
||||
@Before
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
res = Host.allocate(client, name, "im_dummy", "vmm_dummy", "tm_dummy");
|
||||
res = Host.allocate(client, name, "im_dummy", "vmm_dummy", "vnm_dummy",
|
||||
"tm_dummy");
|
||||
|
||||
int hid = !res.isError() ? Integer.parseInt(res.getMessage()) : -1;
|
||||
host = new Host(hid, client);
|
||||
@ -83,7 +84,8 @@ public class HostTest
|
||||
{
|
||||
String name = "allocate_test";
|
||||
|
||||
res = Host.allocate(client, name, "im_dummy", "vmm_dummy", "tm_dummy");
|
||||
res = Host.allocate(client, name, "im_dummy", "vmm_dummy", "vmm_dummy",
|
||||
"tm_dummy");
|
||||
assertTrue( !res.isError() );
|
||||
// assertTrue( res.getMessage().equals("0") );
|
||||
|
||||
|
@ -80,11 +80,11 @@ public class VirtualMachineTest
|
||||
|
||||
|
||||
res = Host.allocate(client, "host_A",
|
||||
"im_dummy", "vmm_dummy", "tm_dummy");
|
||||
"im_dummy", "vmm_dummy", "vmm_dummy", "tm_dummy");
|
||||
hid_A = Integer.parseInt( res.getMessage() );
|
||||
|
||||
res = Host.allocate(client, "host_B",
|
||||
"im_dummy", "vmm_dummy", "tm_dummy");
|
||||
"im_dummy", "vmm_dummy", "vmm_dummy", "tm_dummy");
|
||||
hid_B = Integer.parseInt( res.getMessage() );
|
||||
}
|
||||
|
||||
|
@ -209,6 +209,54 @@ public class VirtualNetworkTest
|
||||
fixed_vnet.delete();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void holdFixed()
|
||||
{
|
||||
res = VirtualNetwork.allocate(client, fixed_template);
|
||||
assertTrue( !res.isError() );
|
||||
|
||||
VirtualNetwork fixed_vnet =
|
||||
new VirtualNetwork(Integer.parseInt(res.getMessage()), client);
|
||||
|
||||
res = fixed_vnet.hold("130.10.0.1");
|
||||
assertTrue( !res.isError() );
|
||||
|
||||
res = fixed_vnet.hold("130.10.0.5");
|
||||
assertTrue( res.isError() );
|
||||
|
||||
res = fixed_vnet.release("130.10.0.1");
|
||||
assertTrue( !res.isError() );
|
||||
|
||||
res = fixed_vnet.release("130.10.0.1");
|
||||
assertTrue( res.isError() );
|
||||
|
||||
res = fixed_vnet.release("130.10.0.5");
|
||||
assertTrue( res.isError() );
|
||||
|
||||
fixed_vnet.delete();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void holdRanged()
|
||||
{
|
||||
res = vnet.hold("192.168.0.10");
|
||||
assertTrue( !res.isError() );
|
||||
|
||||
res = vnet.hold("192.168.100.1");
|
||||
assertTrue( res.isError() );
|
||||
|
||||
res = vnet.release("192.168.0.10");
|
||||
assertTrue( !res.isError() );
|
||||
|
||||
res = vnet.release("192.168.0.10");
|
||||
assertTrue( res.isError() );
|
||||
|
||||
res = vnet.release("192.168.100.1");
|
||||
assertTrue( res.isError() );
|
||||
|
||||
vnet.delete();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void update()
|
||||
{
|
||||
|
@ -78,15 +78,15 @@ module OpenNebula
|
||||
|
||||
# Allocates a new Host in OpenNebula
|
||||
#
|
||||
# +hostname+ A string containing the name of the new Host.
|
||||
# @param hostname [String] Name of the new Host.
|
||||
# @param im [String] Name of the im_driver
|
||||
# @param vmm [String] Name of the vmm_driver
|
||||
# @param tm [String] Name of the tm_driver
|
||||
#
|
||||
# +im+ A string containing the name of the im_driver
|
||||
#
|
||||
# +vmm+ A string containing the name of the vmm_driver
|
||||
#
|
||||
# +tm+ A string containing the name of the tm_driver
|
||||
def allocate(hostname,im,vmm,tm)
|
||||
super(HOST_METHODS[:allocate],hostname,im,vmm,tm)
|
||||
# @return [Integer, OpenNebula::Error] the new VM ID in case of
|
||||
# success, error otherwise
|
||||
def allocate(hostname,im,vmm,vnm,tm)
|
||||
super(HOST_METHODS[:allocate],hostname,im,vmm,vnm,tm)
|
||||
end
|
||||
|
||||
# Deletes the Host
|
||||
|
@ -38,6 +38,9 @@ module OpenNebula
|
||||
# Driver name for default core authentication
|
||||
CORE_AUTH = "core"
|
||||
|
||||
# Driver name for default core authentication
|
||||
CIPHER_AUTH = "server_cipher"
|
||||
|
||||
# Driver name for ssh authentication
|
||||
SSH_AUTH = "ssh"
|
||||
|
||||
|
@ -32,7 +32,9 @@ module OpenNebula
|
||||
:addleases => "vn.addleases",
|
||||
:rmleases => "vn.rmleases",
|
||||
:chown => "vn.chown",
|
||||
:update => "vn.update"
|
||||
:update => "vn.update",
|
||||
:hold => "vn.hold",
|
||||
:release => "vn.release"
|
||||
}
|
||||
|
||||
VN_TYPES=%w{RANGED FIXED}
|
||||
@ -128,6 +130,32 @@ module OpenNebula
|
||||
return rc
|
||||
end
|
||||
|
||||
# Holds a virtual network Lease as used
|
||||
# @param ip [String] IP to hold
|
||||
def hold(ip)
|
||||
return Error.new('ID not defined') if !@pe_id
|
||||
|
||||
lease_template = "LEASES = [ IP = #{ip} ]"
|
||||
|
||||
rc = @client.call(VN_METHODS[:hold], @pe_id, lease_template)
|
||||
rc = nil if !OpenNebula.is_error?(rc)
|
||||
|
||||
return rc
|
||||
end
|
||||
|
||||
# Releases a virtual network Lease on hold
|
||||
# @param ip [String] IP to release
|
||||
def release(ip)
|
||||
return Error.new('ID not defined') if !@pe_id
|
||||
|
||||
lease_template = "LEASES = [ IP = #{ip} ]"
|
||||
|
||||
rc = @client.call(VN_METHODS[:release], @pe_id, lease_template)
|
||||
rc = nil if !OpenNebula.is_error?(rc)
|
||||
|
||||
return rc
|
||||
end
|
||||
|
||||
# Changes the owner/group
|
||||
# uid:: _Integer_ the new owner id. Set to -1 to leave the current one
|
||||
# gid:: _Integer_ the new group id. Set to -1 to leave the current one
|
||||
|
@ -201,7 +201,7 @@ module OpenNebula
|
||||
template_like_str('TEMPLATE', indent)
|
||||
end
|
||||
|
||||
def template_like_str(root_element, indent=true)
|
||||
def template_like_str(root_element, indent=true, xpath_exp=nil)
|
||||
if NOKOGIRI
|
||||
xml_template=@xml.xpath(root_element).to_s
|
||||
rexml=REXML::Document.new(xml_template).root
|
||||
@ -217,7 +217,7 @@ module OpenNebula
|
||||
ind_tab=' '
|
||||
end
|
||||
|
||||
str=rexml.collect {|n|
|
||||
str=rexml.elements.collect(xpath_exp) {|n|
|
||||
if n.class==REXML::Element
|
||||
str_line=""
|
||||
if n.has_elements?
|
||||
|
215
src/onedb/3.1.0_to_3.1.80.rb
Normal file
215
src/onedb/3.1.0_to_3.1.80.rb
Normal file
@ -0,0 +1,215 @@
|
||||
# -------------------------------------------------------------------------- *
|
||||
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may *
|
||||
# not use this file except in compliance with the License. You may obtain *
|
||||
# a copy of the License at *
|
||||
# *
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 *
|
||||
# *
|
||||
# Unless required by applicable law or agreed to in writing, software *
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, *
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
|
||||
# See the License for the specific language governing permissions and *
|
||||
# limitations under the License. *
|
||||
# -------------------------------------------------------------------------- *
|
||||
|
||||
require 'digest/sha1'
|
||||
require "rexml/document"
|
||||
include REXML
|
||||
require 'ipaddr'
|
||||
|
||||
module Migrator
|
||||
def db_version
|
||||
"3.1.80"
|
||||
end
|
||||
|
||||
def one_version
|
||||
"OpenNebula 3.1.80"
|
||||
end
|
||||
|
||||
def up
|
||||
puts " > Networking isolation hooks have been moved to Host drivers.\n"<<
|
||||
" If you were using a networking hook, enter its name, or press enter\n"<<
|
||||
" to use the default dummy vn_mad driver.\n\n"
|
||||
|
||||
vn_mad = ""
|
||||
|
||||
while !( ["802.1Q", "dummy", "ebtables", "ovswitch"].include?(vn_mad) ) do
|
||||
print " Driver name (802.1Q, dummy, ebtables, ovswitch): "
|
||||
vn_mad = gets.chomp
|
||||
vn_mad = "dummy" if vn_mad.empty?
|
||||
end
|
||||
|
||||
# 0 = all, 1 = none, 2 = interactive
|
||||
vlan_option = 1
|
||||
|
||||
if ( vn_mad == "ebtables" || vn_mad == "ovswitch" )
|
||||
puts
|
||||
puts " > A new attribute, VLAN = YES/NO will be added to each VNET.\n"<<
|
||||
" For driver '#{vn_mad}', please choose if you want to isolate all networks (all),\n"<<
|
||||
" none (none), or be asked individually for each VNET (interactive)\n"
|
||||
|
||||
vlan = ""
|
||||
while !( ["all", "none", "interactive"].include?(vlan) ) do
|
||||
print " Isolate VNETs (all, none, interactive): "
|
||||
vlan = gets.chomp
|
||||
end
|
||||
|
||||
case vlan
|
||||
when "all"
|
||||
vlan_option = 0
|
||||
when "none"
|
||||
vlan_option = 1
|
||||
when "interactive"
|
||||
vlan_option = 2
|
||||
end
|
||||
end
|
||||
|
||||
# New VN_MAD element for hosts
|
||||
|
||||
@db.run "ALTER TABLE host_pool RENAME TO old_host_pool;"
|
||||
@db.run "CREATE TABLE host_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, state INTEGER, last_mon_time INTEGER, UNIQUE(name));"
|
||||
|
||||
@db.fetch("SELECT * FROM old_host_pool") do |row|
|
||||
doc = Document.new(row[:body])
|
||||
|
||||
vn_mad_elem = doc.root.add_element("VN_MAD")
|
||||
vn_mad_elem.text = vn_mad
|
||||
|
||||
@db[:host_pool].insert(
|
||||
:oid => row[:oid],
|
||||
:name => row[:name],
|
||||
:body => doc.root.to_s,
|
||||
:state => row[:state],
|
||||
:last_mon_time => row[:last_mon_time])
|
||||
end
|
||||
|
||||
@db.run "DROP TABLE old_host_pool;"
|
||||
|
||||
# New VLAN and RANGE for vnets
|
||||
|
||||
@db.run "ALTER TABLE network_pool RENAME TO old_network_pool;"
|
||||
@db.run "CREATE TABLE network_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, uid INTEGER, gid INTEGER, public INTEGER, UNIQUE(name,uid));"
|
||||
|
||||
@db.fetch("SELECT * FROM old_network_pool") do |row|
|
||||
doc = Document.new(row[:body])
|
||||
|
||||
type = ""
|
||||
doc.root.each_element("TYPE") { |e|
|
||||
type = e.text
|
||||
}
|
||||
|
||||
if type == "0" # RANGED
|
||||
range_elem = doc.root.add_element("RANGE")
|
||||
ip_start_elem = range_elem.add_element("IP_START")
|
||||
ip_end_elem = range_elem.add_element("IP_END")
|
||||
|
||||
net_address = ""
|
||||
doc.root.each_element("TEMPLATE/NETWORK_ADDRESS") { |e|
|
||||
net_address = e.text
|
||||
}
|
||||
|
||||
net_valid = false
|
||||
while !net_valid do
|
||||
begin
|
||||
net_address = IPAddr.new(net_address, Socket::AF_INET)
|
||||
net_valid = true
|
||||
rescue ArgumentError
|
||||
puts
|
||||
puts " > Error processing VNET ##{row[:oid]} '#{row[:name]}'\n"<<
|
||||
" This network address is invalid: '#{net_address}'\n"
|
||||
print " Please enter a valid network address: "
|
||||
net_address = gets.chomp
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
st_size = ""
|
||||
doc.root.each_element("TEMPLATE/NETWORK_SIZE") { |e|
|
||||
st_size = e.text
|
||||
}
|
||||
|
||||
if ( st_size == "C" || st_size == "c" )
|
||||
host_bits = 8
|
||||
elsif ( st_size == "B" || st_size == "b" )
|
||||
host_bits = 16
|
||||
elsif ( st_size == "A" || st_size == "a" )
|
||||
host_bits = 24
|
||||
else
|
||||
size = st_size.to_i
|
||||
host_bits = (Math.log(size+2)/Math.log(2)).ceil
|
||||
end
|
||||
|
||||
net_mask = 0xFFFFFFFF << host_bits
|
||||
|
||||
net_address = net_address.to_i & net_mask
|
||||
|
||||
ip_start_elem.text = IPAddr.new((net_address + 1), Socket::AF_INET).to_s
|
||||
ip_end_elem.text = IPAddr.new((net_address + (1 << host_bits) - 2), Socket::AF_INET).to_s
|
||||
end
|
||||
|
||||
phydev_present = false
|
||||
doc.root.each_element("PHYDEV") { |e|
|
||||
phydev_present = true
|
||||
}
|
||||
|
||||
vlan_elem = doc.root.add_element("VLAN")
|
||||
|
||||
if phydev_present
|
||||
vlan_elem.text = "1"
|
||||
else
|
||||
case vlan_option
|
||||
when 0
|
||||
vlan_elem.text = "1"
|
||||
when 1
|
||||
vlan_elem.text = "0"
|
||||
when 2
|
||||
vlan = ""
|
||||
while !( ["y", "n"].include?(vlan) ) do
|
||||
print " > Isolate VNET ##{row[:oid]} '#{row[:name]}'? (y/n) : "
|
||||
vlan = gets.chomp
|
||||
end
|
||||
|
||||
if ( vlan == "y" )
|
||||
vlan_elem.text = "1"
|
||||
else
|
||||
vlan_elem.text = "0"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@db[:network_pool].insert(
|
||||
:oid => row[:oid],
|
||||
:name => row[:name],
|
||||
:body => doc.root.to_s,
|
||||
:uid => row[:uid],
|
||||
:gid => row[:gid],
|
||||
:public => row[:public])
|
||||
end
|
||||
|
||||
@db.run "DROP TABLE old_network_pool;"
|
||||
|
||||
# Add empty HISTORY_RECORDS element to VMs without any records
|
||||
@db.run "ALTER TABLE vm_pool RENAME TO old_vm_pool;"
|
||||
@db.run "CREATE TABLE vm_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, uid INTEGER, gid INTEGER, last_poll INTEGER, state INTEGER, lcm_state INTEGER);"
|
||||
@db.run "INSERT INTO vm_pool SELECT * FROM old_vm_pool;"
|
||||
|
||||
@db.fetch("SELECT * FROM old_vm_pool") do |row|
|
||||
doc = Document.new(row[:body])
|
||||
|
||||
found = false
|
||||
doc.root.each_element("HISTORY_RECORDS") { |e|
|
||||
found = true
|
||||
}
|
||||
|
||||
if !found
|
||||
doc.root.add_element("HISTORY_RECORDS")
|
||||
end
|
||||
end
|
||||
|
||||
@db.run "DROP TABLE old_vm_pool;"
|
||||
|
||||
|
||||
return true
|
||||
end
|
||||
end
|
@ -215,6 +215,12 @@ label{
|
||||
text-align:left;
|
||||
}
|
||||
|
||||
.dataTables_wrapper label {
|
||||
float: none;
|
||||
width: auto;
|
||||
padding: 0 0;
|
||||
text-align:right;
|
||||
}
|
||||
|
||||
div.tip {
|
||||
display: inline-block;
|
||||
@ -286,13 +292,14 @@ textarea:focus{
|
||||
}
|
||||
|
||||
.add_remove_button {
|
||||
font-size:0.8em;
|
||||
height:25px;
|
||||
font-size:0.8em !important;
|
||||
height:25px !important;
|
||||
margin-bottom:4px;
|
||||
}
|
||||
|
||||
.add_button {
|
||||
margin-left:177px;
|
||||
margin-left:148px;
|
||||
width: 58px !important;
|
||||
}
|
||||
|
||||
.remove_button {
|
||||
@ -411,7 +418,7 @@ tr.even:hover{
|
||||
}
|
||||
|
||||
.top_button {
|
||||
font-size: 0.8em;
|
||||
font-size: 0.8em!important;
|
||||
height: 25px;
|
||||
margin: 3px 2px;
|
||||
vertical-align: middle;
|
||||
@ -465,15 +472,15 @@ tr.even:hover{
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
.jGrowl-notification, .jGrowl-closer, .jGrowl-notify-submit {
|
||||
.jGrowl-notification, .jGrowl-notify-submit {
|
||||
border: 2px #444444 solid;
|
||||
background-color: #F3F3F3;
|
||||
background-color: #F3F3F3!important;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.jGrowl-notify-error {
|
||||
border: 2px #660000 solid;
|
||||
background-color: #F39999;
|
||||
background-color: #F39999!important;
|
||||
color: #660000;
|
||||
}
|
||||
|
||||
@ -578,4 +585,13 @@ ul.dd_right{
|
||||
}
|
||||
ul.dd_left{
|
||||
|
||||
}
|
||||
|
||||
.ui-widget{
|
||||
font: 10pt Arial, Verdana, Geneva, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
.ui-layout-resizer-open-hover, /* hover-color to 'resize' */
|
||||
.ui-layout-resizer-dragging {
|
||||
background: #EEE;
|
||||
}
|
@ -44,19 +44,26 @@ body {
|
||||
}
|
||||
|
||||
#header {
|
||||
padding:0;
|
||||
padding: 0 10px 0 10px;
|
||||
background-color: #353735;
|
||||
border:0;
|
||||
}
|
||||
|
||||
#footer {
|
||||
padding:0;
|
||||
padding-top: 9px;
|
||||
font-size: 0.8em;
|
||||
color: white;
|
||||
text-align: center;
|
||||
background-color: #353735;
|
||||
border:0;
|
||||
|
||||
}
|
||||
|
||||
#header {
|
||||
padding: 0 10px 0 10px;
|
||||
background-color: #353735;
|
||||
#footer a {
|
||||
color: white;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#logo {
|
||||
padding-top: 6px;
|
||||
font-weight: bold;
|
||||
@ -87,18 +94,6 @@ body {
|
||||
color: #88C140;
|
||||
}
|
||||
|
||||
#footer {
|
||||
padding-top: 9px;
|
||||
font-size: 0.8em;
|
||||
color: white;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#footer a {
|
||||
color: white;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#logo-wrapper {
|
||||
float: right;
|
||||
margin-top: 0px;
|
||||
@ -108,6 +103,7 @@ body {
|
||||
#menu {
|
||||
padding-right: 0;
|
||||
padding-left: 0;
|
||||
border:0;
|
||||
border-right: 1px solid #353735;
|
||||
background-image: -webkit-gradient(
|
||||
linear,
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user