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

Merge branch 'master' into feature-192

This commit is contained in:
Ruben S. Montero 2010-03-12 23:37:20 +01:00
commit 2976924d3a
326 changed files with 7599 additions and 2681 deletions

18
NOTICE Normal file
View File

@ -0,0 +1,18 @@
OpenNebula Open Source Project
Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org)
-----------------------------------------
You can find more information about the project, relase notes and
documentation at www.OpenNebula.org
AUTHORS
- Ruben Santiago Montero (rubensm@dacya.ucm.es)
- Ignacio Martín Llorente (llorente@dacya.ucm.es)
ACKNOWLEDGEMENTS
The following people have contributed to the development of the technology
- Javier Fontán Muiños (jfontan@fdi.ucm.es)
- Constantino Vázquez Blanco (tinova@fdi.ucm.es)
- Jaime Melis Bayo (j.melis@fdi.ucm.es)

View File

@ -1,6 +1,5 @@
# -------------------------------------------------------------------------- #
# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
# Complutense de Madrid (dsa-research.org) #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
@ -284,7 +283,11 @@ public:
*
*
*/
int get_share_running_vms()
{
return host_share.running_vms;
}
int get_share_disk_usage()
{
return host_share.disk_usage;

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
@ -223,7 +222,7 @@ public:
static string version()
{
return "OpenNebula 1.3.80";
return "OpenNebula 1.5.0";
};
void start();

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
@ -45,10 +44,10 @@ public:
if(priority.empty()!=true)
{
sw.max = *max_element(
sw.max = fabs(*max_element(
priority.begin(),
priority.end(),
SchedulerHostPolicy::abs_cmp);
SchedulerHostPolicy::abs_cmp));
transform(
priority.begin(),

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
@ -111,10 +110,15 @@ private:
~Host(){};
bool operator<(const Host& b) { //Sort by priority
bool operator<(const Host& b) const { //Sort by priority
return priority < b.priority;
}
};
static bool host_cmp (const Host * a, const Host * b )
{
return (*a < *b );
};
//--------------------------------------------------------------------------

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
# Complutense de Madrid (dsa-research.org) #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@ -30,20 +29,22 @@
usage() {
echo
echo "Usage: install.sh [-u install_user] [-g install_group] [-k keep conf]"
echo " [-d ONE_LOCATION] [-r] [-h]"
echo " [-d ONE_LOCATION] [-c occi|ec2] [-r] [-h]"
echo
echo "-u: user that will run opennebula, defults to user executing install.sh"
echo "-g: group of the user that will run opennebula, defults to user"
echo " executing install.sh"
echo "-k: keep current configuration files, useful when upgrading"
echo "-d: target installation directory, if not defined it'd be root"
echo "-c: install only 'occi' or 'ec2' client files"
echo "-r: remove Opennebula, only useful if -d was not specified, otherwise"
echo " rm -rf \$ONE_LOCATION would do the job"
echo "-l: creates symlinks instead of copying files, useful for development"
echo "-h: prints this help"
}
#-------------------------------------------------------------------------------
TEMP_OPT=`getopt -o hkru:g:d: -n 'install.sh' -- "$@"`
TEMP_OPT=`getopt -o hkrlc:u:g:d: -n 'install.sh' -- "$@"`
if [ $? != 0 ] ; then
usage
@ -54,6 +55,8 @@ eval set -- "$TEMP_OPT"
INSTALL_ETC="yes"
UNINSTALL="no"
LINK="no"
CLIENT="no"
ONEADMIN_USER=`id -u`
ONEADMIN_GROUP=`id -g`
SRC_DIR=$PWD
@ -63,6 +66,8 @@ while true ; do
-h) usage; exit 0;;
-k) INSTALL_ETC="no" ; shift ;;
-r) UNINSTALL="yes" ; shift ;;
-l) LINK="yes" ; shift ;;
-c) CLIENT="$2" ; shift 2;;
-u) ONEADMIN_USER="$2" ; shift 2;;
-g) ONEADMIN_GROUP="$2"; shift 2;;
-d) ROOT="$2" ; shift 2 ;;
@ -71,6 +76,14 @@ while true ; do
esac
done
if echo "$CLIENT" | egrep -ivq '^(no|occi|ec2)$'; then
echo "ERROR: client '$CLIENT' not valid. Use either 'occi' or 'ec2'."
usage
exit 1
else
CLIENT=`echo $CLIENT | tr [:upper:] [:lower:]`
fi
#-------------------------------------------------------------------------------
# Definition of locations
#-------------------------------------------------------------------------------
@ -82,17 +95,27 @@ if [ -z "$ROOT" ] ; then
LOG_LOCATION="/var/log/one"
VAR_LOCATION="/var/lib/one"
RUN_LOCATION="/var/run/one"
LOCK_LOCATION="/var/lock/one"
INCLUDE_LOCATION="/usr/include"
SHARE_LOCATION="/usr/share/doc/opennebula"
if [ "$CLIENT" = "no" ]; then
MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $ETC_LOCATION $VAR_LOCATION \
$INCLUDE_LOCATION $SHARE_LOCATION \
$LOG_LOCATION $RUN_LOCATION $LOCK_LOCATION"
DELETE_DIRS="$LIB_LOCATION $ETC_LOCATION $LOG_LOCATION $VAR_LOCATION \
$RUN_LOCATION $SHARE_DIRS"
MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $ETC_LOCATION $VAR_LOCATION \
$INCLUDE_LOCATION $SHARE_LOCATION \
$LOG_LOCATION $RUN_LOCATION"
CHOWN_DIRS="$LOG_LOCATION $VAR_LOCATION $RUN_LOCATION $LOCK_LOCATION"
else
MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION"
DELETE_DIRS="$LIB_LOCATION $ETC_LOCATION $LOG_LOCATION $VAR_LOCATION \
$RUN_LOCATION $SHARE_DIRS"
DELETE_DIRS=""
CHOWN_DIRS=""
fi
CHOWN_DIRS="$LOG_LOCATION $VAR_LOCATION $RUN_LOCATION"
else
BIN_LOCATION="$ROOT/bin"
LIB_LOCATION="$ROOT/lib"
@ -101,10 +124,18 @@ else
INCLUDE_LOCATION="$ROOT/include"
SHARE_LOCATION="$ROOT/share"
MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $ETC_LOCATION $VAR_LOCATION \
$INCLUDE_LOCATION $SHARE_LOCATION"
DELETE_DIRS="$MAKE_DIRS"
if [ "$CLIENT" = "no" ]; then
MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $ETC_LOCATION $VAR_LOCATION \
$INCLUDE_LOCATION $SHARE_LOCATION"
DELETE_DIRS="$MAKE_DIRS"
CHOWN_DIRS="$ROOT"
else
MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION"
DELETE_DIRS="$MAKE_DIRS"
fi
CHOWN_DIRS="$ROOT"
fi
@ -124,20 +155,41 @@ ETC_DIRS="$ETC_LOCATION/im_kvm \
$ETC_LOCATION/tm_nfs \
$ETC_LOCATION/tm_ssh \
$ETC_LOCATION/tm_dummy \
$ETC_LOCATION/tm_lvm \
$ETC_LOCATION/hm \
$ETC_LOCATION/ec2query_templates"
$ETC_LOCATION/ec2query_templates \
$ETC_LOCATION/occi_templates"
LIB_DIRS="$LIB_LOCATION/im_probes \
$LIB_LOCATION/ruby \
$LIB_LOCATION/ruby/OpenNebula \
$LIB_LOCATION/ruby/econe \
$LIB_LOCATION/ruby/cloud/ \
$LIB_LOCATION/ruby/cloud/econe \
$LIB_LOCATION/ruby/cloud/econe/views \
$LIB_LOCATION/ruby/cloud/occi \
$LIB_LOCATION/tm_commands \
$LIB_LOCATION/tm_commands/nfs \
$LIB_LOCATION/tm_commands/ssh \
$LIB_LOCATION/tm_commands/dummy \
$LIB_LOCATION/tm_commands/lvm \
$LIB_LOCATION/mads"
MAKE_DIRS="$MAKE_DIRS $SHARE_DIRS $ETC_DIRS $LIB_DIRS"
LIB_ECO_CLIENT_DIRS="$LIB_LOCATION/ruby \
$LIB_LOCATION/ruby/OpenNebula
$LIB_LOCATION/ruby/cloud/ \
$LIB_LOCATION/ruby/cloud/econe"
LIB_OCCI_CLIENT_DIRS="$LIB_LOCATION/ruby \
$LIB_LOCATION/ruby/OpenNebula
$LIB_LOCATION/ruby/cloud/occi"
if [ "$CLIENT" = "no" ]; then
MAKE_DIRS="$MAKE_DIRS $SHARE_DIRS $ETC_DIRS $LIB_DIRS"
elif [ "$CLIENT" = "ec2" ]; then
MAKE_DIRS="$MAKE_DIRS $LIB_ECO_CLIENT_DIRS"
elif [ "$CLIENT" = "occi" ]; then
MAKE_DIRS="$MAKE_DIRS $LIB_OCCI_CLIENT_DIRS"
fi
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
@ -155,11 +207,24 @@ INSTALL_FILES[6]="IM_PROBES_LIB_FILES:$LIB_LOCATION/im_probes"
INSTALL_FILES[7]="NFS_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/nfs"
INSTALL_FILES[8]="SSH_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/ssh"
INSTALL_FILES[9]="DUMMY_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/dummy"
INSTALL_FILES[10]="EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples"
INSTALL_FILES[11]="TM_EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples/tm"
INSTALL_FILES[12]="HOOK_SHARE_FILES:$SHARE_LOCATION/hooks"
INSTALL_FILES[13]="ECO_LIB_FILES:$LIB_LOCATION/ruby/econe"
INSTALL_FILES[14]="ECO_BIN_FILES:$BIN_LOCATION"
INSTALL_FILES[10]="LVM_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/lvm"
INSTALL_FILES[11]="EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples"
INSTALL_FILES[12]="TM_EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples/tm"
INSTALL_FILES[13]="HOOK_SHARE_FILES:$SHARE_LOCATION/hooks"
INSTALL_FILES[14]="COMMON_CLOUD_LIB_FILES:$LIB_LOCATION/ruby/cloud"
INSTALL_FILES[15]="ECO_LIB_FILES:$LIB_LOCATION/ruby/cloud/econe"
INSTALL_FILES[16]="ECO_LIB_VIEW_FILES:$LIB_LOCATION/ruby/cloud/econe/views"
INSTALL_FILES[17]="ECO_BIN_FILES:$BIN_LOCATION"
INSTALL_FILES[18]="OCCI_LIB_FILES:$LIB_LOCATION/ruby/cloud/occi"
INSTALL_FILES[19]="OCCI_BIN_FILES:$BIN_LOCATION"
INSTALL_ECO_CLIENT_FILES[0]="COMMON_CLOUD_CLIENT_LIB_FILES:$LIB_LOCATION/ruby/cloud"
INSTALL_ECO_CLIENT_FILES[1]="ECO_LIB_CLIENT_FILES:$LIB_LOCATION/ruby/cloud/econe"
INSTALL_ECO_CLIENT_FILES[2]="ECO_BIN_CLIENT_FILES:$BIN_LOCATION"
INSTALL_OCCI_CLIENT_FILES[0]="COMMON_CLOUD_CLIENT_LIB_FILES:$LIB_LOCATION/ruby/cloud"
INSTALL_OCCI_CLIENT_FILES[1]="OCCI_LIB_CLIENT_FILES:$LIB_LOCATION/ruby/cloud/occi"
INSTALL_OCCI_CLIENT_FILES[2]="OCCI_BIN_CLIENT_FILES:$BIN_LOCATION"
INSTALL_ETC_FILES[0]="ETC_FILES:$ETC_LOCATION"
INSTALL_ETC_FILES[1]="VMM_XEN_ETC_FILES:$ETC_LOCATION/vmm_xen"
@ -173,9 +238,12 @@ INSTALL_ETC_FILES[8]="IM_EH_ETC_FILES:$ETC_LOCATION/im_eh"
INSTALL_ETC_FILES[9]="TM_NFS_ETC_FILES:$ETC_LOCATION/tm_nfs"
INSTALL_ETC_FILES[10]="TM_SSH_ETC_FILES:$ETC_LOCATION/tm_ssh"
INSTALL_ETC_FILES[11]="TM_DUMMY_ETC_FILES:$ETC_LOCATION/tm_dummy"
INSTALL_ETC_FILES[12]="HM_ETC_FILES:$ETC_LOCATION/hm"
INSTALL_ETC_FILES[13]="ECO_ETC_FILES:$ETC_LOCATION"
INSTALL_ETC_FILES[14]="ECO_TEMPLATE_FILES:$ETC_LOCATION/ec2query_templates"
INSTALL_ETC_FILES[12]="TM_LVM_ETC_FILES:$ETC_LOCATION/tm_lvm"
INSTALL_ETC_FILES[13]="HM_ETC_FILES:$ETC_LOCATION/hm"
INSTALL_ETC_FILES[14]="ECO_ETC_FILES:$ETC_LOCATION"
INSTALL_ETC_FILES[15]="ECO_ETC_TEMPLATE_FILES:$ETC_LOCATION/ec2query_templates"
INSTALL_ETC_FILES[16]="OCCI_ETC_FILES:$ETC_LOCATION"
INSTALL_ETC_FILES[17]="OCCI_ETC_TEMPLATE_FILES:$ETC_LOCATION/occi_templates"
#-------------------------------------------------------------------------------
# Binary files, to be installed under $BIN_LOCATION
@ -225,12 +293,11 @@ RUBY_OPENNEBULA_LIB_FILES="src/oca/ruby/OpenNebula/Host.rb \
src/oca/ruby/OpenNebula/VirtualNetwork.rb \
src/oca/ruby/OpenNebula/VirtualNetworkPool.rb \
src/oca/ruby/OpenNebula/XMLUtils.rb"
#-------------------------------------------------------------------------------
# Driver executable files, to be installed under $LIB_LOCATION/mads
#-------------------------------------------------------------------------------
MADS_LIB_FILES="share/scripts/madcommon.sh \
MADS_LIB_FILES="src/mad/sh/madcommon.sh \
src/tm_mad/tm_common.sh \
src/vmm_mad/xen/one_vmm_xen.rb \
src/vmm_mad/xen/one_vmm_xen \
@ -266,6 +333,7 @@ IM_PROBES_LIB_FILES="src/im_mad/xen/xen.rb \
# - NFS TM, $LIB_LOCATION/tm_commands/nfs
# - SSH TM, $LIB_LOCATION/tm_commands/ssh
# - dummy TM, $LIB_LOCATION/tm_commands/dummy
# - LVM TM, $LIB_LOCATION/tm_commands/lvm
#-------------------------------------------------------------------------------
NFS_TM_COMMANDS_LIB_FILES="src/tm_mad/nfs/tm_clone.sh \
@ -286,6 +354,14 @@ SSH_TM_COMMANDS_LIB_FILES="src/tm_mad/ssh/tm_clone.sh \
DUMMY_TM_COMMANDS_LIB_FILES="src/tm_mad/dummy/tm_dummy.sh"
LVM_TM_COMMANDS_LIB_FILES="src/tm_mad/lvm/tm_clone.sh \
src/tm_mad/lvm/tm_delete.sh \
src/tm_mad/lvm/tm_ln.sh \
src/tm_mad/lvm/tm_mkswap.sh \
src/tm_mad/lvm/tm_mkimage.sh \
src/tm_mad/lvm/tm_mv.sh \
src/tm_mad/lvm/tm_context.sh"
#-------------------------------------------------------------------------------
# Configuration files for OpenNebula, to be installed under $ETC_LOCATION
#-------------------------------------------------------------------------------
@ -337,6 +413,7 @@ IM_EH_ETC_FILES="src/im_mad/eh/im_ehrc \
# - nfs, $ETC_LOCATION/tm_nfs
# - ssh, $ETC_LOCATION/tm_ssh
# - dummy, $ETC_LOCATION/tm_dummy
# - lvm, $ETC_LOCATION/tm_lvm
#-------------------------------------------------------------------------------
TM_NFS_ETC_FILES="src/tm_mad/nfs/tm_nfs.conf \
@ -348,6 +425,9 @@ TM_SSH_ETC_FILES="src/tm_mad/ssh/tm_ssh.conf \
TM_DUMMY_ETC_FILES="src/tm_mad/dummy/tm_dummy.conf \
src/tm_mad/dummy/tm_dummyrc"
TM_LVM_ETC_FILES="src/tm_mad/lvm/tm_lvm.conf \
src/tm_mad/lvm/tm_lvmrc"
#-------------------------------------------------------------------------------
# Hook Manager driver config. files, to be installed under $ETC_LOCATION/hm
#-------------------------------------------------------------------------------
@ -378,36 +458,93 @@ TM_EXAMPLE_SHARE_FILES="share/examples/tm/tm_clone.sh \
# HOOK scripts, to be installed under $SHARE_LOCATION/hooks
#-------------------------------------------------------------------------------
HOOK_SHARE_FILES="share/hooks/ebtables-xen"
HOOK_SHARE_FILES="share/hooks/ebtables-xen \
share/hooks/ebtables-kvm \
share/hooks/ebtables-flush"
#-------------------------------------------------------------------------------
# OCA files
# Common Cloud Files
#-------------------------------------------------------------------------------
ECO_LIB_FILES="src/cloud/rm/image.rb \
src/cloud/rm/repo_manager.rb \
src/cloud/ec2/OcaConfiguration.rb \
src/cloud/ec2/eco.rb \
src/cloud/ec2/lib/EC2QueryClient.rb"
ECO_BIN_FILES="src/cloud/ec2/econe-server \
src/cloud/ec2/econe-describe-images \
src/cloud/ec2/econe-describe-instances \
src/cloud/ec2/econe-register \
src/cloud/ec2/econe-run-instances \
src/cloud/ec2/econe-terminate-instances \
src/cloud/ec2/econe-upload"
ECO_ETC_FILES="src/cloud/ec2/econe.conf"
ECO_TEMPLATE_FILES="src/cloud/ec2/templates/m1.small.erb"
COMMON_CLOUD_LIB_FILES="src/cloud/common/CloudServer.rb \
src/cloud/common/CloudClient.rb \
src/cloud/common/Configuration.rb \
src/cloud/rm/image.rb \
src/cloud/rm/repo_manager.rb"
COMMON_CLOUD_CLIENT_LIB_FILES="src/cloud/common/CloudClient.rb"
#-------------------------------------------------------------------------------
# EC2 Query for OpenNebula
#-------------------------------------------------------------------------------
ECO_LIB_FILES="src/cloud/ec2/lib/EC2QueryClient.rb \
src/cloud/ec2/lib/EC2QueryServer.rb \
src/cloud/ec2/lib/econe-server.rb"
ECO_LIB_CLIENT_FILES="src/cloud/ec2/lib/EC2QueryClient.rb"
ECO_LIB_VIEW_FILES="src/cloud/ec2/lib/views/describe_images.erb \
src/cloud/ec2/lib/views/describe_instances.erb \
src/cloud/ec2/lib/views/register_image.erb \
src/cloud/ec2/lib/views/run_instances.erb \
src/cloud/ec2/lib/views/terminate_instances.erb"
ECO_BIN_FILES="src/cloud/ec2/bin/econe-server \
src/cloud/ec2/bin/econe-describe-images \
src/cloud/ec2/bin/econe-describe-instances \
src/cloud/ec2/bin/econe-register \
src/cloud/ec2/bin/econe-run-instances \
src/cloud/ec2/bin/econe-terminate-instances \
src/cloud/ec2/bin/econe-upload"
ECO_BIN_CLIENT_FILES="src/cloud/ec2/bin/econe-describe-images \
src/cloud/ec2/bin/econe-describe-instances \
src/cloud/ec2/bin/econe-register \
src/cloud/ec2/bin/econe-run-instances \
src/cloud/ec2/bin/econe-terminate-instances \
src/cloud/ec2/bin/econe-upload"
ECO_ETC_FILES="src/cloud/ec2/etc/econe.conf"
ECO_ETC_TEMPLATE_FILES="src/cloud/ec2/etc/templates/m1.small.erb"
#-----------------------------------------------------------------------------
# OCCI files
#-----------------------------------------------------------------------------
OCCI_LIB_FILES="src/cloud/occi/lib/OCCIServer.rb \
src/cloud/occi/lib/occi-server.rb \
src/cloud/occi/lib/OCCIClient.rb \
src/cloud/occi/lib/VirtualMachineOCCI.rb \
src/cloud/occi/lib/VirtualMachinePoolOCCI.rb \
src/cloud/occi/lib/VirtualNetworkOCCI.rb \
src/cloud/occi/lib/VirtualNetworkPoolOCCI.rb \
src/cloud/occi/lib/ImageOCCI.rb \
src/cloud/occi/lib/ImagePoolOCCI.rb"
OCCI_LIB_CLIENT_FILES="src/cloud/occi/lib/OCCIClient.rb"
OCCI_BIN_FILES="src/cloud/occi/bin/occi-server \
src/cloud/occi/bin/occi-compute \
src/cloud/occi/bin/occi-network \
src/cloud/occi/bin/occi-storage"
OCCI_BIN_CLIENT_FILES="src/cloud/occi/bin/occi-compute \
src/cloud/occi/bin/occi-network \
src/cloud/occi/bin/occi-storage"
OCCI_ETC_FILES="src/cloud/occi/etc/occi-server.conf"
OCCI_ETC_TEMPLATE_FILES="src/cloud/occi/etc/templates/small.erb \
src/cloud/occi/etc/templates/medium.erb \
src/cloud/occi/etc/templates/large.erb"
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# INSTALL.SH SCRIPT
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# --- Create OpenNebula directories ---
@ -423,11 +560,24 @@ do_file() {
if [ "$UNINSTALL" = "yes" ]; then
rm $2/`basename $1`
else
cp $SRC_DIR/$1 $DESTDIR$2
if [ "$LINK" = "yes" ]; then
ln -s $SRC_DIR/$1 $DESTDIR$2
else
cp $SRC_DIR/$1 $DESTDIR$2
fi
fi
}
for i in ${INSTALL_FILES[@]}; do
if [ "$CLIENT" = "no" ]; then
INSTALL_SET=${INSTALL_FILES[@]}
elif [ "$CLIENT" = "occi" ]; then
INSTALL_SET=${INSTALL_OCCI_CLIENT_FILES[@]}
elif [ "$CLIENT" = "ec2" ]; then
INSTALL_SET=${INSTALL_ECO_CLIENT_FILES[@]}
fi
for i in ${INSTALL_SET[@]}; do
SRC=$`echo $i | cut -d: -f1`
DST=`echo $i | cut -d: -f2`
@ -438,16 +588,21 @@ for i in ${INSTALL_FILES[@]}; do
done
done
if [ "$INSTALL_ETC" = "yes" ] ; then
if [ "$CLIENT" = "no" -a "$INSTALL_ETC" = "yes" ] ; then
for i in ${INSTALL_ETC_FILES[@]}; do
SRC=$`echo $i | cut -d: -f1`
DST=`echo $i | cut -d: -f2`
eval SRC_FILES=$SRC
eval SRC_FILES=$SRC
OLD_LINK=$LINK
LINK="no"
for f in $SRC_FILES; do
do_file $f $DST
done
LINK=$OLD_LINK
done
fi
@ -455,13 +610,15 @@ fi
if [ "$UNINSTALL" = "no" ] ; then
for d in $CHOWN_DIRS; do
/bin/chown -R $ONEADMIN_USER:$ONEADMIN_GROUP $DESTDIR$d
chown -R $ONEADMIN_USER:$ONEADMIN_GROUP $DESTDIR$d
done
# Create library links
ln -s $DESTDIR$LIB_LOCATION/liboneapi.so \
$DESTDIR$LIB_LOCATION/liboneapi.so.1
ln -s $DESTDIR$LIB_LOCATION/liboneapi.so.1 \
$DESTDIR$LIB_LOCATION/liboneapi.so.1.2
if [ "$CLIENT" = "no" ] ; then
ln -s $DESTDIR$LIB_LOCATION/liboneapi.so \
$DESTDIR$LIB_LOCATION/liboneapi.so.1
ln -s $DESTDIR$LIB_LOCATION/liboneapi.so.1 \
$DESTDIR$LIB_LOCATION/liboneapi.so.1.4
fi
else
for d in `echo $DELETE_DIRS | awk '{for (i=NF;i>=1;i--) printf $i" "}'`; do
rmdir $d

