1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-27 14:03:40 +03:00

Merge branch 'master' into feature-1437

Conflicts:
	install.sh
This commit is contained in:
Tino Vazquez 2012-09-20 19:03:19 +02:00
commit 6281564810
109 changed files with 3646 additions and 1850 deletions

View File

@ -46,6 +46,7 @@ public:
{ {
SUSPEND_SUCCESS,/**< Send by LCM when a VM is suspended*/ SUSPEND_SUCCESS,/**< Send by LCM when a VM is suspended*/
STOP_SUCCESS, /**< Send by LCM when a VM is stopped*/ STOP_SUCCESS, /**< Send by LCM when a VM is stopped*/
POWEROFF_SUCCESS, /**< Send by LCM when a VM is powered off */
DONE, /**< Send by LCM when a VM is shut down*/ DONE, /**< Send by LCM when a VM is shut down*/
FAILED, /**< Send by LCM when one of the execution steps fails*/ FAILED, /**< Send by LCM when one of the execution steps fails*/
RESUBMIT, /**< Send by LCM when a VM is ready for resubmission*/ RESUBMIT, /**< Send by LCM when a VM is ready for resubmission*/
@ -129,6 +130,15 @@ public:
int shutdown ( int shutdown (
int vid); int vid);
/**
* Powers off a VM.
* @param vid VirtualMachine identification
* @return 0 on success, -1 if the VM does not exits or -2 if the VM is
* in a wrong a state
*/
int poweroff (
int vid);
/** /**
* Holds a VM. * Holds a VM.
* @param vid VirtualMachine identification * @param vid VirtualMachine identification
@ -317,6 +327,8 @@ private:
void stop_success_action(int vid); void stop_success_action(int vid);
void poweroff_success_action(int vid);
void done_action(int vid); void done_action(int vid);
void failed_action(int vid); void failed_action(int vid);

View File

@ -70,6 +70,7 @@ public:
MIGRATE, /**< Sent by the DM to migrate a VM to other host */ MIGRATE, /**< Sent by the DM to migrate a VM to other host */
LIVE_MIGRATE, /**< Sent by the DM to live-migrate a VM */ LIVE_MIGRATE, /**< Sent by the DM to live-migrate a VM */
SHUTDOWN, /**< Sent by the DM to shutdown a running VM */ SHUTDOWN, /**< Sent by the DM to shutdown a running VM */
POWEROFF, /**< Sent by the DM to power off a running VM */
RESTART, /**< Sent by the DM to restart a deployed VM */ RESTART, /**< Sent by the DM to restart a deployed VM */
DELETE, /**< Sent by the DM to delete a VM */ DELETE, /**< Sent by the DM to delete a VM */
CLEAN, /**< Sent by the DM to cleanup a VM for resubmission*/ CLEAN, /**< Sent by the DM to cleanup a VM for resubmission*/
@ -202,6 +203,8 @@ private:
void shutdown_action(int vid); void shutdown_action(int vid);
void poweroff_action(int vid);
void failure_action(VirtualMachine * vm); void failure_action(VirtualMachine * vm);
void restart_action(int vid); void restart_action(int vid);

View File

@ -63,15 +63,15 @@ public:
* Triggers specific actions to the Information Manager. This function * Triggers specific actions to the Information Manager. This function
* wraps the ActionManager trigger function. * wraps the ActionManager trigger function.
* @param action the IM action * @param action the IM action
* @param vid VM unique id. This is the argument of the passed to the * @param vid VM unique id. This is the argument of the passed to the
* invoked action. * invoked action.
*/ */
virtual void trigger( virtual void trigger(
Actions action, Actions action,
int vid); int vid);
/** /**
* 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 * new thread for the Information Manager. This thread will wait in
* an action loop till it receives ACTION_FINALIZE. * an action loop till it receives ACTION_FINALIZE.
* @return 0 on success. * @return 0 on success.
@ -80,12 +80,12 @@ public:
/** /**
* Loads Virtual Machine Manager Mads defined in configuration file * Loads Virtual Machine Manager Mads defined in configuration file
* @param uid of the user executing the driver. When uid is 0 the nebula * @param uid of the user executing the driver. When uid is 0 the nebula
* identity will be used. Otherwise the Mad will be loaded through the * identity will be used. Otherwise the Mad will be loaded through the
* sudo application. * sudo application.
*/ */
void load_mads(int uid); void load_mads(int uid);
/** /**
* Gets the thread identification. * Gets the thread identification.
* @return pthread_t for the manager thread (that in the action loop). * @return pthread_t for the manager thread (that in the action loop).
@ -128,6 +128,15 @@ public:
VirtualMachine * vm, VirtualMachine * vm,
const VectorAttribute * disk, const VectorAttribute * disk,
ostream& xfr); ostream& xfr);
/**
* Inserts a transfer command in the xfs stream, for live migration
*
* @param vm The VM
* @param xfr Stream where the transfer command will be written
*/
void migrate_transfer_command(
VirtualMachine * vm,
ostream& xfr);
private: private:
/** /**
@ -144,7 +153,7 @@ private:
* Pointer to the Host Pool, to access hosts * Pointer to the Host Pool, to access hosts
*/ */
HostPool * hpool; HostPool * hpool;
/** /**
* Action engine for the Manager * Action engine for the Manager
*/ */
@ -171,7 +180,7 @@ private:
}; };
/** /**
* Returns a pointer to a Transfer Manager driver. The driver is * Returns a pointer to a Transfer Manager driver. The driver is
* searched by its name. * searched by its name.
* @param name the name of the driver * @param name the name of the driver
* @return the TM driver owned by uid with attribute name equal to value * @return the TM driver owned by uid with attribute name equal to value
@ -184,9 +193,9 @@ private:
return static_cast<const TransferManagerDriver *> return static_cast<const TransferManagerDriver *>
(MadManager::get(0,_name,name)); (MadManager::get(0,_name,name));
}; };
/** /**
* Returns a pointer to a Transfer Manager driver. The driver is * Returns a pointer to a Transfer Manager driver. The driver is
* searched by its name. * searched by its name.
* @return the TM driver for the Transfer Manager * @return the TM driver for the Transfer Manager
*/ */
@ -198,11 +207,11 @@ private:
}; };
/** /**
* 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) * (requires C linkage)
*/ */
friend void * tm_action_loop(void *arg); friend void * tm_action_loop(void *arg);
/** /**
* The action function executed when an action is triggered. * The action function executed when an action is triggered.
* @param action the name of the action * @param action the name of the action
@ -213,20 +222,20 @@ private:
void * arg); void * arg);
/** /**
* This function starts the prolog sequence * This function starts the prolog sequence
*/ */
void prolog_action(int vid); void prolog_action(int vid);
/** /**
* This function starts the prolog migration sequence * This function starts the prolog migration sequence
*/ */
void prolog_migr_action(int vid); void prolog_migr_action(int vid);
/** /**
* This function starts the prolog resume sequence * This function starts the prolog resume sequence
*/ */
void prolog_resume_action(int vid); void prolog_resume_action(int vid);
/** /**
* This function starts the epilog sequence * This function starts the epilog sequence
*/ */
@ -236,7 +245,7 @@ private:
* This function starts the epilog_stop sequence * This function starts the epilog_stop sequence
*/ */
void epilog_stop_action(int vid); void epilog_stop_action(int vid);
/** /**
* This function starts the epilog_delete sequence * This function starts the epilog_delete sequence
*/ */
@ -275,4 +284,3 @@ private:
}; };
#endif /*TRANSFER_MANAGER_H*/ #endif /*TRANSFER_MANAGER_H*/

View File

