mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-21 04:12:37 +09:00
Merge branch 'master' of opennebula.org:one
This commit is contained in:
commit
a2ee7a6e54
41 files changed
+1042
-116
No files matched your search
+29
-16
@@ -179,7 +179,13 @@ LIB_DIRS="$LIB_LOCATION/ruby \
|
||||
$LIB_LOCATION/tm_commands/ssh \
|
||||
$LIB_LOCATION/tm_commands/dummy \
|
||||
$LIB_LOCATION/tm_commands/lvm \
|
||||
$LIB_LOCATION/mads"
|
||||
$LIB_LOCATION/mads \
|
||||
$LIB_LOCATION/remotes \
|
||||
$LIB_LOCATION/remotes/im \
|
||||
$LIB_LOCATION/remotes/im/kvm.d \
|
||||
$LIB_LOCATION/remotes/im/xen.d \
|
||||
$LIB_LOCATION/remotes/vmm/xen \
|
||||
$LIB_LOCATION/remotes/vmm/kvm"
|
||||
|
||||
VAR_DIRS="$VAR_LOCATION/remotes \
|
||||
$VAR_LOCATION/remotes/im \
|
||||
@@ -222,20 +228,25 @@ INSTALL_FILES[7]="IM_PROBES_KVM_FILES:$VAR_LOCATION/remotes/im/kvm.d"
|
||||
INSTALL_FILES[8]="IM_PROBES_XEN_FILES:$VAR_LOCATION/remotes/im/xen.d"
|
||||
INSTALL_FILES[9]="VMM_SSH_KVM_SCRIPTS:$VAR_LOCATION/remotes/vmm/kvm"
|
||||
INSTALL_FILES[10]="VMM_SSH_XEN_SCRIPTS:$VAR_LOCATION/remotes/vmm/xen"
|
||||
INSTALL_FILES[11]="NFS_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/nfs"
|
||||
INSTALL_FILES[12]="SSH_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/ssh"
|
||||
INSTALL_FILES[13]="DUMMY_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/dummy"
|
||||
INSTALL_FILES[14]="LVM_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/lvm"
|
||||
INSTALL_FILES[15]="EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples"
|
||||
INSTALL_FILES[16]="TM_EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples/tm"
|
||||
INSTALL_FILES[17]="HOOK_SHARE_FILES:$SHARE_LOCATION/hooks"
|
||||
INSTALL_FILES[18]="COMMON_CLOUD_LIB_FILES:$LIB_LOCATION/ruby/cloud"
|
||||
INSTALL_FILES[19]="ECO_LIB_FILES:$LIB_LOCATION/ruby/cloud/econe"
|
||||
INSTALL_FILES[20]="ECO_LIB_VIEW_FILES:$LIB_LOCATION/ruby/cloud/econe/views"
|
||||
INSTALL_FILES[21]="ECO_BIN_FILES:$BIN_LOCATION"
|
||||
INSTALL_FILES[22]="OCCI_LIB_FILES:$LIB_LOCATION/ruby/cloud/occi"
|
||||
INSTALL_FILES[23]="OCCI_BIN_FILES:$BIN_LOCATION"
|
||||
INSTALL_FILES[24]="MAN_FILES:$MAN_LOCATION"
|
||||
INSTALL_FILES[11]="IM_PROBES_FILES:$LIB_LOCATION/remotes/im"
|
||||
INSTALL_FILES[12]="IM_PROBES_KVM_FILES:$LIB_LOCATION/remotes/im/kvm.d"
|
||||
INSTALL_FILES[13]="IM_PROBES_XEN_FILES:$LIB_LOCATION/remotes/im/xen.d"
|
||||
INSTALL_FILES[14]="VMM_SSH_KVM_SCRIPTS:$LIB_LOCATION/remotes/vmm/kvm"
|
||||
INSTALL_FILES[15]="VMM_SSH_XEN_SCRIPTS:$LIB_LOCATION/remotes/vmm/xen"
|
||||
INSTALL_FILES[16]="NFS_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/nfs"
|
||||
INSTALL_FILES[17]="SSH_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/ssh"
|
||||
INSTALL_FILES[18]="DUMMY_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/dummy"
|
||||
INSTALL_FILES[19]="LVM_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/lvm"
|
||||
INSTALL_FILES[20]="EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples"
|
||||
INSTALL_FILES[21]="TM_EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples/tm"
|
||||
INSTALL_FILES[22]="HOOK_SHARE_FILES:$SHARE_LOCATION/hooks"
|
||||
INSTALL_FILES[23]="COMMON_CLOUD_LIB_FILES:$LIB_LOCATION/ruby/cloud"
|
||||
INSTALL_FILES[24]="ECO_LIB_FILES:$LIB_LOCATION/ruby/cloud/econe"
|
||||
INSTALL_FILES[25]="ECO_LIB_VIEW_FILES:$LIB_LOCATION/ruby/cloud/econe/views"
|
||||
INSTALL_FILES[26]="ECO_BIN_FILES:$BIN_LOCATION"
|
||||
INSTALL_FILES[27]="OCCI_LIB_FILES:$LIB_LOCATION/ruby/cloud/occi"
|
||||
INSTALL_FILES[28]="OCCI_BIN_FILES:$BIN_LOCATION"
|
||||
INSTALL_FILES[29]="MAN_FILES:$MAN_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"
|
||||
@@ -591,7 +602,9 @@ OCCI_BIN_CLIENT_FILES="src/cloud/occi/bin/occi-compute \
|
||||
|
||||
OCCI_ETC_FILES="src/cloud/occi/etc/occi-server.conf"
|
||||
|
||||
OCCI_ETC_TEMPLATE_FILES="src/cloud/occi/etc/templates/small.erb \
|
||||
OCCI_ETC_TEMPLATE_FILES="src/cloud/occi/etc/templates/common.erb \
|
||||
src/cloud/occi/etc/templates/custom.erb \
|
||||
src/cloud/occi/etc/templates/small.erb \
|
||||
src/cloud/occi/etc/templates/medium.erb \
|
||||
src/cloud/occi/etc/templates/large.erb"
|
||||
|
||||
|
||||
Executable
+95
@@ -0,0 +1,95 @@
|
||||
#! /bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: opennebula
|
||||
# Required-Start: $remote_fs
|
||||
# Required-Stop: $remote_fs
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: OpenNebula init script
|
||||
# Description: OpenNebula cloud initialisation script
|
||||
### END INIT INFO
|
||||
|
||||
# Author: Soren Hansen <soren@canonical.com>
|
||||
|
||||
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
||||
DESC="OpenNebula cloud"
|
||||
NAME=one
|
||||
DAEMON=/usr/bin/$NAME
|
||||
DAEMON_ARGS=""
|
||||
PIDFILE=/var/run/$NAME.pid
|
||||
SCRIPTNAME=/etc/init.d/$NAME
|
||||
|
||||
# Exit if the package is not installed
|
||||
[ -x "$DAEMON" ] || exit 0
|
||||
|
||||
# Load the VERBOSE setting and other rcS variables
|
||||
. /lib/init/vars.sh
|
||||
|
||||
# Define LSB log_* functions.
|
||||
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
#
|
||||
# Function that starts the daemon/service
|
||||
#
|
||||
do_start()
|
||||
{
|
||||
mkdir -p /var/run/one /var/lock/one
|
||||
chown oneadmin /var/run/one /var/lock/one
|
||||
su oneadmin -s /bin/sh -c 'one start'
|
||||
}
|
||||
|
||||
#
|
||||
# Function that stops the daemon/service
|
||||
#
|
||||
do_stop()
|
||||
{
|
||||
su oneadmin -s /bin/sh -c 'one stop'
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
|
||||
do_start
|
||||
case "$?" in
|
||||
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
||||
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
||||
esac
|
||||
;;
|
||||
stop)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
|
||||
do_stop
|
||||
case "$?" in
|
||||
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
||||
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
||||
esac
|
||||
;;
|
||||
restart|force-reload)
|
||||
#
|
||||
# If the "reload" option is implemented then remove the
|
||||
# 'force-reload' alias
|
||||
#
|
||||
log_daemon_msg "Restarting $DESC" "$NAME"
|
||||
do_stop
|
||||
case "$?" in
|
||||
0|1)
|
||||
do_start
|
||||
case "$?" in
|
||||
0) log_end_msg 0 ;;
|
||||
1) log_end_msg 1 ;; # Old process is still running
|
||||
*) log_end_msg 1 ;; # Failed to start
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
# Failed to stop
|
||||
log_end_msg 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
|
||||
exit 3
|
||||
;;
|
||||
esac
|
||||
|
||||
:
|
||||
Executable
+95
@@ -0,0 +1,95 @@
|
||||
#! /bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: opennebula
|
||||
# Required-Start: $remote_fs
|
||||
# Required-Stop: $remote_fs
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: OpenNebula init script
|
||||
# Description: OpenNebula cloud initialisation script
|
||||
### END INIT INFO
|
||||
|
||||
# Author: Soren Hansen <soren@canonical.com>
|
||||
|
||||
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
||||
DESC="OpenNebula cloud"
|
||||
NAME=one
|
||||
DAEMON=/usr/bin/$NAME
|
||||
DAEMON_ARGS=""
|
||||
PIDFILE=/var/run/$NAME.pid
|
||||
SCRIPTNAME=/etc/init.d/$NAME
|
||||
|
||||
# Exit if the package is not installed
|
||||
[ -x "$DAEMON" ] || exit 0
|
||||
|
||||
# Load the VERBOSE setting and other rcS variables
|
||||
. /lib/init/vars.sh
|
||||
|
||||
# Define LSB log_* functions.
|
||||
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
#
|
||||
# Function that starts the daemon/service
|
||||
#
|
||||
do_start()
|
||||
{
|
||||
mkdir -p /var/run/one /var/lock/one
|
||||
chown oneadmin /var/run/one /var/lock/one
|
||||
su oneadmin -s /bin/sh -c 'one start'
|
||||
}
|
||||
|
||||
#
|
||||
# Function that stops the daemon/service
|
||||
#
|
||||
do_stop()
|
||||
{
|
||||
su oneadmin -s /bin/sh -c 'one stop'
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
|
||||
do_start
|
||||
case "$?" in
|
||||
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
||||
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
||||
esac
|
||||
;;
|
||||
stop)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
|
||||
do_stop
|
||||
case "$?" in
|
||||
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
||||
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
||||
esac
|
||||
;;
|
||||
restart|force-reload)
|
||||
#
|
||||
# If the "reload" option is implemented then remove the
|
||||
# 'force-reload' alias
|
||||
#
|
||||
log_daemon_msg "Restarting $DESC" "$NAME"
|
||||
do_stop
|
||||
case "$?" in
|
||||
0|1)
|
||||
do_start
|
||||
case "$?" in
|
||||
0) log_end_msg 0 ;;
|
||||
1) log_end_msg 1 ;; # Old process is still running
|
||||
*) log_end_msg 1 ;; # Failed to start
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
# Failed to stop
|
||||
log_end_msg 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
|
||||
exit 3
|
||||
;;
|
||||
esac
|
||||
|
||||
:
|
||||
Executable
+83
@@ -0,0 +1,83 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# /etc/rc.d/init.d/oned
|
||||
#
|
||||
# Starts the OpenNebula daemon
|
||||
#
|
||||
# chkconfig: 345 26 74
|
||||
# description: Starts the OpenNebula daemon
|
||||
# processname: oned
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: oned
|
||||
# Required-Start: $local_fs $remote_fs
|
||||
# Required-Stop: $local_fs $remote_fs
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: start and stop oned
|
||||
# Description: start and stop oned
|
||||
### END INIT INFO
|
||||
|
||||
ONE_BIN=/usr/bin/one
|
||||
|
||||
# Source function library.
|
||||
. /etc/rc.d/init.d/functions
|
||||
|
||||
RETVAL=0
|
||||
|
||||
check() {
|
||||
# Check that we're a privileged user
|
||||
[ `id -u` = 0 ] || exit 4
|
||||
|
||||
# Check if oned is executable
|
||||
test -x $ONE_BIN || exit 5
|
||||
}
|
||||
|
||||
start() {
|
||||
|
||||
check
|
||||
|
||||
echo -n $"Starting OpenNebula daemon: "
|
||||
daemon --user oneadmin $ONE_BIN start
|
||||
RETVAL=$?
|
||||
echo
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
stop() {
|
||||
|
||||
check
|
||||
|
||||
echo -n $"Stopping OpenNebula daemon: "
|
||||
su oneadmin -s /bin/sh -c "$ONE_BIN stop"
|
||||
RETVAL=$?
|
||||
echo
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
restart
|
||||
;;
|
||||
status)
|
||||
status oned
|
||||
RETVAL=$?
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|status|restart}"
|
||||
RETVAL=2
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
||||
Executable
+97
@@ -0,0 +1,97 @@
|
||||
#!/bin/sh
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: ONE
|
||||
# Required-Start: $remote_fs
|
||||
# Required-Stop: $remote_fs
|
||||
# Default-Start: 3 5
|
||||
# Default-Stop: 0 1 2 6
|
||||
# Short-Description: OpenNebula Init Script
|
||||
# Description: OpenNebula Init Script
|
||||
### END INIT INFO
|
||||
|
||||
ONE_BIN=/usr/bin/one
|
||||
|
||||
. /etc/rc.status
|
||||
|
||||
rc_reset
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo -n "Starting ONE "
|
||||
/sbin/startproc -u oneadmin $ONE_BIN start
|
||||
rc_status -v
|
||||
;;
|
||||
stop)
|
||||
echo -n "Shutting down ONE "
|
||||
/sbin/startproc -u oneadmin $ONE_BIN stop
|
||||
rc_status -v
|
||||
;;
|
||||
try-restart|condrestart)
|
||||
if test "$1" = "condrestart"; then
|
||||
echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
|
||||
fi
|
||||
$0 status
|
||||
if test $? = 0; then
|
||||
$0 restart
|
||||
else
|
||||
rc_reset # Not running is not a failure.
|
||||
fi
|
||||
# Remember status and be quiet
|
||||
rc_status
|
||||
;;
|
||||
restart)
|
||||
$0 stop
|
||||
$0 start
|
||||
|
||||
rc_status
|
||||
;;
|
||||
force-reload)
|
||||
$0 try-restart
|
||||
rc_status
|
||||
;;
|
||||
reload)
|
||||
rc_failed 3
|
||||
rc_status -v
|
||||
;;
|
||||
status)
|
||||
echo -n "Checking for service ONE "
|
||||
## Check status with checkproc(8), if process is running
|
||||
## checkproc will return with exit status 0.
|
||||
|
||||
# Return value is slightly different for the status command:
|
||||
# 0 - service up and running
|
||||
# 1 - service dead, but /var/run/ pid file exists
|
||||
# 2 - service dead, but /var/lock/ lock file exists
|
||||
# 3 - service not running (unused)
|
||||
# 4 - service status unknown :-(
|
||||
# 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
|
||||
|
||||
# NOTE: checkproc returns LSB compliant status values.
|
||||
/sbin/checkproc $ONE_BIN
|
||||
# NOTE: rc_status knows that we called this init script with
|
||||
# "status" option and adapts its messages accordingly.
|
||||
rc_status -v
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
rc_exit
|
||||
+1
-1
@@ -98,7 +98,7 @@ Description:
|
||||
This command enables the OpenNebula administrator to manage users, adding,
|
||||
listing and deleting them.
|
||||
|
||||
The create and passwd commands accept the [-r, –read-file] option. Use this
|
||||
The create and passwd commands accept the [-r, --read-file] option. Use this
|
||||
option to store the contents of a file (without hashing it) as the password.
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,15 @@ require 'uri'
|
||||
require 'digest/sha1'
|
||||
require 'net/https'
|
||||
|
||||
require "rexml/document"
|
||||
|
||||
begin
|
||||
require 'rexml/formatters/pretty'
|
||||
REXML_FORMATTERS=true
|
||||
rescue LoadError
|
||||
REXML_FORMATTERS=false
|
||||
end
|
||||
|
||||
begin
|
||||
require 'curb'
|
||||
CURL_LOADED=true
|
||||
@@ -131,6 +140,32 @@ end
|
||||
|
||||
# Command line help functions
|
||||
module CloudCLI
|
||||
def print_xml(xml_text)
|
||||
begin
|
||||
doc = REXML::Document.new(xml_text)
|
||||
rescue REXML::ParseException => e
|
||||
return e.message, -1
|
||||
end
|
||||
|
||||
xml = doc.root
|
||||
|
||||
if xml.nil?
|
||||
return xml_text, -1
|
||||
end
|
||||
|
||||
str = String.new
|
||||
if REXML_FORMATTERS
|
||||
formatter = REXML::Formatters::Pretty.new
|
||||
formatter.compact = true
|
||||
|
||||
formatter.write(xml,str)
|
||||
else
|
||||
str = xml.to_s
|
||||
end
|
||||
|
||||
return str, 0
|
||||
end
|
||||
|
||||
# Returns the command name
|
||||
def cmd_name
|
||||
File.basename($0)
|
||||
|
||||
@@ -79,7 +79,6 @@ EOT
|
||||
|
||||
require 'occi/OCCIClient'
|
||||
require 'getoptlong'
|
||||
require "rexml/document"
|
||||
|
||||
include CloudCLI
|
||||
|
||||
@@ -151,7 +150,7 @@ case ARGV[0].downcase
|
||||
end
|
||||
|
||||
rc = occi_client.post_vms(vm_xml)
|
||||
|
||||
|
||||
when 'show'
|
||||
vm_id = ARGV[1]
|
||||
|
||||
@@ -189,23 +188,10 @@ end
|
||||
|
||||
if CloudClient::is_error?(rc)
|
||||
puts rc.to_s()
|
||||
exit(-1)
|
||||
else
|
||||
begin
|
||||
doc = REXML::Document.new(rc)
|
||||
rescue REXML::ParseException => e
|
||||
puts e.message
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
xml = doc.root
|
||||
|
||||
if xml.nil?
|
||||
puts rc
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
str = ""
|
||||
REXML::Formatters::Pretty.new(4).write(xml,str)
|
||||
puts "\n" + str + "\n "
|
||||
str, code = print_xml(rc)
|
||||
puts str
|
||||
exit(code)
|
||||
end
|
||||
|
||||
@@ -36,18 +36,22 @@ Usage:
|
||||
|
||||
Commands:
|
||||
|
||||
create <occi xml file>
|
||||
* create <occi xml file>
|
||||
creates a new virtual network described by the provided
|
||||
<occi xml file>
|
||||
|
||||
list
|
||||
* list
|
||||
lists available virtual networks
|
||||
|
||||
show <network id>
|
||||
* show <network id>
|
||||
retrieves the OCCI XML representation of the virtual network
|
||||
identified by <network id>
|
||||
|
||||
delete <network id>
|
||||
* update <occi xml file>
|
||||
updates the representation of the network resource represented by the
|
||||
provided <occi xml file>
|
||||
|
||||
* delete <network id>
|
||||
deletes the virtual network idenfitied by <network id>
|
||||
|
||||
|
||||
@@ -80,7 +84,6 @@ EOT
|
||||
require 'occi/OCCIClient'
|
||||
require 'CloudClient'
|
||||
require 'getoptlong'
|
||||
require "rexml/document"
|
||||
|
||||
include CloudCLI
|
||||
|
||||
@@ -165,6 +168,16 @@ case ARGV[0].downcase
|
||||
|
||||
rc = occi_client.get_network(network_id)
|
||||
|
||||
when 'update'
|
||||
network_xml = ARGV[1]
|
||||
|
||||
if !network_xml || !File.exists?(network_xml)
|
||||
puts "#{cmd_name} update: missing OCCI-XML or file not found"
|
||||
exit -1
|
||||
end
|
||||
|
||||
rc = occi_client.put_network(network_xml)
|
||||
|
||||
when 'delete'
|
||||
network_id = ARGV[1]
|
||||
|
||||
@@ -182,22 +195,9 @@ end
|
||||
|
||||
if CloudClient::is_error?(rc)
|
||||
puts rc.to_s()
|
||||
exit(-1)
|
||||
else
|
||||
begin
|
||||
doc = REXML::Document.new(rc)
|
||||
rescue REXML::ParseException => e
|
||||
puts e.message
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
xml = doc.root
|
||||
|
||||
if xml.nil?
|
||||
puts rc
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
str = ""
|
||||
REXML::Formatters::Pretty.new(4).write(xml,str)
|
||||
puts "\n" + str + "\n "
|
||||
str, code = print_xml(rc)
|
||||
puts str
|
||||
exit(code)
|
||||
end
|
||||
@@ -36,18 +36,23 @@ Usage:
|
||||
|
||||
Commands:
|
||||
|
||||
create <occi xml file>
|
||||
* create <occi xml file>
|
||||
creates a new storage resource described by the provided
|
||||
<occi xml file>
|
||||
|
||||
list
|
||||
* list
|
||||
lists available storage resources
|
||||
|
||||
show <storage id>
|
||||
* show <storage id>
|
||||
retrieves the OCCI XML representation of the storage resource
|
||||
identified by <storage id>
|
||||
|
||||
delete <storage id>
|
||||
|
||||
* update <occi xml file>
|
||||
updates the representation of the storage resource represented by the
|
||||
provided <occi xml file>
|
||||
|
||||
* delete <storage id>
|
||||
deletes the storage resource idenfitied by <storage id>
|
||||
|
||||
|
||||
@@ -79,8 +84,7 @@ EOT
|
||||
require 'occi/OCCIClient'
|
||||
require 'CloudClient'
|
||||
require 'getoptlong'
|
||||
require 'rexml/document'
|
||||
require 'pp'
|
||||
|
||||
include CloudCLI
|
||||
|
||||
opts = GetoptLong.new(
|
||||
@@ -167,6 +171,16 @@ case ARGV[0].downcase
|
||||
|
||||
rc = occi_client.get_image(image_id)
|
||||
|
||||
when 'update'
|
||||
image_xml = ARGV[1]
|
||||
|
||||
if !image_xml || !File.exists?(image_xml)
|
||||
puts "#{cmd_name} update: missing OCCI-XML or file not found"
|
||||
exit -1
|
||||
end
|
||||
|
||||
rc = occi_client.put_image(image_xml)
|
||||
|
||||
when 'delete'
|
||||
image_id = ARGV[1]
|
||||
|
||||
@@ -184,22 +198,9 @@ end
|
||||
|
||||
if CloudClient::is_error?(rc)
|
||||
puts rc.to_s()
|
||||
else
|
||||
begin
|
||||
doc = REXML::Document.new(rc)
|
||||
rescue REXML::ParseException => e
|
||||
puts e.message
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
xml = doc.root
|
||||
|
||||
if xml.nil?
|
||||
puts rc
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
str = ""
|
||||
REXML::Formatters::Pretty.new(4).write(xml,str)
|
||||
puts "\n" + str + "\n "
|
||||
exit(-1)
|
||||
else
|
||||
str, code = print_xml(rc)
|
||||
puts str
|
||||
exit(code)
|
||||
end
|
||||
@@ -12,6 +12,7 @@ PORT=4567
|
||||
BRIDGE=<NAME OF DEFAULT BRIDGE>
|
||||
|
||||
# VM types allowed and its template file (inside templates directory)
|
||||
VM_TYPE=[NAME=custom, TEMPLATE=custom.erb]
|
||||
VM_TYPE=[NAME=small, TEMPLATE=small.erb]
|
||||
VM_TYPE=[NAME=medium, TEMPLATE=medium.erb]
|
||||
VM_TYPE=[NAME=large, TEMPLATE=large.erb]
|
||||
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# This template is processed by the OCCI Server to include specific data for the
|
||||
# instance, you should not need to modify the <% ... %> compounds.
|
||||
# instance, you should not need to modify the ruby code.
|
||||
# You can add common attributes for your cloud templates (e.g. OS)
|
||||
#
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
#
|
||||
# Virtual Machine Template generated for custom instance types.
|
||||
# The CPU and MEMORY parameters will be specified in the body of the request.
|
||||
# You can also add specific attributes for your cloud in this file (e.g. OS).
|
||||
#
|
||||
|
||||
# Default values for VM capacity
|
||||
<%
|
||||
DEFAULT_CPU = 1
|
||||
DEFAULT_MEMORY = 128
|
||||
%>
|
||||
|
||||
CPU = "<%= @vm_info['CPU'].nil? ? DEFAULT_CPU : @vm_info['CPU'] %>"
|
||||
MEMORY = "<%= @vm_info['MEMORY'].nil? ? DEFAULT_MEMORY : @vm_info['MEMORY'] %>"
|
||||
@@ -35,6 +35,8 @@ class ImageOCCI < Image
|
||||
<% if fstype != nil %>
|
||||
<FSTYPE><%= fstype %></FSTYPE>
|
||||
<% end %>
|
||||
<PUBLIC><%= self['PUBLIC'] == "0" ? "NO" : "YES"%></PUBLIC>
|
||||
<PERSISTENT><%= self['PERSISTENT'] == "0" ? "NO" : "YES"%></PERSISTENT>
|
||||
</STORAGE>
|
||||
}
|
||||
|
||||
@@ -44,6 +46,12 @@ class ImageOCCI < Image
|
||||
<% if @image_info['DESCRIPTION'] != nil %>
|
||||
DESCRIPTION = "<%= @image_info['DESCRIPTION'] %>"
|
||||
<% end %>
|
||||
<% if @image_info['PUBLIC'] != nil %>
|
||||
PUBLIC = "<%= @image_info['PUBLIC'] %>"
|
||||
<% end %>
|
||||
<% if @image_info['PERSISTENT'] != nil %>
|
||||
PERSISTENT = "<%= @image_info['PERSISTENT'] %>"
|
||||
<% end %>
|
||||
<% if @image_info['TYPE'] != nil %>
|
||||
TYPE = <%= @image_info['TYPE'] %>
|
||||
<% end %>
|
||||
|
||||
@@ -162,7 +162,13 @@ module OCCIClient
|
||||
######################################################################
|
||||
def post_image(xmlfile, curb=true)
|
||||
xml = File.read(xmlfile)
|
||||
image_info = REXML::Document.new(xml).root
|
||||
|
||||
begin
|
||||
image_info = REXML::Document.new(xml).root
|
||||
rescue Exception => e
|
||||
error = CloudClient::Error.new(e.message)
|
||||
return error
|
||||
end
|
||||
|
||||
if image_info.elements['URL'] == nil
|
||||
return CloudClient::Error.new("Can not find URL")
|
||||
@@ -285,10 +291,16 @@ module OCCIClient
|
||||
######################################################################
|
||||
def put_vm(xmlfile)
|
||||
xml = File.read(xmlfile)
|
||||
vm_info = REXML::Document.new(xml).root
|
||||
|
||||
begin
|
||||
vm_info = REXML::Document.new(xml).root
|
||||
rescue Exception => e
|
||||
error = CloudClient::Error.new(e.message)
|
||||
return error
|
||||
end
|
||||
|
||||
if vm_info.elements['ID'] == nil
|
||||
return CloudClient::Error.new("Can not find VM_ID")
|
||||
return CloudClient::Error.new("Can not find COMPUTE_ID")
|
||||
end
|
||||
|
||||
vm_id = vm_info.elements['ID'].text
|
||||
@@ -352,6 +364,44 @@ module OCCIClient
|
||||
end
|
||||
end
|
||||
|
||||
######################################################################
|
||||
# Puts a new Network representation in order to change its state
|
||||
# :xmlfile Network OCCI xml representation
|
||||
######################################################################
|
||||
def put_network(xmlfile)
|
||||
xml = File.read(xmlfile)
|
||||
|
||||
begin
|
||||
vnet_info = REXML::Document.new(xml).root
|
||||
rescue Exception => e
|
||||
error = CloudClient::Error.new(e.message)
|
||||
return error
|
||||
end
|
||||
|
||||
if vnet_info.elements['ID'] == nil
|
||||
return CloudClient::Error.new("Can not find NETWORK_ID")
|
||||
end
|
||||
|
||||
vnet_id = vnet_info.elements['ID'].text
|
||||
|
||||
url = URI.parse(@endpoint+'/network/' + vnet_id)
|
||||
|
||||
req = Net::HTTP::Put.new(url.path)
|
||||
req.body = xml
|
||||
|
||||
req.basic_auth @occiauth[0], @occiauth[1]
|
||||
|
||||
res = CloudClient::http_start(url, @timeout) do |http|
|
||||
http.request(req)
|
||||
end
|
||||
|
||||
if CloudClient::is_error?(res)
|
||||
return res
|
||||
else
|
||||
return res.body
|
||||
end
|
||||
end
|
||||
|
||||
######################################################################
|
||||
# :id VM identifier
|
||||
######################################################################
|
||||
@@ -393,6 +443,44 @@ module OCCIClient
|
||||
end
|
||||
end
|
||||
|
||||
######################################################################
|
||||
# Puts a new Storage representation in order to change its state
|
||||
# :xmlfile Storage OCCI xml representation
|
||||
######################################################################
|
||||
def put_image(xmlfile)
|
||||
xml = File.read(xmlfile)
|
||||
|
||||
begin
|
||||
image_info = REXML::Document.new(xml).root
|
||||
rescue Exception => e
|
||||
error = OpenNebula::Error.new(e.message)
|
||||
return error
|
||||
end
|
||||
|
||||
if image_info.elements['ID'] == nil
|
||||
return CloudClient::Error.new("Can not find STORAGE_ID")
|
||||
end
|
||||
|
||||
image_id = image_info.elements['ID'].text
|
||||
|
||||
url = URI.parse(@endpoint+'/storage/' + image_id)
|
||||
|
||||
req = Net::HTTP::Put.new(url.path)
|
||||
req.body = xml
|
||||
|
||||
req.basic_auth @occiauth[0], @occiauth[1]
|
||||
|
||||
res = CloudClient::http_start(url, @timeout) do |http|
|
||||
http.request(req)
|
||||
end
|
||||
|
||||
if CloudClient::is_error?(res)
|
||||
return res
|
||||
else
|
||||
return res.body
|
||||
end
|
||||
end
|
||||
|
||||
######################################################################
|
||||
# :id VM identifier
|
||||
######################################################################
|
||||
|
||||
@@ -210,22 +210,69 @@ class OCCIServer < CloudServer
|
||||
# [return] _String_,_Integer_ Update confirmation msg or error,
|
||||
# status code
|
||||
def put_compute(request, params)
|
||||
vm = VirtualMachineOCCI.new(
|
||||
VirtualMachine.build_xml(params[:id]),
|
||||
get_client(request.env))
|
||||
|
||||
rc = vm.info
|
||||
return rc, 400 if OpenNebula.is_error?(rc)
|
||||
|
||||
xmldoc = XMLElement.build_xml(request.body, 'COMPUTE')
|
||||
vm_info = XMLElement.new(xmldoc) if xmldoc != nil
|
||||
|
||||
# Check the number of changes in the request
|
||||
image_name = nil
|
||||
image_type = nil
|
||||
vm_info.each('DISK/SAVE_AS') { |disk|
|
||||
if image_name
|
||||
error_msg = "It is only allowed one save_as per request"
|
||||
return OpenNebula::Error.new(error_msg), 400
|
||||
end
|
||||
image_name = disk.attr('.', 'name')
|
||||
image_type = disk.attr('.', 'type')
|
||||
}
|
||||
state = vm_info['STATE']
|
||||
|
||||
if image_name && state
|
||||
error_msg = "It is not allowed to change the state and save_as" <<
|
||||
" a disk in the same request"
|
||||
return OpenNebula::Error.new(error_msg), 400
|
||||
elsif image_name
|
||||
# Get the disk id
|
||||
disk_id = vm_info.attr('DISK/SAVE_AS/..', 'id')
|
||||
if disk_id.nil?
|
||||
error_msg = "DISK id attribute not specified"
|
||||
return OpenNebula::Error.new(error_msg), 400
|
||||
end
|
||||
|
||||
# --- Get the VM and Action on it ---
|
||||
if vm_info['STATE'] != nil
|
||||
vm = VirtualMachineOCCI.new(
|
||||
VirtualMachine.build_xml(params[:id]),
|
||||
get_client(request.env))
|
||||
disk_id = disk_id.to_i
|
||||
if vm["TEMPLATE/DISK[DISK_ID=\"#{disk_id}\"]/SAVE_AS"]
|
||||
error_msg = "The disk #{disk_id} is already" <<
|
||||
" suppossed to be saved"
|
||||
return OpenNebula::Error.new(error_msg), 400
|
||||
end
|
||||
|
||||
# Create a new Image to save the disk
|
||||
template = "NAME=\"#{image_name}\"\n"
|
||||
if image_type
|
||||
template << "TYPE=\"#{image_type}\"\n"
|
||||
else
|
||||
template << "TYPE=\"OS\"\n"
|
||||
end
|
||||
|
||||
rc = vm.mk_action(vm_info['STATE'])
|
||||
image = Image.new(Image.build_xml, one_client)
|
||||
|
||||
rc = image.allocate(template)
|
||||
return rc, 400 if OpenNebula.is_error?(rc)
|
||||
|
||||
rc = vm.save_as(disk_id, image.id)
|
||||
if OpenNebula.is_error?(rc)
|
||||
image.delete
|
||||
return rc, 400
|
||||
end
|
||||
elsif state
|
||||
rc = vm.mk_action(state)
|
||||
return rc, 400 if OpenNebula.is_error?(rc)
|
||||
else
|
||||
error_msg = "State not defined in the OCCI XML"
|
||||
error = OpenNebula::Error.new(error_msg)
|
||||
return error, 400
|
||||
end
|
||||
|
||||
# --- Prepare XML Response ---
|
||||
@@ -293,6 +340,34 @@ class OCCIServer < CloudServer
|
||||
|
||||
return "", 204
|
||||
end
|
||||
|
||||
# Updates a NETWORK resource
|
||||
# request:: _Hash_ hash containing the data of the request
|
||||
# [return] _String_,_Integer_ Update confirmation msg or error,
|
||||
# status code
|
||||
def put_network(request, params)
|
||||
xmldoc = XMLElement.build_xml(request.body, 'NETWORK')
|
||||
vnet_info = XMLElement.new(xmldoc) if xmldoc != nil
|
||||
|
||||
vnet = VirtualNetworkOCCI.new(
|
||||
VirtualNetwork.build_xml(params[:id]),
|
||||
get_client(request.env))
|
||||
|
||||
rc = vnet.info
|
||||
return rc, 400 if OpenNebula.is_error?(rc)
|
||||
|
||||
if vnet_info['PUBLIC'] == 'YES'
|
||||
rc = vnet.publish
|
||||
return rc, 400 if OpenNebula.is_error?(rc)
|
||||
elsif vnet_info['PUBLIC'] == 'NO'
|
||||
rc = vnet.unpublish
|
||||
return rc, 400 if OpenNebula.is_error?(rc)
|
||||
end
|
||||
|
||||
# --- Prepare XML Response ---
|
||||
vnet.info
|
||||
return to_occi_xml(vnet, 202)
|
||||
end
|
||||
|
||||
############################################################################
|
||||
# STORAGE Methods
|
||||
@@ -363,4 +438,41 @@ class OCCIServer < CloudServer
|
||||
|
||||
return "", 204
|
||||
end
|
||||
|
||||
# Updates a STORAGE resource
|
||||
# request:: _Hash_ hash containing the data of the request
|
||||
# [return] _String_,_Integer_ Update confirmation msg or error,
|
||||
# status code
|
||||
def put_storage(request, params)
|
||||
xmldoc = XMLElement.build_xml(request.body, 'STORAGE')
|
||||
image_info = XMLElement.new(xmldoc) if xmldoc != nil
|
||||
|
||||
image = ImageOCCI.new(
|
||||
Image.build_xml(params[:id]),
|
||||
get_client(request.env))
|
||||
|
||||
rc = image.info
|
||||
return rc, 400 if OpenNebula.is_error?(rc)
|
||||
|
||||
if image_info['PERSISTENT'] && image_info['PUBLIC']
|
||||
error_msg = "It is not allowed more than one change per request"
|
||||
return OpenNebula::Error.new(error_msg), 400
|
||||
elsif image_info['PERSISTENT'] == 'YES'
|
||||
rc = image.persistent
|
||||
return rc, 400 if OpenNebula.is_error?(rc)
|
||||
elsif image_info['PERSISTENT'] == 'NO'
|
||||
rc = image.nonpersistent
|
||||
return rc, 400 if OpenNebula.is_error?(rc)
|
||||
elsif image_info['PUBLIC'] == 'YES'
|
||||
rc = image.publish
|
||||
return rc, 400 if OpenNebula.is_error?(rc)
|
||||
elsif image_info['PUBLIC'] == 'NO'
|
||||
rc = image.unpublish
|
||||
return rc, 400 if OpenNebula.is_error?(rc)
|
||||
end
|
||||
|
||||
# --- Prepare XML Response ---
|
||||
image.info
|
||||
return to_occi_xml(image, 202)
|
||||
end
|
||||
end
|
||||
@@ -22,13 +22,18 @@ class VirtualMachineOCCI < VirtualMachine
|
||||
OCCI_VM = %q{
|
||||
<COMPUTE href="<%= base_url %>/compute/<%= self.id.to_s %>">
|
||||
<ID><%= self.id.to_s%></ID>
|
||||
<CPU><%= self['TEMPLATE/CPU'] %></CPU>
|
||||
<MEMORY><%= self['TEMPLATE/MEMORY'] %></MEMORY>
|
||||
<NAME><%= self.name%></NAME>
|
||||
<% if self['TEMPLATE/INSTANCE_TYPE'] %>
|
||||
<INSTANCE_TYPE><%= self['TEMPLATE/INSTANCE_TYPE'] %></INSTANCE_TYPE>
|
||||
<% end %>
|
||||
<STATE><%= self.state_str %></STATE>
|
||||
<% self.each('TEMPLATE/DISK') do |disk| %>
|
||||
<DISK>
|
||||
<DISK id="<%= disk['DISK_ID']%>">
|
||||
<% if disk['SAVE_AS'] %>
|
||||
<SAVE_AS href="<%= base_url %>/storage/<%= disk['SAVE_AS'] %>"/>
|
||||
<% end %>
|
||||
<STORAGE href="<%= base_url %>/storage/<%= disk['IMAGE_ID'] %>" name="<%= disk['IMAGE'] %>"/>
|
||||
<TYPE><%= disk['TYPE'] %></TYPE>
|
||||
<TARGET><%= disk['TARGET'] %></TARGET>
|
||||
|
||||
@@ -23,16 +23,26 @@ class VirtualNetworkOCCI < VirtualNetwork
|
||||
<NETWORK href="<%= base_url %>/network/<%= self.id.to_s %>">
|
||||
<ID><%= self.id.to_s %></ID>
|
||||
<NAME><%= self.name %></NAME>
|
||||
<% if self['TEMPLATE/DESCRIPTION'] != nil %>
|
||||
<DESCRIPTION><%= self['TEMPLATE/DESCRIPTION'] %></DESCRIPTION>
|
||||
<% end %>
|
||||
<ADDRESS><%= self['TEMPLATE/NETWORK_ADDRESS'] %></ADDRESS>
|
||||
<% if self['TEMPLATE/NETWORK_SIZE'] %>
|
||||
<SIZE><%= self['TEMPLATE/NETWORK_SIZE'] %></SIZE>
|
||||
<% end %>
|
||||
<PUBLIC><%= self['PUBLIC'] == "0" ? "NO" : "YES"%></PUBLIC>
|
||||
</NETWORK>
|
||||
}
|
||||
|
||||
ONE_NETWORK = %q{
|
||||
NAME = "<%= @vnet_info['NAME'] %>"
|
||||
TYPE = RANGED
|
||||
<% if @vnet_info['DESCRIPTION'] != nil %>
|
||||
DESCRIPTION = "<%= @vnet_info['DESCRIPTION'] %>"
|
||||
<% end %>
|
||||
<% if @vnet_info['PUBLIC'] != nil %>
|
||||
PUBLIC = "<%= @vnet_info['PUBLIC'] %>"
|
||||
<% end %>
|
||||
<% if @bridge %>
|
||||
BRIDGE = <%= @bridge %>
|
||||
<% end %>
|
||||
|
||||
@@ -151,6 +151,11 @@ delete '/network/:id' do
|
||||
treat_response(result,rc)
|
||||
end
|
||||
|
||||
put '/network/:id' do
|
||||
result,rc = $occi_server.put_network(request, params)
|
||||
treat_response(result,rc)
|
||||
end
|
||||
|
||||
get '/storage/:id' do
|
||||
result,rc = $occi_server.get_storage(request, params)
|
||||
treat_response(result,rc)
|
||||
@@ -160,3 +165,8 @@ delete '/storage/:id' do
|
||||
result,rc = $occi_server.delete_storage(request, params)
|
||||
treat_response(result,rc)
|
||||
end
|
||||
|
||||
put '/storage/:id' do
|
||||
result,rc = $occi_server.put_storage(request, params)
|
||||
treat_response(result,rc)
|
||||
end
|
||||
@@ -160,7 +160,7 @@ class RemotesCommand < SSHCommand
|
||||
cmd.run
|
||||
|
||||
if cmd.code == MAGIC_RC
|
||||
self.update_remotes(host, remote_dir, logger)
|
||||
cmd.update_remotes(host, remote_dir, logger)
|
||||
|
||||
@command = command
|
||||
cmd.run
|
||||
@@ -169,7 +169,7 @@ class RemotesCommand < SSHCommand
|
||||
cmd
|
||||
end
|
||||
|
||||
def self.update_remotes(host, remote_dir, logger=nil)
|
||||
def update_remotes(host, remote_dir, logger=nil)
|
||||
log("Remote worker node files not found")
|
||||
log("Updating remotes")
|
||||
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
begin # require 'rubygems'
|
||||
require 'rubygems'
|
||||
rescue Exception
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
require 'OpenNebula/Pool'
|
||||
|
||||
module OpenNebula
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
require 'OpenNebula/Pool'
|
||||
|
||||
module OpenNebula
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
require 'OpenNebula/Pool'
|
||||
|
||||
module OpenNebula
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
require 'OpenNebula/Pool'
|
||||
|
||||
module OpenNebula
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
require 'OpenNebula/Pool'
|
||||
require 'fileutils'
|
||||
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
require 'OpenNebula/Pool'
|
||||
|
||||
module OpenNebula
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
require 'OpenNebula/Image'
|
||||
require 'fileutils'
|
||||
require 'CommandManager'
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
# -------------------------------------------------------------------------- #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
module OpenNebula
|
||||
# The Pool class represents a generic OpenNebula Pool in XML format
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
require 'OpenNebula/Pool'
|
||||
|
||||
module OpenNebula
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
require 'OpenNebula/Pool'
|
||||
|
||||
module OpenNebula
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
require 'OpenNebula/Pool'
|
||||
|
||||
module OpenNebula
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
require 'OpenNebula/Pool'
|
||||
|
||||
module OpenNebula
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
require 'OpenNebula/Pool'
|
||||
|
||||
module OpenNebula
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
require 'OpenNebula/Pool'
|
||||
|
||||
module OpenNebula
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
# -------------------------------------------------------------------------- #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
module OpenNebula
|
||||
|
||||
@@ -91,7 +106,9 @@ module OpenNebula
|
||||
return nil
|
||||
end
|
||||
|
||||
value = element[name] if element != nil
|
||||
attribute = element.attr(name)
|
||||
|
||||
value = attribute.text if attribute != nil
|
||||
else
|
||||
element=@xml.elements[key.to_s.upcase]
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ void RequestManager::ClusterDelete::execute(
|
||||
int clid;
|
||||
ostringstream oss;
|
||||
int rc;
|
||||
|
||||
|
||||
const string method_name = "ClusterDelete";
|
||||
|
||||
/* -- RPC specific vars -- */
|
||||
@@ -74,7 +74,7 @@ void RequestManager::ClusterDelete::execute(
|
||||
}
|
||||
|
||||
// Return success
|
||||
arrayData.push_back(xmlrpc_c::value_boolean( rc == 0 )); // SUCCESS
|
||||
arrayData.push_back(xmlrpc_c::value_boolean(true)); // SUCCESS
|
||||
arrayresult = new xmlrpc_c::value_array(arrayData);
|
||||
|
||||
// Copy arrayresult into retval mem space
|
||||
|
||||
@@ -33,7 +33,7 @@ void RequestManager::HostDelete::execute(
|
||||
Host * host;
|
||||
ostringstream oss;
|
||||
int rc;
|
||||
|
||||
|
||||
const string method_name = "HostDelete";
|
||||
|
||||
/* -- RPC specific vars -- */
|
||||
@@ -79,8 +79,13 @@ void RequestManager::HostDelete::execute(
|
||||
|
||||
host->unlock();
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
goto error_host_drop;
|
||||
}
|
||||
|
||||
// All nice, return the host info to the client
|
||||
arrayData.push_back(xmlrpc_c::value_boolean( rc == 0 )); // SUCCESS
|
||||
arrayData.push_back(xmlrpc_c::value_boolean(true)); // SUCCESS
|
||||
arrayresult = new xmlrpc_c::value_array(arrayData);
|
||||
|
||||
// Copy arrayresult into retval mem space
|
||||
@@ -102,6 +107,10 @@ error_host_get:
|
||||
oss.str(get_error(method_name, "HOST", hid));
|
||||
goto error_common;
|
||||
|
||||
error_host_drop:
|
||||
oss.str(action_error(method_name, "DELETE", "HOST", hid, rc));
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
NebulaLog::log ("Rem",Log::ERROR,oss);
|
||||
|
||||
|
||||
@@ -33,14 +33,14 @@ void RequestManager::ImageDelete::execute(
|
||||
int iid;
|
||||
int uid;
|
||||
int rc;
|
||||
|
||||
|
||||
int image_owner;
|
||||
bool is_public;
|
||||
|
||||
Image * image;
|
||||
|
||||
ostringstream oss;
|
||||
|
||||
|
||||
const string method_name = "ImageDelete";
|
||||
|
||||
vector<xmlrpc_c::value> arrayData;
|
||||
@@ -60,7 +60,7 @@ void RequestManager::ImageDelete::execute(
|
||||
{
|
||||
goto error_authenticate;
|
||||
}
|
||||
|
||||
|
||||
// Get image from the ImagePool
|
||||
image = ImageDelete::ipool->get(iid,true);
|
||||
|
||||
@@ -68,12 +68,12 @@ void RequestManager::ImageDelete::execute(
|
||||
{
|
||||
goto error_image_get;
|
||||
}
|
||||
|
||||
|
||||
image_owner = image->get_uid();
|
||||
is_public = image->isPublic();
|
||||
|
||||
|
||||
image->unlock();
|
||||
|
||||
|
||||
//Authorize the operation
|
||||
if ( uid != 0 ) // uid == 0 means oneadmin
|
||||
{
|
||||
@@ -101,14 +101,13 @@ void RequestManager::ImageDelete::execute(
|
||||
|
||||
rc = ImageDelete::ipool->drop(image);
|
||||
|
||||
image->unlock();
|
||||
|
||||
if ( rc < 0 )
|
||||
{
|
||||
goto error_delete;
|
||||
|
||||
}
|
||||
|
||||
image->unlock();
|
||||
|
||||
arrayData.push_back(xmlrpc_c::value_boolean(true));
|
||||
arrayData.push_back(xmlrpc_c::value_int(iid));
|
||||
|
||||
|
||||
@@ -105,8 +105,13 @@ void RequestManager::VirtualNetworkDelete::execute(
|
||||
|
||||
vn->unlock();
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
goto error_vn_drop;
|
||||
}
|
||||
|
||||
// All nice, return the host info to the client
|
||||
arrayData.push_back(xmlrpc_c::value_boolean( rc == 0 )); // SUCCESS
|
||||
arrayData.push_back(xmlrpc_c::value_boolean(true)); // SUCCESS
|
||||
arrayresult = new xmlrpc_c::value_array(arrayData);
|
||||
|
||||
// Copy arrayresult into retval mem space
|
||||
@@ -128,6 +133,10 @@ error_vn_get:
|
||||
oss.str(get_error(method_name, "NET", nid));
|
||||
goto error_common;
|
||||
|
||||
error_vn_drop:
|
||||
oss.str(action_error(method_name, "DELETE", "NET",nid,rc));
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
NebulaLog::log ("ReM",Log::ERROR,oss);
|
||||
|
||||
|
||||
@@ -124,13 +124,13 @@ function error_message
|
||||
# Gets the host from an argument
|
||||
function arg_host
|
||||
{
|
||||
echo $1 | $SED 's/^\([^:]*\):.*$/\1/'
|
||||
echo $1 | $SED 's/^([^:]*):.*$/\1/'
|
||||
}
|
||||
|
||||
# Gets the path from an argument
|
||||
function arg_path
|
||||
{
|
||||
echo $1 | $SED 's/^[^:]*:\(.*\)$/\1/'
|
||||
echo $1 | $SED 's/^[^:]*:(.*)$/\1/'
|
||||
}
|
||||
|
||||
# Executes a command, if it fails return error message and exits
|
||||
|
||||
Reference in new issue
Block a user