View File

@ -1,6 +1,5 @@
# -------------------------------------------------------------------------- #
# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
# Complutense de Madrid (dsa-research.org) #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #

View File

@ -171,6 +171,15 @@ TM_MAD = [
# arguments = "tm_dummy/tm_dummy.conf" ]
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# LVM Transfer Manager Driver sample configuration
#-------------------------------------------------------------------------------
#TM_MAD = [
# name = "tm_lvm",
# executable = "one_tm",
# arguments = "tm_lvm/tm_lvm.conf" ]
#-------------------------------------------------------------------------------
#*******************************************************************************
# Hook Manager Configuration
#*******************************************************************************
@ -190,9 +199,10 @@ TM_MAD = [
# - RUNNING, after the VM is successfully booted
# - SHUTDOWN, after the VM is shutdown
# - STOP, after the VM is stopped (including VM image transfers)
# - DONE, after the VM is deleted or shutdown
# command : use absolute path here
# arguments : for the hook. You can access to VM template variables with $
# - $ATTR, the value of an attribute e.g. $NAME or $VM_ID
# - $ATTR, the value of an attribute e.g. $NAME or $VMID
# - $ATTR[VAR], the value of a vector e.g. $NIC[MAC]
# - $ATTR[VAR, COND], same of previous but COND select between
# multiple ATTRs e.g. $NIC[MAC, NETWORK="Public"]
@ -210,7 +220,7 @@ HM_MAD = [
# name = "dhcp",
# on = "create",
# command = "/bin/echo",
# arguments = "$NAME > /tmp/test.$VM_ID" ]
# arguments = "$NAME > /tmp/test.$VMID" ]
#-------------------------------------------------------------------------------
#VM_HOOK = [
# name = "ebtables",
@ -223,6 +233,6 @@ HM_MAD = [
# name = "mail",
# on = "running",
# command = "/usr/local/one/bin/send_mail",
# arguments = "$VM_ID $NAME",
# arguments = "$VMID $NAME",
# remote = "no" ]
#------------------------------------------------------------------------------

View File

@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
# Complutense de Madrid (dsa-research.org) #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #

View File

@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
# Complutense de Madrid (dsa-research.org) #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #

View File

@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
# Complutense de Madrid (dsa-research.org) #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #

View File

@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
# Complutense de Madrid (dsa-research.org) #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #

View File

@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
# Complutense de Madrid (dsa-research.org) #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #

View File

@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
# Complutense de Madrid (dsa-research.org) #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #

65
share/hooks/ebtables-flush Executable file
View File

@ -0,0 +1,65 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
def deactivate(rule)
system "sudo ebtables -D #{rule}"
end
def get_interfaces
brctl_exit=`brctl show`
brctl_exit.split("\n")[1..-1].collect{|l| l.split.last }
end
RULE_TYPES=[
/-i ([\w\.\-]+) /,
/-o ([\w\.\-]+) /
]
def get_rules
rules=Array.new
RULE_TYPES.each do |reg|
ebtables_exit=`sudo ebtables -L FORWARD`
rules << ebtables_exit.split("\n")[3..-1].collect do |l|
line=l.strip
m=line.match(reg)
if m
interface=m[1]
{
:interface => interface,
:rule => line
}
else
nil
end
end.compact
end
rules.flatten
end
# if executed on "done", we must wait a bit until the tap is detached from the bridge
sleep 1
interfaces=get_interfaces
all_rules=get_rules
all_rules.each do |rule|
if !interfaces.include?(rule[:interface])
deactivate("FORWARD #{rule[:rule]}")
end
end

80
share/hooks/ebtables-kvm Executable file
View File

@ -0,0 +1,80 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
require 'pp'
require 'rexml/document'
VM_NAME=ARGV[0]
# Uncomment to act only on the listed bridges.
#FILTERED_BRIDGES = ['beth0']
def activate(rule)
system "sudo ebtables -A #{rule}"
end
def get_bridges
bridges = Hash.new
brctl_exit=`brctl show`
cur_bridge = ""
brctl_exit.split("\n")[1..-1].each do |l|
l = l.split
if l.length > 1
cur_bridge = l[0]
bridges[cur_bridge] = Array.new
bridges[cur_bridge] << l[3]
else
bridges[cur_bridge] << l[0]
end
end
bridges
end
def get_interfaces
bridges = get_bridges
if defined? FILTERED_BRIDGES
FILTERED_BRIDGES.collect {|k,v| bridges[k]}.flatten
else
bridges.values.flatten
end
end
nets=`virsh -c qemu:///system dumpxml #{VM_NAME}`
doc=REXML::Document.new(nets).root
interfaces = get_interfaces()
doc.elements.each('/domain/devices/interface') {|net|
tap=net.elements['target'].attributes['dev']
if interfaces.include? tap
iface_mac=net.elements['mac'].attributes['address']
mac=iface_mac.split(':')
mac[-1]='00'
net_mac=mac.join(':')
in_rule="FORWARD -s ! #{net_mac}/ff:ff:ff:ff:ff:00 -o #{tap} -j DROP"
out_rule="FORWARD -s ! #{iface_mac} -i #{tap} -j DROP"
activate(in_rule)
activate(out_rule)
end
}

View File

@ -1,42 +1,79 @@
#!/usr/bin/env ruby
COMMAND=ARGV[0]
VM_NAME=ARGV[1]
# -------------------------------------------------------------------------- #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
VM_NAME=ARGV[0]
# Uncomment to act only on the listed bridges.
#FILTERED_BRIDGES = ['beth0']
def activate(rule)
system "sudo ebtables -A #{rule}"
end
def deactivate(rule)
system "sudo ebtables -D #{rule}"
def get_bridges
bridges = Hash.new
brctl_exit=`brctl show`
cur_bridge = ""
brctl_exit.split("\n")[1..-1].each do |l|
l = l.split
if l.length > 1
cur_bridge = l[0]
bridges[cur_bridge] = Array.new
bridges[cur_bridge] << l[3]
else
bridges[cur_bridge] << l[0]
end
end
bridges
end
def get_interfaces
bridges = get_bridges
if defined? FILTERED_BRIDGES
FILTERED_BRIDGES.collect {|k,v| bridges[k]}.flatten
else
bridges.values.flatten
end
end
vm_id=`sudo xm domid #{VM_NAME}`.strip
networks=`sudo xm network-list #{vm_id}`.split("\n")[1..-1]
interfaces = get_interfaces
networks.each {|net|
n=net.split
iface_id=n[0]
iface_mac=n[2]
mac=iface_mac.split(':')
mac[-1]='00'
net_mac=mac.join(':')
tap="vif#{vm_id}.#{iface_id}"
in_rule="INPUT -d ! #{iface_mac}/FF:FF:FF:FF:FF:FF -i #{tap} -j DROP"
out_rule="OUTPUT -s ! #{net_mac}/FF:FF:FF:FF:FF:00 -o #{tap} -j DROP"
case COMMAND
when "start"
if interfaces.include? tap
mac=iface_mac.split(':')
mac[-1]='00'
net_mac=mac.join(':')
in_rule="FORWARD -s ! #{net_mac}/ff:ff:ff:ff:ff:00 -o #{tap} -j DROP"
out_rule="FORWARD -s ! #{iface_mac} -i #{tap} -j DROP"
activate(in_rule)
activate(out_rule)
when "stop"
deactivate(in_rule)
deactivate(out_rule)
else
puts "First parameter should be start or stop"
end
}

View File

@ -1,8 +1,7 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
# Complutense de Madrid (dsa-research.org) #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #

View File

@ -1,6 +1,5 @@
# -------------------------------------------------------------------------- #
# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
# Complutense de Madrid (dsa-research.org) #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #

View File

@ -1,6 +1,5 @@
# -------------------------------------------------------------------------- #
# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
# Complutense de Madrid (dsa-research.org) #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #

View File

@ -0,0 +1,130 @@
_one_list() {
local cmd filter
one_cmd=$1
if [ -n "$2" ]; then
filter="-f $2"
fi
echo $($one_cmd $filter list|sed 1d|awk '{print $1}')
return 0
}
_onevm() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create deploy shutdown livemigrate migrate hold release stop cancel suspend resume delete restart list show top history"
cmd=onevm
if [ $COMP_CWORD == 1 ]
then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
elif [ $COMP_CWORD == 2 ]
then
case "$prev" in
show|delete)
vms=`_one_list $cmd`
COMPREPLY=( $(compgen -W "${vms}" -- ${cur}) )
return 0
;;
cancel|shutdown|suspend|stop)
vms=`_one_list $cmd stat='runn'`
COMPREPLY=( $(compgen -W "${vms}" -- ${cur}) )
return 0
;;
create|submit)
COMPREPLY=( $(compgen -A file -- ${cur}) )
return 0
;;
migrate)
vms=`_one_list $cmd stat='runn'`
COMPREPLY=( $(compgen -W "${vms}" -- ${cur}) )
return 0
;;
esac
elif [ $COMP_CWORD == 3 ]
then
case "$pprev" in
migrate)
hosts=`onehost list -f STAT=on|sed 1d|awk '{print $2}'`
COMPREPLY=( $(compgen -W "${hosts}" -- ${cur}) )
return 0
;;
esac
fi
}
complete -F _onevm onevm
_onevnet() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="create delete list show"
cmd=onevnet
if [ $COMP_CWORD == 1 ]
then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
elif [ $COMP_CWORD == 2 ]
then
case "$prev" in
create|submit)
COMPREPLY=( $(compgen -A file -- ${cur}) )
return 0
;;
delete|show)
vnets=`_one_list $cmd`
COMPREPLY=( $(compgen -W "${vnets}" -- ${cur}) )
return 0
;;
esac
fi
}
complete -F _onevnet onevnet
_onehost() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="create show delete list enable disable top"
cmd=onehost
if [ $COMP_CWORD == 1 ]
then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
elif [ $COMP_CWORD == 2 ]
then
case "$prev" in
create|submit)
COMPREPLY=( $(compgen -A file -- ${cur}) )
return 0
;;
delete|show)
hosts=`_one_list $cmd`
COMPREPLY=( $(compgen -W "${hosts}" -- ${cur}) )
return 0
;;
enable)
hosts=`_one_list $cmd stat='off'`
COMPREPLY=( $(compgen -W "${hosts}" -- ${cur}) )
return 0
;;
disable)
hosts=`_one_list $cmd stat='on'`
COMPREPLY=( $(compgen -W "${hosts}" -- ${cur}) )
return 0
;;
esac
fi
}
complete -F _onehost onehost

