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

Remove SoftLayer Hybrid Drivers

They are now available as an addon:
https://github.com/OpenNebula/addon-softlayer
This commit is contained in:
Jaime Melis 2016-04-14 15:36:21 +02:00
parent f51caa194e
commit 08e345b380
29 changed files with 6 additions and 1441 deletions

View File

@ -244,14 +244,12 @@ VAR_DIRS="$VAR_LOCATION/remotes \
$VAR_LOCATION/remotes/im/kvm-probes.d \
$VAR_LOCATION/remotes/im/vcenter.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/lib \
$VAR_LOCATION/remotes/vmm/kvm \
$VAR_LOCATION/remotes/vmm/vcenter \
$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 \
@ -375,7 +373,6 @@ INSTALL_FILES=(
IM_PROBES_KVM_PROBES_FILES:$VAR_LOCATION/remotes/im/kvm-probes.d
IM_PROBES_VCENTER_FILES:$VAR_LOCATION/remotes/im/vcenter.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
@ -389,7 +386,6 @@ INSTALL_FILES=(
VMM_EXEC_KVM_SCRIPTS:$VAR_LOCATION/remotes/vmm/kvm
VMM_EXEC_VCENTER_SCRIPTS:$VAR_LOCATION/remotes/vmm/vcenter
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
@ -527,7 +523,6 @@ INSTALL_ONEFLOW_ETC_FILES=(
INSTALL_ETC_FILES=(
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
@ -593,8 +588,7 @@ RUBY_LIB_FILES="src/mad/ruby/ActionManager.rb \
src/sunstone/OpenNebulaVNC.rb \
src/vmm_mad/remotes/vcenter/vcenter_driver.rb \
src/vmm_mad/remotes/az/az_driver.rb \
src/vmm_mad/remotes/ec2/ec2_driver.rb \
src/vmm_mad/remotes/sl/sl_driver.rb"
src/vmm_mad/remotes/ec2/ec2_driver.rb"
#-------------------------------------------------------------------------------
# Ruby auth library files, to be installed under $LIB_LOCATION/ruby/opennebula
@ -723,29 +717,6 @@ VMM_EXEC_EC2_SCRIPTS="src/vmm_mad/remotes/ec2/cancel \
src/vmm_mad/remotes/ec2/reconfigure \
src/vmm_mad/remotes/ec2/prereconfigure"
#------------------------------------------------------------------------------
# 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/reconfigure \
src/vmm_mad/remotes/sl/prereconfigure"
#------------------------------------------------------------------------------
# VMM Driver Azure scripts, to be installed under $REMOTES_LOCATION/vmm/az
#------------------------------------------------------------------------------
@ -793,7 +764,6 @@ IM_PROBES_VCENTER_FILES="src/im_mad/remotes/vcenter.d/vcenter.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"
@ -1231,19 +1201,14 @@ ETC_FILES="share/etc/oned.conf \
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
#-------------------------------------------------------------------------------
VMM_EXEC_ETC_FILES="src/vmm_mad/exec/vmm_execrc \
src/vmm_mad/exec/vmm_exec_kvm.conf \
src/vmm_mad/exec/vmm_exec_vcenter.conf"

View File

@ -334,17 +334,6 @@ 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
@ -477,23 +466,6 @@ VM_MAD = [
#]
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# 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",
# IMPORTED_VMS_ACTIONS = "shutdown, shutdown-hard, hold, release, suspend,
# resume, delete, reboot, reboot-hard, resched, unresched, poweroff,
# poweroff-hard, disk-attach, disk-detach, nic-attach, nic-detach,
# snap-create, snap-delete"
#]
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# Azure Virtualization Driver Manager Configuration
# -r number of retries when monitoring a host

View File

@ -29,7 +29,7 @@ GROUPS={
:sunstone => ['json', 'rack', 'sinatra', 'thin', 'memcache-client',
ZENDESK_API, SQLITE],
:cloud => %w{amazon-ec2 rack sinatra thin uuidtools curb json},
:hybrid => %w{softlayer_api configparser azure},
:hybrid => %w{configparser azure},
:auth_ldap => LDAP,
:vmware => %w{builder trollop},
:oneflow => ['sinatra', 'json', TREETOP, 'parse-cron'],

View File

@ -1,34 +0,0 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2015, OpenNebula Project, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# -------------------------------------------------------------------------- #
ONE_LOCATION=ENV["ONE_LOCATION"] if !defined?(ONE_LOCATION)
if !ONE_LOCATION
RUBY_LIB_LOCATION="/usr/lib/one/ruby" if !defined?(RUBY_LIB_LOCATION)
else
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" if !defined?(RUBY_LIB_LOCATION)
end
$: << RUBY_LIB_LOCATION
require 'sl_driver'
host = ARGV[-1]
sl_drv = SLDriver.new(host)
sl_drv.monitor_all_vms

View File

@ -46,6 +46,7 @@ module Migrator
def up
init_log_time()
=begin
# Feature #3671
@db.run "ALTER TABLE user_pool RENAME TO old_user_pool;"
@ -196,7 +197,7 @@ module Migrator
@db.run "REPLACE INTO pool_control VALUES('acl', #{last_oid+1});"
log_time()
=end
return true
end

View File

@ -602,7 +602,7 @@ define(function(require) {
function isNICGraphsSupported(element) {
var history = retrieveLastHistoryRecord(element)
if (history) {
return $.inArray(history.VM_MAD, ['vcenter', 'az', 'sl']) == -1;
return $.inArray(history.VM_MAD, ['vcenter', 'az']) == -1;
} else {
return false;
}
@ -611,7 +611,7 @@ define(function(require) {
function isNICAttachSupported(element) {
var history = retrieveLastHistoryRecord(element)
if (history) {
return $.inArray(history.VM_MAD, ['ec2', 'az', 'sl']) == -1;
return $.inArray(history.VM_MAD, ['ec2', 'az']) == -1;
} else {
return false;
}

View File

@ -141,109 +141,6 @@ define(function(require) {
tooltip: Locale.tr("Specifies Base64-encoded MIME user data to be made available to the instance(s) in this reservation.")
}
],
softlayer: [
{
name: "BLOCKDEVICETEMPLATE",
label: Locale.tr("Block Device Template"),
tooltip: Locale.tr("A global identifier for the template to be used to provision the computing instance")
},
{
name: "BLOCKDEVICE",
label: Locale.tr("Block Device Size"),
tooltip: Locale.tr("Size of the block device size to be presented to the VM")
},
{
name: "DATACENTER",
label: Locale.tr("Datacenter"),
tooltip: Locale.tr("Specifies which datacenter the instance is to be provisioned in")
},
{
name: "DEDICATEDHOST",
label: Locale.tr("Dedicated Host"),
tooltip: Locale.tr("Specifies whether or not the instance must only run on hosts with instances from the same account")
},
{
name: "DOMAIN",
label: Locale.tr("Domain"),
tooltip: Locale.tr("Domain for the computing instance"),
required: true
},
{
name: "HOSTNAME",
label: Locale.tr("Hostname"),
tooltip: Locale.tr("Hostname for the computing instance"),
required: true
},
{
name: "HOURLYBILLING",
label: Locale.tr("Hourly Billing"),
tooltip: Locale.tr("Specifies the billing type for the instance . When true the computing instance will be billed on hourly usage, otherwise it will be billed on a monthly basis"),
required: true
},
{
name: "INSTANCE_TYPE",
label: Locale.tr("Instance Type"),
tooltip: Locale.tr("Specifies the capacity of the VM in terms of CPU and memory. If both STARTCPUS and MAXMEMORY are used, then this parameter is disregarded"),
required: true
},
{
name: "LOCALDISK",
label: Locale.tr("Local Disk"),
tooltip: Locale.tr("Name of the placement group. When true the disks for the computing instance will be provisioned on the host which it runs, otherwise SAN disks will be provisioned"),
required: true
},
{
name: "MAXMEMORY",
label: Locale.tr("Max Memory"),
tooltip: Locale.tr("The amount of memory to allocate in megabytes")
},
{
name: "NETWORKCOMPONENTSMAXSPEED",
label: Locale.tr("Network Components Max Speed"),
tooltip: Locale.tr("Specifies the connection speed for the instance's network components")
},
{
name: "OPERATINGSYSTEM",
label: Locale.tr("Operating System"),
tooltip: Locale.tr("An identifier for the operating system to provision the computing instance with. A non exhaustive list of identifiers can be found here"),
required: true
},
{
name: "POSTSCRIPT",
label: Locale.tr("Postscript"),
tooltip: Locale.tr("Specifies the uri location of the script to be downloaded and run after installation is complete")
},
{
name: "PRIVATENETWORKONLY",
label: Locale.tr("Private Netwrok Only"),
tooltip: Locale.tr("Specifies whether or not the instance only has access to the private network (ie, if it is going to have a public IP interface or not)")
},
{
name: "PRIMARYNETWORKVLAN",
label: Locale.tr("Primary Network VLAN"),
tooltip: Locale.tr("Specifies the network vlan which is to be used for the frontend interface of the computing instance")
},
{
name: "PRIMARYBACKENDNETWORKVLAN",
label: Locale.tr("Primary Backed Network VLAN"),
tooltip: Locale.tr("Specifies the network vlan which is to be used for the backend interface of the computing instance")
},
{
name: "SSHKEYS",
label: Locale.tr("SSH Keys"),
tooltip: Locale.tr("SSH keys to install on the computing instance upon provisioning")
},
{
name: "STARTCPUS",
label: Locale.tr("Start CPUs"),
tooltip: Locale.tr("The number of CPU cores to allocate to the VM")
},
{
name: "USERDATA",
label: Locale.tr("User Data"),
tooltip: Locale.tr("Arbitrary data to be made available to the computing instance")
}
],
azure: [
{
name: "AFFINITY_GROUP",
@ -386,10 +283,6 @@ define(function(require) {
case 'ec2':
ec2JSON.push(hash);
break;
case 'softlayer':
hash["TYPE"] = hybrid.toUpperCase();
publicCloudJSON.push(hash);
break;
case 'azure':
hash["TYPE"] = hybrid.toUpperCase();
publicCloudJSON.push(hash);
@ -448,7 +341,6 @@ define(function(require) {
'<div class="large-12 columns">' +
'<label>' + Locale.tr("Hybrid Cloud") + '</label>' +
'<input type="radio" class="hybridRadio" name="hybrid' + htmlId + '" value="ec2" id="amazonRadio' + htmlId + '"><label for="amazonRadio' + htmlId + '">Amazon EC2</label>' +
'<input type="radio" class="hybridRadio" name="hybrid' + htmlId + '" value="softlayer" id="softlayerRadio' + htmlId + '"><label for="softlayerRadio' + htmlId + '">IBM Softlayer</label>' +
'<input type="radio" class="hybridRadio" name="hybrid' + htmlId + '" value="azure" id="azureRadio' + htmlId + '"><label for="azureRadio' + htmlId + '">Microsoft Azure</label>' +
'</div>' +
'</div>' +

View File

@ -1,20 +0,0 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2015, OpenNebula Project, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
SCRIPT_NAME=$(basename $0)
echo "Action $SCRIPT_NAME not supported" 1>&2

View File

@ -1,20 +0,0 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2015, OpenNebula Project, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
SCRIPT_NAME=$(basename $0)
echo "Action $SCRIPT_NAME not supported" 1>&2

View File

@ -1,37 +0,0 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2015, OpenNebula Project, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# -------------------------------------------------------------------------- #
ONE_LOCATION=ENV["ONE_LOCATION"] if !defined?(ONE_LOCATION)
if !ONE_LOCATION
RUBY_LIB_LOCATION="/usr/lib/one/ruby" if !defined?(RUBY_LIB_LOCATION)
else
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" if !defined?(RUBY_LIB_LOCATION)
end
$: << RUBY_LIB_LOCATION
$: << File.dirname(__FILE__)
require 'sl_driver'
deploy_id = ARGV[0]
host = ARGV[1]
sl_drv = SLDriver.new(host)
sl_drv.cancel(deploy_id)

View File

@ -1,53 +0,0 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2015, OpenNebula Project, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# -------------------------------------------------------------------------- #
ONE_LOCATION=ENV["ONE_LOCATION"] if !defined?(ONE_LOCATION)
if !ONE_LOCATION
RUBY_LIB_LOCATION="/usr/lib/one/ruby" if !defined?(RUBY_LIB_LOCATION)
else
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" if !defined?(RUBY_LIB_LOCATION)
end
$: << RUBY_LIB_LOCATION
$: << File.dirname(__FILE__)
require 'sl_driver'
require 'opennebula'
dfile = ARGV[0]
host = ARGV[1]
id = ARGV[2]
vm = OpenNebula::VirtualMachine.new_with_id(id, OpenNebula::Client.new)
vm.info
lcm_state = vm.lcm_state_str
deploy_id = vm.deploy_id
sl_drv = SLDriver.new(host)
text=File.read(dfile)
begin
puts sl_drv.deploy(id, host, text, lcm_state, deploy_id)
rescue Exception => e
STDERR.puts "Deploy of VM #{id} on host #{host} with #{dfile} failed " +
"due to \"#{e.message}\""
exit -1
end

View File

@ -1,20 +0,0 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2015, OpenNebula Project, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
SCRIPT_NAME=$(basename $0)
echo "Action $SCRIPT_NAME not supported" 1>&2

View File

@ -1,20 +0,0 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2015, OpenNebula Project, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
SCRIPT_NAME=$(basename $0)
echo "Action $SCRIPT_NAME not supported" 1>&2

View File

@ -1,20 +0,0 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2015, OpenNebula Project, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
SCRIPT_NAME=$(basename $0)
echo "Action $SCRIPT_NAME not supported" 1>&2

View File

@ -1,20 +0,0 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2015, OpenNebula Project, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
SCRIPT_NAME=$(basename $0)
echo "Action $SCRIPT_NAME not supported" 1>&2

View File

@ -1,38 +0,0 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2015, OpenNebula Project, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# -------------------------------------------------------------------------- #
ONE_LOCATION=ENV["ONE_LOCATION"] if !defined?(ONE_LOCATION)
if !ONE_LOCATION
RUBY_LIB_LOCATION="/usr/lib/one/ruby" if !defined?(RUBY_LIB_LOCATION)
else
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" if !defined?(RUBY_LIB_LOCATION)
end
$: << RUBY_LIB_LOCATION
$: << 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)

View File

@ -1 +0,0 @@
../common/dummy.sh

View File

@ -1,37 +0,0 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2015, OpenNebula Project, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# -------------------------------------------------------------------------- #
ONE_LOCATION=ENV["ONE_LOCATION"] if !defined?(ONE_LOCATION)
if !ONE_LOCATION
RUBY_LIB_LOCATION="/usr/lib/one/ruby" if !defined?(RUBY_LIB_LOCATION)
else
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" if !defined?(RUBY_LIB_LOCATION)
end
$: << RUBY_LIB_LOCATION
$: << File.dirname(__FILE__)
require 'sl_driver'
deploy_id = ARGV[0]
host = ARGV[1]
sl_drv = SLDriver.new(host)
sl_drv.reboot(deploy_id)

View File

@ -1 +0,0 @@
../common/dummy.sh

View File

@ -1,20 +0,0 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2015, OpenNebula Project, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
SCRIPT_NAME=$(basename $0)
echo "Action $SCRIPT_NAME not supported" 1>&2

View File

@ -1,36 +0,0 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2015, OpenNebula Project, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# -------------------------------------------------------------------------- #
ONE_LOCATION=ENV["ONE_LOCATION"] if !defined?(ONE_LOCATION)
if !ONE_LOCATION
RUBY_LIB_LOCATION="/usr/lib/one/ruby" if !defined?(RUBY_LIB_LOCATION)
else
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" if !defined?(RUBY_LIB_LOCATION)
end
$: << RUBY_LIB_LOCATION
$: << File.dirname(__FILE__)
require 'sl_driver'
host = ARGV[-1]
deploy_id = ARGV[2]
sl_drv = SLDriver.new(host)
sl_drv.restore(deploy_id)

View File

@ -1,36 +0,0 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2015, OpenNebula Project, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# -------------------------------------------------------------------------- #
ONE_LOCATION=ENV["ONE_LOCATION"] if !defined?(ONE_LOCATION)
if !ONE_LOCATION
RUBY_LIB_LOCATION="/usr/lib/one/ruby" if !defined?(RUBY_LIB_LOCATION)
else
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" if !defined?(RUBY_LIB_LOCATION)
end
$: << RUBY_LIB_LOCATION
$: << File.dirname(__FILE__)
require 'sl_driver'
deploy_id = ARGV[0]
host = ARGV[1]
sl_drv = SLDriver.new(host)
sl_drv.save(deploy_id)

View File

@ -1,44 +0,0 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2015, OpenNebula Project, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
# -------------------------------------------------------------------------- #
ONE_LOCATION=ENV["ONE_LOCATION"] if !defined?(ONE_LOCATION)
if !ONE_LOCATION
RUBY_LIB_LOCATION="/usr/lib/one/ruby" if !defined?(RUBY_LIB_LOCATION)
else
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" if !defined?(RUBY_LIB_LOCATION)
end
$: << RUBY_LIB_LOCATION
$: << File.dirname(__FILE__)
require 'sl_driver'
require 'opennebula'
deploy_id = ARGV[0]
host = ARGV[1]
vm_id = ARGV[-2]
vm = OpenNebula::VirtualMachine.new_with_id(vm_id, OpenNebula::Client.new)
vm.info
lcm_state = vm.lcm_state_str
sl_drv = SLDriver.new(host)
sl_drv.shutdown(deploy_id, lcm_state)

View File

@ -1,110 +0,0 @@
# Regions extracted from http://www.softlayer.com/data-centers
timeout: 120
regions:
default:
region_name: sjc01
username:
api_key:
capacity:
slcci.small: 5
slcci.medium: 0
slcci.large: 0
ams01:
region_name: ams01
username:
api_key:
capacity:
slcci.small: 5
slcci.medium: 0
slcci.large: 0
sjc01:
region_name: sjc01
username:
api_key:
capacity:
slcci.small:
slcci.medium:
slcci.large:
dal01:
region_name: dal01
username:
api_key:
capacity:
slcci.small:
slcci.medium:
slcci.large:
dal02:
region_name: dal02
username:
api_key:
capacity:
slcci.small:
slcci.medium:
slcci.large:
dal05:
region_name: dal05
username:
api_key:
capacity:
slcci.small:
slcci.medium:
slcci.large:
dal06:
region_name: dal06
username:
api_key:
capacity:
slcci.small:
slcci.medium:
slcci.large:
dal07:
region_name: dal07
username:
api_key:
capacity:
slcci.small:
slcci.medium:
slcci.large:
hou02:
region_name: hou02
username:
api_key:
capacity:
slcci.small:
slcci.medium:
slcci.large:
sea01:
region_name: sea01
username:
api_key:
capacity:
slcci.small:
slcci.medium:
slcci.large:
sng01:
region_name: sng01
username:
api_key:
capacity:
slcci.small:
slcci.medium:
slcci.large:
wdc01:
region_name: wdc01
username:
api_key:
capacity:
slcci.small:
slcci.medium:
slcci.large:
instance_types:
slcci.small:
cpu: 1
memory: 1
slcci.medium:
cpu: 2
memory: 4
slcci.large:
cpu: 4
memory: 8

View File

@ -1,37 +0,0 @@
# -------------------------------------------------------------------------- #
# Copyright 2002-2015, OpenNebula Project, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
<!--
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>opennebula.systems</DOMAIN>
<INSTANCE_TYPE>slcci.small</INSTANCE_TYPE>
<HOURLYBILLINGFLAG>true</HOURLYBILLINGFLAG>
<LOCALDISKFLAG>true</LOCALDISKFLAG>
<DATACENTER>ams01</DATACENTER>
</SOFTLAYER>
</TEMPLATE>

View File

@ -1,601 +0,0 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2015, OpenNebula Project, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
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']
client_cred[:timeout] = public_cloud_sl_conf['timeout'] || 120
@sl_client = SoftLayer::Client.new(client_cred)
end
# DEPLOY action
def deploy(id, host, xml_text, lcm_state, deploy_id)
if lcm_state == "BOOT" || lcm_state == "BOOT_FAILURE"
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]
instance_type = value_from_xml(sl_info,"INSTANCE_TYPE")
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)
else
restore(deploy_id)
deploy_id
end
end
# Shutdown a SoftLayer instance
def shutdown(deploy_id, lcm_state)
case lcm_state
when "SHUTDOWN"
sl_action(deploy_id, :terminate)
when "SHUTDOWN_POWEROFF", "SHUTDOWN_UNDEPLOY"
sl_action(deploy_id, :stop)
end
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)
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"
vm_template_to_one = vm_to_one(i, @host)
vm_template_to_one = Base64.encode64(vm_template_to_one)
vm_template_to_one = vm_template_to_one.gsub("\n","")
vms_info << "VM=[\n"
vms_info << " ID=#{one_id || -1},\n"
vms_info << " VM_NAME=#{i['fullyQualifiedDomainName']},\n"
vms_info << " IMPORT_TEMPLATE=\"#{vm_template_to_one}\",\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")
all_sl_elements = all_sl_elements.select { |element|
element.elements["TYPE"].text.downcase.eql? "softlayer"
}
# 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
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
sl = all_sl_elements[0]
else
STDERR.puts(
"Cannot find SoftLayer element in VM template "<<
"or ambigous definition of SofLayer templates "<<
"(for instance, two SoftLayer sections without " <<
"a DATACENTER defined)")
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)
begin
info = "#{POLL_ATTRIBUTE[:memory]}=0 " \
"#{POLL_ATTRIBUTE[:cpu]}=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[:unknown]
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
rescue
# Unkown state if exception occurs retrieving information from
# an instance
"#{POLL_ATTRIBUTE[:state]}=#{VM_STATE[:unknown]} "
end
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
# Build template for importation
def vm_to_one(i, host)
cpu = i['maxCpu'].to_i * 100
mem = i['maxMemory'].to_i * 1024
mem = mem.to_i / 1024 # Memory for templates expressed in MB
cpu = cpu.to_f / 100 # CPU expressed in units
str = "NAME = \"#{i['fullyQualifiedDomainName']}\"\n"\
"CPU = \"#{cpu}\"\n"\
"vCPU = \"#{cpu.ceil}\"\n"\
"MEMORY = \"#{mem}\"\n"\
"HYPERVISOR = \"SOFTLAYER\"\n"\
"PUBLIC_CLOUD = [\n"\
" TYPE =\"SOFTLAYER\"\n"\
"]\n"\
"IMPORT_VM_ID = \"#{i['id']}\"\n"\
"SCHED_REQUIREMENTS=\"NAME=\\\"#{@host}\\\"\"\n"\
"DESCRIPTION = \"Instance imported from SoftLayer, from instance"\
" #{i['id']}\"\n"
str
end
end

View File

@ -1,20 +0,0 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2015, OpenNebula Project, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
SCRIPT_NAME=$(basename $0)
echo "Action $SCRIPT_NAME not supported" 1>&2

View File

@ -1,20 +0,0 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2015, OpenNebula Project, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
SCRIPT_NAME=$(basename $0)
echo "Action $SCRIPT_NAME not supported" 1>&2

View File

@ -1,20 +0,0 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2015, OpenNebula Project, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
SCRIPT_NAME=$(basename $0)
echo "Action $SCRIPT_NAME not supported" 1>&2