@ -56,7 +56,8 @@ public:
STOPPED = 4, STOPPED = 4,
SUSPENDED = 5, SUSPENDED = 5,
DONE = 6, DONE = 6,
FAILED = 7 FAILED = 7,
POWEROFF = 8
}; };
/** /**
@ -81,7 +82,8 @@ public:
FAILURE = 14, FAILURE = 14,
CLEANUP = 15, CLEANUP = 15,
UNKNOWN = 16, UNKNOWN = 16,
HOTPLUG = 17 HOTPLUG = 17,
SHUTDOWN_POWEROFF = 18
}; };
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------

1223
install.sh

File diff suppressed because it is too large Load Diff

View File

@ -24,7 +24,7 @@ digraph OpenNebula {
color="white" } color="white" }
subgraph { rank = max; suspended; done; failure; subgraph { rank = max; suspended; done; failure;
stopped;color="white" } stopped; poweroff; color="white" }
# create # create
user -> pending [label="create"]; user -> pending [label="create"];
@ -42,6 +42,10 @@ digraph OpenNebula {
shutdown -> epilog [style="dashed"]; shutdown -> epilog [style="dashed"];
epilog -> done [style="dashed"]; epilog -> done [style="dashed"];
# poweroff
running -> shutdown_poweroff [label="poweroff"];
shutdown_poweroff -> poweroff [style="dashed"];
# livemigrate # livemigrate
running -> migrate [label="livemigrate"]; running -> migrate [label="livemigrate"];
migrate -> running [style="dashed"]; migrate -> running [style="dashed"];
@ -80,6 +84,7 @@ digraph OpenNebula {
# restart # restart
unknown -> boot [label="restart"]; unknown -> boot [label="restart"];
boot -> boot [label="restart"]; boot -> boot [label="restart"];
poweroff -> boot [label="restart"];
# reboot, reset # reboot, reset
running -> running [label="reboot / reset"]; running -> running [label="reboot / reset"];

View File

@ -23,7 +23,7 @@ digraph OpenNebula {
subgraph { rank = same; prolog; boot; color="white" } subgraph { rank = same; prolog; boot; color="white" }
subgraph { rank = same; migrate; save; shutdown; unknown; hotplug; subgraph { rank = same; migrate; save; shutdown; unknown; hotplug;
color="white" } color="white" }
subgraph { rank = max; suspended; done; failure; stopped; color="white" } subgraph { rank = max; suspended; done; failure; stopped; poweroff; color="white" }
# create # create
user -> pending [label="create"]; user -> pending [label="create"];
@ -35,9 +35,13 @@ digraph OpenNebula {
# shutdown # shutdown
running -> shutdown [label="shutdown"]; running -> shutdown [label="shutdown"];
shutdown -> epilog [style="dashed"]; shutdown -> epilog [label="shutdown", style="dashed"];
epilog -> done [style="dashed"]; epilog -> done [style="dashed"];
# poweroff
running -> shutdown [label="poweroff"];
shutdown -> poweroff [label="poweroff", style="dashed"];
# livemigrate # livemigrate
running -> migrate [label="livemigrate"]; running -> migrate [label="livemigrate"];
migrate -> running [label="livemigrate", style="dashed"]; migrate -> running [label="livemigrate", style="dashed"];
@ -75,6 +79,7 @@ digraph OpenNebula {
# restart # restart
unknown -> boot [label="restart"]; unknown -> boot [label="restart"];
boot -> boot [label="restart"]; boot -> boot [label="restart"];
poweroff -> boot [label="restart"];
# reboot, reset # reboot, reset
running -> running [label="reboot / reset"]; running -> running [label="reboot / reset"];

View File

@ -0,0 +1,83 @@
Here are located the files needed to generate OpenNebula contextualization packages. The packages generated contain these files:
* `/etc/udev/rules.d/*` These files disable the udev network an cdrom
generation
* `/etc/init.d/vmcontext` This is the startup script that will try to mount
context cdrom, load contextualizaton variables,
call scripts in the contextualization scripts
directory and call init.sh if it exists in the
context cd.
* `/etc/one-context.d/*` This directory holds the scripts that will be
called by vmcontext script. They should be named
starting with a number so they are called in order.
By default only the network configuration context script is included in the
packages. These scripts are different for rpm and deb based distributions and
are located in `base_<deb|rpm>` directories.
The packages also have a post-install script that does this steps:
* Delete persistent cd and net rules from /etc/udev/rules.d
* Links vmcontext script to /etc/rc<runlevel>.d
* Deletes network configuration files
# GENERATOR
## Requirements
* Ruby >= 1.8.7
* gem fpm
* dpkg utils for deb package creation
* rpm utils for rpm package creation
On Ubuntu/Debian you can install the package `rpm` and you will be able to generate both rpm and deb packages.
## Description
The script `generator.sh` generates both deb and rpm packages and can be configured to include more files in the package or change some of its parameters.
On start it creates a temporary directory and copies there:
* `base` directory
* `base_<deb|rpm>` directory
* Any file or directory from the arguments.
Then these files are included in the package
## Usage
The default parameters to create a package are as follows:
VERSION=1.0.1
MAINTAINER=C12G Labs <support@c12g.com>
LICENSE=Apache
PACKAGE_NAME=one-context
VENDOR=C12G Labs
DESCRIPTION="
This package prepares a VM image for OpenNebula:
* Disables udev net and cd persistent rules
* Deletes udev net and cd persistent rules
* Unconfigures the network
* Adds OpenNebula contextualization scripts to startup
To get support use the OpenNebula mailing list:
http://opennebula.org/community:mailinglists
"
PACKAGE_TYPE=deb
URL=http://opennebula.org
You can change any parameter setting an environment variable with the same name. For example, to generate an rpm package with a different package name:
$ PACKAGE_TYPE=rpm PACKAGE_NAME=my-context ./generate.sh
You can also include new files. This is handy to, for example, include new scripts executed to contextualize an image. For example, we can have an script that install a user ssh key. We will create the file hierarchy that will go inside the package in a directory:
$ mkdir -p ssh/etc/one-context.d
$ cp <our-ssh-script> ssh/etc/one-context.d/01-ssh-key
$ ./generate.sh ssh/etc
NOTE: The generator must be executed from the same directory it resides.

View File

@ -0,0 +1,70 @@
#!/bin/bash
#
# chkconfig: 2345 9 90
# description: network reconfigure
#
# -------------------------------------------------------------------------- #
# Copyright 2010-2012, C12G Labs S.L. #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
### BEGIN INIT INFO
# Provides: vmcontext
# Required-Start:
# Required-Stop:
# Should-Start: networking
# Should-Stop: networking
# Default-Start:
# Default-Stop: 0 6
# Short-Description: OpenNebula contextualization script
### END INIT INFO
function export_rc_vars
{
if [ -f $1 ] ; then
ONE_VARS=`cat $1 | egrep -e '^[a-zA-Z\-\_0-9]*=' | sed 's/=.*$//'`
. $1
for v in $ONE_VARS; do
export $v
done
fi
}
function execute_scripts {
SCRIPTS_DIR="/etc/one-context.d"
for script in $SCRIPTS_DIR/*; do
$script
done
}
CDROM_DEVICE=$(ls /dev/cdrom* /dev/scd* | sort | head -n 1)
if [ -e "$CDROM_DEVICE" ]; then
mount -t iso9660 $CDROM_DEVICE /mnt
if [ -f /mnt/context.sh ]; then
export_rc_vars /mnt/context.sh
fi
execute_scripts
if [ -f /mnt/init.sh ]; then
/mnt/init.sh
fi
umount /mnt
else
execute_scripts
fi

View File

@ -0,0 +1,155 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2010-2012, C12G Labs S.L. #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
# Gets IP address from a given MAC
mac2ip() {
mac=$1
let ip_a=0x`echo $mac | cut -d: -f 3`
let ip_b=0x`echo $mac | cut -d: -f 4`
let ip_c=0x`echo $mac | cut -d: -f 5`
let ip_d=0x`echo $mac | cut -d: -f 6`
ip="$ip_a.$ip_b.$ip_c.$ip_d"
echo $ip
}
# Gets the network part of an IP
get_network() {
network=$(get_iface_var "NETWORK")
if [ -z "$network" ]; then
network="$(echo $IP | cut -d'.' -f1,2,3).0"
fi
echo $network
}
# Gets the network mask
get_mask() {
mask=$(get_iface_var "MASK")
if [ -z "$mask" ]; then
mask="255.255.255.0"
fi
echo $mask
}
# Gets the network gateway
get_gateway() {
gateway=$(get_iface_var "GATEWAY")
if [ -z "$gateway" ]; then
if [ "$DEV" = "eth0" ]; then
net_prefix=$(echo $NETWORK | cut -d'.' -f1,2,3)
gateway="${net_prefix}.1"
fi
fi
echo $gateway
}
get_interfaces() {
IFCMD="/sbin/ifconfig -a"
$IFCMD | grep ^eth | sed 's/ *Link encap:Ethernet.*HWaddr /-/g'
}
get_dev() {
echo $1 | cut -d'-' -f 1
}
get_mac() {
echo $1 | cut -d'-' -f 2
}
get_ip() {
ip=$(get_iface_var "IP")
if [ -z "$ip" ]; then
ip=$(mac2ip $MAC)
fi
echo $ip
}
get_iface_var() {
var_name="${UPCASE_DEV}_$1"
var=$(eval "echo \"\${$var_name}\"")
echo $var
}
upcase() {
echo "$*" | tr '[:lower:]' '[:upper:]'
}
gen_iface_conf() {
cat <<EOT
auto $DEV
iface $DEV inet static
address $IP
network $NETWORK
netmask $MASK
EOT
if [ -n "$GATEWAY" ]; then
echo " gateway $GATEWAY"
fi
echo ""
}
gen_network_configuration()
{
cat <<EOT
auto lo
iface lo inet loopback
EOT
IFACES=`get_interfaces`
for i in $IFACES; do
MAC=`get_mac $i`
DEV=`get_dev $i`
UPCASE_DEV=`upcase $DEV`
IP=$(get_ip)
NETWORK=$(get_network)
MASK=$(get_mask)
GATEWAY=$(get_gateway)
gen_iface_conf
done
}
configure_network()
{
gen_network_configuration > /etc/network/interfaces
service networking start
sleep 2
}
configure_network

View File

@ -0,0 +1,150 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2010-2012, C12G Labs S.L. #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
# Gets IP address from a given MAC
mac2ip() {
mac=$1
let ip_a=0x`echo $mac | cut -d: -f 3`
let ip_b=0x`echo $mac | cut -d: -f 4`
let ip_c=0x`echo $mac | cut -d: -f 5`
let ip_d=0x`echo $mac | cut -d: -f 6`
ip="$ip_a.$ip_b.$ip_c.$ip_d"
echo $ip
}
# Gets the network part of an IP
get_network() {
network=$(get_iface_var "NETWORK")
if [ -z "$network" ]; then
network="$(echo $IP | cut -d'.' -f1,2,3).0"
fi
echo $network
}
# Gets the network mask
get_mask() {
mask=$(get_iface_var "MASK")
if [ -z "$mask" ]; then
mask="255.255.255.0"
fi
echo $mask
}
# Gets the network gateway
get_gateway() {
gateway=$(get_iface_var "GATEWAY")
if [ -z "$gateway" ]; then
if [ "$DEV" = "eth0" ]; then
net_prefix=$(echo $NETWORK | cut -d'.' -f1,2,3)
gateway="${net_prefix}.1"
fi
fi
echo $gateway
}
get_interfaces() {
IFCMD="/sbin/ifconfig -a"
$IFCMD | grep ^eth | sed 's/ *Link encap:Ethernet.*HWaddr /-/g'
}
get_dev() {
echo $1 | cut -d'-' -f 1
}
get_mac() {
echo $1 | cut -d'-' -f 2
}
get_ip() {
ip=$(get_iface_var "IP")
if [ -z "$ip" ]; then
ip=$(mac2ip $MAC)
fi
echo $ip
}
get_iface_var() {
var_name="${UPCASE_DEV}_$1"
var=$(eval "echo \"\${$var_name}\"")
echo $var
}
upcase() {
echo "$*" | tr '[:lower:]' '[:upper:]'
}
gen_iface_conf() {
cat <<EOT
DEVICE=$DEV
BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet
NETMASK=$MASK
IPADDR=$IP
EOT
if [ -n "$GATEWAY" ]; then
echo "GATEWAY=$GATEWAY"
fi
echo ""
}
gen_network_configuration()
{
IFACES=`get_interfaces`
for i in $IFACES; do
MAC=`get_mac $i`
DEV=`get_dev $i`
UPCASE_DEV=`upcase $DEV`
IP=$(get_ip)
NETWORK=$(get_network)
MASK=$(get_mask)
GATEWAY=$(get_gateway)
gen_iface_conf > /etc/sysconfig/network-scripts/ifcfg-${DEV}
done
}
configure_network()
{
gen_network_configuration
service network restart
sleep 2
}
configure_network

View File

@ -0,0 +1,60 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2010-2012, C12G Labs S.L. #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
VERSION=${VERSION:-3.6.0}
MAINTAINER=${MAINTAINER:-C12G Labs <support@c12g.com>}
LICENSE=${LICENSE:-Apache 2.0}
PACKAGE_NAME=${PACKAGE_NAME:-one-context}
VENDOR=${VENDOR:-C12G Labs}
DESC="
This package prepares a VM image for OpenNebula:
* Disables udev net and cd persistent rules
* Deletes udev net and cd persistent rules
* Unconfigures the network
* Adds OpenNebula contextualization scripts to startup
To get support check the OpenNebula web page:
http://OpenNebula.org
"
DESCRIPTION=${DESCRIPTION:-$DESC}
PACKAGE_TYPE=${PACKAGE_TYPE:-deb}
URL=${URL:-http://opennebula.org}
SCRIPTS_DIR=$PWD
NAME="${PACKAGE_NAME}_${VERSION}.${PACKAGE_TYPE}"
rm $NAME
rm -rf tmp
mkdir tmp
cp -r base/* tmp
cp -r base_$PACKAGE_TYPE/* tmp
for i in $*; do
cp -r "$i" tmp
done
cd tmp
fpm -n "$PACKAGE_NAME" -t "$PACKAGE_TYPE" -s dir --vendor "$VENDOR" \
--license "$LICENSE" --description "$DESCRIPTION" --url "$URL" \
-m "$MAINTAINER" -v "$VERSION" --after-install $SCRIPTS_DIR/postinstall \
-a all -p $SCRIPTS_DIR/$NAME *
echo $NAME

View File

@ -0,0 +1,47 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2010-2012, C12G Labs S.L. #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
rm -f /etc/udev/rules.d/70-persistent-cd.rules
rm -f /etc/udev/rules.d/70-persistent-net.rules
RUNLEVEL=$(runlevel | cut -d' ' -f2)
(
cd /etc/rc${RUNLEVEL}.d
ln -sf ../init.d/vmcontext S99vmcontext
)
# Debian based distros
if [ -d /etc/network ]; then
cp /etc/network/interfaces /etc/network/interfaces.$(date "+%s")
cat > /etc/network/interfaces <<EOT
# The loopback network interface
auto lo
iface lo inet loopback
EOT
fi
# RedHat based distros
if [ -d /etc/sysconfig/network-scripts ]; then
rm -f /etc/sysconfig/network-scripts/ifcfg-eth*
fi

View File

@ -85,6 +85,16 @@ class AuthDriver < OpenNebulaDriver
end end
end end
# Works the same as log_method but changes the password by '****'.
# The last word is the password for authentication.
def log_method_no_password(num, secret)
lambda {|message|
m=message.gsub(/ #{Regexp.escape(secret)}$/, ' ****')
log(num, m)
}
end
# Authenticate a user based in a string of the form user:secret when using the # Authenticate a user based in a string of the form user:secret when using the
# driver secret is protocol:token # driver secret is protocol:token
# @param [String] the id for this request, used by OpenNebula core # @param [String] the id for this request, used by OpenNebula core
@ -115,7 +125,8 @@ class AuthDriver < OpenNebulaDriver
Shellwords.escape(p) Shellwords.escape(p)
end.join(' ')) end.join(' '))
rc = LocalCommand.run(command, log_method(request_id)) rc = LocalCommand.run(command,
log_method_no_password(request_id, secret))
result , info = get_info_from_execution(rc) result , info = get_info_from_execution(rc)

View File

@ -83,8 +83,8 @@ begin
end end
if ldap.authenticate(user_name, secret) if ldap.authenticate(user_name, secret)
escaped_user=URI_PARSER.escape(user_name) escaped_user=URI_PARSER.escape(user)
escaped_secret=URI_PARSER.escape(secret) escaped_secret=URI_PARSER.escape(user_name)
puts "ldap #{escaped_user} #{escaped_secret}" puts "ldap #{escaped_user} #{escaped_secret}"
authenticated=true authenticated=true
break break

View File

@ -82,6 +82,36 @@ module CLIHelper
print "\33[#{x};#{y}H" print "\33[#{x};#{y}H"
end end
def CLIHelper.scr_red
print "\33[31m"
end
def CLIHelper.scr_green
print "\33[32m"
end
ANSI_RED="\33[31m"
ANSI_GREEN="\33[32m"
ANSI_RESET="\33[0m"
OK_STATES=%w{runn rdy on}
BAD_STATES=%w{fail err err}
def CLIHelper.color_state(stat)
if $stdout.tty?
case stat.strip
when *OK_STATES
ANSI_GREEN+stat+ANSI_RESET
when *BAD_STATES
ANSI_RED+stat+ANSI_RESET
else
stat
end
else
stat
end
end
# Print header # Print header
def CLIHelper.print_header(str, underline=true) def CLIHelper.print_header(str, underline=true)
if $stdout.tty? if $stdout.tty?
@ -158,6 +188,14 @@ module CLIHelper
end end
end end
def describe_columns
str="%-20s: %-20s"
@columns.each do |column, d|
puts str % [column, d[:desc]]
end
end
private private
def print_table(data, options) def print_table(data, options)
@ -169,12 +207,23 @@ module CLIHelper
ncolumns=@default_columns.length ncolumns=@default_columns.length
res_data=data_array(data, options) res_data=data_array(data, options)
if options[:stat_column]
stat_column=@default_columns.index(
options[:stat_column].upcase.to_sym)
else
stat_column=@default_columns.index(:STAT)
end
begin begin
print res_data.collect{|l| print res_data.collect{|l|
(0..ncolumns-1).collect{ |i| (0..ncolumns-1).collect{ |i|
dat=l[i] dat=l[i]
col=@default_columns[i] col=@default_columns[i]
format_str(col, dat)
str=format_str(col, dat)
str=CLIHelper.color_state(str) if i==stat_column
str
}.join(' ') }.join(' ')
}.join("\n") }.join("\n")
rescue Errno::EPIPE rescue Errno::EPIPE

View File

@ -468,6 +468,10 @@ module CommandParser
else else
puts "one parameter to run" puts "one parameter to run"
end end
puts
puts "Usage:"
print " #{name} "
print_command(@commands[name])
exit -1 exit -1
else else
id=0 id=0
@ -585,7 +589,6 @@ module CommandParser
def print_commands def print_commands
cmd_format5 = "#{' '*3}%s" cmd_format5 = "#{' '*3}%s"
cmd_format10 = "#{' '*8}%s"
if @main if @main
print_command(@main) print_command(@main)
@ -601,6 +604,8 @@ module CommandParser
end end
def print_command(command) def print_command(command)
cmd_format10 = "#{' '*8}%s"
args_str=command[:args_format].collect{ |a| args_str=command[:args_format].collect{ |a|
if a.include?(nil) if a.include?(nil)
"[<#{a.compact.join("|")}>]" "[<#{a.compact.join("|")}>]"

View File

@ -61,6 +61,66 @@ EOT
:description => "Show units in kilobytes" :description => "Show units in kilobytes"
} }
DESCRIBE={
:name => "describe",
:large => "--describe",
:description => "Describe list columns"
}
# Command line VM template options
TEMPLATE_OPTIONS=[
{
:name => 'name',
:large => '--name name',
:description =>
'Name for the VM',
:format => String
},
{
:name => 'cpu',
:large => '--cpu cpu',
:description =>
'CPU percentage reserved for the VM (1=100% one CPU)',
:format => Float
},
{
:name => 'memory',
:large => '--memory memory',
:description => 'Memory ammount given to the VM',
:format => String,
:proc => lambda do |o,options|
m=o.strip.match(/^(\d+(?:\.\d+)?)(m|mb|g|gb)?$/i)
if !m
[-1, 'Memory value malformed']
else
multiplier=case m[2]
when /(g|gb)/i
1024
else
1
end
value=m[1].to_f*multiplier
[0, value.floor]
end
end
},
{
:name => 'disk',
:large => '--disk disk0,disk1',
:description => 'Disks to attach. To use a disk owned by other user use user[disk]',
:format => Array
},
{
:name => 'network',
:large => '--network network0,network1',
:description => 'Networks to attach. To use a network owned by other user use user[network]',
:format => Array
}
]
OPTIONS = XML, NUMERIC, KILOBYTES OPTIONS = XML, NUMERIC, KILOBYTES
class OneHelper class OneHelper
@ -88,6 +148,13 @@ EOT
end end
def list_pool(options, top=false, filter_flag=nil) def list_pool(options, top=false, filter_flag=nil)
if options[:describe]
table = format_pool(options)
table.describe_columns
return 0
end
filter_flag ||= OpenNebula::Pool::INFO_ALL filter_flag ||= OpenNebula::Pool::INFO_ALL
pool = factory_pool(filter_flag) pool = factory_pool(filter_flag)
@ -445,4 +512,76 @@ EOT
str = File.read(path) str = File.read(path)
str str
end end
def self.parse_user_object(user_object)
reg=/^([^\[]+)(?:\[([^\]]+)\])?$/
m=user_object.match(reg)
return nil if !m
user=nil
if m[2]
user=m[1]
object=m[2]
else
object=m[1]
end
[user, object]
end
def self.create_disk_net(objects, section, name)
template=''
objects.each do |obj|
res=parse_user_object(obj)
return [-1, "#{section.capitalize} \"#{obj}\" malformed"] if !res
user, object=*res
template<<"#{section.upcase}=[\n"
template<<" #{name.upcase}_UNAME=\"#{user}\",\n" if user
template<<" #{name.upcase}=\"#{object}\"\n"
template<<"]\n"
end if objects
[0, template]
end
def self.create_template(options)
template=''
template<<"NAME=\"#{options[:name]}\"\n" if options[:name]
template<<"CPU=#{options[:cpu]}\n" if options[:cpu]
template<<"MEMORY=#{options[:memory]}\n" if options[:memory]
if options[:disk]
res=create_disk_net(options[:disk], 'DISK', 'IMAGE')
return res if res.first!=0
template<<res.last
end
if options[:network]
res=create_disk_net(options[:network], 'NIC', 'NETWORK')
return res if res.first!=0
template<<res.last
end
[0, template]
end
def self.create_template_options_used?(options)
# Get the template options names as symbols. options hash
# uses symbols
template_options=OpenNebulaHelper::TEMPLATE_OPTIONS.map do |o|
o[:name].to_sym
end
# Check if one at least one of the template options is
# in options hash
(template_options-options.keys)!=template_options
end
end end

View File

@ -17,6 +17,153 @@
require 'one_helper' require 'one_helper'
class OneImageHelper < OpenNebulaHelper::OneHelper class OneImageHelper < OpenNebulaHelper::OneHelper
TEMPLATE_OPTIONS=[
{
:name => "name",
:short => "-n name",
:large => "--name type",
:format => String,
:description => "Name of the new image"
},
{
:name => "description",
:short => "-d description",
:large => "--description description",
:format => String,
:description => "Description for the new Image"
},
{
:name => "type",
:short => "-t type",
:large => "--type type",
:format => String,
:description => "Type of the new Image",
:proc => lambda do |o, options|
type=o.strip.upcase
if %w{OS CDROM DATABLOCK}.include? type
[0, type]
else
[-1, "Type should be OS, CDROM or DATABLOCK"]
end
end
},
{
:name => "persistent",
:short => "-p",
:large => "--persistent",
:description => "Tells if the image will be persistent"
},
{
:name => "prefix",
:large => "--prefix prefix",
:description => "Device prefix for the disk (hd, sd, xvd or vd)",
:format => String,
:proc => lambda do |o, options|
prefix=o.strip.downcase
if %w{hd sd xvd vd}.include? prefix
[0, prefix]
else
[-1, "The prefix must be hd, sd, xvd or vd"]
end
end
},
{
:name => "target",
:large => "--target target",
:description => "Device the disk will be attached to",
:format => String
},
{
:name => "path",
:large => "--path path",
:description => "Path of the image file",
:format => String,
:proc => lambda do |o, options|
if o[0,1]=='/'
path=o
else
path=Dir.pwd+"/"+o
end
if File.exist?(path)
[0, path]
else
[-1, "File '#{path}' does not exist."]
end
end
},
{
:name => "driver",
:large => "--driver driver",
:description => "Driver to use image (raw, qcow2, tap:aio:...)",
:format => String
},
{
:name => "disk_type",
:large => "--disk_type disk_type",
:description => "Type of the image (BLOCK, CDROM or FILE)",
:format => String,
:proc => lambda do |o, options|
type=o.strip.upcase
if %w{BLOCK CDROM FILE}.include? type
[0, type]
else
[-1, "Disk type must be BLOCK, CDROM or FILE"]
end
end
},
{
:name => "source",
:large => "--source source",
:description =>
"Source to be used. Useful for not file-based images",
:format => String
},
{
:name => "size",
:large => "--size size",
:description => "Size in MB. Used for DATABLOCK type",
:format => String,
:proc => lambda do |o, options|
if !options[:type] || !(options[:type].upcase=='DATABLOCK')
next [-1, "Size is only used for DATABLOCK type images"]
end
m=o.strip.match(/^(\d+(?:\.\d+)?)(m|mb|g|gb)?$/i)
if !m
[-1, 'Size value malformed']
else
multiplier=case m[2]
when /(g|gb)/i
1024
else
1
end
value=m[1].to_f*multiplier
[0, value.floor]
end
end
},
{
:name => "fstype",
:large => "--fstype fstype",
:description => "Type of file system to be built. This can be "<<
"any value understood by mkfs unix command.",
:format => String,
:proc => lambda do |o, options|
if !options[:type] || !(options[:type].upcase=='DATABLOCK')
[-1, "FSTYPE is only used for DATABLOCK type images"]
else
[0, o]
end
end
}
]
def self.rname def self.rname
"IMAGE" "IMAGE"
end end
@ -151,4 +298,34 @@ class OneImageHelper < OpenNebulaHelper::OneHelper
CLIHelper.print_header(str_h1 % "IMAGE TEMPLATE",false) CLIHelper.print_header(str_h1 % "IMAGE TEMPLATE",false)
puts image.template_str puts image.template_str
end end
def self.create_image_variables(options, name)
if Array===name
names=name
else
names=[name]
end
t=''
names.each do |n|
if options[n]
t<<"#{n.to_s.upcase}=\"#{options[n]}\"\n"
end
end
t
end
def self.create_image_template(options)
template_options=TEMPLATE_OPTIONS.map do |o|
o[:name].to_sym
end
template=create_image_variables(
options, template_options-[:persistent])
template<<"PERSISTENT=YES\n" if options[:persistent]
[0, template]
end
end end

View File

@ -90,7 +90,8 @@ cmd = CommandParser::CmdParser.new(ARGV) do
Lists the ACL rule set Lists the ACL rule set
EOT EOT
command :list, list_desc,:options=>OpenNebulaHelper::XML do command :list, list_desc,:options=>[OpenNebulaHelper::XML,
OpenNebulaHelper::DESCRIBE] do
helper.list_pool( options ) helper.list_pool( options )
end end
end end

View File

@ -44,6 +44,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
list_options = CLIHelper::OPTIONS list_options = CLIHelper::OPTIONS
list_options << OpenNebulaHelper::XML list_options << OpenNebulaHelper::XML
list_options << OpenNebulaHelper::NUMERIC list_options << OpenNebulaHelper::NUMERIC
list_options << OpenNebulaHelper::DESCRIBE
######################################################################## ########################################################################
# Formatters for arguments # Formatters for arguments

View File

@ -45,6 +45,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
list_options = CLIHelper::OPTIONS list_options = CLIHelper::OPTIONS
list_options << OpenNebulaHelper::XML list_options << OpenNebulaHelper::XML
list_options << OpenNebulaHelper::NUMERIC list_options << OpenNebulaHelper::NUMERIC
list_options << OpenNebulaHelper::DESCRIBE
######################################################################## ########################################################################
# Formatters for arguments # Formatters for arguments

View File

@ -44,6 +44,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
list_options = CLIHelper::OPTIONS list_options = CLIHelper::OPTIONS
list_options << OpenNebulaHelper::XML list_options << OpenNebulaHelper::XML
list_options << OpenNebulaHelper::NUMERIC list_options << OpenNebulaHelper::NUMERIC
list_options << OpenNebulaHelper::DESCRIBE
######################################################################## ########################################################################
# Formatters for arguments # Formatters for arguments

View File

@ -170,7 +170,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do
EOT EOT
command :list, list_desc, command :list, list_desc,
:options=>CLIHelper::OPTIONS+OpenNebulaHelper::OPTIONS do :options=>CLIHelper::OPTIONS+OpenNebulaHelper::OPTIONS+
[OpenNebulaHelper::DESCRIBE] do
helper.list_pool(options) helper.list_pool(options)
end end

View File

@ -45,6 +45,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
list_options = CLIHelper::OPTIONS list_options = CLIHelper::OPTIONS
list_options << OpenNebulaHelper::XML list_options << OpenNebulaHelper::XML
list_options << OpenNebulaHelper::NUMERIC list_options << OpenNebulaHelper::NUMERIC
list_options << OpenNebulaHelper::DESCRIBE
CREATE_OPTIONS = [OneDatastoreHelper::DATASTORE] CREATE_OPTIONS = [OneDatastoreHelper::DATASTORE]
@ -79,16 +80,37 @@ cmd=CommandParser::CmdParser.new(ARGV) do
Creates a new Image from the given template file Creates a new Image from the given template file
EOT EOT
command :create, create_desc, :file, :options=>CREATE_OPTIONS do command :create, create_desc, [:file, nil], :options=>CREATE_OPTIONS+
OneImageHelper::TEMPLATE_OPTIONS do
if options[:datastore].nil? if options[:datastore].nil?
STDERR.puts "Datastore to save the image is mandatory: " STDERR.puts "Datastore to save the image is mandatory: "
STDERR.puts "\t -d datastore_id" STDERR.puts "\t -d datastore_id"
exit -1 exit -1
end end
if args[0] && OpenNebulaHelper.create_template_options_used?(options)
STDERR.puts "You can not use both template file and template"<<
" creation options."
next -1
end
res=OneImageHelper.create_image_template(options)
if res.first!=0
STDERR.puts res.last
next -1
end
helper.create_resource(options) do |image| helper.create_resource(options) do |image|
begin begin
template=File.read(args[0]) if args[0]
image.allocate(template, options[:datastore] ) template=File.read(args[0])
else
template=''
end
template<<res.last
image.allocate(template, options[:datastore])
rescue => e rescue => e
STDERR.puts e.messsage STDERR.puts e.messsage
exit -1 exit -1

View File

@ -44,6 +44,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
list_options = CLIHelper::OPTIONS list_options = CLIHelper::OPTIONS
list_options << OpenNebulaHelper::XML list_options << OpenNebulaHelper::XML
list_options << OpenNebulaHelper::NUMERIC list_options << OpenNebulaHelper::NUMERIC
list_options << OpenNebulaHelper::DESCRIBE
instantiate_options = [ instantiate_options = [
OneTemplateHelper::VM_NAME, OneTemplateHelper::VM_NAME,
@ -81,9 +82,29 @@ cmd=CommandParser::CmdParser.new(ARGV) do
Creates a new Template from the given template file Creates a new Template from the given template file
EOT EOT
command :create, create_desc, :file do command :create, create_desc, [:file, nil],
:options=>OpenNebulaHelper::TEMPLATE_OPTIONS do
res=OpenNebulaHelper.create_template(options)
if args[0] && OpenNebulaHelper.create_template_options_used?(options)
STDERR.puts "You can not use both template file and template"<<
" creation options."
next -1
end
if res.first!=0
STDERR.puts res.last
next -1
end
helper.create_resource(options) do |t| helper.create_resource(options) do |t|
template=File.read(args[0]) if args[0]
template=File.read(args[0])
else
template=''
end
template<<res.last
t.allocate(template) t.allocate(template)
end end
end end

View File

@ -45,6 +45,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
list_options = CLIHelper::OPTIONS list_options = CLIHelper::OPTIONS
list_options << OpenNebulaHelper::XML list_options << OpenNebulaHelper::XML
list_options << OpenNebulaHelper::NUMERIC list_options << OpenNebulaHelper::NUMERIC
list_options << OpenNebulaHelper::DESCRIBE
READ_FILE={ READ_FILE={
:name => "read_file", :name => "read_file",

View File

@ -99,15 +99,41 @@ cmd=CommandParser::CmdParser.new(ARGV) do
See 'onetemplate create' and 'onetemplate instantiate' See 'onetemplate create' and 'onetemplate instantiate'
EOT EOT
command :create, create_desc, :file, command :create, create_desc, [:file, nil],
:options=>[OneVMHelper::MULTIPLE]+OpenNebulaHelper::OPTIONS do :options=>[OneVMHelper::MULTIPLE]+
OpenNebulaHelper::TEMPLATE_OPTIONS do
number = options[:multiple] || 1 number = options[:multiple] || 1
exit_code=nil exit_code=nil
res=OpenNebulaHelper.create_template(options)
if res.first!=0
STDERR.puts res.last
next -1
end
if args[0]
if OpenNebulaHelper.create_template_options_used?(options)
STDERR.puts "You can not use both template file and template"<<
" creation options."
next -1
end
begin
template=File.read(args[0])
rescue
STDERR.puts "Error reading template."
next -1
end
else
template=''
end
template<<res.last
number.times do number.times do
exit_code=helper.create_resource(options) do |vm| exit_code=helper.create_resource(options) do |vm|
template=File.read(args[0])
error=vm.allocate(template) error=vm.allocate(template)
end end
@ -183,7 +209,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
end end
shutdown_desc = <<-EOT.unindent shutdown_desc = <<-EOT.unindent
Shuts down the given VM. Shuts down the given VM. The VM life cycle will end.
States: RUNNING States: RUNNING
EOT EOT
@ -194,6 +220,19 @@ cmd=CommandParser::CmdParser.new(ARGV) do
end end
end end
poweroff_desc = <<-EOT.unindent
Powers off the given VM. The VM will remain in the poweroff state, and
can be powered on with the 'onevm restart' command.
States: RUNNING
EOT
command :poweroff, poweroff_desc, [:range,:vmid_list] do
helper.perform_actions(args[0],options,"shutting down") do |vm|
vm.poweroff
end
end
reboot_desc = <<-EOT.unindent reboot_desc = <<-EOT.unindent
Reboots the given VM, this is equivalent to execute the reboot command Reboots the given VM, this is equivalent to execute the reboot command
from the VM console. from the VM console.
@ -267,9 +306,9 @@ cmd=CommandParser::CmdParser.new(ARGV) do
end end
restart_desc = <<-EOT.unindent restart_desc = <<-EOT.unindent
Forces a re-deployment of the given VM, issuing a boot action. Boots the given VM.
States: UNKNOWN, BOOT States: UNKNOWN, BOOT, POWEROFF
EOT EOT
command :restart, restart_desc, [:range,:vmid_list] do command :restart, restart_desc, [:range,:vmid_list] do
@ -456,7 +495,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do
EOT EOT
command :list, list_desc, [:filterflag, nil], command :list, list_desc, [:filterflag, nil],
:options=>CLIHelper::OPTIONS+OpenNebulaHelper::OPTIONS do :options=>CLIHelper::OPTIONS+OpenNebulaHelper::OPTIONS+
[OpenNebulaHelper::DESCRIBE] do
helper.list_pool(options, false, args[0]) helper.list_pool(options, false, args[0])
end end

View File

@ -199,7 +199,8 @@ cmd=CommandParser::CmdParser.new(ARGV) do
EOT EOT
command :list, list_desc, [:filterflag, nil], command :list, list_desc, [:filterflag, nil],
:options=>CLIHelper::OPTIONS+OpenNebulaHelper::OPTIONS do :options=>CLIHelper::OPTIONS+OpenNebulaHelper::OPTIONS+
[OpenNebulaHelper::DESCRIBE] do
helper.list_pool(options, false, args[0]) helper.list_pool(options, false, args[0])
end end

View File

@ -26,8 +26,10 @@ module OpenNebulaCloudAuth
rc = user.info rc = user.info
if OpenNebula.is_error?(rc) if OpenNebula.is_error?(rc)
logger.error { "User #{username} could not be authenticated" } if logger
logger.error { rc.message } logger.error{ "User #{username} could not be authenticated"}
logger.error { rc.message }
end
return nil return nil
end end
@ -36,4 +38,4 @@ module OpenNebulaCloudAuth
return nil return nil
end end
end end

View File

@ -43,15 +43,15 @@ setup()
if [ -f $ECONE_LOCK_FILE ]; then if [ -f $ECONE_LOCK_FILE ]; then
if [ -f $ECONE_PID ]; then if [ -f $ECONE_PID ]; then
ONEPID=`cat $ECONE_PID` ECONEPID=`cat $ECONE_PID`
ps $ECONE_PID > /dev/null 2>&1 ps $ECONEPID > /dev/null 2>&1
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "econe-server is still running (PID:$ECONE_PID). Please try 'occi-server stop' first." echo "econe-server is still running (PID:$ECONEPID). Please try 'econe-server stop' first."
exit 1 exit 1
fi fi
fi fi
echo "Stale .lock detected. Erasing it." echo "Stale .lock detected. Erasing it."
rm $LOCK_FILE rm $ECONE_LOCK_FILE
fi fi
} }
@ -62,6 +62,8 @@ start()
exit 1 exit 1
fi fi
touch $ECONE_LOCK_FILE
# Start the econe-server daemon # Start the econe-server daemon
ruby $ECONE_SERVER >$ECONE_LOG 2>$ECONE_LOG_ERROR & ruby $ECONE_SERVER >$ECONE_LOG 2>$ECONE_LOG_ERROR &
@ -70,7 +72,7 @@ start()
if [ $LASTRC -ne 0 ]; then if [ $LASTRC -ne 0 ]; then
echo "Error executing econe-server." echo "Error executing econe-server."
echo "Check $ECONE_LOG for more information" echo "Check $ECONE_LOG_ERROR and $ECONE_LOG for more information"
exit 1 exit 1
else else
echo $LASTPID > $ECONE_PID echo $LASTPID > $ECONE_PID
@ -81,7 +83,7 @@ start()
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Error executing econe-server." echo "Error executing econe-server."
echo "Check $ECONE_LOG for more information" echo "Check $ECONE_LOG_ERROR and $ECONE_LOG for more information"
exit 1 exit 1
fi fi
@ -105,6 +107,7 @@ stop()
# Remove pid files # Remove pid files
rm -f $ECONE_PID > /dev/null 2>&1 rm -f $ECONE_PID > /dev/null 2>&1
rm -f $ECONE_LOCK_FILE > /dev/null 2>&1
echo "econe-server stopped" echo "econe-server stopped"
} }

View File

@ -28,8 +28,8 @@
:host: localhost :host: localhost
:port: 4567 :port: 4567
# SSL proxy that serves the API (set if is being used) # SSL proxy URL that serves the API (set if is being used)
#:ssl_server: fqdm.of.the.server #:ssl_server: https://service.endpoint.fqdn:port/
############################################################# #############################################################
# Auth # Auth

View File

@ -43,15 +43,15 @@ setup()
if [ -f $OCCI_LOCK_FILE ]; then if [ -f $OCCI_LOCK_FILE ]; then
if [ -f $OCCI_PID ]; then if [ -f $OCCI_PID ]; then
ONEPID=`cat $OCCI_PID` OCCIPID=`cat $OCCI_PID`
ps $OCCI_PID > /dev/null 2>&1 ps $OCCIPID > /dev/null 2>&1
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "OCCI Server is still running (PID:$OCCI_PID). Please try 'occi-server stop' first." echo "OCCI Server is still running (PID:$OCCIPID). Please try 'occi-server stop' first."
exit 1 exit 1
fi fi
fi fi
echo "Stale .lock detected. Erasing it." echo "Stale .lock detected. Erasing it."
rm $LOCK_FILE rm $OCCI_LOCK_FILE
fi fi
} }
@ -62,6 +62,8 @@ start()
exit 1 exit 1
fi fi
touch $OCCI_LOCK_FILE
# Start the occi-server daemon # Start the occi-server daemon
ruby $OCCI_SERVER >$OCCI_LOG 2>$OCCI_LOG_ERROR & ruby $OCCI_SERVER >$OCCI_LOG 2>$OCCI_LOG_ERROR &
@ -70,7 +72,7 @@ start()
if [ $LASTRC -ne 0 ]; then if [ $LASTRC -ne 0 ]; then
echo "Error executing occi-server." echo "Error executing occi-server."
echo "Check $OCCI_LOG for more information" echo "Check $OCCI_LOG_ERROR and $OCCI_LOG for more information"
exit 1 exit 1
else else
echo $LASTPID > $OCCI_PID echo $LASTPID > $OCCI_PID
@ -81,7 +83,7 @@ start()
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Error executing occi-server." echo "Error executing occi-server."
echo "Check $OCCI_LOG for more information" echo "Check $OCCI_LOG_ERROR and $OCCI_LOG for more information"
exit 1 exit 1
fi fi

View File

@ -58,7 +58,7 @@ class OCCIServer < CloudServer
if config[:ssl_server] if config[:ssl_server]
@base_url=config[:ssl_server] @base_url=config[:ssl_server]
else else
@base_url="http://#{config[:server]}:#{config[:port]}" @base_url="http://#{config[:host]}:#{config[:port]}"
end end
@client = client @client = client

View File

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# -------------------------------------------------------------------------- # # -------------------------------------------------------------------------- #
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) # # Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
# # # #
@ -72,6 +73,9 @@ class VirtualMachineOCCI < VirtualMachine
"REBOOT" => { :from => ["ACTIVE"], :action => :reboot}, "REBOOT" => { :from => ["ACTIVE"], :action => :reboot},
"RESET" => { :from => ["ACTIVE"], :action => :reset}, "RESET" => { :from => ["ACTIVE"], :action => :reset},
"SHUTDOWN" => { :from => ["ACTIVE"], :action => :shutdown}, "SHUTDOWN" => { :from => ["ACTIVE"], :action => :shutdown},
"RESTART" => { :from => ["ACTIVE"], :action => :restart},
"RESUBMIT" => { :from => ["ACTIVE", "FAILED"], :action => :resubmit},
"POWEROFF" => { :from => ["ACTIVE"], :action => :poweroff},
"DONE" => { :from => VM_STATE, :action => :finalize} "DONE" => { :from => VM_STATE, :action => :finalize}
} }

View File

@ -150,6 +150,7 @@ end
before do before do
cache_control :no_store cache_control :no_store
content_type 'application/xml', :charset => 'utf-8'
unless request.path=='/ui/login' || request.path=='/ui' unless request.path=='/ui/login' || request.path=='/ui'
if !authorized? if !authorized?
begin begin
@ -245,6 +246,7 @@ helpers do
def treat_response(result,rc) def treat_response(result,rc)
if OpenNebula::is_error?(result) if OpenNebula::is_error?(result)
logger.error {result.message} logger.error {result.message}
content_type 'text/plain', :charset => 'utf-8'
halt rc, result.message halt rc, result.message
end end
@ -325,6 +327,7 @@ post '/compute/:id/action' do
when 'detachdisk' then when 'detachdisk' then
@occi_server.detach_disk(request, params, xml) @occi_server.detach_disk(request, params, xml)
else else
content_type 'text/plain', :charset => 'utf-8'
halt 403, "Action #{xml['PERFORM']} not supported" halt 403, "Action #{xml['PERFORM']} not supported"
end end
@ -421,6 +424,7 @@ post '/ui/config' do
begin begin
body = JSON.parse(request.body.read) body = JSON.parse(request.body.read)
rescue rescue
content_type 'text/plain', :charset => 'utf-8'
[500, "POST Config: Error parsing configuration JSON"] [500, "POST Config: Error parsing configuration JSON"]
end end
@ -446,6 +450,7 @@ post '/ui/logout' do
end end
get '/ui' do get '/ui' do
content_type 'text/html', :charset => 'utf-8'
if !authorized? if !authorized?
return File.read(File.dirname(__FILE__)+'/ui/templates/login.html') return File.read(File.dirname(__FILE__)+'/ui/templates/login.html')
end end
@ -462,6 +467,7 @@ get '/ui' do
end end
post '/ui/upload' do post '/ui/upload' do
content_type 'application/json', :charset => 'utf-8'
#so we can re-use occi post_storage() #so we can re-use occi post_storage()
request.params['file'] = {:tempfile => request.env['rack.input']} request.params['file'] = {:tempfile => request.env['rack.input']}
result,rc = @occi_server.post_storage(request) result,rc = @occi_server.post_storage(request)
@ -469,11 +475,13 @@ post '/ui/upload' do
end end
post '/ui/startvnc/:id' do post '/ui/startvnc/:id' do
content_type 'application/json', :charset => 'utf-8'
vm_id = params[:id] vm_id = params[:id]
@occi_server.startvnc(vm_id, settings.vnc) @occi_server.startvnc(vm_id, settings.vnc)
end end
get '/ui/accounting' do get '/ui/accounting' do
content_type 'application/json', :charset => 'utf-8'
@occi_server.get_user_accounting(params) @occi_server.get_user_accounting(params)
end end

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: OpenNebula\n" "Project-Id-Version: OpenNebula\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-07-06 12:23+0200\n" "POT-Creation-Date: 2012-09-18 13:27+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -50,18 +50,18 @@ msgstr ""
msgid "All" msgid "All"
msgstr "" msgstr ""
#: ../public/js/plugins/storage.js:27 ../public/js/plugins/storage.js:345 #: ../public/js/plugins/storage.js:27 ../public/js/plugins/storage.js:382
#: ../public/js/plugins/network.js:27 ../public/js/plugins/network.js:278 #: ../public/js/plugins/network.js:27 ../public/js/plugins/network.js:278
#: ../public/js/plugins/compute.js:64 ../public/js/plugins/compute.js:538 #: ../public/js/plugins/compute.js:64 ../public/js/plugins/compute.js:585
#: ../public/js/plugins/compute.js:583 ../public/js/plugins/compute.js:628 #: ../public/js/plugins/compute.js:637
msgid "ID" msgid "ID"
msgstr "" msgstr ""
#: ../public/js/plugins/storage.js:28 ../public/js/plugins/storage.js:45 #: ../public/js/plugins/storage.js:28 ../public/js/plugins/storage.js:45
#: ../public/js/plugins/storage.js:349 ../public/js/plugins/network.js:28 #: ../public/js/plugins/storage.js:107 ../public/js/plugins/storage.js:386
#: ../public/js/plugins/network.js:41 ../public/js/plugins/network.js:282 #: ../public/js/plugins/network.js:28 ../public/js/plugins/network.js:41
#: ../public/js/plugins/compute.js:65 ../public/js/plugins/compute.js:542 #: ../public/js/plugins/network.js:282 ../public/js/plugins/compute.js:65
#: ../public/js/plugins/compute.js:587 ../public/js/plugins/compute.js:632 #: ../public/js/plugins/compute.js:589 ../public/js/plugins/compute.js:641
msgid "Name" msgid "Name"
msgstr "" msgstr ""
@ -77,7 +77,7 @@ msgstr ""
msgid "Name that the Image will get." msgid "Name that the Image will get."
msgstr "" msgstr ""
#: ../public/js/plugins/storage.js:50 ../public/js/plugins/storage.js:353 #: ../public/js/plugins/storage.js:50 ../public/js/plugins/storage.js:390
msgid "Description" msgid "Description"
msgstr "" msgstr ""
@ -85,8 +85,7 @@ msgstr ""
msgid "Human readable description of the image." msgid "Human readable description of the image."
msgstr "" msgstr ""
#: ../public/js/plugins/storage.js:57 ../public/js/plugins/storage.js:357 #: ../public/js/plugins/storage.js:57 ../public/js/plugins/storage.js:394
#: ../public/js/plugins/compute.js:595
msgid "Type" msgid "Type"
msgstr "" msgstr ""
@ -134,7 +133,7 @@ msgstr ""
msgid "Public scope of the image" msgid "Public scope of the image"
msgstr "" msgstr ""
#: ../public/js/plugins/storage.js:88 ../public/js/plugins/storage.js:361 #: ../public/js/plugins/storage.js:88 ../public/js/plugins/storage.js:398
msgid "Persistent" msgid "Persistent"
msgstr "" msgstr ""
@ -142,8 +141,8 @@ msgstr ""
msgid "Persistence of the image" msgid "Persistence of the image"
msgstr "" msgstr ""
#: ../public/js/plugins/storage.js:95 ../public/js/plugins/network.js:56 #: ../public/js/plugins/storage.js:95 ../public/js/plugins/storage.js:112
#: ../public/js/plugins/compute.js:103 #: ../public/js/plugins/network.js:56 ../public/js/plugins/compute.js:103
msgid "Close" msgid "Close"
msgstr "" msgstr ""
@ -152,75 +151,89 @@ msgstr ""
msgid "Create" msgid "Create"
msgstr "" msgstr ""
#: ../public/js/plugins/storage.js:214 ../public/js/plugins/network.js:158 #: ../public/js/plugins/storage.js:104
#: ../public/js/plugins/compute.js:323 msgid "Choose a new name for the image"
msgid "Refresh list"
msgstr "" msgstr ""
#: ../public/js/plugins/storage.js:219 ../public/js/plugins/network.js:164 #: ../public/js/plugins/storage.js:105
#: ../public/js/plugins/compute.js:329 msgid "Several image are selected, please choose prefix to name the new copies"
msgstr ""
#: ../public/js/plugins/storage.js:108
msgid "Prefix"
msgstr ""
#: ../public/js/plugins/storage.js:114 ../public/js/plugins/storage.js:270
msgid "Clone"
msgstr ""
#: ../public/js/plugins/storage.js:245 ../public/js/plugins/network.js:164
#: ../public/js/plugins/compute.js:355
msgid "+ New" msgid "+ New"
msgstr "" msgstr ""
#: ../public/js/plugins/storage.js:223 #: ../public/js/plugins/storage.js:249
msgid "Make persistent" msgid "Make persistent"
msgstr "" msgstr ""
#: ../public/js/plugins/storage.js:227 #: ../public/js/plugins/storage.js:253
msgid "Make non persistent" msgid "Make non persistent"
msgstr "" msgstr ""
#: ../public/js/plugins/storage.js:234 ../public/js/plugins/network.js:169 #: ../public/js/plugins/storage.js:260 ../public/js/plugins/network.js:169
msgid "Publish" msgid "Publish"
msgstr "" msgstr ""
#: ../public/js/plugins/storage.js:238 ../public/js/plugins/network.js:174 #: ../public/js/plugins/storage.js:264 ../public/js/plugins/network.js:174
msgid "Unpublish" msgid "Unpublish"
msgstr "" msgstr ""
#: ../public/js/plugins/storage.js:244 ../public/js/plugins/network.js:179 #: ../public/js/plugins/storage.js:274 ../public/js/plugins/network.js:179
#: ../public/js/plugins/compute.js:381 #: ../public/js/plugins/compute.js:422
msgid "Delete" msgid "Delete"
msgstr "" msgstr ""
#: ../public/js/plugins/storage.js:250 ../public/js/plugins/storage.js:337 #: ../public/js/plugins/storage.js:280 ../public/js/plugins/storage.js:374
msgid "Image information" msgid "Image information"
msgstr "" msgstr ""
#: ../public/js/plugins/storage.js:258 #: ../public/js/plugins/storage.js:287
msgid "Add storage" msgid "Add storage"
msgstr "" msgstr ""
#: ../public/js/plugins/storage.js:264 ../public/js/plugins/dashboard.js:46 #: ../public/js/plugins/storage.js:294
#: ../public/customize/custom.js:68 msgid "Clone image"
msgstr ""
#: ../public/js/plugins/storage.js:300 ../public/customize/custom.js:68
msgid "Storage" msgid "Storage"
msgstr "" msgstr ""
#: ../public/js/plugins/storage.js:341 #: ../public/js/plugins/storage.js:378
msgid "Image" msgid "Image"
msgstr "" msgstr ""
#: ../public/js/plugins/storage.js:342 ../public/js/plugins/network.js:275 #: ../public/js/plugins/storage.js:379 ../public/js/plugins/network.js:275
msgid "information" msgid "information"
msgstr "" msgstr ""
#: ../public/js/plugins/storage.js:365 #: ../public/js/plugins/storage.js:402
msgid "Filesystem type" msgid "Filesystem type"
msgstr "" msgstr ""
#: ../public/js/plugins/storage.js:369 #: ../public/js/plugins/storage.js:406
msgid "Size (Mb)" msgid "Size (Mb)"
msgstr "" msgstr ""
#: ../public/js/plugins/storage.js:503 #: ../public/js/plugins/storage.js:537
msgid "You must specify a name" msgid "You must specify a name"
msgstr "" msgstr ""
#: ../public/js/plugins/storage.js:521 #: ../public/js/plugins/storage.js:555
msgid "You must specify size and FS type" msgid "You must specify size and FS type"
msgstr "" msgstr ""
#: ../public/js/plugins/storage.js:528 #: ../public/js/plugins/storage.js:562
msgid "You must select a file to upload" msgid "You must select a file to upload"
msgstr "" msgstr ""
@ -240,8 +253,9 @@ msgstr ""
msgid "Create network" msgid "Create network"
msgstr "" msgstr ""
#: ../public/js/plugins/network.js:199 ../public/js/plugins/compute.js:91 #: ../public/js/plugins/network.js:199 ../public/js/plugins/dashboard.js:62
#: ../public/js/plugins/compute.js:396 ../public/js/plugins/compute.js:655 #: ../public/js/plugins/compute.js:91 ../public/js/plugins/compute.js:437
#: ../public/js/plugins/compute.js:664
msgid "Networks" msgid "Networks"
msgstr "" msgstr ""
@ -269,50 +283,105 @@ msgstr ""
msgid "Please provide a network address" msgid "Please provide a network address"
msgstr "" msgstr ""
#: ../public/js/plugins/dashboard.js:37 #: ../public/js/plugins/dashboard.js:18 ../public/js/plugins/dashboard.js:262
msgid "Current resources" #: ../public/js/plugins/compute.js:32
msgid "CPU"
msgstr "" msgstr ""
#: ../public/js/plugins/dashboard.js:42 ../public/js/plugins/compute.js:409 #: ../public/js/plugins/dashboard.js:22 ../public/js/plugins/dashboard.js:249
#: ../public/js/plugins/compute.js:37
msgid "Memory"
msgstr ""
#: ../public/js/plugins/dashboard.js:26
msgid "Net transfer rates"
msgstr ""
#: ../public/js/plugins/dashboard.js:52
msgid "Resources and quotas"
msgstr ""
#: ../public/js/plugins/dashboard.js:56 ../public/js/plugins/compute.js:450
#: ../public/customize/custom.js:64 #: ../public/customize/custom.js:64
msgid "Compute" msgid "Compute"
msgstr "" msgstr ""
#: ../public/js/plugins/dashboard.js:50 ../public/customize/custom.js:72 #: ../public/js/plugins/dashboard.js:58
msgid "Network" msgid "Storage quotas"
msgstr "" msgstr ""
#: ../public/js/plugins/dashboard.js:62 #: ../public/js/plugins/dashboard.js:60 ../public/js/plugins/compute.js:86
msgid "Useful links" msgid "Images"
msgstr "" msgstr ""
#: ../public/js/plugins/dashboard.js:81 #: ../public/js/plugins/dashboard.js:73
msgid "Usages"
msgstr ""
#: ../public/js/plugins/dashboard.js:77
msgid "From"
msgstr ""
#: ../public/js/plugins/dashboard.js:78
msgid "To"
msgstr ""
#: ../public/js/plugins/dashboard.js:79
#: ../../../../../sunstone/public/js/sunstone-util.js:746
msgid "Update"
msgstr ""
#: ../public/js/plugins/dashboard.js:126
msgid "Create new compute resource" msgid "Create new compute resource"
msgstr "" msgstr ""
#: ../public/js/plugins/dashboard.js:82 ../public/js/plugins/dashboard.js:96 #: ../public/js/plugins/dashboard.js:127 ../public/js/plugins/dashboard.js:141
#: ../public/js/plugins/dashboard.js:110 #: ../public/js/plugins/dashboard.js:155
msgid "See more" msgid "See more"
msgstr "" msgstr ""
#: ../public/js/plugins/dashboard.js:95 #: ../public/js/plugins/dashboard.js:140
msgid "Create new storage resource" msgid "Create new storage resource"
msgstr "" msgstr ""
#: ../public/js/plugins/dashboard.js:109 #: ../public/js/plugins/dashboard.js:154
msgid "Create new network resource" msgid "Create new network resource"
msgstr "" msgstr ""
#: ../public/js/plugins/dashboard.js:120 #: ../public/js/plugins/dashboard.js:163
msgid "Useful links"
msgstr ""
#: ../public/js/plugins/dashboard.js:175
msgid "Dashboard" msgid "Dashboard"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:32 ../public/js/plugins/compute.js:554 #: ../public/js/plugins/dashboard.js:238
msgid "CPU" msgid "Virtual Machines quotas"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:37 ../public/js/plugins/compute.js:558 #: ../public/js/plugins/dashboard.js:274
msgid "Memory" msgid "Storage size"
msgstr ""
#: ../public/js/plugins/dashboard.js:287
msgid "Number of images"
msgstr ""
#: ../public/js/plugins/dashboard.js:296
msgid "Image quota"
msgstr ""
#: ../public/js/plugins/dashboard.js:302
msgid "RVMs"
msgstr ""
#: ../public/js/plugins/dashboard.js:311
msgid "Network quota"
msgstr ""
#: ../public/js/plugins/dashboard.js:317
msgid "Leases"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:42 #: ../public/js/plugins/compute.js:42
@ -323,11 +392,11 @@ msgstr ""
msgid "Network reception" msgid "Network reception"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:65 ../public/js/plugins/compute.js:550 #: ../public/js/plugins/compute.js:65 ../public/js/plugins/compute.js:597
msgid "State" msgid "State"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:66 ../public/js/plugins/compute.js:636 #: ../public/js/plugins/compute.js:66 ../public/js/plugins/compute.js:645
msgid "IP" msgid "IP"
msgstr "" msgstr ""
@ -335,306 +404,329 @@ msgstr ""
msgid "VM Name" msgid "VM Name"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:80 ../public/js/plugins/compute.js:546 #: ../public/js/plugins/compute.js:80 ../public/js/plugins/compute.js:593
msgid "Instance type" msgid "Instance type"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:82 ../public/js/plugins/compute.js:1010 #: ../public/js/plugins/compute.js:82 ../public/js/plugins/compute.js:1038
msgid "Loading" msgid "Loading"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:86
msgid "Images"
msgstr ""
#: ../public/js/plugins/compute.js:97 #: ../public/js/plugins/compute.js:97
msgid "Create # VMs" msgid "Create # VMs"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:99 #: ../public/js/plugins/compute.js:99
msgid "You can use the wildcard &#37;. When creating several VMs, &#37; will be replaced with a different number starting from 0 in each of them" msgid "You can use the wildcard &#37;i. When creating several VMs, &#37;i will be replaced with a different number starting from 0 in each of them"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:335 #: ../public/js/plugins/compute.js:361
msgid "Shutdown" msgid "Shutdown"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:336 #: ../public/js/plugins/compute.js:362
msgid "This will shutdown the selected VMs" msgid "This will shutdown the selected VMs"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:344 #: ../public/js/plugins/compute.js:370
msgid "Suspend" msgid "Suspend"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:345 #: ../public/js/plugins/compute.js:371
msgid "This will suspend the selected VMs" msgid "This will suspend the selected VMs"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:349 #: ../public/js/plugins/compute.js:375
msgid "Resume" msgid "Resume"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:350 #: ../public/js/plugins/compute.js:376
msgid "This will resume the selected VMs in stopped or suspended states" msgid "This will resume the selected VMs in stopped or suspended states"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:354 #: ../public/js/plugins/compute.js:380
msgid "Stop" msgid "Stop"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:359 #: ../public/js/plugins/compute.js:385
msgid "Reboot" msgid "Reboot"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:364 #: ../public/js/plugins/compute.js:390
msgid "Reset" msgid "Reset"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:369 ../public/js/plugins/compute.js:837 #: ../public/js/plugins/compute.js:395
#: ../../../../../sunstone/public/js/sunstone.js:663 msgid "Restart"
#: ../../../../../sunstone/public/js/sunstone.js:695 msgstr ""
#: ../public/js/plugins/compute.js:396
msgid "This will redeploy selected VMs"
msgstr ""
#: ../public/js/plugins/compute.js:400
msgid "Resubmit"
msgstr ""
#: ../public/js/plugins/compute.js:401
msgid "This will resubmits VMs to PENDING state"
msgstr ""
#: ../public/js/plugins/compute.js:405
msgid "Power Off"
msgstr ""
#: ../public/js/plugins/compute.js:406
msgid "This will send a power off signal to running VMs. They can be restarted later."
msgstr ""
#: ../public/js/plugins/compute.js:410
#: ../../../../../sunstone/public/js/sunstone.js:664
#: ../../../../../sunstone/public/js/sunstone.js:696
msgid "Cancel" msgid "Cancel"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:370 #: ../public/js/plugins/compute.js:411
msgid "This will cancel selected VMs" msgid "This will cancel selected VMs"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:374 ../public/js/plugins/compute.js:826 #: ../public/js/plugins/compute.js:415
msgid "Take snapshot" msgid "Take snapshot"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:382 #: ../public/js/plugins/compute.js:423
msgid "This will delete the selected VMs from the database" msgid "This will delete the selected VMs from the database"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:388 #: ../public/js/plugins/compute.js:429
msgid "Compute resource" msgid "Compute resource"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:392 ../public/js/plugins/compute.js:610 #: ../public/js/plugins/compute.js:433 ../public/js/plugins/compute.js:619
msgid "Disks" msgid "Disks & Hotplugging"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:403 #: ../public/js/plugins/compute.js:444
msgid "Create Virtual Machine" msgid "Create Virtual Machine"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:530 #: ../public/js/plugins/compute.js:577
msgid "VM information" msgid "VM information"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:534 #: ../public/js/plugins/compute.js:581
msgid "Virtual Machine information" msgid "Virtual Machine information"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:562 #: ../public/js/plugins/compute.js:601
msgid "Used CPU"
msgstr ""
#: ../public/js/plugins/compute.js:605
msgid "Used Memory"
msgstr ""
#: ../public/js/plugins/compute.js:609
msgid "Launch VNC session" msgid "Launch VNC session"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:573 #: ../public/js/plugins/compute.js:625
msgid "Disks information"
msgstr ""
#: ../public/js/plugins/compute.js:591
msgid "Target"
msgstr ""
#: ../public/js/plugins/compute.js:602 ../public/js/plugins/compute.js:933
msgid "No disks defined"
msgstr ""
#: ../public/js/plugins/compute.js:616
msgid "Networks information" msgid "Networks information"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:640 #: ../public/js/plugins/compute.js:649
msgid "MAC" msgid "MAC"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:647 #: ../public/js/plugins/compute.js:656
msgid "No networks defined" msgid "No networks defined"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:661 #: ../public/js/plugins/compute.js:670
msgid "Monitoring information" msgid "Monitoring information"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:836 #: ../public/js/plugins/compute.js:708
#: ../../../../../sunstone/public/js/sunstone.js:662 msgid "Disks information - Save As and Detach"
#: ../../../../../sunstone/public/js/sunstone.js:694
msgid "OK"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:859 #: ../public/js/plugins/compute.js:722
msgid "Skipping VM " msgid "No disks to show"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:860 #: ../public/js/plugins/compute.js:733
msgid "No disk id or image name specified" msgid "Detach"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:896 #: ../public/js/plugins/compute.js:735
msgid "Saveas for VM with ID" msgid "Save"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:899 #: ../public/js/plugins/compute.js:737
msgid "Select disk" msgid "Save_as name"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:901 #: ../public/js/plugins/compute.js:755
msgid "Retrieving" msgid "Attach disk to running VM"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:905 #: ../public/js/plugins/compute.js:758
msgid "Image name" msgid "Select image"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:925 ../public/js/plugins/compute.js:928 #: ../public/js/plugins/compute.js:765
msgid "disk id" msgid "Target"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:1003 #: ../public/js/plugins/compute.js:772
msgid "Attach"
msgstr ""
#: ../public/js/plugins/compute.js:821
msgid "Please select an image to attach"
msgstr ""
#: ../public/js/plugins/compute.js:1031
msgid "VNC connection" msgid "VNC connection"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:1018 #: ../public/js/plugins/compute.js:1046
msgid "Canvas not supported." msgid "Canvas not supported."
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:1079 ../public/js/plugins/compute.js:1095 #: ../public/js/plugins/compute.js:1098 ../public/js/plugins/compute.js:1114
msgid "Open VNC Session" msgid "Open VNC Session"
msgstr "" msgstr ""
#: ../public/js/plugins/compute.js:1082 ../public/js/plugins/compute.js:1098 #: ../public/js/plugins/compute.js:1101 ../public/js/plugins/compute.js:1117
msgid "VNC Disabled" msgid "VNC Disabled"
msgstr "" msgstr ""
#: ../public/js/plugins/configuration.js:23 #: ../public/js/plugins/configuration.js:24
msgid "Self-Service UI Configuration" msgid "Self-Service UI Configuration"
msgstr "" msgstr ""
#: ../public/js/plugins/configuration.js:28 #: ../public/js/plugins/configuration.js:29
msgid "Language" msgid "Language"
msgstr "" msgstr ""
#: ../public/js/plugins/configuration.js:31
msgid "English"
msgstr ""
#: ../public/js/plugins/configuration.js:32 #: ../public/js/plugins/configuration.js:32
msgid "Chinese" msgid "English (US)"
msgstr "" msgstr ""
#: ../public/js/plugins/configuration.js:33 #: ../public/js/plugins/configuration.js:33
msgid "French (CA)" msgid "Chinese (TW)"
msgstr "" msgstr ""
#: ../public/js/plugins/configuration.js:34 #: ../public/js/plugins/configuration.js:34
msgid "French (FR)" msgid "French (CA)"
msgstr "" msgstr ""
#: ../public/js/plugins/configuration.js:35 #: ../public/js/plugins/configuration.js:35
msgid "German" msgid "French (FR)"
msgstr "" msgstr ""
#: ../public/js/plugins/configuration.js:36 #: ../public/js/plugins/configuration.js:36
msgid "Italian" msgid "German (DE)"
msgstr "" msgstr ""
#: ../public/js/plugins/configuration.js:37 #: ../public/js/plugins/configuration.js:37
msgid "Persian (IR)" msgid "Italian (IT)"
msgstr "" msgstr ""
#: ../public/js/plugins/configuration.js:38 #: ../public/js/plugins/configuration.js:38
msgid "Portuguese (BR)" msgid "Persian (IR)"
msgstr "" msgstr ""
#: ../public/js/plugins/configuration.js:39 #: ../public/js/plugins/configuration.js:39
msgid "Portuguese (PT)" msgid "Portuguese (BR)"
msgstr "" msgstr ""
#: ../public/js/plugins/configuration.js:40 #: ../public/js/plugins/configuration.js:40
msgid "Slovak" msgid "Portuguese (PT)"
msgstr "" msgstr ""
#: ../public/js/plugins/configuration.js:41 #: ../public/js/plugins/configuration.js:41
msgid "Spanish" msgid "Slovak (SK)"
msgstr "" msgstr ""
#: ../public/js/plugins/configuration.js:63 #: ../public/js/plugins/configuration.js:42
msgid "Spanish (ES)"
msgstr ""
#: ../public/js/plugins/configuration.js:64
msgid "Configuration" msgid "Configuration"
msgstr "" msgstr ""
#: ../../../../../sunstone/public/js/sunstone.js:588 #: ../../../../../sunstone/public/js/sunstone.js:589
msgid "Previous action" msgid "Previous action"
msgstr "" msgstr ""
#: ../../../../../sunstone/public/js/sunstone.js:651 #: ../../../../../sunstone/public/js/sunstone.js:652
#: ../../../../../sunstone/public/js/sunstone.js:685 #: ../../../../../sunstone/public/js/sunstone.js:686
msgid "Confirmation of action" msgid "Confirmation of action"
msgstr "" msgstr ""
#: ../../../../../sunstone/public/js/sunstone.js:657 #: ../../../../../sunstone/public/js/sunstone.js:658
msgid "You have to confirm this action." msgid "You have to confirm this action."
msgstr "" msgstr ""
#: ../../../../../sunstone/public/js/sunstone.js:659 #: ../../../../../sunstone/public/js/sunstone.js:660
msgid "Do you want to proceed?" msgid "Do you want to proceed?"
msgstr "" msgstr ""
#: ../../../../../sunstone/public/js/sunstone.js:690 #: ../../../../../sunstone/public/js/sunstone.js:663
#: ../../../../../sunstone/public/js/sunstone.js:695
msgid "OK"
msgstr ""
#: ../../../../../sunstone/public/js/sunstone.js:691
msgid "You need to select something." msgid "You need to select something."
msgstr "" msgstr ""
#: ../../../../../sunstone/public/js/sunstone-util.js:206 #: ../../../../../sunstone/public/js/sunstone-util.js:210
msgid "Submitted" msgid "Submitted"
msgstr "" msgstr ""
#: ../../../../../sunstone/public/js/sunstone-util.js:223 #: ../../../../../sunstone/public/js/sunstone-util.js:227
msgid "Error" msgid "Error"
msgstr "" msgstr ""
#: ../../../../../sunstone/public/js/sunstone-util.js:229 #: ../../../../../sunstone/public/js/sunstone-util.js:233
msgid "Info" msgid "Info"
msgstr "" msgstr ""
#: ../../../../../sunstone/public/js/sunstone-util.js:361 #: ../../../../../sunstone/public/js/sunstone-util.js:365
msgid "Cannot contact server: is it running and reachable?" msgid "Cannot contact server: is it running and reachable?"
msgstr "" msgstr ""
#: ../../../../../sunstone/public/js/sunstone-util.js:369 #: ../../../../../sunstone/public/js/sunstone-util.js:373
msgid "Network is unreachable: is OpenNebula running?" msgid "Network is unreachable: is OpenNebula running?"
msgstr "" msgstr ""
#: ../../../../../sunstone/public/js/sunstone-util.js:390 #: ../../../../../sunstone/public/js/sunstone-util.js:394
msgid "Unauthorized" msgid "Unauthorized"
msgstr "" msgstr ""
#: ../../../../../sunstone/public/js/sunstone-util.js:581 #: ../../../../../sunstone/public/js/sunstone-util.js:585
#: ../../../../../sunstone/public/js/sunstone-util.js:801 #: ../../../../../sunstone/public/js/sunstone-util.js:807
msgid "Please select" msgid "Please select"
msgstr "" msgstr ""
#: ../../../../../sunstone/public/js/sunstone-util.js:724 #: ../../../../../sunstone/public/js/sunstone-util.js:730
msgid "Update template" msgid "Update template"
msgstr "" msgstr ""
#: ../../../../../sunstone/public/js/sunstone-util.js:730 #: ../../../../../sunstone/public/js/sunstone-util.js:736
msgid "Please, choose and modify the template you want to update" msgid "Please, choose and modify the template you want to update"
msgstr "" msgstr ""
#: ../../../../../sunstone/public/js/sunstone-util.js:732 #: ../../../../../sunstone/public/js/sunstone-util.js:738
#: ../../../../../sunstone/public/js/sunstone-util.js:735 #: ../../../../../sunstone/public/js/sunstone-util.js:741
msgid "Select a template" msgid "Select a template"
msgstr "" msgstr ""
#: ../../../../../sunstone/public/js/sunstone-util.js:740 #: ../../../../../sunstone/public/js/sunstone-util.js:1026
msgid "Update"
msgstr ""
#: ../../../../../sunstone/public/js/sunstone-util.js:1020
msgid "Please select an element" msgid "Please select an element"
msgstr "" msgstr ""
@ -666,6 +758,10 @@ msgstr ""
msgid "Storage pool is formed by several images. These images can contain from full operating systems to be used as base for compute resources, to simple data. OpenNebula Self-Service offers you the possibility to create or upload your own images." msgid "Storage pool is formed by several images. These images can contain from full operating systems to be used as base for compute resources, to simple data. OpenNebula Self-Service offers you the possibility to create or upload your own images."
msgstr "" msgstr ""
#: ../public/customize/custom.js:72
msgid "Network"
msgstr ""
#: ../public/customize/custom.js:74 #: ../public/customize/custom.js:74
msgid "Your compute resources connectivity is performed using pre-defined virtual networks. You can create and manage these networks using OpenNebula Self-Service." msgid "Your compute resources connectivity is performed using pre-defined virtual networks. You can create and manage these networks using OpenNebula Self-Service."
msgstr "" msgstr ""

View File

@ -27,6 +27,23 @@ body {
padding: 0 10px 0 10px; padding: 0 10px 0 10px;
} }
#footer {
padding: 9px 10px 10px 10px;
color: white;
text-align: center;
background-color: #353735;
border:0;
width: 100%;
height: 9px;
position: fixed;
bottom: 0;
font-size: 10.4px;
}
#footer a {
color: white;
text-decoration: underline;
}
#logo { #logo {
padding-top: 6px; padding-top: 6px;

Binary file not shown.

After

Width:  |  Height:  |  Size: 399 B

View File

@ -466,6 +466,18 @@ var OCCI = {
params.data.body = { state : "RESUME" }; params.data.body = { state : "RESUME" };
OCCI.Action.update(params,OCCI.VM.resource,"resume"); OCCI.Action.update(params,OCCI.VM.resource,"resume");
}, },
"restart": function(params){
params.data.body = { state : "RESTART" };
OCCI.Action.update(params,OCCI.VM.resource,"restart");
},
"poweroff": function(params){
params.data.body = { state : "POWEROFF" };
OCCI.Action.update(params,OCCI.VM.resource,"poweroff");
},
"resubmit": function(params){
params.data.body = { state : "RESUBMIT" };
OCCI.Action.update(params,OCCI.VM.resource,"resubmit");
},
"done": function(params){ "done": function(params){
params.data.body = { state : "DONE" }; params.data.body = { state : "DONE" };
OCCI.Action.update(params,OCCI.VM.resource,"done"); OCCI.Action.update(params,OCCI.VM.resource,"done");

View File

@ -291,6 +291,33 @@ var vm_actions = {
}, },
error: onError, error: onError,
notify: true notify: true
},
"VM.restart" : {
type: "multiple",
call: OCCI.VM.restart,
callback: updateVMachineElement,
elements: vmElements,
error: onError,
notify: true
},
"VM.resubmit" : {
type: "multiple",
call: OCCI.VM.resubmit,
callback: updateVMachineElement,
elements: vmElements,
error: onError,
notify: true
},
"VM.poweroff" : {
type: "multiple",
call: OCCI.VM.poweroff,
callback: updateVMachineElement,
elements: vmElements,
error: onError,
notify: true
} }
/* /*
@ -363,6 +390,21 @@ var vm_buttons = {
text: tr("Reset"), text: tr("Reset"),
tip: "This will perform a hard reset on selected VMs" tip: "This will perform a hard reset on selected VMs"
}, },
"VM.restart" : {
type: "confirm",
text: tr("Restart"),
tip: tr("This will redeploy selected VMs")
},
"VM.resubmit" : {
type: "confirm",
text: tr("Resubmit"),
tip: tr("This will resubmits VMs to PENDING state")
},
"VM.poweroff" : {
type : "confirm",
text: tr("Power Off"),
tip: tr("This will send a power off signal to running VMs. They can be restarted later.")
},
"VM.cancel" : { "VM.cancel" : {
type: "confirm", type: "confirm",
text: tr("Cancel"), text: tr("Cancel"),
@ -513,6 +555,7 @@ function VMStateBulletStr(vm){
case "HOLD": case "HOLD":
case "STOPPED": case "STOPPED":
case "SUSPENDED": case "SUSPENDED":
case "POWEROFF":
state_html = '<img style="display:inline-block;margin-right:5px;;" src="images/yellow_bullet.png" alt="'+vm_state+'" title="'+vm_state+'" />'; state_html = '<img style="display:inline-block;margin-right:5px;;" src="images/yellow_bullet.png" alt="'+vm_state+'" title="'+vm_state+'" />';
break; break;
case "ACTIVE": case "ACTIVE":
@ -886,7 +929,7 @@ function popUpCreateVMDialog(){
var href = location.protocol + "//" + location.host; var href = location.protocol + "//" + location.host;
var disks = $('#disk_box option[clicked="clicked"]'); var disks = $('#disk_box option[clicked="clicked"]', dialog);
if (disks.length){ if (disks.length){
vm["DISK"] = []; vm["DISK"] = [];
@ -896,7 +939,7 @@ function popUpCreateVMDialog(){
}); });
}; };
var nets = $('#network_box option[clicked="clicked"]'); var nets = $('#network_box option[clicked="clicked"]', dialog);
if (nets.length){ if (nets.length){
vm["NIC"] = []; vm["NIC"] = [];

View File

@ -29,17 +29,17 @@ var config_tab_content =
<td class="key_td">' + tr("Language") + '</td>\ <td class="key_td">' + tr("Language") + '</td>\
<td class="value_td">\ <td class="value_td">\
<select id="lang_sel" style="width:20em;">\ <select id="lang_sel" style="width:20em;">\
<option value="en_US">'+tr("English")+'</option>\ <option value="en_US">'+tr("English (US)")+'</option>\
<option value="zh_TW">'+tr("Chinese")+' (TW)</option>\ <option value="zh_TW">'+tr("Chinese (TW)")+'</option>\
<option value="fr_CA">'+tr("French (CA)")+'</option>\ <option value="fr_CA">'+tr("French (CA)")+'</option>\
<option value="fr_FR">'+tr("French (FR)")+'</option>\ <option value="fr_FR">'+tr("French (FR)")+'</option>\
<option value="de">'+tr("German")+'</option>\ <option value="de">'+tr("German (DE)")+'</option>\
<option value="it_IT">'+tr("Italian")+'</option>\ <option value="it_IT">'+tr("Italian (IT)")+'</option>\
<option value="fa_IR">'+tr("Persian (IR)")+'</option>\ <option value="fa_IR">'+tr("Persian (IR)")+'</option>\
<option value="pt_BR">'+tr("Portuguese (BR)")+'</option>\ <option value="pt_BR">'+tr("Portuguese (BR)")+'</option>\
<option value="pt_PT">'+tr("Portuguese (PT)")+'</option>\ <option value="pt_PT">'+tr("Portuguese (PT)")+'</option>\
<option value="sk_SK">'+tr("Slovak")+'</option>\ <option value="sk_SK">'+tr("Slovak (SK)")+'</option>\
<option value="es_ES">'+tr("Spanish")+'</option>\ <option value="es_ES">'+tr("Spanish (ES)")+'</option>\
</select>\ </select>\
</td>\ </td>\
</tr>\ </tr>\

View File

@ -1,6 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="images/favicon.ico" />
<title>OpenNebula Self-Service Login</title> <title>OpenNebula Self-Service Login</title>
<link rel="stylesheet" type="text/css" href="css/login.css" /> <link rel="stylesheet" type="text/css" href="css/login.css" />
<link rel="stylesheet" type="text/css" href="vendor/jQueryUI/jquery-ui-1.8.16.custom.css" /> <link rel="stylesheet" type="text/css" href="vendor/jQueryUI/jquery-ui-1.8.16.custom.css" />
@ -51,5 +52,8 @@
</div> </div>
</form> </form>
</div> </div>
<div id="footer" style="overflow:visible;">
<a href="http://opennebula.org" target="_blank">OpenNebula 3.7.0</a> by <a href="http://c12g.com" target="_blank">C12G Labs</a>.
</div>
</body> </body>
</html> </html>

View File

@ -3,7 +3,7 @@
<head> <head>
<title>OpenNebula Self-Service</title> <title>OpenNebula Self-Service</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta http-equiv="content-type" content="text/html; charset=utf-8">
<link rel="shortcut icon" href="images/favicon.ico" />
<!-- Vendor Libraries --> <!-- Vendor Libraries -->
<link rel="stylesheet" type="text/css" href="vendor/dataTables/demo_table_jui.css" /> <link rel="stylesheet" type="text/css" href="vendor/dataTables/demo_table_jui.css" />
<link rel="stylesheet" type="text/css" href="vendor/jQueryUI/jquery-ui-1.8.16.custom.css" /> <link rel="stylesheet" type="text/css" href="vendor/jQueryUI/jquery-ui-1.8.16.custom.css" />
@ -81,7 +81,7 @@
</div> </div>
<div id="footer" style="overflow:visible;" class="ui-layout-south"> <div id="footer" style="overflow:visible;" class="ui-layout-south">
Copyright 2002-2012 &copy; OpenNebula Project Leads (<a href="http://opennebula.org" target="_blank">OpenNebula.org</a>). All Rights Reserved. OpenNebula 3.7.0 <a href="http://opennebula.org" target="_blank">OpenNebula 3.7.0</a> by <a href="http://c12g.com" target="_blank">C12G Labs</a>.
</div> </div>

View File

@ -91,6 +91,21 @@ EOF
function fs_size { function fs_size {
case $1 in case $1 in
http://*/download|https://*/download)
BASE_URL=${1%%/download}
HEADERS=`wget -S --spider --no-check-certificate $BASE_URL 2>&1`
echo $HEADERS | grep "opennebula_marketplace" > /dev/null 2>&1
if [ $? -eq 0 ]; then
#URL is from market place
SIZE=`wget -O - -S --no-check-certificate $BASE_URL 2>&1 | grep size | cut -d: -f2`
else
#Not a marketplace URL
SIZE=`wget -S --spider --no-check-certificate $1 2>&1 | grep Content-Length | cut -d':' -f2`
fi
error=$?
;;
http://*|https://*) http://*|https://*)
SIZE=`wget -S --spider --no-check-certificate $1 2>&1 | grep Content-Length | cut -d':' -f2` SIZE=`wget -S --spider --no-check-certificate $1 2>&1 | grep Content-Length | cut -d':' -f2`
error=$? error=$?

