diff --git a/NOTICE b/NOTICE index 35da7197f9..dff13a505a 100644 --- a/NOTICE +++ b/NOTICE @@ -1,6 +1,6 @@ OpenNebula Open Source Project -------------------------------------------------------------------------------- -Copyright 2002-2014, OpenNebula Project, OpenNebula Systems (formerly C12G Labs) +Copyright 2002-2015, OpenNebula Project, OpenNebula Systems (formerly C12G Labs) -------------------------------------------------------------------------------- You can find more information about the project, release notes and @@ -21,11 +21,6 @@ The following people have contributed to the development of the technology - Daniel Molina Aranda (dmolina@opennebula.org) - Hector Sanjuan Redondo (hsanjuan@opennebula.org) -The new features for service elasticity (oneFlow) introduced in OpenNebula 4.2 -were funded by BlackBerry in the context of the Fund a Feature Program. - -OpenNebula Project also acknowledges the contributions of C12G Labs developers. - LICENSE OpenNebula is licensed under the Apache License, Version 2.0 (the diff --git a/include/UserPool.h b/include/UserPool.h index b94682c336..484f030b3d 100644 --- a/include/UserPool.h +++ b/include/UserPool.h @@ -187,11 +187,6 @@ public: */ static const char * PUBLIC_AUTH; - /** - * Name for the default auth driver to be used for not registered users - */ - static const char * DEFAULT_AUTH; - /** * Name for the default Sunstone server user */ diff --git a/install.sh b/install.sh index c244ae0369..982a871b3e 100755 --- a/install.sh +++ b/install.sh @@ -1018,6 +1018,7 @@ TM_SHARED_FILES="src/tm_mad/shared/clone \ src/tm_mad/shared/context \ src/tm_mad/shared/premigrate \ src/tm_mad/shared/postmigrate \ + src/tm_mad/shared/failmigrate \ src/tm_mad/shared/mvds \ src/tm_mad/shared/snap_create \ src/tm_mad/shared/snap_delete \ @@ -1034,6 +1035,7 @@ TM_FS_LVM_FILES="src/tm_mad/fs_lvm/clone \ src/tm_mad/fs_lvm/snap_create \ src/tm_mad/fs_lvm/snap_delete \ src/tm_mad/fs_lvm/snap_revert \ + src/tm_mad/fs_lvm/failmigrate \ src/tm_mad/fs_lvm/delete" TM_QCOW2_FILES="src/tm_mad/qcow2/clone \ @@ -1045,6 +1047,7 @@ TM_QCOW2_FILES="src/tm_mad/qcow2/clone \ src/tm_mad/qcow2/context \ src/tm_mad/qcow2/premigrate \ src/tm_mad/qcow2/postmigrate \ + src/tm_mad/qcow2/failmigrate \ src/tm_mad/qcow2/mvds \ src/tm_mad/qcow2/snap_create \ src/tm_mad/qcow2/snap_delete \ @@ -1060,6 +1063,7 @@ TM_SSH_FILES="src/tm_mad/ssh/clone \ src/tm_mad/ssh/context \ src/tm_mad/ssh/premigrate \ src/tm_mad/ssh/postmigrate \ + src/tm_mad/ssh/failmigrate \ src/tm_mad/ssh/mvds \ src/tm_mad/ssh/snap_create \ src/tm_mad/ssh/snap_delete \ @@ -1075,6 +1079,7 @@ TM_DUMMY_FILES="src/tm_mad/dummy/clone \ src/tm_mad/dummy/context \ src/tm_mad/dummy/premigrate \ src/tm_mad/dummy/postmigrate \ + src/tm_mad/dummy/failmigrate \ src/tm_mad/dummy/mvds \ src/tm_mad/dummy/snap_create \ src/tm_mad/dummy/snap_delete \ @@ -1094,6 +1099,7 @@ TM_VMFS_FILES="src/tm_mad/vmfs/clone \ src/tm_mad/vmfs/snap_create \ src/tm_mad/vmfs/snap_delete \ src/tm_mad/vmfs/snap_revert \ + src/tm_mad/vmfs/failmigrate \ src/tm_mad/vmfs/premigrate" TM_LVM_FILES="src/tm_mad/lvm/clone \ @@ -1106,6 +1112,7 @@ TM_LVM_FILES="src/tm_mad/lvm/clone \ src/tm_mad/lvm/snap_create \ src/tm_mad/lvm/snap_delete \ src/tm_mad/lvm/snap_revert \ + src/tm_mad/lvm/failmigrate \ src/tm_mad/lvm/delete" TM_CEPH_FILES="src/tm_mad/ceph/clone \ @@ -1118,6 +1125,7 @@ TM_CEPH_FILES="src/tm_mad/ceph/clone \ src/tm_mad/ceph/snap_create \ src/tm_mad/ceph/snap_delete \ src/tm_mad/ceph/snap_revert \ + src/tm_mad/ceph/failmigrate \ src/tm_mad/ceph/delete" TM_DEV_FILES="src/tm_mad/dev/clone \ @@ -1130,6 +1138,7 @@ TM_DEV_FILES="src/tm_mad/dev/clone \ src/tm_mad/dev/snap_create \ src/tm_mad/dev/snap_delete \ src/tm_mad/dev/snap_revert \ + src/tm_mad/dev/failmigrate \ src/tm_mad/dev/delete" #------------------------------------------------------------------------------- diff --git a/share/etc/oned.conf b/share/etc/oned.conf index d32b5578a8..b942dc390d 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -703,6 +703,13 @@ HM_MAD = [ # defined all the modules available will be enabled # authz : list of authentication modules separated by commas # +# DEFAULT_AUTH: The default authentication driver to use when OpenNebula does +# not know the user and needs to authenticate it externally. If you want to +# use "default" (not recommended, but supported for backwards compatibility +# reasons) make sure you create a symlink pointing to the actual authentication +# driver in /var/lib/one/remotes/auth, and add "default" to the 'auth' +# parameter in the 'AUTH_MAD' section. +# # SESSION_EXPIRATION_TIME: Time in seconds to keep an authenticated token as # valid. During this time, the driver is not used. Use 0 to disable session # caching @@ -721,6 +728,8 @@ AUTH_MAD = [ authn = "ssh,x509,ldap,server_cipher,server_x509" ] +#DEFAULT_AUTH = "default" + SESSION_EXPIRATION_TIME = 900 #ENABLE_OTHER_PERMISSIONS = "YES" diff --git a/share/pkgs/Debian/opennebula b/share/pkgs/Debian7/opennebula similarity index 100% rename from share/pkgs/Debian/opennebula rename to share/pkgs/Debian7/opennebula diff --git a/share/pkgs/Debian/opennebula-econe b/share/pkgs/Debian7/opennebula-econe similarity index 100% rename from share/pkgs/Debian/opennebula-econe rename to share/pkgs/Debian7/opennebula-econe diff --git a/share/pkgs/Debian/opennebula-flow b/share/pkgs/Debian7/opennebula-flow similarity index 100% rename from share/pkgs/Debian/opennebula-flow rename to share/pkgs/Debian7/opennebula-flow diff --git a/share/pkgs/Debian/opennebula-gate b/share/pkgs/Debian7/opennebula-gate similarity index 100% rename from share/pkgs/Debian/opennebula-gate rename to share/pkgs/Debian7/opennebula-gate diff --git a/share/pkgs/Debian/opennebula-novnc b/share/pkgs/Debian7/opennebula-novnc similarity index 100% rename from share/pkgs/Debian/opennebula-novnc rename to share/pkgs/Debian7/opennebula-novnc diff --git a/share/pkgs/Debian/opennebula-sunstone b/share/pkgs/Debian7/opennebula-sunstone similarity index 100% rename from share/pkgs/Debian/opennebula-sunstone rename to share/pkgs/Debian7/opennebula-sunstone diff --git a/share/pkgs/Debian7/opennebula.sudoers b/share/pkgs/Debian7/opennebula.sudoers new file mode 100644 index 0000000000..4f75c3eec7 --- /dev/null +++ b/share/pkgs/Debian7/opennebula.sudoers @@ -0,0 +1,11 @@ +Defaults:oneadmin !requiretty +Defaults:oneadmin secure_path = /sbin:/bin:/usr/sbin:/usr/bin + +Cmnd_Alias ONE_MISC = /bin/dd, /sbin/mkfs, /bin/sync +Cmnd_Alias ONE_NET = /sbin/brctl, /sbin/ebtables, /sbin/iptables, /sbin/ip, /usr/sbin/ipset +Cmnd_Alias ONE_LVM = /sbin/lvcreate, /sbin/lvremove, /sbin/lvrename, /sbin/lvs, /sbin/vgdisplay +Cmnd_Alias ONE_ISCSI = /usr/bin/iscsiadm, /usr/sbin/tgt-admin, /usr/sbin/tgtadm +Cmnd_Alias ONE_OVS = /usr/bin/ovs-ofctl, /usr/bin/ovs-vsctl +Cmnd_Alias ONE_XEN = /usr/sbin/xentop, /usr/sbin/xl, /usr/sbin/xm + +oneadmin ALL=(ALL) NOPASSWD: ONE_MISC, ONE_NET, ONE_LVM, ONE_ISCSI, ONE_OVS, ONE_XEN diff --git a/share/pkgs/Debian8/opennebula b/share/pkgs/Debian8/opennebula new file mode 100755 index 0000000000..9d923565b4 --- /dev/null +++ b/share/pkgs/Debian8/opennebula @@ -0,0 +1,128 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: opennebula +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Should-Start: mysql +# Should-Stop: mysql +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: OpenNebula init script +# Description: OpenNebula cloud initialisation script +### END INIT INFO + +# Author: Soren Hansen + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +DESC="OpenNebula cloud" +NAME=one +DAEMON=/usr/bin/$NAME +DAEMON_ARGS="" +PIDFILE=/var/run/$NAME.pid +SCRIPTNAME=/etc/init.d/$NAME + +# Exit if the package is not installed +[ -x "$DAEMON" ] || exit 0 + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. +. /lib/lsb/init-functions + +# +# Function that starts the daemon/service +# +do_start() +{ + mkdir -p /var/run/one /var/lock/one + chown oneadmin /var/run/one /var/lock/one + su oneadmin -s /bin/sh -c 'one start' +} + +# +# Function that stops the daemon/service +# +do_stop() +{ + su oneadmin -s /bin/sh -c 'one stop' +} + +do_start_sched() +{ + su oneadmin -s /bin/sh -c 'one start-sched' +} + +do_stop_sched() +{ + su oneadmin -s /bin/sh -c 'one stop-sched' +} + +case "$1" in + start) + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + stop) + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + status) + status_of_proc "oned" "$NAME" && exit 0 || exit $? + ;; + restart|force-reload) + # + # If the "reload" option is implemented then remove the + # 'force-reload' alias + # + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + restart-sched) + log_daemon_msg "Restarting scheduler" + do_stop_sched + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2 + exit 3 + ;; +esac + +: diff --git a/share/pkgs/Debian8/opennebula-econe b/share/pkgs/Debian8/opennebula-econe new file mode 100755 index 0000000000..31003b2b0d --- /dev/null +++ b/share/pkgs/Debian8/opennebula-econe @@ -0,0 +1,106 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: opennebula-econe +# Required-Start: $remote_fs +# Required-Stop: $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: ECONE Server init script +# Description: OpenNebula ECONE service initialisation script +### END INIT INFO + +# Author: Tino Vázquez + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +DESC="ECONE Service" +NAME=econe-server +DAEMON=/usr/bin/$NAME +DAEMON_ARGS="" +SCRIPTNAME=/etc/init.d/$NAME +PID_FILE=/var/run/one/econe-server.pid + +# Exit if the package is not installed +[ -x "$DAEMON" ] || exit 0 + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. +. /lib/lsb/init-functions + +# +# Function that starts the daemon/service +# +do_start() +{ + mkdir -p /var/run/one /var/lock/one /var/log/one + chown oneadmin /var/run/one /var/lock/one /var/log/one + su oneadmin -s /bin/sh -c "$DAEMON start" +} + +# +# Function that stops the daemon/service +# +do_stop() +{ + su oneadmin -s /bin/sh -c "$DAEMON stop" +} + +case "$1" in + start) + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + stop) + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + status) + ECONE_PID=`cat $PID_FILE` + kill -0 $ECONE_PID > /dev/null 2>&1 + if [ "$?" -eq "0" ]; then + log_daemon_msg "$NAME is running" + log_end_msg 0 + else + log_daemon_msg "$NAME is not running" + log_end_msg 1 + fi + ;; + restart|force-reload) + # + # If the "reload" option is implemented then remove the + # 'force-reload' alias + # + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 + exit 3 + ;; +esac + +: diff --git a/share/pkgs/Debian8/opennebula-flow b/share/pkgs/Debian8/opennebula-flow new file mode 100755 index 0000000000..6467dd9476 --- /dev/null +++ b/share/pkgs/Debian8/opennebula-flow @@ -0,0 +1,94 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: opennebula-flow +# Required-Start: $remote_fs +# Required-Stop: $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: OneFlow init script +# Description: OpenNebula OneFlow service initialisation script +### END INIT INFO + +# Author: Tino Vázquez + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +DESC="OneFlow Service" +NAME=oneflow-server +DAEMON=/usr/bin/$NAME +DAEMON_ARGS="" +SCRIPTNAME=/etc/init.d/$NAME + +# Exit if the package is not installed +[ -x "$DAEMON" ] || exit 0 + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. +. /lib/lsb/init-functions + +# +# Function that starts the daemon/service +# +do_start() +{ + mkdir -p /var/run/one /var/lock/one /var/log/one + chown oneadmin /var/run/one /var/lock/one /var/log/one + su oneadmin -s /bin/sh -c "$DAEMON start" +} + +# +# Function that stops the daemon/service +# +do_stop() +{ + su oneadmin -s /bin/sh -c "$DAEMON stop" +} + +case "$1" in + start) + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + stop) + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + restart|force-reload) + # + # If the "reload" option is implemented then remove the + # 'force-reload' alias + # + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 + exit 3 + ;; +esac + +: diff --git a/share/pkgs/Debian8/opennebula-gate b/share/pkgs/Debian8/opennebula-gate new file mode 100755 index 0000000000..613f2614ef --- /dev/null +++ b/share/pkgs/Debian8/opennebula-gate @@ -0,0 +1,94 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: opennebula-gate +# Required-Start: $remote_fs +# Required-Stop: $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: OneGate init script +# Description: OpenNebula OneGate service initialisation script +### END INIT INFO + +# Author: Tino Vázquez + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +DESC="OneGate Service" +NAME=onegate-server +DAEMON=/usr/bin/$NAME +DAEMON_ARGS="" +SCRIPTNAME=/etc/init.d/$NAME + +# Exit if the package is not installed +[ -x "$DAEMON" ] || exit 0 + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. +. /lib/lsb/init-functions + +# +# Function that starts the daemon/service +# +do_start() +{ + mkdir -p /var/run/one /var/lock/one /var/log/one + chown oneadmin /var/run/one /var/lock/one /var/log/one + su oneadmin -s /bin/sh -c "$DAEMON start" +} + +# +# Function that stops the daemon/service +# +do_stop() +{ + su oneadmin -s /bin/sh -c "$DAEMON stop" +} + +case "$1" in + start) + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + stop) + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + restart|force-reload) + # + # If the "reload" option is implemented then remove the + # 'force-reload' alias + # + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 + exit 3 + ;; +esac + +: diff --git a/share/pkgs/Debian8/opennebula-novnc b/share/pkgs/Debian8/opennebula-novnc new file mode 100755 index 0000000000..f583a5fe1c --- /dev/null +++ b/share/pkgs/Debian8/opennebula-novnc @@ -0,0 +1,105 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: opennebula-novnc +# Required-Start: $remote_fs +# Required-Stop: $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: novnc init script +# Description: OpenNebula novnc server +### END INIT INFO + +# Author: Arnold Bechtoldt + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +DESC="OpenNebula novnc server" +NAME=novnc-server +DAEMON=/usr/bin/$NAME +DAEMON_ARGS="" +SCRIPTNAME=/etc/init.d/opennebula-novnc + +# Exit if the package is not installed +[ -x "$DAEMON" ] || exit 0 + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. +. /lib/lsb/init-functions + +# +# Function that starts the daemon/service +# +do_start() +{ + mkdir -p /var/lock/one /var/log/one + chown oneadmin /var/lock/one /var/log/one + su oneadmin -s /bin/sh -c "$DAEMON start" +} + +# +# Function that retrives the status of the daemon/service +# +do_status() +{ + su oneadmin -s /bin/sh -c "$DAEMON status" +} + +# +# Function that stops the daemon/service +# +do_stop() +{ + su oneadmin -s /bin/sh -c "$DAEMON stop" +} + +case "$1" in + start) + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + status) + do_status && exit 0 || exit $? + ;; + stop) + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + restart|force-reload) + # + # If the "reload" option is implemented then remove the + # 'force-reload' alias + # + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 + exit 3 + ;; +esac + +: diff --git a/share/pkgs/Debian8/opennebula-sunstone b/share/pkgs/Debian8/opennebula-sunstone new file mode 100755 index 0000000000..34e9e1fbfb --- /dev/null +++ b/share/pkgs/Debian8/opennebula-sunstone @@ -0,0 +1,108 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: opennebula-sunstone +# Required-Start: $remote_fs +# Required-Stop: $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Sunstone init script +# Description: OpenNebula Sunstone web interface cloud initialisation script +### END INIT INFO + +# Author: Jaime Melis + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +DESC="Sunstone Web interface" +NAME=sunstone-server +DAEMON=/usr/bin/$NAME +DAEMON_ARGS="" +SCRIPTNAME=/etc/init.d/opennebula-sunstone +PID_FILE=/var/run/one/sunstone.pid + +# Exit if the package is not installed +[ -x "$DAEMON" ] || exit 0 + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. +. /lib/lsb/init-functions + +# +# Function that starts the daemon/service +# +do_start() +{ + service opennebula-novnc start + mkdir -p /var/run/one /var/lock/one /var/log/one + chown oneadmin /var/run/one /var/lock/one /var/log/one + su oneadmin -s /bin/sh -c "$DAEMON start-sunstone" +} + +# +# Function that stops the daemon/service +# +do_stop() +{ + su oneadmin -s /bin/sh -c "$DAEMON stop-sunstone" + service opennebula-novnc stop +} + +case "$1" in + start) + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + stop) + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + status) + SUNSTONE_PID=`cat $PID_FILE` + kill -0 $SUNSTONE_PID > /dev/null 2>&1 + if [ "$?" -eq "0" ]; then + log_daemon_msg "$NAME is running" + log_end_msg 0 + else + log_daemon_msg "$NAME is not running" + log_end_msg 1 + fi + ;; + restart|force-reload) + # + # If the "reload" option is implemented then remove the + # 'force-reload' alias + # + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 + exit 3 + ;; +esac + +: diff --git a/share/pkgs/Debian/opennebula.sudoers b/share/pkgs/Debian8/opennebula.sudoers similarity index 100% rename from share/pkgs/Debian/opennebula.sudoers rename to share/pkgs/Debian8/opennebula.sudoers diff --git a/src/cli/one_helper/onehost_helper.rb b/src/cli/one_helper/onehost_helper.rb index a9ed75ea51..44f262daa4 100644 --- a/src/cli/one_helper/onehost_helper.rb +++ b/src/cli/one_helper/onehost_helper.rb @@ -167,6 +167,11 @@ class OneHostHelper < OpenNebulaHelper::OneHelper NUM_THREADS = 15 def sync(host_ids, options) + if `id -u`.to_i == 0 || `id -G`.split.collect{|e| e.to_i}.include?(0) + STDERR.puts("Cannot run 'onehost sync' as root") + exit -1 + end + begin current_version = File.read(REMOTES_LOCATION+'/VERSION').strip rescue diff --git a/src/cli/one_helper/onevnet_helper.rb b/src/cli/one_helper/onevnet_helper.rb index 958876b7d6..33f89a40a7 100644 --- a/src/cli/one_helper/onevnet_helper.rb +++ b/src/cli/one_helper/onevnet_helper.rb @@ -303,11 +303,11 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper d['AR_ID'] end - column :OWNER, "", :left, :size=>10 do |d| + column :OWNER, "", :left, :size=>15 do |d| if d['VM'] - "VM : #{d['VM']}" + "V:#{d['VM']}" elsif d['VNET'] - "NET: #{d['VNET']}" + "N:#{d['VNET']}" end end @@ -319,7 +319,7 @@ class OneVNetHelper < OpenNebulaHelper::OneHelper d["IP"]||"-" end - column :IP6_GLOBAL, "", :donottruncate, :size=>31 do |d| + column :IP6_GLOBAL, "", :donottruncate, :size=>26 do |d| d["IP6_GLOBAL"]||"-" end end.show(leases, {}) diff --git a/src/cli/onevcenter b/src/cli/onevcenter index 87f11bc617..00bbc98944 100755 --- a/src/cli/onevcenter +++ b/src/cli/onevcenter @@ -216,84 +216,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do end vms_desc = <<-EOT.unindent - Import vCenter running Virtual Machines into OpenNebula + Deprecated action in onevcenter, please use onehost importvm instead EOT command :vms, vms_desc, :options=>[ VCENTER, USER, PASS ] do - if options[:vuser].nil? || - options[:vpass].nil? || - options[:vcenter].nil? - STDERR.puts "vCenter connection parameters are mandatory to import"\ - " VM templates:\n"\ - "\t --vcenter vCenter hostname\n"\ - "\t --vuser username to login in vcenter\n"\ - "\t --vpass password for the user" - exit -1 - end + STDERR.puts "Deprecated action in onevcenter, please use onehost "\ + "importvm instead" - begin - STDOUT.print "\nConnecting to vCenter: #{options[:vcenter]}..." - - vc = VCenterDriver::VIClient.new_connection( - :user => options[:vuser], - :password => options[:vpass], - :host => options[:vcenter]) - - STDOUT.print "done!\n\n" - - STDOUT.print "Looking for running Virtual Machines..." - - rs = vc.running_vms - - STDOUT.print "done!\n" - - rs.each {|dc, tmps| - STDOUT.print "\nDo you want to process datacenter #{dc} [y/n]? " - - next if STDIN.gets.strip.downcase != 'y' - - if tmps.empty? - STDOUT.print " No new running Virtual Machines found in"\ - " #{dc}...\n\n" - next - end - - tmps.each{ |v| - STDOUT.print "\n * Running Virtual Machine found:\n"\ - " - Name : #{v[:name]}\n"\ - " - UUID : #{v[:uuid]}\n"\ - " - Cluster: #{v[:host]}\n"\ - " Import this Virtual Machine [y/n]? " - - next if STDIN.gets.strip.downcase != 'y' - - one_v = ::OpenNebula::VirtualMachine.new( - ::OpenNebula::VirtualMachine.build_xml, vc.one) - - rc = one_v.allocate(v[:one]) - - if ::OpenNebula.is_error?(rc) - STDOUT.puts " Error creating Virtual Machine: "\ - "#{rc.message}\n" - end - - rc = one_v.deploy v[:host_id] - - if ::OpenNebula.is_error?(rc) - STDOUT.puts " Error creating Virtual Machine: "\ - "#{rc.message}\n" - else - STDOUT.puts " OpenNebula VM #{one_v.id} "\ - "created!\n" - end - } - } - rescue Exception => e - STDOUT.puts "error: #{e.message}" - exit -1 - end - - exit 0 + exit -1 end network_desc = <<-EOT.unindent diff --git a/src/datastore_mad/remotes/fs/cp b/src/datastore_mad/remotes/fs/cp index e65991a68e..cfd9560d8c 100755 --- a/src/datastore_mad/remotes/fs/cp +++ b/src/datastore_mad/remotes/fs/cp @@ -52,6 +52,7 @@ done < <($XPATH /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH \ /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/SAFE_DIRS \ /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/BRIDGE_LIST \ /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/STAGING_DIR \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TYPE \ /DS_DRIVER_ACTION_DATA/IMAGE/PATH \ /DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/MD5 \ /DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/SHA1 \ @@ -65,6 +66,7 @@ RESTRICTED_DIRS="${XPATH_ELEMENTS[i++]}" SAFE_DIRS="${XPATH_ELEMENTS[i++]}" BRIDGE_LIST="${XPATH_ELEMENTS[i++]}" STAGING_DIR="${XPATH_ELEMENTS[i++]:-/var/tmp}" +TYPE="${XPATH_ELEMENTS[i++]}" SRC="${XPATH_ELEMENTS[i++]}" MD5="${XPATH_ELEMENTS[i++]}" SHA1="${XPATH_ELEMENTS[i++]}" @@ -76,6 +78,11 @@ IMAGE_HASH=`basename $DST` set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS" +# Disable auto-decompress for the 'files' datastores (type 2) +if [ "$TYPE" = "2" ]; then + NO_DECOMPRESS="${NO_DECOMPRESS:-yes}" +fi + if [ -n "$BRIDGE_LIST" ]; then DOWNLOADER_ARGS=`set_downloader_args "$MD5" "$SHA1" "$NO_DECOMPRESS" "$LIMIT_TRANSFER_BW" "$SRC" -` else diff --git a/src/im_mad/remotes/kvm-probes.d/kvm.rb b/src/im_mad/remotes/kvm-probes.d/kvm.rb index 7209dd67b5..32db20488f 100755 --- a/src/im_mad/remotes/kvm-probes.d/kvm.rb +++ b/src/im_mad/remotes/kvm-probes.d/kvm.rb @@ -26,6 +26,8 @@ end # TODO : use virsh freecell when available ###### +ENV['LANG'] = 'C' + nodeinfo_text = `virsh -c qemu:///system nodeinfo` exit(-1) if $?.exitstatus != 0 @@ -40,36 +42,31 @@ nodeinfo_text.split(/\n/).each{|line| } ###### -# for everything else, top & proc -##### +# CPU +###### +vmstat = `vmstat 1 2` +$free_cpu = $total_cpu * ((vmstat.split("\n").to_a.last.split)[14].to_i)/100 +$used_cpu = $total_cpu - $free_cpu -NETINTERFACE = "eth|bond|em|p[0-9]+p[0-9]+" +###### +# MEMORY +###### +memory = `cat /proc/meminfo` +meminfo = Hash.new() +memory.each_line do |line| + key, value = line.split(':') + meminfo[key] = /\d+/.match(value)[0].to_i +end -top_text=`top -bin2` -exit(-1) if $?.exitstatus != 0 +$total_memory = meminfo['MemTotal'] -top_text.gsub!(/^top.*^top.*?$/m, "") # Strip first top output +$used_memory = meminfo['MemTotal'] - meminfo['MemFree'] - meminfo['Buffers'] - meminfo['Cached'] +$free_memory = $total_memory - $used_memory -top_text.split(/\n/).each{|line| - if line.match('^%?Cpu') - line[7..-1].split(",").each{|elemento| - temp = elemento.strip.split(/[% ]/) - if temp[1]=="id" - idle = temp[0] - $free_cpu = idle.to_f * $total_cpu.to_f / 100 - $used_cpu = $total_cpu.to_f - $free_cpu - break - end - - } - end -} - -$total_memory = `free -k|grep "Mem:" | awk '{print $2}'` -tmp=`free -k|grep "buffers\/cache"|awk '{print $3 " " $4}'`.split - -$used_memory=tmp[0] -$free_memory=tmp[1] +###### +# INTERFACE +###### +NETINTERFACE = "eth|bond|em|enp|p[0-9]+p[0-9]+" net_text=`cat /proc/net/dev` exit(-1) if $?.exitstatus != 0 diff --git a/src/mad/sh/scripts_common.sh b/src/mad/sh/scripts_common.sh index 343e869186..43317bce2f 100644 --- a/src/mad/sh/scripts_common.sh +++ b/src/mad/sh/scripts_common.sh @@ -320,7 +320,7 @@ function mkfs_command { OPTS="-F" ;; - "reiserfs") + "reiserfs"|"xfs") OPTS="-f -q" ;; @@ -355,7 +355,9 @@ function mkfs_command { return 0 ;; *) - OPTS="" + echo "" + echo "Filesystem '$FSTYPE' not valid." 1>&2 + return 1 ;; esac diff --git a/src/nebula/NebulaTemplate.cc b/src/nebula/NebulaTemplate.cc index 1741404ae2..876310daf0 100644 --- a/src/nebula/NebulaTemplate.cc +++ b/src/nebula/NebulaTemplate.cc @@ -356,11 +356,18 @@ void OpenNebulaTemplate::set_conf_default() #******************************************************************************* # Auth Manager Configuration #******************************************************************************* +# DEFAULT_AUTH # SESSION_EXPIRATION_TIME # ENABLE_OTHER_PERMISSIONS # DEFAULT_UMASK #******************************************************************************* */ + // DEFAULT_AUTH + value = "default"; + + attribute = new SingleAttribute("DEFAULT_AUTH",value); + conf_default.insert(make_pair(attribute->name(),attribute)); + // SESSION_EXPIRATION_TIME value = "0"; diff --git a/src/oca/ruby/opennebula/client.rb b/src/oca/ruby/opennebula/client.rb index d649f36e8f..a733dd5269 100644 --- a/src/oca/ruby/opennebula/client.rb +++ b/src/oca/ruby/opennebula/client.rb @@ -130,7 +130,7 @@ module OpenNebula raise "ONE_AUTH file not present" end - @one_auth.rstrip! + @one_auth = @one_auth.rstrip if endpoint @one_endpoint = endpoint @@ -144,6 +144,8 @@ module OpenNebula @one_endpoint = "http://localhost:2633/RPC2" end + @one_endpoint= @one_endpoint.rstrip + @async = !options[:sync] timeout=nil diff --git a/src/sunstone/public/js/plugins/templates-tab.js b/src/sunstone/public/js/plugins/templates-tab.js index 6b9a0cb99b..d49806a618 100644 --- a/src/sunstone/public/js/plugins/templates-tab.js +++ b/src/sunstone/public/js/plugins/templates-tab.js @@ -503,7 +503,7 @@ if (Config.isTemplateCreationTabEnabled('input_output')){ ''+ ''+ ''+ - '
'+ + '
'+ ''+ diff --git a/src/sunstone/routes/vcenter.rb b/src/sunstone/routes/vcenter.rb index 74d09b03bb..ac7c125e18 100644 --- a/src/sunstone/routes/vcenter.rb +++ b/src/sunstone/routes/vcenter.rb @@ -87,26 +87,6 @@ get '/vcenter/templates' do end end - -get '/vcenter/vms' do - begin - vms = vcenter_client.running_vms( - $cloud_auth.client(session[:user], session[:active_zone_endpoint])) - if vms.nil? - msg = "No datacenter found" - logger.error("[vCenter] " + msg) - error = Error.new(msg) - error 404, error.to_json - end - - [200, vms.to_json] - rescue Exception => e - logger.error("[vCenter] " + e.message) - error = Error.new(e.message) - error 403, error.to_json - end -end - get '/vcenter/networks' do begin networks = vcenter_client.vcenter_networks( diff --git a/src/tm_mad/ceph/failmigrate b/src/tm_mad/ceph/failmigrate new file mode 120000 index 0000000000..5928a42794 --- /dev/null +++ b/src/tm_mad/ceph/failmigrate @@ -0,0 +1 @@ +../common/failmigrate \ No newline at end of file diff --git a/src/tm_mad/common/failmigrate b/src/tm_mad/common/failmigrate new file mode 100755 index 0000000000..49ab4a881d --- /dev/null +++ b/src/tm_mad/common/failmigrate @@ -0,0 +1,29 @@ +#!/bin/bash + +# -------------------------------------------------------------------------- # +# Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # +# FAILMIGRATE SOURCE DST remote_system_dir vmid dsid template +# - SOURCE is the host where the VM is running +# - DST is the host where the VM failed to be migrated +# - remote_system_dir is the path for the VM home in the system datastore +# - vmid is the id of the VM +# - dsid is the target datastore +# - template is the template of the VM in XML and base64 encoded + +# To access the vm_template you can use the xpath.rb utility. Check the +# datastore drivers for an example. + +exit 0 diff --git a/src/tm_mad/dev/failmigrate b/src/tm_mad/dev/failmigrate new file mode 120000 index 0000000000..5928a42794 --- /dev/null +++ b/src/tm_mad/dev/failmigrate @@ -0,0 +1 @@ +../common/failmigrate \ No newline at end of file diff --git a/src/tm_mad/dummy/failmigrate b/src/tm_mad/dummy/failmigrate new file mode 120000 index 0000000000..5928a42794 --- /dev/null +++ b/src/tm_mad/dummy/failmigrate @@ -0,0 +1 @@ +../common/failmigrate \ No newline at end of file diff --git a/src/tm_mad/fs_lvm/failmigrate b/src/tm_mad/fs_lvm/failmigrate new file mode 120000 index 0000000000..5928a42794 --- /dev/null +++ b/src/tm_mad/fs_lvm/failmigrate @@ -0,0 +1 @@ +../common/failmigrate \ No newline at end of file diff --git a/src/tm_mad/lvm/failmigrate b/src/tm_mad/lvm/failmigrate new file mode 120000 index 0000000000..5928a42794 --- /dev/null +++ b/src/tm_mad/lvm/failmigrate @@ -0,0 +1 @@ +../common/failmigrate \ No newline at end of file diff --git a/src/tm_mad/qcow2/failmigrate b/src/tm_mad/qcow2/failmigrate new file mode 120000 index 0000000000..5928a42794 --- /dev/null +++ b/src/tm_mad/qcow2/failmigrate @@ -0,0 +1 @@ +../common/failmigrate \ No newline at end of file diff --git a/src/tm_mad/shared/failmigrate b/src/tm_mad/shared/failmigrate new file mode 120000 index 0000000000..5928a42794 --- /dev/null +++ b/src/tm_mad/shared/failmigrate @@ -0,0 +1 @@ +../common/failmigrate \ No newline at end of file diff --git a/src/tm_mad/ssh/failmigrate b/src/tm_mad/ssh/failmigrate new file mode 120000 index 0000000000..5928a42794 --- /dev/null +++ b/src/tm_mad/ssh/failmigrate @@ -0,0 +1 @@ +../common/failmigrate \ No newline at end of file diff --git a/src/tm_mad/vmfs/failmigrate b/src/tm_mad/vmfs/failmigrate new file mode 120000 index 0000000000..5928a42794 --- /dev/null +++ b/src/tm_mad/vmfs/failmigrate @@ -0,0 +1 @@ +../common/failmigrate \ No newline at end of file diff --git a/src/um/UserPool.cc b/src/um/UserPool.cc index fc50c7dee1..808d8c829b 100644 --- a/src/um/UserPool.cc +++ b/src/um/UserPool.cc @@ -36,7 +36,6 @@ const char * UserPool::CORE_AUTH = "core"; const char * UserPool::SERVER_AUTH = "server*"; const char * UserPool::PUBLIC_AUTH = "public"; -const char * UserPool::DEFAULT_AUTH = "default"; const char * UserPool::SERVER_NAME = "serveradmin"; @@ -248,7 +247,7 @@ error_no_open: erro_exists: oss << "Password file " << filenames[i] << " already exists " - << "but OpenNebula is boostraping the database. Check your " + << "but OpenNebula is boostraping the database. Check your " << "database configuration in oned.conf."; goto error_common; @@ -713,6 +712,7 @@ bool UserPool::authenticate_external(const string& username, string mad_pass; string error_str; string tmp_str; + string default_auth; Nebula& nd = Nebula::instance(); AuthManager * authm = nd.get_authm(); @@ -734,7 +734,9 @@ bool UserPool::authenticate_external(const string& username, } //Initialize authentication request and call the driver - ar.add_authenticate(UserPool::DEFAULT_AUTH, username,"-",token); + nd.get_configuration_attribute("DEFAULT_AUTH",default_auth); + + ar.add_authenticate(default_auth, username,"-",token); authm->trigger(AuthManager::AUTHENTICATE, &ar); ar.wait(); diff --git a/src/vmm_mad/exec/one_vmm_exec.rb b/src/vmm_mad/exec/one_vmm_exec.rb index 4e4ffaa7b2..3f45fb4560 100755 --- a/src/vmm_mad/exec/one_vmm_exec.rb +++ b/src/vmm_mad/exec/one_vmm_exec.rb @@ -478,9 +478,11 @@ class ExecDriver < VirtualMachineDriver action = VmmAction.new(self, id, :migrate, drv_message) pre = "PRE" post = "POST" + failed = "FAIL" pre << action.data[:tm_command] << " " << action.data[:vm] post << action.data[:tm_command] << " " << action.data[:vm] + failed << action.data[:tm_command] << " " << action.data[:vm] steps=[ # Execute a pre-migrate TM setup @@ -499,7 +501,15 @@ class ExecDriver < VirtualMachineDriver { :driver => :vmm, :action => :migrate, - :parameters => [:deploy_id, :dest_host, :host] + :parameters => [:deploy_id, :dest_host, :host], + :fail_actions => [ + { + :driver => :tm, + :action => :tm_failmigrate, + :parameters => failed.split, + :no_fail => true + } + ] }, # Execute networking clean up operations # NOTE: VM is now in the new host. If we fail from now on, oned will diff --git a/src/vmm_mad/remotes/vcenter/vcenter_driver.rb b/src/vmm_mad/remotes/vcenter/vcenter_driver.rb index aaba592cb3..e86d9cde30 100644 --- a/src/vmm_mad/remotes/vcenter/vcenter_driver.rb +++ b/src/vmm_mad/remotes/vcenter/vcenter_driver.rb @@ -146,7 +146,50 @@ class VIClient # The associated resource pool for this connection ######################################################################## def resource_pool - return @cluster.resourcePool + rp_name = @one_host["TEMPLATE/VCENTER_RESOURCE_POOL"] + + if rp_name.nil? + @cluster.resourcePool + else + find_resource_pool(rp_name) + end + end + + ######################################################################## + # Searches the desired ResourcePool of the DataCenter for the current + # connection. Returns a RbVmomi::VIM::ResourcePool or the default pool + # if not found + # @param rpool [String] the ResourcePool name + ######################################################################## + def find_resource_pool(poolName) + baseEntity = @cluster + entityArray = poolName.split('/') + entityArray.each do |entityArrItem| + if entityArrItem != '' + if baseEntity.is_a? RbVmomi::VIM::Folder + baseEntity = baseEntity.childEntity.find { |f| + f.name == entityArrItem + } or return @cluster.resourcePool + elsif baseEntity.is_a? RbVmomi::VIM::ClusterComputeResource + baseEntity = baseEntity.resourcePool.resourcePool.find { |f| + f.name == entityArrItem + } or return @cluster.resourcePool + elsif baseEntity.is_a? RbVmomi::VIM::ResourcePool + baseEntity = baseEntity.resourcePool.find { |f| + f.name == entityArrItem + } or return @cluster.resourcePool + else + return @cluster.resourcePool + end + end + end + + if !baseEntity.is_a?(RbVmomi::VIM::ResourcePool) and + baseEntity.respond_to?(:resourcePool) + baseEntity = baseEntity.resourcePool + end + + baseEntity end ######################################################################## @@ -538,7 +581,8 @@ class VCenterHost < ::OpenNebula::Host ############################################################################ # Generate an OpenNebula monitor string for this host. Reference: - # https://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/vim.ComputeResource.Summary.html + # https://www.vmware.com/support/developer/vc-sdk/visdk25pubs/Reference + # Guide/vim.ComputeResource.Summary.html # - effectiveCpu: Effective CPU resources (in MHz) available to run # VMs. This is the aggregated from all running hosts excluding hosts in # maintenance mode or unresponsive are not counted. @@ -690,6 +734,22 @@ class VCenterVm hid = VIClient::translate_hostname(hostname) connection = VIClient.new(hid) vm = connection.find_vm_template(deploy_id) + + # Find out if we need to reconfigure capacity + xml = REXML::Document.new xml_text + + expected_cpu = xml.root.elements["//TEMPLATE/CPU"].text + expected_memory = xml.root.elements["//TEMPLATE/MEMORY"].text + current_cpu = vm.config.hardware.numCPU + current_memory = vm.config.hardware.memoryMB + + if current_cpu != expected_cpu or current_memory != expected_memory + capacity_hash = {:numCPUs => expected_cpu.to_i, + :memoryMB => expected_memory } + spec = RbVmomi::VIM.VirtualMachineConfigSpec(capacity_hash) + vm.ReconfigVM_Task(:spec => spec).wait_for_completion + end + vm.PowerOnVM_Task.wait_for_completion return vm.config.uuid end @@ -1058,6 +1118,8 @@ class VCenterVm # ######################################################################## def vm_to_one + host_name = @vm.runtime.host.parent.name + str = "NAME = \"#{@vm.name}\"\n"\ "CPU = \"#{@vm.config.hardware.numCPU}\"\n"\ "vCPU = \"#{@vm.config.hardware.numCPU}\"\n"\ @@ -1068,21 +1130,25 @@ class VCenterVm " VM_TEMPLATE =\"#{@vm.config.uuid}\"\n"\ "]\n"\ "IMPORT_VM_ID = \"#{@vm.config.uuid}\"\n"\ - "SCHED_REQUIREMENTS=\"NAME=\\\"#{@vm.runtime.host.parent.name}\\\"\"\n" + "SCHED_REQUIREMENTS=\"NAME=\\\"#{host_name}\\\"\"\n" - vp=@vm.config.extraConfig.select{|v| v[:key]=="remotedisplay.vnc.port"} + vp = @vm.config.extraConfig.select{|v| + v[:key]=="remotedisplay.vnc.port"} + keymap = @vm.config.extraConfig.select{|v| + v[:key]=="remotedisplay.vnc.keymap"} if vp.size > 0 str << "GRAPHICS = [\n"\ " TYPE =\"vnc\",\n"\ " LISTEN =\"0.0.0.0\",\n"\ - " PORT =\"#{vp[0][:value]}\"\n"\ - "]\n" + " PORT =\"#{vp[0][:value]}\"\n" + str << " ,KEYMAP =\"#{keymap[0][:value]}\"\n" if keymap + str << "]\n" end if @vm.config.annotation.nil? || @vm.config.annotation.empty? - str << "DESCRIPTION = \"vCenter Virtual Machine imported by OpenNebula"\ - " from Cluster #{@vm.runtime.host.parent.name}\"\n" + str << "DESCRIPTION = \"vCenter Virtual Machine imported by"\ + " OpenNebula from Cluster #{@vm.runtime.host.parent.name}\"\n" else notes = @vm.config.annotation.gsub("\\", "\\\\").gsub("\"", "\\\"") str << "DESCRIPTION = \"#{notes}\"\n" @@ -1193,7 +1259,6 @@ private def self.clone_vm(xml_text) xml = REXML::Document.new xml_text - pcs = xml.root.get_elements("//USER_TEMPLATE/PUBLIC_CLOUD") raise "Cannot find VCenter element in VM template." if pcs.nil? @@ -1210,33 +1275,29 @@ private raise "Cannot find VM_TEMPLATE in VCenter element." if uuid.nil? uuid = uuid.text - vmid = xml.root.elements["/VM/ID"].text - hid = xml.root.elements["//HISTORY_RECORDS/HISTORY/HID"] raise "Cannot find host id in deployment file history." if hid.nil? context = xml.root.elements["//TEMPLATE/CONTEXT"] - connection = VIClient.new(hid) - vc_template = connection.find_vm_template(uuid) relocate_spec = RbVmomi::VIM.VirtualMachineRelocateSpec( - :diskMoveType => :moveChildMostDiskBacking, - :pool => connection.resource_pool) + :diskMoveType => :moveChildMostDiskBacking, + :pool => connection.resource_pool) clone_spec = RbVmomi::VIM.VirtualMachineCloneSpec( - :location => relocate_spec, - :powerOn => false, - :template => false) + :location => relocate_spec, + :powerOn => false, + :template => false) begin vm = vc_template.CloneVM_Task( - :folder => vc_template.parent, - :name => "one-#{vmid}", - :spec => clone_spec).wait_for_completion + :folder => vc_template.parent, + :name => "one-#{vmid}", + :spec => clone_spec).wait_for_completion rescue Exception => e if !e.message.start_with?('DuplicateName') @@ -1247,8 +1308,7 @@ private raise "Cannot clone VM Template" if vm.nil? - vm.Destroy_Task.wait_for_completion - + vm.Destroy_Task.wait_for_completion vm = vc_template.CloneVM_Task( :folder => vc_template.parent, :name => "one-#{vmid}", @@ -1257,8 +1317,11 @@ private vm_uuid = vm.config.uuid + # VNC Section + vnc_port = xml.root.elements["/VM/TEMPLATE/GRAPHICS/PORT"] vnc_listen = xml.root.elements["/VM/TEMPLATE/GRAPHICS/LISTEN"] + vnc_keymap = xml.root.elements["/VM/TEMPLATE/GRAPHICS/KEYMAP"] if !vnc_listen vnc_listen = "0.0.0.0" @@ -1271,11 +1334,16 @@ private if vnc_port config_array += - [{:key=>"remotedisplay.vnc.enabled", :value=>"TRUE"}, - {:key=>"remotedisplay.vnc.port", :value=>vnc_port.text}, - {:key=>"remotedisplay.vnc.ip", :value=>vnc_listen}] + [{:key=>"remotedisplay.vnc.enabled",:value=>"TRUE"}, + {:key=>"remotedisplay.vnc.port", :value=>vnc_port.text}, + {:key=>"remotedisplay.vnc.ip", :value=>vnc_listen}] end + config_array += [{:key=>"remotedisplay.vnc.keymap", + :value=>vnc_keymap.text}] if vnc_keymap + + # Context section + if context # Remove (9) and \n (11) context_text = "# Context variables generated by OpenNebula\n" @@ -1293,7 +1361,8 @@ private context_vnc_spec = {:extraConfig =>config_array} end - # Take care of the NIC section, build the reconfig hash + # NIC section, build the reconfig hash + nics = xml.root.get_elements("//TEMPLATE/NIC") nic_spec = {} @@ -1309,12 +1378,19 @@ private nic_spec = {:deviceChange => nic_array} end - if !context_vnc_spec.empty? or !nic_spec.empty? - spec_hash = context_vnc_spec.merge(nic_spec) - spec = RbVmomi::VIM.VirtualMachineConfigSpec(spec_hash) - vm.ReconfigVM_Task(:spec => spec).wait_for_completion - end + # Capacity section + cpu = xml.root.elements["//TEMPLATE/CPU"].text + memory = xml.root.elements["//TEMPLATE/MEMORY"].text + capacity_spec = {:numCPUs => cpu.to_i, + :memoryMB => memory } + + # Perform the VM reconfiguration + spec_hash = context_vnc_spec.merge(nic_spec).merge(capacity_spec) + spec = RbVmomi::VIM.VirtualMachineConfigSpec(spec_hash) + vm.ReconfigVM_Task(:spec => spec).wait_for_completion + + # Power on the VM vm.PowerOnVM_Task.wait_for_completion return vm_uuid diff --git a/src/vmm_mad/remotes/vmware/shutdown b/src/vmm_mad/remotes/vmware/shutdown index fbaac03238..50041948de 100755 --- a/src/vmm_mad/remotes/vmware/shutdown +++ b/src/vmm_mad/remotes/vmware/shutdown @@ -28,6 +28,7 @@ $: << RUBY_LIB_LOCATION $: << File.dirname(__FILE__) require 'vmware_driver' +require 'vi_driver' #------------------------------------------------------------------------------ # Wait the VM to shutdown TIMEOUT (xPOLL_INTERVAL) seconds. @@ -39,12 +40,14 @@ TIMEOUT=300 deploy_id = ARGV[0] host = ARGV[1] +VIDriver::initialize(host) + vmware_drv = VMwareDriver.new(host) vmware_drv.shutdown(deploy_id) count=0 -while (vmware_drv.poll(deploy_id).match(/STATE=(.*)/)[1] != "d") do +while (VIDriver::poll_vm(deploy_id).match(/STATE=(.*)/)[1] != "d") do sleep POLL_INTERVAL if count > TIMEOUT then OpenNebula.log_debug("Timeout reached and VM #{deploy_id} is still alive.") diff --git a/src/vnm_mad/remotes/ebtables/Ebtables.rb b/src/vnm_mad/remotes/ebtables/Ebtables.rb index 931bd23308..cf1f29b788 100644 --- a/src/vnm_mad/remotes/ebtables/Ebtables.rb +++ b/src/vnm_mad/remotes/ebtables/Ebtables.rb @@ -62,8 +62,15 @@ class EbtablesVLAN < VNMMAD::VNMDriver def deactivate lock + attach_nic_id = @vm['TEMPLATE/NIC[ATTACH="YES"]/NIC_ID'] + process do |nic| + if attach_nic_id && attach_nic_id != nic[:nic_id] + next + end + mac = nic[:mac] + # remove 0-padding mac = mac.split(":").collect{|e| e.hex.to_s(16)}.join(":") diff --git a/src/vnm_mad/remotes/lib/fw_driver.rb b/src/vnm_mad/remotes/lib/fw_driver.rb index 513f7980ed..592b3f7f44 100644 --- a/src/vnm_mad/remotes/lib/fw_driver.rb +++ b/src/vnm_mad/remotes/lib/fw_driver.rb @@ -40,7 +40,7 @@ module VNMMAD lock vm_id = @vm['ID'] - + process do |nic| #:white_ports_tcp => iptables_range #:white_ports_udp => iptables_range @@ -93,8 +93,15 @@ module VNMMAD def deactivate lock - vm_id = @vm['ID'] + vm_id = @vm['ID'] + + attach_nic_id = @vm['TEMPLATE/NIC[ATTACH="YES"]/NIC_ID'] + process do |nic| + if attach_nic_id && attach_nic_id != nic[:nic_id] + next + end + chain = "one-#{vm_id}-#{nic[:network_id]}" iptables_out = `#{command(:iptables)} -n -v --line-numbers -L FORWARD` if m = iptables_out.match(/.*#{chain}.*/) @@ -196,4 +203,4 @@ module VNMMAD "#{command(:iptables)} #{rule}" end end -end \ No newline at end of file +end diff --git a/src/vnm_mad/remotes/lib/sg_driver.rb b/src/vnm_mad/remotes/lib/sg_driver.rb index bf2efea5f4..9a87b0ccbb 100644 --- a/src/vnm_mad/remotes/lib/sg_driver.rb +++ b/src/vnm_mad/remotes/lib/sg_driver.rb @@ -23,7 +23,7 @@ module VNMMAD DRIVER = "sg" XPATH_FILTER = "TEMPLATE/NIC" - + # Creates a new SG driver and scans SG Rules def initialize(vm, deploy_id = nil, hypervisor = nil) super(vm, XPATH_FILTER, deploy_id, hypervisor) @@ -48,7 +48,7 @@ module VNMMAD @security_group_rules = rules end - # Activate the rules, bootstrap iptables chains and set filter rules for + # Activate the rules, bootstrap iptables chains and set filter rules for # each VM NIC def activate deactivate @@ -68,7 +68,7 @@ module VNMMAD sg_ids.each do |sg_id| rules = @security_group_rules[sg_id] - sg = SGIPTables::SecurityGroupIPTables.new(@vm, nic, sg_id, + sg = SGIPTables::SecurityGroupIPTables.new(@vm, nic, sg_id, rules) begin @@ -92,7 +92,13 @@ module VNMMAD lock begin + attach_nic_id = @vm['TEMPLATE/NIC[ATTACH="YES"]/NIC_ID'] + @vm.nics.each do |nic| + if attach_nic_id && attach_nic_id != nic[:nic_id] + next + end + SGIPTables.nic_deactivate(@vm, nic) end rescue Exception => e diff --git a/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb b/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb index 8a1bd5e848..adb9e74a44 100644 --- a/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb +++ b/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb @@ -72,7 +72,13 @@ class OpenvSwitchVLAN < VNMMAD::VNMDriver def deactivate lock + attach_nic_id = @vm['TEMPLATE/NIC[ATTACH="YES"]/NIC_ID'] + process do |nic| + if attach_nic_id && attach_nic_id != nic[:nic_id] + next + end + @nic = nic # Remove flows