View File

@ -0,0 +1,22 @@
NAME = Centos5
CPU = 0.5
MEMORY = 400
DISK = [
source = "/home/srv/cloud/images/centos-5.img",
target = "hda",
readonly = "no" ]
NIC = [ NETWORK = "Red Virtual" ]
FEATURES=[ acpi="no" ]
RAW = [ type = "kvm", data = " <serial type='pty'> <source path='/dev/pts/3'/> <target port='1'/> </serial>" ]
CONTEXT = [
hostname = "$NAME",
#ip_public = "$NIC[IP, NETWORK=\"Red Virtual\"]",
ip_public = "192.168.0.5",
files = "/home/oneadmin/one-templates/centos-5/init.sh /home/oneadmin/one-templates/centos-5/id_dsa.pub",
target = "hdc",
root_pubkey = "id_dsa.pub",
username = "oneadmin",
user_pubkey = "id_dsa.pub"
]

View File

@ -0,0 +1,51 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
if [ -f /mnt/context.sh ]
then
. /mnt/context.sh
fi
hostname $HOSTNAME
sed -i "/HOSTNAME=/s/=.*$/=$HOSTNAME/" /etc/sysconfig/network
if [ -n "$IP_PUBLIC" ]; then
ifconfig eth0 $IP_PUBLIC
fi
if [ -n "$NETMASK" ]; then
ifconfig eth0 netmask $NETMASK
fi
if [ -f /mnt/$ROOT_PUBKEY ]; then
mkdir -p /root/.ssh
cat /mnt/$ROOT_PUBKEY >> /root/.ssh/authorized_keys
chmod -R 600 /root/.ssh/
fi
if [ -n "$USERNAME" ]; then
useradd $USERNAME
if [ -f /mnt/$USER_PUBKEY ]; then
mkdir -p /home/$USERNAME/.ssh/
cat /mnt/$USER_PUBKEY >> /home/$USERNAME/.ssh/authorized_keys
chown -R $USERNAME:$USERNAME /home/$USERNAME/.ssh
chmod -R 600 /home/$USERNAME/.ssh/authorized_keys
fi
fi