View File

@ -77,6 +77,10 @@ void DispatchManager::trigger(Actions action, int _vid)
aname = "STOP_SUCCESS"; aname = "STOP_SUCCESS";
break; break;
case POWEROFF_SUCCESS:
aname = "POWEROFF_SUCCESS";
break;
case DONE: case DONE:
aname = "DONE"; aname = "DONE";
break; break;
@ -126,6 +130,10 @@ void DispatchManager::do_action(const string &action, void * arg)
{ {
stop_success_action(vid); stop_success_action(vid);
} }
else if (action == "POWEROFF_SUCCESS")
{
poweroff_success_action(vid);
}
else if (action == "DONE") else if (action == "DONE")
{ {
done_action(vid); done_action(vid);

View File

@ -209,6 +209,52 @@ error:
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
int DispatchManager::poweroff (
int vid)
{
ostringstream oss;
VirtualMachine * vm;
vm = vmpool->get(vid,true);
if ( vm == 0 )
{
return -1;
}
oss << "Powering off VM " << vid;
NebulaLog::log("DiM",Log::DEBUG,oss);
if (vm->get_state() == VirtualMachine::ACTIVE &&
vm->get_lcm_state() == VirtualMachine::RUNNING )
{
Nebula& nd = Nebula::instance();
LifeCycleManager * lcm = nd.get_lcm();
lcm->trigger(LifeCycleManager::POWEROFF,vid);
}
else
{
goto error;
}
vm->unlock();
return 0;
error:
oss.str("");
oss << "Could not power off VM " << vid << ", wrong state.";
NebulaLog::log("DiM",Log::ERROR,oss);
vm->unlock();
return -2;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int DispatchManager::hold( int DispatchManager::hold(
int vid) int vid)
{ {
@ -464,8 +510,6 @@ int DispatchManager::resume(
Nebula& nd = Nebula::instance(); Nebula& nd = Nebula::instance();
LifeCycleManager * lcm = nd.get_lcm(); LifeCycleManager * lcm = nd.get_lcm();
vm->set_state(VirtualMachine::ACTIVE);
vmpool->update(vm); vmpool->update(vm);
vm->log("DiM", Log::INFO, "New VM state is ACTIVE."); vm->log("DiM", Log::INFO, "New VM state is ACTIVE.");
@ -508,9 +552,10 @@ int DispatchManager::restart(int vid)
oss << "Restarting VM " << vid; oss << "Restarting VM " << vid;
NebulaLog::log("DiM",Log::DEBUG,oss); NebulaLog::log("DiM",Log::DEBUG,oss);
if (vm->get_state() == VirtualMachine::ACTIVE && if ((vm->get_state() == VirtualMachine::ACTIVE &&
(vm->get_lcm_state() == VirtualMachine::UNKNOWN || (vm->get_lcm_state() == VirtualMachine::UNKNOWN ||
vm->get_lcm_state() == VirtualMachine::BOOT)) vm->get_lcm_state() == VirtualMachine::BOOT))
|| vm->get_state() == VirtualMachine::POWEROFF )
{ {
Nebula& nd = Nebula::instance(); Nebula& nd = Nebula::instance();
LifeCycleManager * lcm = nd.get_lcm(); LifeCycleManager * lcm = nd.get_lcm();
@ -739,6 +784,7 @@ int DispatchManager::finalize(
switch (state) switch (state)
{ {
case VirtualMachine::SUSPENDED: case VirtualMachine::SUSPENDED:
case VirtualMachine::POWEROFF:
int cpu, mem, disk; int cpu, mem, disk;
vm->get_requirements(cpu,mem,disk); vm->get_requirements(cpu,mem,disk);
@ -799,6 +845,12 @@ int DispatchManager::resubmit(int vid)
switch (vm->get_state()) switch (vm->get_state())
{ {
case VirtualMachine::POWEROFF:
NebulaLog::log("DiM",Log::ERROR,
"Cannot resubmit a powered off VM. Restart it first");
rc = -2;
break;
case VirtualMachine::SUSPENDED: case VirtualMachine::SUSPENDED:
NebulaLog::log("DiM",Log::ERROR, NebulaLog::log("DiM",Log::ERROR,
"Cannot resubmit a suspended VM. Resume it first"); "Cannot resubmit a suspended VM. Resume it first");
@ -810,19 +862,30 @@ int DispatchManager::resubmit(int vid)
break; break;
case VirtualMachine::FAILED: //Cleanup VM host files case VirtualMachine::FAILED: //Cleanup VM host files
vm->log("DiM", Log::INFO, "New VM state is CLEANUP.");
vm->set_state(VirtualMachine::CLEANUP);
vm->set_state(VirtualMachine::ACTIVE);
vmpool->update(vm);
tm->trigger(TransferManager::EPILOG_DELETE,vid); tm->trigger(TransferManager::EPILOG_DELETE,vid);
break;
case VirtualMachine::HOLD: // Move the VM to PENDING in any of these case VirtualMachine::HOLD: // Move the VM to PENDING in any of these
case VirtualMachine::STOPPED: case VirtualMachine::STOPPED:
vm->set_state(VirtualMachine::LCM_INIT); vm->set_state(VirtualMachine::LCM_INIT);
vm->set_state(VirtualMachine::PENDING); vm->set_state(VirtualMachine::PENDING);
vmpool->update(vm); vmpool->update(vm);
vm->log("DiM", Log::INFO, "New VM state is PENDING."); vm->log("DiM", Log::INFO, "New VM state is PENDING.");
break; break;
case VirtualMachine::ACTIVE: //Cleanup VM resources before PENDING case VirtualMachine::ACTIVE: //Cleanup VM resources before PENDING
lcm->trigger(LifeCycleManager::CLEAN,vid); lcm->trigger(LifeCycleManager::CLEAN, vid);
break; break;
case VirtualMachine::DONE: case VirtualMachine::DONE:
NebulaLog::log("DiM",Log::ERROR, NebulaLog::log("DiM",Log::ERROR,
"Cannot resubmit a VM already in DONE state"); "Cannot resubmit a VM already in DONE state");

View File

@ -97,6 +97,45 @@ void DispatchManager::stop_success_action(int vid)
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
void DispatchManager::poweroff_success_action(int vid)
{
VirtualMachine * vm;
vm = vmpool->get(vid,true);
if ( vm == 0 )
{
return;
}
if ((vm->get_state() == VirtualMachine::ACTIVE) &&
(vm->get_lcm_state() == VirtualMachine::SHUTDOWN_POWEROFF))
{
vm->set_state(VirtualMachine::POWEROFF);
vm->set_state(VirtualMachine::LCM_INIT);
vmpool->update(vm);
vm->log("DiM", Log::INFO, "New VM state is POWEROFF");
}
else
{
ostringstream oss;
oss << "poweroff_success action received but VM " << vid
<< " not in ACTIVE state";
NebulaLog::log("DiM",Log::ERROR,oss);
}
vm->unlock();
return;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void DispatchManager::done_action(int vid) void DispatchManager::done_action(int vid)
{ {
VirtualMachine * vm; VirtualMachine * vm;

View File

@ -17,8 +17,6 @@
#--------------------------------------------------------------------------- # #--------------------------------------------------------------------------- #
#Setup driver variables #Setup driver variables
DRIVER_NAME=`basename $0 | cut -d. -f1`
if [ -z "${ONE_LOCATION}" ]; then if [ -z "${ONE_LOCATION}" ]; then
DRIVERRC=/etc/one/${DRIVER_NAME}/${DRIVER_NAME}rc DRIVERRC=/etc/one/${DRIVER_NAME}/${DRIVER_NAME}rc
MADCOMMON=/usr/lib/one/mads/madcommon.sh MADCOMMON=/usr/lib/one/mads/madcommon.sh
@ -38,7 +36,7 @@ export_rc_vars $DRIVERRC
# Go to var directory ONE_LOCATION/var or /var/lib/one # Go to var directory ONE_LOCATION/var or /var/lib/one
cd $VAR_LOCATION cd $VAR_LOCATION
LOG_FILE=one_im_ssh_$DRIVER_NAME LOG_FILE=$DRIVER_NAME
# Execute the actual MAD # Execute the actual MAD
execute_mad $* execute_mad $*

View File

@ -22,4 +22,6 @@ else
MAD_LOCATION=$ONE_LOCATION/lib/mads MAD_LOCATION=$ONE_LOCATION/lib/mads
fi fi
export DRIVER_NAME="one_im_sh_${BASH_ARGV##* }"
exec $MAD_LOCATION/one_im_exec -l $* exec $MAD_LOCATION/one_im_exec -l $*

View File

@ -22,4 +22,6 @@ else
MAD_LOCATION=$ONE_LOCATION/lib/mads MAD_LOCATION=$ONE_LOCATION/lib/mads
fi fi
export DRIVER_NAME="one_im_ssh_${BASH_ARGV##* }"
exec $MAD_LOCATION/one_im_exec $* exec $MAD_LOCATION/one_im_exec $*

View File

@ -112,7 +112,7 @@ void LifeCycleManager::suspend_action(int vid)
vm->set_state(VirtualMachine::SAVE_SUSPEND); vm->set_state(VirtualMachine::SAVE_SUSPEND);
vm->set_resched(false); vm->set_resched(false);
vmpool->update(vm); vmpool->update(vm);
vm->log("LCM", Log::INFO, "New VM state is SAVE_SUSPEND"); vm->log("LCM", Log::INFO, "New VM state is SAVE_SUSPEND");
@ -156,9 +156,9 @@ void LifeCycleManager::stop_action(int vid)
//---------------------------------------------------- //----------------------------------------------------
vm->set_state(VirtualMachine::SAVE_STOP); vm->set_state(VirtualMachine::SAVE_STOP);
vm->set_resched(false); vm->set_resched(false);
vmpool->update(vm); vmpool->update(vm);
vm->log("LCM", Log::INFO, "New VM state is SAVE_STOP"); vm->log("LCM", Log::INFO, "New VM state is SAVE_STOP");
@ -337,6 +337,52 @@ void LifeCycleManager::shutdown_action(int vid)
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
void LifeCycleManager::poweroff_action(int vid)
{
VirtualMachine * vm;
vm = vmpool->get(vid,true);
if ( vm == 0 )
{
return;
}
if (vm->get_state() == VirtualMachine::ACTIVE &&
vm->get_lcm_state() == VirtualMachine::RUNNING)
{
Nebula& nd = Nebula::instance();
VirtualMachineManager * vmm = nd.get_vmm();
//----------------------------------------------------
// SHUTDOWN_POWEROFF STATE
//----------------------------------------------------
vm->set_state(VirtualMachine::SHUTDOWN_POWEROFF);
vm->set_resched(false);
vmpool->update(vm);
vm->log("LCM",Log::INFO,"New VM state is SHUTDOWN_POWEROFF");
//----------------------------------------------------
vmm->trigger(VirtualMachineManager::SHUTDOWN,vid);
}
else
{
vm->log("LCM", Log::ERROR, "poweroff_action, VM in a wrong state.");
}
vm->unlock();
return;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void LifeCycleManager::restore_action(int vid) void LifeCycleManager::restore_action(int vid)
{ {
VirtualMachine * vm; VirtualMachine * vm;
@ -349,7 +395,7 @@ void LifeCycleManager::restore_action(int vid)
return; return;
} }
if (vm->get_state() == VirtualMachine::ACTIVE) if (vm->get_state() == VirtualMachine::SUSPENDED)
{ {
Nebula& nd = Nebula::instance(); Nebula& nd = Nebula::instance();
VirtualMachineManager * vmm = nd.get_vmm(); VirtualMachineManager * vmm = nd.get_vmm();
@ -360,6 +406,7 @@ void LifeCycleManager::restore_action(int vid)
//---------------------------------------------------- //----------------------------------------------------
// BOOT STATE (FROM SUSPEND) // BOOT STATE (FROM SUSPEND)
//---------------------------------------------------- //----------------------------------------------------
vm->set_state(VirtualMachine::ACTIVE);
vm->set_state(VirtualMachine::BOOT); vm->set_state(VirtualMachine::BOOT);
@ -449,9 +496,10 @@ void LifeCycleManager::restart_action(int vid)
return; return;
} }
if (vm->get_state() == VirtualMachine::ACTIVE && if ((vm->get_state() == VirtualMachine::ACTIVE &&
(vm->get_lcm_state() == VirtualMachine::UNKNOWN || (vm->get_lcm_state() == VirtualMachine::UNKNOWN ||
vm->get_lcm_state() == VirtualMachine::BOOT)) vm->get_lcm_state() == VirtualMachine::BOOT ))
||vm->get_state() == VirtualMachine::POWEROFF)
{ {
Nebula& nd = Nebula::instance(); Nebula& nd = Nebula::instance();
VirtualMachineManager * vmm = nd.get_vmm(); VirtualMachineManager * vmm = nd.get_vmm();
@ -460,12 +508,14 @@ void LifeCycleManager::restart_action(int vid)
// RE-START THE VM IN THE SAME HOST // RE-START THE VM IN THE SAME HOST
//---------------------------------------------------- //----------------------------------------------------
if (vm->get_lcm_state() == VirtualMachine::BOOT) if (vm->get_state() == VirtualMachine::ACTIVE &&
vm->get_lcm_state() == VirtualMachine::BOOT)
{ {
vm->log("LCM", Log::INFO, "Sending BOOT command to VM again"); vm->log("LCM", Log::INFO, "Sending BOOT command to VM again");
} }
else else
{ {
vm->set_state(VirtualMachine::ACTIVE); // Only needed by poweroff
vm->set_state(VirtualMachine::BOOT); vm->set_state(VirtualMachine::BOOT);
vmpool->update(vm); vmpool->update(vm);
@ -550,8 +600,6 @@ void LifeCycleManager::clean_action(int vid)
clean_up_vm(vm); clean_up_vm(vm);
dm->trigger(DispatchManager::RESUBMIT,vid);
vm->unlock(); vm->unlock();
} }
@ -571,6 +619,8 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm)
VirtualMachine::LcmState state = vm->get_lcm_state(); VirtualMachine::LcmState state = vm->get_lcm_state();
int vid = vm->get_oid(); int vid = vm->get_oid();
vm->log("LCM", Log::INFO, "New VM state is CLEANUP.");
vm->set_state(VirtualMachine::CLEANUP); vm->set_state(VirtualMachine::CLEANUP);
vm->set_resched(false); vm->set_resched(false);
vmpool->update(vm); vmpool->update(vm);
@ -597,6 +647,7 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm)
case VirtualMachine::RUNNING: case VirtualMachine::RUNNING:
case VirtualMachine::UNKNOWN: case VirtualMachine::UNKNOWN:
case VirtualMachine::SHUTDOWN: case VirtualMachine::SHUTDOWN:
case VirtualMachine::SHUTDOWN_POWEROFF:
case VirtualMachine::CANCEL: case VirtualMachine::CANCEL:
case VirtualMachine::HOTPLUG: case VirtualMachine::HOTPLUG:
vm->set_running_etime(the_time); vm->set_running_etime(the_time);
@ -679,7 +730,7 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm)
vmpool->update_history(vm); vmpool->update_history(vm);
tm->trigger(TransferManager::EPILOG_DELETE,vid); tm->trigger(TransferManager::EPILOG_DELETE,vid);
break; break;
default: //LCM_INIT,CLEANUP default: //LCM_INIT,CLEANUP
break; break;
} }

View File

@ -193,6 +193,10 @@ void LifeCycleManager::trigger(Actions action, int _vid)
aname = ACTION_FINALIZE; aname = ACTION_FINALIZE;
break; break;
case POWEROFF:
aname = "POWEROFF";
break;
default: default:
delete vid; delete vid;
return; return;
@ -338,6 +342,10 @@ void LifeCycleManager::do_action(const string &action, void * arg)
{ {
clean_action(vid); clean_action(vid);
} }
else if (action == "POWEROFF")
{
poweroff_action(vid);
}
else if (action == ACTION_FINALIZE) else if (action == ACTION_FINALIZE)
{ {
NebulaLog::log("LCM",Log::INFO,"Stopping Life-cycle Manager..."); NebulaLog::log("LCM",Log::INFO,"Stopping Life-cycle Manager...");

View File

@ -314,7 +314,7 @@ void LifeCycleManager::deploy_failure_action(int vid)
vm->set_reason(History::ERROR); vm->set_reason(History::ERROR);
vmpool->update_history(vm); vmpool->update_history(vm);
vm->set_previous_etime(the_time); vm->set_previous_etime(the_time);
vm->set_previous_vm_info(); vm->set_previous_vm_info();
@ -367,6 +367,7 @@ void LifeCycleManager::shutdown_success_action(int vid)
{ {
Nebula& nd = Nebula::instance(); Nebula& nd = Nebula::instance();
TransferManager * tm = nd.get_tm(); TransferManager * tm = nd.get_tm();
DispatchManager * dm = nd.get_dm();
VirtualMachine * vm; VirtualMachine * vm;
time_t the_time = time(0); time_t the_time = time(0);
@ -377,25 +378,52 @@ void LifeCycleManager::shutdown_success_action(int vid)
return; return;
} }
//---------------------------------------------------- if ( vm->get_lcm_state() == VirtualMachine::SHUTDOWN )
// EPILOG STATE {
//---------------------------------------------------- //----------------------------------------------------
// EPILOG STATE
//----------------------------------------------------
vm->set_state(VirtualMachine::EPILOG); vm->set_state(VirtualMachine::EPILOG);
vmpool->update(vm); vmpool->update(vm);
vm->set_epilog_stime(the_time); vm->set_epilog_stime(the_time);
vm->set_running_etime(the_time); vm->set_running_etime(the_time);
vmpool->update_history(vm); vmpool->update_history(vm);
vm->log("LCM", Log::INFO, "New VM state is EPILOG"); vm->log("LCM", Log::INFO, "New VM state is EPILOG");
//---------------------------------------------------- //----------------------------------------------------
tm->trigger(TransferManager::EPILOG,vid); tm->trigger(TransferManager::EPILOG,vid);
}
else if (vm->get_lcm_state() == VirtualMachine::SHUTDOWN_POWEROFF)
{
//----------------------------------------------------
// POWEROFF STATE
//----------------------------------------------------
vm->set_running_etime(the_time);
vm->set_etime(the_time);
vm->set_vm_info();
vm->set_reason(History::STOP_RESUME);
vmpool->update_history(vm);
//----------------------------------------------------
dm->trigger(DispatchManager::POWEROFF_SUCCESS,vid);
}
else
{
vm->log("LCM",Log::ERROR,"shutdown_success_action, VM in a wrong state");
}
vm->unlock(); vm->unlock();
} }
@ -536,6 +564,7 @@ void LifeCycleManager::epilog_success_action(int vid)
time_t the_time = time(0); time_t the_time = time(0);
int cpu,mem,disk; int cpu,mem,disk;
VirtualMachine::LcmState state;
DispatchManager::Actions action; DispatchManager::Actions action;
vm = vmpool->get(vid,true); vm = vmpool->get(vid,true);
@ -545,14 +574,24 @@ void LifeCycleManager::epilog_success_action(int vid)
return; return;
} }
if (vm->get_lcm_state() == VirtualMachine::EPILOG_STOP) state = vm->get_lcm_state();
if ( state == VirtualMachine::EPILOG_STOP )
{ {
action = DispatchManager::STOP_SUCCESS; action = DispatchManager::STOP_SUCCESS;
} }
else if (vm->get_lcm_state() == VirtualMachine::EPILOG) else if ( state == VirtualMachine::EPILOG )
{ {
action = DispatchManager::DONE; action = DispatchManager::DONE;
} }
else if ( state == VirtualMachine::CLEANUP )
{
dm->trigger(DispatchManager::RESUBMIT, vid);
vm->unlock();
return;
}
else else
{ {
vm->log("LCM",Log::ERROR,"epilog_success_action, VM in a wrong state"); vm->log("LCM",Log::ERROR,"epilog_success_action, VM in a wrong state");
@ -597,9 +636,19 @@ void LifeCycleManager::epilog_failure_action(int vid)
return; return;
} }
vm->set_epilog_etime(the_time); if ( vm->get_lcm_state() == VirtualMachine::CLEANUP )
{
Nebula& nd = Nebula::instance();
DispatchManager * dm = nd.get_dm();
failure_action(vm); dm->trigger(DispatchManager::RESUBMIT, vid);
}
else
{
vm->set_epilog_etime(the_time);
failure_action(vm);
}
vm->unlock(); vm->unlock();
@ -809,7 +858,7 @@ void LifeCycleManager::failure_action(VirtualMachine * vm)
vm->set_state(VirtualMachine::FAILURE); vm->set_state(VirtualMachine::FAILURE);
vm->set_resched(false); vm->set_resched(false);
vmpool->update(vm); vmpool->update(vm);
vm->set_etime(the_time); vm->set_etime(the_time);

View File

@ -17,6 +17,7 @@
require 'socket' require 'socket'
require 'pp' require 'pp'
require 'rexml/document' require 'rexml/document'
require 'zlib'
begin begin
require 'rubygems' require 'rubygems'
@ -155,7 +156,7 @@ class GangliaHost
return nil if !base64_info return nil if !base64_info
info_yaml=Base64::decode64(base64_info) info_yaml=Zlib::Inflate.inflate(Base64::decode64(base64_info))
info=YAML.load(info_yaml) info=YAML.load(info_yaml)
end end

View File

@ -161,8 +161,6 @@ class SshStreamCommand < RemotesCommand
@remote_dir = remote_dir @remote_dir = remote_dir
@stream = SshStream.new(host, shell) @stream = SshStream.new(host, shell)
@stream.open
end end
def run(command, stdin=nil, base_cmd = nil) def run(command, stdin=nil, base_cmd = nil)

View File

@ -14,14 +14,14 @@
# limitations under the License. # # limitations under the License. #
#--------------------------------------------------------------------------- # #--------------------------------------------------------------------------- #
function mad_debug function mad_debug
{ {
if [ -n "${ONE_MAD_DEBUG}" ]; then if [ -n "${ONE_MAD_DEBUG}" ]; then
ulimit -c 15000 ulimit -c 15000
fi fi
} }
function export_rc_vars function export_rc_vars
{ {
if [ -f $1 ] ; then if [ -f $1 ] ; then
ONE_VARS=`cat $1 | egrep -e '^[a-zA-Z\-\_0-9]*=' | sed 's/=.*$//'` ONE_VARS=`cat $1 | egrep -e '^[a-zA-Z\-\_0-9]*=' | sed 's/=.*$//'`
@ -38,17 +38,17 @@ function execute_mad
{ {
MAD_FILE=`basename $0` MAD_FILE=`basename $0`
if [ -z "$LOG_FILE" ]; then if [ -z "$LOG_FILE" ]; then
LOG_FILE=$MAD_FILE LOG_FILE=$MAD_FILE
fi fi
if [ -z "${ONE_LOCATION}" ]; then if [ -z "${ONE_LOCATION}" ]; then
MAD_EXEC_PATH=/usr/lib/one/mads/$MAD_FILE.rb MAD_EXEC_PATH=/usr/lib/one/mads/$MAD_FILE.rb
MAD_LOG_PATH=/var/log/one/$LOG_FILE.log MAD_LOG_PATH=/var/log/one/$LOG_FILE.log
else else
MAD_EXEC_PATH=$ONE_LOCATION/lib/mads/$MAD_FILE.rb MAD_EXEC_PATH=$ONE_LOCATION/lib/mads/$MAD_FILE.rb
MAD_LOG_PATH=$ONE_LOCATION/var/$LOG_FILE.log MAD_LOG_PATH=$ONE_LOCATION/var/$LOG_FILE.log
fi fi
if [ -n "${ONE_MAD_DEBUG}" ]; then if [ -n "${ONE_MAD_DEBUG}" ]; then

View File

@ -49,7 +49,8 @@ public class VirtualMachine extends PoolElement{
"STOPPED", "STOPPED",
"SUSPENDED", "SUSPENDED",
"DONE", "DONE",
"FAILED" }; "FAILED",
"POWEROFF" };
private static final String[] SHORT_VM_STATES = private static final String[] SHORT_VM_STATES =
{ {
@ -60,7 +61,8 @@ public class VirtualMachine extends PoolElement{
"stop", "stop",
"susp", "susp",
"done", "done",
"fail" }; "fail",
"poff" };
private static final String[] LCM_STATE = private static final String[] LCM_STATE =
{ {
@ -81,7 +83,8 @@ public class VirtualMachine extends PoolElement{
"FAILURE", "FAILURE",
"CLEANUP", "CLEANUP",
"UNKNOWN", "UNKNOWN",
"HOTPLUG" }; "HOTPLUG",
"SHUTDOWN_POWEROFF" };
private static final String[] SHORT_LCM_STATES = private static final String[] SHORT_LCM_STATES =
{ {
@ -102,7 +105,8 @@ public class VirtualMachine extends PoolElement{
"fail", "fail",
"clea", "clea",
"unkn", "unkn",
"hotp" }; "hotp",
"poff" };
/** /**
* Creates a new VM representation. * Creates a new VM representation.
@ -123,7 +127,6 @@ public class VirtualMachine extends PoolElement{
super(xmlElement, client); super(xmlElement, client);
} }
// ================================= // =================================
// Static XML-RPC methods // Static XML-RPC methods
// ================================= // =================================
@ -306,11 +309,12 @@ public class VirtualMachine extends PoolElement{
* <li>{@link VirtualMachine#resume()}</li> * <li>{@link VirtualMachine#resume()}</li>
* <li>{@link VirtualMachine#finalizeVM()}</li> * <li>{@link VirtualMachine#finalizeVM()}</li>
* <li>{@link VirtualMachine#restart()}</li> * <li>{@link VirtualMachine#restart()}</li>
* <li>{@link VirtualMachine#poweroff()}</li>
* </ul> * </ul>
* *
* @param action The action name to be performed, can be:<br/> * @param action The action name to be performed, can be:<br/>
* "shutdown", "reboot", "hold", "release", "stop", "cancel", "suspend", * "shutdown", "reboot", "hold", "release", "stop", "cancel", "suspend",
* "resume", "restart", "finalize". * "resume", "restart", "finalize","poweroff".
* @return If an error occurs the error message contains the reason. * @return If an error occurs the error message contains the reason.
*/ */
protected OneResponse action(String action) protected OneResponse action(String action)

View File

@ -84,7 +84,13 @@ module OpenNebula
# @return [nil, OpenNebula::Error] nil in case of success, Error # @return [nil, OpenNebula::Error] nil in case of success, Error
# otherwise # otherwise
def info() def info()
super(DOCUMENT_METHODS[:info], 'DOCUMENT') rc = super(DOCUMENT_METHODS[:info], 'DOCUMENT')
if !OpenNebula.is_error?(rc) && self['TYPE'].to_i != document_type
return OpenNebula::Error.new("[DocumentInfo] Error getting document [#{@pe_id}].")
end
return rc
end end
# Allocates a new Document in OpenNebula # Allocates a new Document in OpenNebula
@ -102,6 +108,9 @@ module OpenNebula
# @return [nil, OpenNebula::Error] nil in case of success, Error # @return [nil, OpenNebula::Error] nil in case of success, Error
# otherwise # otherwise
def delete() def delete()
rc = check_type()
return rc if OpenNebula.is_error?(rc)
return call(DOCUMENT_METHODS[:delete], @pe_id) return call(DOCUMENT_METHODS[:delete], @pe_id)
end end
@ -112,6 +121,9 @@ module OpenNebula
# @return [nil, OpenNebula::Error] nil in case of success, Error # @return [nil, OpenNebula::Error] nil in case of success, Error
# otherwise # otherwise
def update(new_template) def update(new_template)
rc = check_type()
return rc if OpenNebula.is_error?(rc)
super(DOCUMENT_METHODS[:update], new_template) super(DOCUMENT_METHODS[:update], new_template)
end end
@ -123,6 +135,9 @@ module OpenNebula
# @return [nil, OpenNebula::Error] nil in case of success, Error # @return [nil, OpenNebula::Error] nil in case of success, Error
# otherwise # otherwise
def chown(uid, gid) def chown(uid, gid)
rc = check_type()
return rc if OpenNebula.is_error?(rc)
super(DOCUMENT_METHODS[:chown], uid, gid) super(DOCUMENT_METHODS[:chown], uid, gid)
end end
@ -133,6 +148,9 @@ module OpenNebula
# @return [nil, OpenNebula::Error] nil in case of success, Error # @return [nil, OpenNebula::Error] nil in case of success, Error
# otherwise # otherwise
def chmod_octet(octet) def chmod_octet(octet)
rc = check_type()
return rc if OpenNebula.is_error?(rc)
super(DOCUMENT_METHODS[:chmod], octet) super(DOCUMENT_METHODS[:chmod], octet)
end end
@ -143,6 +161,9 @@ module OpenNebula
# otherwise # otherwise
def chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u, def chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u,
other_m, other_a) other_m, other_a)
rc = check_type()
return rc if OpenNebula.is_error?(rc)
super(DOCUMENT_METHODS[:chmod], owner_u, owner_m, owner_a, group_u, super(DOCUMENT_METHODS[:chmod], owner_u, owner_m, owner_a, group_u,
group_m, group_a, other_u, other_m, other_a) group_m, group_a, other_u, other_m, other_a)
end end
@ -154,6 +175,9 @@ module OpenNebula
# @return [Integer, OpenNebula::Error] The new Document ID in case # @return [Integer, OpenNebula::Error] The new Document ID in case
# of success, Error otherwise # of success, Error otherwise
def clone(name) def clone(name)
rc = check_type()
return rc if OpenNebula.is_error?(rc)
return Error.new('ID not defined') if !@pe_id return Error.new('ID not defined') if !@pe_id
rc = @client.call(DOCUMENT_METHODS[:clone], @pe_id, name) rc = @client.call(DOCUMENT_METHODS[:clone], @pe_id, name)
@ -198,5 +222,27 @@ module OpenNebula
chmod(-1, -1, -1, group_u, -1, -1, -1, -1, -1) chmod(-1, -1, -1, group_u, -1, -1, -1, -1, -1)
end end
def check_type()
type = self['TYPE']
if type.nil? && @pe_id
rc = @client.call(DOCUMENT_METHODS[:info], @pe_id)
return rc if OpenNebula.is_error?(rc)
xmldoc = XMLElement.new
xmldoc.initialize_xml(rc, 'DOCUMENT')
type = xmldoc['TYPE']
end
if !type.nil? && type.to_i != document_type
return OpenNebula::Error.new(
"[DocumentInfo] Error getting document [#{@pe_id}].")
end
return nil
end
end end
end end

View File

@ -38,11 +38,12 @@ module OpenNebula
:detach => "vm.detach" :detach => "vm.detach"
} }
VM_STATE=%w{INIT PENDING HOLD ACTIVE STOPPED SUSPENDED DONE FAILED} VM_STATE=%w{INIT PENDING HOLD ACTIVE STOPPED SUSPENDED DONE FAILED
POWEROFF}
LCM_STATE=%w{LCM_INIT PROLOG BOOT RUNNING MIGRATE SAVE_STOP SAVE_SUSPEND LCM_STATE=%w{LCM_INIT PROLOG BOOT RUNNING MIGRATE SAVE_STOP SAVE_SUSPEND
SAVE_MIGRATE PROLOG_MIGRATE PROLOG_RESUME EPILOG_STOP EPILOG SAVE_MIGRATE PROLOG_MIGRATE PROLOG_RESUME EPILOG_STOP EPILOG
SHUTDOWN CANCEL FAILURE CLEANUP UNKNOWN HOTPLUG} SHUTDOWN CANCEL FAILURE CLEANUP UNKNOWN HOTPLUG SHUTDOWN_POWEROFF}
SHORT_VM_STATES={ SHORT_VM_STATES={
"INIT" => "init", "INIT" => "init",
@ -52,7 +53,8 @@ module OpenNebula
"STOPPED" => "stop", "STOPPED" => "stop",
"SUSPENDED" => "susp", "SUSPENDED" => "susp",
"DONE" => "done", "DONE" => "done",
"FAILED" => "fail" "FAILED" => "fail",
"POWEROFF" => "poff"
} }
SHORT_LCM_STATES={ SHORT_LCM_STATES={
@ -72,7 +74,8 @@ module OpenNebula
"FAILURE" => "fail", "FAILURE" => "fail",
"CLEANUP" => "clea", "CLEANUP" => "clea",
"UNKNOWN" => "unkn", "UNKNOWN" => "unkn",
"HOTPLUG" => "hotp" "HOTPLUG" => "hotp",
"SHUTDOWN_POWEROFF" => "shut"
} }
MIGRATE_REASON=%w{NONE ERROR STOP_RESUME USER CANCEL} MIGRATE_REASON=%w{NONE ERROR STOP_RESUME USER CANCEL}
@ -148,6 +151,11 @@ module OpenNebula
action('shutdown') action('shutdown')
end end
# Powers off a running VM
def poweroff
action('poweroff')
end
# Reboots an already deployed VM # Reboots an already deployed VM
def reboot def reboot
action('reboot') action('reboot')

View File

@ -65,7 +65,8 @@ start()
ruby $OZONES_SERVER > $OZONES_LOG 2>$OZONES_LOG_ERROR & ruby $OZONES_SERVER > $OZONES_LOG 2>$OZONES_LOG_ERROR &
LASTPID=$! LASTPID=$!
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Error executing $OZONES_SERVER, please check the log $OZONES_LOG" echo "Error executing ozones-server."
echo "Check $OZONES_LOG_ERROR and $OZONES_LOG for more information"
exit 1 exit 1
else else
echo $LASTPID > $OZONES_PID echo $LASTPID > $OZONES_PID
@ -75,7 +76,8 @@ start()
ps $LASTPID &> /dev/null ps $LASTPID &> /dev/null
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Error executing $OZONES_SERVER, please check the log $OZONES_LOG" echo "Error executing ozones-server."
echo "Check $OZONES_LOG_ERROR and $OZONES_LOG for more information"
exit 1 exit 1
fi fi
@ -97,6 +99,7 @@ stop()
# Remove pid files # Remove pid files
rm -f $OZONES_LOCK_FILE &> /dev/null rm -f $OZONES_LOCK_FILE &> /dev/null
rm -f $OZONES_PID &> /dev/null
echo "ozones-server stopped" echo "ozones-server stopped"
} }

View File

@ -191,6 +191,7 @@ end
before do before do
cache_control :no_store cache_control :no_store
content_type 'application/json', :charset => 'utf-8'
unless request.path=='/login' || request.path=='/' unless request.path=='/login' || request.path=='/'
unless authorized? unless authorized?
@ -224,6 +225,7 @@ end
# HTML Requests # HTML Requests
############################################################################## ##############################################################################
get '/' do get '/' do
content_type 'text/html', :charset => 'utf-8'
return File.read(File.dirname(__FILE__)+ return File.read(File.dirname(__FILE__)+
'/templates/login.html') unless authorized? '/templates/login.html') unless authorized?
@ -236,6 +238,7 @@ get '/' do
end end
get '/login' do get '/login' do
content_type 'text/html', :charset => 'utf-8'
File.read(File.dirname(__FILE__)+'/templates/login.html') File.read(File.dirname(__FILE__)+'/templates/login.html')
end end
@ -253,9 +256,9 @@ end
############################################################################## ##############################################################################
# Config and Logs # Config and Logs
############################################################################## ##############################################################################
get '/config' do # get '/config' do
config # config
end # end
############################################################################## ##############################################################################
# GET information # GET information

View File

@ -27,6 +27,23 @@ body {
padding: 0 10px 0 10px; padding: 0 10px 0 10px;
} }
#footer {
padding: 9px 10px 10px 10px;
color: white;
text-align: center;
background-color: #353735;
border:0;
width: 100%;
height: 9px;
position: fixed;
bottom: 0;
font-size: 10.4px;
}
#footer a {
color: white;
text-decoration: underline;
}
#logo { #logo {
padding-top: 6px; padding-top: 6px;

Binary file not shown.

After

Width:  |  Height:  |  Size: 399 B

View File

@ -44,81 +44,86 @@ var oZones = {
"Helper": { "Helper": {
"resource_state": function(type, value) "resource_state": function(type, value)
{ {
var state;
switch(type) switch(type)
{ {
case "HOST": case "HOST":
case "host": case "host":
return ["INIT", state = tr(["INIT",
"MONITORING_MONITORED", "MONITORING_MONITORED",
"MONITORED", "MONITORED",
"ERROR", "ERROR",
"DISABLED", "DISABLED",
"MONITORING_ERROR"][value]; "MONITORING_ERROR"][value]);
break; break;
case "HOST_SIMPLE": case "HOST_SIMPLE":
case "host_simple": case "host_simple":
return ["INIT", state = tr(["INIT",
"UPDATE", "UPDATE",
"ON", "ON",
"ERROR", "ERROR",
"OFF", "OFF",
"RETRY"][value]; "RETRY"][value]);
break; break;
case "VM": case "VM":
case "vm": case "vm":
return ["INIT", state = tr(["INIT",
"PENDING", "PENDING",
"HOLD", "HOLD",
"ACTIVE", "ACTIVE",
"STOPPED", "STOPPED",
"SUSPENDED", "SUSPENDED",
"DONE", "DONE",
"FAILED"][value]; "FAILED",
"POWEROFF"][value]);
break; break;
case "VM_LCM": case "VM_LCM":
case "vm_lcm": case "vm_lcm":
return ["LCM_INIT", state = tr(["LCM_INIT",
"PROLOG", "PROLOG",
"BOOT", "BOOT",
"RUNNING", "RUNNING",
"MIGRATE", "MIGRATE",
"SAVE_STOP", "SAVE_STOP",
"SAVE_SUSPEND", "SAVE_SUSPEND",
"SAVE_MIGRATE", "SAVE_MIGRATE",
"PROLOG_MIGRATE", "PROLOG_MIGRATE",
"PROLOG_RESUME", "PROLOG_RESUME",
"EPILOG_STOP", "EPILOG_STOP",
"EPILOG", "EPILOG",
"SHUTDOWN", "SHUTDOWN",
"CANCEL", "CANCEL",
"FAILURE", "FAILURE",
"CLEANUP", "CLEANUP",
"UNKNOWN", "UNKNOWN",
"HOTPLUG"][value]; "HOTPLUG",
"SHUTDOWN_POWEROFF"][value]);
break; break;
case "IMAGE": case "IMAGE":
case "image": case "image":
return ["INIT", state = tr(["INIT",
"READY", "READY",
"USED", "USED",
"DISABLED", "DISABLED",
"LOCKED", "LOCKED",
"ERROR", "ERROR",
"CLONE", "CLONE",
"DELETE", "DELETE",
"USED_PERS"][value]; "USED_PERS"][value]);
break; break;
case "VM_MIGRATE_REASON": case "VM_MIGRATE_REASON":
case "vm_migrate_reason": case "vm_migrate_reason":
return ["NONE", state = tr(["NONE",
"ERROR", "ERROR",
"STOP_RESUME", "STOP_RESUME",
"USER", "USER",
"CANCEL"][value]; "CANCEL"][value]);
break; break;
default: default:
return; return value;
} }
if (!state) state = value
return state;
}, },
"image_type": function(value) "image_type": function(value)

View File

@ -3,6 +3,7 @@
<head> <head>
<title>OpenNebula oZones</title> <title>OpenNebula oZones</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<link rel="shortcut icon" href="images/favicon.ico" />
<!-- Vendor Libraries --> <!-- Vendor Libraries -->
<link rel="stylesheet" type="text/css" href="vendor/dataTables/demo_table_jui.css" /> <link rel="stylesheet" type="text/css" href="vendor/dataTables/demo_table_jui.css" />
@ -62,10 +63,10 @@
<a href="http://opennebula.org/community:community" target="_blank">Community</a> <a href="http://opennebula.org/community:community" target="_blank">Community</a>
</div> </div>
</div> </div>
<div id="footer" style="overflow:visible;" class="ui-layout-south">
Copyright 2002-2012 &copy; OpenNebula Project Leads (<a href="http://opennebula.org" target="_blank">OpenNebula.org</a>). All Rights Reserved. OpenNebula 3.7.0
</div>
<div id="footer" style="overflow:visible;" class="ui-layout-south">
<a href="http://opennebula.org" target="_blank">OpenNebula 3.7.0</a> by <a href="http://c12g.com" target="_blank">C12G Labs</a>.
</div>
<div id="dialogs"> <div id="dialogs">

View File

@ -1,6 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="images/favicon.ico" />
<title>OpenNebula oZones Login</title> <title>OpenNebula oZones Login</title>
<link rel="stylesheet" type="text/css" href="css/login.css" /> <link rel="stylesheet" type="text/css" href="css/login.css" />
<link rel="stylesheet" type="text/css" href="vendor/jQueryUI/jquery-ui-1.8.16.custom.css" /> <link rel="stylesheet" type="text/css" href="vendor/jQueryUI/jquery-ui-1.8.16.custom.css" />
@ -47,5 +48,8 @@
</div> </div>
</form> </form>
</div> </div>
<div id="footer" style="overflow:visible;">
<a href="http://opennebula.org" target="_blank">OpenNebula 3.7.0</a> by <a href="http://c12g.com" target="_blank">C12G Labs</a>.
</div>
</body> </body>
</html> </html>

View File

@ -328,6 +328,10 @@ void VirtualMachineAction::request_execute(xmlrpc_c::paramList const& paramList,
{ {
rc = dm->reset(id); rc = dm->reset(id);
} }
else if (action == "poweroff")
{
rc = dm->poweroff(id);
}
switch (rc) switch (rc)
{ {

View File

@ -64,13 +64,15 @@ start()
echo "Cannot find $SUNSTONE_SERVER." echo "Cannot find $SUNSTONE_SERVER."
exit 1 exit 1
fi fi
# Start the sunstone daemon # Start the sunstone daemon
touch $SUNSTONE_LOCK_FILE touch $SUNSTONE_LOCK_FILE
ruby $SUNSTONE_SERVER > $SUNSTONE_LOG 2>$SUNSTONE_LOG_ERROR & ruby $SUNSTONE_SERVER > $SUNSTONE_LOG 2>$SUNSTONE_LOG_ERROR &
LASTPID=$! LASTPID=$!
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Error executing $SUNSTONE_SERVER, please check the log $SUNSTONE_LOG" echo "Error executing sunstone-server."
echo "Check $SUNSTONE_LOG_ERROR and $SUNSTONE_LOG for more information"
exit 1 exit 1
else else
echo $LASTPID > $SUNSTONE_PID echo $LASTPID > $SUNSTONE_PID
@ -80,7 +82,8 @@ start()
ps $LASTPID &> /dev/null ps $LASTPID &> /dev/null
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Error executing $SUNSTONE_SERVER, please check the log $SUNSTONE_LOG" echo "Error executing sunstone-server."
echo "Check $SUNSTONE_LOG_ERROR and $SUNSTONE_LOG for more information"
exit 1 exit 1
fi fi
@ -102,6 +105,7 @@ stop()
# Remove pid files # Remove pid files
rm -f $SUNSTONE_LOCK_FILE &> /dev/null rm -f $SUNSTONE_LOCK_FILE &> /dev/null
rm -f $SUNSTONE_PID &> /dev/null
echo "sunstone-server stopped" echo "sunstone-server stopped"
} }

View File

@ -29,6 +29,6 @@ env.Po('fa_IR.po')
env.Po('fr_FR.po') env.Po('fr_FR.po')
env.Po('it_IT.po') env.Po('it_IT.po')
env.Po('pt_PT.po') env.Po('pt_PT.po')
env.Po('ru.po') env.Po('ru_RU.po')
env.Po('sk_SK.po') env.Po('sk_SK.po')
env.Po('zh_TW.po') env.Po('zh_TW.po')

File diff suppressed because it is too large Load Diff

View File

@ -64,6 +64,7 @@ module OpenNebulaJSON
when "saveas" then self.save_as(action_hash['params']) when "saveas" then self.save_as(action_hash['params'])
when "shutdown" then self.shutdown when "shutdown" then self.shutdown
when "reboot" then self.reboot when "reboot" then self.reboot
when "poweroff" then self.poweroff
when "resubmit" then self.resubmit when "resubmit" then self.resubmit
when "chown" then self.chown(action_hash['params']) when "chown" then self.chown(action_hash['params'])
when "chmod" then self.chmod_octet(action_hash['params']) when "chmod" then self.chmod_octet(action_hash['params'])

View File

@ -28,6 +28,24 @@ body {
} }
#footer {
padding: 9px 10px 10px 10px;
color: white;
text-align: center;
background-color: #353735;
border:0;
width: 100%;
height: 9px;
position: fixed;
bottom: 0;
font-size: 10.4px;
}
#footer a {
color: white;
text-decoration: underline;
}
#logo { #logo {
padding-top: 6px; padding-top: 6px;
font-size: 1.1em; font-size: 1.1em;

Binary file not shown.

After

Width:  |  Height:  |  Size: 399 B

View File

@ -44,11 +44,12 @@ var OpenNebula = {
"Helper": { "Helper": {
"resource_state": function(type, value) "resource_state": function(type, value)
{ {
var state;
switch(type) switch(type)
{ {
case "HOST": case "HOST":
case "host": case "host":
return tr(["INIT", state = tr(["INIT",
"MONITORING_MONITORED", "MONITORING_MONITORED",
"MONITORED", "MONITORED",
"ERROR", "ERROR",
@ -57,7 +58,7 @@ var OpenNebula = {
break; break;
case "HOST_SIMPLE": case "HOST_SIMPLE":
case "host_simple": case "host_simple":
return tr(["INIT", state = tr(["INIT",
"UPDATE", "UPDATE",
"ON", "ON",
"ERROR", "ERROR",
@ -66,18 +67,19 @@ var OpenNebula = {
break; break;
case "VM": case "VM":
case "vm": case "vm":
return tr(["INIT", state = tr(["INIT",
"PENDING", "PENDING",
"HOLD", "HOLD",
"ACTIVE", "ACTIVE",
"STOPPED", "STOPPED",
"SUSPENDED", "SUSPENDED",
"DONE", "DONE",
"FAILED"][value]); "FAILED",
"POWEROFF"][value]);
break; break;
case "VM_LCM": case "VM_LCM":
case "vm_lcm": case "vm_lcm":
return tr(["LCM_INIT", state = tr(["LCM_INIT",
"PROLOG", "PROLOG",
"BOOT", "BOOT",
"RUNNING", "RUNNING",
@ -94,11 +96,12 @@ var OpenNebula = {
"FAILURE", "FAILURE",
"CLEANUP", "CLEANUP",
"UNKNOWN", "UNKNOWN",
"HOTPLUG"][value]); "HOTPLUG",
"SHUTDOWN_POWEROFF"][value]);
break; break;
case "IMAGE": case "IMAGE":
case "image": case "image":
return tr(["INIT", state = tr(["INIT",
"READY", "READY",
"USED", "USED",
"DISABLED", "DISABLED",
@ -110,15 +113,17 @@ var OpenNebula = {
break; break;
case "VM_MIGRATE_REASON": case "VM_MIGRATE_REASON":
case "vm_migrate_reason": case "vm_migrate_reason":
return tr(["NONE", state = tr(["NONE",
"ERROR", "ERROR",
"STOP_RESUME", "STOP_RESUME",
"USER", "USER",
"CANCEL"][value]); "CANCEL"][value]);
break; break;
default: default:
return; return value;
} }
if (!state) state = value
return state;
}, },
"image_type": function(value) "image_type": function(value)
@ -201,14 +206,15 @@ var OpenNebula = {
//server requests helper methods //server requests helper methods
"create": function(params,resource){ "create": function(params, resource, path){
var callback = params.success; var callback = params.success;
var callback_error = params.error; var callback_error = params.error;
var data = params.data; var data = params.data;
var request = OpenNebula.Helper.request(resource,"create", data); var request = OpenNebula.Helper.request(resource,"create", data);
var req_path = path ? path : resource.toLowerCase();
$.ajax({ $.ajax({
url: resource.toLowerCase(), url: req_path,
type: "POST", type: "POST",
dataType: "json", dataType: "json",
data: JSON.stringify(data), data: JSON.stringify(data),
@ -222,14 +228,15 @@ var OpenNebula = {
}); });
}, },
"del": function(params,resource){ "del": function(params, resource, path){
var callback = params.success; var callback = params.success;
var callback_error = params.error; var callback_error = params.error;
var id = params.data.id; var id = params.data.id;
var request = OpenNebula.Helper.request(resource,"delete", id); var request = OpenNebula.Helper.request(resource,"delete", id);
var req_path = path ? path : resource.toLowerCase();
$.ajax({ $.ajax({
url: resource.toLowerCase() + "/" + id, url: req_path + "/" + id,
type: "DELETE", type: "DELETE",
success: function(){ success: function(){
return callback ? callback(request) : null; return callback ? callback(request) : null;
@ -241,14 +248,15 @@ var OpenNebula = {
}); });
}, },
"list": function(params,resource){ "list": function(params, resource, path){
var callback = params.success; var callback = params.success;
var callback_error = params.error; var callback_error = params.error;
var timeout = params.timeout || false; var timeout = params.timeout || false;
var request = OpenNebula.Helper.request(resource,"list"); var request = OpenNebula.Helper.request(resource,"list");
var req_path = path ? path : resource.toLowerCase();
$.ajax({ $.ajax({
url: resource.toLowerCase(), url: req_path,
type: "GET", type: "GET",
data: {timeout: timeout}, data: {timeout: timeout},
dataType: "json", dataType: "json",
@ -266,7 +274,7 @@ var OpenNebula = {
}, },
//Subresource examples: "fetch_template", "log"... //Subresource examples: "fetch_template", "log"...
"show": function(params,resource,subresource){ "show": function(params, resource, subresource, path){
var callback = params.success; var callback = params.success;
var callback_error = params.error; var callback_error = params.error;
var id = params.data.id; var id = params.data.id;
@ -274,7 +282,8 @@ var OpenNebula = {
OpenNebula.Helper.request(resource,subresource,id) : OpenNebula.Helper.request(resource,subresource,id) :
OpenNebula.Helper.request(resource,"show", id); OpenNebula.Helper.request(resource,"show", id);
var url = resource.toLowerCase() + "/" + id; var req_path = path ? path : resource.toLowerCase();
var url = req_path + "/" + id;
url = subresource? url + "/" + subresource : url; url = subresource? url + "/" + subresource : url;
$.ajax({ $.ajax({
@ -291,7 +300,7 @@ var OpenNebula = {
}); });
}, },
"chown": function(params,resource,chgrp){ "chown": function(params, resource, path){
var id = params.data.extra_param; var id = params.data.extra_param;
var action_obj = {"owner_id": id, var action_obj = {"owner_id": id,
"group_id": "-1"}; "group_id": "-1"};
@ -299,10 +308,11 @@ var OpenNebula = {
OpenNebula.Action.simple_action(params, OpenNebula.Action.simple_action(params,
resource, resource,
"chown", "chown",
action_obj); action_obj,
path);
}, },
"chgrp": function(params,resource){ "chgrp": function(params, resource, path){
var id = params.data.extra_param; var id = params.data.extra_param;
var action_obj = {"owner_id": "-1", var action_obj = {"owner_id": "-1",
"group_id": id}; "group_id": id};
@ -310,11 +320,12 @@ var OpenNebula = {
OpenNebula.Action.simple_action(params, OpenNebula.Action.simple_action(params,
resource, resource,
"chown", "chown",
action_obj); action_obj,
path);
}, },
//Example: Simple action: publish. Simple action with action obj: deploy //Example: Simple action: publish. Simple action with action obj: deploy
"simple_action": function(params,resource,method,action_obj){ "simple_action": function(params, resource, method, action_obj, path){
var callback = params.success; var callback = params.success;
var callback_error = params.error; var callback_error = params.error;
var id = params.data.id; var id = params.data.id;
@ -328,8 +339,10 @@ var OpenNebula = {
request = OpenNebula.Helper.request(resource,method, id); request = OpenNebula.Helper.request(resource,method, id);
}; };
var req_path = path ? path : resource.toLowerCase();
$.ajax({ $.ajax({
url: resource.toLowerCase() + "/" + id + "/action", url: req_path + "/" + id + "/action",
type: "POST", type: "POST",
data: JSON.stringify(action), data: JSON.stringify(action),
success: function(){ success: function(){
@ -342,7 +355,7 @@ var OpenNebula = {
}); });
}, },
"monitor": function(params,resource,all){ "monitor": function(params, resource, all, path){
var callback = params.success; var callback = params.success;
var callback_error = params.error; var callback_error = params.error;
var data = params.data; var data = params.data;
@ -350,7 +363,7 @@ var OpenNebula = {
var method = "monitor"; var method = "monitor";
var request = OpenNebula.Helper.request(resource,method, data); var request = OpenNebula.Helper.request(resource,method, data);
var url = resource.toLowerCase(); var url = path ? path : resource.toLowerCase();
url = all ? url + "/monitor" : url + "/" + params.data.id + "/monitor"; url = all ? url + "/monitor" : url + "/" + params.data.id + "/monitor";
$.ajax({ $.ajax({
@ -622,6 +635,9 @@ var OpenNebula = {
"resubmit": function(params){ "resubmit": function(params){
OpenNebula.Action.simple_action(params,OpenNebula.VM.resource,"resubmit"); OpenNebula.Action.simple_action(params,OpenNebula.VM.resource,"resubmit");
}, },
"poweroff" : function(params){
OpenNebula.Action.simple_action(params,OpenNebula.VM.resource,"poweroff");
},
"reboot" : function(params){ "reboot" : function(params){
OpenNebula.Action.simple_action(params,OpenNebula.VM.resource,"reboot"); OpenNebula.Action.simple_action(params,OpenNebula.VM.resource,"reboot");
}, },

View File

@ -29,14 +29,14 @@ var config_tab_content =
<td class="key_td">' + tr("Language") + '</td>\ <td class="key_td">' + tr("Language") + '</td>\
<td class="value_td">\ <td class="value_td">\
<select id="lang_sel" style="width:20em;">\ <select id="lang_sel" style="width:20em;">\
<option value="en_US">'+tr("English")+'</option>\ <option value="en_US">'+tr("English (US)")+'</option>\
<option value="zh_TW">'+tr("Chinese (TW)")+'</option>\ <option value="zh_TW">'+tr("Chinese (TW)")+'</option>\
<option value="fr_FR">'+tr("French")+'</option>\ <option value="fr_FR">'+tr("French (FR)")+'</option>\
<option value="it_IT">'+tr("Italian")+'</option>\ <option value="it_IT">'+tr("Italian (IT)")+'</option>\
<option value="fa_IR">'+tr("Persian (IR)")+'</option>\ <option value="fa_IR">'+tr("Persian (IR)")+'</option>\
<option value="pt_PT">'+tr("Portuguese")+'</option>\ <option value="pt_PT">'+tr("Portuguese (PT)")+'</option>\
<option value="ru">'+tr("Russian")+'</option>\ <option value="ru_RU">'+tr("Russian (RU)")+'</option>\
<option value="sk_SK">'+tr("Slovak")+'</option>\ <option value="sk_SK">'+tr("Slovak (SK)")+'</option>\
</select>\ </select>\
</td>\ </td>\
</tr>\ </tr>\

View File

@ -15,7 +15,7 @@
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
var infra_tab_content = var infra_tab_content =
'<table class="dashboard_table" id="infra_dashboard" style=>\ '<table class="dashboard_table" id="infra_dashboard">\
<tr>\ <tr>\
<td style="width:50%">\ <td style="width:50%">\
<table style="width:100%">\ <table style="width:100%">\

View File

@ -44,6 +44,9 @@ var market_actions = {
callback: function(request,response){ callback: function(request,response){
$('#img_name', $create_image_dialog).val(response['name']); $('#img_name', $create_image_dialog).val(response['name']);
$('#img_path', $create_image_dialog).val(response['links']['download']['href']); $('#img_path', $create_image_dialog).val(response['links']['download']['href']);
$('#src_path_select input[value="path"]', $create_image_dialog).trigger('click');
$('select#img_type', $create_image_dialog).val('OS');
$('select#img_type', $create_image_dialog).trigger('change');
//remove any options from the custom vars dialog box //remove any options from the custom vars dialog box
$("#custom_var_image_box",$create_image_dialog).empty(); $("#custom_var_image_box",$create_image_dialog).empty();

View File

@ -1605,12 +1605,14 @@ function setupCreateTemplateDialog(){
$('#PORT',section_graphics).parent().show(); $('#PORT',section_graphics).parent().show();
$('#PASSWD',section_graphics).parent().show(); $('#PASSWD',section_graphics).parent().show();
$('#KEYMAP',section_graphics).parent().show(); $('#KEYMAP',section_graphics).parent().show();
$('#LISTEN',section_graphics).parent().removeAttr('disabled');
$('#PORT',section_graphics).parent().removeAttr('disabled'); $('#PORT',section_graphics).parent().removeAttr('disabled');
$('#PASSWD',section_graphics).parent().removeAttr('disabled'); $('#PASSWD',section_graphics).parent().removeAttr('disabled');
$('#KEYMAP',section_graphics).parent().removeAttr('disabled'); $('#KEYMAP',section_graphics).parent().removeAttr('disabled');
break; break;
case "sdl": case "sdl":
$('#LISTEN',section_graphics).parent().show(); $('#LISTEN',section_graphics).parent().show();
$('#LISTEN',section_graphics).parent().removeAttr('disabled');
$('#PORT',section_graphics).parent().hide(); $('#PORT',section_graphics).parent().hide();
$('#PASSWD',section_graphics).parent().hide(); $('#PASSWD',section_graphics).parent().hide();
$('#KEYMAP',section_graphics).parent().hide(); $('#KEYMAP',section_graphics).parent().hide();
@ -1619,10 +1621,18 @@ function setupCreateTemplateDialog(){
$('#KEYMAP',section_graphics).parent().attr('disabled','disabled'); $('#KEYMAP',section_graphics).parent().attr('disabled','disabled');
break; break;
default: default:
$('#LISTEN',section_graphics).parent().hide(); $('#LISTEN',
$('#PORT',section_graphics).parent().hide(); section_graphics).parent().hide().attr('disabled',
$('#PASSWD',section_graphics).parent().hide(); 'disabled');
$('#KEYMAP',section_graphics).parent().hide(); $('#PORT',
section_graphics).parent().hide().attr('disabled',
'disabled');
$('#PASSWD',
section_graphics).parent().hide().attr('disabled',
'disabled');
$('#KEYMAP',
section_graphics).parent().hide().attr('disabled',
'disabled');
} }
}); });

View File

@ -343,6 +343,15 @@ var vm_actions = {
notify: true notify: true
}, },
"VM.poweroff" : {
type: "multiple",
call: OpenNebula.VM.poweroff,
callback: vmShow,
elements: vmElements,
error: onError,
notify: true
},
"VM.saveas" : { "VM.saveas" : {
type: "single", type: "single",
call: OpenNebula.VM.saveas, call: OpenNebula.VM.saveas,
@ -582,6 +591,11 @@ var vm_buttons = {
text: tr("Resubmit"), text: tr("Resubmit"),
tip: tr("This will resubmits VMs to PENDING state") tip: tr("This will resubmits VMs to PENDING state")
}, },
"VM.poweroff" : {
type : "confirm",
text: tr("Power Off"),
tip: tr("This will send a power off signal to running VMs. They can be restarted later.")
},
"VM.reboot" : { "VM.reboot" : {
type : "confirm", type : "confirm",
text: tr("Reboot"), text: tr("Reboot"),

View File

@ -87,7 +87,7 @@ enable_logging SUNSTONE_LOG, settings.config[:debug_level].to_i
begin begin
ENV["ONE_CIPHER_AUTH"] = SUNSTONE_AUTH ENV["ONE_CIPHER_AUTH"] = SUNSTONE_AUTH
cloud_auth = CloudAuth.new(settings.config) cloud_auth = CloudAuth.new(settings.config, settings.logger)
rescue => e rescue => e
settings.logger.error { settings.logger.error {
"Error initializing authentication system" } "Error initializing authentication system" }
@ -120,8 +120,8 @@ helpers do
begin begin
result = settings.cloud_auth.auth(request.env, params) result = settings.cloud_auth.auth(request.env, params)
rescue Exception => e rescue Exception => e
error 500, ""
logger.error { e.message } logger.error { e.message }
return [500, ""]
end end
if result.nil? if result.nil?
@ -183,6 +183,7 @@ end
before do before do
cache_control :no_store cache_control :no_store
content_type 'application/json', :charset => 'utf-8'
unless request.path=='/login' || request.path=='/' unless request.path=='/login' || request.path=='/'
halt 401 unless authorized? halt 401 unless authorized?
@ -218,6 +219,7 @@ end
# HTML Requests # HTML Requests
############################################################################## ##############################################################################
get '/' do get '/' do
content_type 'text/html', :charset => 'utf-8'
if !authorized? if !authorized?
return erb :login return erb :login
end end
@ -239,6 +241,7 @@ get '/' do
end end
get '/login' do get '/login' do
content_type 'text/html', :charset => 'utf-8'
if !authorized? if !authorized?
erb :login erb :login
end end
@ -290,6 +293,7 @@ post '/config' do
when "wss" then session[:wss] = value when "wss" then session[:wss] = value
end end
end end
[204,""]
end end
get '/vm/:id/log' do get '/vm/:id/log' do

View File

@ -3,7 +3,7 @@
<head> <head>
<title>OpenNebula Sunstone: Cloud Operations Center</title> <title>OpenNebula Sunstone: Cloud Operations Center</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta http-equiv="content-type" content="text/html; charset=utf-8">
<link rel="shortcut icon" href="images/favicon.ico" />
<!-- Vendor Libraries --> <!-- Vendor Libraries -->
<link rel="stylesheet" type="text/css" href="vendor/dataTables/demo_table_jui.css" /> <link rel="stylesheet" type="text/css" href="vendor/dataTables/demo_table_jui.css" />
<link rel="stylesheet" type="text/css" href="vendor/dataTables/ColVis.css" /> <link rel="stylesheet" type="text/css" href="vendor/dataTables/ColVis.css" />
@ -94,7 +94,7 @@
</div> </div>
</div> </div>
<div id="footer" style="overflow:visible;" class="ui-layout-south"> <div id="footer" style="overflow:visible;" class="ui-layout-south">
Copyright 2002-2012 &copy; OpenNebula Project Leads (<a href="http://opennebula.org" target="_blank">OpenNebula.org</a>). All Rights Reserved. OpenNebula 3.7.0 <a href="http://opennebula.org" target="_blank">OpenNebula 3.7.0</a> by <a href="http://c12g.com" target="_blank">C12G Labs</a>.
</div> </div>

View File

@ -1,8 +1,10 @@
<!DOCTYPE html> <!DOCTYPE html>
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="images/favicon.ico" />
<title>OpenNebula Sunstone Login</title> <title>OpenNebula Sunstone Login</title>
<link rel="stylesheet" type="text/css" href="css/login.css" /> <link rel="stylesheet" type="text/css" href="css/login.css" />
<link rel="stylesheet" type="text/css" href="vendor/jQueryUI/jquery-ui-1.8.16.custom.css" />
<!-- Vendor Libraries --> <!-- Vendor Libraries -->
<script type="text/javascript" src="vendor/jQuery/jquery-1.7.2.min.js"></script> <script type="text/javascript" src="vendor/jQuery/jquery-1.7.2.min.js"></script>
@ -27,5 +29,9 @@
<%= erb :_login_standard %> <%= erb :_login_standard %>
<% end %> <% end %>
<div id="footer" style="overflow:visible;">
<a href="http://opennebula.org" target="_blank">OpenNebula 3.7.0</a> by <a href="http://c12g.com" target="_blank">C12G Labs</a>.
</div>
</body> </body>
</html> </html>

View File

@ -224,8 +224,12 @@ int TransferManager::prolog_transfer_command(
string format; string format;
string tm_mad; string tm_mad;
string ds_id; string ds_id;
string vm_ds_id;
int disk_index; int disk_index;
vm_ds_id = vm->get_ds_id();
disk->vector_value("DISK_ID", disk_index); disk->vector_value("DISK_ID", disk_index);
type = disk->vector_value("TYPE"); type = disk->vector_value("TYPE");
@ -253,7 +257,7 @@ int TransferManager::prolog_transfer_command(
<< vm->get_hostname() << ":" << vm->get_hostname() << ":"
<< vm->get_remote_system_dir() << "/disk." << disk_index << " " << vm->get_remote_system_dir() << "/disk." << disk_index << " "
<< vm->get_oid() << " " << vm->get_oid() << " "
<< "0" << vm_ds_id
<< endl; << endl;
} }
else if ( type == "FS" ) else if ( type == "FS" )
@ -279,7 +283,7 @@ int TransferManager::prolog_transfer_command(
<< vm->get_hostname() << ":" << vm->get_hostname() << ":"
<< vm->get_remote_system_dir() << "/disk." << disk_index << " " << vm->get_remote_system_dir() << "/disk." << disk_index << " "
<< vm->get_oid() << " " << vm->get_oid() << " "
<< "0" << vm_ds_id
<< endl; << endl;
} }
else else
@ -386,8 +390,8 @@ void TransferManager::prolog_action(int vid)
goto error_history; goto error_history;
} }
vm_tm_mad = vm->get_tm_mad(); vm_tm_mad = vm->get_tm_mad();
tm_md = get(); tm_md = get();
if ( tm_md == 0 || vm_tm_mad.empty() ) if ( tm_md == 0 || vm_tm_mad.empty() )
{ {
@ -418,11 +422,11 @@ void TransferManager::prolog_action(int vid)
continue; continue;
} }
rc = prolog_transfer_command(vm, rc = prolog_transfer_command(vm,
disk, disk,
vm_tm_mad, vm_tm_mad,
opennebula_hostname, opennebula_hostname,
xfr, xfr,
os); os);
if ( rc != 0 ) if ( rc != 0 )
{ {
@ -443,7 +447,7 @@ void TransferManager::prolog_action(int vid)
if ( context_result ) if ( context_result )
{ {
//CONTEXT tm_mad files hostname:remote_system_dir/disk.i vmid dsid(=0) //CONTEXT tm_mad files hostname:remote_system_dir/disk.i vmid dsid(=0)
xfr << "CONTEXT " xfr << "CONTEXT "
<< vm_tm_mad << " " << vm_tm_mad << " "
<< vm->get_context_file() << " "; << vm->get_context_file() << " ";
@ -452,10 +456,11 @@ void TransferManager::prolog_action(int vid)
xfr << files << " "; xfr << files << " ";
} }
xfr << vm->get_hostname() << ":" xfr << vm->get_hostname() << ":"
<< vm->get_remote_system_dir() << "/disk." << num << " " << vm->get_remote_system_dir() << "/disk." << num << " "
<< vm->get_oid() << " " << vm->get_oid() << " "
<< "0" << endl; << vm->get_ds_id()
<< endl;
} }
xfr.close(); xfr.close();
@ -587,21 +592,21 @@ void TransferManager::prolog_migr_action(int vid)
tm_mad = vm_tm_mad; tm_mad = vm_tm_mad;
ds_id = vm_ds_id; ds_id = vm_ds_id;
} }
else else
{ {
tm_mad = disk->vector_value("TM_MAD"); tm_mad = disk->vector_value("TM_MAD");
ds_id = disk->vector_value("DATASTORE_ID"); ds_id = disk->vector_value("DATASTORE_ID");
if ( tm_mad.empty() || ds_id.empty() ) if ( tm_mad.empty() || ds_id.empty() )
{ {
continue; continue;
} }
} }
//MV tm_mad prev_host:remote_system_dir/disk.i host:remote_system_dir/disk.i vmid dsid //MV tm_mad prev_host:remote_system_dir/disk.i host:remote_system_dir/disk.i vmid dsid
xfr << "MV " xfr << "MV "
<< tm_mad << " " << tm_mad << " "
<< vm->get_previous_hostname() << ":" << vm->get_previous_hostname() << ":"
<< vm->get_remote_system_dir() << "/disk." << disk_id << " " << vm->get_remote_system_dir() << "/disk." << disk_id << " "
<< vm->get_hostname() << ":" << vm->get_hostname() << ":"
<< vm->get_remote_system_dir() << "/disk." << disk_id << " " << vm->get_remote_system_dir() << "/disk." << disk_id << " "
@ -612,11 +617,11 @@ void TransferManager::prolog_migr_action(int vid)
//MV tm_mad prev_host:remote_system_dir host:remote_system_dir VMID 0 //MV tm_mad prev_host:remote_system_dir host:remote_system_dir VMID 0
xfr << "MV " xfr << "MV "
<< vm_tm_mad << " " << vm_tm_mad << " "
<< vm->get_previous_hostname() << ":" << vm->get_previous_hostname() << ":"
<< vm->get_remote_system_dir() << " " << vm->get_remote_system_dir() << " "
<< vm->get_hostname() << ":" << vm->get_hostname() << ":"
<< vm->get_remote_system_dir() << " " << vm->get_remote_system_dir() << " "
<< vm->get_oid() << " " << vm->get_oid() << " "
<< vm_ds_id << endl; << vm_ds_id << endl;
xfr.close(); xfr.close();
@ -726,21 +731,21 @@ void TransferManager::prolog_resume_action(int vid)
tm_mad = vm_tm_mad; tm_mad = vm_tm_mad;
ds_id = vm_ds_id; ds_id = vm_ds_id;
} }
else else
{ {
tm_mad = disk->vector_value("TM_MAD"); tm_mad = disk->vector_value("TM_MAD");
ds_id = disk->vector_value("DATASTORE_ID"); ds_id = disk->vector_value("DATASTORE_ID");
if ( tm_mad.empty() || ds_id.empty() ) if ( tm_mad.empty() || ds_id.empty() )
{ {
continue; continue;
} }
} }
//MV tm_mad fe:system_dir/disk.i host:remote_system_dir/disk.i vmid dsid //MV tm_mad fe:system_dir/disk.i host:remote_system_dir/disk.i vmid dsid
xfr << "MV " xfr << "MV "
<< tm_mad << " " << tm_mad << " "
<< nd.get_nebula_hostname() << ":" << nd.get_nebula_hostname() << ":"
<< vm->get_system_dir() << "/disk." << disk_id << " " << vm->get_system_dir() << "/disk." << disk_id << " "
<< vm->get_hostname() << ":" << vm->get_hostname() << ":"
<< vm->get_remote_system_dir() << "/disk." << disk_id << " " << vm->get_remote_system_dir() << "/disk." << disk_id << " "
@ -755,7 +760,7 @@ void TransferManager::prolog_resume_action(int vid)
<< vm->get_hostname() << ":" << vm->get_remote_system_dir()<< " " << vm->get_hostname() << ":" << vm->get_remote_system_dir()<< " "
<< vm->get_oid() << " " << vm->get_oid() << " "
<< vm_ds_id << endl; << vm_ds_id << endl;
xfr.close(); xfr.close();
tm_md->transfer(vid,xfr_name); tm_md->transfer(vid,xfr_name);
@ -805,15 +810,15 @@ void TransferManager::epilog_transfer_command(
tm_mad = vm->get_tm_mad(); tm_mad = vm->get_tm_mad();
ds_id = vm->get_ds_id(); ds_id = vm->get_ds_id();
} }
else else
{ {
save = disk->vector_value("SAVE"); save = disk->vector_value("SAVE");
tm_mad = disk->vector_value("TM_MAD"); tm_mad = disk->vector_value("TM_MAD");
ds_id = disk->vector_value("DATASTORE_ID"); ds_id = disk->vector_value("DATASTORE_ID");
if ( save.empty() || ds_id.empty() || tm_mad.empty() ) if ( save.empty() || ds_id.empty() || tm_mad.empty() )
{ {
return; return;
} }
} }
@ -858,7 +863,7 @@ void TransferManager::epilog_transfer_command(
<< vm->get_hostname() << ":" << vm->get_hostname() << ":"
<< vm->get_remote_system_dir() << "/disk." << disk_index << " " << vm->get_remote_system_dir() << "/disk." << disk_index << " "
<< vm->get_oid() << " " << vm->get_oid() << " "
<< ds_id << ds_id
<< endl; << endl;
} }
} }
@ -935,12 +940,12 @@ void TransferManager::epilog_action(int vid)
} }
//DELETE vm_tm_mad hostname:remote_system_dir vmid ds_id //DELETE vm_tm_mad hostname:remote_system_dir vmid ds_id
xfr << "DELETE " xfr << "DELETE "
<< vm_tm_mad << " " << vm_tm_mad << " "
<< vm->get_hostname() << ":" << vm->get_remote_system_dir() << " " << vm->get_hostname() << ":" << vm->get_remote_system_dir() << " "
<< vm->get_oid() << " " << vm->get_oid() << " "
<< vm_ds_id << endl; << vm_ds_id << endl;
xfr.close(); xfr.close();
tm_md->transfer(vid,xfr_name); tm_md->transfer(vid,xfr_name);
@ -1049,14 +1054,14 @@ void TransferManager::epilog_stop_action(int vid)
tm_mad = vm_tm_mad; tm_mad = vm_tm_mad;
ds_id = vm_ds_id; ds_id = vm_ds_id;
} }
else else
{ {
tm_mad = disk->vector_value("TM_MAD"); tm_mad = disk->vector_value("TM_MAD");
ds_id = disk->vector_value("DATASTORE_ID"); ds_id = disk->vector_value("DATASTORE_ID");
if ( tm_mad.empty() || ds_id.empty() ) if ( tm_mad.empty() || ds_id.empty() )
{ {
continue; continue;
} }
} }
@ -1065,7 +1070,7 @@ void TransferManager::epilog_stop_action(int vid)
<< tm_mad << " " << tm_mad << " "
<< vm->get_hostname() << ":" << vm->get_hostname() << ":"
<< vm->get_remote_system_dir() << "/disk." << disk_id << " " << vm->get_remote_system_dir() << "/disk." << disk_id << " "
<< nd.get_nebula_hostname() << ":" << nd.get_nebula_hostname() << ":"
<< vm->get_system_dir() << "/disk." << disk_id << " " << vm->get_system_dir() << "/disk." << disk_id << " "
<< vm->get_oid() << " " << vm->get_oid() << " "
<< ds_id << endl; << ds_id << endl;
@ -1188,14 +1193,14 @@ void TransferManager::epilog_delete_action(bool local, int vid)
tm_mad = vm_tm_mad; tm_mad = vm_tm_mad;
ds_id = vm_ds_id; ds_id = vm_ds_id;
} }
else else
{ {
tm_mad = disk->vector_value("TM_MAD"); tm_mad = disk->vector_value("TM_MAD");
ds_id = disk->vector_value("DATASTORE_ID"); ds_id = disk->vector_value("DATASTORE_ID");
if ( tm_mad.empty() || ds_id.empty() ) if ( tm_mad.empty() || ds_id.empty() )
{ {
continue; continue;
} }
} }
@ -1260,7 +1265,7 @@ error_drivers:
error_file: error_file:
os.str(""); os.str("");
os << "epilog_delete, could not open file: " << xfr_name; os << "epilog_delete, could not open file: " << xfr_name;
os << ". You may need to manually clean " << vm->get_hostname() os << ". You may need to manually clean " << vm->get_hostname()
<< ":" << vm->get_remote_system_dir(); << ":" << vm->get_remote_system_dir();
goto error_common; goto error_common;
@ -1350,14 +1355,14 @@ void TransferManager::epilog_delete_previous_action(int vid)
tm_mad = vm_tm_mad; tm_mad = vm_tm_mad;
ds_id = vm_ds_id; ds_id = vm_ds_id;
} }
else else
{ {
tm_mad = disk->vector_value("TM_MAD"); tm_mad = disk->vector_value("TM_MAD");
ds_id = disk->vector_value("DATASTORE_ID"); ds_id = disk->vector_value("DATASTORE_ID");
if ( tm_mad.empty() || ds_id.empty() ) if ( tm_mad.empty() || ds_id.empty() )
{ {
continue; continue;
} }
} }
@ -1371,12 +1376,12 @@ void TransferManager::epilog_delete_previous_action(int vid)
} }
//DELTE vm_tm_mad prev_host:remote_system_dir vmid ds_id(=0) //DELTE vm_tm_mad prev_host:remote_system_dir vmid ds_id(=0)
xfr << "DELETE " xfr << "DELETE "
<< vm_tm_mad << " " << vm_tm_mad << " "
<< vm->get_previous_hostname() <<":"<< vm->get_remote_system_dir() << vm->get_previous_hostname() <<":"<< vm->get_remote_system_dir()
<< " " << vm->get_oid() << " " << " " << vm->get_oid() << " "
<< vm_ds_id << endl; << vm_ds_id << endl;
xfr.close(); xfr.close();
tm_md->transfer(vid,xfr_name); tm_md->transfer(vid,xfr_name);
@ -1397,7 +1402,7 @@ error_drivers:
error_file: error_file:
os.str(""); os.str("");
os << "epilog_delete_previous, could not open file: " << xfr_name; os << "epilog_delete_previous, could not open file: " << xfr_name;
os << ". You may need to manually clean " << vm->get_previous_hostname() os << ". You may need to manually clean " << vm->get_previous_hostname()
<< ":" << vm->get_remote_system_dir(); << ":" << vm->get_remote_system_dir();
goto error_common; goto error_common;
@ -1442,7 +1447,7 @@ void TransferManager::driver_cancel_action(int vid)
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// Cancel the current operation // Cancel the current operation
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
tm_md->driver_cancel(vid); tm_md->driver_cancel(vid);
vm->unlock(); vm->unlock();
@ -1457,6 +1462,25 @@ void TransferManager::checkpoint_action(int vid)
} }
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
void TransferManager::migrate_transfer_command(
VirtualMachine * vm,
ostream& xfr)
{
// <PREMIGRATE/POSTMIGRATE> tm_mad SOURCE DST remote_system_dir vmid dsid
xfr << "MIGRATE " //TM action PRE or POST to be completed by VMM driver
<< vm->get_tm_mad() << " "
<< vm->get_hostname() << " "
<< vm->get_previous_hostname() << " "
<< vm->get_remote_system_dir() << " "
<< vm->get_oid() << " "
<< vm->get_ds_id()
<< endl;
}
/* ************************************************************************** */ /* ************************************************************************** */
/* MAD Loading */ /* MAD Loading */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@ -96,8 +96,7 @@ void TransferManagerDriver::protocol(
return; return;
} }
if ( vm->get_lcm_state() == VirtualMachine::CLEANUP || if ( vm->get_lcm_state() == VirtualMachine::FAILURE ||
vm->get_lcm_state() == VirtualMachine::FAILURE ||
vm->get_lcm_state() == VirtualMachine::LCM_INIT ) vm->get_lcm_state() == VirtualMachine::LCM_INIT )
{ {
os.str(""); os.str("");
@ -128,6 +127,7 @@ void TransferManagerDriver::protocol(
case VirtualMachine::EPILOG: case VirtualMachine::EPILOG:
case VirtualMachine::EPILOG_STOP: case VirtualMachine::EPILOG_STOP:
case VirtualMachine::CLEANUP:
lcm_action = LifeCycleManager::EPILOG_SUCCESS; lcm_action = LifeCycleManager::EPILOG_SUCCESS;
break; break;
@ -143,7 +143,7 @@ void TransferManagerDriver::protocol(
os.str(""); os.str("");
os << "Error executing image transfer script"; os << "Error executing image transfer script";
if (!info.empty() && info[0] != '-') if (!info.empty() && info[0] != '-')
{ {
os << ": " << info; os << ": " << info;
@ -151,7 +151,7 @@ void TransferManagerDriver::protocol(
vm->set_template_error_message(os.str()); vm->set_template_error_message(os.str());
vmpool->update(vm); vmpool->update(vm);
} }
vm->log("TM",Log::ERROR,os); vm->log("TM",Log::ERROR,os);
switch (vm->get_lcm_state()) switch (vm->get_lcm_state())
@ -164,6 +164,7 @@ void TransferManagerDriver::protocol(
case VirtualMachine::EPILOG: case VirtualMachine::EPILOG:
case VirtualMachine::EPILOG_STOP: case VirtualMachine::EPILOG_STOP:
case VirtualMachine::CLEANUP:
lcm_action = LifeCycleManager::EPILOG_FAILURE; lcm_action = LifeCycleManager::EPILOG_FAILURE;
break; break;

29
src/tm_mad/common/postmigrate Executable file
View File

@ -0,0 +1,29 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2012, 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. #
#--------------------------------------------------------------------------- #
# POSTMIGRATE SOURCE DST remote_system_dir vmid dsid template
# - SOURCE is the host where the VM is running
# - DST is the host where the VM is 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

29
src/tm_mad/common/premigrate Executable file
View File

@ -0,0 +1,29 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2012, 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. #
#--------------------------------------------------------------------------- #
# PREMIGRATE SOURCE DST remote_system_dir vmid dsid template
# - SOURCE is the host where the VM is running
# - DST is the host where the VM is 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

View File

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

1
src/tm_mad/dummy/premigrate Symbolic link
View File

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

View File

@ -0,0 +1 @@
../common/postmigrate

1
src/tm_mad/iscsi/premigrate Symbolic link
View File

@ -0,0 +1 @@
../common/premigrate

1
src/tm_mad/lvm/postmigrate Symbolic link
View File

@ -0,0 +1 @@
../common/postmigrate

1
src/tm_mad/lvm/premigrate Symbolic link
View File

@ -0,0 +1 @@
../common/premigrate

View File

@ -0,0 +1 @@
../common/postmigrate

1
src/tm_mad/qcow2/premigrate Symbolic link
View File

@ -0,0 +1 @@
../common/premigrate

View File

@ -0,0 +1 @@
../common/postmigrate

View File

@ -0,0 +1 @@
../common/premigrate

Some files were not shown because too many files have changed in this diff Show More