diff --git a/install.sh b/install.sh index 77a27c67b4..4df3e6a24e 100755 --- a/install.sh +++ b/install.sh @@ -115,9 +115,11 @@ SHARE_DIRS="$SHARE_LOCATION/examples \ ETC_DIRS="$ETC_LOCATION/im_kvm \ $ETC_LOCATION/im_xen \ $ETC_LOCATION/im_ec2 \ + $ETC_LOCATION/im_eh \ $ETC_LOCATION/vmm_kvm \ $ETC_LOCATION/vmm_xen \ $ETC_LOCATION/vmm_ec2 \ + $ETC_LOCATION/vmm_eh \ $ETC_LOCATION/tm_nfs \ $ETC_LOCATION/tm_ssh \ $ETC_LOCATION/tm_dummy \ @@ -157,13 +159,15 @@ INSTALL_ETC_FILES[0]="ETC_FILES:$ETC_LOCATION" INSTALL_ETC_FILES[1]="VMM_XEN_ETC_FILES:$ETC_LOCATION/vmm_xen" INSTALL_ETC_FILES[2]="VMM_KVM_ETC_FILES:$ETC_LOCATION/vmm_kvm" INSTALL_ETC_FILES[3]="VMM_EC2_ETC_FILES:$ETC_LOCATION/vmm_ec2" -INSTALL_ETC_FILES[4]="IM_XEN_ETC_FILES:$ETC_LOCATION/im_xen" -INSTALL_ETC_FILES[5]="IM_KVM_ETC_FILES:$ETC_LOCATION/im_kvm" -INSTALL_ETC_FILES[6]="IM_EC2_ETC_FILES:$ETC_LOCATION/im_ec2" -INSTALL_ETC_FILES[7]="TM_NFS_ETC_FILES:$ETC_LOCATION/tm_nfs" -INSTALL_ETC_FILES[8]="TM_SSH_ETC_FILES:$ETC_LOCATION/tm_ssh" -INSTALL_ETC_FILES[9]="TM_DUMMY_ETC_FILES:$ETC_LOCATION/tm_dummy" -INSTALL_ETC_FILES[10]="HM_ETC_FILES:$ETC_LOCATION/hm" +INSTALL_ETC_FILES[4]="VMM_EH_ETC_FILES:$ETC_LOCATION/vmm_eh" +INSTALL_ETC_FILES[5]="IM_XEN_ETC_FILES:$ETC_LOCATION/im_xen" +INSTALL_ETC_FILES[6]="IM_KVM_ETC_FILES:$ETC_LOCATION/im_kvm" +INSTALL_ETC_FILES[7]="IM_EC2_ETC_FILES:$ETC_LOCATION/im_ec2" +INSTALL_ETC_FILES[8]="IM_EH_ETC_FILES:$ETC_LOCATION/im_eh" +INSTALL_ETC_FILES[9]="TM_NFS_ETC_FILES:$ETC_LOCATION/tm_nfs" +INSTALL_ETC_FILES[10]="TM_SSH_ETC_FILES:$ETC_LOCATION/tm_ssh" +INSTALL_ETC_FILES[11]="TM_DUMMY_ETC_FILES:$ETC_LOCATION/tm_dummy" +INSTALL_ETC_FILES[12]="HM_ETC_FILES:$ETC_LOCATION/hm" #------------------------------------------------------------------------------- # Binary files, to be installed under $BIN_LOCATION @@ -226,10 +230,14 @@ MADS_LIB_FILES="share/scripts/madcommon.sh \ src/vmm_mad/kvm/one_vmm_kvm \ src/vmm_mad/ec2/one_vmm_ec2.rb \ src/vmm_mad/ec2/one_vmm_ec2 \ + src/vmm_mad/eh/one_vmm_eh.rb \ + src/vmm_mad/eh/one_vmm_eh \ src/im_mad/im_ssh/one_im_ssh.rb \ src/im_mad/im_ssh/one_im_ssh \ src/im_mad/ec2/one_im_ec2.rb \ src/im_mad/ec2/one_im_ec2 \ + src/im_mad/eh/one_im_eh.rb \ + src/im_mad/eh/one_im_eh \ src/tm_mad/one_tm \ src/tm_mad/one_tm.rb \ src/hm_mad/one_hm.rb \ @@ -282,6 +290,7 @@ ETC_FILES="share/etc/oned.conf \ # - xen, $ETC_LOCATION/vmm_xen # - kvm, $ETC_LOCATION/vmm_kvm # - ec2, $ETC_LOCATION/vmm_ec2 +# - eh, $ETC_LOCATION/vmm_eh #------------------------------------------------------------------------------- VMM_XEN_ETC_FILES="src/vmm_mad/xen/vmm_xenrc \ @@ -293,6 +302,9 @@ VMM_KVM_ETC_FILES="src/vmm_mad/kvm/vmm_kvmrc \ VMM_EC2_ETC_FILES="src/vmm_mad/ec2/vmm_ec2rc \ src/vmm_mad/ec2/vmm_ec2.conf" +VMM_EH_ETC_FILES="src/vmm_mad/eh/vmm_ehrc \ + src/vmm_mad/eh/vmm_eh.conf" + #------------------------------------------------------------------------------- # Information drivers config. files, to be installed under $ETC_LOCATION # - xen, $ETC_LOCATION/im_xen @@ -309,6 +321,9 @@ IM_KVM_ETC_FILES="src/im_mad/kvm/im_kvmrc \ IM_EC2_ETC_FILES="src/im_mad/ec2/im_ec2rc \ src/im_mad/ec2/im_ec2.conf" +IM_EH_ETC_FILES="src/im_mad/eh/im_ehrc \ + src/im_mad/eh/im_eh.conf" + #------------------------------------------------------------------------------- # Storage drivers config. files, to be installed under $ETC_LOCATION # - nfs, $ETC_LOCATION/tm_nfs @@ -392,7 +407,7 @@ if [ "$INSTALL_ETC" = "yes" ] ; then DST=`echo $i | cut -d: -f2` eval SRC_FILES=$SRC - + for f in $SRC_FILES; do do_file $f $DST done diff --git a/src/im_mad/eh/im_eh.conf b/src/im_mad/eh/im_eh.conf new file mode 100644 index 0000000000..e122c1a79d --- /dev/null +++ b/src/im_mad/eh/im_eh.conf @@ -0,0 +1,7 @@ +# Max memory that can be provided by ElasticHosts +# These defaults allows for two machines with MEMORY=1024 and using 1 CPU + +TOTAL_MEMORY=2048 +TOTAL_CPU=2 + + diff --git a/src/im_mad/eh/im_ehrc b/src/im_mad/eh/im_ehrc new file mode 100644 index 0000000000..e9238feca4 --- /dev/null +++ b/src/im_mad/eh/im_ehrc @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------- # +# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad # +# Complutense de Madrid (dsa-research.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + diff --git a/src/im_mad/eh/one_im_eh b/src/im_mad/eh/one_im_eh new file mode 100644 index 0000000000..fe5f260c44 --- /dev/null +++ b/src/im_mad/eh/one_im_eh @@ -0,0 +1,43 @@ +#!/bin/bash +# -------------------------------------------------------------------------- # +# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad # +# Complutense de Madrid (dsa-research.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +if [ -z "${ONE_LOCATION}" ]; then + EHRC=/etc/one/im_eh/im_ehrc + EHCONF=/etc/one/im_eh/im_eh.conf + MADCOMMON=/usr/lib/one/mads/madcommon.sh + VAR_LOCATION=/var/lib/one +else + EHRC=$ONE_LOCATION/etc/im_eh/im_ehrc + EHCONF=$ONE_LOCATION/etc/im_eh/im_eh.conf + MADCOMMON=$ONE_LOCATION/lib/mads/madcommon.sh + VAR_LOCATION=$ONE_LOCATION/var +fi + +. $MADCOMMON + +# Export the vmm_mad specific rc +export_rc_vars $EHRC + +# Export max instance type usages +export_rc_vars $EHCONF + +# Go to var directory ONE_LOCATION/var or /var/lib/one +cd $VAR_LOCATION + +# Execute the actual MAD +execute_mad $* \ No newline at end of file diff --git a/src/im_mad/eh/one_im_eh.rb b/src/im_mad/eh/one_im_eh.rb new file mode 100644 index 0000000000..1eaec87157 --- /dev/null +++ b/src/im_mad/eh/one_im_eh.rb @@ -0,0 +1,62 @@ +#!/usr/bin/env ruby + +# -------------------------------------------------------------------------- # +# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad # +# Complutense de Madrid (dsa-research.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +ONE_LOCATION=ENV["ONE_LOCATION"] + +if !ONE_LOCATION + RUBY_LIB_LOCATION="/usr/lib/one/ruby" +else + RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" +end + +$: << RUBY_LIB_LOCATION + +require 'pp' +require 'one_mad' + +################ +# EC2 IM MAD # +################ + +class IM < ONEMad + + def initialize(sensors=nil) + super(3, 4) + end + + def action_init(args) + STDOUT.puts "INIT SUCCESS" + STDOUT.flush + end + + def action_monitor(args) + + totalmemory = ENV["TOTAL_MEMORY"].to_i + totalcpu = 100 * ENV["TOTAL_CPU"].to_i + + + STDOUT.puts "MONITOR SUCCESS " + args[1].to_s + + "HOSTNAME=#{args[2]},TOTALMEMORY=#{totalmemory},TOTALCPU=#{totalcpu},CPUSPEED=1000,FREEMEMORY=#{totalmemory},FREECPU=#{totalcpu}" + STDOUT.flush + end + +end + +im=IM.new(nil) +im.loop \ No newline at end of file diff --git a/src/vmm_mad/eh/one_vmm_eh b/src/vmm_mad/eh/one_vmm_eh new file mode 100644 index 0000000000..fe1b37511a --- /dev/null +++ b/src/vmm_mad/eh/one_vmm_eh @@ -0,0 +1,39 @@ +#!/bin/bash + +# -------------------------------------------------------------------------- # +# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad # +# Complutense de Madrid (dsa-research.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +if [ -z "${ONE_LOCATION}" ]; then + DRIVERRC=/etc/one/vmm_eh/vmm_ehrc + MADCOMMON=/usr/lib/one/mads/madcommon.sh + VAR_LOCATION=/var/lib/one +else + DRIVERRC=$ONE_LOCATION/etc/vmm_eh/vmm_ehrc + MADCOMMON=$ONE_LOCATION/lib/mads/madcommon.sh + VAR_LOCATION=$ONE_LOCATION/var +fi + +. $MADCOMMON + +# Export the vmm_mad specific rc +export_rc_vars $DRIVERRC + +# Go to ONE_LOCATION +cd $VAR_LOCATION + +# Execute the actual MAD +execute_mad $* \ No newline at end of file diff --git a/src/vmm_mad/eh/one_vmm_eh.rb b/src/vmm_mad/eh/one_vmm_eh.rb new file mode 100644 index 0000000000..d832df47a5 --- /dev/null +++ b/src/vmm_mad/eh/one_vmm_eh.rb @@ -0,0 +1,179 @@ +#!/usr/bin/env ruby +# -------------------------------------------------------------------------- # +# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad # +# Complutense de Madrid (dsa-research.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +EHAUTH = ENV["EHAUTH"] + +if !EHAUTH + puts "EHAUTH not set" + exit -1 +end + +ONE_LOCATION=ENV["ONE_LOCATION"] + +if !ONE_LOCATION + RUBY_LIB_LOCATION="/usr/lib/one/ruby" +else + RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" +end + +$: << RUBY_LIB_LOCATION + +require 'pp' +require 'one_mad' +require 'open3' + +class DM < ONEMad + + def initialize + super(5, 4) + end + + def action_init(args) + + send_message("INIT", "SUCCESS") + + end + + def action_deploy(args) + + action_number=args[1] + action_host=args[2] + remote_deployment_file=args[3] + + # Get local deployment file + local_deployment_file=get_local_deployment_file(remote_deployment_file) + + std_action("DEPLOY", "elastichosts -f #{local_deployment_file} servers create", args) + + end + + def action_shutdown(args) + + std_action("SHUTDOWN", "elastichosts servers #{args[3]} shutdown", args) + + end + + def action_cancel(args) + + std_action("SHUTDOWN", "elastichosts servers #{args[3]} destroy", args) + + end + + def action_checkpoint(args) + + send_message("CHECKPOINT", "FAILURE", args[1], "action not supported for ElasticHost") + + end + + def action_save(args) + + send_message("SAVE", "FAILURE", args[1], "action not supported for ElasticHost") + + end + + def action_restore(args) + + send_message("RESTORE", "FAILURE", args[1], "action not supported for ElasticHost") + + end + + def action_poll(args) + + std = Open3.popen3("elastichosts servers #{args[3]} info; echo ExitCode: $? 1>&2") + + stdout=std[1].read + stderr=std[2].read + + exit_code=get_exit_code(stderr) + + tx=0 + rx=0 + + if exit_code=="0" + stdout.each_line{|line| + cols=line.split(" ") + case cols[0] + when "rx" + rx=cols[1] + when "tx" + tx=cols[1] + end + } + + end + + send_message("POLL", "SUCCESS", args[1],"USEDCPU=0.0 NETTX=#{tx} NETRX=#{rx} USEDMEMORY=0") + + end + + ########################### + # Common action functions # + ########################### + + def std_action(action, command, args) + + std= Open3.popen3("#{command} ; echo ExitCode: $? 1>&2") + + stdout=std[1].read + stderr=std[2].read + + exit_code=get_exit_code(stderr) + + if exit_code=="0" + domain_name=args[3] + if action=="DEPLOY" + remote_deployment_file=args[3] + + # Get local deployment file + local_deployment_file=get_local_deployment_file(remote_deployment_file) + + domain_name = stdout + end + send_message(action, "SUCCESS", args[1], domain_name) + else + error_message=get_error_message(stderr) + send_message(action, "FAILURE", args[1], error_message) + end + + end + + ######################################### + # Get information form xm create output # + ######################################### + + # From STDERR if exit code == 1 + def get_exit_code(str) + tmp=str.scan(/^ExitCode:.*$/)[0] + if tmp + return tmp.split(' ')[1] + else + return -1 + end + end + + # From STDERR if exit code == 1 + def get_error_message(str) + tmp=str.split(/\n/) + return "Unknown error" if !tmp[0] + tmp[0] + end + +end + +dm=DM.new +dm.loop \ No newline at end of file diff --git a/src/vmm_mad/eh/vmm_eh.conf b/src/vmm_mad/eh/vmm_eh.conf new file mode 100644 index 0000000000..15c1accf9e --- /dev/null +++ b/src/vmm_mad/eh/vmm_eh.conf @@ -0,0 +1 @@ +# Default configuration attributes for the ElasticHost driver \ No newline at end of file diff --git a/src/vmm_mad/eh/vmm_ehrc b/src/vmm_mad/eh/vmm_ehrc new file mode 100644 index 0000000000..586ba5f74d --- /dev/null +++ b/src/vmm_mad/eh/vmm_ehrc @@ -0,0 +1,26 @@ +# -------------------------------------------------------------------------- # +# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad # +# Complutense de Madrid (dsa-research.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- ## + +# May be needed in some setups +# CLASSPATH="" + +# +# Note: elastichosts command line script (download it here http://www.elastichosts.com/downloads/elastichosts) +# MUST be in the PATH +# + +EHAUTH=":" \ No newline at end of file