mirror of
https://github.com/OpenNebula/one.git
synced 2025-08-29 09:49:28 +03:00
Merge branch 'master' of git.opennebula.org:one
This commit is contained in:
@ -355,6 +355,14 @@ public:
|
||||
*/
|
||||
void replace(const map<string,string>& attr);
|
||||
|
||||
/**
|
||||
* The attributes from vattr will be copied to this vector
|
||||
* @param attr Vector attribute to merge
|
||||
* @param replace True to replace existing values, false to copy values
|
||||
* only if they don't exist in this vector attribute
|
||||
*/
|
||||
void merge(VectorAttribute* vattr, bool replace);
|
||||
|
||||
/**
|
||||
* Replace the value of the given vector attribute
|
||||
*/
|
||||
|
@ -1266,28 +1266,34 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Collects information about VM DISKS
|
||||
* @param max_disk_id of the VM
|
||||
*/
|
||||
void get_nic_info(int& max_nic_id);
|
||||
|
||||
/**
|
||||
* Generates a NIC attribute to be attached to the VM.
|
||||
* @param tmpl Template containing a single NIC vector attribute.
|
||||
* @param max_nic_id Max NIC/NIC_ID of the VM
|
||||
* @param uid of the VM owner
|
||||
* @param network_id returns the id of the acquired network
|
||||
* @param error_str describes the error
|
||||
* Gets info about the new NIC to attach
|
||||
*
|
||||
* @return a new VectorAttribute with the DISK (should be freed if not
|
||||
* @param tmpl Template containing a single NIC vector attribute.
|
||||
* @param max_nic_id Returns the max NIC_ID of the VM
|
||||
* @param error_str error reason, if any
|
||||
* @return a new VectorAttribute with the NIC (should be freed if not
|
||||
* added to the template), 0 in case of error
|
||||
*/
|
||||
static VectorAttribute * set_up_attach_nic(
|
||||
int vm_id,
|
||||
VectorAttribute * get_attach_nic_info(
|
||||
VirtualMachineTemplate * tmpl,
|
||||
int& max_nic_id,
|
||||
string& error_str);
|
||||
|
||||
/**
|
||||
* Setups the new NIC attribute to be attached to the VM.
|
||||
*
|
||||
* @param vm_id Id of the VM where this nic will be attached
|
||||
* @param new_nic New NIC vector attribute, obtained from get_attach_nic_info
|
||||
* @param max_nic_id Max NIC/NIC_ID of the VM
|
||||
* @param uid of the VM owner
|
||||
* @param error_str error reason, if any
|
||||
* @return 0 on success, -1 otherwise
|
||||
*/
|
||||
static int set_up_attach_nic(
|
||||
int vm_id,
|
||||
VectorAttribute * new_nic,
|
||||
int max_nic_id,
|
||||
int uid,
|
||||
int& network_id,
|
||||
string& error_str);
|
||||
|
||||
/**
|
||||
@ -1596,6 +1602,21 @@ private:
|
||||
*/
|
||||
int parse_os(string& error_str);
|
||||
|
||||
/**
|
||||
* Attributes not allowed in NIC_DEFAULT to avoid authorization bypass and
|
||||
* inconsistencies for NIC_DEFAULTS
|
||||
*/
|
||||
static const char * NO_NIC_DEFAULTS[];
|
||||
|
||||
static const int NUM_NO_NIC_DEFAULTS;
|
||||
|
||||
/**
|
||||
* Parse the "NIC_DEFAULT" attribute
|
||||
* @param error_str Returns the error reason, if any
|
||||
* @return 0 on success
|
||||
*/
|
||||
int parse_defaults(string& error_str);
|
||||
|
||||
/**
|
||||
* Parse the "CONTEXT" attribute of the template by substituting
|
||||
* $VARIABLE, $VARIABLE[ATTR] and $VARIABLE[ATTR, ATTR = VALUE]
|
||||
@ -1644,6 +1665,13 @@ private:
|
||||
*/
|
||||
string& to_xml_extended(string& xml, int n_history) const;
|
||||
|
||||
/**
|
||||
* Merges NIC_DEFAULT with the given NIC
|
||||
* @param nic NIC to process
|
||||
*/
|
||||
void merge_nic_defaults(VectorAttribute* nic);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
//**************************************************************************
|
||||
|
65
install.sh
65
install.sh
@ -250,12 +250,16 @@ VAR_DIRS="$VAR_LOCATION/remotes \
|
||||
$VAR_LOCATION/remotes/im/xen4-probes.d \
|
||||
$VAR_LOCATION/remotes/im/vmware.d \
|
||||
$VAR_LOCATION/remotes/im/ec2.d \
|
||||
$VAR_LOCATION/remotes/im/sl.d \
|
||||
$VAR_LOCATION/remotes/im/az.d \
|
||||
$VAR_LOCATION/remotes/vmm \
|
||||
$VAR_LOCATION/remotes/vmm/kvm \
|
||||
$VAR_LOCATION/remotes/vmm/xen3 \
|
||||
$VAR_LOCATION/remotes/vmm/xen4 \
|
||||
$VAR_LOCATION/remotes/vmm/vmware \
|
||||
$VAR_LOCATION/remotes/vmm/ec2 \
|
||||
$VAR_LOCATION/remotes/vmm/sl \
|
||||
$VAR_LOCATION/remotes/vmm/az \
|
||||
$VAR_LOCATION/remotes/vnm \
|
||||
$VAR_LOCATION/remotes/vnm/802.1Q \
|
||||
$VAR_LOCATION/remotes/vnm/dummy \
|
||||
@ -412,6 +416,8 @@ INSTALL_FILES=(
|
||||
IM_PROBES_XEN4_PROBES_FILES:$VAR_LOCATION/remotes/im/xen4-probes.d
|
||||
IM_PROBES_VMWARE_FILES:$VAR_LOCATION/remotes/im/vmware.d
|
||||
IM_PROBES_EC2_FILES:$VAR_LOCATION/remotes/im/ec2.d
|
||||
IM_PROBES_SL_FILES:$VAR_LOCATION/remotes/im/sl.d
|
||||
IM_PROBES_AZ_FILES:$VAR_LOCATION/remotes/im/az.d
|
||||
IM_PROBES_VERSION:$VAR_LOCATION/remotes
|
||||
AUTH_SSH_FILES:$VAR_LOCATION/remotes/auth/ssh
|
||||
AUTH_X509_FILES:$VAR_LOCATION/remotes/auth/x509
|
||||
@ -425,6 +431,8 @@ INSTALL_FILES=(
|
||||
VMM_EXEC_XEN4_SCRIPTS:$VAR_LOCATION/remotes/vmm/xen4
|
||||
VMM_EXEC_VMWARE_SCRIPTS:$VAR_LOCATION/remotes/vmm/vmware
|
||||
VMM_EXEC_EC2_SCRIPTS:$VAR_LOCATION/remotes/vmm/ec2
|
||||
VMM_EXEC_SL_SCRIPTS:$VAR_LOCATION/remotes/vmm/sl
|
||||
VMM_EXEC_AZ_SCRIPTS:$VAR_LOCATION/remotes/vmm/az
|
||||
TM_FILES:$VAR_LOCATION/remotes/tm
|
||||
TM_SHARED_FILES:$VAR_LOCATION/remotes/tm/shared
|
||||
TM_FS_LVM_FILES:$VAR_LOCATION/remotes/tm/fs_lvm
|
||||
@ -576,6 +584,8 @@ INSTALL_ETC_FILES=(
|
||||
ETC_FILES:$ETC_LOCATION
|
||||
VMWARE_ETC_FILES:$ETC_LOCATION
|
||||
EC2_ETC_FILES:$ETC_LOCATION
|
||||
SL_ETC_FILES:$ETC_LOCATION
|
||||
AZ_ETC_FILES:$ETC_LOCATION
|
||||
VMM_EXEC_ETC_FILES:$ETC_LOCATION/vmm_exec
|
||||
HM_ETC_FILES:$ETC_LOCATION/hm
|
||||
AUTH_ETC_FILES:$ETC_LOCATION/auth
|
||||
@ -788,6 +798,51 @@ VMM_EXEC_EC2_SCRIPTS="src/vmm_mad/remotes/ec2/cancel \
|
||||
src/vmm_mad/remotes/ec2/shutdown \
|
||||
src/vmm_mad/remotes/ec2/ec2_driver.rb"
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# VMM Driver SoftLayer scripts, to be installed under $REMOTES_LOCATION/vmm/sl
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
VMM_EXEC_SL_SCRIPTS="src/vmm_mad/remotes/sl/cancel \
|
||||
src/vmm_mad/remotes/sl/attach_disk \
|
||||
src/vmm_mad/remotes/sl/detach_disk \
|
||||
src/vmm_mad/remotes/sl/attach_nic \
|
||||
src/vmm_mad/remotes/sl/detach_nic \
|
||||
src/vmm_mad/remotes/sl/snapshot_create \
|
||||
src/vmm_mad/remotes/sl/snapshot_revert \
|
||||
src/vmm_mad/remotes/sl/snapshot_delete \
|
||||
src/vmm_mad/remotes/sl/deploy \
|
||||
src/vmm_mad/remotes/sl/migrate \
|
||||
src/vmm_mad/remotes/sl/restore \
|
||||
src/vmm_mad/remotes/sl/reboot \
|
||||
src/vmm_mad/remotes/sl/reset \
|
||||
src/vmm_mad/remotes/sl/save \
|
||||
src/vmm_mad/remotes/sl/poll \
|
||||
src/vmm_mad/remotes/sl/shutdown \
|
||||
src/vmm_mad/remotes/sl/sl_driver.rb"
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# VMM Driver Azure scripts, to be installed under $REMOTES_LOCATION/vmm/az
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
VMM_EXEC_AZ_SCRIPTS="src/vmm_mad/remotes/az/cancel \
|
||||
src/vmm_mad/remotes/az/attach_disk \
|
||||
src/vmm_mad/remotes/az/detach_disk \
|
||||
src/vmm_mad/remotes/az/attach_nic \
|
||||
src/vmm_mad/remotes/az/detach_nic \
|
||||
src/vmm_mad/remotes/az/snapshot_create \
|
||||
src/vmm_mad/remotes/az/snapshot_revert \
|
||||
src/vmm_mad/remotes/az/snapshot_delete \
|
||||
src/vmm_mad/remotes/az/deploy \
|
||||
src/vmm_mad/remotes/az/migrate \
|
||||
src/vmm_mad/remotes/az/restore \
|
||||
src/vmm_mad/remotes/az/reboot \
|
||||
src/vmm_mad/remotes/az/reset \
|
||||
src/vmm_mad/remotes/az/save \
|
||||
src/vmm_mad/remotes/az/poll \
|
||||
src/vmm_mad/remotes/az/shutdown \
|
||||
src/vmm_mad/remotes/az/az_driver.rb"
|
||||
>>>>>>> feature-2989
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Information Manager Probes, to be installed under $REMOTES_LOCATION/im
|
||||
#-------------------------------------------------------------------------------
|
||||
@ -835,6 +890,9 @@ IM_PROBES_VMWARE_FILES="src/im_mad/remotes/vmware.d/vmware.rb"
|
||||
|
||||
IM_PROBES_EC2_FILES="src/im_mad/remotes/ec2.d/poll"
|
||||
|
||||
IM_PROBES_SL_FILES="src/im_mad/remotes/sl.d/poll"
|
||||
IM_PROBES_AZ_FILES="src/im_mad/remotes/az.d/poll"
|
||||
|
||||
IM_PROBES_VERSION="src/im_mad/remotes/VERSION"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
@ -1124,6 +1182,13 @@ VMWARE_ETC_FILES="src/vmm_mad/remotes/vmware/vmwarerc"
|
||||
EC2_ETC_FILES="src/vmm_mad/remotes/ec2/ec2_driver.conf \
|
||||
src/vmm_mad/remotes/ec2/ec2_driver.default"
|
||||
|
||||
SL_ETC_FILES="src/vmm_mad/remotes/sl/sl_driver.conf \
|
||||
src/vmm_mad/remotes/sl/sl_driver.default"
|
||||
|
||||
AZ_ETC_FILES="src/vmm_mad/remotes/az/az_driver.conf \
|
||||
src/vmm_mad/remotes/az/az_driver.default"
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Virtualization drivers config. files, to be installed under $ETC_LOCATION
|
||||
# - ssh, $ETC_LOCATION/vmm_exec
|
||||
|
@ -312,6 +312,8 @@ IM_MAD = [
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# EC2 Information Driver Manager Configuration
|
||||
# -r number of retries when monitoring a host
|
||||
# -t number of threads, i.e. number of hosts monitored at the same time
|
||||
#-------------------------------------------------------------------------------
|
||||
#IM_MAD = [
|
||||
# name = "ec2",
|
||||
@ -319,6 +321,28 @@ IM_MAD = [
|
||||
# arguments = "-c -t 1 -r 0 ec2" ]
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# SoftLayer Information Driver Manager Configuration
|
||||
# -r number of retries when monitoring a host
|
||||
# -t number of threads, i.e. number of hosts monitored at the same time
|
||||
#-------------------------------------------------------------------------------
|
||||
#IM_MAD = [
|
||||
# name = "sl",
|
||||
# executable = "one_im_sh",
|
||||
# arguments = "-c -t 1 -r 0 sl" ]
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Azure Information Driver Manager Configuration
|
||||
# -r number of retries when monitoring a host
|
||||
# -t number of threads, i.e. number of hosts monitored at the same time
|
||||
#-------------------------------------------------------------------------------
|
||||
#IM_MAD = [
|
||||
# name = "az",
|
||||
# executable = "one_im_sh",
|
||||
# arguments = "-c -t 1 -r 0 az" ]
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Dummy Information Driver Manager Configuration
|
||||
#-------------------------------------------------------------------------------
|
||||
@ -419,6 +443,29 @@ VM_MAD = [
|
||||
# type = "xml" ]
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# SoftLayer Virtualization Driver Manager Configuration
|
||||
# -r number of retries when monitoring a host
|
||||
# -t number of threads, i.e. number of actions performed at the same time
|
||||
#-------------------------------------------------------------------------------
|
||||
#VM_MAD = [
|
||||
# name = "sl",
|
||||
# executable = "one_vmm_sh",
|
||||
# arguments = "-t 15 -r 0 sl",
|
||||
# type = "xml" ]
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# Azure Virtualization Driver Manager Configuration
|
||||
# -r number of retries when monitoring a host
|
||||
# -t number of threads, i.e. number of actions performed at the same time
|
||||
#-------------------------------------------------------------------------------
|
||||
#VM_MAD = [
|
||||
# name = "az",
|
||||
# executable = "one_vmm_sh",
|
||||
# arguments = "-t 15 -r 0 az",
|
||||
# type = "xml" ]
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Dummy Virtualization Driver Configuration
|
||||
#-------------------------------------------------------------------------------
|
||||
@ -666,6 +713,9 @@ VM_RESTRICTED_ATTR = "CONTEXT/FILES"
|
||||
VM_RESTRICTED_ATTR = "NIC/MAC"
|
||||
VM_RESTRICTED_ATTR = "NIC/VLAN_ID"
|
||||
VM_RESTRICTED_ATTR = "NIC/BRIDGE"
|
||||
VM_RESTRICTED_ATTR = "NIC_DEFAULT/MAC"
|
||||
VM_RESTRICTED_ATTR = "NIC_DEFAULT/VLAN_ID"
|
||||
VM_RESTRICTED_ATTR = "NIC_DEFAULT/BRIDGE"
|
||||
|
||||
#VM_RESTRICTED_ATTR = "RANK"
|
||||
#VM_RESTRICTED_ATTR = "SCHED_RANK"
|
||||
|
@ -20,7 +20,7 @@ end
|
||||
GROUPS={
|
||||
:quota => [SQLITE, 'sequel'],
|
||||
:sunstone => ['json', 'rack', 'sinatra', 'thin', SQLITE],
|
||||
:cloud => %w{amazon-ec2 rack sinatra thin uuidtools curb json},
|
||||
:cloud => %w{softlayer_api configparser amazon-ec2 rack sinatra thin uuidtools curb json azure},
|
||||
:auth_ldap => 'net-ldap',
|
||||
:vmware => %w{builder trollop},
|
||||
:oneflow => %w{sinatra json treetop parse-cron},
|
||||
|
@ -172,6 +172,35 @@ void VectorAttribute::replace(const map<string,string>& attr)
|
||||
{
|
||||
attribute_value = attr;
|
||||
}
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void VectorAttribute::merge(VectorAttribute* vattr, bool replace)
|
||||
{
|
||||
map<string, string>::const_iterator it;
|
||||
map<string, string>::iterator jt;
|
||||
|
||||
const map<string,string>& source_values = vattr->value();
|
||||
|
||||
for(it=source_values.begin(); it!=source_values.end(); it++)
|
||||
{
|
||||
jt = attribute_value.find(it->first);
|
||||
|
||||
if (jt != attribute_value.end())
|
||||
{
|
||||
if (replace)
|
||||
{
|
||||
attribute_value.erase(jt);
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
attribute_value.insert(make_pair(it->first,it->second));
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -1355,7 +1355,7 @@ int DispatchManager::attach_nic(
|
||||
int max_nic_id;
|
||||
int uid;
|
||||
int oid;
|
||||
int network_id;
|
||||
int rc;
|
||||
|
||||
VectorAttribute * nic;
|
||||
|
||||
@ -1387,7 +1387,15 @@ int DispatchManager::attach_nic(
|
||||
return -1;
|
||||
}
|
||||
|
||||
vm->get_nic_info(max_nic_id);
|
||||
nic = vm->get_attach_nic_info(tmpl, max_nic_id, error_str);
|
||||
|
||||
if ( nic == 0 )
|
||||
{
|
||||
vm->unlock();
|
||||
|
||||
NebulaLog::log("DiM", Log::ERROR, error_str);
|
||||
return -1;
|
||||
}
|
||||
|
||||
vm->set_state(VirtualMachine::HOTPLUG_NIC);
|
||||
|
||||
@ -1400,17 +1408,21 @@ int DispatchManager::attach_nic(
|
||||
|
||||
vm->unlock();
|
||||
|
||||
nic = VirtualMachine::set_up_attach_nic(oid,
|
||||
tmpl,
|
||||
max_nic_id,
|
||||
uid,
|
||||
network_id,
|
||||
error_str);
|
||||
rc = VirtualMachine::set_up_attach_nic(oid,
|
||||
nic,
|
||||
max_nic_id,
|
||||
uid,
|
||||
error_str);
|
||||
vm = vmpool->get(vid, true);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
VirtualMachine::release_network_leases(nic, vid);
|
||||
delete nic;
|
||||
|
||||
if ( rc == 0 )
|
||||
{
|
||||
VirtualMachine::release_network_leases(nic, vid);
|
||||
}
|
||||
|
||||
oss << "Could not attach a new NIC to VM " << vid
|
||||
<< ", VM does not exist after setting its state to HOTPLUG." ;
|
||||
@ -1421,8 +1433,10 @@ int DispatchManager::attach_nic(
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( nic == 0 )
|
||||
if ( rc != 0 )
|
||||
{
|
||||
delete nic;
|
||||
|
||||
vm->set_state(VirtualMachine::RUNNING);
|
||||
|
||||
vmpool->update(vm);
|
||||
@ -1430,6 +1444,7 @@ int DispatchManager::attach_nic(
|
||||
vm->unlock();
|
||||
|
||||
NebulaLog::log("DiM", Log::ERROR, error_str);
|
||||
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
|
27
src/im_mad/remotes/az.d/poll
Executable file
27
src/im_mad/remotes/az.d/poll
Executable file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2010-2014, C12G Labs S.L #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
$: << File.join(File.dirname(__FILE__), '../../vmm/az')
|
||||
|
||||
require 'az_driver'
|
||||
|
||||
host = ARGV[-1]
|
||||
az_drv = AzureDriver.new(host)
|
||||
|
||||
az_drv.monitor_all_vms
|
||||
|
26
src/im_mad/remotes/sl.d/poll
Executable file
26
src/im_mad/remotes/sl.d/poll
Executable file
@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2010-2014, C12G Labs S.L #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
$: << File.join(File.dirname(__FILE__), '../../vmm/sl')
|
||||
|
||||
require 'sl_driver'
|
||||
|
||||
host = ARGV[-1]
|
||||
sl_drv = SLDriver.new(host)
|
||||
|
||||
sl_drv.monitor_all_vms
|
@ -1830,6 +1830,14 @@ function wizard_tab_content(){
|
||||
'<dt class="text-center"><button type="button" class="button tiny radius" id="tf_btn_nics"><span class="fa fa-plus"></span> '+tr("Add another nic")+'</button></dt>'+
|
||||
'</dl>'+
|
||||
'<div class="tabs-content vertical" id="template_create_network_tabs_content">'+
|
||||
'<div class="row">'+
|
||||
'<div class="large-6 columns">'+
|
||||
'<label for="DEFAULT_MODEL">'+tr("Default model")+
|
||||
'<span class="tip">'+tr("Default value for all NICs. Hardware that will emulate the network interface. With Xen this is the type attribute of the vif.")+'</span>'+
|
||||
'</label>'+
|
||||
'<input type="text" id="DEFAULT_MODEL" name="DEFAULT_MODEL"/>'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'</div>';
|
||||
}
|
||||
@ -3618,6 +3626,13 @@ function initialize_create_template_dialog(dialog) {
|
||||
}
|
||||
});
|
||||
|
||||
var default_model = $('#DEFAULT_MODEL', dialog).val();
|
||||
if (default_model){
|
||||
vm_json["NIC_DEFAULT"] = {
|
||||
"MODEL": default_model
|
||||
};
|
||||
}
|
||||
|
||||
//
|
||||
// GRAPHICS
|
||||
//
|
||||
@ -4017,6 +4032,14 @@ function fillTemplatePopUp(template, dialog){
|
||||
delete template.NIC
|
||||
}
|
||||
|
||||
var nic_default = template.NIC_DEFAULT
|
||||
if (nic_default != undefined) {
|
||||
if (nic_default.MODEL) {
|
||||
$('#DEFAULT_MODEL', dialog).val(nic_default.MODEL);
|
||||
}
|
||||
|
||||
delete template.NIC_DEFAULT;
|
||||
}
|
||||
|
||||
//
|
||||
// OS
|
||||
|
@ -115,6 +115,11 @@ const char * VirtualMachine::monit_db_bootstrap = "CREATE TABLE IF NOT EXISTS "
|
||||
"vm_monitoring (vmid INTEGER, last_poll INTEGER, body MEDIUMTEXT, "
|
||||
"PRIMARY KEY(vmid, last_poll))";
|
||||
|
||||
const char * VirtualMachine::NO_NIC_DEFAULTS[] = {"NETWORK_ID", "NETWORK",
|
||||
"NETWORK_UID", "NETWORK_UNAME"};
|
||||
|
||||
const int VirtualMachine::NUM_NO_NIC_DEFAULTS = 4;
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
@ -332,6 +337,17 @@ int VirtualMachine::insert(SqlDB * db, string& error_str)
|
||||
goto error_os;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Parse the defaults to merge
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
rc = parse_defaults(error_str);
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
goto error_defaults;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Get network leases
|
||||
// ------------------------------------------------------------------------
|
||||
@ -433,6 +449,7 @@ error_memory:
|
||||
goto error_common;
|
||||
|
||||
error_os:
|
||||
error_defaults:
|
||||
error_name:
|
||||
error_common:
|
||||
NebulaLog::log("ONE",Log::ERROR, error_str);
|
||||
@ -612,6 +629,57 @@ int VirtualMachine::parse_os(string& error_str)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int VirtualMachine::parse_defaults(string& error_str)
|
||||
{
|
||||
int num;
|
||||
|
||||
vector<Attribute *> attr;
|
||||
VectorAttribute* vatt = 0;
|
||||
|
||||
num = user_obj_template->remove("NIC_DEFAULT", attr);
|
||||
|
||||
if ( num == 0 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( num > 1 )
|
||||
{
|
||||
error_str = "Only one NIC_DEFAULT attribute can be defined.";
|
||||
return -1;
|
||||
}
|
||||
|
||||
vatt = dynamic_cast<VectorAttribute *>(attr[0]);
|
||||
|
||||
if ( vatt == 0 )
|
||||
{
|
||||
error_str = "Wrong format for NIC_DEFAULT attribute.";
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (int i=0; i < NUM_NO_NIC_DEFAULTS; i++)
|
||||
{
|
||||
if(vatt->vector_value(NO_NIC_DEFAULTS[i]) != "")
|
||||
{
|
||||
ostringstream oss;
|
||||
oss << "Attribute " << NO_NIC_DEFAULTS[i]
|
||||
<< " is not allowed inside NIC_DEFAULT.";
|
||||
|
||||
error_str = oss.str();
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
obj_template->set(vatt);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
@ -2121,7 +2189,10 @@ long long VirtualMachine::get_volatile_disk_size(Template * tmpl)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void VirtualMachine::get_nic_info(int& max_nic_id)
|
||||
VectorAttribute * VirtualMachine::get_attach_nic_info(
|
||||
VirtualMachineTemplate * tmpl,
|
||||
int& max_nic_id,
|
||||
string& error_str)
|
||||
{
|
||||
vector<Attribute *> nics;
|
||||
VectorAttribute * nic;
|
||||
@ -2129,6 +2200,10 @@ void VirtualMachine::get_nic_info(int& max_nic_id)
|
||||
int nic_id;
|
||||
int num_nics;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Get the highest NIC_ID
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
max_nic_id = -1;
|
||||
|
||||
num_nics = obj_template->get("NIC", nics);
|
||||
@ -2149,46 +2224,46 @@ void VirtualMachine::get_nic_info(int& max_nic_id)
|
||||
max_nic_id = nic_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
VectorAttribute * VirtualMachine::set_up_attach_nic(
|
||||
int vm_id,
|
||||
VirtualMachineTemplate * tmpl,
|
||||
int max_nic_id,
|
||||
int uid,
|
||||
int& network_id,
|
||||
string& error_str)
|
||||
{
|
||||
vector<Attribute *> nics;
|
||||
VectorAttribute * new_nic;
|
||||
|
||||
Nebula& nd = Nebula::instance();
|
||||
VirtualNetworkPool* vnpool = nd.get_vnpool();
|
||||
|
||||
network_id = -1;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Get the NIC attribute from the template
|
||||
// Get the new NIC attribute from the template
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
nics.clear();
|
||||
|
||||
if ( tmpl->get("NIC", nics) != 1 )
|
||||
{
|
||||
error_str = "The template must contain one NIC attribute";
|
||||
return 0;
|
||||
}
|
||||
|
||||
new_nic = dynamic_cast<VectorAttribute * >(nics[0]);
|
||||
nic = dynamic_cast<VectorAttribute * >(nics[0]);
|
||||
|
||||
if ( new_nic == 0 )
|
||||
if ( nic == 0 )
|
||||
{
|
||||
error_str = "Internal error parsing NIC attribute";
|
||||
return 0;
|
||||
}
|
||||
|
||||
new_nic = new_nic->clone();
|
||||
nic = nic->clone();
|
||||
|
||||
merge_nic_defaults(nic);
|
||||
|
||||
return nic;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int VirtualMachine::set_up_attach_nic(
|
||||
int vm_id,
|
||||
VectorAttribute * new_nic,
|
||||
int max_nic_id,
|
||||
int uid,
|
||||
string& error_str)
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
VirtualNetworkPool* vnpool = nd.get_vnpool();
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Acquire the new network lease
|
||||
@ -2198,11 +2273,10 @@ VectorAttribute * VirtualMachine::set_up_attach_nic(
|
||||
|
||||
if ( rc == -1 ) //-2 is not using a pre-defined network
|
||||
{
|
||||
delete new_nic;
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return new_nic;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@ -2554,6 +2628,8 @@ int VirtualMachine::get_network_leases(string& estr)
|
||||
continue;
|
||||
}
|
||||
|
||||
merge_nic_defaults(nic);
|
||||
|
||||
rc = vnpool->nic_attribute(nic, i, uid, oid, estr);
|
||||
|
||||
if (rc == -1)
|
||||
@ -2568,6 +2644,35 @@ int VirtualMachine::get_network_leases(string& estr)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void VirtualMachine::merge_nic_defaults(VectorAttribute* nic)
|
||||
{
|
||||
vector<Attribute *> nics_def;
|
||||
VectorAttribute * nic_def = 0;
|
||||
|
||||
int num;
|
||||
|
||||
num = obj_template->get("NIC_DEFAULT", nics_def);
|
||||
|
||||
if (num == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
nic_def = dynamic_cast<VectorAttribute * >(nics_def[0]);
|
||||
|
||||
if ( nic_def == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
nic->merge(nic_def, false);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void VirtualMachine::release_network_leases()
|
||||
{
|
||||
string vnid;
|
||||
|
@ -103,20 +103,34 @@ int LibVirtDriver::deployment_description_kvm(
|
||||
const VectorAttribute * disk;
|
||||
const VectorAttribute * context;
|
||||
|
||||
string type = "";
|
||||
string target = "";
|
||||
string bus = "";
|
||||
string ro = "";
|
||||
string driver = "";
|
||||
string cache = "";
|
||||
string disk_io = "";
|
||||
string source = "";
|
||||
string clone = "";
|
||||
string ceph_host = "";
|
||||
string ceph_secret= "";
|
||||
string ceph_user = "";
|
||||
string gluster_host = "";
|
||||
string gluster_volume = "";
|
||||
string type = "";
|
||||
string target = "";
|
||||
string bus = "";
|
||||
string ro = "";
|
||||
string driver = "";
|
||||
string cache = "";
|
||||
string disk_io = "";
|
||||
string source = "";
|
||||
string clone = "";
|
||||
string ceph_host = "";
|
||||
string ceph_secret = "";
|
||||
string ceph_user = "";
|
||||
string gluster_host = "";
|
||||
string gluster_volume = "";
|
||||
|
||||
string total_bytes_sec = "";
|
||||
string read_bytes_sec = "";
|
||||
string write_bytes_sec = "";
|
||||
string total_iops_sec = "";
|
||||
string read_iops_sec = "";
|
||||
string write_iops_sec = "";
|
||||
|
||||
string default_total_bytes_sec = "";
|
||||
string default_read_bytes_sec = "";
|
||||
string default_write_bytes_sec = "";
|
||||
string default_total_iops_sec = "";
|
||||
string default_read_iops_sec = "";
|
||||
string default_write_iops_sec = "";
|
||||
|
||||
int disk_id;
|
||||
string default_driver = "";
|
||||
@ -367,21 +381,29 @@ int LibVirtDriver::deployment_description_kvm(
|
||||
// ------------------------------------------------------------------------
|
||||
// Disks
|
||||
// ------------------------------------------------------------------------
|
||||
get_default("DISK","DRIVER",default_driver);
|
||||
get_default("DISK", "DRIVER", default_driver);
|
||||
|
||||
if (default_driver.empty())
|
||||
{
|
||||
default_driver = "raw";
|
||||
}
|
||||
|
||||
get_default("DISK","CACHE",default_driver_cache);
|
||||
get_default("DISK", "CACHE", default_driver_cache);
|
||||
|
||||
if (default_driver_cache.empty())
|
||||
{
|
||||
default_driver_cache = "default";
|
||||
}
|
||||
|
||||
get_default("DISK","IO",default_driver_disk_io);
|
||||
get_default("DISK", "IO", default_driver_disk_io);
|
||||
|
||||
get_default("DISK", "TOTAL_BYTES_SEC", default_total_bytes_sec);
|
||||
get_default("DISK", "READ_BYTES_SEC", default_read_bytes_sec);
|
||||
get_default("DISK", "WRITE_BYTES_SEC", default_write_bytes_sec);
|
||||
get_default("DISK", "TOTAL_IOPS_SEC", default_total_iops_sec);
|
||||
get_default("DISK", "READ_IOPS_SEC", default_read_iops_sec);
|
||||
get_default("DISK", "WRITE_IOPS_SEC", default_write_iops_sec);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
num = vm->get_template_attribute("DISK",attrs);
|
||||
@ -395,20 +417,59 @@ int LibVirtDriver::deployment_description_kvm(
|
||||
continue;
|
||||
}
|
||||
|
||||
type = disk->vector_value("TYPE");
|
||||
target = disk->vector_value("TARGET");
|
||||
ro = disk->vector_value("READONLY");
|
||||
driver = disk->vector_value("DRIVER");
|
||||
cache = disk->vector_value("CACHE");
|
||||
disk_io = disk->vector_value("IO");
|
||||
source = disk->vector_value("SOURCE");
|
||||
clone = disk->vector_value("CLONE");
|
||||
ceph_host = disk->vector_value("CEPH_HOST");
|
||||
ceph_secret = disk->vector_value("CEPH_SECRET");
|
||||
ceph_user = disk->vector_value("CEPH_USER");
|
||||
type = disk->vector_value("TYPE");
|
||||
target = disk->vector_value("TARGET");
|
||||
ro = disk->vector_value("READONLY");
|
||||
driver = disk->vector_value("DRIVER");
|
||||
cache = disk->vector_value("CACHE");
|
||||
disk_io = disk->vector_value("IO");
|
||||
source = disk->vector_value("SOURCE");
|
||||
clone = disk->vector_value("CLONE");
|
||||
|
||||
ceph_host = disk->vector_value("CEPH_HOST");
|
||||
ceph_secret = disk->vector_value("CEPH_SECRET");
|
||||
ceph_user = disk->vector_value("CEPH_USER");
|
||||
|
||||
gluster_host = disk->vector_value("GLUSTER_HOST");
|
||||
gluster_volume = disk->vector_value("GLUSTER_VOLUME");
|
||||
|
||||
total_bytes_sec = disk->vector_value("TOTAL_BYTES_SEC");
|
||||
read_bytes_sec = disk->vector_value("READ_BYTES_SEC");
|
||||
write_bytes_sec = disk->vector_value("WRITE_BYTES_SEC");
|
||||
total_iops_sec = disk->vector_value("TOTAL_IOPS_SEC");
|
||||
read_iops_sec = disk->vector_value("READ_IOPS_SEC");
|
||||
write_iops_sec = disk->vector_value("WRITE_IOPS_SEC");
|
||||
|
||||
if ( total_bytes_sec.empty() && !default_total_bytes_sec.empty())
|
||||
{
|
||||
total_bytes_sec = default_total_bytes_sec;
|
||||
}
|
||||
|
||||
if ( read_bytes_sec.empty() && !default_read_bytes_sec.empty())
|
||||
{
|
||||
read_bytes_sec = default_read_bytes_sec;
|
||||
}
|
||||
|
||||
if ( write_bytes_sec.empty() && !default_write_bytes_sec.empty())
|
||||
{
|
||||
write_bytes_sec = default_write_bytes_sec;
|
||||
}
|
||||
|
||||
if ( total_iops_sec.empty() && !default_total_iops_sec.empty())
|
||||
{
|
||||
total_iops_sec = default_total_iops_sec;
|
||||
}
|
||||
|
||||
if ( read_iops_sec.empty() && !default_read_iops_sec.empty())
|
||||
{
|
||||
read_iops_sec = default_read_iops_sec;
|
||||
}
|
||||
|
||||
if ( write_iops_sec.empty() && !default_write_iops_sec.empty())
|
||||
{
|
||||
write_iops_sec = default_write_iops_sec;
|
||||
}
|
||||
|
||||
disk->vector_value_str("DISK_ID", disk_id);
|
||||
|
||||
if (target.empty())
|
||||
@ -552,7 +613,56 @@ int LibVirtDriver::deployment_description_kvm(
|
||||
file << " io='" << default_driver_disk_io << "'";
|
||||
}
|
||||
|
||||
file << "/>" << endl << "\t\t</disk>" << endl;
|
||||
file << "/>" << endl;
|
||||
|
||||
// ---- I/O Options ----
|
||||
|
||||
if (!(total_bytes_sec.empty() && read_bytes_sec.empty() &&
|
||||
write_bytes_sec.empty() && total_iops_sec.empty() &&
|
||||
read_iops_sec.empty() && write_iops_sec.empty()))
|
||||
{
|
||||
file << "\t\t\t<iotune>" << endl;
|
||||
|
||||
if ( !total_bytes_sec.empty() )
|
||||
{
|
||||
file << "\t\t\t\t<total_bytes_sec>" << total_bytes_sec
|
||||
<< "</total_bytes_sec>" << endl;
|
||||
}
|
||||
|
||||
if ( !read_bytes_sec.empty() )
|
||||
{
|
||||
file << "\t\t\t\t<read_bytes_sec>" << read_bytes_sec
|
||||
<< "</read_bytes_sec>" << endl;
|
||||
}
|
||||
|
||||
if ( !write_bytes_sec.empty() )
|
||||
{
|
||||
file << "\t\t\t\t<write_bytes_sec>" << write_bytes_sec
|
||||
<< "</write_bytes_sec>" << endl;
|
||||
}
|
||||
|
||||
if ( !total_iops_sec.empty() )
|
||||
{
|
||||
file << "\t\t\t\t<total_iops_sec>" << total_iops_sec
|
||||
<< "</total_iops_sec>" << endl;
|
||||
}
|
||||
|
||||
if ( !read_iops_sec.empty() )
|
||||
{
|
||||
file << "\t\t\t\t<read_iops_sec>" << read_iops_sec
|
||||
<< "</read_iops_sec>" << endl;
|
||||
}
|
||||
|
||||
if ( !write_iops_sec.empty() )
|
||||
{
|
||||
file << "\t\t\t\t<write_iops_sec>" << write_iops_sec
|
||||
<< "</write_iops_sec>" << endl;
|
||||
}
|
||||
|
||||
file << "\t\t\t</iotune>" << endl;
|
||||
}
|
||||
|
||||
file << "\t\t</disk>" << endl;
|
||||
}
|
||||
|
||||
attrs.clear();
|
||||
|
@ -21,7 +21,7 @@
|
||||
# - os [kernel,initrd,boot,root,kernel_cmd,arch,machine]
|
||||
# - vcpu
|
||||
# - features [acpi, pae, apic, hyperv, localtime]
|
||||
# - disk [driver, cache, io]
|
||||
# - disk [driver, cache, io, total_bytes_sec, total_iops_sec, read_bytes_sec, write_bytes_sec, read_iops_sec, write_iops_sec]
|
||||
# - nic [filter, model]
|
||||
# - raw
|
||||
# - hyperv_options: options used for FEATURES = [ HYPERV = yes ]
|
||||
|
20
src/vmm_mad/remotes/az/attach_disk
Normal file
20
src/vmm_mad/remotes/az/attach_disk
Normal file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
echo "Action $SCRIPT_NAME not supported" 1>&2
|
20
src/vmm_mad/remotes/az/attach_nic
Executable file
20
src/vmm_mad/remotes/az/attach_nic
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
echo "Action $SCRIPT_NAME not supported" 1>&2
|
126
src/vmm_mad/remotes/az/az_driver.conf
Normal file
126
src/vmm_mad/remotes/az/az_driver.conf
Normal file
@ -0,0 +1,126 @@
|
||||
proxy_uri:
|
||||
regions:
|
||||
default:
|
||||
region_name: "West Europe"
|
||||
# pem_management_cert --> Absolute path to pem management certificate
|
||||
# Info on creating certificates:
|
||||
# http://azure.microsoft.com/en-us/documentation/articles/linux-use-ssh-key/
|
||||
pem_management_cert:
|
||||
subscription_id:
|
||||
managament_endpoint:
|
||||
capacity:
|
||||
Small: 5
|
||||
Medium: 1
|
||||
Large: 0
|
||||
west-europe:
|
||||
region_name: "West Europe"
|
||||
pem_management_cert:
|
||||
subscription_id:
|
||||
managament_endpoint:
|
||||
capacity:
|
||||
Small: 5
|
||||
Medium: 1
|
||||
Large: 0
|
||||
north-europe:
|
||||
region_name: "North Europe"
|
||||
pem_management_cert:
|
||||
subscription_id:
|
||||
managament_endpoint:
|
||||
capacity:
|
||||
Small:
|
||||
Medium:
|
||||
Large:
|
||||
east-us:
|
||||
region_name: "East US"
|
||||
pem_management_cert:
|
||||
subscription_id:
|
||||
managament_endpoint:
|
||||
capacity:
|
||||
Small:
|
||||
Medium:
|
||||
Large:
|
||||
southcentral-us:
|
||||
region_name: "South Central US"
|
||||
pem_management_cert:
|
||||
subscription_id:
|
||||
managament_endpoint:
|
||||
capacity:
|
||||
Small:
|
||||
Medium:
|
||||
Large:
|
||||
west-us:
|
||||
region_name: "West US"
|
||||
pem_management_cert:
|
||||
subscription_id:
|
||||
managament_endpoint:
|
||||
capacity:
|
||||
Small:
|
||||
Medium:
|
||||
Large:
|
||||
east-asia:
|
||||
region_name: "East Asia"
|
||||
pem_management_cert:
|
||||
subscription_id:
|
||||
managament_endpoint:
|
||||
capacity:
|
||||
Small:
|
||||
Medium:
|
||||
Large:
|
||||
southeast-asia:
|
||||
region_name: "Southeast Asia"
|
||||
pem_management_cert:
|
||||
subscription_id:
|
||||
managament_endpoint:
|
||||
capacity:
|
||||
Small:
|
||||
Medium:
|
||||
Large:
|
||||
japan-west:
|
||||
region_name: "Japan West"
|
||||
pem_management_cert:
|
||||
subscription_id:
|
||||
managament_endpoint:
|
||||
capacity:
|
||||
Small:
|
||||
Medium:
|
||||
Large:
|
||||
brazil-south:
|
||||
region_name: "Brazil South"
|
||||
pem_management_cert:
|
||||
subscription_id:
|
||||
managament_endpoint:
|
||||
capacity:
|
||||
Small:
|
||||
Medium:
|
||||
Large:
|
||||
instance_types:
|
||||
ExtraSmall:
|
||||
cpu: 0.1
|
||||
memory: 0.75
|
||||
Small:
|
||||
cpu: 1
|
||||
memory: 1.75
|
||||
Medium:
|
||||
cpu: 2
|
||||
memory: 3.5
|
||||
Large:
|
||||
cpu: 4
|
||||
memory: 7
|
||||
ExtraLarge:
|
||||
cpu: 8
|
||||
memory: 14
|
||||
A5:
|
||||
cpu: 2
|
||||
memory: 14
|
||||
A6:
|
||||
cpu: 4
|
||||
memory: 28
|
||||
A7:
|
||||
cpu: 8
|
||||
memory: 56
|
||||
A8:
|
||||
cpu: 8
|
||||
memory: 56
|
||||
A9:
|
||||
cpu: 16
|
||||
memory: 112
|
55
src/vmm_mad/remotes/az/az_driver.default
Normal file
55
src/vmm_mad/remotes/az/az_driver.default
Normal file
@ -0,0 +1,55 @@
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
<!--
|
||||
Default configuration attributes for the Azure driver
|
||||
(all domains will use these values as defaults)
|
||||
Valid attributes are: INSTANCE_TYPE, IMAGE, VM_USER, VM_PASSWORD, LOCATION,
|
||||
STORAGE_ACCOUNT, WIN_RM, CLOUD_SERVICE, TCP_ENDPOINTS, SSHPORT, AFFINITY_GROUP,
|
||||
VIRTUAL_NETWORK_NAME, SUBNET and AVAILABILITY_SET
|
||||
Use XML syntax to specify defaults, note elements are UPCASE
|
||||
Example:
|
||||
<TEMPLATE>
|
||||
<AZURE>
|
||||
<LOCATION>west-europe</LOCATION>
|
||||
<INSTANCE_TYPE>Small</INSTANCE_TYPE>
|
||||
<CLOUD_SERVICE>MyDefaultCloudService</CLOUD_SERVICE>
|
||||
<IMAGE>0b11de9248dd4d87b18621318e037d37__RightImage-Ubuntu-12.04-x64-v13.4</IMAGE>
|
||||
<VM_USER>MyUser</VM_USER>
|
||||
<VM_PASSWORD>MyPassword</VM_PASSWORD>
|
||||
<STORAGE_ACCOUNT>MyStorageAccountName</STORAGE_ACCOUNT>
|
||||
<WIN_RM>http</WIN_RM>
|
||||
<CLOUD_SERVICE>MyCloudServiceName</CLOUD_SERVICE>
|
||||
<TCP_ENDPOINTS>80,3389:3390</TCP_ENDPOINTS>
|
||||
<SSHPORT>2222</SSHPORT>
|
||||
<AFFINITY_GROUP>MyAffinityGroup</AFFINITY_GROUP>
|
||||
<VIRTUAL_NETWORK_NAME>MyVirtualNetwork</VIRTUAL_NETWORK_NAME>
|
||||
<SUBNET>MySubNet<SUBNET>
|
||||
<AVAILABILITY_SET>MyAvailabilitySetName<AVAILABILITY_SET>
|
||||
</AZURE>
|
||||
</TEMPLATE>
|
||||
-->
|
||||
|
||||
<TEMPLATE>
|
||||
<AZURE>
|
||||
<LOCATION>west-europe</LOCATION>
|
||||
<INSTANCE_TYPE>Small</INSTANCE_TYPE>
|
||||
</AZURE>
|
||||
</TEMPLATE>
|
||||
|
||||
|
||||
|
||||
|
||||
|
552
src/vmm_mad/remotes/az/az_driver.rb
Executable file
552
src/vmm_mad/remotes/az/az_driver.rb
Executable file
@ -0,0 +1,552 @@
|
||||
#!/usr/bin/env ruby
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
ONE_LOCATION = ENV["ONE_LOCATION"] if !defined?(ONE_LOCATION)
|
||||
|
||||
if !ONE_LOCATION
|
||||
RUBY_LIB_LOCATION = "/usr/lib/one/ruby" if !defined?(RUBY_LIB_LOCATION)
|
||||
ETC_LOCATION = "/etc/one/" if !defined?(ETC_LOCATION)
|
||||
else
|
||||
RUBY_LIB_LOCATION = ONE_LOCATION + "/lib/ruby" if !defined?(RUBY_LIB_LOCATION)
|
||||
ETC_LOCATION = ONE_LOCATION + "/etc/" if !defined?(ETC_LOCATION)
|
||||
end
|
||||
|
||||
AZ_DRIVER_CONF = "#{ETC_LOCATION}/az_driver.conf"
|
||||
AZ_DRIVER_DEFAULT = "#{ETC_LOCATION}/az_driver.default"
|
||||
|
||||
# Load Azure credentials and environment
|
||||
require 'yaml'
|
||||
require 'rubygems'
|
||||
require 'azure'
|
||||
require 'uri'
|
||||
|
||||
$: << RUBY_LIB_LOCATION
|
||||
|
||||
require 'CommandManager'
|
||||
require 'scripts_common'
|
||||
require 'rexml/document'
|
||||
require 'VirtualMachineDriver'
|
||||
|
||||
# The main class for the Azure driver
|
||||
class AzureDriver
|
||||
ACTION = VirtualMachineDriver::ACTION
|
||||
POLL_ATTRIBUTE = VirtualMachineDriver::POLL_ATTRIBUTE
|
||||
VM_STATE = VirtualMachineDriver::VM_STATE
|
||||
|
||||
# Azure commands constants
|
||||
AZ = {
|
||||
:run => {
|
||||
:cmd => :create_virtual_machine,
|
||||
:args => {
|
||||
"INSTANCE_TYPE" => {
|
||||
:opt => 'vm_size'
|
||||
},
|
||||
"IMAGE" => {
|
||||
:opt => 'image'
|
||||
},
|
||||
"VM_USER" => {
|
||||
:opt => 'vm_user'
|
||||
},
|
||||
"VM_PASSWORD" => {
|
||||
:opt => 'password'
|
||||
},
|
||||
"LOCATION" => {
|
||||
:opt => 'location'
|
||||
},
|
||||
"STORAGE_ACCOUNT" => {
|
||||
:opt => 'storage_account_name'
|
||||
},
|
||||
"WIN_RM" => {
|
||||
:opt => 'winrm_transport',
|
||||
:proc => lambda { |str| str.split(",") }
|
||||
},
|
||||
"CLOUD_SERVICE" => {
|
||||
:opt => 'cloud_service_name'
|
||||
},
|
||||
"TCP_ENDPOINTS" => {
|
||||
:opt => 'tcp_endpoints'
|
||||
},
|
||||
"SSHPORT" => {
|
||||
:opt => 'ssh_port'
|
||||
},
|
||||
"AFFINITY_GROUP" => {
|
||||
:opt => 'affinity_group_name'
|
||||
},
|
||||
"VIRTUAL_NETWORK_NAME" => {
|
||||
:opt => 'virtual_network_name'
|
||||
},
|
||||
"SUBNET" => {
|
||||
:opt => 'subnet_name'
|
||||
},
|
||||
"AVAILABILITY_SET" => {
|
||||
:opt => 'availability_set_name'
|
||||
}
|
||||
}
|
||||
},
|
||||
:shutdown => {
|
||||
:cmd => :shutdown_virtual_machine
|
||||
},
|
||||
:reboot => {
|
||||
:cmd => :restart_virtual_machine
|
||||
},
|
||||
:stop => {
|
||||
:cmd => :shutdown_virtual_machine
|
||||
},
|
||||
:start => {
|
||||
:cmd => :start_virtual_machine
|
||||
},
|
||||
:delete => {
|
||||
:cmd => :delete_virtual_machine
|
||||
}
|
||||
}
|
||||
|
||||
# Azure attributes that will be retrieved in a polling action
|
||||
AZ_POLL_ATTRS = [
|
||||
:availability_set_name,
|
||||
:cloud_service_name,
|
||||
:data_disks,
|
||||
:deployment_name,
|
||||
:disk_name,
|
||||
:hostname,
|
||||
:image,
|
||||
:ipaddress,
|
||||
:media_link,
|
||||
:os_type,
|
||||
:role_size,
|
||||
:tcp_endpoints,
|
||||
:udp_endpoints,
|
||||
:virtual_network_name
|
||||
]
|
||||
|
||||
# Azure constructor, loads credentials and endpoint
|
||||
def initialize(host)
|
||||
@host = host
|
||||
|
||||
@public_cloud_az_conf = YAML::load(File.read(AZ_DRIVER_CONF))
|
||||
|
||||
@instance_types = @public_cloud_az_conf['instance_types']
|
||||
|
||||
regions = @public_cloud_az_conf['regions']
|
||||
@region = regions[host] || regions["default"]
|
||||
|
||||
# Sanitize region data
|
||||
if @region['pem_management_cert'].nil?
|
||||
raise "pem_management_cert not defined for #{host}"
|
||||
end
|
||||
|
||||
if @region['subscription_id'].nil?
|
||||
raise "subscription_id not defined for #{host}"
|
||||
end
|
||||
|
||||
# Set default endpoint if not declared
|
||||
if @region['managment_endpoint'].nil?
|
||||
@region['managment_endpoint']="https://management.core.windows.net"
|
||||
end
|
||||
|
||||
Azure.configure do |config|
|
||||
# Configure these 3 properties to use Storage
|
||||
config.management_certificate = @region['pem_management_cert']
|
||||
config.subscription_id = @region['subscription_id']
|
||||
config.management_endpoint = @region['management_endpoint']
|
||||
end
|
||||
|
||||
@azure_vms = Azure::VirtualMachineManagementService.new
|
||||
end
|
||||
|
||||
# DEPLOY action
|
||||
def deploy(id, host, xml_text)
|
||||
load_default_template_values
|
||||
|
||||
az_info = get_deployment_info(host, xml_text)
|
||||
|
||||
if !az_value(az_info, 'IMAGE')
|
||||
STDERR.puts("Cannot find IMAGE in deployment file")
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
csn = az_value(az_info, 'CLOUD_SERVICE')
|
||||
|
||||
csn = "OpenNebulaDefaultCloudServiceName-#{id}" if !csn
|
||||
|
||||
create_params = create_params(id,csn,az_info)
|
||||
create_options = create_options(id,csn,az_info)
|
||||
instance = nil
|
||||
|
||||
begin
|
||||
in_silence do
|
||||
instance = @azure_vms.create_virtual_machine(create_params,
|
||||
create_options)
|
||||
end
|
||||
rescue => e
|
||||
STDERR.puts(e.message)
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
if instance.class == Azure::VirtualMachineManagement::VirtualMachine
|
||||
puts(instance.vm_name)
|
||||
else
|
||||
STDERR.puts(instance)
|
||||
exit (-1)
|
||||
end
|
||||
end
|
||||
|
||||
# Shutdown an Azure instance
|
||||
def shutdown(deploy_id)
|
||||
az_action(deploy_id, :shutdown)
|
||||
az_action(deploy_id, :delete)
|
||||
end
|
||||
|
||||
# Reboot an Azure instance
|
||||
def reboot(deploy_id)
|
||||
az_action(deploy_id, :reboot)
|
||||
end
|
||||
|
||||
# Cancel an Azure instance
|
||||
def cancel(deploy_id)
|
||||
az_action(deploy_id, :delete)
|
||||
end
|
||||
|
||||
# Stop an Azure instance
|
||||
def save(deploy_id)
|
||||
az_action(deploy_id, :shutdown)
|
||||
end
|
||||
|
||||
# Cancel an Azure instance
|
||||
def restore(deploy_id)
|
||||
az_action(deploy_id, :start)
|
||||
end
|
||||
|
||||
# Get info (IP, and state) for an Azure instance
|
||||
def poll(id, deploy_id)
|
||||
i = get_instance(deploy_id)
|
||||
puts parse_poll(i)
|
||||
end
|
||||
|
||||
# Get the info of all Aure instances. An Azure instance must have
|
||||
# a name compliant with the "one-#####_csn" format, where ##### are intengers
|
||||
def monitor_all_vms
|
||||
totalmemory = 0
|
||||
totalcpu = 0
|
||||
@region['capacity'].each { |name, size|
|
||||
cpu, mem = instance_type_capacity(name)
|
||||
|
||||
totalmemory += mem * size.to_i
|
||||
totalcpu += cpu * size.to_i
|
||||
}
|
||||
|
||||
host_info = "HYPERVISOR=AZURE\n"
|
||||
host_info << "PUBLIC_CLOUD=YES\n"
|
||||
host_info << "PRIORITY=-1\n"
|
||||
host_info << "TOTALMEMORY=#{totalmemory.round}\n"
|
||||
host_info << "TOTALCPU=#{totalcpu}\n"
|
||||
host_info << "HOSTNAME=\"#{@host}\"\n"
|
||||
|
||||
vms_info = "VM_POLL=YES\n"
|
||||
|
||||
usedcpu = 0
|
||||
usedmemory = 0
|
||||
|
||||
begin
|
||||
@azure_vms.list_virtual_machines.each do |vm|
|
||||
poll_data=parse_poll(vm)
|
||||
|
||||
if vm.vm_name.start_with?('one-') and
|
||||
vm.vm_name.match(/([^_]+)_(.+)/) and
|
||||
vm.vm_name.match(/([^_]+)_(.+)/).size > 1
|
||||
|
||||
one_id = vm.vm_name.match(/([^_]+)_(.+)/)[1].split("-")[1]
|
||||
end
|
||||
|
||||
vms_info << "VM=[\n"
|
||||
vms_info << " ID=#{one_id || -1},\n"
|
||||
vms_info << " DEPLOY_ID=#{vm.vm_name},\n"
|
||||
vms_info << " POLL=\"#{poll_data}\" ]\n"
|
||||
|
||||
if one_id
|
||||
cpu, mem = instance_type_capacity(vm.role_size)
|
||||
usedcpu += cpu
|
||||
usedmemory += mem
|
||||
end
|
||||
|
||||
end
|
||||
rescue => e
|
||||
STDERR.puts(e.message)
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
host_info << "USEDMEMORY=#{usedmemory.round}\n"
|
||||
host_info << "USEDCPU=#{usedcpu.round}\n"
|
||||
host_info << "FREEMEMORY=#{(totalmemory - usedmemory).round}\n"
|
||||
host_info << "FREECPU=#{(totalcpu - usedcpu).round}\n"
|
||||
|
||||
puts host_info
|
||||
puts vms_info
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Get the associated capacity of the instance_type as cpu (in 100 percent
|
||||
# e.g. 800 for 8 cores) and memory (in KB)
|
||||
def instance_type_capacity(name)
|
||||
return 0, 0 if @instance_types[name].nil?
|
||||
return @instance_types[name]['cpu'].to_i * 100 ,
|
||||
@instance_types[name]['memory'].to_i * 1024 * 1024
|
||||
end
|
||||
|
||||
# Get the Azure section of the template. If more than one Azure section
|
||||
# the LOCATION element is used and matched with the host
|
||||
def get_deployment_info(host, xml_text)
|
||||
xml = REXML::Document.new xml_text
|
||||
|
||||
az = nil
|
||||
|
||||
all_az_elements = xml.root.get_elements("//USER_TEMPLATE/PUBLIC_CLOUD")
|
||||
|
||||
# First, let's see if we have an Azure location that matches
|
||||
# our host name
|
||||
all_az_elements.each { |element|
|
||||
cloud_host = element.elements["LOCATION"]
|
||||
type = element.elements["TYPE"].text
|
||||
|
||||
next if !type.downcase.eql? "azure"
|
||||
|
||||
if cloud_host and cloud_host.text.upcase.eql? host.upcase
|
||||
az = element
|
||||
end
|
||||
}
|
||||
|
||||
if !az
|
||||
# If we don't find an Azure location, and ONE just
|
||||
# knows about one Azure location, let's use that
|
||||
if all_az_elements.size == 1 and
|
||||
all_az_elements[0].elements["TYPE"].text.downcase.eql? "azure"
|
||||
az = all_az_elements[0]
|
||||
else
|
||||
STDERR.puts(
|
||||
"Cannot find Azure element in VM template "<<
|
||||
"or couldn't find any Azure location matching "<<
|
||||
"one of the templates.")
|
||||
exit(-1)
|
||||
end
|
||||
end
|
||||
|
||||
# If LOCATION not explicitly defined, try to get default, if not
|
||||
# try to use hostname as datacenter
|
||||
if !az.elements["LOCATION"]
|
||||
location=REXML::Element.new("LOCATION")
|
||||
if @defaults["LOCATION"]
|
||||
location.text=@defaults["LOCATION"]
|
||||
else
|
||||
location.text=host
|
||||
end
|
||||
az.elements << location
|
||||
end
|
||||
|
||||
# Translate region name form keyword to actual value
|
||||
region_keyword = az.elements["LOCATION"].text
|
||||
translated_region = @public_cloud_az_conf["regions"][region_keyword]
|
||||
az.elements["LOCATION"].text=translated_region["region_name"]
|
||||
|
||||
az
|
||||
end
|
||||
|
||||
# Retrive the vm information from the Azure instance
|
||||
def parse_poll(instance)
|
||||
info = "#{POLL_ATTRIBUTE[:usedmemory]}=0 " \
|
||||
"#{POLL_ATTRIBUTE[:usedcpu]}=0 " \
|
||||
"#{POLL_ATTRIBUTE[:nettx]}=0 " \
|
||||
"#{POLL_ATTRIBUTE[:netrx]}=0 "
|
||||
|
||||
state = ""
|
||||
if !instance
|
||||
state = VM_STATE[:deleted]
|
||||
else
|
||||
state = case instance.deployment_status
|
||||
when "Running", "Starting"
|
||||
VM_STATE[:active]
|
||||
when "Suspended", "Stopping",
|
||||
VM_STATE[:paused]
|
||||
else
|
||||
VM_STATE[:deleted]
|
||||
end
|
||||
end
|
||||
info << "#{POLL_ATTRIBUTE[:state]}=#{state} "
|
||||
|
||||
AZ_POLL_ATTRS.map { |key|
|
||||
value = instance.send(key)
|
||||
if !value.nil? && !value.empty?
|
||||
if key.to_s.upcase == "TCP_ENDPOINTS" or
|
||||
key.to_s.upcase == "UDP_ENDPOINTS"
|
||||
value_str = format_endpoints(value)
|
||||
elsif value.kind_of?(Hash)
|
||||
value_str = value.inspect
|
||||
else
|
||||
value_str = value
|
||||
end
|
||||
|
||||
info << "AZ_#{key.to_s.upcase}=#{value_str.gsub("\"","")} "
|
||||
|
||||
end
|
||||
}
|
||||
|
||||
info
|
||||
end
|
||||
|
||||
def format_endpoints(endpoints)
|
||||
endpnt_str = ""
|
||||
|
||||
endpoints.each{|ep|
|
||||
endpnt_str += "name=#{ep[:name]}," +
|
||||
"vip=#{ep[:vip]},publicport=#{ep[:public_port]}," +
|
||||
"local_port=#{ep[:local_port]}," +
|
||||
"local_port=#{ep[:protocol]};"
|
||||
}
|
||||
|
||||
endpnt_str.chop
|
||||
end
|
||||
|
||||
def create_params(id,csn,az_info)
|
||||
params = {
|
||||
# Name will always be 'one-<id>_<cloud_service_name>'
|
||||
:vm_name => "one-#{id}_#{csn}",
|
||||
:vm_user => az_value(az_info, 'VM_USER'),
|
||||
:image => az_value(az_info, 'IMAGE'),
|
||||
:password => az_value(az_info, 'VM_PASSWORD'),
|
||||
:location => az_value(az_info, 'LOCATION')
|
||||
}.delete_if { |k, v| v.nil? }
|
||||
end
|
||||
|
||||
def create_options(id,csn,az_info)
|
||||
options = {
|
||||
:storage_account_name => az_value(az_info, 'STORAGE_ACCOUNT'),
|
||||
:winrm_transport => az_value(az_info, 'WIN_RM'),
|
||||
:cloud_service_name => csn,
|
||||
:tcp_endpoints => az_value(az_info, 'TCP_ENDPOINTS'),
|
||||
# TODO possibly taking the values from user template
|
||||
# and create temp files
|
||||
# :private_key_file => 'c:/private_key.key',
|
||||
# :certificate_file => 'c:/certificate.pem',
|
||||
:ssh_port => az_value(az_info, 'SSHPORT'),
|
||||
:vm_size => az_value(az_info, 'INSTANCE_TYPE'),
|
||||
:affinity_group_name => az_value(az_info, 'AFFINITY_GROUP'),
|
||||
:virtual_network_name => az_value(az_info, 'VIRTUAL_NETWORK_NAME'),
|
||||
:subnet_name => az_value(az_info, 'SUBNET'),
|
||||
:availability_set_name => az_value(az_info, 'AVAILABILITY_SET')
|
||||
}.delete_if { |k, v| v.nil? }
|
||||
end
|
||||
|
||||
# Execute an Azure command
|
||||
# +deploy_id+: String, VM id in Azure
|
||||
# +az_action+: Symbol, one of the keys of the Azure hash constant (i.e :run)
|
||||
def az_action(deploy_id, az_action)
|
||||
name, csn = deploy_id.match(/([^_]+)_(.+)/)[1..-1]
|
||||
|
||||
begin
|
||||
in_silence do
|
||||
@azure_vms.send(AZ[az_action][:cmd], deploy_id, csn)
|
||||
end
|
||||
rescue => e
|
||||
STDERR.puts e.message
|
||||
exit(-1)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the value of the xml specified by the name or the default
|
||||
# one if it does not exist
|
||||
# +xml+: REXML Document, containing Azure information
|
||||
# +name+: String, xpath expression to retrieve the value
|
||||
# +block+: Block, block to be applied to the value before returning it
|
||||
def az_value(xml, name, &block)
|
||||
value = value_from_xml(xml, name) || @defaults[name]
|
||||
if block_given? && value
|
||||
block.call(value)
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
|
||||
def value_from_xml(xml, name)
|
||||
if xml
|
||||
element = xml.elements[name]
|
||||
element.text.strip if element && element.text
|
||||
end
|
||||
end
|
||||
|
||||
# Load the default values that will be used to create a new instance, if
|
||||
# not provided in the template. These values are defined in the AZ_CONF
|
||||
# file
|
||||
def load_default_template_values
|
||||
@defaults = Hash.new
|
||||
|
||||
if File.exists?(AZ_DRIVER_DEFAULT)
|
||||
fd = File.new(AZ_DRIVER_DEFAULT)
|
||||
xml = REXML::Document.new fd
|
||||
fd.close()
|
||||
|
||||
return if !xml || !xml.root
|
||||
|
||||
az = xml.root.elements["AZURE"]
|
||||
|
||||
return if !az
|
||||
|
||||
AZ.each {|action, hash|
|
||||
if hash[:args]
|
||||
hash[:args].each { |key, value|
|
||||
@defaults[key] = value_from_xml(az, key)
|
||||
}
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def in_silence
|
||||
begin
|
||||
orig_stderr = $stderr.clone
|
||||
orig_stdout = $stdout.clone
|
||||
$stderr.reopen File.new('/dev/null', 'w')
|
||||
$stdout.reopen File.new('/dev/null', 'w')
|
||||
retval = yield
|
||||
rescue Exception => e
|
||||
$stdout.reopen orig_stdout
|
||||
$stderr.reopen orig_stderr
|
||||
raise e
|
||||
ensure
|
||||
$stdout.reopen orig_stdout
|
||||
$stderr.reopen orig_stderr
|
||||
end
|
||||
retval
|
||||
end
|
||||
|
||||
# Retrive the instance from Azure. If OpenNebula asks for it, then the
|
||||
# vm_name must comply with the notation name_csn
|
||||
def get_instance(vm_name)
|
||||
begin
|
||||
csn = vm_name.match(/([^_]+)_(.+)/)[2]
|
||||
|
||||
instance = @azure_vms.get_virtual_machine(vm_name,csn)
|
||||
if instance
|
||||
return instance
|
||||
else
|
||||
raise "Instance #{vm_name} does not exist"
|
||||
end
|
||||
rescue => e
|
||||
STDERR.puts e.message
|
||||
exit(-1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
29
src/vmm_mad/remotes/az/cancel
Executable file
29
src/vmm_mad/remotes/az/cancel
Executable file
@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2010-2014, C12G Labs S.L #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
$: << File.dirname(__FILE__)
|
||||
|
||||
require 'az_driver'
|
||||
|
||||
deploy_id = ARGV[0]
|
||||
host = ARGV[1]
|
||||
|
||||
az_drv = AzureDriver.new(host)
|
||||
|
||||
az_drv.cancel(deploy_id)
|
||||
|
34
src/vmm_mad/remotes/az/deploy
Executable file
34
src/vmm_mad/remotes/az/deploy
Executable file
@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Copyright 2010-2014, C12G Labs S.L #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
$: << File.dirname(__FILE__)
|
||||
|
||||
require 'az_driver'
|
||||
|
||||
dfile = ARGV[0]
|
||||
host = ARGV[1]
|
||||
id = ARGV[2]
|
||||
|
||||
az_drv = AzureDriver.new(host)
|
||||
|
||||
text=File.read(dfile)
|
||||
|
||||
puts az_drv.deploy(id, host, text)
|
||||
|
||||
exit 0
|
||||
|
20
src/vmm_mad/remotes/az/detach_disk
Executable file
20
src/vmm_mad/remotes/az/detach_disk
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
echo "Action $SCRIPT_NAME not supported" 1>&2
|
20
src/vmm_mad/remotes/az/detach_nic
Executable file
20
src/vmm_mad/remotes/az/detach_nic
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
echo "Action $SCRIPT_NAME not supported" 1>&2
|
20
src/vmm_mad/remotes/az/migrate
Executable file
20
src/vmm_mad/remotes/az/migrate
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
echo "Action $SCRIPT_NAME not supported" 1>&2
|
20
src/vmm_mad/remotes/az/migrate_local
Executable file
20
src/vmm_mad/remotes/az/migrate_local
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
echo "Action $SCRIPT_NAME not supported" 1>&2
|
30
src/vmm_mad/remotes/az/poll
Executable file
30
src/vmm_mad/remotes/az/poll
Executable file
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2010-2014, C12G Labs S.L #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
$: << File.dirname(__FILE__)
|
||||
|
||||
require 'az_driver'
|
||||
|
||||
deploy_id = ARGV[0]
|
||||
host = ARGV[1]
|
||||
id = ARGV[2]
|
||||
|
||||
az_drv = AzureDriver.new(host)
|
||||
|
||||
az_drv.poll(id, deploy_id)
|
||||
|
29
src/vmm_mad/remotes/az/reboot
Executable file
29
src/vmm_mad/remotes/az/reboot
Executable file
@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2010-2014, C12G Labs S.L #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
$: << File.dirname(__FILE__)
|
||||
|
||||
require 'az_driver'
|
||||
|
||||
deploy_id = ARGV[0]
|
||||
host = ARGV[1]
|
||||
|
||||
az_drv = AzureDriver.new(host)
|
||||
|
||||
az_drv.reboot(deploy_id)
|
||||
|
20
src/vmm_mad/remotes/az/reset
Executable file
20
src/vmm_mad/remotes/az/reset
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
echo "Action $SCRIPT_NAME not supported" 1>&2
|
28
src/vmm_mad/remotes/az/restore
Executable file
28
src/vmm_mad/remotes/az/restore
Executable file
@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2010-2014, C12G Labs S.L #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
$: << File.dirname(__FILE__)
|
||||
|
||||
require 'az_driver'
|
||||
|
||||
checkpoint_file = ARGV[0]
|
||||
host = ARGV[1]
|
||||
deploy_id = ARGV[2]
|
||||
|
||||
az_drv = AzureDriver.new(host)
|
||||
az_drv.restore(deploy_id)
|
29
src/vmm_mad/remotes/az/save
Executable file
29
src/vmm_mad/remotes/az/save
Executable file
@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2010-2014, C12G Labs S.L #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
$: << File.dirname(__FILE__)
|
||||
|
||||
require 'az_driver'
|
||||
|
||||
deploy_id = ARGV[0]
|
||||
file = ARGV[1]
|
||||
host = ARGV[2]
|
||||
|
||||
az_drv = AzureDriver.new(host)
|
||||
az_drv.save(deploy_id)
|
||||
|
29
src/vmm_mad/remotes/az/shutdown
Executable file
29
src/vmm_mad/remotes/az/shutdown
Executable file
@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2010-2014, C12G Labs S.L #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
$: << File.dirname(__FILE__)
|
||||
|
||||
require 'az_driver'
|
||||
|
||||
deploy_id = ARGV[0]
|
||||
host = ARGV[1]
|
||||
|
||||
az_drv = AzureDriver.new(host)
|
||||
|
||||
az_drv.shutdown(deploy_id)
|
||||
|
20
src/vmm_mad/remotes/az/snapshot_create
Executable file
20
src/vmm_mad/remotes/az/snapshot_create
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
echo "Action $SCRIPT_NAME not supported" 1>&2
|
20
src/vmm_mad/remotes/az/snapshot_delete
Executable file
20
src/vmm_mad/remotes/az/snapshot_delete
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
echo "Action $SCRIPT_NAME not supported" 1>&2
|
20
src/vmm_mad/remotes/az/snapshot_revert
Executable file
20
src/vmm_mad/remotes/az/snapshot_revert
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
echo "Action $SCRIPT_NAME not supported" 1>&2
|
0
src/vmm_mad/remotes/ec2/attach_disk
Normal file → Executable file
0
src/vmm_mad/remotes/ec2/attach_disk
Normal file → Executable file
20
src/vmm_mad/remotes/sl/attach_disk
Executable file
20
src/vmm_mad/remotes/sl/attach_disk
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
echo "Action $SCRIPT_NAME not supported" 1>&2
|
20
src/vmm_mad/remotes/sl/attach_nic
Executable file
20
src/vmm_mad/remotes/sl/attach_nic
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
echo "Action $SCRIPT_NAME not supported" 1>&2
|
28
src/vmm_mad/remotes/sl/cancel
Executable file
28
src/vmm_mad/remotes/sl/cancel
Executable file
@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2010-2014, C12G Labs S.L #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
$: << File.dirname(__FILE__)
|
||||
|
||||
require 'sl_driver'
|
||||
|
||||
deploy_id = ARGV[0]
|
||||
host = ARGV[1]
|
||||
|
||||
sl_drv = SLDriver.new(host)
|
||||
|
||||
sl_drv.cancel(deploy_id)
|
33
src/vmm_mad/remotes/sl/deploy
Executable file
33
src/vmm_mad/remotes/sl/deploy
Executable file
@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2010-2014, C12G Labs S.L #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
$: << File.dirname(__FILE__)
|
||||
|
||||
require 'sl_driver'
|
||||
|
||||
dfile = ARGV[0]
|
||||
host = ARGV[1]
|
||||
id = ARGV[2]
|
||||
|
||||
sl_drv = SLDriver.new(host)
|
||||
|
||||
text=File.read(dfile)
|
||||
|
||||
puts sl_drv.deploy(id, host, text)
|
||||
|
||||
exit 0
|
20
src/vmm_mad/remotes/sl/detach_disk
Executable file
20
src/vmm_mad/remotes/sl/detach_disk
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
echo "Action $SCRIPT_NAME not supported" 1>&2
|
20
src/vmm_mad/remotes/sl/detach_nic
Executable file
20
src/vmm_mad/remotes/sl/detach_nic
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
echo "Action $SCRIPT_NAME not supported" 1>&2
|
20
src/vmm_mad/remotes/sl/migrate
Executable file
20
src/vmm_mad/remotes/sl/migrate
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
echo "Action $SCRIPT_NAME not supported" 1>&2
|
20
src/vmm_mad/remotes/sl/migrate_local
Executable file
20
src/vmm_mad/remotes/sl/migrate_local
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
echo "Action $SCRIPT_NAME not supported" 1>&2
|
29
src/vmm_mad/remotes/sl/poll
Executable file
29
src/vmm_mad/remotes/sl/poll
Executable file
@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2010-2014, C12G Labs S.L #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
$: << File.dirname(__FILE__)
|
||||
|
||||
require 'sl_driver'
|
||||
|
||||
deploy_id = ARGV[0]
|
||||
host = ARGV[1]
|
||||
id = ARGV[2]
|
||||
|
||||
sl_drv = SLDriver.new(host)
|
||||
|
||||
sl_drv.poll(id, deploy_id)
|
28
src/vmm_mad/remotes/sl/reboot
Executable file
28
src/vmm_mad/remotes/sl/reboot
Executable file
@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2010-2014, C12G Labs S.L #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
$: << File.dirname(__FILE__)
|
||||
|
||||
require 'sl_driver'
|
||||
|
||||
deploy_id = ARGV[0]
|
||||
host = ARGV[1]
|
||||
|
||||
sl_drv = SLDriver.new(host)
|
||||
|
||||
sl_drv.reboot(deploy_id)
|
20
src/vmm_mad/remotes/sl/reset
Executable file
20
src/vmm_mad/remotes/sl/reset
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
echo "Action $SCRIPT_NAME not supported" 1>&2
|
27
src/vmm_mad/remotes/sl/restore
Executable file
27
src/vmm_mad/remotes/sl/restore
Executable file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2010-2014, C12G Labs S.L #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
$: << File.dirname(__FILE__)
|
||||
|
||||
require 'sl_driver'
|
||||
|
||||
host = ARGV[-1]
|
||||
deploy_id = ARGV[2]
|
||||
|
||||
sl_drv = SLDriver.new(host)
|
||||
sl_drv.restore(deploy_id)
|
27
src/vmm_mad/remotes/sl/save
Executable file
27
src/vmm_mad/remotes/sl/save
Executable file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2010-2014, C12G Labs S.L #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
$: << File.dirname(__FILE__)
|
||||
|
||||
require 'sl_driver'
|
||||
|
||||
deploy_id = ARGV[0]
|
||||
host = ARGV[1]
|
||||
|
||||
sl_drv = SLDriver.new(host)
|
||||
sl_drv.save(deploy_id)
|
28
src/vmm_mad/remotes/sl/shutdown
Executable file
28
src/vmm_mad/remotes/sl/shutdown
Executable file
@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2010-2014, C12G Labs S.L #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
$: << File.dirname(__FILE__)
|
||||
|
||||
require 'sl_driver'
|
||||
|
||||
deploy_id = ARGV[0]
|
||||
host = ARGV[1]
|
||||
|
||||
sl_drv = SLDriver.new(host)
|
||||
|
||||
sl_drv.shutdown(deploy_id)
|
109
src/vmm_mad/remotes/sl/sl_driver.conf
Normal file
109
src/vmm_mad/remotes/sl/sl_driver.conf
Normal file
@ -0,0 +1,109 @@
|
||||
# Regions extracted from http://www.softlayer.com/data-centers
|
||||
regions:
|
||||
default:
|
||||
region_name: sjc01
|
||||
username:
|
||||
api_key:
|
||||
capacity:
|
||||
slcci.small: 5
|
||||
slcci.large: 0
|
||||
slcci.large: 0
|
||||
ams01:
|
||||
region_name: ams01
|
||||
username:
|
||||
api_key:
|
||||
capacity:
|
||||
slcci.small: 5
|
||||
slcci.large: 0
|
||||
slcci.large: 0
|
||||
sjc01:
|
||||
region_name: sjc01
|
||||
username:
|
||||
api_key:
|
||||
capacity:
|
||||
slcci.small:
|
||||
slcci.large:
|
||||
slcci.large:
|
||||
dal01:
|
||||
region_name: dal01
|
||||
username:
|
||||
api_key:
|
||||
capacity:
|
||||
slcci.small:
|
||||
slcci.large:
|
||||
slcci.large:
|
||||
dal02:
|
||||
region_name: dal02
|
||||
username:
|
||||
api_key:
|
||||
capacity:
|
||||
slcci.small:
|
||||
slcci.large:
|
||||
slcci.large:
|
||||
dal05:
|
||||
region_name: dal05
|
||||
username:
|
||||
api_key:
|
||||
capacity:
|
||||
slcci.small:
|
||||
slcci.large:
|
||||
slcci.large:
|
||||
dal06:
|
||||
region_name: dal06
|
||||
username:
|
||||
api_key:
|
||||
capacity:
|
||||
slcci.small:
|
||||
slcci.large:
|
||||
slcci.large:
|
||||
dal07:
|
||||
region_name: dal07
|
||||
username:
|
||||
api_key:
|
||||
capacity:
|
||||
slcci.small:
|
||||
slcci.large:
|
||||
slcci.large:
|
||||
hou02:
|
||||
region_name: hou02
|
||||
username:
|
||||
api_key:
|
||||
capacity:
|
||||
slcci.small:
|
||||
slcci.large:
|
||||
slcci.large:
|
||||
sea01:
|
||||
region_name: sea01
|
||||
username:
|
||||
api_key:
|
||||
capacity:
|
||||
slcci.small:
|
||||
slcci.large:
|
||||
slcci.large:
|
||||
sng01:
|
||||
region_name: sng01
|
||||
username:
|
||||
api_key:
|
||||
capacity:
|
||||
slcci.small:
|
||||
slcci.large:
|
||||
slcci.large:
|
||||
wdc01:
|
||||
region_name: wdc01
|
||||
username:
|
||||
api_key:
|
||||
capacity:
|
||||
slcci.small:
|
||||
slcci.large:
|
||||
slcci.large:
|
||||
instance_types:
|
||||
slcci.small:
|
||||
cpu: 1
|
||||
memory: 1
|
||||
slcci.medium:
|
||||
cpu: 2
|
||||
memory: 4
|
||||
slcci.large:
|
||||
cpu: 4
|
||||
memory: 8
|
||||
|
37
src/vmm_mad/remotes/sl/sl_driver.default
Normal file
37
src/vmm_mad/remotes/sl/sl_driver.default
Normal file
@ -0,0 +1,37 @@
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
<!--
|
||||
Default configuration attributes for the SoftLayer driver
|
||||
(all domains will use these values as defaults)
|
||||
|
||||
Use XML syntax to specify defaults, note elements are UPPERCASE
|
||||
Example:
|
||||
<TEMPLATE>
|
||||
<SOFTLAYER>
|
||||
<INSTANCETYPE>scci.small</INSTANCETYPE>
|
||||
</SOFTLAYER>
|
||||
</TEMPLATE>
|
||||
-->
|
||||
|
||||
<TEMPLATE>
|
||||
<SOFTLAYER>
|
||||
<DOMAIN>c12g.com</DOMAIN>
|
||||
<INSTANCE_TYPE>slcci.small</INSTANCE_TYPE>
|
||||
<HOURLYBILLINGFLAG>true</HOURLYBILLINGFLAG>
|
||||
<LOCALDISKFLAG>true</LOCALDISKFLAG>
|
||||
<DATACENTER>ams01</DATACENTER>
|
||||
</SOFTLAYER>
|
||||
</TEMPLATE>
|
553
src/vmm_mad/remotes/sl/sl_driver.rb
Normal file
553
src/vmm_mad/remotes/sl/sl_driver.rb
Normal file
@ -0,0 +1,553 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
ONE_LOCATION = ENV["ONE_LOCATION"] if !defined?(ONE_LOCATION)
|
||||
|
||||
if !ONE_LOCATION
|
||||
RUBY_LIB_LOCATION = "/usr/lib/one/ruby" if !defined?(RUBY_LIB_LOCATION)
|
||||
ETC_LOCATION = "/etc/one/" if !defined?(ETC_LOCATION)
|
||||
else
|
||||
RUBY_LIB_LOCATION = ONE_LOCATION + "/lib/ruby" if !defined?(RUBY_LIB_LOCATION)
|
||||
ETC_LOCATION = ONE_LOCATION + "/etc/" if !defined?(ETC_LOCATION)
|
||||
end
|
||||
|
||||
SL_DRIVER_CONF = "#{ETC_LOCATION}/sl_driver.conf"
|
||||
SL_DRIVER_DEFAULT = "#{ETC_LOCATION}/sl_driver.default"
|
||||
|
||||
# Load SL credentials and needed gems
|
||||
require 'yaml'
|
||||
require 'rubygems'
|
||||
require 'softlayer_api'
|
||||
|
||||
$: << RUBY_LIB_LOCATION
|
||||
|
||||
require 'CommandManager'
|
||||
require 'scripts_common'
|
||||
require 'rexml/document'
|
||||
require 'VirtualMachineDriver'
|
||||
|
||||
# The main class for the SoftLayer driver
|
||||
class SLDriver
|
||||
ACTION = VirtualMachineDriver::ACTION
|
||||
POLL_ATTRIBUTE = VirtualMachineDriver::POLL_ATTRIBUTE
|
||||
VM_STATE = VirtualMachineDriver::VM_STATE
|
||||
|
||||
# Key that will be used to store the monitoring information in the template
|
||||
SL_MONITOR_KEY = "SLDRIVER_MONITOR"
|
||||
|
||||
# SL commands constants
|
||||
SL = {
|
||||
:run => {
|
||||
:cmd => :createObject, # Create a new SL object
|
||||
:args => {
|
||||
"HOSTNAME" => {
|
||||
:opt => 'hostname'
|
||||
},
|
||||
"DOMAIN" => {
|
||||
:opt => 'domain'
|
||||
},
|
||||
"STARTCPUS" => {
|
||||
:opt => 'startCpus'
|
||||
},
|
||||
"MAXMEMORY" => {
|
||||
:opt => 'maxMemory'
|
||||
},
|
||||
"HOURLYBILLING" => {
|
||||
:opt => 'hourlyBillingFlag'
|
||||
},
|
||||
"LOCALDISK" => {
|
||||
:opt => 'localDiskFlag'
|
||||
},
|
||||
"DEDICATEDHOST" => {
|
||||
:opt => 'dedicatedAccountHostOnlyFlag'
|
||||
},
|
||||
"DATACENTER" => {
|
||||
:opt => 'datacenter.name'
|
||||
},
|
||||
"OPERATINGSYSTEM" => {
|
||||
:opt => 'operatingSystemReferenceCode'
|
||||
},
|
||||
"BLOCKDEVICETEMPLATE" => {
|
||||
:opt => 'blockDeviceTemplateGroup.globalIdentifier'
|
||||
},
|
||||
"BLOCKDEVICE" => {
|
||||
:opt => 'blockDevices',
|
||||
:proc => lambda {|str|
|
||||
[{:device=>0, :diskImage=>{:capacity=>str}}]}
|
||||
|
||||
},
|
||||
"NETWORKCOMPONENTSMAXSPEED" => {
|
||||
:opt => 'networkComponents.maxSpeed',
|
||||
},
|
||||
"PRIVATENETWORKONLY" => {
|
||||
:opt => 'privateNetworkOnlyFlag',
|
||||
:proc => lambda {|str| str=="YES"?true:false}
|
||||
},
|
||||
"PRIMARYNETWORKVLAN" => {
|
||||
:opt => 'primaryNetworkComponent.networkVlan.id'
|
||||
},
|
||||
"PRIMARYBACKENDNETWORKVLAN" => {
|
||||
:opt => 'primaryBackendNetworkComponent.networkVlan.id'
|
||||
},
|
||||
"USERDATA" => {
|
||||
:opt => 'userData.value'
|
||||
},
|
||||
"SSHKEYS" => {
|
||||
:opt => 'sshKeys', # Array of SSH Keys ids
|
||||
:proc => lambda {|str|
|
||||
sshArray = Array.new
|
||||
str.split(",").each { |id|
|
||||
sshArray << {:id=> id}
|
||||
}
|
||||
sshArray
|
||||
}
|
||||
|
||||
},
|
||||
"POSTSCRIPT" => {
|
||||
:opt => 'postInstallScriptUri'
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
:terminate => {
|
||||
:cmd => :deleteObject # Terminate a Virtual Guest
|
||||
},
|
||||
:reboot => {
|
||||
:cmd => :rebootDefault # Reboot a Virtual Guest
|
||||
},
|
||||
:stop => {
|
||||
:cmd => :pause # Stop a Virtual Guest
|
||||
},
|
||||
:start => {
|
||||
:cmd => :resume # Resume a Virtual Guest
|
||||
},
|
||||
:poweroff => {
|
||||
:cmd => :powerOff # Powers off a Virtual Guest
|
||||
}
|
||||
}
|
||||
|
||||
# SoftLayer attributes that will be retrieved in a polling action.
|
||||
SL_POLL_ATTRS = [
|
||||
:id,
|
||||
:hostname,
|
||||
:domain,
|
||||
:fullyQualifiedDomainName,
|
||||
:maxCpu,
|
||||
:maxMemory,
|
||||
:startCpus,
|
||||
:uuid,
|
||||
:globalIdentifier,
|
||||
:primaryBackendIpAddress,
|
||||
:primaryIpAddress
|
||||
]
|
||||
|
||||
# SoftLayer constructor, loads credentials and endpoint
|
||||
def initialize(host)
|
||||
@host = host
|
||||
|
||||
public_cloud_sl_conf = YAML::load(File.read(SL_DRIVER_CONF))
|
||||
|
||||
@instance_types = public_cloud_sl_conf['instance_types']
|
||||
|
||||
regions = public_cloud_sl_conf['regions']
|
||||
@region = regions[host] || regions["default"]
|
||||
|
||||
client_cred={:username => @region['username'],
|
||||
:api_key => @region['api_key']}
|
||||
|
||||
client_cred[:endpoint_url]=@region['endpoint'] if @region['endpoint']
|
||||
|
||||
|
||||
@sl_client = SoftLayer::Client.new(client_cred)
|
||||
end
|
||||
|
||||
# DEPLOY action
|
||||
def deploy(id, host, xml_text)
|
||||
load_default_template_values
|
||||
|
||||
sl_info = get_deployment_info(host, xml_text)
|
||||
|
||||
opts = generate_options(:run, sl_info, {
|
||||
:min_count => 1,
|
||||
:max_count => 1})
|
||||
|
||||
if !opts[:startCpus] or !opts[:maxMemory]
|
||||
xml = REXML::Document.new xml_text
|
||||
instance_type = xml.root.get_elements("//INSTANCE_TYPE")[0].text
|
||||
cpu, mem = instance_type_capacity(instance_type)
|
||||
opts[:startCpus] = cpu / 100
|
||||
opts[:maxMemory] = mem / 1024
|
||||
end
|
||||
|
||||
vg_srvc = @sl_client['Virtual_Guest']
|
||||
|
||||
begin
|
||||
vgid = vg_srvc.createObject(opts)['id']
|
||||
vg = vg_srvc.object_with_id(vgid)
|
||||
rescue => e
|
||||
STDERR.puts(e.message)
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
begin
|
||||
vg.setTags("#{id}")
|
||||
rescue => e
|
||||
STDERR.puts(e.message)
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
puts(vgid)
|
||||
end
|
||||
|
||||
# Shutdown a SoftLayer instance
|
||||
def shutdown(deploy_id)
|
||||
sl_action(deploy_id, :terminate)
|
||||
end
|
||||
|
||||
# Reboot a SoftLayer instance
|
||||
def reboot(deploy_id)
|
||||
sl_action(deploy_id, :reboot)
|
||||
end
|
||||
|
||||
# Cancel a SoftLayer instance
|
||||
def cancel(deploy_id)
|
||||
sl_action(deploy_id, :terminate)
|
||||
end
|
||||
|
||||
# Stop a SoftLayer instance
|
||||
def save(deploy_id)
|
||||
sl_action(deploy_id, :stop)
|
||||
end
|
||||
|
||||
# Start a SoftLayer instance
|
||||
def restore(deploy_id)0
|
||||
sl_action(deploy_id, :start)
|
||||
end
|
||||
|
||||
# Get info (IP, and state) for a SoftLayer instance
|
||||
def poll(id, deploy_id)
|
||||
i = get_instance(deploy_id)
|
||||
puts parse_poll(i)
|
||||
end
|
||||
|
||||
# Get the info of all the SoftLayer instances. A SoftLayer instance must include
|
||||
# the OpenNebula VID as the first tag, otherwise it will be ignored
|
||||
def monitor_all_vms
|
||||
totalmemory = 0
|
||||
totalcpu = 0
|
||||
|
||||
@region['capacity'].each { |name, size|
|
||||
cpu, mem = instance_type_capacity(name)
|
||||
|
||||
totalmemory += mem * size.to_i
|
||||
totalcpu += cpu * size.to_i
|
||||
}
|
||||
|
||||
host_info = "HYPERVISOR=SOFTLAYER\n"
|
||||
host_info << "PUBLIC_CLOUD=YES\n"
|
||||
host_info << "PRIORITY=-1\n"
|
||||
host_info << "TOTALMEMORY=#{totalmemory.round}\n"
|
||||
host_info << "TOTALCPU=#{totalcpu}\n"
|
||||
host_info << "CPUSPEED=1000\n"
|
||||
host_info << "HOSTNAME=\"#{@host}\"\n"
|
||||
|
||||
vms = @sl_client['Account'].getVirtualGuests
|
||||
|
||||
vms_info = "VM_POLL=YES\n"
|
||||
|
||||
usedcpu = 0
|
||||
usedmemory = 0
|
||||
|
||||
begin
|
||||
vms.each do |i|
|
||||
vm = @sl_client['Virtual_Guest'].object_with_id(i['id'].to_i)
|
||||
poll_data = parse_poll(vm)
|
||||
# Retrieve Virtual Guest to consult tags
|
||||
|
||||
tags = vm.getTagReferences
|
||||
# We know that the first one is the ONE identifier
|
||||
one_id=nil
|
||||
begin
|
||||
one_id=tags[0]["tag"]["name"]
|
||||
rescue
|
||||
end
|
||||
next if one_id=="one_id"
|
||||
vms_info << "VM=[\n"
|
||||
vms_info << " ID=#{one_id || -1},\n"
|
||||
vms_info << " DEPLOY_ID=#{i['id']},\n"
|
||||
vms_info << " POLL=\"#{poll_data[0...-1]}\" ]\n"
|
||||
|
||||
if one_id
|
||||
usedcpu += i['maxCpu'].to_i * 100
|
||||
usedmemory += i['maxMemory'].to_i * 1024
|
||||
end
|
||||
end
|
||||
rescue => e
|
||||
STDERR.puts(e.message)
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
host_info << "USEDMEMORY=#{usedmemory.round}\n"
|
||||
host_info << "USEDCPU=#{usedcpu.round}\n"
|
||||
host_info << "FREEMEMORY=#{(totalmemory - usedmemory).round}\n"
|
||||
host_info << "FREECPU=#{(totalcpu - usedcpu).round}\n"
|
||||
|
||||
puts host_info
|
||||
puts vms_info
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
#Get the associated capacity of the instance_type as cpu (in 100 percent
|
||||
#e.g. 800) and memory (in KB)
|
||||
def instance_type_capacity(name)
|
||||
if @instance_types[name].nil?
|
||||
STDERR.puts("Instance type #{name} not recognized")
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
return @instance_types[name]['cpu'].to_i * 100 ,
|
||||
@instance_types[name]['memory'].to_i * 1024 * 1024
|
||||
end
|
||||
|
||||
# Get the SoftLayer section of the template. If more than one SoftLayer
|
||||
# section, the DATACENTER element is used and matched with the host
|
||||
def get_deployment_info(host, xml_text)
|
||||
xml = REXML::Document.new xml_text
|
||||
|
||||
sl = nil
|
||||
all_sl_elements = xml.root.get_elements("//USER_TEMPLATE/PUBLIC_CLOUD")
|
||||
|
||||
# First, let's see if we have an SoftLayer site that matches
|
||||
# our desired host name
|
||||
all_sl_elements.each { |element|
|
||||
cloud_host = element.elements["DATACENTER"]
|
||||
type = element.elements["TYPE"].text
|
||||
|
||||
next if !type.downcase.eql? "softlayer"
|
||||
|
||||
if cloud_host and cloud_host.text.upcase.eql? host.upcase
|
||||
sl = element
|
||||
end
|
||||
}
|
||||
|
||||
if !sl
|
||||
# If we don't find the SoftLayer site, and ONE just
|
||||
# knows about one SoftLayer site, let's use that
|
||||
if all_sl_elements.size == 1 and
|
||||
all_sl_elements[0].elements["TYPE"].text.upcase.eql? "SOFTLAYER"
|
||||
sl = all_sl_elements[0]
|
||||
else
|
||||
STDERR.puts(
|
||||
"Cannot find SoftLayer element in VM template "<<
|
||||
"or couldn't find any SoftLayer site matching "<<
|
||||
"one of the templates.")
|
||||
exit(-1)
|
||||
end
|
||||
end
|
||||
|
||||
# If DATACENTER not explicitly defined, try to get default, if not
|
||||
# try to use hostname as datacenter
|
||||
if !sl.elements["DATACENTER"]
|
||||
dc=REXML::Element.new("DATACENTER")
|
||||
if @defaults["DATACENTER"]
|
||||
dc.text=@defaults["DATACENTER"]
|
||||
else
|
||||
dc.text=host
|
||||
end
|
||||
sl.elements << dc
|
||||
end
|
||||
|
||||
sl
|
||||
end
|
||||
|
||||
# Retrieve the VM information from the SoftLayer instance
|
||||
def parse_poll(vm)
|
||||
info = "#{POLL_ATTRIBUTE[:usedmemory]}=0 " \
|
||||
"#{POLL_ATTRIBUTE[:usedcpu]}=0 " \
|
||||
"#{POLL_ATTRIBUTE[:nettx]}=0 " \
|
||||
"#{POLL_ATTRIBUTE[:netrx]}=0 "
|
||||
|
||||
state = ""
|
||||
|
||||
instance = vm.getObject
|
||||
sl_state = vm.getPowerState["name"]
|
||||
|
||||
password_mask = "mask[operatingSystem[passwords]]"
|
||||
pass_info = vm.object_mask(password_mask).getObject
|
||||
|
||||
begin
|
||||
user = pass_info["operatingSystem"]["passwords"][0]["username"]
|
||||
pwd = pass_info["operatingSystem"]["passwords"][0]["password"]
|
||||
rescue
|
||||
end
|
||||
|
||||
if !instance
|
||||
state = VM_STATE[:deleted]
|
||||
else
|
||||
state = case sl_state.upcase
|
||||
when "RUNNING"
|
||||
VM_STATE[:active]
|
||||
when "PAUSED"
|
||||
VM_STATE[:paused]
|
||||
else
|
||||
VM_STATE[:deleted]
|
||||
end
|
||||
end
|
||||
info << "#{POLL_ATTRIBUTE[:state]}=#{state} "
|
||||
|
||||
SL_POLL_ATTRS.map { |key|
|
||||
value = instance["#{key}"].to_s
|
||||
|
||||
if !value.nil? && !value.empty?
|
||||
if value.is_a?(Array)
|
||||
value = value.map {|v|}.join(",")
|
||||
end
|
||||
info << "SL_#{key.to_s.upcase}=#{value} "
|
||||
end
|
||||
}
|
||||
|
||||
info << "SL_CRED_USER=#{user} SL_CRED_PASSWORD=#{pwd}" if user and pwd
|
||||
|
||||
info
|
||||
end
|
||||
|
||||
# Execute a SoftLayer command
|
||||
# +deploy_id+: String, VM id in SoftLayer
|
||||
# +sl_action+: Symbol, one of the keys of the SL hash constant (i.e :run)
|
||||
def sl_action(deploy_id, sl_action)
|
||||
i = get_instance(deploy_id)
|
||||
|
||||
begin
|
||||
i.send(SL[sl_action][:cmd])
|
||||
rescue => e
|
||||
STDERR.puts e.message
|
||||
exit(-1)
|
||||
end
|
||||
end
|
||||
|
||||
# Generate the options for the given command from the xml provided in the
|
||||
# template. The available options for each command are defined in the 'SL'
|
||||
# constant
|
||||
def generate_options(action, xml, extra_params={})
|
||||
opts = extra_params || {}
|
||||
|
||||
if SL[action][:args]
|
||||
SL[action][:args].each {|k,v|
|
||||
str = sl_value(xml, k, &v[:proc])
|
||||
|
||||
if str
|
||||
if v[:opt].include? "."
|
||||
opts=create_opts_hash(opts,v[:opt],str)
|
||||
else
|
||||
opts[v[:opt].to_sym] = str
|
||||
end
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
opts
|
||||
end
|
||||
|
||||
def create_opts_hash(opts,key_schema,value)
|
||||
split_keys = key_schema.split(".")
|
||||
new_hash = {}
|
||||
current_hash = new_hash
|
||||
last_hash = {}
|
||||
|
||||
split_keys.size.times{ |i|
|
||||
index = i + 1 # We skip the first key
|
||||
|
||||
if index == split_keys.size # Last iteration
|
||||
last_hash[split_keys[index-1].to_sym] = value
|
||||
break
|
||||
else
|
||||
current_hash[split_keys[index].to_sym]={}
|
||||
last_hash =current_hash
|
||||
current_hash=current_hash[split_keys[index].to_sym]
|
||||
end
|
||||
}
|
||||
opts[split_keys[0].to_sym] = new_hash
|
||||
|
||||
opts
|
||||
end
|
||||
|
||||
# Returns the value of the xml specified by the name or the default
|
||||
# one if it does not exist
|
||||
# +xml+: REXML Document, containing SoftLayer information
|
||||
# +name+: String, xpath expression to retrieve the value
|
||||
# +block+: Block, block to be applied to the value before returning it
|
||||
def sl_value(xml, name, &block)
|
||||
value = value_from_xml(xml, name) || @defaults[name]
|
||||
if block_given? && value
|
||||
block.call(value)
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
|
||||
def value_from_xml(xml, name)
|
||||
if xml
|
||||
element = xml.elements[name]
|
||||
element.text.strip if element && element.text
|
||||
end
|
||||
end
|
||||
|
||||
# Load the default values that will be used to create a new instance, if
|
||||
# not provided in the template. These values are defined in the
|
||||
# SL_DRIVER_DEFAULT file
|
||||
def load_default_template_values
|
||||
@defaults = Hash.new
|
||||
|
||||
if File.exists?(SL_DRIVER_DEFAULT)
|
||||
fd = File.new(SL_DRIVER_DEFAULT)
|
||||
xml = REXML::Document.new fd
|
||||
fd.close()
|
||||
|
||||
return if !xml || !xml.root
|
||||
|
||||
sl = xml.root.elements["SOFTLAYER"]
|
||||
|
||||
return if !sl
|
||||
|
||||
SL.each {|action, hash|
|
||||
if hash[:args]
|
||||
hash[:args].each { |key, value|
|
||||
@defaults[key] = value_from_xml(sl, key)
|
||||
}
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
# Retrieve the instance from SoftLayer
|
||||
def get_instance(id)
|
||||
begin
|
||||
vg_srvc = @sl_client['Virtual_Guest']
|
||||
instance = vg_srvc.object_with_id(id)
|
||||
if instance
|
||||
return instance
|
||||
else
|
||||
raise "Instance #{id} does not exist"
|
||||
end
|
||||
rescue => e
|
||||
STDERR.puts e.message
|
||||
exit(-1)
|
||||
end
|
||||
end
|
||||
end
|
20
src/vmm_mad/remotes/sl/snapshot_create
Executable file
20
src/vmm_mad/remotes/sl/snapshot_create
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
echo "Action $SCRIPT_NAME not supported" 1>&2
|
20
src/vmm_mad/remotes/sl/snapshot_delete
Executable file
20
src/vmm_mad/remotes/sl/snapshot_delete
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
echo "Action $SCRIPT_NAME not supported" 1>&2
|
20
src/vmm_mad/remotes/sl/snapshot_revert
Executable file
20
src/vmm_mad/remotes/sl/snapshot_revert
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
SCRIPT_NAME=$(basename $0)
|
||||
echo "Action $SCRIPT_NAME not supported" 1>&2
|
@ -429,11 +429,22 @@ class VMwareDriver
|
||||
# Append the raw datavmx to vmx file
|
||||
metadata = REXML::XPath.first(dfile_hash, "/domain/metadata/datavmx")
|
||||
|
||||
return if metadata.nil?
|
||||
return if metadata.text.nil?
|
||||
return if metadata.text.strip.empty?
|
||||
if metadata.nil? || metadata.text.nil? || metadata.text.strip.empty?
|
||||
metadata = ''
|
||||
else
|
||||
metadata = metadata.text
|
||||
end
|
||||
|
||||
metadata = metadata.text
|
||||
if !@reserve_memory
|
||||
mem_txt = REXML::XPath.first(dfile_hash, "/domain/memory").text
|
||||
mem = mem_txt.to_i/1024
|
||||
|
||||
metadata << "\\nsched.mem.min = \"#{mem}\""
|
||||
metadata << "\\nsched.mem.shares = \"normal\""
|
||||
metadata << "\\nsched.mem.pin = \"TRUE\""
|
||||
end
|
||||
|
||||
return if metadata.strip.empty?
|
||||
|
||||
# Get the ds_id for system_ds from the first disk
|
||||
disk = REXML::XPath.first(dfile_hash, "/domain//disk/source")
|
||||
@ -447,15 +458,6 @@ class VMwareDriver
|
||||
path_to_vmx = "\$(find /vmfs/volumes/#{ds_id}/#{vm_id}/"
|
||||
path_to_vmx << " -name #{name}.vmx)"
|
||||
|
||||
if !@reserve_memory
|
||||
mem_txt = REXML::XPath.first(dfile_hash, "/domain/memory").text
|
||||
mem = mem_txt.to_i/1024
|
||||
|
||||
metadata << "\\nsched.mem.min = \"#{mem}\""
|
||||
metadata << "\\nsched.mem.shares = \"normal\""
|
||||
metadata << "\\nsched.mem.pin = \"TRUE\""
|
||||
end
|
||||
|
||||
metadata.gsub!("\\n","\n")
|
||||
|
||||
sed_str = metadata.scan(/^([^ ]+) *=/).join("|")
|
||||
|
@ -29,6 +29,15 @@ CONF = {
|
||||
:start_vlan => 2
|
||||
}
|
||||
|
||||
def get_xen_command
|
||||
if system("ps axuww | grep -v grep | grep '\\bxen\\b'")
|
||||
"sudo xm"
|
||||
else
|
||||
"sudo xl"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
COMMANDS = {
|
||||
:ebtables => "sudo ebtables",
|
||||
:iptables => "sudo iptables",
|
||||
@ -36,12 +45,14 @@ COMMANDS = {
|
||||
:ip => "sudo ip",
|
||||
:vconfig => "sudo vconfig",
|
||||
:virsh => "virsh -c qemu:///system",
|
||||
:xm => "sudo xm",
|
||||
:xm => get_xen_command,
|
||||
:ovs_vsctl=> "sudo ovs-vsctl",
|
||||
:ovs_ofctl=> "sudo ovs-ofctl",
|
||||
:lsmod => "lsmod"
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Set PATH
|
||||
ENV['PATH'] = "#{ENV['PATH']}:/bin:/sbin:/usr/bin"
|
||||
|
||||
|
Reference in New Issue
Block a user