mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-23 17:33:56 +03:00
Merge branch 'master' into feature-1004
Conflicts: install.sh src/sunstone/etc/sunstone-server.conf src/sunstone/public/js/plugins/hosts-tab.js src/sunstone/public/js/plugins/vnets-tab.js I have updated the vnets plugin to include missing translations.
This commit is contained in:
commit
48f363cebc
@ -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
|
||||
@ -312,6 +321,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
|
||||
*/
|
||||
string tm_mad_name;
|
||||
@ -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,12 +250,12 @@ 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
|
||||
// -------------------------------------------------------------------------
|
||||
|
@ -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)
|
||||
// *************************************************************************
|
||||
|
68
install.sh
68
install.sh
@ -223,10 +223,15 @@ VAR_DIRS="$VAR_LOCATION/remotes \
|
||||
$VAR_LOCATION/remotes/im/vmware.d \
|
||||
$VAR_LOCATION/remotes/im/ganglia.d \
|
||||
$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 \
|
||||
@ -354,13 +359,17 @@ INSTALL_FILES=(
|
||||
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
|
||||
@ -518,6 +527,9 @@ 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 \
|
||||
@ -650,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
|
||||
@ -707,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"
|
||||
|
||||
@ -805,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"
|
||||
|
||||
@ -930,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"
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
@ -1084,6 +1119,9 @@ 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"
|
||||
|
||||
|
@ -438,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
|
||||
#*******************************************************************************
|
||||
|
@ -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
|
||||
|
@ -111,7 +111,11 @@ class AuthDriver < OpenNebulaDriver
|
||||
command = File.join(authN_path, ACTION[:authN].downcase)
|
||||
command << " '" << user.gsub("'", '\'"\'"\'') << "' '" << password.gsub("'", '\'"\'"\'') << "' " << secret
|
||||
|
||||
local_action(command, request_id, ACTION[:authN])
|
||||
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
|
||||
@ -141,7 +145,11 @@ class AuthDriver < OpenNebulaDriver
|
||||
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
|
||||
|
@ -54,7 +54,7 @@ if options[:group]
|
||||
end
|
||||
|
||||
if ldap.authenticate(user_name, secret)
|
||||
puts "#{user} #{user_name}"
|
||||
puts "ldap #{user} #{user_name}"
|
||||
exit(0)
|
||||
else
|
||||
STDERR.puts "Bad user/password"
|
||||
|
@ -81,8 +81,24 @@ class Quota
|
||||
:proc_info => lambda {|template|
|
||||
if template['TYPE'] == 'DATABLOCK'
|
||||
template['SIZE'].to_i
|
||||
else
|
||||
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'
|
||||
@ -97,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
|
||||
|
@ -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,7 @@ 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']]
|
||||
@ -68,13 +69,26 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper
|
||||
|
||||
puts vn.template_str(false)
|
||||
|
||||
leases_str = vn.template_like_str('/VNET/LEASES', false)
|
||||
if vn.type_str == "RANGED"
|
||||
puts
|
||||
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 % ["LEASES INFORMATION"], false)
|
||||
CLIHelper.print_header(str_h1 % [pair[0]], false)
|
||||
puts leases_str
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
def format_pool(options)
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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,11 +45,7 @@ class CloudAuth
|
||||
def initialize(conf)
|
||||
@conf = conf
|
||||
|
||||
# @token_expiration_delta: Number of seconds that will be used
|
||||
# the same timestamp for the token generation
|
||||
# @token_expiration_time: Current timestamp to be used in tokens.
|
||||
@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]]
|
||||
@ -90,14 +87,24 @@ class CloudAuth
|
||||
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
|
||||
@token_expiration_time = time_now + @token_expiration_delta
|
||||
update_userpool_cache
|
||||
@token_expiration_time = time_now + EXPIRE_DELTA
|
||||
end
|
||||
|
||||
@token_expiration_time
|
||||
|
@ -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?
|
||||
|
@ -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?
|
||||
|
@ -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
|
||||
@ -36,16 +33,18 @@
|
||||
# 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:
|
||||
:custom:
|
||||
:template: custom.erb
|
||||
:small:
|
||||
:template: small.erb
|
||||
:cpu: 1
|
||||
:memory: 1024
|
||||
:medium:
|
||||
:template: medium.erb
|
||||
:cpu: 4
|
||||
:memory: 4096
|
||||
:large:
|
||||
:template: large.erb
|
||||
:cpu: 8
|
||||
:memory: 8192
|
||||
|
@ -41,4 +41,4 @@
|
||||
]
|
||||
<% end %>
|
||||
|
||||
INSTANCE_TYPE = <%= @vm_info['INSTANCE_TYPE']%>
|
||||
INSTANCE_TYPE = <%= @itype %>
|
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
|
@ -30,7 +30,7 @@ class ImageOCCI < Image
|
||||
<DESCRIPTION><%= self['TEMPLATE/DESCRIPTION'] %></DESCRIPTION>
|
||||
<% end %>
|
||||
<SIZE><%= self['SIZE'] %></SIZE>
|
||||
<% if self['FSTYPE'] != nil %>
|
||||
<% if self['FSTYPE'] != nil and !self['FSTYPE'].empty? %>
|
||||
<FSTYPE><%= self['FSTYPE'] %></FSTYPE>
|
||||
<% end %>
|
||||
<PUBLIC><%= self['PUBLIC'] == "0" ? "NO" : "YES"%></PUBLIC>
|
||||
|
@ -37,6 +37,12 @@ require 'pp'
|
||||
# The OCCI Server provides an OCCI implementation based on the
|
||||
# OpenNebula Engine
|
||||
##############################################################################
|
||||
|
||||
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
|
||||
@ -69,26 +75,51 @@ class OCCIServer < CloudServer
|
||||
############################################################################
|
||||
############################################################################
|
||||
|
||||
def get_collections(request)
|
||||
xml_resp = "<COLLECTIONS>\n"
|
||||
|
||||
COLLECTIONS.each { |c|
|
||||
xml_resp << "\t<#{c.upcase}_COLLECTION href=\"#{@base_url}/#{c}\">\n"
|
||||
}
|
||||
|
||||
xml_resp << "</COLLECTIONS>"
|
||||
|
||||
return xml_resp, 200
|
||||
end
|
||||
|
||||
def get_instance_types(request)
|
||||
xml_resp = "<INSTANCE_TYPE_COLLECTION>\n"
|
||||
|
||||
@config[:instance_types].each { |k, v|
|
||||
xml_resp << "\t<INSTANCE_TYPE href=\"#{@base_url}/instance_type/#{k.to_s}\">\n"
|
||||
xml_resp << "\t\t<NAME>#{k.to_s}</NAME>\n"
|
||||
v.each { |elem, value|
|
||||
next if elem==:template
|
||||
str = elem.to_s.upcase
|
||||
xml_resp << "\t\t<#{str}>#{value}</#{str}>\n"
|
||||
}
|
||||
xml_resp << "\t</INSTANCE_TYPE>\n"
|
||||
}
|
||||
|
||||
xml_resp << "</INSTANCE_TYPE_COLLECTION>"
|
||||
|
||||
return xml_resp, 200
|
||||
end
|
||||
|
||||
|
||||
# Gets the pool representation of COMPUTES
|
||||
# request:: _Hash_ hash containing the data of the request
|
||||
# [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)
|
||||
@ -101,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)
|
||||
@ -127,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)
|
||||
@ -157,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
|
||||
@ -192,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
|
||||
@ -211,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)
|
||||
@ -234,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
|
||||
@ -282,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
|
||||
@ -307,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)
|
||||
@ -328,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
|
||||
@ -350,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 ---
|
||||
@ -397,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
|
||||
@ -415,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 ---
|
||||
@ -438,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
|
||||
@ -460,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 ---
|
||||
@ -497,45 +499,10 @@ class OCCIServer < CloudServer
|
||||
|
||||
# --- Prepare XML Response ---
|
||||
rc = user.info
|
||||
|
||||
if OpenNebula.is_error?(rc)
|
||||
return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
|
||||
end
|
||||
|
||||
return to_occi_xml(user, 200)
|
||||
end
|
||||
|
||||
def get_computes_types
|
||||
etc_location=ONE_LOCATION ? ONE_LOCATION+"/etc" : "/etc/one"
|
||||
begin
|
||||
xml_response = "<ALLOWED_COMPUTE_TYPES>\n"
|
||||
|
||||
Dir[etc_location + "/occi_templates/**"].each{| filename |
|
||||
next if File.basename(filename) == "common.erb"
|
||||
xml_response += "\t<COMPUTE_TYPE>"
|
||||
xml_response += "\t\t<NAME>#{File.basename(filename)[0..-5]}</NAME>"
|
||||
file = File.open(filename, "r")
|
||||
file.each_line{|line|
|
||||
next if line.match(/^#/)
|
||||
match=line.match(/^(.*)=(.*)/)
|
||||
next if !match
|
||||
case match[1].strip
|
||||
when "NAME"
|
||||
xml_response += "\t\t<NAME>#{match[2].strip}</NAME>"
|
||||
when "CPU"
|
||||
xml_response += "\t\t<vCPU>#{match[2].strip}</vCPU>"
|
||||
when "MEMORY"
|
||||
xml_response += "\t\t<vMEM>#{match[2].strip}</vMEM>"
|
||||
end
|
||||
}
|
||||
xml_response += "\t</COMPUTE_TYPE>"
|
||||
}
|
||||
|
||||
xml_response += "</ALLOWED_COMPUTE_TYPES>"
|
||||
|
||||
return xml_response, 200
|
||||
rescue Exception => e
|
||||
return "Error getting the instance types. Reason: #{e.message}", 500
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -26,7 +26,7 @@ class VirtualMachineOCCI < VirtualMachine
|
||||
<MEMORY><%= self['TEMPLATE/MEMORY'] %></MEMORY>
|
||||
<NAME><%= self.name%></NAME>
|
||||
<% if self['TEMPLATE/INSTANCE_TYPE'] %>
|
||||
<INSTANCE_TYPE><%= self['TEMPLATE/INSTANCE_TYPE'] %></INSTANCE_TYPE>
|
||||
<INSTANCE_TYPE href="<%= base_url %>/instance_type/<%= self['TEMPLATE/INSTANCE_TYPE'] %>"><%= self['TEMPLATE/INSTANCE_TYPE'] %></INSTANCE_TYPE>
|
||||
<% end %>
|
||||
<STATE><%= self.state_str %></STATE>
|
||||
<% self.each('TEMPLATE/DISK') do |disk| %>
|
||||
@ -84,10 +84,14 @@ class VirtualMachineOCCI < VirtualMachine
|
||||
end
|
||||
|
||||
if @vm_info != nil
|
||||
itype = @vm_info['INSTANCE_TYPE']
|
||||
if href = @vm_info.attr('INSTANCE_TYPE','href')
|
||||
@itype = href.split('/').last
|
||||
else
|
||||
@itype = @vm_info['INSTANCE_TYPE']
|
||||
end
|
||||
|
||||
if itype != nil and types[itype.to_sym] != nil
|
||||
@template = base + "/#{types[itype.to_sym][:template]}"
|
||||
if @itype != nil and types[@itype.to_sym] != nil
|
||||
@template = base + "/#{types[@itype.to_sym][:template]}"
|
||||
end
|
||||
end
|
||||
|
||||
@ -96,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
|
||||
|
@ -128,10 +128,20 @@ end
|
||||
# Actions
|
||||
##############################################################################
|
||||
|
||||
get '/' do
|
||||
result,rc = @occi_server.get_collections(request)
|
||||
treat_response(result,rc)
|
||||
end
|
||||
|
||||
###################################################
|
||||
# Pool Resources methods
|
||||
###################################################
|
||||
|
||||
get '/instance_type' do
|
||||
result,rc = @occi_server.get_instance_types(request)
|
||||
treat_response(result,rc)
|
||||
end
|
||||
|
||||
post '/compute' do
|
||||
result,rc = @occi_server.post_compute(request)
|
||||
treat_response(result,rc)
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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,6 +16,7 @@
|
||||
require 'thread'
|
||||
|
||||
=begin rdoc
|
||||
|
||||
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
|
||||
triggered (thread-safe), and will execute them concurrently. The action manager
|
||||
|
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,9 +43,16 @@ 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
|
||||
|
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
|
@ -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
|
||||
|
@ -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
|
@ -292,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 {
|
||||
|
@ -59,7 +59,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id="footer" class="ui-layout-south">
|
||||
Copyright 2002-2011 © OpenNebula Project Leads (<a href="http://opennebula.org" target="_blank">OpenNebula.org</a>). All Rights Reserved. OpenNebula 3.1.0
|
||||
Copyright 2002-2011 © OpenNebula Project Leads (<a href="http://opennebula.org" target="_blank">OpenNebula.org</a>). All Rights Reserved. OpenNebula 3.1.80
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -246,6 +246,8 @@ void RequestManager::register_xml_methods()
|
||||
// VirtualNetwork Methods
|
||||
xmlrpc_c::methodPtr vn_addleases(new VirtualNetworkAddLeases());
|
||||
xmlrpc_c::methodPtr vn_rmleases(new VirtualNetworkRemoveLeases());
|
||||
xmlrpc_c::methodPtr vn_hold(new VirtualNetworkHold());
|
||||
xmlrpc_c::methodPtr vn_release(new VirtualNetworkRelease());
|
||||
|
||||
// Update Template Methods
|
||||
xmlrpc_c::methodPtr image_update(new ImageUpdateTemplate());
|
||||
@ -357,6 +359,8 @@ void RequestManager::register_xml_methods()
|
||||
/* Network related methods*/
|
||||
RequestManagerRegistry.addMethod("one.vn.addleases", vn_addleases);
|
||||
RequestManagerRegistry.addMethod("one.vn.rmleases", vn_rmleases);
|
||||
RequestManagerRegistry.addMethod("one.vn.hold", vn_hold);
|
||||
RequestManagerRegistry.addMethod("one.vn.release", vn_release);
|
||||
RequestManagerRegistry.addMethod("one.vn.allocate", vn_allocate);
|
||||
RequestManagerRegistry.addMethod("one.vn.publish", vn_publish);
|
||||
RequestManagerRegistry.addMethod("one.vn.update", vn_update);
|
||||
|
@ -212,11 +212,13 @@ int HostAllocate::pool_allocate(xmlrpc_c::paramList const& paramList,
|
||||
string host = xmlrpc_c::value_string(paramList.getString(1));
|
||||
string im_mad = xmlrpc_c::value_string(paramList.getString(2));
|
||||
string vmm_mad = xmlrpc_c::value_string(paramList.getString(3));
|
||||
string tm_mad = xmlrpc_c::value_string(paramList.getString(4));
|
||||
string vnm_mad = xmlrpc_c::value_string(paramList.getString(4));
|
||||
string tm_mad = xmlrpc_c::value_string(paramList.getString(5));
|
||||
|
||||
HostPool * hpool = static_cast<HostPool *>(pool);
|
||||
|
||||
return hpool->allocate(&id, host, im_mad, vmm_mad, tm_mad, error_str);
|
||||
return hpool->allocate(&id, host, im_mad, vmm_mad, vnm_mad, tm_mad,
|
||||
error_str);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -89,6 +89,7 @@ bool RequestManagerVirtualMachine::vm_authorization(int oid,
|
||||
int RequestManagerVirtualMachine::get_host_information(int hid,
|
||||
string& name,
|
||||
string& vmm,
|
||||
string& vnm,
|
||||
string& tm,
|
||||
RequestAttributes& att)
|
||||
{
|
||||
@ -110,6 +111,7 @@ int RequestManagerVirtualMachine::get_host_information(int hid,
|
||||
|
||||
name = host->get_name();
|
||||
vmm = host->get_vmm_mad();
|
||||
vnm = host->get_vnm_mad();
|
||||
tm = host->get_tm_mad();
|
||||
|
||||
host->unlock();
|
||||
@ -142,6 +144,7 @@ int RequestManagerVirtualMachine::add_history(VirtualMachine * vm,
|
||||
int hid,
|
||||
const string& hostname,
|
||||
const string& vmm_mad,
|
||||
const string& vnm_mad,
|
||||
const string& tm_mad,
|
||||
RequestAttributes& att)
|
||||
{
|
||||
@ -154,7 +157,7 @@ int RequestManagerVirtualMachine::add_history(VirtualMachine * vm,
|
||||
|
||||
nd.get_configuration_attribute("VM_DIR",vmdir);
|
||||
|
||||
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);
|
||||
|
||||
@ -273,6 +276,7 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
|
||||
string hostname;
|
||||
string vmm_mad;
|
||||
string vnm_mad;
|
||||
string tm_mad;
|
||||
|
||||
int id = xmlrpc_c::value_int(paramList.getInt(1));
|
||||
@ -283,7 +287,7 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
return;
|
||||
}
|
||||
|
||||
if (get_host_information(hid,hostname,vmm_mad,tm_mad, att) != 0)
|
||||
if (get_host_information(hid,hostname,vmm_mad,vnm_mad,tm_mad, att) != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -303,7 +307,7 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
return;
|
||||
}
|
||||
|
||||
if ( add_history(vm,hid,hostname,vmm_mad,tm_mad,att) != 0)
|
||||
if ( add_history(vm,hid,hostname,vmm_mad,vnm_mad,tm_mad,att) != 0)
|
||||
{
|
||||
vm->unlock();
|
||||
return;
|
||||
@ -329,6 +333,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
|
||||
|
||||
string hostname;
|
||||
string vmm_mad;
|
||||
string vnm_mad;
|
||||
string tm_mad;
|
||||
|
||||
int id = xmlrpc_c::value_int(paramList.getInt(1));
|
||||
@ -340,7 +345,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
|
||||
return;
|
||||
}
|
||||
|
||||
if (get_host_information(hid,hostname,vmm_mad,tm_mad,att) != 0)
|
||||
if (get_host_information(hid,hostname,vmm_mad,vnm_mad,tm_mad,att) != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -362,7 +367,7 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
|
||||
return;
|
||||
}
|
||||
|
||||
if ( add_history(vm,hid,hostname,vmm_mad,tm_mad,att) != 0)
|
||||
if ( add_history(vm,hid,hostname,vmm_mad,vnm_mad,tm_mad,att) != 0)
|
||||
{
|
||||
vm->unlock();
|
||||
return;
|
||||
@ -412,6 +417,8 @@ void VirtualMachineSaveDisk::request_execute(xmlrpc_c::paramList const& paramLis
|
||||
oss << "NAME= \"" << img_name << "\"" << endl;
|
||||
oss << "PUBLIC = NO " << endl;
|
||||
oss << "SOURCE = - " << endl;
|
||||
oss << "SAVED_DISK_ID = " << disk_id << endl;
|
||||
oss << "SAVED_VM_ID = " << id << endl;
|
||||
|
||||
if ( img_type != "" )
|
||||
{
|
||||
|
@ -80,7 +80,7 @@ void RequestManagerVirtualNetwork::
|
||||
if ( rc < 0 )
|
||||
{
|
||||
failure_response(INTERNAL,
|
||||
request_error("Error modifiying network leases",error_str),
|
||||
request_error("Error modifying network leases",error_str),
|
||||
att);
|
||||
|
||||
vn->unlock();
|
||||
|
@ -14,8 +14,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
|
||||
|
||||
# VNC Configuration
|
||||
:vnc_proxy_base_port: 29876
|
||||
|
@ -29,6 +29,7 @@ module OpenNebulaJSON
|
||||
self.allocate(host_hash['name'],
|
||||
host_hash['im_mad'],
|
||||
host_hash['vm_mad'],
|
||||
host_hash['vnm_mad'],
|
||||
host_hash['tm_mad'])
|
||||
end
|
||||
|
||||
|
@ -48,6 +48,8 @@ module OpenNebulaJSON
|
||||
when "unpublish" then self.unpublish
|
||||
when "update" then self.update(action_hash['params'])
|
||||
when "chown" then self.chown(action_hash['params'])
|
||||
when "hold" then self.hold(action_hash['params'])
|
||||
when "release" then self.release(action_hash['params'])
|
||||
else
|
||||
error_msg = "#{action_hash['perform']} action not " <<
|
||||
" available for this resource"
|
||||
@ -70,5 +72,13 @@ module OpenNebulaJSON
|
||||
def chown(params=Hash.new)
|
||||
super(params['owner_id'].to_i,params['group_id'].to_i)
|
||||
end
|
||||
|
||||
def hold(params=Hash.new)
|
||||
super(params['ip'])
|
||||
end
|
||||
|
||||
def release(params=Hash.new)
|
||||
super(params['ip'])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -294,14 +294,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:148px;
|
||||
width:74px;
|
||||
width:58px !important;
|
||||
}
|
||||
|
||||
.remove_button {
|
||||
|
BIN
src/sunstone/public/images/green_bullet.png
Normal file
BIN
src/sunstone/public/images/green_bullet.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 484 B |
BIN
src/sunstone/public/images/red_bullet.png
Normal file
BIN
src/sunstone/public/images/red_bullet.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 484 B |
BIN
src/sunstone/public/images/yellow_bullet.png
Normal file
BIN
src/sunstone/public/images/yellow_bullet.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 449 B |
@ -511,6 +511,20 @@ var OpenNebula = {
|
||||
"rmleases",
|
||||
action_obj);
|
||||
},
|
||||
"hold" : function(params){
|
||||
var action_obj = params.data.extra_param;
|
||||
OpenNebula.Action.simple_action(params,
|
||||
OpenNebula.Network.resource,
|
||||
"hold",
|
||||
action_obj);
|
||||
},
|
||||
"release" : function(params){
|
||||
var action_obj = params.data.extra_param;
|
||||
OpenNebula.Action.simple_action(params,
|
||||
OpenNebula.Network.resource,
|
||||
"release",
|
||||
action_obj);
|
||||
},
|
||||
"update": function(params){
|
||||
var action_obj = {"template_raw" : params.data.extra_param };
|
||||
OpenNebula.Action.simple_action(params,
|
||||
|
@ -80,6 +80,15 @@ var create_host_tmpl =
|
||||
<option value="im_dummy">' + tr("Dummy") + '</option>\
|
||||
</select>\
|
||||
</div>\
|
||||
<div class="manager clear" id="vnm_mads">\
|
||||
<label>Virtual Network Manager:</label>\
|
||||
<select id="vnm_mad" name="vn">\
|
||||
<option value="dummy">Dummy</option>\
|
||||
<option value="etables">Etables</option>\
|
||||
<option value="ovswitch">Open vSwitch</option>\
|
||||
<option value="802.1Q">802.1Q</option>\
|
||||
</select>\
|
||||
</div>\
|
||||
<div class="manager clear" id="tm_mads">\
|
||||
<label>' + tr("Transfer Manager") + ':</label>\
|
||||
<select id="tm_mad" name="tm">\
|
||||
@ -443,6 +452,10 @@ function updateHostInfo(request,host){
|
||||
<td class="key_td">' + tr("VM MAD") + '</td>\
|
||||
<td class="value_td">'+host_info.VM_MAD+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">'+ tr("VN MAD") +'</td>\
|
||||
<td class="value_td">'+host_info.VN_MAD+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">'+ tr("TM MAD") +'</td>\
|
||||
<td class="value_td">'+host_info.TM_MAD+'</td>\
|
||||
@ -537,6 +550,7 @@ function setupCreateHostDialog(){
|
||||
"name": $('#name',this).val(),
|
||||
"tm_mad": $('#tm_mad :selected',this).val(),
|
||||
"vm_mad": $('#vmm_mad :selected',this).val(),
|
||||
"vnm_mad": $('#vnm_mad :selected',this).val(),
|
||||
"im_mad": $('#im_mad :selected',this).val()
|
||||
}
|
||||
}
|
||||
|
@ -85,8 +85,14 @@ var create_vn_tmpl =
|
||||
<fieldset>\
|
||||
<label for="net_address">'+tr("Network Address")+':</label>\
|
||||
<input type="text" name="net_address" id="net_address" /><br />\
|
||||
<label for="net_size">'+tr("Network size")+':</label>\
|
||||
<input type="text" name="net_size" id="net_size" />\
|
||||
<label for="net_mask">'+tr("Network Mask")+':</label>\
|
||||
<input type="text" name="net_mask" id="net_mask" /><br />\
|
||||
<label for="custom_pool" style="height:2em;">'+tr("Define a subnet by IP range")+':</label>\
|
||||
<input type="checkbox" name="custom_pool" id="custom_pool" style="margin-bottom:2em;" value="yes" /><br />\
|
||||
<label for="ip_start">'+tr("IP Start")+':</label>\
|
||||
<input type="text" name="ip_start" id="ip_start" disabled="disabled" /><br />\
|
||||
<label for="ip_end">'+tr("IP End")+':</label>\
|
||||
<input type="text" name="ip_end" id="ip_end" disabled="disabled" />\
|
||||
</fieldset>\
|
||||
</div>\
|
||||
</div>\
|
||||
@ -95,9 +101,9 @@ var create_vn_tmpl =
|
||||
<fieldset>\
|
||||
<div class="">\
|
||||
<label for="custom_var_vnet_name">'+tr("Name")+':</label>\
|
||||
<input type="text" id="custom_var_vnet_name" name="custom_var_vnet_name" />\
|
||||
<input type="text" id="custom_var_vnet_name" name="custom_var_vnet_name" /><br />\
|
||||
<label for="custom_var_vnet_value">'+tr("Value")+':</label>\
|
||||
<input type="text" id="custom_var_vnet_value" name="custom_var_vnet_value" />\
|
||||
<input type="text" id="custom_var_vnet_value" name="custom_var_vnet_value" /><br />\
|
||||
<button class="add_remove_button add_button" id="add_custom_var_vnet_button" value="add_custom_vnet_var">'+tr("Add")+'</button>\
|
||||
<button class="add_remove_button" id="remove_custom_var_vnet_button" value="remove_custom_vnet_var">'+tr("Remove selected")+'</button>\
|
||||
<div class="clear"></div>\
|
||||
@ -248,7 +254,7 @@ var vnet_actions = {
|
||||
call: OpenNebula.Network.addleases,
|
||||
callback: vnShow,
|
||||
error: onError,
|
||||
notify: true
|
||||
notify: false,
|
||||
},
|
||||
|
||||
"Network.rmleases" : {
|
||||
@ -256,27 +262,23 @@ var vnet_actions = {
|
||||
call: OpenNebula.Network.rmleases,
|
||||
callback: vnShow,
|
||||
error: onError,
|
||||
notify: true
|
||||
notify: false,
|
||||
},
|
||||
|
||||
"Network.modifyleases" : {
|
||||
type: "custom",
|
||||
call: function(action,obj){
|
||||
nodes = getSelectedNodes(dataTable_vNetworks);
|
||||
$.each(nodes,function(){
|
||||
Sunstone.runAction(action,this,obj);
|
||||
});
|
||||
}
|
||||
"Network.hold" : {
|
||||
type: "single",
|
||||
call: OpenNebula.Network.hold,
|
||||
callback: vnShow,
|
||||
error: onError,
|
||||
notify: false,
|
||||
},
|
||||
|
||||
"Network.addleases_dialog" : {
|
||||
type: "custom",
|
||||
call: popUpAddLeaseDialog
|
||||
},
|
||||
|
||||
"Network.rmleases_dialog" : {
|
||||
type: "custom",
|
||||
call: popUpRemoveLeaseDialog
|
||||
"Network.release" : {
|
||||
type: "single",
|
||||
call: OpenNebula.Network.release,
|
||||
callback: vnShow,
|
||||
error: onError,
|
||||
notify: false,
|
||||
},
|
||||
|
||||
"Network.chown" : {
|
||||
@ -369,20 +371,6 @@ var vnet_buttons = {
|
||||
condition: mustBeAdmin,
|
||||
},
|
||||
|
||||
"action_list" : {
|
||||
type: "select",
|
||||
actions: {
|
||||
"Network.addleases_dialog" : {
|
||||
type: "action",
|
||||
text: tr("Add lease")
|
||||
},
|
||||
"Network.rmleases_dialog" : {
|
||||
type: "action",
|
||||
text: tr("Remove lease")
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"Network.delete" : {
|
||||
type: "action",
|
||||
text: tr("Delete")
|
||||
@ -394,10 +382,10 @@ var vnet_info_panel = {
|
||||
title: tr("Virtual network information"),
|
||||
content: ""
|
||||
},
|
||||
"vnet_template_tab" : {
|
||||
title: tr("Virtual network template"),
|
||||
"vnet_leases_tab" : {
|
||||
title: tr("Lease management"),
|
||||
content: ""
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
var vnets_tab = {
|
||||
@ -455,6 +443,9 @@ function updateVNetworkElement(request, vn_json){
|
||||
id = vn_json.VNET.ID;
|
||||
element = vNetworkElementArray(vn_json);
|
||||
updateSingleElement(element,dataTable_vNetworks,'#vnetwork_'+id);
|
||||
|
||||
//we update this too, even if it's not shown.
|
||||
$('#leases_form').replaceWith(printLeases(vn_json.VNET));
|
||||
}
|
||||
|
||||
//Callback to delete a vnet element from the table
|
||||
@ -466,6 +457,8 @@ function deleteVNetworkElement(req){
|
||||
function addVNetworkElement(request,vn_json){
|
||||
var element = vNetworkElementArray(vn_json);
|
||||
addElement(element,dataTable_vNetworks);
|
||||
//we update this too, even if it's not shown.
|
||||
$('#leases_form').replaceWith(printLeases(vn_json.VNET));
|
||||
}
|
||||
|
||||
//updates the list of virtual networks
|
||||
@ -495,6 +488,10 @@ function updateVNetworkInfo(request,vn){
|
||||
<td class="key_td">'+tr("ID")+'</td>\
|
||||
<td class="value_td">'+vn_info.ID+'</td>\
|
||||
<tr>\
|
||||
<tr>\
|
||||
<td class="key_td">'+tr("Name")+'</td>\
|
||||
<td class="value_td">'+vn_info.NAME+'</td>\
|
||||
<tr>\
|
||||
<tr>\
|
||||
<td class="key_td">'+tr("Owner")+'</td>\
|
||||
<td class="value_td">'+vn_info.UNAME+'</td>\
|
||||
@ -509,52 +506,135 @@ function updateVNetworkInfo(request,vn){
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">'+tr("Physical device")+'</td>\
|
||||
<td class="value_td">'+(vn_info.PHYDEV ? vn_info.PHYDEV : "--" )+'</td>\
|
||||
<td class="value_td">'+ (typeof(vn_info.PHYDEV) == "object" ? "--": vn_info.PHYDEV) +'</td>\
|
||||
</tr>\
|
||||
</table>\
|
||||
<table id="vn_leases_info_table" class="info_table">\
|
||||
<thead>\
|
||||
<tr><th colspan="2">'+tr("Leases information")+'</th></tr>\
|
||||
</thead>'+
|
||||
printLeases(vn_info.LEASES)+
|
||||
'</table>';;
|
||||
<tr>\
|
||||
<td class="key_td">'+tr("VNET ID")+'</td>\
|
||||
<td class="value_td">'+ (typeof(vn_info.VLAN_ID) == "object" ? "--": vn_info.VLAN_ID) +'</td>\
|
||||
</tr>\
|
||||
</table>';
|
||||
|
||||
info_tab_content += '\
|
||||
<table id="vn_template_table" class="info_table">\
|
||||
<thead><tr><th colspan="2">'+tr("Virtual Network template (attributes)")+'</th></tr></thead>'+
|
||||
prettyPrintJSON(vn_info.TEMPLATE)+
|
||||
'</table>';
|
||||
|
||||
|
||||
var leases_tab_content = printLeases(vn_info);
|
||||
|
||||
var info_tab = {
|
||||
title: tr("Virtual Network information"),
|
||||
content: info_tab_content
|
||||
}
|
||||
};
|
||||
|
||||
var template_tab = {
|
||||
title: tr("Virtual Network template"),
|
||||
content:
|
||||
'<table id="vn_template_table" class="info_table" style="width:80%">\
|
||||
<thead><tr><th colspan="2">'+tr("Virtual Network template")+'</th></tr></thead>'+
|
||||
prettyPrintJSON(vn_info.TEMPLATE)+
|
||||
'</table>'
|
||||
}
|
||||
var leases_tab = {
|
||||
title: "Lease management",
|
||||
content: leases_tab_content
|
||||
};
|
||||
|
||||
Sunstone.updateInfoPanelTab("vnet_info_panel","vnet_info_tab",info_tab);
|
||||
Sunstone.updateInfoPanelTab("vnet_info_panel","vnet_template_tab",template_tab);
|
||||
Sunstone.updateInfoPanelTab("vnet_info_panel","vnet_leases_tab",leases_tab);
|
||||
|
||||
Sunstone.popUpInfoPanel("vnet_info_panel");
|
||||
|
||||
}
|
||||
|
||||
function printLeases(leases){
|
||||
if (!leases.LEASE) //empty
|
||||
{
|
||||
return "";
|
||||
function printLeases(vn_info){
|
||||
var html ='<form style="display:inline-block;width:80%" id="leases_form" vnid="'+vn_info.ID+'"><table id="vn_leases_info_table" class="info_table" style="width:100%;">\
|
||||
<thead>\
|
||||
<tr><th colspan="2">'+tr("Leases information")+'</th></tr>\
|
||||
</thead><tbody>';
|
||||
|
||||
if (vn_info.TYPE == "0"){
|
||||
html += '<tr>\
|
||||
<td class="key_td">'+tr("IP Start")+'</td>\
|
||||
<td class="value_td">'+vn_info.RANGE.IP_START+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">'+tr("IP End")+'</td>\
|
||||
<td class="value_td">'+vn_info.RANGE.IP_END+'</td>\
|
||||
</tr\>\
|
||||
<tr>\
|
||||
<td class="key_td">'+tr("Network mask")+'</td>\
|
||||
<td class="value_td">'+( vn_info.TEMPLATE.NETWORK_MASK ? vn_info.TEMPLATE.NETWORK_MASK : "--" )+'</td>\
|
||||
</tr\>\
|
||||
<tr><td class="key_td">\
|
||||
<label for="panel_hold_lease">'+tr("Hold lease")+':</label></td><td class="value_td"><input type="text" id="panel_hold_lease" style="width:9em;"/>\
|
||||
<button id="panel_hold_lease_button">'+tr("Hold")+'</button>\
|
||||
</td></tr>';
|
||||
} else {
|
||||
html += '<tr><td class="key_td">\
|
||||
<label for="panel_add_lease">'+tr("Add lease")+':</label></td><td class="value_td"><input type="text" id="panel_add_lease" style="width:9em;"/>\
|
||||
<button id="panel_add_lease_button">'+tr("Add")+'</button>\
|
||||
</td></tr>';
|
||||
};
|
||||
|
||||
if (leases.LEASE.constructor == Array) //>1 lease
|
||||
var leases = vn_info.LEASES.LEASE;
|
||||
|
||||
if (!leases) //empty
|
||||
{
|
||||
return prettyPrintJSON(leases.LEASE);
|
||||
html+='<tr id="no_leases_tr"><td class="key_td">\
|
||||
'+tr("No leases to show")+'\
|
||||
</td>\
|
||||
<td class="value_td">\
|
||||
</td></tr>';
|
||||
return html;
|
||||
}
|
||||
else {//1 lease
|
||||
return prettyPrintJSON([leases.LEASE]);
|
||||
else if (leases.constructor != Array) //>1 lease
|
||||
{
|
||||
leases = [leases];
|
||||
};
|
||||
|
||||
var lease;
|
||||
var state=null;
|
||||
|
||||
for (var i=0; i<leases.length; i++){
|
||||
lease = leases[i];
|
||||
|
||||
if (lease.USED != "0" && lease.VID == "-1") { //hold
|
||||
state = 2;
|
||||
} else { //free
|
||||
state = parseInt(lease.USED,10);
|
||||
};
|
||||
|
||||
|
||||
html+='<tr ip="'+lease.IP+'"><td class="key_td">';
|
||||
html+='<img style="vertical-align:middle;margin-right:5px;" ';
|
||||
switch (state){
|
||||
case 0: //free
|
||||
html += 'src="images/green_bullet.png" />';
|
||||
break;
|
||||
case 1: //used
|
||||
html += 'src="images/red_bullet.png" />';
|
||||
break;
|
||||
case 2: //hold
|
||||
html += 'src="images/yellow_bullet.png" />';
|
||||
break;
|
||||
};
|
||||
|
||||
html += lease.IP + '</td>';
|
||||
|
||||
html += '<td class="value_td">\
|
||||
'+lease.MAC+'  ';
|
||||
|
||||
switch (state){
|
||||
case 0:
|
||||
html += '<a class="hold_lease" href="#">'+tr("hold")+'</a> | <a class="delete_lease" href="#">'+tr("delete")+'</a>';
|
||||
break;
|
||||
case 1:
|
||||
html += tr("Used by VM")+' '+lease.VID;
|
||||
break;
|
||||
case 2:
|
||||
html += '<a class="release_lease" href="#">'+tr("release")+'</a>';
|
||||
break;
|
||||
};
|
||||
html += '</td></tr>';
|
||||
};
|
||||
|
||||
html += '</tbody></table></form>';
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
//Prepares the vnet creation dialog
|
||||
@ -623,6 +703,17 @@ function setupCreateVNetDialog() {
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#custom_pool', dialog).change(function(){
|
||||
if ($(this).is(':checked')){
|
||||
$('#ip_start', $create_vn_dialog).removeAttr('disabled');
|
||||
$('#ip_end', $create_vn_dialog).removeAttr('disabled');
|
||||
}
|
||||
else {
|
||||
$('#ip_start', $create_vn_dialog).attr('disabled','disabled');
|
||||
$('#ip_end', $create_vn_dialog).attr('disabled','disabled');
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
$('#add_custom_var_vnet_button', dialog).click(
|
||||
function(){
|
||||
@ -682,7 +773,11 @@ function setupCreateVNetDialog() {
|
||||
else { //type ranged
|
||||
|
||||
var network_addr = $('#net_address',this).val();
|
||||
var network_size = $('#net_size',this).val();
|
||||
var network_mask = $('#net_mask',this).val();
|
||||
var custom = $('#custom_pool',this).is(':checked');
|
||||
var ip_start = $('#ip_start',this).val();
|
||||
var ip_end = $('#ip_end',this).val();
|
||||
|
||||
if (!network_addr.length){
|
||||
notifyError(tr("Please provide a network address"));
|
||||
return false;
|
||||
@ -693,10 +788,17 @@ function setupCreateVNetDialog() {
|
||||
"vnet" : {
|
||||
"type" : "RANGED",
|
||||
"bridge" : bridge,
|
||||
"network_size" : network_size,
|
||||
"network_mask" : network_mask,
|
||||
"network_address" : network_addr,
|
||||
"name" : name }
|
||||
};
|
||||
|
||||
if (custom){
|
||||
if (ip_start.length)
|
||||
network_json["vnet"]["ip_start"] = ip_start;
|
||||
if (ip_end.length)
|
||||
network_json["vnet"]["ip_start"] = ip_end;
|
||||
};
|
||||
};
|
||||
|
||||
//Time to add custom attributes
|
||||
@ -827,71 +929,58 @@ function popUpVNetTemplateUpdateDialog(){
|
||||
|
||||
}
|
||||
|
||||
function setupAddRemoveLeaseDialog() {
|
||||
dialogs_context.append('<div title="'+tr("Lease management")+'" id="lease_vn_dialog"></div>');
|
||||
$lease_vn_dialog = $('#lease_vn_dialog',dialogs_context)
|
||||
|
||||
var dialog = $lease_vn_dialog;
|
||||
|
||||
dialog.html(
|
||||
'<form id="lease_vn_form" action="javascript:alert(\'js error!\');">\
|
||||
<fieldset>\
|
||||
<div>'+tr("Please specify")+':</div>\
|
||||
<label for="add_lease_ip">'+tr("Lease IP")+':</label>\
|
||||
<input type="text" name="add_lease_ip" id="add_lease_ip" /><br />\
|
||||
<label id="add_lease_mac_label" for="add_lease_mac">'+tr("Lease MAC")+':</label>\
|
||||
<input type="text" name="add_lease_mac" id="add_lease_mac" />\
|
||||
</select>\
|
||||
</fieldset>\
|
||||
<fieldset>\
|
||||
<div class="form_buttons">\
|
||||
<button id="lease_vn_proceed" class="" value="">'+tr("OK")+'</button>\
|
||||
<button class="confirm_cancel" value="">'+tr("Cancel")+'</button>\
|
||||
</div>\
|
||||
</fieldset>\
|
||||
</form>'
|
||||
);
|
||||
|
||||
//Prepare the jquery-ui dialog. Set style options here.
|
||||
dialog.dialog({
|
||||
autoOpen: false,
|
||||
modal: true,
|
||||
width: 410,
|
||||
height: 220
|
||||
});
|
||||
|
||||
$('button',dialog).button();
|
||||
|
||||
$('#lease_vn_form',dialog).submit(function(){
|
||||
var ip = $('#add_lease_ip',this).val();
|
||||
var mac = $('#add_lease_mac',this).val();
|
||||
|
||||
var obj = {ip: ip, mac: mac};
|
||||
|
||||
if (!mac.length) { delete obj.mac; };
|
||||
|
||||
Sunstone.runAction("Network.modifyleases",
|
||||
$('#lease_vn_proceed',this).val(),
|
||||
obj);
|
||||
$lease_vn_dialog.dialog('close');
|
||||
function setupLeasesOps(){
|
||||
$('button#panel_add_lease_button').live("click",function(){
|
||||
var lease = $(this).prev().val();
|
||||
//var mac = $(this).previous().val();
|
||||
var id = $(this).parents('form').attr('vnid');
|
||||
if (lease.length){
|
||||
var obj = {ip: lease};
|
||||
Sunstone.runAction('Network.addleases',id,obj);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
function popUpAddLeaseDialog() {
|
||||
$lease_vn_dialog.dialog("option","title",tr("Add lease"));
|
||||
$('#add_lease_mac',$lease_vn_dialog).show();
|
||||
$('#add_lease_mac_label',$lease_vn_dialog).show();
|
||||
$('#lease_vn_proceed',$lease_vn_dialog).val("Network.addleases");
|
||||
$lease_vn_dialog.dialog("open");
|
||||
$('button#panel_hold_lease_button').live("click",function(){
|
||||
var lease = $(this).prev().val();
|
||||
//var mac = $(this).previous().val();
|
||||
var id = $(this).parents('form').attr('vnid');
|
||||
if (lease.length){
|
||||
var obj = {ip: lease};
|
||||
Sunstone.runAction('Network.hold',id,obj);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
function popUpRemoveLeaseDialog() {
|
||||
$lease_vn_dialog.dialog("option","title",tr("Remove lease"));
|
||||
$('#add_lease_mac',$lease_vn_dialog).hide();
|
||||
$('#add_lease_mac_label',$lease_vn_dialog).hide();
|
||||
$('#lease_vn_proceed',$lease_vn_dialog).val("Network.rmleases");
|
||||
$lease_vn_dialog.dialog("open");
|
||||
$('form#leases_form a.delete_lease').live("click",function(){
|
||||
var lease = $(this).parents('tr').attr('ip');
|
||||
var id = $(this).parents('form').attr('vnid');
|
||||
var obj = { ip: lease};
|
||||
Sunstone.runAction('Network.rmleases',id,obj);
|
||||
//Set spinner
|
||||
$(this).parents('tr').html('<td class="key_td">'+spinner+'</td><td class="value_td"></td>');
|
||||
return false;
|
||||
});
|
||||
|
||||
$('a.hold_lease').live("click",function(){
|
||||
var lease = $(this).parents('tr').attr('ip');
|
||||
var id = $(this).parents('form').attr('vnid');
|
||||
var obj = { ip: lease};
|
||||
Sunstone.runAction('Network.hold',id,obj);
|
||||
//Set spinner
|
||||
$(this).parents('tr').html('<td class="key_td">'+spinner+'</td><td class="value_td"></td>');
|
||||
return false;
|
||||
});
|
||||
|
||||
$('a.release_lease').live("click",function(){
|
||||
var lease = $(this).parents('tr').attr('ip');
|
||||
var id = $(this).parents('form').attr('vnid');
|
||||
var obj = { ip: lease};
|
||||
Sunstone.runAction('Network.release',id,obj);
|
||||
//Set spinner
|
||||
$(this).parents('tr').html('<td class="key_td">'+spinner+'</td><td class="value_td"></td>');
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
function setVNetAutorefresh() {
|
||||
@ -907,7 +996,7 @@ function setVNetAutorefresh() {
|
||||
|
||||
function is_public_vnet(id) {
|
||||
var data = getElementData(id,"#vnetwork",dataTable_vNetworks)[7];
|
||||
return $(data).attr('checked');
|
||||
return $(data).is(":checked");
|
||||
};
|
||||
|
||||
function setupVNetActionCheckboxes(){
|
||||
@ -951,7 +1040,7 @@ $(document).ready(function(){
|
||||
|
||||
setupCreateVNetDialog();
|
||||
setupVNetTemplateUpdateDialog();
|
||||
setupAddRemoveLeaseDialog();
|
||||
setupLeasesOps();
|
||||
setupVNetActionCheckboxes();
|
||||
setVNetAutorefresh();
|
||||
|
||||
|
@ -83,7 +83,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id="footer" class="ui-layout-south">
|
||||
Copyright 2002-2011 © OpenNebula Project Leads (<a href="http://opennebula.org" target="_blank">OpenNebula.org</a>). All Rights Reserved. OpenNebula 3.1.0
|
||||
Copyright 2002-2011 © OpenNebula Project Leads (<a href="http://opennebula.org" target="_blank">OpenNebula.org</a>). All Rights Reserved. OpenNebula 3.1.80
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -1,9 +1,8 @@
|
||||
/* A Bison parser, made by GNU Bison 2.4.2. */
|
||||
/* A Bison parser, made by GNU Bison 2.5. */
|
||||
|
||||
/* Skeleton implementation for Bison's Yacc-like parsers in C
|
||||
/* Bison implementation for Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software
|
||||
Foundation, Inc.
|
||||
Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -45,7 +44,7 @@
|
||||
#define YYBISON 1
|
||||
|
||||
/* Bison version. */
|
||||
#define YYBISON_VERSION "2.4.2"
|
||||
#define YYBISON_VERSION "2.5"
|
||||
|
||||
/* Skeleton name. */
|
||||
#define YYSKELETON_NAME "yacc.c"
|
||||
@ -74,7 +73,7 @@
|
||||
|
||||
/* Copy the first part of user declarations. */
|
||||
|
||||
/* Line 189 of yacc.c */
|
||||
/* Line 268 of yacc.c */
|
||||
#line 17 "template_syntax.y"
|
||||
|
||||
#include <iostream>
|
||||
@ -127,8 +126,8 @@ extern "C"
|
||||
|
||||
|
||||
|
||||
/* Line 189 of yacc.c */
|
||||
#line 132 "template_syntax.cc"
|
||||
/* Line 268 of yacc.c */
|
||||
#line 131 "template_syntax.cc"
|
||||
|
||||
/* Enabling traces. */
|
||||
#ifndef YYDEBUG
|
||||
@ -171,7 +170,7 @@ extern "C"
|
||||
typedef union YYSTYPE
|
||||
{
|
||||
|
||||
/* Line 214 of yacc.c */
|
||||
/* Line 293 of yacc.c */
|
||||
#line 74 "template_syntax.y"
|
||||
|
||||
char * val_str;
|
||||
@ -179,8 +178,8 @@ typedef union YYSTYPE
|
||||
|
||||
|
||||
|
||||
/* Line 214 of yacc.c */
|
||||
#line 184 "template_syntax.cc"
|
||||
/* Line 293 of yacc.c */
|
||||
#line 183 "template_syntax.cc"
|
||||
} YYSTYPE;
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
@ -204,8 +203,8 @@ typedef struct YYLTYPE
|
||||
/* Copy the second part of user declarations. */
|
||||
|
||||
|
||||
/* Line 264 of yacc.c */
|
||||
#line 209 "template_syntax.cc"
|
||||
/* Line 343 of yacc.c */
|
||||
#line 208 "template_syntax.cc"
|
||||
|
||||
#ifdef short
|
||||
# undef short
|
||||
@ -308,11 +307,11 @@ YYID (yyi)
|
||||
# define alloca _alloca
|
||||
# else
|
||||
# define YYSTACK_ALLOC alloca
|
||||
# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
|
||||
# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
|
||||
|| defined __cplusplus || defined _MSC_VER)
|
||||
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
|
||||
# ifndef _STDLIB_H
|
||||
# define _STDLIB_H 1
|
||||
# ifndef EXIT_SUCCESS
|
||||
# define EXIT_SUCCESS 0
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
@ -335,24 +334,24 @@ YYID (yyi)
|
||||
# ifndef YYSTACK_ALLOC_MAXIMUM
|
||||
# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
|
||||
# endif
|
||||
# if (defined __cplusplus && ! defined _STDLIB_H \
|
||||
# if (defined __cplusplus && ! defined EXIT_SUCCESS \
|
||||
&& ! ((defined YYMALLOC || defined malloc) \
|
||||
&& (defined YYFREE || defined free)))
|
||||
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
|
||||
# ifndef _STDLIB_H
|
||||
# define _STDLIB_H 1
|
||||
# ifndef EXIT_SUCCESS
|
||||
# define EXIT_SUCCESS 0
|
||||
# endif
|
||||
# endif
|
||||
# ifndef YYMALLOC
|
||||
# define YYMALLOC malloc
|
||||
# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
|
||||
# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
|
||||
|| defined __cplusplus || defined _MSC_VER)
|
||||
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
|
||||
# endif
|
||||
# endif
|
||||
# ifndef YYFREE
|
||||
# define YYFREE free
|
||||
# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
|
||||
# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
|
||||
|| defined __cplusplus || defined _MSC_VER)
|
||||
void free (void *); /* INFRINGES ON USER NAME SPACE */
|
||||
# endif
|
||||
@ -383,23 +382,7 @@ union yyalloc
|
||||
((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
|
||||
+ 2 * YYSTACK_GAP_MAXIMUM)
|
||||
|
||||
/* Copy COUNT objects from FROM to TO. The source and destination do
|
||||
not overlap. */
|
||||
# ifndef YYCOPY
|
||||
# if defined __GNUC__ && 1 < __GNUC__
|
||||
# define YYCOPY(To, From, Count) \
|
||||
__builtin_memcpy (To, From, (Count) * sizeof (*(From)))
|
||||
# else
|
||||
# define YYCOPY(To, From, Count) \
|
||||
do \
|
||||
{ \
|
||||
YYSIZE_T yyi; \
|
||||
for (yyi = 0; yyi < (Count); yyi++) \
|
||||
(To)[yyi] = (From)[yyi]; \
|
||||
} \
|
||||
while (YYID (0))
|
||||
# endif
|
||||
# endif
|
||||
# define YYCOPY_NEEDED 1
|
||||
|
||||
/* Relocate STACK from its old location to the new one. The
|
||||
local variables YYSIZE and YYSTACKSIZE give the old and new number of
|
||||
@ -419,6 +402,26 @@ union yyalloc
|
||||
|
||||
#endif
|
||||
|
||||
#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
|
||||
/* Copy COUNT objects from FROM to TO. The source and destination do
|
||||
not overlap. */
|
||||
# ifndef YYCOPY
|
||||
# if defined __GNUC__ && 1 < __GNUC__
|
||||
# define YYCOPY(To, From, Count) \
|
||||
__builtin_memcpy (To, From, (Count) * sizeof (*(From)))
|
||||
# else
|
||||
# define YYCOPY(To, From, Count) \
|
||||
do \
|
||||
{ \
|
||||
YYSIZE_T yyi; \
|
||||
for (yyi = 0; yyi < (Count); yyi++) \
|
||||
(To)[yyi] = (From)[yyi]; \
|
||||
} \
|
||||
while (YYID (0))
|
||||
# endif
|
||||
# endif
|
||||
#endif /* !YYCOPY_NEEDED */
|
||||
|
||||
/* YYFINAL -- State number of the termination state. */
|
||||
#define YYFINAL 6
|
||||
/* YYLAST -- Last index in YYTABLE. */
|
||||
@ -528,8 +531,8 @@ static const yytype_uint8 yyr2[] =
|
||||
0, 2, 1, 2, 3, 5, 2, 3, 5
|
||||
};
|
||||
|
||||
/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
|
||||
STATE-NUM when YYTABLE doesn't specify something else to do. Zero
|
||||
/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
|
||||
Performed when YYTABLE doesn't specify something else to do. Zero
|
||||
means the default is an error. */
|
||||
static const yytype_uint8 yydefact[] =
|
||||
{
|
||||
@ -560,8 +563,7 @@ static const yytype_int8 yypgoto[] =
|
||||
|
||||
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
|
||||
positive, shift that token. If negative, reduce the rule which
|
||||
number is the opposite. If zero, do what YYDEFACT says.
|
||||
If YYTABLE_NINF, syntax error. */
|
||||
number is the opposite. If YYTABLE_NINF, syntax error. */
|
||||
#define YYTABLE_NINF -1
|
||||
static const yytype_uint8 yytable[] =
|
||||
{
|
||||
@ -569,6 +571,12 @@ static const yytype_uint8 yytable[] =
|
||||
12, 15, 17, 16, 18, 7
|
||||
};
|
||||
|
||||
#define yypact_value_is_default(yystate) \
|
||||
((yystate) == (-8))
|
||||
|
||||
#define yytable_value_is_error(yytable_value) \
|
||||
YYID (0)
|
||||
|
||||
static const yytype_uint8 yycheck[] =
|
||||
{
|
||||
0, 3, 9, 9, 5, 7, 4, 8, 6, 9,
|
||||
@ -616,7 +624,6 @@ do \
|
||||
{ \
|
||||
yychar = (Token); \
|
||||
yylval = (Value); \
|
||||
yytoken = YYTRANSLATE (yychar); \
|
||||
YYPOPSTACK (1); \
|
||||
goto yybackup; \
|
||||
} \
|
||||
@ -880,7 +887,6 @@ int yydebug;
|
||||
# define YYMAXDEPTH 10000
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if YYERROR_VERBOSE
|
||||
|
||||
@ -983,115 +989,142 @@ yytnamerr (char *yyres, const char *yystr)
|
||||
}
|
||||
# endif
|
||||
|
||||
/* Copy into YYRESULT an error message about the unexpected token
|
||||
YYCHAR while in state YYSTATE. Return the number of bytes copied,
|
||||
including the terminating null byte. If YYRESULT is null, do not
|
||||
copy anything; just return the number of bytes that would be
|
||||
copied. As a special case, return 0 if an ordinary "syntax error"
|
||||
message will do. Return YYSIZE_MAXIMUM if overflow occurs during
|
||||
size calculation. */
|
||||
static YYSIZE_T
|
||||
yysyntax_error (char *yyresult, int yystate, int yychar)
|
||||
{
|
||||
int yyn = yypact[yystate];
|
||||
/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
|
||||
about the unexpected token YYTOKEN for the state stack whose top is
|
||||
YYSSP.
|
||||
|
||||
if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
|
||||
return 0;
|
||||
else
|
||||
Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
|
||||
not large enough to hold the message. In that case, also set
|
||||
*YYMSG_ALLOC to the required number of bytes. Return 2 if the
|
||||
required number of bytes is too large to store. */
|
||||
static int
|
||||
yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
|
||||
yytype_int16 *yyssp, int yytoken)
|
||||
{
|
||||
int yytype = YYTRANSLATE (yychar);
|
||||
YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
|
||||
YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
|
||||
YYSIZE_T yysize = yysize0;
|
||||
YYSIZE_T yysize1;
|
||||
int yysize_overflow = 0;
|
||||
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
|
||||
/* Internationalized format string. */
|
||||
const char *yyformat = 0;
|
||||
/* Arguments of yyformat. */
|
||||
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
|
||||
int yyx;
|
||||
|
||||
# if 0
|
||||
/* This is so xgettext sees the translatable formats that are
|
||||
constructed on the fly. */
|
||||
YY_("syntax error, unexpected %s");
|
||||
YY_("syntax error, unexpected %s, expecting %s");
|
||||
YY_("syntax error, unexpected %s, expecting %s or %s");
|
||||
YY_("syntax error, unexpected %s, expecting %s or %s or %s");
|
||||
YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
|
||||
# endif
|
||||
char *yyfmt;
|
||||
char const *yyf;
|
||||
static char const yyunexpected[] = "syntax error, unexpected %s";
|
||||
static char const yyexpecting[] = ", expecting %s";
|
||||
static char const yyor[] = " or %s";
|
||||
char yyformat[sizeof yyunexpected
|
||||
+ sizeof yyexpecting - 1
|
||||
+ ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
|
||||
* (sizeof yyor - 1))];
|
||||
char const *yyprefix = yyexpecting;
|
||||
/* Number of reported tokens (one for the "unexpected", one per
|
||||
"expected"). */
|
||||
int yycount = 0;
|
||||
|
||||
/* There are many possibilities here to consider:
|
||||
- Assume YYFAIL is not used. It's too flawed to consider. See
|
||||
<http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
|
||||
for details. YYERROR is fine as it does not invoke this
|
||||
function.
|
||||
- If this state is a consistent state with a default action, then
|
||||
the only way this function was invoked is if the default action
|
||||
is an error action. In that case, don't check for expected
|
||||
tokens because there are none.
|
||||
- The only way there can be no lookahead present (in yychar) is if
|
||||
this state is a consistent state with a default action. Thus,
|
||||
detecting the absence of a lookahead is sufficient to determine
|
||||
that there is no unexpected or expected token to report. In that
|
||||
case, just report a simple "syntax error".
|
||||
- Don't assume there isn't a lookahead just because this state is a
|
||||
consistent state with a default action. There might have been a
|
||||
previous inconsistent state, consistent state with a non-default
|
||||
action, or user semantic action that manipulated yychar.
|
||||
- Of course, the expected token list depends on states to have
|
||||
correct lookahead information, and it depends on the parser not
|
||||
to perform extra reductions after fetching a lookahead from the
|
||||
scanner and before detecting a syntax error. Thus, state merging
|
||||
(from LALR or IELR) and default reductions corrupt the expected
|
||||
token list. However, the list is correct for canonical LR with
|
||||
one exception: it will still contain any token that will not be
|
||||
accepted due to an error action in a later state.
|
||||
*/
|
||||
if (yytoken != YYEMPTY)
|
||||
{
|
||||
int yyn = yypact[*yyssp];
|
||||
yyarg[yycount++] = yytname[yytoken];
|
||||
if (!yypact_value_is_default (yyn))
|
||||
{
|
||||
/* Start YYX at -YYN if negative to avoid negative indexes in
|
||||
YYCHECK. */
|
||||
YYCHECK. In other words, skip the first -YYN actions for
|
||||
this state because they are default actions. */
|
||||
int yyxbegin = yyn < 0 ? -yyn : 0;
|
||||
|
||||
/* Stay within bounds of both yycheck and yytname. */
|
||||
int yychecklim = YYLAST - yyn + 1;
|
||||
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
|
||||
int yycount = 1;
|
||||
|
||||
yyarg[0] = yytname[yytype];
|
||||
yyfmt = yystpcpy (yyformat, yyunexpected);
|
||||
int yyx;
|
||||
|
||||
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
|
||||
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
|
||||
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
|
||||
&& !yytable_value_is_error (yytable[yyx + yyn]))
|
||||
{
|
||||
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
|
||||
{
|
||||
yycount = 1;
|
||||
yysize = yysize0;
|
||||
yyformat[sizeof yyunexpected - 1] = '\0';
|
||||
break;
|
||||
}
|
||||
yyarg[yycount++] = yytname[yyx];
|
||||
yysize1 = yysize + yytnamerr (0, yytname[yyx]);
|
||||
yysize_overflow |= (yysize1 < yysize);
|
||||
if (! (yysize <= yysize1
|
||||
&& yysize1 <= YYSTACK_ALLOC_MAXIMUM))
|
||||
return 2;
|
||||
yysize = yysize1;
|
||||
yyfmt = yystpcpy (yyfmt, yyprefix);
|
||||
yyprefix = yyor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
yyf = YY_(yyformat);
|
||||
yysize1 = yysize + yystrlen (yyf);
|
||||
yysize_overflow |= (yysize1 < yysize);
|
||||
switch (yycount)
|
||||
{
|
||||
# define YYCASE_(N, S) \
|
||||
case N: \
|
||||
yyformat = S; \
|
||||
break
|
||||
YYCASE_(0, YY_("syntax error"));
|
||||
YYCASE_(1, YY_("syntax error, unexpected %s"));
|
||||
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
|
||||
YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
|
||||
YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
|
||||
YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
|
||||
# undef YYCASE_
|
||||
}
|
||||
|
||||
yysize1 = yysize + yystrlen (yyformat);
|
||||
if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
|
||||
return 2;
|
||||
yysize = yysize1;
|
||||
|
||||
if (yysize_overflow)
|
||||
return YYSIZE_MAXIMUM;
|
||||
|
||||
if (yyresult)
|
||||
if (*yymsg_alloc < yysize)
|
||||
{
|
||||
*yymsg_alloc = 2 * yysize;
|
||||
if (! (yysize <= *yymsg_alloc
|
||||
&& *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
|
||||
*yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Avoid sprintf, as that infringes on the user's name space.
|
||||
Don't have undefined behavior even if the translation
|
||||
produced a string with the wrong number of "%s"s. */
|
||||
char *yyp = yyresult;
|
||||
int yyi = 0;
|
||||
while ((*yyp = *yyf) != '\0')
|
||||
{
|
||||
if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
|
||||
char *yyp = *yymsg;
|
||||
int yyi = 0;
|
||||
while ((*yyp = *yyformat) != '\0')
|
||||
if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
|
||||
{
|
||||
yyp += yytnamerr (yyp, yyarg[yyi++]);
|
||||
yyf += 2;
|
||||
yyformat += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
yyp++;
|
||||
yyf++;
|
||||
yyformat++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return yysize;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif /* YYERROR_VERBOSE */
|
||||
|
||||
|
||||
/*-----------------------------------------------.
|
||||
| Release the memory associated to this symbol. |
|
||||
@ -1132,6 +1165,7 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp, mc, tmpl, error_msg)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Prevent warnings from -Wmissing-prototypes. */
|
||||
#ifdef YYPARSE_PARAM
|
||||
#if defined __STDC__ || defined __cplusplus
|
||||
@ -1148,12 +1182,9 @@ int yyparse ();
|
||||
#endif /* ! YYPARSE_PARAM */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*-------------------------.
|
||||
| yyparse or yypush_parse. |
|
||||
`-------------------------*/
|
||||
/*----------.
|
||||
| yyparse. |
|
||||
`----------*/
|
||||
|
||||
#ifdef YYPARSE_PARAM
|
||||
#if (defined __STDC__ || defined __C99__FUNC__ \
|
||||
@ -1219,7 +1250,7 @@ YYLTYPE yylloc;
|
||||
YYLTYPE *yylsp;
|
||||
|
||||
/* The locations where the error started and ended. */
|
||||
YYLTYPE yyerror_range[2];
|
||||
YYLTYPE yyerror_range[3];
|
||||
|
||||
YYSIZE_T yystacksize;
|
||||
|
||||
@ -1368,7 +1399,7 @@ yybackup:
|
||||
|
||||
/* First try to decide what to do without reference to lookahead token. */
|
||||
yyn = yypact[yystate];
|
||||
if (yyn == YYPACT_NINF)
|
||||
if (yypact_value_is_default (yyn))
|
||||
goto yydefault;
|
||||
|
||||
/* Not known => get a lookahead token if don't already have one. */
|
||||
@ -1399,7 +1430,7 @@ yybackup:
|
||||
yyn = yytable[yyn];
|
||||
if (yyn <= 0)
|
||||
{
|
||||
if (yyn == 0 || yyn == YYTABLE_NINF)
|
||||
if (yytable_value_is_error (yyn))
|
||||
goto yyerrlab;
|
||||
yyn = -yyn;
|
||||
goto yyreduce;
|
||||
@ -1456,7 +1487,7 @@ yyreduce:
|
||||
{
|
||||
case 4:
|
||||
|
||||
/* Line 1464 of yacc.c */
|
||||
/* Line 1806 of yacc.c */
|
||||
#line 99 "template_syntax.y"
|
||||
{
|
||||
Attribute * pattr;
|
||||
@ -1466,12 +1497,12 @@ yyreduce:
|
||||
pattr = new SingleAttribute(name,unescape(value));
|
||||
|
||||
tmpl->set(pattr);
|
||||
;}
|
||||
}
|
||||
break;
|
||||
|
||||
case 5:
|
||||
|
||||
/* Line 1464 of yacc.c */
|
||||
/* Line 1806 of yacc.c */
|
||||
#line 109 "template_syntax.y"
|
||||
{
|
||||
Attribute * pattr;
|
||||
@ -1484,12 +1515,12 @@ yyreduce:
|
||||
tmpl->set(pattr);
|
||||
|
||||
delete amap;
|
||||
;}
|
||||
}
|
||||
break;
|
||||
|
||||
case 6:
|
||||
|
||||
/* Line 1464 of yacc.c */
|
||||
/* Line 1806 of yacc.c */
|
||||
#line 122 "template_syntax.y"
|
||||
{
|
||||
Attribute * pattr;
|
||||
@ -1499,12 +1530,12 @@ yyreduce:
|
||||
pattr = new SingleAttribute(name,value);
|
||||
|
||||
tmpl->set(pattr);
|
||||
;}
|
||||
}
|
||||
break;
|
||||
|
||||
case 7:
|
||||
|
||||
/* Line 1464 of yacc.c */
|
||||
/* Line 1806 of yacc.c */
|
||||
#line 134 "template_syntax.y"
|
||||
{
|
||||
map<string,string>* vattr;
|
||||
@ -1517,12 +1548,12 @@ yyreduce:
|
||||
vattr->insert(make_pair(name,unescape(value)));
|
||||
|
||||
(yyval.val_attr) = static_cast<void *>(vattr);
|
||||
;}
|
||||
}
|
||||
break;
|
||||
|
||||
case 8:
|
||||
|
||||
/* Line 1464 of yacc.c */
|
||||
/* Line 1806 of yacc.c */
|
||||
#line 147 "template_syntax.y"
|
||||
{
|
||||
string name((yyvsp[(3) - (5)].val_str));
|
||||
@ -1535,15 +1566,26 @@ yyreduce:
|
||||
|
||||
attrmap->insert(make_pair(name,unescape(value)));
|
||||
(yyval.val_attr) = (yyvsp[(1) - (5)].val_attr);
|
||||
;}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 1545 "template_syntax.cc"
|
||||
/* Line 1806 of yacc.c */
|
||||
#line 1576 "template_syntax.cc"
|
||||
default: break;
|
||||
}
|
||||
/* User semantic actions sometimes alter yychar, and that requires
|
||||
that yytoken be updated with the new translation. We take the
|
||||
approach of translating immediately before every use of yytoken.
|
||||
One alternative is translating here after every semantic action,
|
||||
but that translation would be missed if the semantic action invokes
|
||||
YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
|
||||
if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
|
||||
incorrect destructor might then be invoked immediately. In the
|
||||
case of YYERROR or YYBACKUP, subsequent parser actions might lead
|
||||
to an incorrect destructor call or verbose syntax error message
|
||||
before the lookahead is translated. */
|
||||
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
|
||||
|
||||
YYPOPSTACK (yylen);
|
||||
@ -1572,6 +1614,10 @@ yyreduce:
|
||||
| yyerrlab -- here on detecting error |
|
||||
`------------------------------------*/
|
||||
yyerrlab:
|
||||
/* Make sure we have latest lookahead translation. See comments at
|
||||
user semantic actions for why this is necessary. */
|
||||
yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
|
||||
|
||||
/* If not already recovering from an error, report this error. */
|
||||
if (!yyerrstatus)
|
||||
{
|
||||
@ -1579,41 +1625,40 @@ yyerrlab:
|
||||
#if ! YYERROR_VERBOSE
|
||||
yyerror (&yylloc, mc, tmpl, error_msg, YY_("syntax error"));
|
||||
#else
|
||||
# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
|
||||
yyssp, yytoken)
|
||||
{
|
||||
YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
|
||||
if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
|
||||
char const *yymsgp = YY_("syntax error");
|
||||
int yysyntax_error_status;
|
||||
yysyntax_error_status = YYSYNTAX_ERROR;
|
||||
if (yysyntax_error_status == 0)
|
||||
yymsgp = yymsg;
|
||||
else if (yysyntax_error_status == 1)
|
||||
{
|
||||
YYSIZE_T yyalloc = 2 * yysize;
|
||||
if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
|
||||
yyalloc = YYSTACK_ALLOC_MAXIMUM;
|
||||
if (yymsg != yymsgbuf)
|
||||
YYSTACK_FREE (yymsg);
|
||||
yymsg = (char *) YYSTACK_ALLOC (yyalloc);
|
||||
if (yymsg)
|
||||
yymsg_alloc = yyalloc;
|
||||
else
|
||||
yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
|
||||
if (!yymsg)
|
||||
{
|
||||
yymsg = yymsgbuf;
|
||||
yymsg_alloc = sizeof yymsgbuf;
|
||||
}
|
||||
}
|
||||
|
||||
if (0 < yysize && yysize <= yymsg_alloc)
|
||||
{
|
||||
(void) yysyntax_error (yymsg, yystate, yychar);
|
||||
yyerror (&yylloc, mc, tmpl, error_msg, yymsg);
|
||||
yysyntax_error_status = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
yyerror (&yylloc, mc, tmpl, error_msg, YY_("syntax error"));
|
||||
if (yysize != 0)
|
||||
yysyntax_error_status = YYSYNTAX_ERROR;
|
||||
yymsgp = yymsg;
|
||||
}
|
||||
}
|
||||
yyerror (&yylloc, mc, tmpl, error_msg, yymsgp);
|
||||
if (yysyntax_error_status == 2)
|
||||
goto yyexhaustedlab;
|
||||
}
|
||||
}
|
||||
# undef YYSYNTAX_ERROR
|
||||
#endif
|
||||
}
|
||||
|
||||
yyerror_range[0] = yylloc;
|
||||
yyerror_range[1] = yylloc;
|
||||
|
||||
if (yyerrstatus == 3)
|
||||
{
|
||||
@ -1650,7 +1695,7 @@ yyerrorlab:
|
||||
if (/*CONSTCOND*/ 0)
|
||||
goto yyerrorlab;
|
||||
|
||||
yyerror_range[0] = yylsp[1-yylen];
|
||||
yyerror_range[1] = yylsp[1-yylen];
|
||||
/* Do not reclaim the symbols of the rule which action triggered
|
||||
this YYERROR. */
|
||||
YYPOPSTACK (yylen);
|
||||
@ -1669,7 +1714,7 @@ yyerrlab1:
|
||||
for (;;)
|
||||
{
|
||||
yyn = yypact[yystate];
|
||||
if (yyn != YYPACT_NINF)
|
||||
if (!yypact_value_is_default (yyn))
|
||||
{
|
||||
yyn += YYTERROR;
|
||||
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
|
||||
@ -1684,7 +1729,7 @@ yyerrlab1:
|
||||
if (yyssp == yyss)
|
||||
YYABORT;
|
||||
|
||||
yyerror_range[0] = *yylsp;
|
||||
yyerror_range[1] = *yylsp;
|
||||
yydestruct ("Error: popping",
|
||||
yystos[yystate], yyvsp, yylsp, mc, tmpl, error_msg);
|
||||
YYPOPSTACK (1);
|
||||
@ -1694,10 +1739,10 @@ yyerrlab1:
|
||||
|
||||
*++yyvsp = yylval;
|
||||
|
||||
yyerror_range[1] = yylloc;
|
||||
yyerror_range[2] = yylloc;
|
||||
/* Using YYLLOC is tempting, but would change the location of
|
||||
the lookahead. YYLOC is available though. */
|
||||
YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
|
||||
YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
|
||||
*++yylsp = yyloc;
|
||||
|
||||
/* Shift the error token. */
|
||||
@ -1733,8 +1778,13 @@ yyexhaustedlab:
|
||||
|
||||
yyreturn:
|
||||
if (yychar != YYEMPTY)
|
||||
{
|
||||
/* Make sure we have latest lookahead translation. See comments at
|
||||
user semantic actions for why this is necessary. */
|
||||
yytoken = YYTRANSLATE (yychar);
|
||||
yydestruct ("Cleanup: discarding lookahead",
|
||||
yytoken, &yylval, &yylloc, mc, tmpl, error_msg);
|
||||
}
|
||||
/* Do not reclaim the symbols of the rule which action triggered
|
||||
this YYABORT or YYACCEPT. */
|
||||
YYPOPSTACK (yylen);
|
||||
@ -1759,7 +1809,7 @@ yyreturn:
|
||||
|
||||
|
||||
|
||||
/* Line 1684 of yacc.c */
|
||||
/* Line 2067 of yacc.c */
|
||||
#line 160 "template_syntax.y"
|
||||
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user