View File

@ -0,0 +1,115 @@
#!/bin/bash
#
# chkconfig: 2345 10 90
# description: network reconfigure
#
# -------------------------------------------------------------------------- #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
# 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() {
IP=$1
echo $IP | cut -d'.' -f1,2,3
}
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
}
gen_hosts() {
NETWORK=$1
echo "127.0.0.1 localhost"
for n in `seq -w 01 99`; do
n2=`echo $n | sed 's/^0*//'`
echo ${NETWORK}.$n2 cluster${n}
done
}
gen_exports() {
NETWORK=$1
echo "/images ${NETWORK}.0/255.255.255.0(rw,async,no_subtree_check)"
}
gen_hostname() {
MAC=$1
NUM=`mac2ip $MAC | cut -d'.' -f4`
NUM2=`echo 000000$NUM | sed 's/.*\(..\)/\1/'`
echo cluster$NUM2
}
gen_interface() {
DEV_MAC=$1
DEV=`get_dev $DEV_MAC`
MAC=`get_mac $DEV_MAC`
IP=`mac2ip $MAC`
NETWORK=`get_network $IP`
cat <<EOT
DEVICE=$DEV
BOOTPROTO=none
HWADDR=$MAC
ONBOOT=yes
TYPE=Ethernet
NETMASK=255.255.255.0
IPADDR=$IP
EOT
if [ $DEV == "eth0" ]; then
echo " GATEWAY=$NETWORK.1"
fi
echo ""
}
IFACES=`get_interfaces`
for i in $IFACES; do
DEV=`get_dev $i`
gen_interface $i > /etc/sysconfig/network-scripts/ifcfg-${DEV}
done
# gen_hosts $NETWORK > /etc/hosts
# gen_exports $NETWORK > /etc/exports
# gen_hostname $MAC > /etc/hostname
#ifdown $DEV
#ifup $DEV

View File

@ -1,8 +1,7 @@
#! /bin/sh
# -------------------------------------------------------------------------- #
# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
# Complutense de Madrid (dsa-research.org) #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@ -26,7 +25,7 @@ if [ -z "$ONE_LOCATION" ]; then
ONED=/usr/bin/oned
ONE_SCHEDULER=/usr/bin/mm_sched
LOCK_FILE=/var/lock/one
LOCK_FILE=/var/lock/one/one
else
ONE_PID=$ONE_LOCATION/var/oned.pid
ONE_SCHEDPID=$ONE_LOCATION/var/sched.pid
@ -83,11 +82,13 @@ start()
fi
if [ ! -f "$ONE_DB" ]; then
if [ -z "$ONE_AUTH" ]; then
echo "You should have ONE_AUTH set the first time you start"
echo "OpenNebula as it is used to set the credentials for"
echo "the adminitrator user."
exit 1
if [ ! -f "$HOME/.one/one_auth" ]; then
if [ -z "$ONE_AUTH" ]; then
echo "You should have ONE_AUTH set the first time you start"
echo "OpenNebula as it is used to set the credentials for"
echo "the adminitrator user."
exit 1
fi
fi
fi

View File

@ -0,0 +1,52 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
if [ -f /mnt/context.sh ]
then
. /mnt/context.sh
fi
hostname $HOSTNAME
sed -i "s/openSUSE/$HOSTNAME/g" /etc/hosts
echo $HOSTNAME > /etc/HOSTNAME
if [ -n "$IP_PUBLIC" ]; then
ifconfig eth0 $IP_PUBLIC
fi
if [ -n "$NETMASK" ]; then
ifconfig eth0 netmask $NETMASK
fi
if [ -f /mnt/$ROOT_PUBKEY ]; then
mkdir -p /root/.ssh
cat /mnt/$ROOT_PUBKEY >> /root/.ssh/authorized_keys
chmod -R 600 /root/.ssh/
fi
if [ -n "$USERNAME" ]; then
useradd -m $USERNAME
if [ -f /mnt/$USER_PUBKEY ]; then
mkdir -p /home/$USERNAME/.ssh/
cat /mnt/$USER_PUBKEY >> /home/$USERNAME/.ssh/authorized_keys
chown -R $USERNAME:users /home/$USERNAME/.ssh
chmod -R 600 /home/$USERNAME/.ssh/authorized_keys
fi
fi

View File

@ -0,0 +1,19 @@
NAME = opensuse11
CPU = 0.5
MEMORY = 400
DISK = [
source = "/home/srv/cloud/images/openSUSE-11.1-v2.img",
target = "hda",
readonly = "no" ]
NIC = [ NETWORK = "Red Virtual" ]
CONTEXT = [
hostname = "$NAME",
ip_public = "192.168.0.5",
files = "/home/oneadmin/one-templates/openSUSE/init.sh /home/oneadmin/one-templates/openSUSE/id_dsa.pub",
target = "hdc",
root_pubkey = "id_dsa.pub",
username = "oneadmin",
user_pubkey = "id_dsa.pub"
]

View File

