From f05fb71f1386e339bd51657b9f1b45404e700757 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Tue, 17 Aug 2010 00:28:48 +0200 Subject: [PATCH 01/13] feature #307: Now the IM protocol is MONITOR hid hostname update --- include/InformationManager.h | 25 +++++++----- include/InformationManagerDriver.h | 24 ++++------- include/Nebula.h | 24 ++++++----- src/im/InformationManager.cc | 25 +++++++++++- src/im/InformationManagerDriver.cc | 64 +++++++++++++++--------------- src/nebula/Nebula.cc | 6 ++- 6 files changed, 98 insertions(+), 70 deletions(-) diff --git a/include/InformationManager.h b/include/InformationManager.h index f7b12ff5db..8c2f065933 100644 --- a/include/InformationManager.h +++ b/include/InformationManager.h @@ -34,11 +34,13 @@ public: HostPool * _hpool, time_t _timer_period, time_t _monitor_period, + const string& _remotes_location, vector& _mads) :MadManager(_mads), hpool(_hpool), timer_period(_timer_period), - monitor_period(_monitor_period) + monitor_period(_monitor_period), + remotes_location(_remotes_location) { am.addListener(this); }; @@ -46,7 +48,7 @@ public: ~InformationManager(){}; /** - * This functions starts the associated listener thread, and creates a + * This functions starts the associated listener thread, and creates a * new thread for the Information Manager. This thread will wait in * an action loop till it receives ACTION_FINALIZE. * @return 0 on success. @@ -63,12 +65,12 @@ public: }; /** - * + * */ void load_mads(int uid=0); /** - * + * */ void finalize() { @@ -90,28 +92,33 @@ private: * Timer period for the Virtual Machine Manager. */ time_t timer_period; - + /** * Host monitoring interval */ time_t monitor_period; - + + /** + * Path for the remote action programs + */ + string remotes_location; + /** * Action engine for the Manager */ ActionManager am; /** - * Function to execute the Manager action loop method within a new pthread + * Function to execute the Manager action loop method within a new pthread * (requires C linkage) */ friend void * im_action_loop(void *arg); /** - * Returns a pointer to a Information Manager MAD. The driver is + * Returns a pointer to a Information Manager MAD. The driver is * searched by its name and owned by gwadmin with uid=0. * @param name of the driver - * @return the VM driver owned by uid 0, with attribute "NAME" equal to + * @return the VM driver owned by uid 0, with attribute "NAME" equal to * name or 0 in not found */ const InformationManagerDriver * get( diff --git a/include/InformationManagerDriver.h b/include/InformationManagerDriver.h index f725a21213..7b4bdf4a96 100644 --- a/include/InformationManagerDriver.h +++ b/include/InformationManagerDriver.h @@ -30,7 +30,7 @@ using namespace std; /** * InformationManagerDriver provides a base class to implement IM * Drivers. This class implements the protocol and recover functions - * from the Mad interface. This class may be used to further specialize + * from the Mad interface. This class may be used to further specialize * the IM driver. */ class InformationManagerDriver : public Mad @@ -42,35 +42,28 @@ public: const map& attrs, bool sudo, HostPool * pool): - Mad(userid,attrs,sudo),hpool(pool) - {} - ; + Mad(userid,attrs,sudo),hpool(pool){}; - virtual ~InformationManagerDriver() - {} - ; + virtual ~InformationManagerDriver(){}; /** * Implements the IM driver protocol. * @param message the string read from the driver */ - void protocol( - string& message); + void protocol(string& message); /** * TODO: What do we need here? just poll the Hosts to recover.. */ void recover(); - + /** * Sends a monitor request to the MAD: "MONITOR ID HOSTNAME -" * @param oid the virtual machine id. * @param host the hostname - * @param conf the filename of the deployment file + * @param update the remotes directory in host */ - void monitor ( - int oid, - const string& host) const; + void monitor(int oid, const string& host, bool update) const; private: /** @@ -78,8 +71,7 @@ private: */ HostPool * hpool; - friend class InformationManager; - + friend class InformationManager; }; /* -------------------------------------------------------------------------- */ diff --git a/include/Nebula.h b/include/Nebula.h index 44e41f503f..baf4b31159 100644 --- a/include/Nebula.h +++ b/include/Nebula.h @@ -232,11 +232,12 @@ private: { nebula_location = "/"; - mad_location = "/usr/lib/one/mads/"; - etc_location = "/etc/one/"; - log_location = "/var/log/one/"; - var_location = "/var/lib/one/"; - hook_location= "/usr/share/one/hooks/"; + mad_location = "/usr/lib/one/mads/"; + etc_location = "/etc/one/"; + log_location = "/var/log/one/"; + var_location = "/var/lib/one/"; + hook_location = "/usr/share/one/hooks/"; + remotes_location = "/usr/lib/one/remotes/"; } else { @@ -247,11 +248,12 @@ private: nebula_location += "/"; } - mad_location = nebula_location + "lib/mads/"; - etc_location = nebula_location + "etc/"; - log_location = nebula_location + "var/"; - var_location = nebula_location + "var/"; - hook_location= nebula_location + "share/hooks/"; + mad_location = nebula_location + "lib/mads/"; + etc_location = nebula_location + "etc/"; + log_location = nebula_location + "var/"; + var_location = nebula_location + "var/"; + hook_location = nebula_location + "share/hooks/"; + remotes_location = nebula_location + "lib/remotes/"; } }; @@ -348,6 +350,8 @@ private: string log_location; string var_location; string hook_location; + string remotes_location; + string hostname; // --------------------------------------------------------------- diff --git a/src/im/InformationManager.cc b/src/im/InformationManager.cc index 1793c2c2ba..8bbf544f60 100644 --- a/src/im/InformationManager.cc +++ b/src/im/InformationManager.cc @@ -17,6 +17,9 @@ #include "InformationManager.h" #include "NebulaLog.h" +#include +#include + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -145,7 +148,7 @@ void InformationManager::timer_action() istringstream iss; // -------------- Max. number of hosts to monitor. --------------------- - int host_limit = 10; + int host_limit = 15; mark = mark + timer_period; @@ -164,6 +167,16 @@ void InformationManager::timer_action() thetime = time(0); + struct stat sb; + + if (stat(remotes_location.c_str(), &sb) == -1) + { + sb.st_mtime = 0; + + NebulaLog::log("InM",Log::ERROR,"Could not stat remotes directory, " + "will not update remotes."); + } + for(it=discovered_hosts.begin();it!=discovered_hosts.end();it++) { host = hpool->get(it->first,true); @@ -204,7 +217,15 @@ void InformationManager::timer_action() } else { - imd->monitor(it->first,host->get_hostname()); + bool update_remotes = false; + + if ((sb.st_mtime != 0) && + (sb.st_mtime > host->get_last_monitored())) + { + update_remotes = true; + } + + imd->monitor(it->first,host->get_hostname(),update_remotes); host->set_state(Host::MONITORING); } diff --git a/src/im/InformationManagerDriver.cc b/src/im/InformationManagerDriver.cc index 8c0d6141f9..4ce4d98299 100644 --- a/src/im/InformationManagerDriver.cc +++ b/src/im/InformationManagerDriver.cc @@ -23,13 +23,13 @@ /* Driver ASCII Protocol Implementation */ /* ************************************************************************** */ -void InformationManagerDriver::monitor ( - const int oid, - const string& host) const +void InformationManagerDriver::monitor(int oid, + const string& host, + bool update) const { ostringstream os; - os << "MONITOR " << oid << " " << host << endl; + os << "MONITOR " << oid << " " << host << " " << update << endl; write(os); }; @@ -39,8 +39,8 @@ void InformationManagerDriver::monitor ( void InformationManagerDriver::protocol( string& message) -{ - istringstream is(message); +{ + istringstream is(message); //stores the action name string action; //stores the action result @@ -51,7 +51,7 @@ void InformationManagerDriver::protocol( ostringstream ess; string hinfo; Host * host; - + // Parse the driver message if ( is.good() ) @@ -84,61 +84,61 @@ void InformationManagerDriver::protocol( // ----------------------- // Protocol implementation // ----------------------- - + if ( action == "MONITOR" ) { host = hpool->get(id,true); - + if ( host == 0 ) { goto error_host; } - + if (result == "SUCCESS") - { - size_t pos; + { + size_t pos; int rc; - + ostringstream oss; - + getline (is,hinfo); - + for (pos=hinfo.find(',');pos!=string::npos;pos=hinfo.find(',')) { hinfo.replace(pos,1,"\n"); } hinfo += "\n"; - + oss << "Host " << id << " successfully monitored."; //, info: "<< hinfo; NebulaLog::log("InM",Log::DEBUG,oss); - + rc = host->update_info(hinfo); - + if (rc != 0) { goto error_parse_info; - } + } } else { - goto error_driver_info; + goto error_driver_info; } - + host->touch(true); - + hpool->update(host); - host->unlock(); + host->unlock(); } else if (action == "LOG") { string info; - + getline(is,info); NebulaLog::log("InM",Log::INFO,info.c_str()); } - + return; error_driver_info: @@ -146,27 +146,27 @@ error_driver_info: NebulaLog::log("InM", Log::ERROR, ess); goto error_common_info; - + error_parse_info: ess << "Error parsing host information: " << hinfo; NebulaLog::log("InM",Log::ERROR,ess); - + error_common_info: host->touch(false); - + hpool->update(host); - + host->unlock(); - + return; error_host: ess << "Could not get host " << id; NebulaLog::log("InM",Log::ERROR,ess); - + return; - + error_parse: ess << "Error while parsing driver message: " << message; diff --git a/src/nebula/Nebula.cc b/src/nebula/Nebula.cc index a08b2b2e65..61c0622404 100644 --- a/src/nebula/Nebula.cc +++ b/src/nebula/Nebula.cc @@ -345,7 +345,11 @@ void Nebula::start() nebula_configuration->get("IM_MAD", im_mads); - im = new InformationManager(hpool,timer_period,monitor_period,im_mads); + im = new InformationManager(hpool, + timer_period, + monitor_period, + remotes_location, + im_mads); } catch (bad_alloc&) { From 4288175ad1024f82cd3347c1fdb48103d44d3d3f Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Thu, 19 Aug 2010 18:58:00 +0200 Subject: [PATCH 02/13] modified IM ssh mad according to new MONITOR protocol --- install.sh | 54 +++--- share/etc/oned.conf | 4 +- .../scripts/im/common.d}/architecture.sh | 0 .../scripts/im/common.d}/cpu.sh | 0 .../scripts/im/common.d}/name.sh | 0 .../kvm => share/scripts/im/kvm.d}/kvm.rb | 0 share/scripts/im/run_probes | 28 ++++ .../xen => share/scripts/im/xen.d}/xen.rb | 0 src/im_mad/im_ssh/one_im_ssh.rb | 154 +++--------------- src/im_mad/kvm/im_kvm.conf | 8 - src/im_mad/xen/im_xen.conf | 8 - 11 files changed, 84 insertions(+), 172 deletions(-) rename {src/im_mad/host_probes => share/scripts/im/common.d}/architecture.sh (100%) rename {src/im_mad/host_probes => share/scripts/im/common.d}/cpu.sh (100%) rename {src/im_mad/host_probes => share/scripts/im/common.d}/name.sh (100%) rename {src/im_mad/kvm => share/scripts/im/kvm.d}/kvm.rb (100%) create mode 100755 share/scripts/im/run_probes rename {src/im_mad/xen => share/scripts/im/xen.d}/xen.rb (100%) delete mode 100644 src/im_mad/kvm/im_kvm.conf delete mode 100644 src/im_mad/xen/im_xen.conf diff --git a/install.sh b/install.sh index d142411efa..d3ef2793a6 100755 --- a/install.sh +++ b/install.sh @@ -164,7 +164,11 @@ ETC_DIRS="$ETC_LOCATION/im_kvm \ $ETC_LOCATION/ec2query_templates \ $ETC_LOCATION/occi_templates" -LIB_DIRS="$LIB_LOCATION/im_probes \ +LIB_DIRS="$LIB_LOCATION/remotes \ + $LIB_LOCATION/remotes/im \ + $LIB_LOCATION/remotes/im/common.d \ + $LIB_LOCATION/remotes/im/kvm.d \ + $LIB_LOCATION/remotes/im/xen.d \ $LIB_LOCATION/ruby \ $LIB_LOCATION/ruby/OpenNebula \ $LIB_LOCATION/ruby/cloud/ \ @@ -207,20 +211,23 @@ INSTALL_FILES[2]="LIB_FILES:$LIB_LOCATION" INSTALL_FILES[3]="RUBY_LIB_FILES:$LIB_LOCATION/ruby" INSTALL_FILES[4]="RUBY_OPENNEBULA_LIB_FILES:$LIB_LOCATION/ruby/OpenNebula" INSTALL_FILES[5]="MADS_LIB_FILES:$LIB_LOCATION/mads" -INSTALL_FILES[6]="IM_PROBES_LIB_FILES:$LIB_LOCATION/im_probes" -INSTALL_FILES[7]="NFS_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/nfs" -INSTALL_FILES[8]="SSH_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/ssh" -INSTALL_FILES[9]="DUMMY_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/dummy" -INSTALL_FILES[10]="LVM_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/lvm" -INSTALL_FILES[11]="EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples" -INSTALL_FILES[12]="TM_EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples/tm" -INSTALL_FILES[13]="HOOK_SHARE_FILES:$SHARE_LOCATION/hooks" -INSTALL_FILES[14]="COMMON_CLOUD_LIB_FILES:$LIB_LOCATION/ruby/cloud" -INSTALL_FILES[15]="ECO_LIB_FILES:$LIB_LOCATION/ruby/cloud/econe" -INSTALL_FILES[16]="ECO_LIB_VIEW_FILES:$LIB_LOCATION/ruby/cloud/econe/views" -INSTALL_FILES[17]="ECO_BIN_FILES:$BIN_LOCATION" -INSTALL_FILES[18]="OCCI_LIB_FILES:$LIB_LOCATION/ruby/cloud/occi" -INSTALL_FILES[19]="OCCI_BIN_FILES:$BIN_LOCATION" +INSTALL_FILES[6]="IM_PROBES_FILES:$LIB_LOCATION/remotes/im" +INSTALL_FILES[7]="IM_PROBES_COMMON_FILES:$LIB_LOCATION/remotes/im/common.d" +INSTALL_FILES[8]="IM_PROBES_KVM_FILES:$LIB_LOCATION/remotes/im/kvm.d" +INSTALL_FILES[9]="IM_PROBES_XEN_FILES:$LIB_LOCATION/remotes/im/xen.d" +INSTALL_FILES[10]="NFS_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/nfs" +INSTALL_FILES[11]="SSH_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/ssh" +INSTALL_FILES[12]="DUMMY_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/dummy" +INSTALL_FILES[13]="LVM_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/lvm" +INSTALL_FILES[14]="EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples" +INSTALL_FILES[15]="TM_EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples/tm" +INSTALL_FILES[16]="HOOK_SHARE_FILES:$SHARE_LOCATION/hooks" +INSTALL_FILES[17]="COMMON_CLOUD_LIB_FILES:$LIB_LOCATION/ruby/cloud" +INSTALL_FILES[18]="ECO_LIB_FILES:$LIB_LOCATION/ruby/cloud/econe" +INSTALL_FILES[19]="ECO_LIB_VIEW_FILES:$LIB_LOCATION/ruby/cloud/econe/views" +INSTALL_FILES[20]="ECO_BIN_FILES:$BIN_LOCATION" +INSTALL_FILES[21]="OCCI_LIB_FILES:$LIB_LOCATION/ruby/cloud/occi" +INSTALL_FILES[22]="OCCI_BIN_FILES:$BIN_LOCATION" INSTALL_ECO_CLIENT_FILES[0]="COMMON_CLOUD_CLIENT_LIB_FILES:$LIB_LOCATION/ruby/cloud" INSTALL_ECO_CLIENT_FILES[1]="ECO_LIB_CLIENT_FILES:$LIB_LOCATION/ruby/cloud/econe" @@ -338,14 +345,19 @@ MADS_LIB_FILES="src/mad/sh/madcommon.sh \ src/authm_mad/one_auth_mad" #------------------------------------------------------------------------------- -# Information Manager Probes, to be installed under $LIB_LOCATION/im_probes +# Information Manager Probes, to be installed under $LIB_LOCATION/remotes #------------------------------------------------------------------------------- -IM_PROBES_LIB_FILES="src/im_mad/xen/xen.rb \ - src/im_mad/kvm/kvm.rb \ - src/im_mad/host_probes/architecture.sh \ - src/im_mad/host_probes/cpu.sh \ - src/im_mad/host_probes/name.sh" +IM_PROBES_FILES="share/scripts/im/run_probes" + +IM_PROBES_COMMON_FILES="share/scripts/im/common.d/architecture.sh \ + share/scripts/im/common.d/cpu.sh \ + share/scripts/im/common.d/name.sh" + +IM_PROBES_XEN_FILES="share/scripts/im/xen.d/xen.rb" + +IM_PROBES_KVM_FILES="share/scripts/im/kvm.d/kvm.rb" + #------------------------------------------------------------------------------- # Transfer Manager commands, to be installed under $LIB_LOCATION/tm_commands diff --git a/share/etc/oned.conf b/share/etc/oned.conf index 5332b1c271..8842859b99 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -106,7 +106,7 @@ DEFAULT_DEVICE_PREFIX = "hd" #IM_MAD = [ # name = "im_xen", # executable = "one_im_ssh", -# arguments = "im_xen/im_xen.conf" ] +# arguments = "xen" ] #------------------------------------------------------------------------------- # KVM Information Driver Manager sample configuration @@ -114,7 +114,7 @@ DEFAULT_DEVICE_PREFIX = "hd" IM_MAD = [ name = "im_kvm", executable = "one_im_ssh", - arguments = "im_kvm/im_kvm.conf" ] + arguments = "kvm" ] #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- diff --git a/src/im_mad/host_probes/architecture.sh b/share/scripts/im/common.d/architecture.sh similarity index 100% rename from src/im_mad/host_probes/architecture.sh rename to share/scripts/im/common.d/architecture.sh diff --git a/src/im_mad/host_probes/cpu.sh b/share/scripts/im/common.d/cpu.sh similarity index 100% rename from src/im_mad/host_probes/cpu.sh rename to share/scripts/im/common.d/cpu.sh diff --git a/src/im_mad/host_probes/name.sh b/share/scripts/im/common.d/name.sh similarity index 100% rename from src/im_mad/host_probes/name.sh rename to share/scripts/im/common.d/name.sh diff --git a/src/im_mad/kvm/kvm.rb b/share/scripts/im/kvm.d/kvm.rb similarity index 100% rename from src/im_mad/kvm/kvm.rb rename to share/scripts/im/kvm.d/kvm.rb diff --git a/share/scripts/im/run_probes b/share/scripts/im/run_probes new file mode 100755 index 0000000000..a24bee086c --- /dev/null +++ b/share/scripts/im/run_probes @@ -0,0 +1,28 @@ +#!/bin/bash + +HYPERVISOR_DIR=$1.d + +SCRIPTS_DIR=`dirname $0` +cd $SCRIPTS_DIR + + +function run_dir { + ( + DIR=$1 + cd $DIR + for i in `ls *`;do + if [ -x "$i" ]; then + ./$i + fi + done + ) +} + +data=$( + run_dir 'common.d' + if [ -d "$HYPERVISOR_DIR" ]; then + run_dir $HYPERVISOR_DIR + fi +) + +echo $data | tr '\n' ' ' diff --git a/src/im_mad/xen/xen.rb b/share/scripts/im/xen.d/xen.rb similarity index 100% rename from src/im_mad/xen/xen.rb rename to share/scripts/im/xen.d/xen.rb diff --git a/src/im_mad/im_ssh/one_im_ssh.rb b/src/im_mad/im_ssh/one_im_ssh.rb index 70340e11a1..408fe9120b 100755 --- a/src/im_mad/im_ssh/one_im_ssh.rb +++ b/src/im_mad/im_ssh/one_im_ssh.rb @@ -22,127 +22,19 @@ if !ONE_LOCATION RUBY_LIB_LOCATION="/usr/lib/one/ruby" ETC_LOCATION="/etc/one/" PROBE_LOCATION="/usr/lib/one/im_probes/" + REMOTES_LOCATION="/usr/lib/one/remotes" else RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" ETC_LOCATION=ONE_LOCATION+"/etc/" PROBE_LOCATION=ONE_LOCATION+"/lib/im_probes/" + REMOTES_LOCATION=ONE_LOCATION+"/lib/remotes/" end $: << RUBY_LIB_LOCATION - -require 'pp' -require 'digest/md5' -require 'fileutils' require 'OpenNebulaDriver' require 'CommandManager' -#------------------------------------------------------------------------------- -# This class holds the information of a IM probe and the methods to copy the -# script to the remote hosts and run it -#------------------------------------------------------------------------------- -class Sensor - - #--------------------------------------------------------------------------- - # Class constructor init the remote script name and working directory - #--------------------------------------------------------------------------- - def initialize(name, script, remote_dir) - id = Digest::MD5.hexdigest("#{name}#{script}") - - @script = script - @remote_script = "#{remote_dir}/one_im-#{id}" - @remote_dir = remote_dir - end - - #--------------------------------------------------------------------------- - # Sends the monitor probe script to the remote host and execute it - #--------------------------------------------------------------------------- - def execute(host, log_proc) - script_text = File.read @script - - src = "'mkdir -p #{@remote_dir}; cat > #{@remote_script};" \ - " if [ \"x$?\" != \"x0\" ]; then exit -1; fi;" \ - " chmod +x #{@remote_script}; #{@remote_script}'" - - cmd = SSHCommand.run(src, host, log_proc, script_text) - - case cmd.code - when 0 - # Splits the output by lines, strips each line and gets only - # lines that have something - value = cmd.stdout.split("\n").collect {|v| - v2 = v.strip - if v2 == "" - nil - else - v2 - end - }.compact.join(",") - else - nil - end - end -end - - -#------------------------------------------------------------------------------- -# This class is an array of sensor probes to be executed by the information -# driver. The class is built on top of the Sensor class -#------------------------------------------------------------------------------- -class SensorList < Array - #--------------------------------------------------------------------------- - # Initialize the class - #--------------------------------------------------------------------------- - def initialize(config_file, remote_dir) - super(0) - - @remote_dir = remote_dir - - load_sensors(config_file) - end - - #--------------------------------------------------------------------------- - # Execute all sensors in the list in the given host - #--------------------------------------------------------------------------- - def execute_sensors(host, log_proc) - results = Array.new - - self.each {|sensor| - results << sensor.execute(host, log_proc) - } - results - end - -private - #--------------------------------------------------------------------------- - # Load sensors from a configuration file - #--------------------------------------------------------------------------- - def load_sensors(file) - f = open(file, "r") - - f.each_line {|line| - l = line.strip.gsub(/#.*$/, "") - - case l - when "" - when /^[^=]+=[^=]+$/ - (name, script)=l.split("=") - - name.strip! - script.strip! - - script = "#{PROBE_LOCATION}#{script}" if script[0] != ?/ - - self << Sensor.new(name, script, @remote_dir) - else - STDERR.puts "Malformed line in configuration file: #{line}" - end - } - - f.close - end -end - #------------------------------------------------------------------------------- # The SSH Information Manager Driver #------------------------------------------------------------------------------- @@ -151,26 +43,33 @@ class InformationManager < OpenNebulaDriver #--------------------------------------------------------------------------- # Init the driver #--------------------------------------------------------------------------- - def initialize(config_file, remote_dir, num) + def initialize(remote_dir, hypervisor, num) super(num, true) - @sensor_list=SensorList.new(config_file, remote_dir) + @hypervisor = hypervisor + @remote_dir = remote_dir # register actions register_action(:MONITOR, method("action_monitor")) end #--------------------------------------------------------------------------- - # Execute the sensor array in the remote host + # Execute the run_probes in the remote host #--------------------------------------------------------------------------- - def action_monitor(number, host) + def action_monitor(number, host, do_update) + STDERR.puts Time.now.to_s + ": do_update=" +do_update.inspect + if do_update == "1" + STDERR.puts Time.now.to_s + ": Doing rsync" + sync_cmd = "rsync -Laz #{REMOTES_LOCATION} #{host}:#{@remote_dir}" + LocalCommand.run(sync_cmd) + else + end - results = @sensor_list.execute_sensors(host, log_method(number)) + cmd = SSHCommand.run("#{@remote_dir}/im/run_probes #{@hypervisor}", + host) - information=results.select{|res| res && !res.empty? }.join(",") - - if information and !information.empty? - send_message("MONITOR", RESULT[:success], number, information) + if cmd.code == 0 + send_message("MONITOR", RESULT[:success], number, cmd.stdout) else send_message("MONITOR", RESULT[:failure], number, "Could not monitor host #{host}.") @@ -184,22 +83,11 @@ end # Information Manager main program #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- -im_conf = ARGV.last - -if !im_conf || File.exists?(im_conf) - puts "You need to specify config file." - exit(-1) -end - -im_conf = "#{ETC_LOCATION}#{im_conf}" if im_conf[0] != ?/ - -if !File.exists?(im_conf) - puts "Configuration file #{im_conf} does not exists." - exit(-1) -end remote_dir = ENV["IM_REMOTE_DIR"] remote_dir = "/tmp/one-im" if !remote_dir -im = InformationManager.new(im_conf, "#{remote_dir}/", 15) +hypervisor = ARGV[0]||'' + +im = InformationManager.new(remote_dir, hypervisor, 15) im.start_driver diff --git a/src/im_mad/kvm/im_kvm.conf b/src/im_mad/kvm/im_kvm.conf deleted file mode 100644 index a891f402c6..0000000000 --- a/src/im_mad/kvm/im_kvm.conf +++ /dev/null @@ -1,8 +0,0 @@ -#------------------------------------------------------------------------------- -# Probes for KVM hosts add as many monitorization sensors as you need -#------------------------------------------------------------------------------- - -cpuarchitecture=architecture.sh -nodename=name.sh -cpu=cpu.sh -kvm=kvm.rb diff --git a/src/im_mad/xen/im_xen.conf b/src/im_mad/xen/im_xen.conf deleted file mode 100644 index b86c8630a8..0000000000 --- a/src/im_mad/xen/im_xen.conf +++ /dev/null @@ -1,8 +0,0 @@ -#------------------------------------------------------------------------------- -# Probes for Xen hosts add as many monitorization sensors as you need -#------------------------------------------------------------------------------- - -cpuarchitecture=architecture.sh -nodename=name.sh -cpu=cpu.sh -xen=xen.rb From f289b6bb28de56435af474b52ab023e2a6d004b6 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Tue, 24 Aug 2010 16:44:42 +0200 Subject: [PATCH 03/13] Added VMM/KVM part of issue #307 --- install.sh | 95 +++++++++++----- share/etc/oned.conf | 14 +++ share/scripts/im/common.d/architecture.sh | 16 +++ share/scripts/im/common.d/cpu.sh | 16 +++ share/scripts/im/common.d/name.sh | 16 +++ share/scripts/im/run_probes | 16 +++ share/scripts/vmm/kvm/cancel | 23 ++++ share/scripts/vmm/kvm/deploy | 32 ++++++ share/scripts/vmm/kvm/kvmrc | 19 ++++ share/scripts/vmm/kvm/migrate | 24 ++++ share/scripts/vmm/kvm/poll | 62 +++++++++++ share/scripts/vmm/kvm/restore | 23 ++++ share/scripts/vmm/kvm/save | 25 +++++ share/scripts/vmm/kvm/shutdown | 48 ++++++++ share/scripts/vmm/xen/cancel | 23 ++++ share/scripts/vmm/xen/deploy | 49 +++++++++ share/scripts/vmm/xen/migrate | 24 ++++ share/scripts/vmm/xen/poll | 60 ++++++++++ share/scripts/vmm/xen/restore | 24 ++++ share/scripts/vmm/xen/save | 25 +++++ share/scripts/vmm/xen/shutdown | 42 +++++++ share/scripts/vmm/xen/xenrc | 28 +++++ src/im_mad/kvm/im_kvm.conf | 8 ++ src/im_mad/xen/im_xen.conf | 8 ++ src/vmm_mad/sh/one_vmm_sh | 38 +++++++ src/vmm_mad/sh/one_vmm_sh.rb | 128 ++++++++++++++++++++++ src/vmm_mad/sh/vmm_sh_kvm.conf | 18 +++ src/vmm_mad/sh/vmm_sh_xen.conf | 13 +++ src/vmm_mad/sh/vmm_shrc | 20 ++++ 29 files changed, 910 insertions(+), 27 deletions(-) create mode 100755 share/scripts/vmm/kvm/cancel create mode 100755 share/scripts/vmm/kvm/deploy create mode 100644 share/scripts/vmm/kvm/kvmrc create mode 100755 share/scripts/vmm/kvm/migrate create mode 100755 share/scripts/vmm/kvm/poll create mode 100755 share/scripts/vmm/kvm/restore create mode 100755 share/scripts/vmm/kvm/save create mode 100755 share/scripts/vmm/kvm/shutdown create mode 100755 share/scripts/vmm/xen/cancel create mode 100755 share/scripts/vmm/xen/deploy create mode 100755 share/scripts/vmm/xen/migrate create mode 100755 share/scripts/vmm/xen/poll create mode 100755 share/scripts/vmm/xen/restore create mode 100755 share/scripts/vmm/xen/save create mode 100755 share/scripts/vmm/xen/shutdown create mode 100644 share/scripts/vmm/xen/xenrc create mode 100644 src/im_mad/kvm/im_kvm.conf create mode 100644 src/im_mad/xen/im_xen.conf create mode 100755 src/vmm_mad/sh/one_vmm_sh create mode 100755 src/vmm_mad/sh/one_vmm_sh.rb create mode 100644 src/vmm_mad/sh/vmm_sh_kvm.conf create mode 100644 src/vmm_mad/sh/vmm_sh_xen.conf create mode 100644 src/vmm_mad/sh/vmm_shrc diff --git a/install.sh b/install.sh index d3ef2793a6..fff73f20a0 100755 --- a/install.sh +++ b/install.sh @@ -155,6 +155,7 @@ ETC_DIRS="$ETC_LOCATION/im_kvm \ $ETC_LOCATION/vmm_xen \ $ETC_LOCATION/vmm_ec2 \ $ETC_LOCATION/vmm_eh \ + $ETC_LOCATION/vmm_sh \ $ETC_LOCATION/tm_nfs \ $ETC_LOCATION/tm_ssh \ $ETC_LOCATION/tm_dummy \ @@ -169,6 +170,8 @@ LIB_DIRS="$LIB_LOCATION/remotes \ $LIB_LOCATION/remotes/im/common.d \ $LIB_LOCATION/remotes/im/kvm.d \ $LIB_LOCATION/remotes/im/xen.d \ + $LIB_LOCATION/remotes/vmm/xen \ + $LIB_LOCATION/remotes/vmm/kvm \ $LIB_LOCATION/ruby \ $LIB_LOCATION/ruby/OpenNebula \ $LIB_LOCATION/ruby/cloud/ \ @@ -215,19 +218,21 @@ INSTALL_FILES[6]="IM_PROBES_FILES:$LIB_LOCATION/remotes/im" INSTALL_FILES[7]="IM_PROBES_COMMON_FILES:$LIB_LOCATION/remotes/im/common.d" INSTALL_FILES[8]="IM_PROBES_KVM_FILES:$LIB_LOCATION/remotes/im/kvm.d" INSTALL_FILES[9]="IM_PROBES_XEN_FILES:$LIB_LOCATION/remotes/im/xen.d" -INSTALL_FILES[10]="NFS_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/nfs" -INSTALL_FILES[11]="SSH_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/ssh" -INSTALL_FILES[12]="DUMMY_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/dummy" -INSTALL_FILES[13]="LVM_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/lvm" -INSTALL_FILES[14]="EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples" -INSTALL_FILES[15]="TM_EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples/tm" -INSTALL_FILES[16]="HOOK_SHARE_FILES:$SHARE_LOCATION/hooks" -INSTALL_FILES[17]="COMMON_CLOUD_LIB_FILES:$LIB_LOCATION/ruby/cloud" -INSTALL_FILES[18]="ECO_LIB_FILES:$LIB_LOCATION/ruby/cloud/econe" -INSTALL_FILES[19]="ECO_LIB_VIEW_FILES:$LIB_LOCATION/ruby/cloud/econe/views" -INSTALL_FILES[20]="ECO_BIN_FILES:$BIN_LOCATION" -INSTALL_FILES[21]="OCCI_LIB_FILES:$LIB_LOCATION/ruby/cloud/occi" -INSTALL_FILES[22]="OCCI_BIN_FILES:$BIN_LOCATION" +INSTALL_FILES[10]="VMM_SH_KVM_SCRIPTS:$LIB_LOCATION/remotes/vmm/kvm" +INSTALL_FILES[11]="VMM_SH_XEN_SCRIPTS:$LIB_LOCATION/remotes/vmm/xen" +INSTALL_FILES[12]="NFS_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/nfs" +INSTALL_FILES[13]="SSH_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/ssh" +INSTALL_FILES[14]="DUMMY_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/dummy" +INSTALL_FILES[15]="LVM_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/lvm" +INSTALL_FILES[16]="EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples" +INSTALL_FILES[17]="TM_EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples/tm" +INSTALL_FILES[18]="HOOK_SHARE_FILES:$SHARE_LOCATION/hooks" +INSTALL_FILES[19]="COMMON_CLOUD_LIB_FILES:$LIB_LOCATION/ruby/cloud" +INSTALL_FILES[20]="ECO_LIB_FILES:$LIB_LOCATION/ruby/cloud/econe" +INSTALL_FILES[21]="ECO_LIB_VIEW_FILES:$LIB_LOCATION/ruby/cloud/econe/views" +INSTALL_FILES[22]="ECO_BIN_FILES:$BIN_LOCATION" +INSTALL_FILES[23]="OCCI_LIB_FILES:$LIB_LOCATION/ruby/cloud/occi" +INSTALL_FILES[24]="OCCI_BIN_FILES:$BIN_LOCATION" INSTALL_ECO_CLIENT_FILES[0]="COMMON_CLOUD_CLIENT_LIB_FILES:$LIB_LOCATION/ruby/cloud" INSTALL_ECO_CLIENT_FILES[1]="ECO_LIB_CLIENT_FILES:$LIB_LOCATION/ruby/cloud/econe" @@ -242,20 +247,21 @@ 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]="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]="TM_LVM_ETC_FILES:$ETC_LOCATION/tm_lvm" -INSTALL_ETC_FILES[13]="HM_ETC_FILES:$ETC_LOCATION/hm" -INSTALL_ETC_FILES[14]="AUTH_ETC_FILES:$ETC_LOCATION/auth" -INSTALL_ETC_FILES[15]="ECO_ETC_FILES:$ETC_LOCATION" -INSTALL_ETC_FILES[16]="ECO_ETC_TEMPLATE_FILES:$ETC_LOCATION/ec2query_templates" -INSTALL_ETC_FILES[17]="OCCI_ETC_FILES:$ETC_LOCATION" -INSTALL_ETC_FILES[18]="OCCI_ETC_TEMPLATE_FILES:$ETC_LOCATION/occi_templates" +INSTALL_ETC_FILES[5]="VMM_SH_ETC_FILES:$ETC_LOCATION/vmm_sh" +INSTALL_ETC_FILES[6]="IM_XEN_ETC_FILES:$ETC_LOCATION/im_xen" +INSTALL_ETC_FILES[7]="IM_KVM_ETC_FILES:$ETC_LOCATION/im_kvm" +INSTALL_ETC_FILES[8]="IM_EC2_ETC_FILES:$ETC_LOCATION/im_ec2" +INSTALL_ETC_FILES[9]="IM_EH_ETC_FILES:$ETC_LOCATION/im_eh" +INSTALL_ETC_FILES[10]="TM_NFS_ETC_FILES:$ETC_LOCATION/tm_nfs" +INSTALL_ETC_FILES[11]="TM_SSH_ETC_FILES:$ETC_LOCATION/tm_ssh" +INSTALL_ETC_FILES[12]="TM_DUMMY_ETC_FILES:$ETC_LOCATION/tm_dummy" +INSTALL_ETC_FILES[13]="TM_LVM_ETC_FILES:$ETC_LOCATION/tm_lvm" +INSTALL_ETC_FILES[14]="HM_ETC_FILES:$ETC_LOCATION/hm" +INSTALL_ETC_FILES[15]="AUTH_ETC_FILES:$ETC_LOCATION/auth" +INSTALL_ETC_FILES[16]="ECO_ETC_FILES:$ETC_LOCATION" +INSTALL_ETC_FILES[17]="ECO_ETC_TEMPLATE_FILES:$ETC_LOCATION/ec2query_templates" +INSTALL_ETC_FILES[18]="OCCI_ETC_FILES:$ETC_LOCATION" +INSTALL_ETC_FILES[19]="OCCI_ETC_TEMPLATE_FILES:$ETC_LOCATION/occi_templates" #------------------------------------------------------------------------------- # Binary files, to be installed under $BIN_LOCATION @@ -317,6 +323,7 @@ RUBY_OPENNEBULA_LIB_FILES="src/oca/ruby/OpenNebula/Host.rb \ src/oca/ruby/OpenNebula/Cluster.rb \ src/oca/ruby/OpenNebula/ClusterPool.rb \ src/oca/ruby/OpenNebula/XMLUtils.rb" + #------------------------------------------------------------------------------- # Driver executable files, to be installed under $LIB_LOCATION/mads #------------------------------------------------------------------------------- @@ -327,6 +334,8 @@ MADS_LIB_FILES="src/mad/sh/madcommon.sh \ src/vmm_mad/xen/one_vmm_xen \ src/vmm_mad/kvm/one_vmm_kvm.rb \ src/vmm_mad/kvm/one_vmm_kvm \ + src/vmm_mad/sh/one_vmm_sh.rb \ + src/vmm_mad/sh/one_vmm_sh \ src/vmm_mad/ec2/one_vmm_ec2.rb \ src/vmm_mad/ec2/one_vmm_ec2 \ src/vmm_mad/eh/one_vmm_eh.rb \ @@ -344,6 +353,32 @@ MADS_LIB_FILES="src/mad/sh/madcommon.sh \ src/authm_mad/one_auth_mad.rb \ src/authm_mad/one_auth_mad" +#------------------------------------------------------------------------------- +# VMM SH Driver KVM scripts, to be installed under $REMOTES_LOCATION/vmm/kvm +#------------------------------------------------------------------------------- + +VMM_SH_KVM_SCRIPTS="share/scripts/vmm/kvm/cancel \ + share/scripts/vmm/kvm/deploy \ + share/scripts/vmm/kvm/kvmrc \ + share/scripts/vmm/kvm/migrate \ + share/scripts/vmm/kvm/poll \ + share/scripts/vmm/kvm/restore \ + share/scripts/vmm/kvm/save \ + share/scripts/vmm/kvm/shutdown" + +#------------------------------------------------------------------------------- +# VMM SH Driver Xen scripts, to be installed under $REMOTES_LOCATION/vmm/xen +#------------------------------------------------------------------------------- + +VMM_SH_XEN_SCRIPTS="share/scripts/vmm/xen/cancel \ + share/scripts/vmm/xen/deploy \ + share/scripts/vmm/xen/xenrc \ + share/scripts/vmm/xen/migrate \ + share/scripts/vmm/xen/poll \ + share/scripts/vmm/xen/restore \ + share/scripts/vmm/xen/save \ + share/scripts/vmm/xen/shutdown" + #------------------------------------------------------------------------------- # Information Manager Probes, to be installed under $LIB_LOCATION/remotes #------------------------------------------------------------------------------- @@ -406,6 +441,7 @@ ETC_FILES="share/etc/oned.conf \ # - kvm, $ETC_LOCATION/vmm_kvm # - ec2, $ETC_LOCATION/vmm_ec2 # - eh, $ETC_LOCATION/vmm_eh +# - sh, $ETC_LOCATION/vmm_sh #------------------------------------------------------------------------------- VMM_XEN_ETC_FILES="src/vmm_mad/xen/vmm_xenrc \ @@ -420,6 +456,11 @@ VMM_EC2_ETC_FILES="src/vmm_mad/ec2/vmm_ec2rc \ VMM_EH_ETC_FILES="src/vmm_mad/eh/vmm_ehrc \ src/vmm_mad/eh/vmm_eh.conf" +VMM_SH_ETC_FILES="src/vmm_mad/sh/vmm_shrc \ + src/vmm_mad/sh/vmm_sh_kvm.conf \ + src/vmm_mad/sh/vmm_sh_xen.conf" + + #------------------------------------------------------------------------------- # Information drivers config. files, to be installed under $ETC_LOCATION # - xen, $ETC_LOCATION/im_xen diff --git a/share/etc/oned.conf b/share/etc/oned.conf index 8842859b99..18b6a03912 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -147,6 +147,20 @@ IM_MAD = [ # type : driver type, supported drivers: xen, kvm, xml #******************************************************************************* +#VM_MAD = [ +# name = "vmm_sh_kvm", +# executable = "one_vmm_sh", +# arguments = "kvm", +# default = "vmm_sh/vmm_sh_kvm.conf", +# type = "kvm" ] + +#VM_MAD = [ +# name = "vmm_sh_xen", +# executable = "one_vmm_sh", +# arguments = "xen", +# default = "vmm_sh/vmm_sh_xen.conf", +# type = "xen" ] + #VM_MAD = [ # name = "vmm_xen", # executable = "one_vmm_xen", diff --git a/share/scripts/im/common.d/architecture.sh b/share/scripts/im/common.d/architecture.sh index ef623381be..1565665945 100755 --- a/share/scripts/im/common.d/architecture.sh +++ b/share/scripts/im/common.d/architecture.sh @@ -1,3 +1,19 @@ #!/bin/sh +# -------------------------------------------------------------------------- # +# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + echo ARCH=`uname -m` diff --git a/share/scripts/im/common.d/cpu.sh b/share/scripts/im/common.d/cpu.sh index 6fd555c0c5..12bc9bea8e 100755 --- a/share/scripts/im/common.d/cpu.sh +++ b/share/scripts/im/common.d/cpu.sh @@ -1,5 +1,21 @@ #!/bin/sh +# -------------------------------------------------------------------------- # +# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + if [ -f /proc/cpuinfo ]; then echo -n "MODELNAME=\"" diff --git a/share/scripts/im/common.d/name.sh b/share/scripts/im/common.d/name.sh index 7cf919ce80..90611577a8 100755 --- a/share/scripts/im/common.d/name.sh +++ b/share/scripts/im/common.d/name.sh @@ -1,5 +1,21 @@ #!/bin/sh +# -------------------------------------------------------------------------- # +# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + echo HOSTNAME=`uname -n` diff --git a/share/scripts/im/run_probes b/share/scripts/im/run_probes index a24bee086c..f92bcd6564 100755 --- a/share/scripts/im/run_probes +++ b/share/scripts/im/run_probes @@ -1,5 +1,21 @@ #!/bin/bash +# -------------------------------------------------------------------------- # +# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + HYPERVISOR_DIR=$1.d SCRIPTS_DIR=`dirname $0` diff --git a/share/scripts/vmm/kvm/cancel b/share/scripts/vmm/kvm/cancel new file mode 100755 index 0000000000..ad708bd76a --- /dev/null +++ b/share/scripts/vmm/kvm/cancel @@ -0,0 +1,23 @@ +#!/bin/bash -e + +# -------------------------------------------------------------------------- # +# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +source $(dirname $0)/kvmrc + +deploy_id=$1 + +virsh --connect $LIBVIRT_URI destroy $deploy_id diff --git a/share/scripts/vmm/kvm/deploy b/share/scripts/vmm/kvm/deploy new file mode 100755 index 0000000000..b9bd265bbe --- /dev/null +++ b/share/scripts/vmm/kvm/deploy @@ -0,0 +1,32 @@ +#!/bin/bash -e + +# -------------------------------------------------------------------------- # +# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +source $(dirname $0)/kvmrc + +domain=$1 + +mkdir -p `dirname $domain` +cat > $domain + +data=`virsh --connect $LIBVIRT_URI create $domain` + +if [ "x$?" = "x0" ]; then + echo $data | sed 's/Domain //' | sed 's/ created from .*$//' +else + exit -1 +fi diff --git a/share/scripts/vmm/kvm/kvmrc b/share/scripts/vmm/kvm/kvmrc new file mode 100644 index 0000000000..0fc5d39ddd --- /dev/null +++ b/share/scripts/vmm/kvm/kvmrc @@ -0,0 +1,19 @@ +# -------------------------------------------------------------------------- # +# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +export LIBVIRT_URI=qemu:///system + +export QEMU_PROTOCOL=qemu diff --git a/share/scripts/vmm/kvm/migrate b/share/scripts/vmm/kvm/migrate new file mode 100755 index 0000000000..b56d8773a5 --- /dev/null +++ b/share/scripts/vmm/kvm/migrate @@ -0,0 +1,24 @@ +#!/bin/bash -e + +# -------------------------------------------------------------------------- # +# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +source $(dirname $0)/kvmrc + +deploy_id=$1 +dest_host=$2 + +virsh --connect $LIBVIRT_URI migrate --live $deploy_id $QEMU_PROTOCOL://$dest_host/system diff --git a/share/scripts/vmm/kvm/poll b/share/scripts/vmm/kvm/poll new file mode 100755 index 0000000000..98259ff197 --- /dev/null +++ b/share/scripts/vmm/kvm/poll @@ -0,0 +1,62 @@ +#!/bin/bash -e + +# -------------------------------------------------------------------------- # +# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +source $(dirname $0)/kvmrc + +# Execution example +# virsh dominfo one-108 | awk "`cat poll.awk`" | tr '\n' ' ' + +AWK_SCRIPT=' +BEGIN { FS=":" }; + +$1=="Used memory" { + split($2, data, " "); + print "USEDMEMORY=" data[1] +}; + +$1=="State" { + vstat=$2; + gsub(" ", "", vstat); + + if(vstat=="running" || + vstat=="blocked" || + vstat=="shutdown" || + vstat=="dying") + state="a"; + else if(vstat=="paused") state="p"; + else if(vstat=="crashed") state="c"; + else state="u"; + + print "STATUS=" state +} +' + +deploy_id=$1 + +virsh_cmd="virsh dominfo $deploy_id" +awk_cmd="awk \'$AWK_SCRIPT\'" + +info=`$virsh_cmd 2>/dev/null | awk "$AWK_SCRIPT"` + +echo $info + + +#virsh_info=`virsh dominfo $deploy_id` + + + diff --git a/share/scripts/vmm/kvm/restore b/share/scripts/vmm/kvm/restore new file mode 100755 index 0000000000..9a01b73333 --- /dev/null +++ b/share/scripts/vmm/kvm/restore @@ -0,0 +1,23 @@ +#!/bin/bash -e + +# -------------------------------------------------------------------------- # +# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +source $(dirname $0)/kvmrc + +file=$1 + +virsh --connect $LIBVIRT_URI restore $file diff --git a/share/scripts/vmm/kvm/save b/share/scripts/vmm/kvm/save new file mode 100755 index 0000000000..efd44274b7 --- /dev/null +++ b/share/scripts/vmm/kvm/save @@ -0,0 +1,25 @@ +#!/bin/bash -e + +# -------------------------------------------------------------------------- # +# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +source $(dirname $0)/kvmrc + +deploy_id=$1 +file=$2 + +touch $file +virsh --connect $LIBVIRT_URI save $deploy_id $file diff --git a/share/scripts/vmm/kvm/shutdown b/share/scripts/vmm/kvm/shutdown new file mode 100755 index 0000000000..393c587382 --- /dev/null +++ b/share/scripts/vmm/kvm/shutdown @@ -0,0 +1,48 @@ +#!/bin/bash -e + +# -------------------------------------------------------------------------- # +# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +source $(dirname $0)/kvmrc + +deploy_id=$1 + +POLL_INTERVAL=2 +TIMEOUT=20 + +virsh --connect $LIBVIRT_URI shutdown $deploy_id + +exit_code=$? + +if [ "$exit_code" != "0" ]; then + exit $exit_code +fi + +count=0 +while [ $(virsh --connect $LIBVIRT_URI dominfo $deploy_id > /dev/null 2>&1; echo $?) = "0" ] +do + sleep $POLL_INTERVAL + if [ "$count" -gt "$TIMEOUT" ] + then + echo "Timeout reached" >&2 + exit 1 + fi + let count=count+$POLL_INTERVAL +done + +sleep 4 + +exit 0 diff --git a/share/scripts/vmm/xen/cancel b/share/scripts/vmm/xen/cancel new file mode 100755 index 0000000000..6d6835f435 --- /dev/null +++ b/share/scripts/vmm/xen/cancel @@ -0,0 +1,23 @@ +#!/bin/bash -e + +# -------------------------------------------------------------------------- # +# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +source $(dirname $0)/xenrc + +deploy_id=$1 + +$XM_CANCEL $deploy_id diff --git a/share/scripts/vmm/xen/deploy b/share/scripts/vmm/xen/deploy new file mode 100755 index 0000000000..2b9a13a8e1 --- /dev/null +++ b/share/scripts/vmm/xen/deploy @@ -0,0 +1,49 @@ +#!/bin/bash -e + +# -------------------------------------------------------------------------- # +# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +source $(dirname $0)/xenrc + +function error_exit() { + exit_code=$1 + if [ "x$exit_code" != "x0" ]; then + exit $exit_code + fi +} + +domain=$1 + +output=`$XM_CREATE $domain` + +error_exit $? + +domain_name=`echo $output | grep 'Started domain' | sed 's/^.*Started domain //' | tr -d '\n'` + +out=`grep -e '^\#O CPU_CREDITS =' < $domain` + +if [ "x$?" != "x0" ]; then + credits=`echo $out | cut -d= -f2 | tr -d ' '` + + name=`grep -e '^name =' < $domain | cut -d= -f2 | tr -d ' '` + + $XM_CREDITS -d $name -w $credits + + error_exit $? +fi + +echo $domain_name + diff --git a/share/scripts/vmm/xen/migrate b/share/scripts/vmm/xen/migrate new file mode 100755 index 0000000000..0996202b43 --- /dev/null +++ b/share/scripts/vmm/xen/migrate @@ -0,0 +1,24 @@ +#!/bin/bash -e + +# -------------------------------------------------------------------------- # +# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +source $(dirname $0)/xenrc + +deploy_id=$1 +dest_host=$2 + +$XM_MIGRATE $deploy_id $dest_host diff --git a/share/scripts/vmm/xen/poll b/share/scripts/vmm/xen/poll new file mode 100755 index 0000000000..eb5ea10f87 --- /dev/null +++ b/share/scripts/vmm/xen/poll @@ -0,0 +1,60 @@ +#!/bin/bash -e + +# -------------------------------------------------------------------------- # +# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +source $(dirname $0)/xenrc + +INFO_MEM=4 +INFO_CPU=3 +INFO_NETTX=10 +INFO_NETRX=11 +INFO_STATE=1 + + +AWK_SCRIPT=' +{ + mem=$5; + cpu=$4; + nettx=$11; + netrx=$12; + stat=$2 + gsub("-", "", stat); + + if(stat=="r" || + stat=="b" || + stat=="s" || + stat=="d") + state="a"; + else if(stat=="p") state="a"; + else if(stat=="c") state="c"; + else state="u"; + + print "USEDMEMORY=" mem " USEDCPU=" cpu " NETTX=" nettx " NETRX=" netrx " STATE=" state +} +' + +function get_info() { + $XM_POLL | egrep "^ *(migrating-)?$1 " | tail -1 | sed 's/^ *//' | sed 's/no limit/no_limit/' +} + + + +info=`get_info $1 2>/dev/null | awk "$AWK_SCRIPT"` + +echo $info + + diff --git a/share/scripts/vmm/xen/restore b/share/scripts/vmm/xen/restore new file mode 100755 index 0000000000..a35c236d8b --- /dev/null +++ b/share/scripts/vmm/xen/restore @@ -0,0 +1,24 @@ +#!/bin/bash -e + +# -------------------------------------------------------------------------- # +# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +source $(dirname $0)/xenrc + +file=$1 + +$XM_RESTORE $file + diff --git a/share/scripts/vmm/xen/save b/share/scripts/vmm/xen/save new file mode 100755 index 0000000000..46c9c5237a --- /dev/null +++ b/share/scripts/vmm/xen/save @@ -0,0 +1,25 @@ +#!/bin/bash -e + +# -------------------------------------------------------------------------- # +# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +source $(dirname $0)/xenrc + +deploy_id=$1 +file=$2 + +$XM_SAVE $deploy_id $file + diff --git a/share/scripts/vmm/xen/shutdown b/share/scripts/vmm/xen/shutdown new file mode 100755 index 0000000000..ee73b12bd0 --- /dev/null +++ b/share/scripts/vmm/xen/shutdown @@ -0,0 +1,42 @@ +#!/bin/bash -e + +# -------------------------------------------------------------------------- # +# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +source $(dirname $0)/xenrc + +deploy_id=$1 + +function gdm { + $XM_LIST | grep "$deploy_id " +} + +$XM_SHUTDOWN $deploy_id || exit -1 + +OUT=$(gdm) + +while [ -n "$OUT" -a $(echo $OUT | awk '{print $5}') != "---s--" ]; do + sleep 1 + OUT=$(gdm) +done + +OUT=$(gdm) + +if [ -n "$OUT" ]; then + $XM_CANCEL "$deploy_id" +fi +sleep 2 + diff --git a/share/scripts/vmm/xen/xenrc b/share/scripts/vmm/xen/xenrc new file mode 100644 index 0000000000..0715fac7e3 --- /dev/null +++ b/share/scripts/vmm/xen/xenrc @@ -0,0 +1,28 @@ +# -------------------------------------------------------------------------- # +# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +export XM_PATH="/usr/sbin/xm" +export XM_CANCEL="sudo $XM_PATH destroy" +export XM_CREATE="sudo $XM_PATH create" +export XM_CREDITS="sudo $XM_PATH sched-cred" +export XM_MIGRATE="sudo $XM_PATH migrate -l" +export XM_SAVE="sudo $XM_PATH save" +export XM_RESTORE="sudo $XM_PATH restore" +export XM_LIST="sudo $XM_PATH list" +export XM_SHUTDOWN="sudo $XM_PATH shutdown" +export XM_POLL="sudo /usr/sbin/xentop -bi2" + + diff --git a/src/im_mad/kvm/im_kvm.conf b/src/im_mad/kvm/im_kvm.conf new file mode 100644 index 0000000000..a891f402c6 --- /dev/null +++ b/src/im_mad/kvm/im_kvm.conf @@ -0,0 +1,8 @@ +#------------------------------------------------------------------------------- +# Probes for KVM hosts add as many monitorization sensors as you need +#------------------------------------------------------------------------------- + +cpuarchitecture=architecture.sh +nodename=name.sh +cpu=cpu.sh +kvm=kvm.rb diff --git a/src/im_mad/xen/im_xen.conf b/src/im_mad/xen/im_xen.conf new file mode 100644 index 0000000000..b86c8630a8 --- /dev/null +++ b/src/im_mad/xen/im_xen.conf @@ -0,0 +1,8 @@ +#------------------------------------------------------------------------------- +# Probes for Xen hosts add as many monitorization sensors as you need +#------------------------------------------------------------------------------- + +cpuarchitecture=architecture.sh +nodename=name.sh +cpu=cpu.sh +xen=xen.rb diff --git a/src/vmm_mad/sh/one_vmm_sh b/src/vmm_mad/sh/one_vmm_sh new file mode 100755 index 0000000000..1d278edc84 --- /dev/null +++ b/src/vmm_mad/sh/one_vmm_sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# -------------------------------------------------------------------------- # +# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +if [ -z "${ONE_LOCATION}" ]; then + DRIVERRC=/etc/one/vmm_sh/vmm_shrc + MADCOMMON=/usr/lib/one/mads/madcommon.sh + VAR_LOCATION=/var/lib/one +else + DRIVERRC=$ONE_LOCATION/etc/vmm_sh/vmm_shrc + 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 $* diff --git a/src/vmm_mad/sh/one_vmm_sh.rb b/src/vmm_mad/sh/one_vmm_sh.rb new file mode 100755 index 0000000000..7b243b0438 --- /dev/null +++ b/src/vmm_mad/sh/one_vmm_sh.rb @@ -0,0 +1,128 @@ +#!/usr/bin/env ruby + +# -------------------------------------------------------------------------- # +# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +# ---------------------------------------------------------------------------- # +# Set up the environment for the driver # +# ---------------------------------------------------------------------------- # + +ONE_LOCATION = ENV["ONE_LOCATION"] + +if !ONE_LOCATION + RUBY_LIB_LOCATION = "/usr/lib/one/ruby" + ETC_LOCATION = "/etc/one/" +else + RUBY_LIB_LOCATION = ONE_LOCATION + "/lib/ruby" + ETC_LOCATION = ONE_LOCATION + "/etc/" +end + +$: << RUBY_LIB_LOCATION + +require "VirtualMachineDriver" + +# ---------------------------------------------------------------------------- # +# The main class for the Sh driver # +# ---------------------------------------------------------------------------- # +class ShDriver < VirtualMachineDriver + # ------------------------------------------------------------------------ # + # ShDriver constructor # + # ------------------------------------------------------------------------ # + def initialize(hypervisor, remote_dir) + super(15,true) + @remote_dir = remote_dir + @hypervisor = hypervisor + end + + # ------------------------------------------------------------------------ # + # DEPLOY action, sends the deployment file to remote host # + # ------------------------------------------------------------------------ # + def deploy(id, host, remote_dfile, not_used) + local_dfile = get_local_deployment_file(remote_dfile) + + if !local_dfile || File.zero?(local_dfile) + send_message(ACTION[:deploy],RESULT[:failure],id, + "Can not open deployment file #{local_dfile}") + return + end + + tmp = File.new(local_dfile) + domain = tmp.read + tmp.close() + + cmd = "#{@remote_dir}/vmm/#{@hypervisor}/deploy #{remote_dfile}" + + deploy_exe = SSHCommand.run(cmd, host, log_method(id), domain) + + + if deploy_exe.code != 0 + send_message(ACTION[:deploy],RESULT[:failure],id) + else + send_message(ACTION[:deploy],RESULT[:success],id,deploy_exe.stdout) + end + end + + # ------------------------------------------------------------------------ # + # Basic Domain Management Operations # + # ------------------------------------------------------------------------ # + def shutdown(id, host, deploy_id, not_used) + ssh_action("#{@remote_dir}/vmm/#{@hypervisor}/shutdown #{deploy_id}", + id, host, :shutdown) + end + + def cancel(id, host, deploy_id, not_used) + ssh_action("#{@remote_dir}/vmm/#{@hypervisor}/cancel #{deploy_id}", + id, host, :cancel) + end + + def save(id, host, deploy_id, file) + ssh_action("#{@remote_dir}/vmm/#{@hypervisor}/save #{deploy_id} #{file}", + id, host, :save) + end + + def restore(id, host, deploy_id, file) + ssh_action("#{@remote_dir}/vmm/#{@hypervisor}/restore #{file}", + id, host, :restore) + end + + def migrate(id, host, deploy_id, dest_host) + ssh_action("#{@remote_dir}/vmm/#{@hypervisor}/migrate #{deploy_id} #{dest_host}", + id, host, :migrate) + end + + def poll(id, host, deploy_id, not_used) + cmd = "#{@remote_dir}/vmm/#{@hypervisor}/poll #{deploy_id}" + + poll_exe = SSHCommand.run(cmd, host, log_method(id)) + + if poll_exe.code != 0 + send_message(ACTION[:poll],RESULT[:failure],id) + else + send_message(ACTION[:poll],RESULT[:success],id,poll_exe.stdout) + end + end +end + +# ---------------------------------------------------------------------------- # +# ShDriver Main program +# ---------------------------------------------------------------------------- # +remote_dir = ENV["VMM_REMOTE_DIR"] +remote_dir = "/tmp/one-im" if !remote_dir + +hypervisor = ARGV[0] + +sh_driver = ShDriver.new(hypervisor, remote_dir) +sh_driver.start_driver diff --git a/src/vmm_mad/sh/vmm_sh_kvm.conf b/src/vmm_mad/sh/vmm_sh_kvm.conf new file mode 100644 index 0000000000..7ba58ee1f4 --- /dev/null +++ b/src/vmm_mad/sh/vmm_sh_kvm.conf @@ -0,0 +1,18 @@ +# Default configuration attributes for the KVM driver +# (all domains will use these values as defaults) +# Valid atributes are: +# - os [kernel,initrd,boot,root,kernel_cmd] +# - memory +# - cpu +# - vcpu +# - features [acpi, pae] + +#VCPU = 1 +#MEMORY = 128 +#OS = [ kernel="/vmlinuz", initrd="/initrd.img", root="sda1", boot=hd,kernel_cmd="ro"] +OS = [ boot = "hd" ] + +FEATURES = [ + PAE=no, + ACPI=yes +] diff --git a/src/vmm_mad/sh/vmm_sh_xen.conf b/src/vmm_mad/sh/vmm_sh_xen.conf new file mode 100644 index 0000000000..573d8209fa --- /dev/null +++ b/src/vmm_mad/sh/vmm_sh_xen.conf @@ -0,0 +1,13 @@ +# Default configuration attributes for the Xen driver +# (all domains will use these values as defaults) +# Valid atributes: +# - credit +# - os [kernel,initrd,root,kernel_cmd] +# - memory +# - vcpu + +#VCPU = 1 +#MEMORY = 128 +#OS = [ kernel="/vmlinuz", initrd="/initrd.img", root="sda1", kernel_cmd="ro" ] +CREDIT = 256 + diff --git a/src/vmm_mad/sh/vmm_shrc b/src/vmm_mad/sh/vmm_shrc new file mode 100644 index 0000000000..78489687c0 --- /dev/null +++ b/src/vmm_mad/sh/vmm_shrc @@ -0,0 +1,20 @@ +# -------------------------------------------------------------------------- # +# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +# To change the directory where the VMM scripts are copied on the remote node +# uncomment and change the path of IM_REMOTE_DIR +# +#VMM_REMOTE_DIR=/tmp/ne_im_scripts From e1931a40473f8f7f0a89160b45bf0caf5785b79e Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Tue, 24 Aug 2010 18:40:44 +0200 Subject: [PATCH 04/13] Removed debugging info for IM driver. Fixed bug in xen deploy script (#307) --- share/scripts/vmm/xen/deploy | 3 +++ src/im_mad/im_ssh/one_im_ssh.rb | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/share/scripts/vmm/xen/deploy b/share/scripts/vmm/xen/deploy index 2b9a13a8e1..06ef8dce32 100755 --- a/share/scripts/vmm/xen/deploy +++ b/share/scripts/vmm/xen/deploy @@ -27,6 +27,9 @@ function error_exit() { domain=$1 +mkdir -p `dirname $domain` +cat > $domain + output=`$XM_CREATE $domain` error_exit $? diff --git a/src/im_mad/im_ssh/one_im_ssh.rb b/src/im_mad/im_ssh/one_im_ssh.rb index 408fe9120b..d517e3d6f4 100755 --- a/src/im_mad/im_ssh/one_im_ssh.rb +++ b/src/im_mad/im_ssh/one_im_ssh.rb @@ -57,9 +57,7 @@ class InformationManager < OpenNebulaDriver # Execute the run_probes in the remote host #--------------------------------------------------------------------------- def action_monitor(number, host, do_update) - STDERR.puts Time.now.to_s + ": do_update=" +do_update.inspect if do_update == "1" - STDERR.puts Time.now.to_s + ": Doing rsync" sync_cmd = "rsync -Laz #{REMOTES_LOCATION} #{host}:#{@remote_dir}" LocalCommand.run(sync_cmd) else From c5ae345e7bd3d2e3a9d31829ebfcfa77d14c54ef Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Wed, 25 Aug 2010 12:54:11 +0200 Subject: [PATCH 05/13] added libvirt readonly for readonly calls (#307) --- share/scripts/im/kvm.d/kvm.rb | 2 +- share/scripts/vmm/kvm/poll | 11 +---------- share/scripts/vmm/kvm/shutdown | 2 +- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/share/scripts/im/kvm.d/kvm.rb b/share/scripts/im/kvm.d/kvm.rb index 0b7c664d7b..6228de8c43 100755 --- a/share/scripts/im/kvm.d/kvm.rb +++ b/share/scripts/im/kvm.d/kvm.rb @@ -21,7 +21,7 @@ # TODO : use virsh freecell when available ###### -nodeinfo_text = `virsh -c qemu:///system nodeinfo` +nodeinfo_text = `virsh -c qemu:///system nodeinfo --readonly` nodeinfo_text.split(/\n/).each{|line| if line.match('^CPU\(s\)') diff --git a/share/scripts/vmm/kvm/poll b/share/scripts/vmm/kvm/poll index 98259ff197..33ec0a44f0 100755 --- a/share/scripts/vmm/kvm/poll +++ b/share/scripts/vmm/kvm/poll @@ -18,9 +18,6 @@ source $(dirname $0)/kvmrc -# Execution example -# virsh dominfo one-108 | awk "`cat poll.awk`" | tr '\n' ' ' - AWK_SCRIPT=' BEGIN { FS=":" }; @@ -48,15 +45,9 @@ $1=="State" { deploy_id=$1 -virsh_cmd="virsh dominfo $deploy_id" +virsh_cmd="virsh --connect $LIBVIRT_URI --readonly dominfo $deploy_id" awk_cmd="awk \'$AWK_SCRIPT\'" info=`$virsh_cmd 2>/dev/null | awk "$AWK_SCRIPT"` echo $info - - -#virsh_info=`virsh dominfo $deploy_id` - - - diff --git a/share/scripts/vmm/kvm/shutdown b/share/scripts/vmm/kvm/shutdown index 393c587382..53d84d25d1 100755 --- a/share/scripts/vmm/kvm/shutdown +++ b/share/scripts/vmm/kvm/shutdown @@ -32,7 +32,7 @@ if [ "$exit_code" != "0" ]; then fi count=0 -while [ $(virsh --connect $LIBVIRT_URI dominfo $deploy_id > /dev/null 2>&1; echo $?) = "0" ] +while [ $(virsh --connect $LIBVIRT_URI --readonly dominfo $deploy_id > /dev/null 2>&1; echo $?) = "0" ] do sleep $POLL_INTERVAL if [ "$count" -gt "$TIMEOUT" ] From 585ab84862b7e964649079633206fb6f7899bb10 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Sat, 28 Aug 2010 00:19:52 +0200 Subject: [PATCH 06/13] feature #307: Get driver messages when an action succeeds --- src/authm/AuthManagerDriver.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/authm/AuthManagerDriver.cc b/src/authm/AuthManagerDriver.cc index b45d42cda9..d37e07fd57 100644 --- a/src/authm/AuthManagerDriver.cc +++ b/src/authm/AuthManagerDriver.cc @@ -100,9 +100,10 @@ void AuthManagerDriver::protocol( else return; + getline(is,info); + if (action == "LOG") { - getline(is,info); NebulaLog::log("AuM",Log::INFO,info.c_str()); } else if (result == "SUCCESS") @@ -111,7 +112,6 @@ void AuthManagerDriver::protocol( } else { - getline(is,info); authm->notify_request(id,false,info); } From 1cf52c536837f58e3f70eed9c5074f006f0824af Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Mon, 30 Aug 2010 12:41:25 +0200 Subject: [PATCH 07/13] feature #307: modified default probe path --- src/im_mad/im_ssh/one_im_ssh.rb | 2 +- src/vmm_mad/sh/one_vmm_sh.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/im_mad/im_ssh/one_im_ssh.rb b/src/im_mad/im_ssh/one_im_ssh.rb index d517e3d6f4..0ecdb503d2 100755 --- a/src/im_mad/im_ssh/one_im_ssh.rb +++ b/src/im_mad/im_ssh/one_im_ssh.rb @@ -83,7 +83,7 @@ end #------------------------------------------------------------------------------- remote_dir = ENV["IM_REMOTE_DIR"] -remote_dir = "/tmp/one-im" if !remote_dir +remote_dir = "/tmp/one" if !remote_dir hypervisor = ARGV[0]||'' diff --git a/src/vmm_mad/sh/one_vmm_sh.rb b/src/vmm_mad/sh/one_vmm_sh.rb index 7b243b0438..44b8ee6135 100755 --- a/src/vmm_mad/sh/one_vmm_sh.rb +++ b/src/vmm_mad/sh/one_vmm_sh.rb @@ -120,7 +120,7 @@ end # ShDriver Main program # ---------------------------------------------------------------------------- # remote_dir = ENV["VMM_REMOTE_DIR"] -remote_dir = "/tmp/one-im" if !remote_dir +remote_dir = "/tmp/one" if !remote_dir hypervisor = ARGV[0] From be58d737effe3192bf21d279de7c17782061ee32 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Mon, 30 Aug 2010 13:00:11 +0200 Subject: [PATCH 08/13] feature-307: moved scripts to src tree --- install.sh | 44 +++++++++---------- .../im_mad/remotes}/common.d/architecture.sh | 0 .../im => src/im_mad/remotes}/common.d/cpu.sh | 0 .../im_mad/remotes}/common.d/name.sh | 0 .../im => src/im_mad/remotes}/kvm.d/kvm.rb | 0 .../im => src/im_mad/remotes}/run_probes | 0 .../im => src/im_mad/remotes}/xen.d/xen.rb | 0 .../vmm => src/vmm_mad/remotes}/kvm/cancel | 0 .../vmm => src/vmm_mad/remotes}/kvm/deploy | 0 .../vmm => src/vmm_mad/remotes}/kvm/kvmrc | 0 .../vmm => src/vmm_mad/remotes}/kvm/migrate | 0 .../vmm => src/vmm_mad/remotes}/kvm/poll | 0 .../vmm => src/vmm_mad/remotes}/kvm/restore | 0 .../vmm => src/vmm_mad/remotes}/kvm/save | 0 .../vmm => src/vmm_mad/remotes}/kvm/shutdown | 0 .../vmm => src/vmm_mad/remotes}/xen/cancel | 0 .../vmm => src/vmm_mad/remotes}/xen/deploy | 0 .../vmm => src/vmm_mad/remotes}/xen/migrate | 0 .../vmm => src/vmm_mad/remotes}/xen/poll | 0 .../vmm => src/vmm_mad/remotes}/xen/restore | 0 .../vmm => src/vmm_mad/remotes}/xen/save | 0 .../vmm => src/vmm_mad/remotes}/xen/shutdown | 0 .../vmm => src/vmm_mad/remotes}/xen/xenrc | 0 23 files changed, 22 insertions(+), 22 deletions(-) rename {share/scripts/im => src/im_mad/remotes}/common.d/architecture.sh (100%) rename {share/scripts/im => src/im_mad/remotes}/common.d/cpu.sh (100%) rename {share/scripts/im => src/im_mad/remotes}/common.d/name.sh (100%) rename {share/scripts/im => src/im_mad/remotes}/kvm.d/kvm.rb (100%) rename {share/scripts/im => src/im_mad/remotes}/run_probes (100%) rename {share/scripts/im => src/im_mad/remotes}/xen.d/xen.rb (100%) rename {share/scripts/vmm => src/vmm_mad/remotes}/kvm/cancel (100%) rename {share/scripts/vmm => src/vmm_mad/remotes}/kvm/deploy (100%) rename {share/scripts/vmm => src/vmm_mad/remotes}/kvm/kvmrc (100%) rename {share/scripts/vmm => src/vmm_mad/remotes}/kvm/migrate (100%) rename {share/scripts/vmm => src/vmm_mad/remotes}/kvm/poll (100%) rename {share/scripts/vmm => src/vmm_mad/remotes}/kvm/restore (100%) rename {share/scripts/vmm => src/vmm_mad/remotes}/kvm/save (100%) rename {share/scripts/vmm => src/vmm_mad/remotes}/kvm/shutdown (100%) rename {share/scripts/vmm => src/vmm_mad/remotes}/xen/cancel (100%) rename {share/scripts/vmm => src/vmm_mad/remotes}/xen/deploy (100%) rename {share/scripts/vmm => src/vmm_mad/remotes}/xen/migrate (100%) rename {share/scripts/vmm => src/vmm_mad/remotes}/xen/poll (100%) rename {share/scripts/vmm => src/vmm_mad/remotes}/xen/restore (100%) rename {share/scripts/vmm => src/vmm_mad/remotes}/xen/save (100%) rename {share/scripts/vmm => src/vmm_mad/remotes}/xen/shutdown (100%) rename {share/scripts/vmm => src/vmm_mad/remotes}/xen/xenrc (100%) diff --git a/install.sh b/install.sh index fff73f20a0..b13e46ecc8 100755 --- a/install.sh +++ b/install.sh @@ -357,41 +357,41 @@ MADS_LIB_FILES="src/mad/sh/madcommon.sh \ # VMM SH Driver KVM scripts, to be installed under $REMOTES_LOCATION/vmm/kvm #------------------------------------------------------------------------------- -VMM_SH_KVM_SCRIPTS="share/scripts/vmm/kvm/cancel \ - share/scripts/vmm/kvm/deploy \ - share/scripts/vmm/kvm/kvmrc \ - share/scripts/vmm/kvm/migrate \ - share/scripts/vmm/kvm/poll \ - share/scripts/vmm/kvm/restore \ - share/scripts/vmm/kvm/save \ - share/scripts/vmm/kvm/shutdown" +VMM_SH_KVM_SCRIPTS="src/vmm_mad/remotes/kvm/cancel \ + src/vmm_mad/remotes/kvm/deploy \ + src/vmm_mad/remotes/kvm/kvmrc \ + src/vmm_mad/remotes/kvm/migrate \ + src/vmm_mad/remotes/kvm/poll \ + src/vmm_mad/remotes/kvm/restore \ + src/vmm_mad/remotes/kvm/save \ + src/vmm_mad/remotes/kvm/shutdown" #------------------------------------------------------------------------------- # VMM SH Driver Xen scripts, to be installed under $REMOTES_LOCATION/vmm/xen #------------------------------------------------------------------------------- -VMM_SH_XEN_SCRIPTS="share/scripts/vmm/xen/cancel \ - share/scripts/vmm/xen/deploy \ - share/scripts/vmm/xen/xenrc \ - share/scripts/vmm/xen/migrate \ - share/scripts/vmm/xen/poll \ - share/scripts/vmm/xen/restore \ - share/scripts/vmm/xen/save \ - share/scripts/vmm/xen/shutdown" +VMM_SH_XEN_SCRIPTS="src/vmm_mad/remotes/xen/cancel \ + src/vmm_mad/remotes/xen/deploy \ + src/vmm_mad/remotes/xen/xenrc \ + src/vmm_mad/remotes/xen/migrate \ + src/vmm_mad/remotes/xen/poll \ + src/vmm_mad/remotes/xen/restore \ + src/vmm_mad/remotes/xen/save \ + src/vmm_mad/remotes/xen/shutdown" #------------------------------------------------------------------------------- # Information Manager Probes, to be installed under $LIB_LOCATION/remotes #------------------------------------------------------------------------------- -IM_PROBES_FILES="share/scripts/im/run_probes" +IM_PROBES_FILES="src/im_mad/remotes/run_probes" -IM_PROBES_COMMON_FILES="share/scripts/im/common.d/architecture.sh \ - share/scripts/im/common.d/cpu.sh \ - share/scripts/im/common.d/name.sh" +IM_PROBES_COMMON_FILES="src/im_mad/remotes/common.d/architecture.sh \ + src/im_mad/remotes/common.d/cpu.sh \ + src/im_mad/remotes/common.d/name.sh" -IM_PROBES_XEN_FILES="share/scripts/im/xen.d/xen.rb" +IM_PROBES_XEN_FILES="src/im_mad/remotes/xen.d/xen.rb" -IM_PROBES_KVM_FILES="share/scripts/im/kvm.d/kvm.rb" +IM_PROBES_KVM_FILES="src/im_mad/remotes/kvm.d/kvm.rb" #------------------------------------------------------------------------------- diff --git a/share/scripts/im/common.d/architecture.sh b/src/im_mad/remotes/common.d/architecture.sh similarity index 100% rename from share/scripts/im/common.d/architecture.sh rename to src/im_mad/remotes/common.d/architecture.sh diff --git a/share/scripts/im/common.d/cpu.sh b/src/im_mad/remotes/common.d/cpu.sh similarity index 100% rename from share/scripts/im/common.d/cpu.sh rename to src/im_mad/remotes/common.d/cpu.sh diff --git a/share/scripts/im/common.d/name.sh b/src/im_mad/remotes/common.d/name.sh similarity index 100% rename from share/scripts/im/common.d/name.sh rename to src/im_mad/remotes/common.d/name.sh diff --git a/share/scripts/im/kvm.d/kvm.rb b/src/im_mad/remotes/kvm.d/kvm.rb similarity index 100% rename from share/scripts/im/kvm.d/kvm.rb rename to src/im_mad/remotes/kvm.d/kvm.rb diff --git a/share/scripts/im/run_probes b/src/im_mad/remotes/run_probes similarity index 100% rename from share/scripts/im/run_probes rename to src/im_mad/remotes/run_probes diff --git a/share/scripts/im/xen.d/xen.rb b/src/im_mad/remotes/xen.d/xen.rb similarity index 100% rename from share/scripts/im/xen.d/xen.rb rename to src/im_mad/remotes/xen.d/xen.rb diff --git a/share/scripts/vmm/kvm/cancel b/src/vmm_mad/remotes/kvm/cancel similarity index 100% rename from share/scripts/vmm/kvm/cancel rename to src/vmm_mad/remotes/kvm/cancel diff --git a/share/scripts/vmm/kvm/deploy b/src/vmm_mad/remotes/kvm/deploy similarity index 100% rename from share/scripts/vmm/kvm/deploy rename to src/vmm_mad/remotes/kvm/deploy diff --git a/share/scripts/vmm/kvm/kvmrc b/src/vmm_mad/remotes/kvm/kvmrc similarity index 100% rename from share/scripts/vmm/kvm/kvmrc rename to src/vmm_mad/remotes/kvm/kvmrc diff --git a/share/scripts/vmm/kvm/migrate b/src/vmm_mad/remotes/kvm/migrate similarity index 100% rename from share/scripts/vmm/kvm/migrate rename to src/vmm_mad/remotes/kvm/migrate diff --git a/share/scripts/vmm/kvm/poll b/src/vmm_mad/remotes/kvm/poll similarity index 100% rename from share/scripts/vmm/kvm/poll rename to src/vmm_mad/remotes/kvm/poll diff --git a/share/scripts/vmm/kvm/restore b/src/vmm_mad/remotes/kvm/restore similarity index 100% rename from share/scripts/vmm/kvm/restore rename to src/vmm_mad/remotes/kvm/restore diff --git a/share/scripts/vmm/kvm/save b/src/vmm_mad/remotes/kvm/save similarity index 100% rename from share/scripts/vmm/kvm/save rename to src/vmm_mad/remotes/kvm/save diff --git a/share/scripts/vmm/kvm/shutdown b/src/vmm_mad/remotes/kvm/shutdown similarity index 100% rename from share/scripts/vmm/kvm/shutdown rename to src/vmm_mad/remotes/kvm/shutdown diff --git a/share/scripts/vmm/xen/cancel b/src/vmm_mad/remotes/xen/cancel similarity index 100% rename from share/scripts/vmm/xen/cancel rename to src/vmm_mad/remotes/xen/cancel diff --git a/share/scripts/vmm/xen/deploy b/src/vmm_mad/remotes/xen/deploy similarity index 100% rename from share/scripts/vmm/xen/deploy rename to src/vmm_mad/remotes/xen/deploy diff --git a/share/scripts/vmm/xen/migrate b/src/vmm_mad/remotes/xen/migrate similarity index 100% rename from share/scripts/vmm/xen/migrate rename to src/vmm_mad/remotes/xen/migrate diff --git a/share/scripts/vmm/xen/poll b/src/vmm_mad/remotes/xen/poll similarity index 100% rename from share/scripts/vmm/xen/poll rename to src/vmm_mad/remotes/xen/poll diff --git a/share/scripts/vmm/xen/restore b/src/vmm_mad/remotes/xen/restore similarity index 100% rename from share/scripts/vmm/xen/restore rename to src/vmm_mad/remotes/xen/restore diff --git a/share/scripts/vmm/xen/save b/src/vmm_mad/remotes/xen/save similarity index 100% rename from share/scripts/vmm/xen/save rename to src/vmm_mad/remotes/xen/save diff --git a/share/scripts/vmm/xen/shutdown b/src/vmm_mad/remotes/xen/shutdown similarity index 100% rename from share/scripts/vmm/xen/shutdown rename to src/vmm_mad/remotes/xen/shutdown diff --git a/share/scripts/vmm/xen/xenrc b/src/vmm_mad/remotes/xen/xenrc similarity index 100% rename from share/scripts/vmm/xen/xenrc rename to src/vmm_mad/remotes/xen/xenrc From 87f71392d5645115f617730c03aa447892233fc1 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Mon, 30 Aug 2010 16:14:26 +0200 Subject: [PATCH 09/13] feature-307: virsh does not support readonly for nodeinfo --- src/im_mad/remotes/kvm.d/kvm.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/im_mad/remotes/kvm.d/kvm.rb b/src/im_mad/remotes/kvm.d/kvm.rb index 6228de8c43..0b7c664d7b 100755 --- a/src/im_mad/remotes/kvm.d/kvm.rb +++ b/src/im_mad/remotes/kvm.d/kvm.rb @@ -21,7 +21,7 @@ # TODO : use virsh freecell when available ###### -nodeinfo_text = `virsh -c qemu:///system nodeinfo --readonly` +nodeinfo_text = `virsh -c qemu:///system nodeinfo` nodeinfo_text.split(/\n/).each{|line| if line.match('^CPU\(s\)') From b953ffea366a02c1e2bc2dfeda05b29292e60054 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Mon, 30 Aug 2010 16:34:08 +0200 Subject: [PATCH 10/13] feature-307: onehost sync --- src/cli/onehost | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/cli/onehost b/src/cli/onehost index f4f26b83f9..7d49757a36 100755 --- a/src/cli/onehost +++ b/src/cli/onehost @@ -187,6 +187,9 @@ Commands: * top (Lists hosts continuously) onehost top +* sync (synchronizes probes with remote hosts) + onehost sync + EOT def text_commands @@ -357,6 +360,14 @@ when "disable" end end +when "sync" + check_parameters("sync", 0) + if ONE_LOCATION + FileUtils.touch "#{ONE_LOCATION}/lib/remotes" + else + FileUtils.touch "/var/lib/one/remotes" + end + else onehost_opts.print_help exit -1 From bb3785d4e0d9612edaebe1a95bd422bdb6663c49 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Mon, 30 Aug 2010 18:14:07 +0200 Subject: [PATCH 11/13] feature-307: scp is the default probe sync method --- src/im_mad/im_ssh/one_im_ssh | 2 +- src/im_mad/im_ssh/one_im_ssh.rb | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/im_mad/im_ssh/one_im_ssh b/src/im_mad/im_ssh/one_im_ssh index 6bf146355f..af34f360a1 100755 --- a/src/im_mad/im_ssh/one_im_ssh +++ b/src/im_mad/im_ssh/one_im_ssh @@ -47,7 +47,7 @@ export_rc_vars $DRIVERRC # Go to var directory ONE_LOCATION/var or /var/lib/one cd $VAR_LOCATION -LOG_FILE=$DRIVER_NAME +LOG_FILE=one_im_ssh_$DRIVER_NAME # Execute the actual MAD execute_mad $* diff --git a/src/im_mad/im_ssh/one_im_ssh.rb b/src/im_mad/im_ssh/one_im_ssh.rb index 0ecdb503d2..243df86f1a 100755 --- a/src/im_mad/im_ssh/one_im_ssh.rb +++ b/src/im_mad/im_ssh/one_im_ssh.rb @@ -58,7 +58,11 @@ class InformationManager < OpenNebulaDriver #--------------------------------------------------------------------------- def action_monitor(number, host, do_update) if do_update == "1" - sync_cmd = "rsync -Laz #{REMOTES_LOCATION} #{host}:#{@remote_dir}" + # Use SCP to sync: + sync_cmd = "scp -r #{REMOTES_LOCATION}/. #{host}:#{@remote_dir}" + + # Use rsync to sync: + # sync_cmd = "rsync -Laz #{REMOTES_LOCATION} #{host}:#{@remote_dir}" LocalCommand.run(sync_cmd) else end @@ -86,6 +90,5 @@ remote_dir = ENV["IM_REMOTE_DIR"] remote_dir = "/tmp/one" if !remote_dir hypervisor = ARGV[0]||'' - im = InformationManager.new(remote_dir, hypervisor, 15) im.start_driver From f1ef57e0b53cf5fdf5f9e79f67e828db7c433f2b Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Mon, 30 Aug 2010 22:25:59 +0200 Subject: [PATCH 12/13] A $ONE_LOCATION/var/config file is written with the configuration being used by the OpenNebula daemon. The file is written in plain txt format. --- src/nebula/Nebula.cc | 14 +++++++++++--- src/template/Template.cc | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/nebula/Nebula.cc b/src/nebula/Nebula.cc index 61c0622404..82ad1f3b2a 100644 --- a/src/nebula/Nebula.cc +++ b/src/nebula/Nebula.cc @@ -64,6 +64,15 @@ void Nebula::start() throw runtime_error("Could not load nebula configuration file."); } + string config_fname = log_location + "config"; + ofstream config_file(config_fname.c_str(), ios_base::trunc & ios_base::out); + + if (config_file.fail() == false) + { + config_file << *nebula_configuration << endl; + config_file.close(); + } + // ----------------------------------------------------------- // Log system // ----------------------------------------------------------- @@ -109,10 +118,9 @@ void Nebula::start() NebulaLog::log("ONE",Log::INFO,"----------------------------------------"); os.str(""); - - os << "\n--------------------------------------------"; + os << "\n----------------------------------\n"; os << *nebula_configuration; - os << "\n--------------------------------------------"; + os << "----------------------------------"; NebulaLog::log("ONE",Log::INFO,os); diff --git a/src/template/Template.cc b/src/template/Template.cc index 0da76c8965..8556237ed4 100644 --- a/src/template/Template.cc +++ b/src/template/Template.cc @@ -367,7 +367,7 @@ string& Template::to_str(string& str) const { s = it->second->marshall(","); - os << endl << "\t" << it->first << separator << *s; + os << it->first << separator << *s << endl; delete s; } From e73b299d32b75c929c81e5f3c9db1576da8853e0 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Tue, 31 Aug 2010 10:47:22 +0200 Subject: [PATCH 13/13] removed legacy vmm and im drivers --- install.sh | 56 +++----- share/etc/oned.conf | 32 ++--- src/im_mad/kvm/im_kvm.conf | 8 -- src/im_mad/kvm/im_kvmrc | 21 --- src/im_mad/xen/im_xen.conf | 8 -- src/im_mad/xen/im_xenrc | 22 ---- src/vmm_mad/kvm/one_vmm_kvm | 38 ------ src/vmm_mad/kvm/one_vmm_kvm.rb | 221 -------------------------------- src/vmm_mad/kvm/vmm_kvm.conf | 18 --- src/vmm_mad/kvm/vmm_kvmrc | 17 --- src/vmm_mad/xen/one_vmm_xen | 38 ------ src/vmm_mad/xen/one_vmm_xen.rb | 227 --------------------------------- src/vmm_mad/xen/vmm_xen.conf | 13 -- src/vmm_mad/xen/vmm_xenrc | 23 ---- 14 files changed, 26 insertions(+), 716 deletions(-) delete mode 100644 src/im_mad/kvm/im_kvm.conf delete mode 100644 src/im_mad/kvm/im_kvmrc delete mode 100644 src/im_mad/xen/im_xen.conf delete mode 100644 src/im_mad/xen/im_xenrc delete mode 100755 src/vmm_mad/kvm/one_vmm_kvm delete mode 100755 src/vmm_mad/kvm/one_vmm_kvm.rb delete mode 100644 src/vmm_mad/kvm/vmm_kvm.conf delete mode 100644 src/vmm_mad/kvm/vmm_kvmrc delete mode 100755 src/vmm_mad/xen/one_vmm_xen delete mode 100755 src/vmm_mad/xen/one_vmm_xen.rb delete mode 100644 src/vmm_mad/xen/vmm_xen.conf delete mode 100644 src/vmm_mad/xen/vmm_xenrc diff --git a/install.sh b/install.sh index b13e46ecc8..1014624f9c 100755 --- a/install.sh +++ b/install.sh @@ -151,8 +151,6 @@ 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/vmm_sh \ @@ -243,25 +241,21 @@ INSTALL_OCCI_CLIENT_FILES[1]="OCCI_LIB_CLIENT_FILES:$LIB_LOCATION/ruby/cloud/occ INSTALL_OCCI_CLIENT_FILES[2]="OCCI_BIN_CLIENT_FILES:$BIN_LOCATION" 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]="VMM_EH_ETC_FILES:$ETC_LOCATION/vmm_eh" -INSTALL_ETC_FILES[5]="VMM_SH_ETC_FILES:$ETC_LOCATION/vmm_sh" -INSTALL_ETC_FILES[6]="IM_XEN_ETC_FILES:$ETC_LOCATION/im_xen" -INSTALL_ETC_FILES[7]="IM_KVM_ETC_FILES:$ETC_LOCATION/im_kvm" -INSTALL_ETC_FILES[8]="IM_EC2_ETC_FILES:$ETC_LOCATION/im_ec2" -INSTALL_ETC_FILES[9]="IM_EH_ETC_FILES:$ETC_LOCATION/im_eh" -INSTALL_ETC_FILES[10]="TM_NFS_ETC_FILES:$ETC_LOCATION/tm_nfs" -INSTALL_ETC_FILES[11]="TM_SSH_ETC_FILES:$ETC_LOCATION/tm_ssh" -INSTALL_ETC_FILES[12]="TM_DUMMY_ETC_FILES:$ETC_LOCATION/tm_dummy" -INSTALL_ETC_FILES[13]="TM_LVM_ETC_FILES:$ETC_LOCATION/tm_lvm" -INSTALL_ETC_FILES[14]="HM_ETC_FILES:$ETC_LOCATION/hm" -INSTALL_ETC_FILES[15]="AUTH_ETC_FILES:$ETC_LOCATION/auth" -INSTALL_ETC_FILES[16]="ECO_ETC_FILES:$ETC_LOCATION" -INSTALL_ETC_FILES[17]="ECO_ETC_TEMPLATE_FILES:$ETC_LOCATION/ec2query_templates" -INSTALL_ETC_FILES[18]="OCCI_ETC_FILES:$ETC_LOCATION" -INSTALL_ETC_FILES[19]="OCCI_ETC_TEMPLATE_FILES:$ETC_LOCATION/occi_templates" +INSTALL_ETC_FILES[1]="VMM_EC2_ETC_FILES:$ETC_LOCATION/vmm_ec2" +INSTALL_ETC_FILES[2]="VMM_EH_ETC_FILES:$ETC_LOCATION/vmm_eh" +INSTALL_ETC_FILES[3]="VMM_SH_ETC_FILES:$ETC_LOCATION/vmm_sh" +INSTALL_ETC_FILES[4]="IM_EC2_ETC_FILES:$ETC_LOCATION/im_ec2" +INSTALL_ETC_FILES[5]="IM_EH_ETC_FILES:$ETC_LOCATION/im_eh" +INSTALL_ETC_FILES[6]="TM_NFS_ETC_FILES:$ETC_LOCATION/tm_nfs" +INSTALL_ETC_FILES[7]="TM_SSH_ETC_FILES:$ETC_LOCATION/tm_ssh" +INSTALL_ETC_FILES[8]="TM_DUMMY_ETC_FILES:$ETC_LOCATION/tm_dummy" +INSTALL_ETC_FILES[9]="TM_LVM_ETC_FILES:$ETC_LOCATION/tm_lvm" +INSTALL_ETC_FILES[10]="HM_ETC_FILES:$ETC_LOCATION/hm" +INSTALL_ETC_FILES[11]="AUTH_ETC_FILES:$ETC_LOCATION/auth" +INSTALL_ETC_FILES[14]="ECO_ETC_FILES:$ETC_LOCATION" +INSTALL_ETC_FILES[15]="ECO_ETC_TEMPLATE_FILES:$ETC_LOCATION/ec2query_templates" +INSTALL_ETC_FILES[16]="OCCI_ETC_FILES:$ETC_LOCATION" +INSTALL_ETC_FILES[17]="OCCI_ETC_TEMPLATE_FILES:$ETC_LOCATION/occi_templates" #------------------------------------------------------------------------------- # Binary files, to be installed under $BIN_LOCATION @@ -330,10 +324,6 @@ RUBY_OPENNEBULA_LIB_FILES="src/oca/ruby/OpenNebula/Host.rb \ MADS_LIB_FILES="src/mad/sh/madcommon.sh \ src/tm_mad/tm_common.sh \ - src/vmm_mad/xen/one_vmm_xen.rb \ - src/vmm_mad/xen/one_vmm_xen \ - src/vmm_mad/kvm/one_vmm_kvm.rb \ - src/vmm_mad/kvm/one_vmm_kvm \ src/vmm_mad/sh/one_vmm_sh.rb \ src/vmm_mad/sh/one_vmm_sh \ src/vmm_mad/ec2/one_vmm_ec2.rb \ @@ -437,19 +427,11 @@ ETC_FILES="share/etc/oned.conf \ #------------------------------------------------------------------------------- # Virtualization drivers config. files, to be installed under $ETC_LOCATION -# - xen, $ETC_LOCATION/vmm_xen -# - kvm, $ETC_LOCATION/vmm_kvm # - ec2, $ETC_LOCATION/vmm_ec2 # - eh, $ETC_LOCATION/vmm_eh # - sh, $ETC_LOCATION/vmm_sh #------------------------------------------------------------------------------- -VMM_XEN_ETC_FILES="src/vmm_mad/xen/vmm_xenrc \ - src/vmm_mad/xen/vmm_xen.conf" - -VMM_KVM_ETC_FILES="src/vmm_mad/kvm/vmm_kvmrc \ - src/vmm_mad/kvm/vmm_kvm.conf" - VMM_EC2_ETC_FILES="src/vmm_mad/ec2/vmm_ec2rc \ src/vmm_mad/ec2/vmm_ec2.conf" @@ -463,17 +445,9 @@ VMM_SH_ETC_FILES="src/vmm_mad/sh/vmm_shrc \ #------------------------------------------------------------------------------- # Information drivers config. files, to be installed under $ETC_LOCATION -# - xen, $ETC_LOCATION/im_xen -# - kvm, $ETC_LOCATION/im_kvm # - ec2, $ETC_LOCATION/im_ec2 #------------------------------------------------------------------------------- -IM_XEN_ETC_FILES="src/im_mad/xen/im_xenrc \ - src/im_mad/xen/im_xen.conf" - -IM_KVM_ETC_FILES="src/im_mad/kvm/im_kvmrc \ - src/im_mad/kvm/im_kvm.conf" - IM_EC2_ETC_FILES="src/im_mad/ec2/im_ec2rc \ src/im_mad/ec2/im_ec2.conf" diff --git a/share/etc/oned.conf b/share/etc/oned.conf index 18b6a03912..9195b8f895 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -147,34 +147,24 @@ IM_MAD = [ # type : driver type, supported drivers: xen, kvm, xml #******************************************************************************* -#VM_MAD = [ -# name = "vmm_sh_kvm", -# executable = "one_vmm_sh", -# arguments = "kvm", -# default = "vmm_sh/vmm_sh_kvm.conf", -# type = "kvm" ] +#------------------------------------------------------------------------------- +# KVM Virtualization Driver Manager sample configuration +#------------------------------------------------------------------------------- + +VM_MAD = [ + name = "vmm_kvm", + executable = "one_vmm_sh", + arguments = "kvm", + default = "vmm_sh/vmm_sh_kvm.conf", + type = "kvm" ] #VM_MAD = [ -# name = "vmm_sh_xen", +# name = "vmm_xen", # executable = "one_vmm_sh", # arguments = "xen", # default = "vmm_sh/vmm_sh_xen.conf", # type = "xen" ] -#VM_MAD = [ -# name = "vmm_xen", -# executable = "one_vmm_xen", -# default = "vmm_xen/vmm_xen.conf", -# type = "xen" ] - -#------------------------------------------------------------------------------- -# KVM Virtualization Driver Manager sample configuration -#------------------------------------------------------------------------------- -VM_MAD = [ - name = "vmm_kvm", - executable = "one_vmm_kvm", - default = "vmm_kvm/vmm_kvm.conf", - type = "kvm" ] #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- diff --git a/src/im_mad/kvm/im_kvm.conf b/src/im_mad/kvm/im_kvm.conf deleted file mode 100644 index a891f402c6..0000000000 --- a/src/im_mad/kvm/im_kvm.conf +++ /dev/null @@ -1,8 +0,0 @@ -#------------------------------------------------------------------------------- -# Probes for KVM hosts add as many monitorization sensors as you need -#------------------------------------------------------------------------------- - -cpuarchitecture=architecture.sh -nodename=name.sh -cpu=cpu.sh -kvm=kvm.rb diff --git a/src/im_mad/kvm/im_kvmrc b/src/im_mad/kvm/im_kvmrc deleted file mode 100644 index 32268dbd8b..0000000000 --- a/src/im_mad/kvm/im_kvmrc +++ /dev/null @@ -1,21 +0,0 @@ -# -------------------------------------------------------------------------- # -# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -# To change the directory where the IM probes are copied on the remote node -# uncomment and change the path of IM_REMOTE_DIR -# -#IM_REMOTE_DIR=/tmp/ne_im_scripts - diff --git a/src/im_mad/xen/im_xen.conf b/src/im_mad/xen/im_xen.conf deleted file mode 100644 index b86c8630a8..0000000000 --- a/src/im_mad/xen/im_xen.conf +++ /dev/null @@ -1,8 +0,0 @@ -#------------------------------------------------------------------------------- -# Probes for Xen hosts add as many monitorization sensors as you need -#------------------------------------------------------------------------------- - -cpuarchitecture=architecture.sh -nodename=name.sh -cpu=cpu.sh -xen=xen.rb diff --git a/src/im_mad/xen/im_xenrc b/src/im_mad/xen/im_xenrc deleted file mode 100644 index 5950cc3036..0000000000 --- a/src/im_mad/xen/im_xenrc +++ /dev/null @@ -1,22 +0,0 @@ -# -------------------------------------------------------------------------- # -# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -# To change the directory where the IM probes are copied on the remote node -# uncomment and change the path of IM_REMOTE_DIR -# -#IM_REMOTE_DIR=/tmp/ne_im_scripts - - diff --git a/src/vmm_mad/kvm/one_vmm_kvm b/src/vmm_mad/kvm/one_vmm_kvm deleted file mode 100755 index df79f32b6f..0000000000 --- a/src/vmm_mad/kvm/one_vmm_kvm +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash - -# -------------------------------------------------------------------------- # -# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -if [ -z "${ONE_LOCATION}" ]; then - DRIVERRC=/etc/one/vmm_kvm/vmm_kvmrc - MADCOMMON=/usr/lib/one/mads/madcommon.sh - VAR_LOCATION=/var/lib/one -else - DRIVERRC=$ONE_LOCATION/etc/vmm_kvm/vmm_kvmrc - 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 $* diff --git a/src/vmm_mad/kvm/one_vmm_kvm.rb b/src/vmm_mad/kvm/one_vmm_kvm.rb deleted file mode 100755 index 535bab0ff2..0000000000 --- a/src/vmm_mad/kvm/one_vmm_kvm.rb +++ /dev/null @@ -1,221 +0,0 @@ -#!/usr/bin/env ruby -# -------------------------------------------------------------------------- # -# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -# ---------------------------------------------------------------------------- # -# Set up the environment for the driver # -# ---------------------------------------------------------------------------- # - -ONE_LOCATION = ENV["ONE_LOCATION"] - -if !ONE_LOCATION - RUBY_LIB_LOCATION = "/usr/lib/one/ruby" - ETC_LOCATION = "/etc/one/" -else - RUBY_LIB_LOCATION = ONE_LOCATION + "/lib/ruby" - ETC_LOCATION = ONE_LOCATION + "/etc/" -end - -if ENV["LIBVIRT_DEFAULT_URI"] - LIBVIRT_URI = ENV["LIBVIRT_DEFAULT_URI"] -else - LIBVIRT_URI = "qemu:///system" -end - -$: << RUBY_LIB_LOCATION - -require 'pp' -require "VirtualMachineDriver" -require 'rexml/document' - -# ---------------------------------------------------------------------------- # -# The main class for the LibVirt driver # -# ---------------------------------------------------------------------------- # -class LibVirtDriver < VirtualMachineDriver - - # ------------------------------------------------------------------------ # - # Libvirt commands constants # - # ------------------------------------------------------------------------ # - QEMU_PROTOCOL = "qemu+ssh" - - LIBVIRT = { - :create => "virsh --connect #{LIBVIRT_URI} create", - :shutdown => "virsh --connect #{LIBVIRT_URI} shutdown", - :cancel => "virsh --connect #{LIBVIRT_URI} destroy", - :save => "virsh --connect #{LIBVIRT_URI} save", - :restore => "virsh --connect #{LIBVIRT_URI} restore", - :migrate => "virsh --connect #{LIBVIRT_URI} migrate --live", - :poll => "virsh --connect #{LIBVIRT_URI} dominfo", - :netstats => "virsh --connect #{LIBVIRT_URI} domifstat", - :dumpxml => "virsh --connect #{LIBVIRT_URI} dumpxml" - } - - # ------------------------------------------------------------------------ # - # LibvirtDriver constructor # - # ------------------------------------------------------------------------ # - def initialize() - super(15,true) - end - - # ------------------------------------------------------------------------ # - # DEPLOY action, sends the deployment file to remote host # - # ------------------------------------------------------------------------ # - def deploy(id, host, remote_dfile, not_used) - - local_dfile = get_local_deployment_file(remote_dfile) - - if !local_dfile || File.zero?(local_dfile) - send_message(ACTION[:deploy],RESULT[:failure],id, - "Can not open deployment file #{local_dfile}") - return - end - - tmp = File.new(local_dfile) - domain = tmp.read - tmp.close() - - images_path = File.dirname remote_dfile - cmd = "mkdir -p #{images_path} && cat > #{remote_dfile} && " \ - "#{LIBVIRT[:create]} #{remote_dfile}" - - deploy_exe = SSHCommand.run("'#{cmd}'", host, log_method(id), domain) - - if deploy_exe.code != 0 - send_message(ACTION[:deploy],RESULT[:failure],id) - elsif deploy_exe.stdout.match(/^Domain (.*) created from .*$/) - send_message(ACTION[:deploy],RESULT[:success],id,$1) - else - send_message(ACTION[:deploy],RESULT[:failure],id, - "Domain id not found in #{LIBVIRT[:create]} output.") - end - end - - # ------------------------------------------------------------------------ # - # Basic Domain Management Operations # - # ------------------------------------------------------------------------ # - def shutdown(id, host, deploy_id, not_used) - cmd = "#{LIBVIRT[:shutdown]} #{deploy_id} && " \ - "c=0 && while [ $c -lt \"5\" ]; do " \ - "if [ $(#{LIBVIRT[:poll]} #{deploy_id} > /dev/null 2>&1; echo $?) -ne \"0\" ]; " \ - "then let 'c=c+1'; else c=0; fi; sleep 2; done; sleep 4" - - execution=SSHCommand.run('bash', host, log_method(id), cmd) - - if execution.code !=0 - send_message(ACTION[:shutdown], RESULT[:failure], id) - else - send_message(ACTION[:shutdown], RESULT[:success], id) - end - end - - def cancel(id, host, deploy_id, not_used) - ssh_action("#{LIBVIRT[:cancel]} #{deploy_id}", id, host, :cancel) - end - - def save(id, host, deploy_id, file) - ssh_action("'touch #{file};#{LIBVIRT[:save]} #{deploy_id} #{file}'",id,host,:save) - end - - def restore(id, host, deploy_id, file) - ssh_action("#{LIBVIRT[:restore]} #{file}", id, host, :restore) - end - - def migrate(id, host, deploy_id, dest_host) - cmd = "#{LIBVIRT[:migrate]} #{deploy_id} "\ - "#{QEMU_PROTOCOL}://#{dest_host}/system" - - ssh_action(cmd, id, host, :migrate) - end - - # ------------------------------------------------------------------------ # - # Get info from the Libvirt Domain # - # ------------------------------------------------------------------------ # - def poll(id, host, deploy_id, not_used) - - exe = SSHCommand.run("#{LIBVIRT[:poll]} #{deploy_id}", host, - log_method(id)) - - exe2 = SSHCommand.run("#{LIBVIRT[:dumpxml]} #{deploy_id}", host, - log_method(id)) - - doc = REXML::Document.new(exe2.stdout) - interfaces = [] - - doc.elements.each('domain/devices/interface/target') do |ele| - interfaces << ele.attributes["dev"] - end - - exe3 = SSHCommand.run("#{LIBVIRT[:netstats]} #{deploy_id} #{interfaces}", host, - log_method(id)) - - if exe.code != 0 - result = :failure - info = "-" - - if exe.stderr.match(/^error: failed to get domain '#{deploy_id}'/) - info = "#{POLL_ATTRIBUTE[:state]}=#{VM_STATE[:deleted]}" - result = :success - end - - send_message(ACTION[:poll], RESULT[result], id, info) - return - end - - info = "" - - exe.stdout.each_line {|line| - columns=line.split(":").collect {|c| c.strip } - - case columns[0] - when 'Used memory' - info << " #{POLL_ATTRIBUTE[:usedmemory]}=" \ - << (columns[1].to_i).to_s - when 'State' - case columns[1] - when "running","blocked","shutdown","dying" - state = VM_STATE[:active] - when "paused" - state = VM_STATE[:paused] - when "crashed" - state = VM_STATE[:error] - else - state = VM_STATE[:unknown] - end - - info << " #{POLL_ATTRIBUTE[:state]}=#{state}" - end - } - - exe3.stdout.each_line do |line| - columns=line.split(" ").collect {|c| c.strip } - case columns[1] - when 'rx_bytes' - info << " #{POLL_ATTRIBUTE[:netrx]}=" << (columns[2].to_i).to_s - when 'tx_bytes' - info << " #{POLL_ATTRIBUTE[:nettx]}=" << (columns[2].to_i).to_s - end - end - - send_message(ACTION[:poll], RESULT[:success], id, info) - end -end - -# ---------------------------------------------------------------------------- # -# LibvirtDriver Main program -# ---------------------------------------------------------------------------- # - -kvm_driver = LibVirtDriver.new -kvm_driver.start_driver diff --git a/src/vmm_mad/kvm/vmm_kvm.conf b/src/vmm_mad/kvm/vmm_kvm.conf deleted file mode 100644 index 7ba58ee1f4..0000000000 --- a/src/vmm_mad/kvm/vmm_kvm.conf +++ /dev/null @@ -1,18 +0,0 @@ -# Default configuration attributes for the KVM driver -# (all domains will use these values as defaults) -# Valid atributes are: -# - os [kernel,initrd,boot,root,kernel_cmd] -# - memory -# - cpu -# - vcpu -# - features [acpi, pae] - -#VCPU = 1 -#MEMORY = 128 -#OS = [ kernel="/vmlinuz", initrd="/initrd.img", root="sda1", boot=hd,kernel_cmd="ro"] -OS = [ boot = "hd" ] - -FEATURES = [ - PAE=no, - ACPI=yes -] diff --git a/src/vmm_mad/kvm/vmm_kvmrc b/src/vmm_mad/kvm/vmm_kvmrc deleted file mode 100644 index 5f10e4cabe..0000000000 --- a/src/vmm_mad/kvm/vmm_kvmrc +++ /dev/null @@ -1,17 +0,0 @@ -# -------------------------------------------------------------------------- # -# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # -LIBVIRT_DEFAULT_URI="qemu:///system" - diff --git a/src/vmm_mad/xen/one_vmm_xen b/src/vmm_mad/xen/one_vmm_xen deleted file mode 100755 index 7a47c040b6..0000000000 --- a/src/vmm_mad/xen/one_vmm_xen +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash - -# -------------------------------------------------------------------------- # -# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -if [ -z "${ONE_LOCATION}" ]; then - DRIVERRC=/etc/one/vmm_xen/vmm_xenrc - MADCOMMON=/usr/lib/one/mads/madcommon.sh - VAR_LOCATION=/var/lib/one -else - DRIVERRC=$ONE_LOCATION/etc/vmm_xen/vmm_xenrc - 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 $* diff --git a/src/vmm_mad/xen/one_vmm_xen.rb b/src/vmm_mad/xen/one_vmm_xen.rb deleted file mode 100755 index 0a0a81aea7..0000000000 --- a/src/vmm_mad/xen/one_vmm_xen.rb +++ /dev/null @@ -1,227 +0,0 @@ -#!/usr/bin/env ruby -# -------------------------------------------------------------------------- # -# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -# ---------------------------------------------------------------------------- # -# Set up the environment for the driver # -# ---------------------------------------------------------------------------- # - -ONE_LOCATION = ENV["ONE_LOCATION"] -XENTOP_PATH = ENV["XENTOP_PATH"] -XM_PATH = ENV["XM_PATH"] - -if !ONE_LOCATION - RUBY_LIB_LOCATION = "/usr/lib/one/ruby" - ETC_LOCATION = "/etc/one/" -else - RUBY_LIB_LOCATION = ONE_LOCATION + "/lib/ruby" - ETC_LOCATION = ONE_LOCATION + "/etc/" -end - -$: << RUBY_LIB_LOCATION - -require 'pp' -require "VirtualMachineDriver" - -# ---------------------------------------------------------------------------- # -# The main class for the Xen driver # -# ---------------------------------------------------------------------------- # -class XenDriver < VirtualMachineDriver - - # ------------------------------------------------------------------------ # - # Xen commands constants # - # ------------------------------------------------------------------------ # - XEN = { - :create => "sudo #{XM_PATH} create", - :shutdown => "sudo #{XM_PATH} shutdown", - :cancel => "sudo #{XM_PATH} destroy", - :save => "sudo #{XM_PATH} save", - :restore => "sudo #{XM_PATH} restore", - :migrate => "sudo #{XM_PATH} migrate -l", - :poll => "sudo #{XENTOP_PATH} -bi2", - :credits => "sudo #{XM_PATH} sched-cred", - :list => "sudo #{XM_PATH} list" - } - - XEN_INFO = { - :name => 0, - :state => 1, - :cpu_sec => 2, - :cpu_per => 3, - :mem => 4, - :mem_per => 5, - :maxmem => 6, - :maxmem_per => 7, - :vcpus => 8, - :nets => 9, - :nettx => 10, - :netrx => 11, - :vbds => 12, - :vbd_oo => 13, - :vbd_rd => 14, - :vbd_wr => 15, - :ssid => 16 - } - - # ------------------------------------------------------------------------ # - # XenDriver constructor # - # ------------------------------------------------------------------------ # - def initialize() - super(15,true) - end - - # ------------------------------------------------------------------------ # - # DEPLOY action, sends the deployment file to remote host # - # ------------------------------------------------------------------------ # - def deploy(id, host, remote_dfile, not_used) - - local_dfile = get_local_deployment_file(remote_dfile) - - if !local_dfile || File.zero?(local_dfile) - send_message(ACTION[:deploy],RESULT[:failure],id, - "Can not open deployment file #{local_dfile}") - return - end - - tmp = File.new(local_dfile) - domain = tmp.read - tmp.close() - - cmd = "cat > #{remote_dfile} && #{XEN[:create]} #{remote_dfile}" - - values = domain.scan(/^#O (.*?) = (.*)$/) - credits = values.assoc("CPU_CREDITS") - - if domain.match(/^name = '(.*?)'$/) && credits - cmd << " && #{XEN[:credits]} -d #{$1} -w #{credits[1]}" - end - - deploy_exe = SSHCommand.run("'#{cmd}'", host, log_method(id), domain) - - if deploy_exe.code != 0 - send_message(ACTION[:deploy],RESULT[:failure],id) - elsif deploy_exe.stdout.match(/^Started domain (.*)/) - send_message(ACTION[:deploy],RESULT[:success],id,$1) - else - send_message(ACTION[:deploy],RESULT[:failure],id, - "Domain id not found in #{XEN[:create]} output.") - end - end - - # ------------------------------------------------------------------------ # - # Basic Domain Management Operations # - # ------------------------------------------------------------------------ # - def shutdown(id, host, deploy_id, not_used) - cmd=<<-EOS -function gdm { - #{XEN[:list]} | grep '#{deploy_id}\\>' -} - -#{XEN[:shutdown]} #{deploy_id} || exit -1 - -OUT=$(gdm) - -while [ -n "$OUT" -a $(echo $OUT | awk '{print $5}') != "---s--" ]; do - sleep 1 - OUT=$(gdm) -done - -OUT=$(gdm) - -if [ -n "$OUT" ]; then - #{XEN[:cancel]} '#{deploy_id}' -fi -sleep 2 -EOS - - execution=SSHCommand.run('bash', host, log_method(id), cmd) - - if execution.code !=0 - send_message(ACTION[:shutdown], RESULT[:failure], id) - else - send_message(ACTION[:shutdown], RESULT[:success], id) - end - end - - def cancel(id, host, deploy_id, not_used) - ssh_action("#{XEN[:cancel]} #{deploy_id}", id, host, :cancel) - end - - def save(id, host, deploy_id, file) - ssh_action("#{XEN[:save]} #{deploy_id} #{file}", id, host, :save) - end - - def restore(id, host, deploy_id, file) - ssh_action("#{XEN[:restore]} #{file}", id, host, :restore) - end - - def migrate(id, host, deploy_id, dest_host) - ssh_action("#{XEN[:migrate]} #{deploy_id} #{dest_host}", - id, host, :migrate) - end - - # ------------------------------------------------------------------------ # - # Get info from the Xen Domain. # - # ------------------------------------------------------------------------ # - def poll(id, host, deploy_id, not_used) - - exe = SSHCommand.run("#{XEN[:poll]} #{deploy_id}", host, log_method(id)) - - if exe.code != 0 - send_message(ACTION[:poll], RESULT[:failure], id, "-") - return - end - - dinfo = exe.stdout.split(/$/).select { |l| - l.match(/^ *(migrating-)?#{deploy_id} /) }[-1] - - if !dinfo - send_message(ACTION[:poll], RESULT[:success], id, - "#{POLL_ATTRIBUTE[:state]}=#{VM_STATE[:deleted]}") - return - end - - dinfo.gsub!("no limit", "no_limit") - data = dinfo.split - - info = "#{POLL_ATTRIBUTE[:usedmemory]}=#{data[XEN_INFO[:mem]]} " \ - "#{POLL_ATTRIBUTE[:usedcpu]}=#{data[XEN_INFO[:cpu_per]]} " \ - "#{POLL_ATTRIBUTE[:nettx]}=#{data[XEN_INFO[:nettx]]} " \ - "#{POLL_ATTRIBUTE[:netrx]}=#{data[XEN_INFO[:netrx]]} " - - case data[XEN_INFO[:state]].gsub!("-", "") - when "r", "b", "s","d" - state = VM_STATE[:active] - when "p" - state = VM_STATE[:paused] - when "c" - state = VM_STATE[:error] - else - state = VM_STATE[:unknown] - end - - info << " #{POLL_ATTRIBUTE[:state]}=#{state}" - - send_message(ACTION[:poll], RESULT[:success], id, info) - end -end - -# ---------------------------------------------------------------------------- # -# XenDriver Main program # -# ---------------------------------------------------------------------------- # - -xen_driver = XenDriver.new -xen_driver.start_driver diff --git a/src/vmm_mad/xen/vmm_xen.conf b/src/vmm_mad/xen/vmm_xen.conf deleted file mode 100644 index 573d8209fa..0000000000 --- a/src/vmm_mad/xen/vmm_xen.conf +++ /dev/null @@ -1,13 +0,0 @@ -# Default configuration attributes for the Xen driver -# (all domains will use these values as defaults) -# Valid atributes: -# - credit -# - os [kernel,initrd,root,kernel_cmd] -# - memory -# - vcpu - -#VCPU = 1 -#MEMORY = 128 -#OS = [ kernel="/vmlinuz", initrd="/initrd.img", root="sda1", kernel_cmd="ro" ] -CREDIT = 256 - diff --git a/src/vmm_mad/xen/vmm_xenrc b/src/vmm_mad/xen/vmm_xenrc deleted file mode 100644 index 258c5f9339..0000000000 --- a/src/vmm_mad/xen/vmm_xenrc +++ /dev/null @@ -1,23 +0,0 @@ -# -------------------------------------------------------------------------- # -# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -#--------------------------------------------------------------------------- -# Path to Xen utilities -#--------------------------------------------------------------------------- - -XENTOP_PATH="/usr/sbin/xentop" - -XM_PATH="/usr/sbin/xm"