From 0b243493dad266981c7f1932ce60962943954311 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Thu, 5 Jun 2014 15:19:54 +0200 Subject: [PATCH 01/18] Initial commit of SoftLayer integration drivers --- install.sh | 32 ++ share/etc/oned.conf | 21 + src/im_mad/remotes/sl.d/poll | 26 ++ src/vmm_mad/remotes/ec2/attach_disk | 0 src/vmm_mad/remotes/sl/attach_disk | 20 + src/vmm_mad/remotes/sl/attach_nic | 20 + src/vmm_mad/remotes/sl/cancel | 28 ++ src/vmm_mad/remotes/sl/deploy | 33 ++ src/vmm_mad/remotes/sl/detach_disk | 20 + src/vmm_mad/remotes/sl/detach_nic | 20 + src/vmm_mad/remotes/sl/migrate | 20 + src/vmm_mad/remotes/sl/migrate_local | 20 + src/vmm_mad/remotes/sl/poll | 29 ++ src/vmm_mad/remotes/sl/reboot | 28 ++ src/vmm_mad/remotes/sl/reset | 20 + src/vmm_mad/remotes/sl/restore | 27 ++ src/vmm_mad/remotes/sl/save | 27 ++ src/vmm_mad/remotes/sl/shutdown | 28 ++ src/vmm_mad/remotes/sl/sl_driver.conf | 109 +++++ src/vmm_mad/remotes/sl/sl_driver.default | 37 ++ src/vmm_mad/remotes/sl/sl_driver.rb | 549 +++++++++++++++++++++++ src/vmm_mad/remotes/sl/snapshot_create | 20 + src/vmm_mad/remotes/sl/snapshot_delete | 20 + src/vmm_mad/remotes/sl/snapshot_revert | 20 + 24 files changed, 1174 insertions(+) create mode 100755 src/im_mad/remotes/sl.d/poll mode change 100644 => 100755 src/vmm_mad/remotes/ec2/attach_disk create mode 100755 src/vmm_mad/remotes/sl/attach_disk create mode 100755 src/vmm_mad/remotes/sl/attach_nic create mode 100755 src/vmm_mad/remotes/sl/cancel create mode 100755 src/vmm_mad/remotes/sl/deploy create mode 100755 src/vmm_mad/remotes/sl/detach_disk create mode 100755 src/vmm_mad/remotes/sl/detach_nic create mode 100755 src/vmm_mad/remotes/sl/migrate create mode 100755 src/vmm_mad/remotes/sl/migrate_local create mode 100755 src/vmm_mad/remotes/sl/poll create mode 100755 src/vmm_mad/remotes/sl/reboot create mode 100755 src/vmm_mad/remotes/sl/reset create mode 100755 src/vmm_mad/remotes/sl/restore create mode 100755 src/vmm_mad/remotes/sl/save create mode 100755 src/vmm_mad/remotes/sl/shutdown create mode 100644 src/vmm_mad/remotes/sl/sl_driver.conf create mode 100644 src/vmm_mad/remotes/sl/sl_driver.default create mode 100644 src/vmm_mad/remotes/sl/sl_driver.rb create mode 100755 src/vmm_mad/remotes/sl/snapshot_create create mode 100755 src/vmm_mad/remotes/sl/snapshot_delete create mode 100755 src/vmm_mad/remotes/sl/snapshot_revert diff --git a/install.sh b/install.sh index d44c1894b9..6caab10bd3 100755 --- a/install.sh +++ b/install.sh @@ -250,12 +250,14 @@ 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/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/vnm \ $VAR_LOCATION/remotes/vnm/802.1Q \ $VAR_LOCATION/remotes/vnm/dummy \ @@ -410,6 +412,7 @@ 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_VERSION:$VAR_LOCATION/remotes AUTH_SSH_FILES:$VAR_LOCATION/remotes/auth/ssh AUTH_X509_FILES:$VAR_LOCATION/remotes/auth/x509 @@ -423,6 +426,7 @@ 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 TM_FILES:$VAR_LOCATION/remotes/tm TM_SHARED_FILES:$VAR_LOCATION/remotes/tm/shared TM_FS_LVM_FILES:$VAR_LOCATION/remotes/tm/fs_lvm @@ -572,6 +576,7 @@ INSTALL_ETC_FILES=( ETC_FILES:$ETC_LOCATION VMWARE_ETC_FILES:$ETC_LOCATION EC2_ETC_FILES:$ETC_LOCATION + SL_ETC_FILES:$ETC_LOCATION VMM_EXEC_ETC_FILES:$ETC_LOCATION/vmm_exec HM_ETC_FILES:$ETC_LOCATION/hm AUTH_ETC_FILES:$ETC_LOCATION/auth @@ -784,6 +789,28 @@ 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" + #------------------------------------------------------------------------------- # Information Manager Probes, to be installed under $REMOTES_LOCATION/im #------------------------------------------------------------------------------- @@ -831,6 +858,8 @@ 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_VERSION="src/im_mad/remotes/VERSION" #------------------------------------------------------------------------------- @@ -1103,6 +1132,9 @@ 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" + #------------------------------------------------------------------------------- # Virtualization drivers config. files, to be installed under $ETC_LOCATION # - ssh, $ETC_LOCATION/vmm_exec diff --git a/share/etc/oned.conf b/share/etc/oned.conf index 880ac93b27..6664065987 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -319,6 +319,15 @@ IM_MAD = [ # arguments = "-c -t 1 -r 0 ec2" ] #------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- +# SoftLayer Information Driver Manager Configuration +#------------------------------------------------------------------------------- +#IM_MAD = [ +# name = "sl", +# executable = "one_im_sh", +# arguments = "-c -t 1 -r 0 sl" ] +#------------------------------------------------------------------------------- + #------------------------------------------------------------------------------- # Dummy Information Driver Manager Configuration #------------------------------------------------------------------------------- @@ -419,6 +428,18 @@ 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" ] +#------------------------------------------------------------------------------- + #------------------------------------------------------------------------------- # Dummy Virtualization Driver Configuration #------------------------------------------------------------------------------- diff --git a/src/im_mad/remotes/sl.d/poll b/src/im_mad/remotes/sl.d/poll new file mode 100755 index 0000000000..78eca8523b --- /dev/null +++ b/src/im_mad/remotes/sl.d/poll @@ -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 diff --git a/src/vmm_mad/remotes/ec2/attach_disk b/src/vmm_mad/remotes/ec2/attach_disk old mode 100644 new mode 100755 diff --git a/src/vmm_mad/remotes/sl/attach_disk b/src/vmm_mad/remotes/sl/attach_disk new file mode 100755 index 0000000000..8aeaf8eba5 --- /dev/null +++ b/src/vmm_mad/remotes/sl/attach_disk @@ -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 diff --git a/src/vmm_mad/remotes/sl/attach_nic b/src/vmm_mad/remotes/sl/attach_nic new file mode 100755 index 0000000000..8aeaf8eba5 --- /dev/null +++ b/src/vmm_mad/remotes/sl/attach_nic @@ -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 diff --git a/src/vmm_mad/remotes/sl/cancel b/src/vmm_mad/remotes/sl/cancel new file mode 100755 index 0000000000..05844b2977 --- /dev/null +++ b/src/vmm_mad/remotes/sl/cancel @@ -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) diff --git a/src/vmm_mad/remotes/sl/deploy b/src/vmm_mad/remotes/sl/deploy new file mode 100755 index 0000000000..6410f5af2c --- /dev/null +++ b/src/vmm_mad/remotes/sl/deploy @@ -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 diff --git a/src/vmm_mad/remotes/sl/detach_disk b/src/vmm_mad/remotes/sl/detach_disk new file mode 100755 index 0000000000..8aeaf8eba5 --- /dev/null +++ b/src/vmm_mad/remotes/sl/detach_disk @@ -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 diff --git a/src/vmm_mad/remotes/sl/detach_nic b/src/vmm_mad/remotes/sl/detach_nic new file mode 100755 index 0000000000..8aeaf8eba5 --- /dev/null +++ b/src/vmm_mad/remotes/sl/detach_nic @@ -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 diff --git a/src/vmm_mad/remotes/sl/migrate b/src/vmm_mad/remotes/sl/migrate new file mode 100755 index 0000000000..8aeaf8eba5 --- /dev/null +++ b/src/vmm_mad/remotes/sl/migrate @@ -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 diff --git a/src/vmm_mad/remotes/sl/migrate_local b/src/vmm_mad/remotes/sl/migrate_local new file mode 100755 index 0000000000..8aeaf8eba5 --- /dev/null +++ b/src/vmm_mad/remotes/sl/migrate_local @@ -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 diff --git a/src/vmm_mad/remotes/sl/poll b/src/vmm_mad/remotes/sl/poll new file mode 100755 index 0000000000..711cdd6016 --- /dev/null +++ b/src/vmm_mad/remotes/sl/poll @@ -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) diff --git a/src/vmm_mad/remotes/sl/reboot b/src/vmm_mad/remotes/sl/reboot new file mode 100755 index 0000000000..7fd2fea3bb --- /dev/null +++ b/src/vmm_mad/remotes/sl/reboot @@ -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) diff --git a/src/vmm_mad/remotes/sl/reset b/src/vmm_mad/remotes/sl/reset new file mode 100755 index 0000000000..8aeaf8eba5 --- /dev/null +++ b/src/vmm_mad/remotes/sl/reset @@ -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 diff --git a/src/vmm_mad/remotes/sl/restore b/src/vmm_mad/remotes/sl/restore new file mode 100755 index 0000000000..d41da8c05f --- /dev/null +++ b/src/vmm_mad/remotes/sl/restore @@ -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) diff --git a/src/vmm_mad/remotes/sl/save b/src/vmm_mad/remotes/sl/save new file mode 100755 index 0000000000..b2fde5e7c3 --- /dev/null +++ b/src/vmm_mad/remotes/sl/save @@ -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) diff --git a/src/vmm_mad/remotes/sl/shutdown b/src/vmm_mad/remotes/sl/shutdown new file mode 100755 index 0000000000..3dd8942734 --- /dev/null +++ b/src/vmm_mad/remotes/sl/shutdown @@ -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) diff --git a/src/vmm_mad/remotes/sl/sl_driver.conf b/src/vmm_mad/remotes/sl/sl_driver.conf new file mode 100644 index 0000000000..1ad69712a8 --- /dev/null +++ b/src/vmm_mad/remotes/sl/sl_driver.conf @@ -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.xlarge: 0 + ams01: + region_name: ams01 + username: + api_key: + capacity: + slcci.small: 5 + slcci.large: 0 + slcci.xlarge: 0 + sjc01: + region_name: sjc01 + username: + api_key: + capacity: + slcci.small: + slcci.large: + slcci.xlarge: + dal01: + region_name: dal01 + username: + api_key: + capacity: + slcci.small: + slcci.large: + slcci.xlarge: + dal02: + region_name: dal02 + username: + api_key: + capacity: + slcci.small: + slcci.large: + slcci.xlarge: + dal05: + region_name: dal05 + username: + api_key: + capacity: + slcci.small: + slcci.large: + slcci.xlarge: + dal06: + region_name: dal06 + username: + api_key: + capacity: + slcci.small: + slcci.large: + slcci.xlarge: + dal07: + region_name: dal07 + username: + api_key: + capacity: + slcci.small: + slcci.large: + slcci.xlarge: + hou02: + region_name: hou02 + username: + api_key: + capacity: + slcci.small: + slcci.large: + slcci.xlarge: + sea01: + region_name: sea01 + username: + api_key: + capacity: + slcci.small: + slcci.large: + slcci.xlarge: + sng01: + region_name: sng01 + username: + api_key: + capacity: + slcci.small: + slcci.large: + slcci.xlarge: + wdc01: + region_name: wdc01 + username: + api_key: + capacity: + slcci.small: + slcci.large: + slcci.xlarge: +instance_types: + slcci.small: + cpu: 1 + memory: 1 + slcci.medium: + cpu: 2 + memory: 4 + slcci.large: + cpu: 4 + memory: 8 + diff --git a/src/vmm_mad/remotes/sl/sl_driver.default b/src/vmm_mad/remotes/sl/sl_driver.default new file mode 100644 index 0000000000..e3fdcf805f --- /dev/null +++ b/src/vmm_mad/remotes/sl/sl_driver.default @@ -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. # +#--------------------------------------------------------------------------- # + + + diff --git a/src/vmm_mad/remotes/sl/sl_driver.rb b/src/vmm_mad/remotes/sl/sl_driver.rb new file mode 100644 index 0000000000..9a36751c9c --- /dev/null +++ b/src/vmm_mad/remotes/sl/sl_driver.rb @@ -0,0 +1,549 @@ +#!/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] and !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 + 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) + 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 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 \ No newline at end of file diff --git a/src/vmm_mad/remotes/sl/snapshot_create b/src/vmm_mad/remotes/sl/snapshot_create new file mode 100755 index 0000000000..8aeaf8eba5 --- /dev/null +++ b/src/vmm_mad/remotes/sl/snapshot_create @@ -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 diff --git a/src/vmm_mad/remotes/sl/snapshot_delete b/src/vmm_mad/remotes/sl/snapshot_delete new file mode 100755 index 0000000000..8aeaf8eba5 --- /dev/null +++ b/src/vmm_mad/remotes/sl/snapshot_delete @@ -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 diff --git a/src/vmm_mad/remotes/sl/snapshot_revert b/src/vmm_mad/remotes/sl/snapshot_revert new file mode 100755 index 0000000000..8aeaf8eba5 --- /dev/null +++ b/src/vmm_mad/remotes/sl/snapshot_revert @@ -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 From a881a599b4653fba7d284d538121cf671ad42604 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Fri, 6 Jun 2014 15:33:20 +0200 Subject: [PATCH 02/18] Fix bad capacity description in SL --- src/vmm_mad/remotes/sl/sl_driver.conf | 24 ++++++++++++------------ src/vmm_mad/remotes/sl/sl_driver.rb | 10 +++++++--- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/vmm_mad/remotes/sl/sl_driver.conf b/src/vmm_mad/remotes/sl/sl_driver.conf index 1ad69712a8..64f46a7bd7 100644 --- a/src/vmm_mad/remotes/sl/sl_driver.conf +++ b/src/vmm_mad/remotes/sl/sl_driver.conf @@ -7,7 +7,7 @@ regions: capacity: slcci.small: 5 slcci.large: 0 - slcci.xlarge: 0 + slcci.large: 0 ams01: region_name: ams01 username: @@ -15,7 +15,7 @@ regions: capacity: slcci.small: 5 slcci.large: 0 - slcci.xlarge: 0 + slcci.large: 0 sjc01: region_name: sjc01 username: @@ -23,7 +23,7 @@ regions: capacity: slcci.small: slcci.large: - slcci.xlarge: + slcci.large: dal01: region_name: dal01 username: @@ -31,7 +31,7 @@ regions: capacity: slcci.small: slcci.large: - slcci.xlarge: + slcci.large: dal02: region_name: dal02 username: @@ -39,7 +39,7 @@ regions: capacity: slcci.small: slcci.large: - slcci.xlarge: + slcci.large: dal05: region_name: dal05 username: @@ -47,7 +47,7 @@ regions: capacity: slcci.small: slcci.large: - slcci.xlarge: + slcci.large: dal06: region_name: dal06 username: @@ -55,7 +55,7 @@ regions: capacity: slcci.small: slcci.large: - slcci.xlarge: + slcci.large: dal07: region_name: dal07 username: @@ -63,7 +63,7 @@ regions: capacity: slcci.small: slcci.large: - slcci.xlarge: + slcci.large: hou02: region_name: hou02 username: @@ -71,7 +71,7 @@ regions: capacity: slcci.small: slcci.large: - slcci.xlarge: + slcci.large: sea01: region_name: sea01 username: @@ -79,7 +79,7 @@ regions: capacity: slcci.small: slcci.large: - slcci.xlarge: + slcci.large: sng01: region_name: sng01 username: @@ -87,7 +87,7 @@ regions: capacity: slcci.small: slcci.large: - slcci.xlarge: + slcci.large: wdc01: region_name: wdc01 username: @@ -95,7 +95,7 @@ regions: capacity: slcci.small: slcci.large: - slcci.xlarge: + slcci.large: instance_types: slcci.small: cpu: 1 diff --git a/src/vmm_mad/remotes/sl/sl_driver.rb b/src/vmm_mad/remotes/sl/sl_driver.rb index 9a36751c9c..f322f9609b 100644 --- a/src/vmm_mad/remotes/sl/sl_driver.rb +++ b/src/vmm_mad/remotes/sl/sl_driver.rb @@ -186,11 +186,11 @@ class SLDriver :min_count => 1, :max_count => 1}) - if !opts[:startCpus] and !opts[:maxMemory] + 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 + opts[:startCpus] = cpu / 100 opts[:maxMemory] = mem / 1024 end @@ -316,7 +316,11 @@ 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) - return 0, 0 if @instance_types[name].nil? + 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 From 8b2c7d4b33326ca4916df7efd15e977ff3be85f6 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Fri, 6 Jun 2014 18:44:53 +0200 Subject: [PATCH 03/18] feature #2959: Add SL gems to install gems --- share/install_gems/install_gems | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/install_gems/install_gems b/share/install_gems/install_gems index 8b779ec546..ca362ca8da 100755 --- a/share/install_gems/install_gems +++ b/share/install_gems/install_gems @@ -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}, :auth_ldap => 'net-ldap', :vmware => %w{builder trollop}, :oneflow => %w{sinatra json treetop parse-cron}, From 6b9f1dbfca19fa78defdce8026fbfc4a37a4e186 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Mon, 9 Jun 2014 15:24:15 +0200 Subject: [PATCH 04/18] Fix default instance type --- src/vmm_mad/remotes/sl/sl_driver.default | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vmm_mad/remotes/sl/sl_driver.default b/src/vmm_mad/remotes/sl/sl_driver.default index e3fdcf805f..1563b51398 100644 --- a/src/vmm_mad/remotes/sl/sl_driver.default +++ b/src/vmm_mad/remotes/sl/sl_driver.default @@ -21,7 +21,7 @@ Example: --> @@ -29,7 +29,7 @@