@ -0,0 +1,123 @@
#!/bin/bash
#
# chkconfig: 2345 10 90
# description: network reconfigure
#
# -------------------------------------------------------------------------- #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
# 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() {
IP=$1
echo $IP | cut -d'.' -f1,2,3
}
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
}
gen_hosts() {
NETWORK=$1
echo "127.0.0.1 localhost"
for n in `seq -w 01 99`; do
n2=`echo $n | sed 's/^0*//'`
echo ${NETWORK}.$n2 cluster${n}
done
}
gen_exports() {
NETWORK=$1
echo "/images ${NETWORK}.0/255.255.255.0(rw,async,no_subtree_check)"
}
gen_hostname() {
MAC=$1
NUM=`mac2ip $MAC | cut -d'.' -f4`
NUM2=`echo 000000$NUM | sed 's/.*\(..\)/\1/'`
echo cluster$NUM2
}
gen_interface() {
DEV_MAC=$1
DEV=`get_dev $DEV_MAC`
MAC=`get_mac $DEV_MAC`
IP=`mac2ip $MAC`
NETWORK=`get_network $IP`
cat <<EOT
BOOTPROTO='static'
BROADCAST=''
ETHTOOL_OPTIONS=''
IFPLUGD_PRIORITY='20'
IPADDR='$IP/24'
MTU=''
NAME='79c970 [PCnet32 LANCE]'
NETMASK=''
NETWORK=''
REMOTE_IPADDR=''
STARTMODE='ifplugd'
USERCONTROL='no'
EOT
echo ""
}
IFACES=`get_interfaces`
for i in $IFACES; do
DEV=`get_dev $i`
gen_interface $i > /etc/sysconfig/network/ifcfg-${DEV}
if [ $DEV == "eth0" ]; then
MAC=`get_mac $DEV_MAC`
IP=`mac2ip $MAC`
NETWORK=`get_network $IP`
echo "default $NETWORK.1" > /etc/sysconfig/network/routes
fi
done
# gen_hosts $NETWORK > /etc/hosts
# gen_exports $NETWORK > /etc/exports
# gen_hostname $MAC > /etc/hostname
#ifdown $DEV
#ifup $DEV

View File

@ -0,0 +1,49 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
if [ -f /mnt/context/context.sh ]
then
. /mnt/context/context.sh
fi
echo $HOSTNAME > /etc/HOSTNAME
hostname $HOSTNAME
if [ -n "$IP_PUBLIC" ]; then
ifconfig eth0 $IP_PUBLIC
fi
if [ -n "$NETMASK" ]; then
ifconfig eth0 netmask $NETMASK
fi
if [ -f /mnt/context/$ROOT_PUBKEY ]; then
cat /mnt/context/$ROOT_PUBKEY >> /root/.ssh/authorized_keys
fi
if [ -n "$USERNAME" ]; then
adduser -s /bin/bash -D $USERNAME
if [ -f /mnt/context/$USER_PUBKEY ]; then
mkdir -p /home/$USERNAME/.ssh/
cat /mnt/context/$USER_PUBKEY >> /home/$USERNAME/.ssh/authorized_keys
chown -R $USERNAME /home/$USERNAME/.ssh
chmod -R 600 /home/$USERNAME/.ssh
fi
fi

View File

@ -0,0 +1,22 @@
NAME = myttyserver
CPU = 0.1
MEMORY = 64
DISK = [
source = "/home/srv/cloud/images/ttylinux.0.4.img",
target = "hda",
readonly = "no" ]
NIC = [ NETWORK = "Red Virtual" ]
FEATURES=[ acpi="no" ]
RAW = [ type = "kvm", data = " <serial type='pty'> <source path='/dev/pts/3'/> <target port='1'/> </serial>" ]
# Context example
CONTEXT = [
hostname = "$NAME",
ip_public = "$NIC[IP, NETWORK=\"Red Virtual\"]",
files = "/home/oneadmin/one-templates/ttylinux/init.sh /home/oneadmin/one-templates/ttylinux/id_dsa.pub",
target = "hdc",
root_pubkey = "id_dsa.pub",
username = "oneadmin",
user_pubkey = "id_dsa.pub"
]

View File

@ -0,0 +1,119 @@
#!/bin/bash
#
# chkconfig: 2345 10 90
# description: network reconfigure
#
# -------------------------------------------------------------------------- #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
# 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() {
IP=$1
echo $IP | cut -d'.' -f1-3
}
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
}
gen_hosts() {
NETWORK=$1
echo "127.0.0.1 localhost"
for n in `seq -w 01 99`; do
n2=`echo $n | sed 's/^0*//'`
echo ${NETWORK}.$n2 cluster${n}
done
}
gen_exports() {
NETWORK=$1
echo "/images ${NETWORK}.0/255.255.255.0(rw,async,no_subtree_check)"
}
gen_hostname() {
MAC=$1
NUM=`mac2ip $MAC | cut -d'.' -f4`
NUM2=`echo 000000$NUM | sed 's/.*\(..\)/\1/'`
echo cluster$NUM2
}
gen_interface() {
DEV_MAC=$1
DEV=`get_dev $DEV_MAC`
MAC=`get_mac $DEV_MAC`
IP=`mac2ip $MAC`
NETWORK=`get_network $IP`
cat <<EOT
ENABLE=yes
NAME=Ethernet
IPADDRESS=$IP
CIDRLEN=24
NETWORK=$NETWORK.0
NETMASK=255.255.255.0
BROADCAST=$NETWORK.255
DHCP=no
EOT
if [ $DEV == "eth0" ]; then
echo " GATEWAY=$NETWORK.1"
fi
echo ""
}
IFACES=`get_interfaces`
for i in $IFACES; do
DEV=`get_dev $i`
gen_interface $i > /etc/sysconfig/network-scripts/ifcfg-${DEV}
done
# gen_hosts $NETWORK > /etc/hosts
# gen_exports $NETWORK > /etc/exports
# gen_hostname $MAC > /etc/hostname
#ifdown $DEV
#ifup $DEV
# /bin/hostname `cat /etc/hostname`

View File

@ -0,0 +1,52 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
if [ -f /mnt/context.sh ]
then
. /mnt/context.sh
fi
echo $HOSTNAME > /etc/hostname
hostname $HOSTNAME
sed -i "/127.0.1.1/s/ubuntu/$HOSTNAME/" /etc/hosts
if [ -n "$IP_PUBLIC" ]; then
ifconfig eth0 $IP_PUBLIC
fi
if [ -n "$NETMASK" ]; then
ifconfig eth0 netmask $NETMASK
fi
if [ -f /mnt/$ROOT_PUBKEY ]; then
mkdir -p /root/.ssh
cat /mnt/$ROOT_PUBKEY >> /root/.ssh/authorized_keys
chmod -R 600 /root/.ssh/
fi
if [ -n "$USERNAME" ]; then
useradd -s /bin/bash -m $USERNAME
if [ -f /mnt/$USER_PUBKEY ]; then
mkdir -p /home/$USERNAME/.ssh/
cat /mnt/$USER_PUBKEY >> /home/$USERNAME/.ssh/authorized_keys
chown -R $USERNAME:$USERNAME /home/$USERNAME/.ssh
chmod -R 600 /home/$USERNAME/.ssh/authorized_keys
fi
fi

View File

@ -0,0 +1,23 @@
NAME = myUbuntu
CPU = 0.5
MEMORY = 400
DISK = [
source = "/home/srv/cloud/images/ubuntu-server-9.04.img",
target = "sda",
readonly = "no" ]
NIC = [ NETWORK = "Red Virtual" ]
FEATURES=[ acpi="no" ]
RAW = [ type = "kvm", data = " <serial type='pty'> <source path='/dev/pts/3'/> <target port='1'/> </serial>" ]
CONTEXT = [
hostname = "$NAME",
#ip_public = "$NIC[IP, NETWORK=\"Red Virtual\"]",
ip_public = "192.168.0.4",
files = "/home/oneadmin/one-templates/ubuntu/init.sh /home/oneadmin/one-templates/ubuntu/id_dsa.pub",
target = "sdb", # This distribution's udev assigns block device symlinks sequentally. If you only define two drives
# the second will be sdb.
root_pubkey = "id_dsa.pub",
username = "oneadmin",
user_pubkey = "id_dsa.pub"
]

View File

@ -0,0 +1,126 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
# 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() {
IP=$1
echo $IP | cut -d'.' -f1,2,3
}
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
}
gen_hosts() {
NETWORK=$1
echo "127.0.0.1 localhost"
for n in `seq -w 01 99`; do
n2=`echo $n | sed 's/^0*//'`
echo ${NETWORK}.$n2 cluster${n}
done
}
gen_exports() {
NETWORK=$1
echo "/images ${NETWORK}.0/255.255.255.0(rw,async,no_subtree_check)"
}
gen_hostname() {
MAC=$1
NUM=`mac2ip $MAC | cut -d'.' -f4`
NUM2=`echo 000000$NUM | sed 's/.*\(..\)/\1/'`
echo cluster$NUM2
}
gen_interface() {
DEV_MAC=$1
DEV=`get_dev $DEV_MAC`
MAC=`get_mac $DEV_MAC`
IP=`mac2ip $MAC`
NETWORK=`get_network $IP`
cat <<EOT
auto $DEV
iface $DEV inet static
address $IP
network $NETWORK.0
netmask 255.255.255.0
EOT
if [ $DEV == "eth0" ]; then
echo " gateway $NETWORK.1"
fi
echo ""
}
IFACES=`get_interfaces`
for i in $IFACES; do
MASTER_DEV_MAC=$i
DEV=`get_dev $i`
MAC=`get_mac $i`
IP=`mac2ip $MAC`
NETWORK=`get_network $IP`
done
# gen_hosts $NETWORK > /etc/hosts
# gen_exports $NETWORK > /etc/exports
# gen_hostname $MAC > /etc/hostname
(
cat <<EOT
auto lo
iface lo inet loopback
EOT
for i in $IFACES; do
gen_interface $i
done
) > /etc/network/interfaces
# /bin/hostname `cat /etc/hostname`

View File

@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
# Complutense de Madrid (dsa-research.org) #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #

Binary file not shown.

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2008, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,8 +1,7 @@
#!/bin/bash
# --------------------------------------------------------------------------
# Copyright 2002-2006 GridWay Team, Distributed Systems Architecture
# Group, Universidad Complutense de Madrid
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org)
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
/* Complutense de Madrid (dsa-research.org) */
/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */

View File

@ -1,8 +1,7 @@
# SConstruct for src/mad
# -------------------------------------------------------------------------- #
# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
# Complutense de Madrid (dsa-research.org) #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #

View File

@ -1,6 +1,5 @@
# -------------------------------------------------------------------------- #
# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
# Complutense de Madrid (dsa-research.org) #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@ -217,10 +216,6 @@ end
################
def get_one_client(session=nil)
if !ENV["ONE_AUTH"] or ENV["ONE_AUTH"].empty? or !ENV["ONE_AUTH"].match(".+:.+")
puts "$ONE_AUTH not defined or malformed"
exit -1
end
OpenNebula::Client.new(session)
end
@ -301,3 +296,45 @@ def str_running_time(data)
"%02d %02d:%02d:%02d" % [dtime.yday-1, dtime.hour, dtime.min, dtime.sec]
end
REG_RANGE=/(.*)\[(\d+)([+-])(\d+)\](.*)/
def expand_range(param)
if match=param.match(REG_RANGE)
pre=match[1]
start=match[2]
operator=match[3]
last=match[4]
post=match[5]
size=0
result=Array.new
if operator=='-'
range=(start.to_i..last.to_i)
size=last.size
elsif operator=='+'
size=(start.to_i+last.to_i-1).to_s.size
range=(start.to_i..(start.to_i+last.to_i-1))
end
if start[0]==?0
range.each do |num|
result<<sprintf("%s%0#{size}d%s", pre, num, post)
end
else
range.each do |num|
result<<sprintf("%s%d%s", pre, num, post)
end
end
result
else
param
end
end
def expand_args(args)
args.collect {|arg| expand_range(arg) }.flatten
end

View File

@ -1,6 +1,5 @@
# -------------------------------------------------------------------------- #
# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
# Complutense de Madrid (dsa-research.org) #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@ -33,10 +32,8 @@ Options:
EOT
ONE_VERSION=<<-EOT
OpenNebula 1.3.0
Copyright 2002-2008, Distributed Systems Architecture Group, Universidad
Complutense de Madrid (dsa-research.org)
OpenNebula 1.5.0
Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org)
EOT
def initialize

View File

@ -1,8 +1,7 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
# Complutense de Madrid (dsa-research.org) #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@ -34,8 +33,8 @@ require 'client_utilities'
require 'command_parse'
ShowTableHost={
:hid => {
:name => "HID",
:id => {
:name => "ID",
:desc => "ONE identifier for host",
:size => 4,
:proc => lambda {|d,e| d.id }
@ -99,7 +98,7 @@ ShowTableHost={
},
:default => [:hid, :name, :rvm, :tcpu, :fcpu, :acpu, :tmem, :fmem, :stat]
:default => [:id, :name, :rvm, :tcpu, :fcpu, :acpu, :tmem, :fmem, :stat]
}
class HostShow
@ -210,7 +209,7 @@ def vms_in_host?(host_id)
exit -1
end
host['host_shares/running_vms'].to_i
host['host_share/running_vms'].to_i
end
@ -236,6 +235,8 @@ when "add", "create"
when "show"
check_parameters("show", 1)
#args=expand_args(ARGV)
host_id=get_host_id(ARGV[0])
host=OpenNebula::Host.new_with_id(host_id, get_one_client)
@ -282,29 +283,34 @@ when "show"
when "delete"
check_parameters("delete", 1)
host_id=get_host_id(ARGV[0])
host = OpenNebula::Host.new_with_id(host_id,get_one_client)
args=expand_args(ARGV)
rc = host.info
args.each do |param|
host_id=get_host_id(param)
host = OpenNebula::Host.new_with_id(host_id,get_one_client)
if OpenNebula::is_error?(rc)
puts rc.message
exit -1
end
rc = host.info
if host['host_shares/running_vms'].to_i != 0
puts "Host still has associated VMs. It will be disabled instead."
result=host.disable
if is_successful?(result)
puts "Host disabled" if ops[:verbose]
exit 0
if OpenNebula::is_error?(rc)
puts rc.message
exit -1
end
else
result=host.delete
if is_successful?(result)
puts "Host deleted" if ops[:verbose]
exit 0
if host['host_share/running_vms'].to_i != 0
puts "Host still has associated VMs. It will be disabled instead."
result=host.disable
if is_successful?(result)
puts "Host disabled" if ops[:verbose]
else
break
end
else
result=host.delete
if is_successful?(result)
puts "Host deleted" if ops[:verbose]
exit 0
end
end
end
@ -326,22 +332,32 @@ when "top"
when "enable"
check_parameters("enable", 1)
host_id=get_host_id(ARGV[0])
host = OpenNebula::Host.new_with_id(host_id,get_one_client)
result=host.enable
if is_successful?(result)
puts "Host enabled" if ops[:verbose]
exit 0
args=expand_args(ARGV)
args.each do |param|
host_id=get_host_id(param)
host = OpenNebula::Host.new_with_id(host_id,get_one_client)
result=host.enable
if is_successful?(result)
puts "Host enabled" if ops[:verbose]
else
break
end
end
when "disable"
check_parameters("disable", 1)
host_id=get_host_id(ARGV[0])
host = OpenNebula::Host.new_with_id(host_id,get_one_client)
result=host.disable
if is_successful?(result)
puts "Host disabled" if ops[:verbose]
exit 0
args=expand_args(ARGV)
args.each do |param|
host_id=get_host_id(param)
host = OpenNebula::Host.new_with_id(host_id,get_one_client)
result=host.disable
if is_successful?(result)
puts "Host disabled" if ops[:verbose]
else
break
end
end
else

View File

@ -1,8 +1,7 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
# Complutense de Madrid (dsa-research.org) #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@ -34,14 +33,14 @@ require 'command_parse'
ShowTableUP={
:uid => {
:name => "UID",
:id => {
:name => "ID",
:desc => "ONE identifier for user",
:size => 4,
:proc => lambda {|d,e| d.id }
},
:name => {
:name => "NAME",
:user => {
:name => "USER",
:desc => "name of the user",
:size => 15,
:left => true,
@ -61,7 +60,7 @@ ShowTableUP={
:proc => lambda {|d,e| d[:enabled] }
},
:default => [:uid, :name, :password, :enable]
:default => [:id, :user, :password, :enable]
}
class UPShow
@ -123,7 +122,7 @@ Commands:
oneuser create username password
* delete (Removes a user)
oneuser delete <uid>
oneuser delete <id>
* list (Lists all the users in the pool)
oneuser list
@ -161,34 +160,38 @@ when "create"
sha_password = Digest::SHA1.hexdigest(ARGV[1])
result=user.allocate(ARGV[0],sha_password)
if !OpenNebula.is_error?(result)
puts "UID: " + user.id.to_s if ops[:verbose]
puts "ID: " + user.id.to_s if ops[:verbose]
exit 0
end
when "delete"
check_parameters("delete", 1)
user_id=get_user_id(ARGV[0])
args=expand_args(ARGV)
# Check if the user has defined VM's
vms=false
vmpool=OpenNebula::VirtualMachinePool.new(
get_one_client, user_id)
vmpool.info
vmpool.each{ vms=true ; break }
args.each do |param|
user_id=get_user_id(param)
if vms
puts "The user still has VM's defined, type YES if you are sure you"
print "want to delete this user: "
answer=STDIN.gets.strip
exit -1 if answer != 'YES'
end
# Check if the user has defined VM's
vms=false
vmpool=OpenNebula::VirtualMachinePool.new(
get_one_client, user_id)
vmpool.info
vmpool.each{ vms=true ; break }
user=OpenNebula::User.new(
OpenNebula::User.build_xml(user_id), get_one_client)
result=user.delete
if !OpenNebula.is_error?(result)
puts "User deleted" if ops[:verbose]
exit 0
if vms
puts "The user #{param} still has VM's defined, "+
"type YES if you are sure you"
print "want to delete this user: "
answer=STDIN.gets.strip
exit -1 if answer != 'YES'
end
user=OpenNebula::User.new(
OpenNebula::User.build_xml(user_id), get_one_client)
result=user.delete
if !OpenNebula.is_error?(result)
puts "User deleted" if ops[:verbose]
end
end
when "list"

View File

@ -1,8 +1,7 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
# Complutense de Madrid (dsa-research.org) #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@ -48,7 +47,7 @@ ShowTableVM={
d.name
}
},
:username => {
:user=> {
:name => "USER",
:desc => "Name of the owner",
:size => 8,
@ -93,7 +92,7 @@ ShowTableVM={
:proc => lambda {|d,e| str_running_time(d) }
},
:default => [:id, :username, :name, :stat, :cpu, :mem, :hostname, :time]
:default => [:id, :user, :name, :stat, :cpu, :mem, :hostname, :time]
}
ShowTableHistory={
@ -356,7 +355,7 @@ Commands:
a, all --> all the known VMs
m, mine --> the VMs belonging to the user in ONE_AUTH
uid --> VMs of the user identified by this uid
username --> VMs of the user identified by the username
user--> VMs of the user identified by the username
* show (Gets information about a specific VM)
onevm show <vm_id>
@ -436,136 +435,191 @@ when "submit", "create"
when "deploy"
check_parameters("deploy", 2)
vm_id=get_vm_id(ARGV[0])
host_id=get_host_id(ARGV[1])
host_id=get_host_id(ARGV[-1])
args=expand_args(ARGV[0..-2])
vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
args.each do |param|
vm_id=get_vm_id(param)
result=vm.deploy(host_id)
if is_successful?(result)
puts "Deploying VM" if ops[:verbose]
exit 0
vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
result=vm.deploy(host_id)
if is_successful?(result)
puts "Deploying VM" if ops[:verbose]
else
break
end
end
when "shutdown"
check_parameters("shutdown", 1)
vm_id=get_vm_id(ARGV[0])
args=expand_args(ARGV)
args.each do |param|
vm_id=get_vm_id(param)
vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
result=vm.shutdown
if is_successful?(result)
puts "Shutting down VM" if ops[:verbose]
exit 0
vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
result=vm.shutdown
if is_successful?(result)
puts "Shutting down VM" if ops[:verbose]
else
break
end
end
when "livemigrate"
check_parameters("livemigrate", 2)
vm_id=get_vm_id(ARGV[0])
host_id=get_host_id(ARGV[1])
host_id=get_host_id(ARGV[-1])
args=expand_args(ARGV[0..-2])
vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
args.each do |param|
vm_id=get_vm_id(param)
result=vm.live_migrate(host_id)
if is_successful?(result)
puts "Migrating VM" if ops[:verbose]
exit 0
vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
result=vm.live_migrate(host_id)
if is_successful?(result)
puts "Migrating VM" if ops[:verbose]
else
break
end
end
when "migrate"
check_parameters("migrate", 2)
vm_id=get_vm_id(ARGV[0])
host_id=get_host_id(ARGV[1])
host_id=get_host_id(ARGV[-1])
args=expand_args(ARGV[0..-2])
vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
args.each do |param|
vm_id=get_vm_id(param)
result=vm.migrate(host_id)
if is_successful?(result)
puts "Migrating VM" if ops[:verbose]
exit 0
vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
result=vm.migrate(host_id)
if is_successful?(result)
puts "Migrating VM" if ops[:verbose]
else
break
end
end
when "hold"
check_parameters("hold", 1)
vm_id=get_vm_id(ARGV[0])
args=expand_args(ARGV)
vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
args.each do |param|
vm_id=get_vm_id(param)
result=vm.hold
if is_successful?(result)
puts "Setting VM to hold state" if ops[:verbose]
exit 0
vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
result=vm.hold
if is_successful?(result)
puts "Setting VM to hold state" if ops[:verbose]
else
break
end
end
when "release"
check_parameters("release", 1)
vm_id=get_vm_id(ARGV[0])
args=expand_args(ARGV)
vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
args.each do |param|
vm_id=get_vm_id(param)
result=vm.release
if is_successful?(result)
puts "Releasing VM" if ops[:verbose]
exit 0
vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
result=vm.release
if is_successful?(result)
puts "Releasing VM" if ops[:verbose]
else
break
end
end
when "stop"
check_parameters("stop", 1)
vm_id=get_vm_id(ARGV[0])
args=expand_args(ARGV)
vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
args.each do |param|
vm_id=get_vm_id(param)
result=vm.stop
if is_successful?(result)
puts "Stopping VM" if ops[:verbose]
exit 0
vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
result=vm.stop
if is_successful?(result)
puts "Stopping VM" if ops[:verbose]
else
break
end
end
when "cancel"
check_parameters("cancel", 1)
vm_id=get_vm_id(ARGV[0])
args=expand_args(ARGV)
vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
result=vm.cancel
if is_successful?(result)
puts "Cancelling VM" if ops[:verbose]
exit 0
args.each do |param|
vm_id=get_vm_id(param)
vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
result=vm.cancel
if is_successful?(result)
puts "Cancelling VM" if ops[:verbose]
else
break
end
end
when "suspend"
check_parameters("suspend", 1)
vm_id=get_vm_id(ARGV[0])
args=expand_args(ARGV)
vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
args.each do |param|
vm_id=get_vm_id(param)
result=vm.suspend
if is_successful?(result)
puts "Suspending VM" if ops[:verbose]
exit 0
vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
result=vm.suspend
if is_successful?(result)
puts "Suspending VM" if ops[:verbose]
else
break
end
end
when "resume"
check_parameters("resume", 1)
vm_id=get_vm_id(ARGV[0])
args=expand_args(ARGV)
vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
args.each do |param|
vm_id=get_vm_id(param)
result=vm.resume
if is_successful?(result)
puts "Resuming VM" if ops[:verbose]
exit 0
vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
result=vm.resume
if is_successful?(result)
puts "Resuming VM" if ops[:verbose]
else
break
end
end
when "restart"
check_parameters("restart", 1)
vm_id=get_vm_id(ARGV[0])
args=expand_args(ARGV)
vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
args.each do |param|
vm_id=get_vm_id(param)
result=vm.restart
if is_successful?(result)
puts "Restarting VM" if ops[:verbose]
exit 0
vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
result=vm.restart
if is_successful?(result)
puts "Restarting VM" if ops[:verbose]
else
break
end
end
when "list"
@ -602,62 +656,71 @@ when "history"
when "delete"
check_parameters("delete", 1)
vm_id=get_vm_id(ARGV[0])
args=expand_args(ARGV)
vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
args.each do |param|
vm_id=get_vm_id(param)
result=vm.finalize
if is_successful?(result)
puts "VM correctly deleted" if ops[:verbose]
exit 0
vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
result=vm.finalize
if is_successful?(result)
puts "VM correctly deleted" if ops[:verbose]
else
break
end
end
when "show"
check_parameters("get_info", 1)
vm_id=get_vm_id(ARGV[0])
args=expand_args(ARGV)
args.each do |param|
vm_id=get_vm_id(param)
vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
vm.info
vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
vm.info
if !ops[:xml]
str="%-15s: %-20s"
str_h1="%-80s"
if !ops[:xml]
str="%-15s: %-20s"
str_h1="%-80s"
print_header(str_h1, "VIRTUAL MACHINE #{vm[:id]} INFORMATION", true)
print_header(str_h1, "VIRTUAL MACHINE #{vm[:id]} INFORMATION", true)
puts str % ["ID", vm[:id]]
puts str % ["NAME", vm[:name]]
puts str % ["STATE", vm.state_str]
puts str % ["LCM_STATE", vm.lcm_state_str]
puts str % ["ID", vm[:id]]
puts str % ["NAME", vm[:name]]
puts str % ["STATE", vm.state_str]
puts str % ["LCM_STATE", vm.lcm_state_str]
value=vm[:stime].to_i
if value==0
value='-'
value=vm[:stime].to_i
if value==0
value='-'
else
value=Time.at(value).strftime("%m/%d %H:%M:%S")
end
puts str % ["START TIME", value]
value=vm[:etime].to_i
if value==0
value='-'
else
value=Time.at(value).strftime("%m/%d %H:%M:%S")
end
puts str % ["END TIME", value]
value=vm[:deploy_id]
puts str % ["DEPLOY ID:", value=="" ? "-" : value]
puts
print_header(str_h1,"VIRTUAL MACHINE TEMPLATE",false)
puts vm.template_str
else
value=Time.at(value).strftime("%m/%d %H:%M:%S")
puts vm.to_xml
end
puts str % ["START TIME", value]
value=vm[:etime].to_i
if value==0
value='-'
else
value=Time.at(value).strftime("%m/%d %H:%M:%S")
end
puts str % ["END TIME", value]
value=vm[:deploy_id]
puts str % ["DEPLOY ID:", value=="" ? "-" : value]
puts
print_header(str_h1,"VIRTUAL MACHINE TEMPLATE",false)
puts vm.template_str
else
puts vm.to_xml
end
end
else
onevm_opts.print_help
exit -1

View File

@ -1,8 +1,7 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
# Complutense de Madrid (dsa-research.org) #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@ -34,8 +33,8 @@ require 'command_parse'
ShowTableVN={
:nid => {
:name => "NID",
:id => {
:name => "ID",
:desc => "ONE identifier for virtual network",
:size => 4,
:proc => lambda {|d,e| d.id }
@ -47,7 +46,7 @@ ShowTableVN={
:left => true,
:proc => lambda {|d,e| d.name }
},
:username => {
:user => {
:name => "USER",
:desc => "Username of the virtual network owner",
:size => 8,
@ -87,7 +86,7 @@ ShowTableVN={
:proc => lambda {|d,e| d["TOTAL_LEASES"] }
},
:default => [:nid, :username, :name, :type, :bridge, :totalleases]
:default => [:id, :user, :name, :type, :bridge, :totalleases]
}
class VNShow
@ -169,7 +168,7 @@ Commands:
a, all --> all the known VNs
m, mine --> the VNs belonging to the user in ONE_AUTH
uid --> VNs of the user identified by this uid
username --> VNs of the user identified by the username
user --> VNs of the user identified by the username
EOT
def text_commands
@ -203,53 +202,61 @@ when "create"
template=File.read(ARGV[0])
result=vn.allocate(template)
if !OpenNebula.is_error?(result)
puts "NID: " + vn.id.to_s if ops[:verbose]
puts "ID: " + vn.id.to_s if ops[:verbose]
exit 0
end
when "show"
check_parameters("show", 1)
vn_id=get_vn_id(ARGV[0])
vn=OpenNebula::VirtualNetwork.new_with_id(vn_id, get_one_client)
result=vn.info
if is_successful?(result)
if !ops[:xml]
str_h1="%-80s"
str="%-10s: %-20s"
print_header(str_h1,
"VIRTUAL NETWORK #{vn.id.to_s} INFORMATION",true)
args=expand_args(ARGV)
args.each do |param|
vn_id=get_vn_id(param)
vn=OpenNebula::VirtualNetwork.new_with_id(vn_id, get_one_client)
result=vn.info
if is_successful?(result)
if !ops[:xml]
str_h1="%-80s"
str="%-10s: %-20s"
print_header(str_h1,
"VIRTUAL NETWORK #{vn.id.to_s} INFORMATION",true)
puts str % ["ID: ",vn.id.to_s]
puts str % ["UID: ",vn["UID"]]
puts
print_header(str_h1,"VIRTUAL NETWORK TEMPLATE",false)
puts vn.template_str(false)
leases_str = vn.template_like_str('/VNET/LEASES', false)
if !leases_str.empty?
puts str % ["ID: ",vn.id.to_s]
puts str % ["UID: ",vn["UID"]]
puts
print_header(str_h1,"LEASES INFORMATION",false)
puts leases_str
print_header(str_h1,"VIRTUAL NETWORK TEMPLATE",false)
puts vn.template_str(false)
leases_str = vn.template_like_str('/VNET/LEASES', false)
if !leases_str.empty?
puts
print_header(str_h1,"LEASES INFORMATION",false)
puts leases_str
end
else
puts vn.to_xml
end
else
puts vn.to_xml
puts "Error: "+result.message
break
end
else
puts "Error: "+result.message
exit -1
end
when "delete"
check_parameters("delete", 1)
vn_id=get_vn_id(ARGV[0])
vn=OpenNebula::VirtualNetwork.new(
OpenNebula::VirtualNetwork.build_xml(vn_id), get_one_client)
result=vn.delete
if !OpenNebula.is_error?(result)
puts "Virtual Network deleted" if ops[:verbose]
exit 0
args=expand_args(ARGV)
args.each do |param|
vn_id=get_vn_id(param)
vn=OpenNebula::VirtualNetwork.new(
OpenNebula::VirtualNetwork.build_xml(vn_id), get_one_client)
result=vn.delete
if !OpenNebula.is_error?(result)
puts "Virtual Network deleted" if ops[:verbose]
break
end
end
when "list"

View File

@ -0,0 +1,121 @@
# -------------------------------------------------------------------------- #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
require 'rubygems'
require 'uri'
require 'digest'
require 'net/https'
begin
require 'curb'
CURL_LOADED=true
rescue LoadError
CURL_LOADED=false
end
begin
require 'net/http/post/multipart'
rescue LoadError
end
###############################################################################
# The CloudClient module contains general functionality to implement a
# Cloud Client
###############################################################################
module CloudClient
# #########################################################################
# Default location for the authentication file
# #########################################################################
DEFAULT_AUTH_FILE = ENV["HOME"]+"/.one/one_auth"
# #########################################################################
# Gets authorization credentials from ONE_AUTH or default
# auth file.
#
# Raises an error if authorization is not found
# #########################################################################
def self.get_one_auth
if ENV["ONE_AUTH"] and !ENV["ONE_AUTH"].empty? and
File.file?(ENV["ONE_AUTH"])
one_auth=File.read(ENV["ONE_AUTH"]).strip.split(':')
elsif File.file?(DEFAULT_AUTH_FILE)
one_auth=File.read(DEFAULT_AUTH_FILE).strip.split(':')
else
raise "No authorization data present"
end
raise "Authorization data malformed" if one_auth.length < 2
one_auth
end
# #########################################################################
# Starts an http connection and calls the block provided. SSL flag
# is set if needed.
# #########################################################################
def self.http_start(url, &block)
http = Net::HTTP.new(url.host, url.port)
if url.scheme=='https'
http.use_ssl = true
http.verify_mode=OpenSSL::SSL::VERIFY_NONE
end
begin
http.start do |connection|
block.call(connection)
end
rescue Errno::ECONNREFUSED => e
str = "Error connecting to server (#{e.to_s})."
str << "Server: #{url.host}:#{url.port}"
return CloudClient::Error.new(str)
end
end
# #########################################################################
# The Error Class represents a generic error in the Cloud Client
# library. It contains a readable representation of the error.
# #########################################################################
class Error
attr_reader :message
# +message+ a description of the error
def initialize(message=nil)
@message=message
end
def to_s()
@message
end
end
# #########################################################################
# Returns true if the object returned by a method of the OpenNebula
# library is an Error
# #########################################################################
def self.is_error?(value)
value.class==CloudClient::Error
end
end
# Command line help functions
module CloudCLI
# Returns the command name
def cmd_name
File.basename($0)
end
end

152
src/cloud/common/CloudServer.rb Executable file
View File

@ -0,0 +1,152 @@
# -------------------------------------------------------------------------- #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
require 'repo_manager'
require 'Configuration'
require 'OpenNebula'
require 'pp'
##############################################################################
# This class represents a generic Cloud Server using the OpenNebula Cloud
# API (OCA). Any cloud implementation should derive from this class
##############################################################################
class CloudServer
##########################################################################
# Public attributes
##########################################################################
attr_reader :config
attr_reader :one_client
# Initializes the Cloud server based on a config file
# config_file:: _String_ for the server. MUST include the following
# variables:
# USER
# PASSWORD
# VM_TYPE
# IMAGE_DIR
# DATABASE
def initialize(config_file)
# --- Load the Cloud Server configuration file ---
@config = Configuration.new(config_file)
@auth = "#{@config[:user]}:#{@config[:password]}"
@instance_types = Hash.new
if @config[:vm_type].kind_of?(Array)
@config[:vm_type].each {|type|
@instance_types[type['NAME']]=type
}
else
@instance_types[@config[:vm_type]['NAME']]=@config[:vm_type]
end
# --- Start a Repository Manager ---
@rm = RepoManager.new(@config[:database])
Image.image_dir = @config[:image_dir]
# --- Start an OpenNebula Session ---
@one_client = Client.new(@auth)
@user_pool = UserPool.new(@one_client)
end
#
# Prints the configuration of the server
#
def print_configuration
puts "--------------------------------------"
puts " Server configuration "
puts "--------------------------------------"
pp @config
puts "--------------------------------------"
puts " Registered Instance Types "
puts "--------------------------------------"
pp @instance_types
end
###########################################################################
# USER and OpenNebula Session Methods
###########################################################################
# Generates an OpenNebula Session for the given user
# user:: _Hash_ the user information
# [return] an OpenNebula client session
def one_client_user(user)
client = Client.new("dummy:dummy")
client.one_auth = "#{user[:name]}:#{user[:password]}"
return client
end
# Authenticates a user
# name:: _String_ of the user
# password:: _String_ of the user
# [return] true if authenticated
def authenticate?(name, password)
user = get_user(name)
return user && user.password == password
end
# Gets the data associated with a user
# name:: _String_ the name of the user
# [return] _Hash_ with the user data
def get_user(name)
user = nil
@user_pool.info
@user_pool.each{ |u|
if u.name==name
user=Hash.new
user[:id] = u.id
user[:name] = u.name
user[:password] = u[:password]
end
}
return user
end
###########################################################################
# Repository Methods
###########################################################################
# Adds a new image to the repository and deletes the temp_file
# uid:: _Integer_ owner of the image
# path:: _String_ path of the tmp file
# metadata:: Additional metadata for the file
# [return] _Image_ Newly created image object
def add_image(uid, file, metadata={})
image = @rm.add(uid,file.path,metadata)
file.unlink
return image
end
# Gets an image from the repository
# image_id:: _Integer_ Image identifier
# [return] _Image_ Image object
def get_image(image_id)
return @rm.get(image_id)
end
end

View File

@ -0,0 +1,115 @@
# -------------------------------------------------------------------------- #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
###############################################################################
# The Configuration Class represents a simple configuration file for the
# Cloud servers. It does not check syntax.
###############################################################################
class Configuration
###########################################################################
# Patterns to parse the Configuration File
###########################################################################
NAME_REG =/[\w\d_-]+/
VARIABLE_REG =/\s*(#{NAME_REG})\s*=\s*/
SIMPLE_VARIABLE_REG =/#{VARIABLE_REG}([^\[]+?)(#.*)?/
SINGLE_VARIABLE_REG =/^#{SIMPLE_VARIABLE_REG}$/
ARRAY_VARIABLE_REG =/^#{VARIABLE_REG}\[(.*?)\]/m
###########################################################################
###########################################################################
def initialize(file)
@conf=parse_conf(file)
end
def add_configuration_value(key,value)
add_value(@conf,key,value)
end
def [](key)
@conf[key.to_s.upcase]
end
###########################################################################
###########################################################################
private
#
#
#
def add_value(conf, key, value)
if conf[key]
if !conf[key].kind_of?(Array)
conf[key]=[conf[key]]
end
conf[key]<<value
else
conf[key]=value
end
end
#
#
#
def parse_conf(file)
conf_file=File.read(file)
conf=Hash.new
conf_file.scan(SINGLE_VARIABLE_REG) {|m|
key=m[0].strip.upcase
value=m[1].strip
# hack to skip multiline VM_TYPE values
next if %w{NAME TEMPLATE}.include? key.upcase
add_value(conf, key, value)
}
conf_file.scan(ARRAY_VARIABLE_REG) {|m|
master_key=m[0].strip.upcase
pieces=m[1].split(',')
vars=Hash.new
pieces.each {|p|
key, value=p.split('=')
vars[key.strip.upcase]=value.strip
}
add_value(conf, master_key, vars)
}
conf
end
end
#
# Test program for the Configuration Parser
#
if $0 == __FILE__
require 'pp'
conf=Configuration.new('cloud.conf')
pp conf
end

View File

@ -0,0 +1,19 @@
# OpenNebula administrator user
USER = oneadmin
PASSWORD = oneadmin
# OpenNebula sever contact information
ONE_XMLRPC=http://localhost:2633/RPC2
# Host and port where econe server will run
SERVER = localhost
PORT = 4567
# Configuration for the image repository
DATABASE = /images/var/econe.db
IMAGE_DIR = /images/tmp
#
# VM types allowed and its template file (inside templates directory)
#
VM_TYPE=[NAME=m1.small, TEMPLATE=m1.small.erb]

View File

@ -1,73 +0,0 @@
class OcaConfiguration
NAME_REG=/[\w\d_-]+/
VARIABLE_REG=/\s*(#{NAME_REG})\s*=\s*/
SIMPLE_VARIABLE_REG=/#{VARIABLE_REG}([^\[]+?)(#.*)?/
SINGLE_VARIABLE_REG=/^#{SIMPLE_VARIABLE_REG}$/
ARRAY_VARIABLE_REG=/^#{VARIABLE_REG}\[(.*?)\]/m
def initialize(file)
@conf=parse_conf(file)
end
def add_value(conf, key, value)
if conf[key]
if !conf[key].kind_of?(Array)
conf[key]=[conf[key]]
end
conf[key]<<value
else
conf[key]=value
end
end
def parse_conf(file)
conf_file=File.read(file)
conf=Hash.new
conf_file.scan(SINGLE_VARIABLE_REG) {|m|
key=m[0].strip.upcase
value=m[1].strip
# hack to skip multiline VM_TYPE values
next if %w{NAME TEMPLATE}.include? key.upcase
add_value(conf, key, value)
}
conf_file.scan(ARRAY_VARIABLE_REG) {|m|
master_key=m[0].strip.upcase
pieces=m[1].split(',')
vars=Hash.new
pieces.each {|p|
key, value=p.split('=')
vars[key.strip.upcase]=value.strip
}
add_value(conf, master_key, vars)
}
conf
end
def conf
@conf
end
def [](key)
@conf[key.to_s.upcase]
end
end
if $0 == __FILE__
require 'pp'
conf=OcaConfiguration.new('econe.conf')
pp conf.conf
end

View File

@ -26,8 +26,7 @@
# Display column headers
# -------------------------------------------------------------------------- #
# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
# Complutense de Madrid (dsa-research.org) #
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@ -52,13 +51,15 @@ end
$: << RUBY_LIB_LOCATION
$: << RUBY_LIB_LOCATION+"/econe"
$: << RUBY_LIB_LOCATION+"/cloud"
require 'EC2QueryClient'
require 'econe/EC2QueryClient'
require 'CloudClient'
require 'getoptlong'
require 'rdoc/usage'
require 'pp'
include CloudCLI
opts = GetoptLong.new(
['--help', '-h',GetoptLong::NO_ARGUMENT],
@ -98,14 +99,14 @@ auth = "#{access}:#{secret}" if secret && access
begin
ec2_client = EC2QueryClient::Client.new(auth,url)
rescue Exception => e
puts "#{$0}: #{e.message}"
puts "#{cmd_name}: #{e.message}"
exit -1
end
rc = ec2_client.describe_images()
if OpenNebula::is_error?(rc)
puts "#{$0}: #{rc.message}"
if CloudClient::is_error?(rc)
puts "#{cmd_name}: #{rc.message}"
exit -1
end
@ -118,14 +119,11 @@ if headers
puts "------------------------------------------------------------------------------"
end
images.each { |img|
if images
images.each { |img|
puts fmt % [img['imageOwnerId'],img['imageId'],img['imageLocation']]
}
end
exit 0

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