mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-22 13:33:52 +03:00
Merge branch 'master' into feature-407
Conflicts: install.sh
This commit is contained in:
commit
3efc2abdc1
@ -207,6 +207,7 @@ build_scripts=[
|
||||
'src/um/SConstruct',
|
||||
'src/authm/SConstruct',
|
||||
'src/xml/SConstruct',
|
||||
'share/man/SConstruct'
|
||||
]
|
||||
|
||||
# Testing
|
||||
|
@ -458,13 +458,6 @@ private:
|
||||
*/
|
||||
void do_action(const string &name, void *args){};
|
||||
|
||||
/**
|
||||
* Base 64 encoding
|
||||
* @param in the string to encoded
|
||||
* @return a pointer to the encoded string (must be freed) or 0 in case of
|
||||
* error
|
||||
*/
|
||||
static string * base64_encode(const string& in);
|
||||
|
||||
};
|
||||
|
||||
|
@ -129,6 +129,14 @@ public:
|
||||
pthread_mutex_unlock(&mutex);
|
||||
};
|
||||
|
||||
/**
|
||||
* Function to print the object into a string in XML format
|
||||
* base64 encoded
|
||||
* @param xml the resulting XML string
|
||||
* @return a reference to the generated string
|
||||
*/
|
||||
virtual string& to_xml64(string &xml64);
|
||||
|
||||
/**
|
||||
* Function to print the object into a string in XML format
|
||||
* @param xml the resulting XML string
|
||||
|
51
include/SSLTools.h
Normal file
51
include/SSLTools.h
Normal file
@ -0,0 +1,51 @@
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* Copyright 2002-2011, 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. */
|
||||
/* -------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef SSL_TOOLS_H_
|
||||
#define SSL_TOOLS_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* The SSLTools class provides a simple interface to common SSL utils used
|
||||
* in OpenNebula
|
||||
*/
|
||||
class SSLTools
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* sha1 digest
|
||||
* @param in the string to be hashed
|
||||
* @return sha1 hash of str
|
||||
*/
|
||||
static string sha1_digest(const string& in);
|
||||
|
||||
/**
|
||||
* Base 64 encoding
|
||||
* @param in the string to encoded
|
||||
* @return a pointer to the encoded string (must be freed) or 0 in case of
|
||||
* error
|
||||
*/
|
||||
static string * base64_encode(const string& in);
|
||||
|
||||
private:
|
||||
SSLTools(){};
|
||||
~SSLTools(){};
|
||||
};
|
||||
|
||||
#endif /*SSL_TOOLS_H_*/
|
@ -94,13 +94,6 @@ public:
|
||||
**/
|
||||
static int split_secret(const string secret, string& user, string& pass);
|
||||
|
||||
/**
|
||||
* "Encrypts" the password with SHA1 digest
|
||||
* @param password
|
||||
* @return sha1 encrypted password
|
||||
*/
|
||||
static string sha1_digest(const string& pass);
|
||||
|
||||
private:
|
||||
// -------------------------------------------------------------------------
|
||||
// Friends
|
||||
|
77
install.sh
77
install.sh
@ -31,8 +31,8 @@ usage() {
|
||||
echo "Usage: install.sh [-u install_user] [-g install_group] [-k keep conf]"
|
||||
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 "-u: user that will run opennebula, defaults to user executing install.sh"
|
||||
echo "-g: group of the user that will run opennebula, defaults to user"
|
||||
echo " executing install.sh"
|
||||
echo "-k: keep configuration files of existing OpenNebula installation, useful"
|
||||
echo " when upgrading. This flag should not be set when installing"
|
||||
@ -98,7 +98,7 @@ if [ -z "$ROOT" ] ; then
|
||||
LOCK_LOCATION="/var/lock/one"
|
||||
INCLUDE_LOCATION="/usr/include"
|
||||
SHARE_LOCATION="/usr/share/one"
|
||||
MAN_LOCATION="/usr/share/man/man8"
|
||||
MAN_LOCATION="/usr/share/man/man1"
|
||||
|
||||
if [ "$CLIENT" = "yes" ]; then
|
||||
MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION"
|
||||
@ -133,7 +133,7 @@ else
|
||||
IMAGES_LOCATION="$VAR_LOCATION/images"
|
||||
INCLUDE_LOCATION="$ROOT/include"
|
||||
SHARE_LOCATION="$ROOT/share"
|
||||
MAN_LOCATION="$ROOT/share/man/man8"
|
||||
MAN_LOCATION="$ROOT/share/man/man1"
|
||||
|
||||
if [ "$CLIENT" = "yes" ]; then
|
||||
MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION"
|
||||
@ -188,15 +188,6 @@ LIB_DIRS="$LIB_LOCATION/ruby \
|
||||
$LIB_LOCATION/tm_commands/dummy \
|
||||
$LIB_LOCATION/tm_commands/lvm \
|
||||
$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/im/ganglia.d \
|
||||
$LIB_LOCATION/remotes/vmm/xen \
|
||||
$LIB_LOCATION/remotes/vmm/kvm \
|
||||
$LIB_LOCATION/remotes/image \
|
||||
$LIB_LOCATION/remotes/image/fs \
|
||||
$LIB_LOCATION/sh"
|
||||
|
||||
VAR_DIRS="$VAR_LOCATION/remotes \
|
||||
@ -260,10 +251,8 @@ INSTALL_FILES=(
|
||||
RUBY_LIB_FILES:$LIB_LOCATION/ruby
|
||||
RUBY_OPENNEBULA_LIB_FILES:$LIB_LOCATION/ruby/OpenNebula
|
||||
MAD_RUBY_LIB_FILES:$LIB_LOCATION/ruby
|
||||
MAD_RUBY_LIB_FILES:$LIB_LOCATION/remotes
|
||||
MAD_RUBY_LIB_FILES:$VAR_LOCATION/remotes
|
||||
MAD_SH_LIB_FILES:$LIB_LOCATION/sh
|
||||
MAD_SH_LIB_FILES:$LIB_LOCATION/remotes
|
||||
MAD_SH_LIB_FILES:$VAR_LOCATION/remotes
|
||||
ONEDB_MIGRATOR_FILES:$LIB_LOCATION/onedb
|
||||
MADS_LIB_FILES:$LIB_LOCATION/mads
|
||||
@ -277,23 +266,13 @@ INSTALL_FILES=(
|
||||
VMM_SSH_XEN_KVM_POLL:$VAR_LOCATION/remotes/vmm/xen/poll
|
||||
VMM_SSH_GANGLIA_POLL:$VAR_LOCATION/remotes/vmm/kvm/poll_local
|
||||
VMM_SSH_GANGLIA_POLL:$VAR_LOCATION/remotes/vmm/xen/poll_local
|
||||
IM_PROBES_FILES:$LIB_LOCATION/remotes/im
|
||||
IM_PROBES_KVM_FILES:$LIB_LOCATION/remotes/im/kvm.d
|
||||
IM_PROBES_XEN_FILES:$LIB_LOCATION/remotes/im/xen.d
|
||||
IM_PROBES_GANGLIA_FILES:$LIB_LOCATION/remotes/im/ganglia.d
|
||||
VMM_SSH_KVM_SCRIPTS:$LIB_LOCATION/remotes/vmm/kvm
|
||||
VMM_SSH_XEN_SCRIPTS:$LIB_LOCATION/remotes/vmm/xen
|
||||
VMM_SSH_XEN_KVM_POLL:$LIB_LOCATION/remotes/vmm/kvm/poll
|
||||
VMM_SSH_XEN_KVM_POLL:$LIB_LOCATION/remotes/vmm/xen/poll
|
||||
VMM_SSH_GANGLIA_POLL:$LIB_LOCATION/remotes/vmm/kvm/poll_local
|
||||
VMM_SSH_GANGLIA_POLL:$LIB_LOCATION/remotes/vmm/xen/poll_local
|
||||
NFS_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/nfs
|
||||
SSH_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/ssh
|
||||
DUMMY_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/dummy
|
||||
LVM_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/lvm
|
||||
IMAGE_DRIVER_FS_SCRIPTS:$LIB_LOCATION/remotes/image/fs
|
||||
IMAGE_DRIVER_FS_SCRIPTS:$VAR_LOCATION/remotes/image/fs
|
||||
EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples
|
||||
INSTALL_NOVNC_SHARE_FILE:$SHARE_LOCATION
|
||||
TM_EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples/tm
|
||||
HOOK_SHARE_FILES:$SHARE_LOCATION/hooks
|
||||
COMMON_CLOUD_LIB_FILES:$LIB_LOCATION/ruby/cloud
|
||||
@ -355,6 +334,7 @@ INSTALL_ETC_FILES=(
|
||||
ECO_ETC_TEMPLATE_FILES:$ETC_LOCATION/ec2query_templates
|
||||
OCCI_ETC_FILES:$ETC_LOCATION
|
||||
OCCI_ETC_TEMPLATE_FILES:$ETC_LOCATION/occi_templates
|
||||
SUNSTONE_ETC_FILES:$ETC_LOCATION
|
||||
)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
@ -654,6 +634,8 @@ HOOK_SHARE_FILES="share/hooks/ebtables-xen \
|
||||
share/hooks/host_error.rb \
|
||||
share/hooks/image.rb"
|
||||
|
||||
INSTALL_NOVNC_SHARE_FILE="share/install_novnc.sh"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Common Cloud Files
|
||||
#-------------------------------------------------------------------------------
|
||||
@ -760,6 +742,8 @@ SUNSTONE_FILES="src/sunstone/config.ru \
|
||||
|
||||
SUNSTONE_BIN_FILES="src/sunstone/bin/sunstone-server"
|
||||
|
||||
SUNSTONE_ETC_FILES="src/sunstone/etc/sunstone-server.conf"
|
||||
|
||||
SUNSTONE_MODELS_FILES="src/sunstone/models/OpenNebulaJSON.rb \
|
||||
src/sunstone/models/SunstoneServer.rb"
|
||||
|
||||
@ -844,7 +828,9 @@ SUNSTONE_PUBLIC_IMAGES_FILES="src/sunstone/public/images/ajax-loader.gif \
|
||||
src/sunstone/public/images/opennebula-sunstone-small.png \
|
||||
src/sunstone/public/images/panel.png \
|
||||
src/sunstone/public/images/pbar.gif \
|
||||
src/sunstone/public/images/Refresh-icon.png"
|
||||
src/sunstone/public/images/Refresh-icon.png \
|
||||
src/sunstone/public/images/vnc_off.png \
|
||||
src/sunstone/public/images/vnc_on.png"
|
||||
|
||||
SUNSTONE_RUBY_LIB_FILES="src/mad/ruby/CommandManager.rb \
|
||||
src/oca/ruby/OpenNebula.rb"
|
||||
@ -853,25 +839,24 @@ SUNSTONE_RUBY_LIB_FILES="src/mad/ruby/CommandManager.rb \
|
||||
# MAN files
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
MAN_FILES="share/man/oneauth.8.gz \
|
||||
share/man/onecluster.8.gz \
|
||||
share/man/onehost.8.gz \
|
||||
share/man/oneimage.8.gz \
|
||||
share/man/oneuser.8.gz \
|
||||
share/man/onevm.8.gz \
|
||||
share/man/onevnet.8.gz \
|
||||
share/man/onetemplate.8.gz \
|
||||
share/man/onegroup.8.gz \
|
||||
share/man/onedb.8.gz \
|
||||
share/man/econe-describe-images.8.gz \
|
||||
share/man/econe-describe-instances.8.gz \
|
||||
share/man/econe-register.8.gz \
|
||||
share/man/econe-run-instances.8.gz \
|
||||
share/man/econe-terminate-instances.8.gz \
|
||||
share/man/econe-upload.8.gz \
|
||||
share/man/occi-compute.8.gz \
|
||||
share/man/occi-network.8.gz \
|
||||
share/man/occi-storage.8.gz"
|
||||
MAN_FILES="share/man/oneauth.1.gz \
|
||||
share/man/onecluster.1.gz \
|
||||
share/man/onehost.1.gz \
|
||||
share/man/oneimage.1.gz \
|
||||
share/man/oneuser.1.gz \
|
||||
share/man/onevm.1.gz \
|
||||
share/man/onevnet.1.gz \
|
||||
share/man/onetemplate.1.gz \
|
||||
share/man/onedb.1.gz \
|
||||
share/man/econe-describe-images.1.gz \
|
||||
share/man/econe-describe-instances.1.gz \
|
||||
share/man/econe-register.1.gz \
|
||||
share/man/econe-run-instances.1.gz \
|
||||
share/man/econe-terminate-instances.1.gz \
|
||||
share/man/econe-upload.1.gz \
|
||||
share/man/occi-compute.1.gz \
|
||||
share/man/occi-network.1.gz \
|
||||
share/man/occi-storage.1.gz"
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#-----------------------------------------------------------------------------
|
||||
|
@ -323,11 +323,9 @@ IMAGE_MAD = [
|
||||
# command : path can be absolute or relative to $ONE_LOCATION/share/hooks
|
||||
# case of self-contained installation or relative to
|
||||
# /usr/share/one/hooks in case of system-wide installation
|
||||
# arguments : for the hook. You can access to VM template variables with $
|
||||
# - $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"]
|
||||
# arguments : for the hook. You can access to VM information with $
|
||||
# - $VMID, the ID of the virtual machine
|
||||
# - $TEMPLATE, the VM template in xml and base64 encoded
|
||||
# remote : values,
|
||||
# - YES, The hook is executed in the host where the VM was
|
||||
# allocated
|
||||
@ -343,8 +341,9 @@ IMAGE_MAD = [
|
||||
# command : path can be absolute or relative to $ONE_LOCATION/share/hooks
|
||||
# case of self-contained installation or relative to
|
||||
# /usr/share/one/hooks in case of system-wide installation
|
||||
# arguments : for the hook. You can use the Host ID with $HID to pass it as
|
||||
# argument for the hook
|
||||
# arguments : for the hook. You can use the following Host information:
|
||||
# - $HID, the ID of the host
|
||||
# - $TEMPLATE, the Host template in xml and base64 encoded
|
||||
# remote : values,
|
||||
# - YES, The hook is executed in the host
|
||||
# - NO, The hook is executed in the OpenNebula server (default)
|
||||
|
37
share/install_novnc.sh
Executable file
37
share/install_novnc.sh
Executable file
@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
|
||||
NOVNC_TMP=/tmp/one/novnc-$(date "+%Y%m%d%H%M%S")
|
||||
|
||||
if [ -z "$ONE_LOCATION" ]; then
|
||||
ONE_SHARE=/usr/share/one
|
||||
ONE_PUBLIC_SUNSTONE=/usr/lib/one/sunstone/public
|
||||
SUNSTONE_CONF=/etc/one/sunstone-server.conf
|
||||
else
|
||||
ONE_SHARE=$ONE_LOCATION/share
|
||||
ONE_PUBLIC_SUNSTONE=$ONE_LOCATION/lib/sunstone/public
|
||||
SUNSTONE_CONF=$ONE_LOCATION/etc/sunstone-server.conf
|
||||
fi
|
||||
|
||||
mkdir -p $NOVNC_TMP
|
||||
wget -P $NOVNC_TMP --no-check-certificate http://github.com/kanaka/noVNC/tarball/master
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error downloading noVNC"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
tar=`ls -rt $NOVNC_TMP|tail -n1`
|
||||
tar -C $ONE_SHARE -mxvzf $NOVNC_TMP/$tar
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error untaring noVNC"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dir=`ls -rt $ONE_SHARE|tail -n1`
|
||||
mv $ONE_SHARE/$dir $ONE_SHARE/noVNC
|
||||
|
||||
mkdir -p $ONE_PUBLIC_SUNSTONE/vendor/noVNC
|
||||
mv $ONE_SHARE/noVNC/include/ $ONE_PUBLIC_SUNSTONE/vendor/noVNC/
|
||||
|
||||
sed -i "s%^\(NOVNC_PATH=\).*$%\1$ONE_SHARE/noVNC%" $SUNSTONE_CONF
|
44
share/man/SConstruct
Normal file
44
share/man/SConstruct
Normal file
@ -0,0 +1,44 @@
|
||||
# SConstruct for share/man
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2011, 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
Import('env')
|
||||
|
||||
gzip_bld = Builder(action = 'gzip -c $SOURCE > $TARGET',
|
||||
suffix = '.1.gz',
|
||||
src_suffix = '.1')
|
||||
|
||||
env.Append(BUILDERS = {'Man' : gzip_bld})
|
||||
|
||||
env.Man('econe-describe-images')
|
||||
env.Man('econe-describe-instances')
|
||||
env.Man('econe-register')
|
||||
env.Man('econe-run-instances')
|
||||
env.Man('econe-terminate-instances')
|
||||
env.Man('econe-upload')
|
||||
env.Man('occi-compute')
|
||||
env.Man('occi-network')
|
||||
env.Man('occi-storage')
|
||||
env.Man('oneauth')
|
||||
env.Man('onecluster')
|
||||
env.Man('onedb')
|
||||
env.Man('onehost')
|
||||
env.Man('oneimage')
|
||||
env.Man('onetemplate')
|
||||
env.Man('oneuser')
|
||||
env.Man('onevm')
|
||||
env.Man('onevnet')
|
0
share/man/econe-describe-images.1
Normal file
0
share/man/econe-describe-images.1
Normal file
Binary file not shown.
0
share/man/econe-describe-instances.1
Normal file
0
share/man/econe-describe-instances.1
Normal file
Binary file not shown.
0
share/man/econe-register.1
Normal file
0
share/man/econe-register.1
Normal file
Binary file not shown.
0
share/man/econe-run-instances.1
Normal file
0
share/man/econe-run-instances.1
Normal file
Binary file not shown.
0
share/man/econe-terminate-instances.1
Normal file
0
share/man/econe-terminate-instances.1
Normal file
Binary file not shown.
0
share/man/econe-upload.1
Normal file
0
share/man/econe-upload.1
Normal file
Binary file not shown.
0
share/man/occi-compute.1
Normal file
0
share/man/occi-compute.1
Normal file
Binary file not shown.
0
share/man/occi-network.1
Normal file
0
share/man/occi-network.1
Normal file
Binary file not shown.
0
share/man/occi-storage.1
Normal file
0
share/man/occi-storage.1
Normal file
Binary file not shown.
0
share/man/oneauth.1
Normal file
0
share/man/oneauth.1
Normal file
Binary file not shown.
76
share/man/onecluster.1
Normal file
76
share/man/onecluster.1
Normal file
@ -0,0 +1,76 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
|
||||
.TH OPENNEBULAPRO "1" "May 2011" "OpenNebulaPro 2.2.0" "User Commands"
|
||||
.SH NAME
|
||||
OpenNebulaPro \- OpenNebula Cluster command
|
||||
.SH SYNOPSIS
|
||||
.B onecluster
|
||||
[\fI<options>\fR] \fI<command> \fR[\fI<parameters>\fR]
|
||||
.SH DESCRIPTION
|
||||
|
||||
This command enables the OpenNebula administrator to manage clusters. The
|
||||
administrator can create, delete, as well as add and remove hosts from them.
|
||||
Any user can list available clusters.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-l\fR, \fB\-\-list\fR x,y,z
|
||||
Selects columns to display with list
|
||||
command
|
||||
.TP
|
||||
\fB\-\-list\-columns\fR
|
||||
Information about the columns available
|
||||
to display, order or filter
|
||||
.TP
|
||||
\fB\-o\fR, \fB\-\-order\fR x,y,z
|
||||
Order by these columns, column starting
|
||||
with \- means decreasing order
|
||||
.TP
|
||||
\fB\-f\fR, \fB\-\-filter\fR x,y,z
|
||||
Filter data. An array is specified
|
||||
with column=value pairs.
|
||||
.TP
|
||||
\fB\-x\fR, \fB\-\-xml\fR
|
||||
Returns xml instead of human readable text
|
||||
.TP
|
||||
\fB\-v\fR, \fB\-\-verbose\fR
|
||||
Tells more information if the command
|
||||
is successful
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Shows this help message
|
||||
.TP
|
||||
\fB\-\-version\fR
|
||||
Shows version and copyright information
|
||||
.SH COMMANDS
|
||||
.TP
|
||||
\fBcreate\fR (Creates a new cluster)
|
||||
.IP
|
||||
onecluster create clustername
|
||||
.TP
|
||||
\fBdelete\fR (Removes a cluster)
|
||||
.IP
|
||||
onecluster delete <id>
|
||||
.TP
|
||||
\fBlist\fR (Lists all the clusters in the pool)
|
||||
.IP
|
||||
onecluster list
|
||||
.TP
|
||||
\fBaddhost\fR (Add a host to the cluster)
|
||||
.IP
|
||||
onecluster addhost <host_id> <cluster_id>
|
||||
.TP
|
||||
\fBremovehost\fR (Remove a host from the cluster)
|
||||
.IP
|
||||
onecluster removehost <host_id> <cluster_id>
|
||||
.SH COPYRIGHT
|
||||
Copyright 2010\-2011, C12G Labs S.L.
|
||||
.PP
|
||||
Licensed under the C12G Commercial Open\-source License (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License as part
|
||||
of the software distribution.
|
||||
.PP
|
||||
Unless 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.
|
Binary file not shown.
97
share/man/onedb.1
Normal file
97
share/man/onedb.1
Normal file
@ -0,0 +1,97 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
|
||||
.TH OPENNEBULAPRO "1" "May 2011" "OpenNebulaPro 2.2.0" "User Commands"
|
||||
.SH NAME
|
||||
OpenNebulaPro \- OpenNebula Database command
|
||||
.SH SYNOPSIS
|
||||
.B onedb
|
||||
[\fI<options>\fR] \fI<command> \fR[\fI<parameters>\fR]
|
||||
.SH DESCRIPTION
|
||||
|
||||
This command enables the user to manage the OpenNebula database. It provides
|
||||
information about the DB version, means to upgrade it to the latest version, and
|
||||
backup tools.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-v\fR, \fB\-\-verbose\fR
|
||||
Tells more information if the command
|
||||
is successful
|
||||
.TP
|
||||
\fB\-f\fR, \fB\-\-force\fR
|
||||
Forces the backup even if the DB exists
|
||||
.TP
|
||||
\fB\-\-backup\fR file
|
||||
Use this file to store/read SQL dump
|
||||
.TP
|
||||
\fB\-s\fR, \fB\-\-sqlite\fR file
|
||||
SQLite DB file
|
||||
.TP
|
||||
\fB\-\-server\fR host
|
||||
MySQL server hostname or IP. Defaults to localhost
|
||||
.TP
|
||||
\fB\-\-port\fR port
|
||||
MySQL server port. Defaults to 3306
|
||||
.TP
|
||||
\fB\-\-user\fR username
|
||||
MySQL username
|
||||
.TP
|
||||
\fB\-\-passwd\fR password
|
||||
MySQL password. Leave unset to be prompted for it
|
||||
.TP
|
||||
\fB\-\-dbname\fR name
|
||||
MySQL DB name for OpenNebula
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Shows this help message
|
||||
.TP
|
||||
\fB\-\-version\fR
|
||||
Shows version and copyright information
|
||||
.PP
|
||||
DB Connection options:
|
||||
.PP
|
||||
By default, onedb reads the connection data from oned.conf
|
||||
If any of these options is set, oned.conf is ignored (i.e. if you set MySQL's
|
||||
port onedb won't look for the rest of the options in oned.conf)
|
||||
.SH COMMANDS
|
||||
.TP
|
||||
\fBupgrade\fR (Upgrades the DB to the latest version)
|
||||
.IP
|
||||
onedb upgrade [<version>]
|
||||
.IP
|
||||
where <version> : DB version (e.g. 1, 3) to upgrade. By default the DB is
|
||||
.IP
|
||||
upgraded to the latest version
|
||||
.TP
|
||||
\fBversion\fR (Prints the current DB version. Use \fB\-v\fR flag to see also OpenNebula version)
|
||||
.IP
|
||||
onedb version
|
||||
.TP
|
||||
\fBhistory\fR (Prints the upgrades history)
|
||||
.IP
|
||||
onedb history
|
||||
.TP
|
||||
\fBbackup\fR (Dumps the DB to a file)
|
||||
.IP
|
||||
onedb backup [<output_file>]
|
||||
.IP
|
||||
where <output_file> : Same as \fB\-\-backup\fR
|
||||
.TP
|
||||
\fBrestore\fR (Restores the DB from a backup file. Only restores backups generated
|
||||
.IP
|
||||
from the same backend (SQLite or MySQL))
|
||||
.IP
|
||||
onedb restore [<backup_file>]
|
||||
.IP
|
||||
where <backup_file> : Same as \fB\-\-backup\fR
|
||||
.SH COPYRIGHT
|
||||
Copyright 2010\-2011, C12G Labs S.L.
|
||||
.PP
|
||||
Licensed under the C12G Commercial Open\-source License (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License as part
|
||||
of the software distribution.
|
||||
.PP
|
||||
Unless 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.
|
112
share/man/onehost.1
Normal file
112
share/man/onehost.1
Normal file
@ -0,0 +1,112 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
|
||||
.TH OPENNEBULAPRO "1" "May 2011" "OpenNebulaPro 2.2.0" "User Commands"
|
||||
.SH NAME
|
||||
OpenNebulaPro \- OpenNebula Host command
|
||||
.SH SYNOPSIS
|
||||
.B onehost
|
||||
[\fI<options>\fR] \fI<command> \fR[\fI<parameters>\fR]
|
||||
.SH DESCRIPTION
|
||||
|
||||
This command enables the user to manage hosts in the Open Nebula server. It
|
||||
provides functionality to allocate, get information and delete a particular
|
||||
host or to list all the available hosts.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-l\fR, \fB\-\-list\fR x,y,z
|
||||
Selects columns to display with list
|
||||
command
|
||||
.TP
|
||||
\fB\-\-list\-columns\fR
|
||||
Information about the columns available
|
||||
to display, order or filter
|
||||
.TP
|
||||
\fB\-o\fR, \fB\-\-order\fR x,y,z
|
||||
Order by these columns, column starting
|
||||
with \- means decreasing order
|
||||
.TP
|
||||
\fB\-f\fR, \fB\-\-filter\fR x,y,z
|
||||
Filter data. An array is specified
|
||||
with column=value pairs.
|
||||
.TP
|
||||
\fB\-d\fR, \fB\-\-delay\fR seconds
|
||||
Sets the delay in seconds for top
|
||||
command
|
||||
.TP
|
||||
\fB\-x\fR, \fB\-\-xml\fR
|
||||
Returns xml instead of human readable text
|
||||
.TP
|
||||
\fB\-v\fR, \fB\-\-verbose\fR
|
||||
Tells more information if the command
|
||||
is successful
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Shows this help message
|
||||
.TP
|
||||
\fB\-\-version\fR
|
||||
Shows version and copyright information
|
||||
.SH COMMANDS
|
||||
.TP
|
||||
\fBcreate\fR (Adds a new machine to the pool)
|
||||
.IP
|
||||
onehost create <hostname> <im_mad> <vmm_mad> <tm_mad>
|
||||
.TP
|
||||
\fBshow\fR (Gets info from a host)
|
||||
.IP
|
||||
onehost show <host_id>
|
||||
.TP
|
||||
\fBdelete\fR (Removes a machine from the pool)
|
||||
.IP
|
||||
onehost delete <host_id>
|
||||
.TP
|
||||
\fBlist\fR (Lists machines in the pool)
|
||||
.IP
|
||||
onehost list
|
||||
.TP
|
||||
\fBenable\fR (Enables host)
|
||||
.IP
|
||||
onehost enable <host_id>
|
||||
.TP
|
||||
\fBdisable\fR (Disables host)
|
||||
.IP
|
||||
onehost disable <host_id>
|
||||
.TP
|
||||
\fBtop\fR (Lists hosts continuously)
|
||||
.IP
|
||||
onehost top
|
||||
.TP
|
||||
\fBsync\fR (synchronizes probes with remote hosts)
|
||||
.IP
|
||||
onehost sync
|
||||
.PP
|
||||
Information Columns:
|
||||
.TP
|
||||
\fBHID\fR Host ID
|
||||
.TP
|
||||
\fBNAME\fR Host name
|
||||
.TP
|
||||
\fBRVM\fR Number of running VMs
|
||||
.TP
|
||||
\fBTCPU\fR Total CPU (percentage)
|
||||
.TP
|
||||
\fBFCPU\fR Free CPU (percentage)
|
||||
.TP
|
||||
\fBACPU\fR Available CPU (not allocated by VMs)
|
||||
.TP
|
||||
\fBTMEM\fR Total memory
|
||||
.TP
|
||||
\fBFMEM\fR Free memory
|
||||
.TP
|
||||
\fBSTAT\fR Host status
|
||||
.SH COPYRIGHT
|
||||
Copyright 2010\-2011, C12G Labs S.L.
|
||||
.PP
|
||||
Licensed under the C12G Commercial Open\-source License (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License as part
|
||||
of the software distribution.
|
||||
.PP
|
||||
Unless 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.
|
Binary file not shown.
133
share/man/oneimage.1
Normal file
133
share/man/oneimage.1
Normal file
@ -0,0 +1,133 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
|
||||
.TH OPENNEBULAPRO "1" "May 2011" "OpenNebulaPro 2.2.0" "User Commands"
|
||||
.SH NAME
|
||||
OpenNebulaPro \- OpenNebula Image command
|
||||
.SH SYNOPSIS
|
||||
.B oneimage
|
||||
[\fI<options>\fR] \fI<command> \fR[\fI<parameters>\fR]
|
||||
.SH DESCRIPTION
|
||||
|
||||
This command enables the user to manage images.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-l\fR, \fB\-\-list\fR x,y,z
|
||||
Selects columns to display with list
|
||||
command
|
||||
.TP
|
||||
\fB\-\-list\-columns\fR
|
||||
Information about the columns available
|
||||
to display, order or filter
|
||||
.TP
|
||||
\fB\-o\fR, \fB\-\-order\fR x,y,z
|
||||
Order by these columns, column starting
|
||||
with \- means decreasing order
|
||||
.TP
|
||||
\fB\-f\fR, \fB\-\-filter\fR x,y,z
|
||||
Filter data. An array is specified
|
||||
with column=value pairs.
|
||||
.TP
|
||||
\fB\-d\fR, \fB\-\-delay\fR seconds
|
||||
Sets the delay in seconds for top
|
||||
command
|
||||
.TP
|
||||
\fB\-x\fR, \fB\-\-xml\fR
|
||||
Returns xml instead of human readable text
|
||||
.TP
|
||||
\fB\-v\fR, \fB\-\-verbose\fR
|
||||
Tells more information if the command
|
||||
is successful
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Shows this help message
|
||||
.TP
|
||||
\fB\-\-version\fR
|
||||
Shows version and copyright information
|
||||
.SH COMMANDS
|
||||
.TP
|
||||
\fBregister\fR (Registers an image, copying it to the repository if it applies)
|
||||
.IP
|
||||
oneimage register <template>
|
||||
.IP
|
||||
template is a file name where the Image description is located
|
||||
.TP
|
||||
\fBaddattr\fR (Add a new image attribute)
|
||||
.IP
|
||||
oneimage addattr <image_id> <attribute_name> <attribute_value>
|
||||
.TP
|
||||
\fBupdate\fR (Modifies an image attribute)
|
||||
.IP
|
||||
oneimage update <image_id> <attribute_name> <attribute_value>
|
||||
.TP
|
||||
\fBrmattr\fR (Deletes an Image attribute)
|
||||
.IP
|
||||
oneimage rmattr <image_id> <attribute_name>
|
||||
.TP
|
||||
\fBenable\fR (Enabled an Image)
|
||||
.IP
|
||||
oneimage enable <image_id>
|
||||
.TP
|
||||
\fBdisable\fR (Disabled an Image)
|
||||
.IP
|
||||
oneimage disable <image_id>
|
||||
.TP
|
||||
\fBpublish\fR (Publish an Image)
|
||||
.IP
|
||||
oneimage publish <image_id>
|
||||
.TP
|
||||
\fBunpublish\fR (Unpublish an Image)
|
||||
.IP
|
||||
oneimage unpublish <image_id>
|
||||
.TP
|
||||
\fBpersistent\fR (Makes an Image persistent)
|
||||
.IP
|
||||
oneimage persistent <image_id>
|
||||
.TP
|
||||
\fBnonpersistent\fR (Makes an Image non persistent)
|
||||
.IP
|
||||
oneimage nonpersistent <image_id>
|
||||
.TP
|
||||
\fBlist\fR (Shows Images in the pool)
|
||||
.IP
|
||||
oneimage list <filter_flag>
|
||||
.IP
|
||||
where filter_flag can be
|
||||
.TP
|
||||
a, all
|
||||
\fB\-\-\fR> all the known Images
|
||||
.TP
|
||||
m, mine
|
||||
\fB\-\-\fR> the Images belonging to the user in ONE_AUTH
|
||||
.TP
|
||||
and all the
|
||||
Public Images
|
||||
.TP
|
||||
uid
|
||||
\fB\-\-\fR> Images of the user identified by this uid
|
||||
.TP
|
||||
user
|
||||
\fB\-\-\fR> Images of the user identified by the username
|
||||
.TP
|
||||
\fBtop\fR (Lists Images continuously)
|
||||
.IP
|
||||
oneimage top
|
||||
.TP
|
||||
\fBshow\fR (Gets information about an specific Image)
|
||||
.IP
|
||||
oneimage show <image_id>
|
||||
.TP
|
||||
\fBdelete\fR (Deletes an already deployed Image)
|
||||
.IP
|
||||
oneimage delete <image_id>
|
||||
.SH COPYRIGHT
|
||||
Copyright 2010\-2011, C12G Labs S.L.
|
||||
.PP
|
||||
Licensed under the C12G Commercial Open\-source License (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License as part
|
||||
of the software distribution.
|
||||
.PP
|
||||
Unless 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.
|
Binary file not shown.
117
share/man/onetemplate.1
Normal file
117
share/man/onetemplate.1
Normal file
@ -0,0 +1,117 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
|
||||
.TH OPENNEBULAPRO "1" "May 2011" "OpenNebulaPro 2.2.0" "User Commands"
|
||||
.SH NAME
|
||||
OpenNebulaPro \- OpenNebula Template command
|
||||
.SH SYNOPSIS
|
||||
.B onetemplate
|
||||
[\fI<options>\fR] \fI<command> \fR[\fI<parameters>\fR]
|
||||
.SH DESCRIPTION
|
||||
|
||||
This command enables the user to manage templates.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-l\fR, \fB\-\-list\fR x,y,z
|
||||
Selects columns to display with list
|
||||
command
|
||||
.TP
|
||||
\fB\-\-list\-columns\fR
|
||||
Information about the columns available
|
||||
to display, order or filter
|
||||
.TP
|
||||
\fB\-o\fR, \fB\-\-order\fR x,y,z
|
||||
Order by these columns, column starting
|
||||
with \- means decreasing order
|
||||
.TP
|
||||
\fB\-f\fR, \fB\-\-filter\fR x,y,z
|
||||
Filter data. An array is specified
|
||||
with column=value pairs.
|
||||
.TP
|
||||
\fB\-d\fR, \fB\-\-delay\fR seconds
|
||||
Sets the delay in seconds for top
|
||||
command
|
||||
.TP
|
||||
\fB\-x\fR, \fB\-\-xml\fR
|
||||
Returns xml instead of human readable text
|
||||
.TP
|
||||
\fB\-v\fR, \fB\-\-verbose\fR
|
||||
Tells more information if the command
|
||||
is successful
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Shows this help message
|
||||
.TP
|
||||
\fB\-\-version\fR
|
||||
Shows version and copyright information
|
||||
.SH COMMANDS
|
||||
.TP
|
||||
\fBcreate\fR (Registers a Template from a template file)
|
||||
.IP
|
||||
onetemplate create <file>
|
||||
.IP
|
||||
file is a file name where the Template description is located
|
||||
.TP
|
||||
\fBaddattr\fR (Add a new Template attribute)
|
||||
.IP
|
||||
onetemplate addattr <template_id> <attribute_name> <attribute_value>
|
||||
.TP
|
||||
\fBupdate\fR (Modifies a Template attribute)
|
||||
.IP
|
||||
onetemplate update <template_id> <attribute_name> <attribute_value>
|
||||
.TP
|
||||
\fBrmattr\fR (Deletes a Template attribute)
|
||||
.IP
|
||||
onetemplate rmattr <template_id> <attribute_name>
|
||||
.TP
|
||||
\fBpublish\fR (Publish a Template)
|
||||
.IP
|
||||
onetemplate publish <template_id>
|
||||
.TP
|
||||
\fBunpublish\fR (Unpublish an Template)
|
||||
.IP
|
||||
onetemplate unpublish <template_id>
|
||||
.TP
|
||||
\fBlist\fR (Shows Templates in the pool)
|
||||
.IP
|
||||
onetemplate list <filter_flag>
|
||||
.IP
|
||||
where filter_flag can be
|
||||
.TP
|
||||
a, all
|
||||
\fB\-\-\fR> all the known Templates
|
||||
.TP
|
||||
m, mine
|
||||
\fB\-\-\fR> the Templates belonging to the user in ONE_AUTH
|
||||
.TP
|
||||
and all the
|
||||
Public Templates
|
||||
.TP
|
||||
uid
|
||||
\fB\-\-\fR> Templates of the user identified by this uid
|
||||
.TP
|
||||
user
|
||||
\fB\-\-\fR> Templates of the user identified by the username
|
||||
.TP
|
||||
\fBtop\fR (Lists Templates continuously)
|
||||
.IP
|
||||
onetemplate top
|
||||
.TP
|
||||
\fBshow\fR (Gets information about an specific Template)
|
||||
.IP
|
||||
onetemplate show <template_id>
|
||||
.TP
|
||||
\fBdelete\fR (Deletes a Template)
|
||||
.IP
|
||||
onetemplate delete <template_id>
|
||||
.SH COPYRIGHT
|
||||
Copyright 2010\-2011, C12G Labs S.L.
|
||||
.PP
|
||||
Licensed under the C12G Commercial Open\-source License (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License as part
|
||||
of the software distribution.
|
||||
.PP
|
||||
Unless 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.
|
90
share/man/oneuser.1
Normal file
90
share/man/oneuser.1
Normal file
@ -0,0 +1,90 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
|
||||
.TH OPENNEBULAPRO "1" "May 2011" "OpenNebulaPro 2.2.0" "User Commands"
|
||||
.SH NAME
|
||||
OpenNebulaPro \- OpenNebula User command
|
||||
.SH SYNOPSIS
|
||||
.B oneuser
|
||||
[\fI<options>\fR] \fI<command> \fR[\fI<parameters>\fR]
|
||||
.SH DESCRIPTION
|
||||
|
||||
This command enables the OpenNebula administrator to manage users, adding,
|
||||
listing and deleting them.
|
||||
.PP
|
||||
The create and passwd commands accept the [\-r, \fB\-\-read\-file]\fR option. Use this
|
||||
option to store the contents of a file (without hashing it) as the password.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-l\fR, \fB\-\-list\fR x,y,z
|
||||
Selects columns to display with list
|
||||
command
|
||||
.TP
|
||||
\fB\-\-list\-columns\fR
|
||||
Information about the columns available
|
||||
to display, order or filter
|
||||
.TP
|
||||
\fB\-o\fR, \fB\-\-order\fR x,y,z
|
||||
Order by these columns, column starting
|
||||
with \- means decreasing order
|
||||
.TP
|
||||
\fB\-f\fR, \fB\-\-filter\fR x,y,z
|
||||
Filter data. An array is specified
|
||||
with column=value pairs.
|
||||
.TP
|
||||
\fB\-x\fR, \fB\-\-xml\fR
|
||||
Returns xml instead of human readable text
|
||||
.TP
|
||||
\fB\-v\fR, \fB\-\-verbose\fR
|
||||
Tells more information if the command
|
||||
is successful
|
||||
.TP
|
||||
\fB\-n\fR, \fB\-\-no\-hash\fR
|
||||
Store plain password into the database
|
||||
.TP
|
||||
\fB\-r\fR, \fB\-\-read\-file\fR
|
||||
Read password from file
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Shows this help message
|
||||
.TP
|
||||
\fB\-\-version\fR
|
||||
Shows version and copyright information
|
||||
.SH COMMANDS
|
||||
.TP
|
||||
\fBcreate\fR (Creates a new user)
|
||||
.IP
|
||||
oneuser create username password
|
||||
.TP
|
||||
\fBdelete\fR (Removes a user)
|
||||
.IP
|
||||
oneuser delete <id>
|
||||
.TP
|
||||
\fBlist\fR (Lists all the users in the pool)
|
||||
.IP
|
||||
oneuser list
|
||||
.TP
|
||||
\fBpasswd\fR (Changes the given user's password)
|
||||
.IP
|
||||
oneuser passwd <id> password
|
||||
.PP
|
||||
Information Columns:
|
||||
.TP
|
||||
\fBUID\fR User ID
|
||||
.TP
|
||||
\fBNAME\fR Name of the user
|
||||
.TP
|
||||
\fBPASSWORD\fR SHA1 encrypted password
|
||||
.TP
|
||||
\fBENABLE\fR Whether the user is enabled or not
|
||||
.SH COPYRIGHT
|
||||
Copyright 2010\-2011, C12G Labs S.L.
|
||||
.PP
|
||||
Licensed under the C12G Commercial Open\-source License (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License as part
|
||||
of the software distribution.
|
||||
.PP
|
||||
Unless 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.
|
Binary file not shown.
235
share/man/onevm.1
Normal file
235
share/man/onevm.1
Normal file
@ -0,0 +1,235 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
|
||||
.TH OPENNEBULAPRO "1" "May 2011" "OpenNebulaPro 2.2.0" "User Commands"
|
||||
.SH NAME
|
||||
OpenNebulaPro \- OpenNebula Virtual Machine command
|
||||
.SH SYNOPSIS
|
||||
.B onevm
|
||||
[\fI<options>\fR] \fI<command> \fR[\fI<parameters>\fR]
|
||||
.SH DESCRIPTION
|
||||
|
||||
This command enables the user to manage virtual machines in OpenNebula.
|
||||
The user can allocate, deploy, migrate, suspend, resume and shutdown a virtual
|
||||
machine with the functionality present in onevm.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-l\fR, \fB\-\-list\fR x,y,z
|
||||
Selects columns to display with list
|
||||
command
|
||||
.TP
|
||||
\fB\-\-list\-columns\fR
|
||||
Information about the columns available
|
||||
to display, order or filter
|
||||
.TP
|
||||
\fB\-o\fR, \fB\-\-order\fR x,y,z
|
||||
Order by these columns, column starting
|
||||
with \- means decreasing order
|
||||
.TP
|
||||
\fB\-f\fR, \fB\-\-filter\fR x,y,z
|
||||
Filter data. An array is specified
|
||||
with column=value pairs.
|
||||
.TP
|
||||
\fB\-d\fR, \fB\-\-delay\fR seconds
|
||||
Sets the delay in seconds for top
|
||||
command
|
||||
.TP
|
||||
\fB\-x\fR, \fB\-\-xml\fR
|
||||
Returns xml instead of human readable text
|
||||
.TP
|
||||
\fB\-t\fR, \fB\-\-type\fR type
|
||||
Image type
|
||||
.TP
|
||||
\fB\-v\fR, \fB\-\-verbose\fR
|
||||
Tells more information if the command
|
||||
is successful
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Shows this help message
|
||||
.TP
|
||||
\fB\-\-version\fR
|
||||
Shows version and copyright information
|
||||
.SH COMMANDS
|
||||
.TP
|
||||
\fBcreate\fR (Submits a new virtual machine, adding it to the ONE VM pool)
|
||||
.IP
|
||||
onevm create <template>
|
||||
.IP
|
||||
template is a file name where the VM description is located
|
||||
.TP
|
||||
\fBdeploy\fR (Starts an existing VM in an specific host)
|
||||
.IP
|
||||
onevm deploy <vm_id> <host_id>
|
||||
.IP
|
||||
States: PENDING
|
||||
.TP
|
||||
\fBshutdown\fR (Shuts down an already deployed VM)
|
||||
.IP
|
||||
onevm shutdown <vm_id>
|
||||
.IP
|
||||
States: RUNNING
|
||||
.TP
|
||||
\fBlivemigrate\fR (Migrates a running VM to another host without downtime)
|
||||
.IP
|
||||
onevm livemigrate <vm_id> <host_id>
|
||||
.IP
|
||||
States: RUNNING
|
||||
.TP
|
||||
\fBmigrate\fR (Saves a running VM and starts it again in the specified host)
|
||||
.IP
|
||||
onevm migrate <vm_id> <host_id>
|
||||
.IP
|
||||
States: RUNNING
|
||||
.TP
|
||||
\fBhold\fR (Sets a VM to hold state, scheduler will not deploy it)
|
||||
.IP
|
||||
onevm hold <vm_id>
|
||||
.IP
|
||||
States: PENDING
|
||||
.TP
|
||||
\fBrelease\fR (Releases a VM from hold state, setting it to pending)
|
||||
.IP
|
||||
onevm release <vm_id>
|
||||
.IP
|
||||
States: HOLD
|
||||
.TP
|
||||
\fBstop\fR (Stops a running VM)
|
||||
.IP
|
||||
onevm stop <vm_id>
|
||||
.IP
|
||||
States: RUNNING
|
||||
.TP
|
||||
\fBcancel\fR (Cancels a running VM)
|
||||
.IP
|
||||
onevm cancel <vm_id>
|
||||
.IP
|
||||
States: RUNNING
|
||||
.TP
|
||||
\fBsuspend\fR (Saves a running VM)
|
||||
.IP
|
||||
onevm suspend <vm_id>
|
||||
.IP
|
||||
States: RUNNING
|
||||
.TP
|
||||
\fBresume\fR (Resumes the execution of a saved VM)
|
||||
.IP
|
||||
onevm resume <vm_id>
|
||||
.IP
|
||||
States: STOPPED, SUSPENDED
|
||||
.TP
|
||||
\fBsaveas\fR (Set the specified vms disk to be saved in a new image (image_name)
|
||||
.IP
|
||||
when the vm shuts down)
|
||||
.IP
|
||||
onevm saveas <vm_id> <disk_id> <image_name>
|
||||
.IP
|
||||
(Set a different type for the new Image)
|
||||
.IP
|
||||
onevm saveas <vm_id> <disk_id> <image_name> \fB\-t\fR/\-\-type <type>
|
||||
.TP
|
||||
\fBdelete\fR (Deletes a VM from the pool)
|
||||
.IP
|
||||
onevm delete <vm_id>
|
||||
.IP
|
||||
States: ANY
|
||||
.TP
|
||||
\fBrestart\fR (Forces a re\-deployment of a VM in UNKNOWN or BOOT state)
|
||||
.IP
|
||||
onevm restart <vm_id>
|
||||
.IP
|
||||
States: UNKNOWN, BOOT
|
||||
.TP
|
||||
\fBresubmit\fR (Resubmits a VM to PENDING state)
|
||||
.IP
|
||||
onevm resubmit <vm_id>
|
||||
.IP
|
||||
States: ANY, except SUSPENDED or DONE
|
||||
.TP
|
||||
\fBlist\fR (Shows VMs in the pool)
|
||||
.IP
|
||||
onevm list <filter_flag>
|
||||
.IP
|
||||
where filter_flag can be
|
||||
.TP
|
||||
a, all
|
||||
\fB\-\-\fR> all the known VMs
|
||||
.TP
|
||||
m, mine
|
||||
\fB\-\-\fR> the VMs belonging to the user in ONE_AUTH
|
||||
.TP
|
||||
uid
|
||||
\fB\-\-\fR> VMs of the user identified by this uid
|
||||
.TP
|
||||
user
|
||||
\fB\-\-\fR> VMs of the user identified by the username
|
||||
.TP
|
||||
\fBshow\fR (Gets information about a specific VM)
|
||||
.IP
|
||||
onevm show <vm_id>
|
||||
.TP
|
||||
\fBtop\fR (Lists VMs continuously)
|
||||
.IP
|
||||
onevm top
|
||||
.TP
|
||||
\fBhistory\fR (Gets history from VMs)
|
||||
.IP
|
||||
onevm history [<vm_id> <vm_id> ...]
|
||||
.IP
|
||||
if no vm_id is provided it will list history for all known VMs
|
||||
.PP
|
||||
Information Columns:
|
||||
.TP
|
||||
\fBID\fR ONE VM identifier
|
||||
.TP
|
||||
\fBUSER\fR Username of the VM owner
|
||||
.TP
|
||||
\fBNAME\fR Name of the VM
|
||||
.TP
|
||||
\fBSTAT\fR Status of the VM
|
||||
.TP
|
||||
\fBCPU\fR CPU percentage used by the VM
|
||||
.TP
|
||||
\fBMEM\fR Memory used by the VM
|
||||
.TP
|
||||
\fBHOSTNAME\fR Host where the VM is being or was run
|
||||
.TP
|
||||
\fBTIME\fR Time since the submission of the VM (days hours:minutes:seconds)
|
||||
.PP
|
||||
VM States:
|
||||
.TP
|
||||
\fBpend\fR pending
|
||||
.TP
|
||||
\fBhold\fR VM on hold (not runnable)
|
||||
.TP
|
||||
\fBstop\fR stopped
|
||||
.TP
|
||||
\fBsusp\fR suspended
|
||||
.TP
|
||||
\fBdone\fR finished
|
||||
.TP
|
||||
\fBprol\fR prolog
|
||||
.TP
|
||||
\fBboot\fR booting
|
||||
.TP
|
||||
\fBrunn\fR running
|
||||
.TP
|
||||
\fBmigr\fR migrating
|
||||
.TP
|
||||
\fBsave\fR saving the VM to disk
|
||||
.TP
|
||||
\fBepil\fR epilog
|
||||
.TP
|
||||
\fBshut\fR shutting down
|
||||
.TP
|
||||
\fBfail\fR failed
|
||||
.SH COPYRIGHT
|
||||
Copyright 2010\-2011, C12G Labs S.L.
|
||||
.PP
|
||||
Licensed under the C12G Commercial Open\-source License (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License as part
|
||||
of the software distribution.
|
||||
.PP
|
||||
Unless 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.
|
Binary file not shown.
117
share/man/onevnet.1
Normal file
117
share/man/onevnet.1
Normal file
@ -0,0 +1,117 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
|
||||
.TH OPENNEBULAPRO "1" "May 2011" "OpenNebulaPro 2.2.0" "User Commands"
|
||||
.SH NAME
|
||||
OpenNebulaPro \- OpenNebula Virtual Network command
|
||||
.SH SYNOPSIS
|
||||
.B onevnet
|
||||
[\fI<options>\fR] \fI<command> \fR[\fI<parameters>\fR]
|
||||
.SH DESCRIPTION
|
||||
|
||||
This command enables the user to manage virtual networks in the OpenNebula
|
||||
server. It provides functionality to create, get information and delete a
|
||||
particular network or to list available and used IP's.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-l\fR, \fB\-\-list\fR x,y,z
|
||||
Selects columns to display with list
|
||||
command
|
||||
.TP
|
||||
\fB\-\-list\-columns\fR
|
||||
Information about the columns available
|
||||
to display, order or filter
|
||||
.TP
|
||||
\fB\-o\fR, \fB\-\-order\fR x,y,z
|
||||
Order by these columns, column starting
|
||||
with \- means decreasing order
|
||||
.TP
|
||||
\fB\-f\fR, \fB\-\-filter\fR x,y,z
|
||||
Filter data. An array is specified
|
||||
with column=value pairs.
|
||||
.TP
|
||||
\fB\-x\fR, \fB\-\-xml\fR
|
||||
Returns xml instead of human readable text
|
||||
.TP
|
||||
\fB\-v\fR, \fB\-\-verbose\fR
|
||||
Tells more information if the command
|
||||
is successful
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Shows this help message
|
||||
.TP
|
||||
\fB\-\-version\fR
|
||||
Shows version and copyright information
|
||||
.SH COMMANDS
|
||||
.TP
|
||||
\fBcreate\fR (Creates a new virtual network)
|
||||
.IP
|
||||
onevnet create <template>
|
||||
.IP
|
||||
template is a filename where the virtual network is described
|
||||
.TP
|
||||
\fBshow\fR (Gets info from a virtual network)
|
||||
.IP
|
||||
onevnet show <network_id>
|
||||
.TP
|
||||
\fBpublish\fR (Publish a virtual network)
|
||||
.IP
|
||||
onevnet publish <network_id>
|
||||
.TP
|
||||
\fBunpublish\fR (Unpublish a virtual network)
|
||||
.IP
|
||||
onevnet unpublish <network_id>
|
||||
.TP
|
||||
\fBdelete\fR (Removes a virtual network)
|
||||
.IP
|
||||
onevnet delete <network_id>
|
||||
.TP
|
||||
\fBaddleases\fR (Adds a lease to the virtual network)
|
||||
.IP
|
||||
onevnet addleases <network_id> <IP> [<MAC>]
|
||||
.TP
|
||||
\fBrmleases\fR (Removes a lease fom the virtual network)
|
||||
.IP
|
||||
onevnet rmleases <network_id> <IP>
|
||||
.TP
|
||||
\fBlist\fR (Lists virtual networks in the pool)
|
||||
.IP
|
||||
onevnet list <filter_flag>
|
||||
.IP
|
||||
where filter_flag can be
|
||||
.TP
|
||||
a, all
|
||||
: all the known VNs
|
||||
.IP
|
||||
m, mine : the VNs belonging to the user in ONE_AUTH
|
||||
.IP
|
||||
and all the Public VNs
|
||||
.TP
|
||||
uid
|
||||
: VNs of the user identified by this uid
|
||||
.TP
|
||||
user
|
||||
: VNs of the user identified by the username
|
||||
.PP
|
||||
Information columns:
|
||||
.TP
|
||||
\fBNID\fR Network ID
|
||||
.TP
|
||||
\fBNAME\fR Name of the virtual network
|
||||
.TP
|
||||
\fBTYPE\fR Type of virtual network (0=ranged, 1=fixed)
|
||||
.TP
|
||||
\fBBRIDGE\fR Bridge associated to the virtual network
|
||||
.TP
|
||||
\fBLEASES\fR Number of leases used from this virtual network
|
||||
.SH COPYRIGHT
|
||||
Copyright 2010\-2011, C12G Labs S.L.
|
||||
.PP
|
||||
Licensed under the C12G Commercial Open\-source License (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License as part
|
||||
of the software distribution.
|
||||
.PP
|
||||
Unless 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.
|
Binary file not shown.
@ -16,15 +16,10 @@
|
||||
|
||||
#include "AuthManager.h"
|
||||
#include "NebulaLog.h"
|
||||
#include "SSLTools.h"
|
||||
|
||||
#include "Nebula.h"
|
||||
|
||||
#include <openssl/sha.h>
|
||||
#include <openssl/hmac.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/buffer.h>
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
@ -35,40 +30,6 @@ const char * AuthManager::auth_driver_name = "auth_exe";
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
string * AuthRequest::base64_encode(const string& in)
|
||||
{
|
||||
BIO * bio_mem;
|
||||
BIO * bio_64;
|
||||
|
||||
char * encoded_c;
|
||||
long int size;
|
||||
|
||||
bio_64 = BIO_new(BIO_f_base64());
|
||||
bio_mem = BIO_new(BIO_s_mem());
|
||||
|
||||
BIO_push(bio_64, bio_mem);
|
||||
|
||||
BIO_set_flags(bio_64,BIO_FLAGS_BASE64_NO_NL);
|
||||
|
||||
BIO_write(bio_64, in.c_str(), in.length());
|
||||
|
||||
if (BIO_flush(bio_64) != 1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
size = BIO_get_mem_data(bio_mem,&encoded_c);
|
||||
|
||||
string * encoded = new string(encoded_c,size);
|
||||
|
||||
BIO_free_all(bio_64);
|
||||
|
||||
return encoded;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void AuthRequest::add_auth(Object ob,
|
||||
const string& ob_id,
|
||||
Operation op,
|
||||
@ -92,7 +53,7 @@ void AuthRequest::add_auth(Object ob,
|
||||
|
||||
if (op == CREATE || op == INSTANTIATE) //encode the ob_id, it is a template
|
||||
{
|
||||
string * encoded_id = base64_encode(ob_id);
|
||||
string * encoded_id = SSLTools::base64_encode(ob_id);
|
||||
|
||||
if (encoded_id != 0)
|
||||
{
|
||||
@ -400,12 +361,14 @@ void AuthManager::timer_action()
|
||||
|
||||
lock();
|
||||
|
||||
for (it=auth_requests.begin();it!=auth_requests.end();it++)
|
||||
it = auth_requests.begin();
|
||||
|
||||
while ( it !=auth_requests.end())
|
||||
{
|
||||
if (the_time > it->second->time_out)
|
||||
{
|
||||
AuthRequest * ar = it->second;
|
||||
auth_requests.erase(it);
|
||||
auth_requests.erase(it++);
|
||||
|
||||
ar->result = false;
|
||||
ar->timeout = true;
|
||||
@ -413,6 +376,10 @@ void AuthManager::timer_action()
|
||||
|
||||
ar->notify();
|
||||
}
|
||||
else
|
||||
{
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
unlock();
|
||||
|
@ -1,4 +1,4 @@
|
||||
# SConstruct for src/vm
|
||||
# SConstruct for src/authm
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org) #
|
||||
|
@ -39,7 +39,7 @@ class AuthManagerTest : public OneUnitTest
|
||||
CPPUNIT_TEST_SUITE (AuthManagerTest);
|
||||
|
||||
CPPUNIT_TEST (load);
|
||||
//CPPUNIT_TEST (timeout);
|
||||
CPPUNIT_TEST (timeout);
|
||||
CPPUNIT_TEST (authenticate);
|
||||
CPPUNIT_TEST (authorize);
|
||||
CPPUNIT_TEST (self_authorize);
|
||||
@ -118,7 +118,7 @@ public:
|
||||
|
||||
am->load_mads(0);
|
||||
|
||||
ar.add_authenticate("the_user","the_pass","the_secret");
|
||||
ar.add_authenticate("timeout","the_pass","the_secret");
|
||||
|
||||
am->trigger(AuthManager::AUTHENTICATE,&ar);
|
||||
|
||||
|
@ -17,10 +17,10 @@ Import('env')
|
||||
|
||||
env.Prepend(LIBS=[
|
||||
'nebula_template',
|
||||
'nebula_authm',
|
||||
'nebula_common',
|
||||
'nebula_core',
|
||||
'nebula_mad',
|
||||
'nebula_authm',
|
||||
'nebula_sql',
|
||||
'nebula_log',
|
||||
'crypto'
|
||||
|
@ -19,9 +19,9 @@
|
||||
echo "MAD started" >> mad.log
|
||||
|
||||
|
||||
while read COMMAND ARG1 ARG2 ARG3
|
||||
while read COMMAND ARG1 ARG2 ARG3 ARG4
|
||||
do
|
||||
echo "$COMMAND $ARG1 $ARG2 $ARG3" >> mad.log
|
||||
echo "$COMMAND $ARG1 $ARG2 $ARG3 $ARG4" >> mad.log
|
||||
case $COMMAND in
|
||||
"INIT")
|
||||
echo "INIT SUCCESS"
|
||||
@ -31,9 +31,13 @@ do
|
||||
exit 0
|
||||
;;
|
||||
"AUTHORIZE")
|
||||
echo "AUTHORIZE FAILURE $ARG1 $ARG3"
|
||||
echo "AUTHORIZE FAILURE $ARG1 $ARG3 $ARG4"
|
||||
;;
|
||||
"AUTHENTICATE")
|
||||
if [ "$ARG3" = "timeout" ] ; then
|
||||
sleep 4
|
||||
fi
|
||||
|
||||
echo "AUTHENTICATE SUCCESS $ARG1"
|
||||
;;
|
||||
*)
|
||||
|
@ -62,8 +62,11 @@ class OCCIServer < CloudServer
|
||||
# [return] _Client_ client with the user credentials
|
||||
def get_client(requestenv)
|
||||
auth = Rack::Auth::Basic::Request.new(requestenv)
|
||||
|
||||
return one_client_user(auth.credentials[0], auth.credentials[1])
|
||||
if auth
|
||||
return one_client_user(auth.credentials[0], auth.credentials[1])
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
# Prepare the OCCI XML Response
|
||||
@ -88,8 +91,14 @@ class OCCIServer < CloudServer
|
||||
def get_computes(request)
|
||||
# --- Get User's VMs ---
|
||||
user_flag = -1
|
||||
|
||||
one_client = get_client(request.env)
|
||||
if !one_client
|
||||
return "No authorization data present", 401
|
||||
end
|
||||
|
||||
vmpool = VirtualMachinePoolOCCI.new(
|
||||
get_client(request.env),
|
||||
one_client,
|
||||
user_flag)
|
||||
|
||||
# --- Prepare XML Response ---
|
||||
@ -107,8 +116,14 @@ class OCCIServer < CloudServer
|
||||
def get_networks(request)
|
||||
# --- Get User's VNETs ---
|
||||
user_flag = -1
|
||||
|
||||
one_client = get_client(request.env)
|
||||
if !one_client
|
||||
return "No authorization data present", 401
|
||||
end
|
||||
|
||||
network_pool = VirtualNetworkPoolOCCI.new(
|
||||
get_client(request.env),
|
||||
one_client,
|
||||
user_flag)
|
||||
|
||||
# --- Prepare XML Response ---
|
||||
@ -125,8 +140,14 @@ class OCCIServer < CloudServer
|
||||
def get_storages(request)
|
||||
# --- Get User's Images ---
|
||||
user_flag = -1
|
||||
|
||||
one_client = get_client(request.env)
|
||||
if !one_client
|
||||
return "No authorization data present", 401
|
||||
end
|
||||
|
||||
image_pool = ImagePoolOCCI.new(
|
||||
get_client(request.env),
|
||||
one_client,
|
||||
user_flag)
|
||||
|
||||
# --- Prepare XML Response ---
|
||||
@ -151,9 +172,14 @@ class OCCIServer < CloudServer
|
||||
# [return] _String_,_Integer_ COMPUTE Representation or error, status code
|
||||
def post_compute(request)
|
||||
# --- Create the new Instance ---
|
||||
one_client = get_client(request.env)
|
||||
if !one_client
|
||||
return "No authorization data present", 401
|
||||
end
|
||||
|
||||
vm = VirtualMachineOCCI.new(
|
||||
VirtualMachine.build_xml,
|
||||
get_client(request.env),
|
||||
one_client,
|
||||
request.body.read,
|
||||
@instance_types,
|
||||
@config[:template_location])
|
||||
@ -176,9 +202,14 @@ class OCCIServer < CloudServer
|
||||
# status code
|
||||
def get_compute(request, params)
|
||||
# --- Get the VM ---
|
||||
one_client = get_client(request.env)
|
||||
if !one_client
|
||||
return "No authorization data present", 401
|
||||
end
|
||||
|
||||
vm = VirtualMachineOCCI.new(
|
||||
VirtualMachine.build_xml(params[:id]),
|
||||
get_client(request.env))
|
||||
one_client)
|
||||
|
||||
# --- Prepare XML Response ---
|
||||
rc = vm.info
|
||||
@ -194,9 +225,14 @@ class OCCIServer < CloudServer
|
||||
# status code
|
||||
def delete_compute(request, params)
|
||||
# --- Get the VM ---
|
||||
one_client = get_client(request.env)
|
||||
if !one_client
|
||||
return "No authorization data present", 401
|
||||
end
|
||||
|
||||
vm = VirtualMachineOCCI.new(
|
||||
VirtualMachine.build_xml(params[:id]),
|
||||
get_client(request.env))
|
||||
one_client)
|
||||
|
||||
rc = vm.info
|
||||
return rc, 404 if OpenNebula::is_error?(rc)
|
||||
@ -213,8 +249,11 @@ class OCCIServer < CloudServer
|
||||
# [return] _String_,_Integer_ Update confirmation msg or error,
|
||||
# status code
|
||||
def put_compute(request, params)
|
||||
|
||||
one_client = get_client(request.env)
|
||||
# --- Get the VM ---
|
||||
one_client = get_client(request.env)
|
||||
if !one_client
|
||||
return "No authorization data present", 401
|
||||
end
|
||||
|
||||
vm = VirtualMachineOCCI.new(
|
||||
VirtualMachine.build_xml(params[:id]),
|
||||
@ -295,9 +334,14 @@ class OCCIServer < CloudServer
|
||||
# [return] _String_,_Integer_ Network Representation or error, status code
|
||||
def post_network(request)
|
||||
# --- Create the new Instance ---
|
||||
one_client = get_client(request.env)
|
||||
if !one_client
|
||||
return "No authorization data present", 401
|
||||
end
|
||||
|
||||
network = VirtualNetworkOCCI.new(
|
||||
VirtualNetwork.build_xml,
|
||||
get_client(request.env),
|
||||
one_client,
|
||||
request.body,
|
||||
@config[:bridge])
|
||||
|
||||
@ -319,9 +363,14 @@ class OCCIServer < CloudServer
|
||||
# status code
|
||||
def get_network(request, params)
|
||||
# --- Get the VNET ---
|
||||
one_client = get_client(request.env)
|
||||
if !one_client
|
||||
return "No authorization data present", 401
|
||||
end
|
||||
|
||||
network = VirtualNetworkOCCI.new(
|
||||
VirtualNetwork.build_xml(params[:id]),
|
||||
get_client(request.env))
|
||||
one_client)
|
||||
|
||||
# --- Prepare XML Response ---
|
||||
rc = network.info
|
||||
@ -336,9 +385,14 @@ class OCCIServer < CloudServer
|
||||
# status code
|
||||
def delete_network(request, params)
|
||||
# --- Get the VNET ---
|
||||
one_client = get_client(request.env)
|
||||
if !one_client
|
||||
return "No authorization data present", 401
|
||||
end
|
||||
|
||||
network = VirtualNetworkOCCI.new(
|
||||
VirtualNetwork.build_xml(params[:id]),
|
||||
get_client(request.env))
|
||||
one_client)
|
||||
|
||||
rc = network.info
|
||||
return rc, 404 if OpenNebula::is_error?(rc)
|
||||
@ -357,10 +411,15 @@ class OCCIServer < CloudServer
|
||||
def put_network(request, params)
|
||||
xmldoc = XMLElement.build_xml(request.body, 'NETWORK')
|
||||
vnet_info = XMLElement.new(xmldoc) if xmldoc != nil
|
||||
|
||||
one_client = get_client(request.env)
|
||||
if !one_client
|
||||
return "No authorization data present", 401
|
||||
end
|
||||
|
||||
vnet = VirtualNetworkOCCI.new(
|
||||
VirtualNetwork.build_xml(params[:id]),
|
||||
get_client(request.env))
|
||||
one_client)
|
||||
|
||||
rc = vnet.info
|
||||
return rc, 400 if OpenNebula.is_error?(rc)
|
||||
@ -393,6 +452,11 @@ class OCCIServer < CloudServer
|
||||
error = OpenNebula::Error.new(error_msg)
|
||||
return error, 400
|
||||
end
|
||||
|
||||
one_client = get_client(request.env)
|
||||
if !one_client
|
||||
return "No authorization data present", 401
|
||||
end
|
||||
|
||||
# --- Create and Add the new Image ---
|
||||
occixml = request.params['occixml']
|
||||
@ -400,7 +464,7 @@ class OCCIServer < CloudServer
|
||||
|
||||
image = ImageOCCI.new(
|
||||
Image.build_xml,
|
||||
get_client(request.env),
|
||||
one_client,
|
||||
occixml,
|
||||
request.params['file'])
|
||||
|
||||
@ -422,9 +486,14 @@ class OCCIServer < CloudServer
|
||||
# status code
|
||||
def get_storage(request, params)
|
||||
# --- Get the Image ---
|
||||
one_client = get_client(request.env)
|
||||
if !one_client
|
||||
return "No authorization data present", 401
|
||||
end
|
||||
|
||||
image = ImageOCCI.new(
|
||||
Image.build_xml(params[:id]),
|
||||
get_client(request.env))
|
||||
one_client)
|
||||
|
||||
rc = image.info
|
||||
return rc, 404 if OpenNebula::is_error?(rc)
|
||||
@ -439,9 +508,14 @@ class OCCIServer < CloudServer
|
||||
# status code
|
||||
def delete_storage(request, params)
|
||||
# --- Get the Image ---
|
||||
one_client = get_client(request.env)
|
||||
if !one_client
|
||||
return "No authorization data present", 401
|
||||
end
|
||||
|
||||
image = ImageOCCI.new(
|
||||
Image.build_xml(params[:id]),
|
||||
get_client(request.env))
|
||||
one_client)
|
||||
|
||||
rc = image.info
|
||||
return rc, 404 if OpenNebula::is_error?(rc)
|
||||
@ -460,10 +534,15 @@ class OCCIServer < CloudServer
|
||||
def put_storage(request, params)
|
||||
xmldoc = XMLElement.build_xml(request.body, 'STORAGE')
|
||||
image_info = XMLElement.new(xmldoc) if xmldoc != nil
|
||||
|
||||
one_client = get_client(request.env)
|
||||
if !one_client
|
||||
return "No authorization data present", 401
|
||||
end
|
||||
|
||||
image = ImageOCCI.new(
|
||||
Image.build_xml(params[:id]),
|
||||
get_client(request.env))
|
||||
one_client)
|
||||
|
||||
rc = image.info
|
||||
return rc, 400 if OpenNebula.is_error?(rc)
|
||||
|
@ -75,8 +75,20 @@ string * VectorAttribute::to_xml() const
|
||||
|
||||
for (it=attribute_value.begin();it!=attribute_value.end();it++)
|
||||
{
|
||||
oss << "<" << it->first << "><![CDATA[" << it->second
|
||||
<< "]]></"<< it->first << ">";
|
||||
if ( it->first.empty() )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( it->second.empty() )
|
||||
{
|
||||
oss << "<" << it->first << "/>";
|
||||
}
|
||||
else
|
||||
{
|
||||
oss << "<" << it->first << "><![CDATA[" << it->second
|
||||
<< "]]></"<< it->first << ">";
|
||||
}
|
||||
}
|
||||
|
||||
oss << "</"<< name() << ">";
|
||||
@ -133,9 +145,16 @@ void VectorAttribute::unmarshall(const string& sattr, const char * _sep)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
attribute_value.insert(make_pair(tmp.substr(0,mpos),
|
||||
tmp.substr(mpos+1)));
|
||||
|
||||
if ( mpos + 1 == tmp.size() )
|
||||
{
|
||||
attribute_value.insert(make_pair(tmp.substr(0,mpos),""));
|
||||
}
|
||||
else
|
||||
{
|
||||
attribute_value.insert(make_pair(tmp.substr(0,mpos),
|
||||
tmp.substr(mpos+1)));
|
||||
}
|
||||
}
|
||||
}
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -24,7 +24,8 @@ lib_name='nebula_common'
|
||||
source_files=[
|
||||
'ActionManager.cc',
|
||||
'Attribute.cc',
|
||||
'mem_collector.c'
|
||||
'mem_collector.c',
|
||||
'SSLTools.cc'
|
||||
]
|
||||
|
||||
# Build library
|
||||
|
98
src/common/SSLTools.cc
Normal file
98
src/common/SSLTools.cc
Normal file
@ -0,0 +1,98 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2011, 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. */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#include <openssl/sha.h>
|
||||
#include <openssl/hmac.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/buffer.h>
|
||||
|
||||
#include "SSLTools.h"
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
|
||||
//#include <iostream>
|
||||
|
||||
|
||||
//#include <sys/types.h>
|
||||
//#include <pwd.h>
|
||||
//#include <stdlib.h>
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
string * SSLTools::base64_encode(const string& in)
|
||||
{
|
||||
BIO * bio_mem;
|
||||
BIO * bio_64;
|
||||
|
||||
char * encoded_c;
|
||||
long int size;
|
||||
|
||||
bio_64 = BIO_new(BIO_f_base64());
|
||||
bio_mem = BIO_new(BIO_s_mem());
|
||||
|
||||
BIO_push(bio_64, bio_mem);
|
||||
|
||||
BIO_set_flags(bio_64,BIO_FLAGS_BASE64_NO_NL);
|
||||
|
||||
BIO_write(bio_64, in.c_str(), in.length());
|
||||
|
||||
if (BIO_flush(bio_64) != 1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
size = BIO_get_mem_data(bio_mem,&encoded_c);
|
||||
|
||||
string * encoded = new string(encoded_c,size);
|
||||
|
||||
BIO_free_all(bio_64);
|
||||
|
||||
return encoded;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
string SSLTools::sha1_digest(const string& in)
|
||||
{
|
||||
EVP_MD_CTX mdctx;
|
||||
unsigned char md_value[EVP_MAX_MD_SIZE];
|
||||
unsigned int md_len;
|
||||
ostringstream oss;
|
||||
|
||||
EVP_MD_CTX_init(&mdctx);
|
||||
EVP_DigestInit_ex(&mdctx, EVP_sha1(), NULL);
|
||||
|
||||
EVP_DigestUpdate(&mdctx, in.c_str(), in.length());
|
||||
|
||||
EVP_DigestFinal_ex(&mdctx,md_value,&md_len);
|
||||
EVP_MD_CTX_cleanup(&mdctx);
|
||||
|
||||
for(unsigned int i = 0; i<md_len; i++)
|
||||
{
|
||||
oss << setfill('0') << setw(2) << hex << nouppercase
|
||||
<< (unsigned short) md_value[i];
|
||||
}
|
||||
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
@ -18,6 +18,30 @@
|
||||
#include "Host.h"
|
||||
#include "Nebula.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
static void parse_host_arguments(Host *host, string& parsed)
|
||||
{
|
||||
size_t found;
|
||||
|
||||
found = parsed.find("$HID");
|
||||
|
||||
if ( found !=string::npos )
|
||||
{
|
||||
ostringstream oss;
|
||||
oss << host->get_oid();
|
||||
|
||||
parsed.replace(found,4,oss.str());
|
||||
}
|
||||
|
||||
found = parsed.find("$TEMPLATE");
|
||||
|
||||
if ( found != string::npos )
|
||||
{
|
||||
string templ;
|
||||
parsed.replace(found,9,host->to_xml64(templ));
|
||||
}
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@ -26,7 +50,6 @@ void HostAllocateHook::do_hook(void *arg)
|
||||
Host * host;
|
||||
|
||||
string parsed_args = args;
|
||||
size_t found;
|
||||
|
||||
host = static_cast<Host *>(arg);
|
||||
|
||||
@ -34,16 +57,8 @@ void HostAllocateHook::do_hook(void *arg)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
found = args.find("$HID");
|
||||
|
||||
if ( found !=string::npos )
|
||||
{
|
||||
ostringstream oss;
|
||||
oss << host->get_oid();
|
||||
|
||||
parsed_args.replace(found,4,oss.str());
|
||||
}
|
||||
|
||||
parse_host_arguments(host,parsed_args);
|
||||
|
||||
Nebula& ne = Nebula::instance();
|
||||
HookManager * hm = ne.get_hm();
|
||||
@ -156,17 +171,8 @@ void HostStateHook::do_hook(void *arg)
|
||||
if ( cur_state == this->state )
|
||||
{
|
||||
string parsed_args = args;
|
||||
size_t found;
|
||||
|
||||
found = args.find("$HID");
|
||||
|
||||
if ( found !=string::npos )
|
||||
{
|
||||
ostringstream oss;
|
||||
oss << host->get_oid();
|
||||
|
||||
parsed_args.replace(found,4,oss.str());
|
||||
}
|
||||
parse_host_arguments(host,parsed_args);
|
||||
|
||||
Nebula& ne = Nebula::instance();
|
||||
HookManager * hm = ne.get_hm();
|
||||
|
@ -38,7 +38,7 @@ ID=$3
|
||||
|
||||
# ------------ Generate a filename for the image ------------
|
||||
|
||||
if [ $DST -eq "-" ] ; then
|
||||
if [ "$DST" = "-" ] ; then
|
||||
DST=`generate_image_path`
|
||||
fi
|
||||
|
||||
@ -54,8 +54,11 @@ http://*)
|
||||
|
||||
*)
|
||||
log "Moving local image $SRC to the image repository"
|
||||
exec_and_log "mv -f $SRC $DST" \
|
||||
"Could not move $SRC to $DST"
|
||||
if [ \( -L $SRC \) -a \( "`$READLINK $SRC`" = "$DST" \) ] ; then
|
||||
log "Not moving files to image repo, they are the same"
|
||||
else
|
||||
exec_and_log "mv -f $SRC $DST" "Could not move $SRC to $DST"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
|
@ -32,6 +32,7 @@ SED=/bin/sed
|
||||
SSH=/usr/bin/ssh
|
||||
SUDO=/usr/bin/sudo
|
||||
WGET=/usr/bin/wget
|
||||
READLINK=/bin/readlink
|
||||
|
||||
# Used for log messages
|
||||
SCRIPT_NAME=`basename $0`
|
||||
|
@ -102,20 +102,27 @@ module OpenNebula
|
||||
end
|
||||
end
|
||||
|
||||
# Gets an array of text from elemenets extracted
|
||||
# using the XPATH expression passed as filter
|
||||
def retrieve_elements(filter)
|
||||
ids_array = Array.new
|
||||
elements_array = Array.new
|
||||
|
||||
if NOKOGIRI
|
||||
@xml.xpath(filter).each { |pelem|
|
||||
ids_array << pelem.text
|
||||
@xml.xpath(filter.to_s).each { |pelem|
|
||||
elements_array << pelem.text if !pelem.text
|
||||
}
|
||||
else
|
||||
@xml.elements.each(filter) { |pelem|
|
||||
ids_array << pelem.text
|
||||
@xml.elements.each(filter.to_s) { |pelem|
|
||||
elements_array << pelem.text if !pelem.text
|
||||
}
|
||||
end
|
||||
|
||||
return ids_array
|
||||
if elements_array.size == 0
|
||||
return nil
|
||||
else
|
||||
return elements_array
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Gets an attribute from an elemenT
|
||||
|
@ -15,6 +15,25 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#include "PoolObjectSQL.h"
|
||||
#include "SSLTools.h"
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
string& PoolObjectSQL::to_xml64(string &xml64)
|
||||
{
|
||||
string *str64;
|
||||
|
||||
to_xml(xml64);
|
||||
|
||||
str64 = SSLTools::base64_encode(xml64);
|
||||
|
||||
xml64 = *str64;
|
||||
|
||||
delete str64;
|
||||
|
||||
return xml64;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -91,6 +91,7 @@ void RequestManager::VirtualMachineSaveDisk::execute(
|
||||
|
||||
oss << "NAME= " << img_name << endl;
|
||||
oss << "PUBLIC = NO " << endl;
|
||||
oss << "SOURCE = - " << endl;
|
||||
|
||||
img_template = new ImageTemplate;
|
||||
|
||||
|
@ -82,6 +82,11 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Default message size for XML data off the network
|
||||
*/
|
||||
static const int MESSAGE_SIZE;
|
||||
|
||||
string one_auth;
|
||||
string one_endpoint;
|
||||
|
||||
@ -92,13 +97,6 @@ private:
|
||||
int read_oneauth(string &secret);
|
||||
|
||||
int split_secret(const string secret, string& user, string& pass);
|
||||
|
||||
string sha1_digest(const string& pass);
|
||||
|
||||
/**
|
||||
* Default message size for XML data off the network
|
||||
*/
|
||||
static const int MESSAGE_SIZE;
|
||||
};
|
||||
|
||||
#endif /*ONECLIENT_H_*/
|
||||
|
@ -15,6 +15,7 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#include "Client.h"
|
||||
#include "SSLTools.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <pwd.h>
|
||||
@ -25,12 +26,8 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include <openssl/evp.h>
|
||||
#include <iomanip>
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
@ -57,7 +54,7 @@ void Client::set_one_auth(string secret)
|
||||
|
||||
if( rc == 0 )
|
||||
{
|
||||
string sha1_pass = sha1_digest(pass);
|
||||
string sha1_pass = SSLTools::sha1_digest(pass);
|
||||
|
||||
one_auth = user + ":" + sha1_pass;
|
||||
}
|
||||
@ -157,33 +154,6 @@ int Client::split_secret(const string secret, string& user, string& pass)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
string Client::sha1_digest(const string& pass)
|
||||
{
|
||||
EVP_MD_CTX mdctx;
|
||||
unsigned char md_value[EVP_MAX_MD_SIZE];
|
||||
unsigned int md_len;
|
||||
ostringstream oss;
|
||||
|
||||
EVP_MD_CTX_init(&mdctx);
|
||||
EVP_DigestInit_ex(&mdctx, EVP_sha1(), NULL);
|
||||
|
||||
EVP_DigestUpdate(&mdctx, pass.c_str(), pass.length());
|
||||
|
||||
EVP_DigestFinal_ex(&mdctx,md_value,&md_len);
|
||||
EVP_MD_CTX_cleanup(&mdctx);
|
||||
|
||||
for(unsigned int i = 0; i<md_len; i++)
|
||||
{
|
||||
oss << setfill('0') << setw(2) << hex << nouppercase
|
||||
<< (unsigned short) md_value[i];
|
||||
}
|
||||
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void Client::set_one_endpoint(string endpoint)
|
||||
{
|
||||
one_endpoint = "http://localhost:2633/RPC2";
|
||||
|
@ -22,24 +22,15 @@ if [ -z "$ONE_LOCATION" ]; then
|
||||
SUNSTONE_SERVER=/usr/lib/one/sunstone/config.ru
|
||||
SUNSTONE_LOCK_FILE=/var/lock/one/.sunstone.lock
|
||||
SUNSTONE_LOG=/var/log/one/sunstone.log
|
||||
SUNSTONE_CONF=/etc/one/sunstone-server.conf
|
||||
else
|
||||
SUNSTONE_PID=$ONE_LOCATION/var/sunstone.pid
|
||||
SUNSTONE_SERVER=$ONE_LOCATION/lib/sunstone/config.ru
|
||||
SUNSTONE_LOCK_FILE=$ONE_LOCATION/var/.sunstone.lock
|
||||
SUNSTONE_LOG=$ONE_LOCATION/var/sunstone.log
|
||||
SUNSTONE_CONF=$ONE_LOCATION/etc/sunstone-server.conf
|
||||
fi
|
||||
|
||||
PORT="4567"
|
||||
HOST="127.0.0.1"
|
||||
|
||||
usage() {
|
||||
echo
|
||||
echo "Usage: sunstone-server [-H host] [-p port]"
|
||||
echo
|
||||
echo "-H: Host for the Sunstone server, default value: localhost"
|
||||
echo "-p: Port for incoming connections, default value: 4567"
|
||||
}
|
||||
|
||||
setup()
|
||||
{
|
||||
|
||||
@ -48,7 +39,8 @@ setup()
|
||||
SUNSTONEPID=`cat $SUNSTONE_PID`
|
||||
ps $SUNSTONEPID &> /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Sunstone Server is still running (PID:$SUNSTONEPID). Please try 'sunstone-server stop' first."
|
||||
echo -n "Sunstone Server is still running (PID:$SUNSTONEPID). Please "
|
||||
echo "try 'sunstone-server stop' first."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
@ -65,14 +57,21 @@ start()
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source $SUNSTONE_CONF
|
||||
|
||||
lsof -i:$PORT &> /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "The port $PORT is being used. Please specify a different one."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Start the sunstone daemon
|
||||
touch $SUNSTONE_LOCK_FILE
|
||||
rackup $SUNSTONE_SERVER -s thin -p $PORT -o $HOST -P $SUNSTONE_PID &> $SUNSTONE_LOG &
|
||||
rackup $SUNSTONE_SERVER -s thin -p $PORT -o $HOST \
|
||||
-P $SUNSTONE_PID &> $SUNSTONE_LOG &
|
||||
|
||||
LASTRC=$?
|
||||
|
||||
if [ $LASTRC -ne 0 ]; then
|
||||
echo "Error executing $SUNSTONE_SERVER"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error executing $SUNSTONE_SERVER, please check the log $SUNSTONE_LOG"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -80,11 +79,11 @@ start()
|
||||
ps $LASTPID &> /dev/null
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error executing $SUNSTONE_SERVER."
|
||||
echo "Error executing $SUNSTONE_SERVER, please check the log $SUNSTONE_LOG"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "sunstone-server started"
|
||||
echo "sunstone-server listening on $HOST:$PORT"
|
||||
}
|
||||
|
||||
#
|
||||
@ -106,19 +105,8 @@ stop()
|
||||
echo "sunstone-server stopped"
|
||||
}
|
||||
|
||||
while getopts "p:H:" OPTION
|
||||
do
|
||||
case $OPTION in
|
||||
p) PORT=$OPTARG;;
|
||||
H) HOST=$OPTARG;;
|
||||
*) usage; exit 3;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $((OPTIND-1))
|
||||
|
||||
case "$1" in
|
||||
start) setup; start;;
|
||||
stop) stop;;
|
||||
*) usage; exit 3;;
|
||||
*) echo "Usage: sunstone-server {start|stop}" >&2; exit 3;;
|
||||
esac
|
||||
|
7
src/sunstone/etc/sunstone-server.conf
Normal file
7
src/sunstone/etc/sunstone-server.conf
Normal file
@ -0,0 +1,7 @@
|
||||
# Server Configuration
|
||||
HOST=127.0.0.1
|
||||
PORT=9869
|
||||
|
||||
# VNC Configuration
|
||||
VNC_PROXY_BASE_PORT=29876
|
||||
NOVNC_PATH=
|
@ -17,6 +17,7 @@
|
||||
require 'OpenNebulaJSON/JSONUtils'
|
||||
|
||||
module OpenNebulaJSON
|
||||
|
||||
class VirtualMachineJSON < OpenNebula::VirtualMachine
|
||||
include JSONUtils
|
||||
|
||||
|
@ -14,22 +14,7 @@
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
ONE_LOCATION = ENV["ONE_LOCATION"]
|
||||
|
||||
if !ONE_LOCATION
|
||||
LOG_LOCATION = "/var/log/one"
|
||||
VAR_LOCATION = "/var/lib/one"
|
||||
RUBY_LIB_LOCATION = "/usr/lib/one/ruby"
|
||||
else
|
||||
VAR_LOCATION = ONE_LOCATION+"/var"
|
||||
LOG_LOCATION = ONE_LOCATION+"/var"
|
||||
RUBY_LIB_LOCATION = ONE_LOCATION+"/lib/ruby"
|
||||
end
|
||||
|
||||
$: << RUBY_LIB_LOCATION
|
||||
$: << File.dirname(__FILE__)
|
||||
|
||||
require 'models/OpenNebulaJSON'
|
||||
require 'OpenNebulaJSON'
|
||||
include OpenNebulaJSON
|
||||
|
||||
class SunstoneServer
|
||||
@ -215,6 +200,69 @@ class SunstoneServer
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
########################################################################
|
||||
# VNC
|
||||
########################################################################
|
||||
def startvnc(id, config)
|
||||
resource = retrieve_resource("vm", id)
|
||||
if OpenNebula.is_error?(resource)
|
||||
return [404, resource.to_json]
|
||||
end
|
||||
|
||||
if resource['LCM_STATE'] != "3"
|
||||
error = OpenNebula::Error.new("VM is not running")
|
||||
return [403, error.to_json]
|
||||
end
|
||||
|
||||
if resource['TEMPLATE/GRAPHICS/TYPE'] != "vnc"
|
||||
error = OpenNebula::Error.new("VM has no VNC configured")
|
||||
return [403, error.to_json]
|
||||
end
|
||||
|
||||
# The VM host and its VNC port
|
||||
host = resource['HISTORY/HOSTNAME']
|
||||
vnc_port = resource['TEMPLATE/GRAPHICS/PORT']
|
||||
|
||||
# The noVNC proxy_port
|
||||
proxy_port = config[:vnc_proxy_base_port].to_i + vnc_port.to_i
|
||||
|
||||
begin
|
||||
novnc_cmd = "#{config[:novnc_path]}/utils/launch.sh"
|
||||
pipe = IO.popen("#{novnc_cmd} --listen #{proxy_port} \
|
||||
--vnc #{host}:#{vnc_port}")
|
||||
rescue Exception => e
|
||||
error = Error.new(e.message)
|
||||
return [500, error.to_json]
|
||||
end
|
||||
|
||||
vnc_pw = resource['TEMPLATE/GRAPHICS/PASSWD']
|
||||
|
||||
info = {:pipe => pipe, :port => proxy_port, :password => vnc_pw}
|
||||
return [200, info]
|
||||
end
|
||||
|
||||
############################################################################
|
||||
#
|
||||
############################################################################
|
||||
def stopvnc(id,pipe)
|
||||
resource = retrieve_resource("vm", id)
|
||||
if OpenNebula.is_error?(resource)
|
||||
return [404, resource.to_json]
|
||||
end
|
||||
|
||||
begin
|
||||
Process.kill('KILL',pipe.pid)
|
||||
pipe.close
|
||||
rescue Exception => e
|
||||
error = Error.new(e.message)
|
||||
return [500, error.to_json]
|
||||
end
|
||||
|
||||
return [200, nil]
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
def retrieve_resource(kind, id)
|
||||
|
@ -372,10 +372,13 @@ tr.even:hover{
|
||||
|
||||
|
||||
.info_table td{
|
||||
border-bottom: 1px solid #CCCCCC;
|
||||
color: #353735;
|
||||
padding: 6px 8px;
|
||||
}
|
||||
border-bottom: 1px solid #CCCCCC;
|
||||
color: #353735;
|
||||
padding-top: 6px;
|
||||
padding-bottom: 6px;
|
||||
padding-left: 8px;
|
||||
padding-right: 8px;
|
||||
}
|
||||
|
||||
|
||||
.info_table td.key_td{
|
||||
|
BIN
src/sunstone/public/images/vnc_off.png
Normal file
BIN
src/sunstone/public/images/vnc_off.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 849 B |
BIN
src/sunstone/public/images/vnc_on.png
Normal file
BIN
src/sunstone/public/images/vnc_on.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
@ -95,7 +95,9 @@ var OpenNebula = {
|
||||
return ["INIT",
|
||||
"READY",
|
||||
"USED",
|
||||
"DISABLED"][value];
|
||||
"DISABLED",
|
||||
"LOCKED",
|
||||
"ERROR"][value];
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
@ -1242,7 +1244,67 @@ var OpenNebula = {
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
"startvnc" : function(params){
|
||||
var callback = params.success;
|
||||
var callback_error = params.error;
|
||||
var id = params.data.id;
|
||||
var resource = OpenNebula.VM.resource;
|
||||
|
||||
var method = "startvnc";
|
||||
var action = OpenNebula.Helper.action(method);
|
||||
var request = OpenNebula.Helper.request(resource,method, id);
|
||||
$.ajax({
|
||||
url: "vm/"+id+"/startvnc",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
success: function(response)
|
||||
{
|
||||
if (callback)
|
||||
{
|
||||
callback(request,response);
|
||||
}
|
||||
},
|
||||
error: function(response)
|
||||
{
|
||||
if (callback_error)
|
||||
{
|
||||
callback_error(request, OpenNebula.Error(response));
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
"stopvnc" : function(params){
|
||||
var callback = params.success;
|
||||
var callback_error = params.error;
|
||||
var id = params.data.id;
|
||||
var resource = OpenNebula.VM.resource;
|
||||
|
||||
var method = "stopvnc";
|
||||
var action = OpenNebula.Helper.action(method);
|
||||
var request = OpenNebula.Helper.request(resource,method, id);
|
||||
$.ajax({
|
||||
url: "vm/"+id+"/stopvnc",
|
||||
type: "POST",
|
||||
success: function()
|
||||
{
|
||||
if (callback)
|
||||
{
|
||||
callback(request);
|
||||
}
|
||||
},
|
||||
error: function(response)
|
||||
{
|
||||
if (callback_error)
|
||||
{
|
||||
callback_error(request, OpenNebula.Error(response));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
"Cluster": {
|
||||
|
@ -56,7 +56,7 @@ var create_image_tmpl =
|
||||
</div>\
|
||||
<div class="img_param">\
|
||||
<label for="img_desc">Description:</label>\
|
||||
<input type="text" name="img_desc" id="img_desc" />\
|
||||
<textarea name="img_desc" id="img_desc" style="height:4em"></textarea>\
|
||||
<div class="tip">Human readable description of the image for other users.</div>\
|
||||
</div>\
|
||||
</fieldset>\
|
||||
|
@ -146,6 +146,34 @@ var create_template_tmpl = '<div id="template_create_tabs">\
|
||||
</fieldset>\
|
||||
</div>\
|
||||
\
|
||||
\
|
||||
<!-- FEATURES SECTION pae,acpi-->\
|
||||
<div class="vm_section" id="features">\
|
||||
<div class="show_hide" id="add_features_cb">\
|
||||
<h3>Features <a id="add_features" class="icon_left" href="#"><span class="ui-icon ui-icon-plus" /></a></h3>\
|
||||
</div>\
|
||||
<fieldset><legend>Features</legend>\
|
||||
<div class="vm_param kvm_opt xen_opt vmware_opt">\
|
||||
<label for="PAE">PAE:</label>\
|
||||
<select id="PAE" name="PAE">\
|
||||
<option value="">Default</option>\
|
||||
<option value="yes">Enable</option>\
|
||||
<option value="no">Disable</option>\
|
||||
</select>\
|
||||
<div class="tip">Physical address extension mode allows 32-bit guests to address more than 4 GB of memory</div>\
|
||||
</div>\
|
||||
<div class="vm_param kvm_opt xen_opt vmware_opt">\
|
||||
<label for="ACPI">ACPI:</label>\
|
||||
<select id="ACPI" name="ACPI">\
|
||||
<option value="">Default</option>\
|
||||
<option value="yes">Enable</option>\
|
||||
<option value="no">Disable</option>\
|
||||
</select>\
|
||||
<div class="tip">Useful for power management, for example, normally required for graceful shutdown to work</div>\
|
||||
</div>\
|
||||
</fieldset>\
|
||||
</div>\
|
||||
\
|
||||
\
|
||||
<!--disks section using image or declaring\
|
||||
image, image ID, bus, target, driver\
|
||||
@ -267,7 +295,7 @@ var create_template_tmpl = '<div id="template_create_tabs">\
|
||||
</select>\
|
||||
<div class="tip">Name of the network to attach this device</div>\
|
||||
</div>\
|
||||
<div class="vm_param kvm_opt xen_opt niccfg">\
|
||||
<div class="vm_param kvm_opt xen_opt niccfg network">\
|
||||
<label for="IP">IP:</label>\
|
||||
<input type="text" id="IP" name="ip" />\
|
||||
<div class="tip">Request an specific IP from the Network</div>\
|
||||
@ -649,6 +677,21 @@ var template_actions = {
|
||||
elements: function() { return getSelectedNodes(dataTable_templates); },
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"Template.instantiate" : {
|
||||
type: "custom",
|
||||
call: function(){
|
||||
nodes = getSelectedNodes(dataTable_templates);
|
||||
$.each(nodes,function(){
|
||||
Sunstone.runAction("VM.create",
|
||||
{vm : {
|
||||
template_id: this
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
notify: false
|
||||
}
|
||||
}
|
||||
|
||||
@ -665,6 +708,11 @@ var template_buttons = {
|
||||
text: "+ New",
|
||||
condition: True
|
||||
},
|
||||
"Template.instantiate" : {
|
||||
type: "action",
|
||||
text: "Instantiate",
|
||||
condition: True
|
||||
},
|
||||
"Template.addattr_dialog" : {
|
||||
type: "action",
|
||||
text: "Add attribute",
|
||||
@ -875,9 +923,8 @@ function popUpTemplateRmattrDialog(){
|
||||
function updateTemplateInfo(request,template){
|
||||
var template_info = template.VMTEMPLATE;
|
||||
var info_tab = {
|
||||
title: "Template information",
|
||||
content:
|
||||
'<table id="info_template_table" class="info_table">\
|
||||
title: "Information",
|
||||
content: '<table id="info_template_table" class="info_table">\
|
||||
<thead>\
|
||||
<tr><th colspan="2">Template "'+template_info.NAME+'" information</th></tr>\
|
||||
</thead>\
|
||||
@ -897,16 +944,20 @@ function updateTemplateInfo(request,template){
|
||||
<td class="key_td">Public</td>\
|
||||
<td class="value_td">'+(parseInt(template_info.PUBLIC) ? "yes" : "no")+'</td>\
|
||||
</tr>\
|
||||
</table>\
|
||||
<table id="template_template_table" class="info_table">\
|
||||
<thead><tr><th colspan="2">Template</th></tr></thead>'+
|
||||
prettyPrintJSON(template_info.TEMPLATE)+
|
||||
'</table>'
|
||||
}
|
||||
|
||||
|
||||
</table>'
|
||||
};
|
||||
var template_tab = {
|
||||
title: "Template",
|
||||
content: '<table id="template_template_table" class="info_table">\
|
||||
<thead><tr><th colspan="2">Template</th></tr></thead>'+
|
||||
prettyPrintJSON(template_info.TEMPLATE)+
|
||||
'</table>'
|
||||
};
|
||||
|
||||
|
||||
Sunstone.updateInfoPanelTab("template_info_panel","template_info_tab",info_tab);
|
||||
|
||||
Sunstone.updateInfoPanelTab("template_info_panel","template_template_tab",template_tab);
|
||||
|
||||
Sunstone.popUpInfoPanel("template_info_panel");
|
||||
|
||||
}
|
||||
@ -1305,6 +1356,16 @@ function setupCreateTemplateDialog(){
|
||||
});
|
||||
};
|
||||
|
||||
// Sets up the features section
|
||||
var features_setup = function(){
|
||||
$('fieldset',section_features).hide();
|
||||
|
||||
$('#add_features',section_features).click(function(){
|
||||
$('fieldset',section_features).toggle();
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
// Sets up the disk section
|
||||
var disks_setup = function(){
|
||||
|
||||
@ -1695,6 +1756,7 @@ function setupCreateTemplateDialog(){
|
||||
//Sections, used to stay within their scope
|
||||
var section_capacity = $('#capacity');
|
||||
var section_os_boot = $('#os_boot_opts');
|
||||
var section_features = $('#features');
|
||||
var section_disks = $('#disks');
|
||||
var section_networks = $('#networks');
|
||||
var section_inputs = $('#inputs');
|
||||
@ -1738,6 +1800,7 @@ function setupCreateTemplateDialog(){
|
||||
//initialise all sections
|
||||
capacity_setup();
|
||||
os_boot_setup();
|
||||
features_setup();
|
||||
disks_setup();
|
||||
networks_setup();
|
||||
inputs_setup();
|
||||
@ -1780,6 +1843,11 @@ function setupCreateTemplateDialog(){
|
||||
vm_json["OS"] = {};
|
||||
addSectionJSON(vm_json["OS"],scope);
|
||||
|
||||
//Fetch pae and acpi options
|
||||
scope = section_features;
|
||||
vm_json["FEATURES"] = {};
|
||||
addSectionJSON(vm_json["FEATURES"],scope);
|
||||
|
||||
//process disks -> fetch from box
|
||||
scope = section_disks;
|
||||
vm_json["DISK"] = [];
|
||||
|
@ -15,6 +15,12 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/*Virtual Machines tab plugin*/
|
||||
var INCLUDE_URI = "vendor/noVNC/include/";
|
||||
function loadVNC(){
|
||||
var script = '<script src="vendor/noVNC/include/vnc.js"></script>';
|
||||
document.write(script);
|
||||
}
|
||||
loadVNC();
|
||||
|
||||
var vms_tab_content =
|
||||
'<form id="virtualMachine_list" action="javascript:alert(\'js error!\');">\
|
||||
@ -32,6 +38,7 @@ var vms_tab_content =
|
||||
<th>Memory</th>\
|
||||
<th>Hostname</th>\
|
||||
<th>Start Time</th>\
|
||||
<th>VNC Access</th>\
|
||||
</tr>\
|
||||
</thead>\
|
||||
<tbody id="tbodyvmachines">\
|
||||
@ -59,6 +66,7 @@ var create_vm_tmpl ='<form id="create_vm_form" action="">\
|
||||
|
||||
var vmachine_list_json = {};
|
||||
var dataTable_vMachines;
|
||||
var rfb;
|
||||
|
||||
var vm_actions = {
|
||||
"VM.create" : {
|
||||
@ -236,12 +244,20 @@ var vm_actions = {
|
||||
{data:obj,
|
||||
success: function (req) {
|
||||
Sunstone.runAction("VM.show",
|
||||
req.request.data[0]);
|
||||
req.request.data[0][0]);
|
||||
},
|
||||
error: onError });
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
"VM.saveas_disks" : {
|
||||
type: "single",
|
||||
call: OpenNebula.VM.show,
|
||||
callback: saveasDisksCallback,
|
||||
error: onError,
|
||||
notify: false
|
||||
},
|
||||
|
||||
"VM.shutdown" : {
|
||||
type: "multiple",
|
||||
call: OpenNebula.VM.shutdown,
|
||||
@ -281,13 +297,14 @@ var vm_actions = {
|
||||
//update the tab and pop it up again
|
||||
var log_lines = res.split("\n");
|
||||
var colored_log = '';
|
||||
for (line in log_lines){
|
||||
line = log_lines[line];
|
||||
for (var i = 0; i < log_lines.length;i++){
|
||||
var line = log_lines[i];
|
||||
if (line.match(/\[E\]/)){
|
||||
line = '<span class="vm_log_error">'+line+'</span>'
|
||||
line = '<span class="vm_log_error">'+line+'</span>';
|
||||
}
|
||||
colored_log += line + "\n";
|
||||
}
|
||||
|
||||
var log_tab = {
|
||||
title: "VM log",
|
||||
content: '<pre>'+colored_log+'</pre>'
|
||||
@ -300,6 +317,22 @@ var vm_actions = {
|
||||
$("#vm_log pre").html('');
|
||||
onError(request,error_json);
|
||||
}
|
||||
},
|
||||
|
||||
"VM.startvnc" : {
|
||||
type: "single",
|
||||
call: OpenNebula.VM.startvnc,
|
||||
callback: vncCallback,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
|
||||
"VM.stopvnc" : {
|
||||
type: "single",
|
||||
call: OpenNebula.VM.stopvnc,
|
||||
callback: null,
|
||||
error: onError,
|
||||
notify: true
|
||||
}
|
||||
}
|
||||
|
||||
@ -467,6 +500,8 @@ function vMachineElementArray(vm_json){
|
||||
if (state == "ACTIVE") {
|
||||
state = OpenNebula.Helper.resource_state("vm_lcm",vm.LCM_STATE);
|
||||
}
|
||||
|
||||
|
||||
return [
|
||||
'<input type="checkbox" id="vm_'+vm.ID+'" name="selected_items" value="'+vm.ID+'"/>',
|
||||
vm.ID,
|
||||
@ -476,7 +511,8 @@ function vMachineElementArray(vm_json){
|
||||
vm.CPU,
|
||||
humanize_size(vm.MEMORY),
|
||||
vm.HISTORY ? vm.HISTORY.HOSTNAME : "--",
|
||||
str_start_time(vm)
|
||||
str_start_time(vm),
|
||||
vncIcon(vm)
|
||||
]
|
||||
}
|
||||
|
||||
@ -485,7 +521,7 @@ function vMachineElementArray(vm_json){
|
||||
function vMachineInfoListener(){
|
||||
|
||||
$('#tbodyvmachines tr').live("click", function(e){
|
||||
if ($(e.target).is('input')) {return true;}
|
||||
if ($(e.target).is('input') || $(e.target).is('a img')) {return true;}
|
||||
popDialogLoading();
|
||||
var aData = dataTable_vMachines.fnGetData(this);
|
||||
var id = $(aData[0]).val();
|
||||
@ -511,8 +547,6 @@ function addVMachineElement(request,vm_json){
|
||||
var id = vm_json.VM.ID;
|
||||
var element = vMachineElementArray(vm_json);
|
||||
addElement(element,dataTable_vMachines);
|
||||
//Popup info panel after creation.
|
||||
updateVMInfo(null,vm_json);
|
||||
}
|
||||
|
||||
|
||||
@ -584,6 +618,10 @@ function updateVMInfo(request,vm){
|
||||
<td class="key_td">Used CPU</td>\
|
||||
<td class="value_td">'+vm_info.CPU+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">VNC Session</td>\
|
||||
<td class="value_td">'+vncIcon(vm_info)+'</td>\
|
||||
</tr>\
|
||||
</table>'
|
||||
}
|
||||
|
||||
@ -659,10 +697,10 @@ function setupSaveasDialog(){
|
||||
<form action="javascript:alert(\'js error!\');">\
|
||||
<div id="saveas_tabs">\
|
||||
</div>\
|
||||
<div class="form_buttons">\
|
||||
<button id="vm_saveas_proceed" value="">OK</button>\
|
||||
<button id="vm_saveas_cancel" value="">Cancel</button>\
|
||||
</div>\
|
||||
<div class="form_buttons">\
|
||||
<button id="vm_saveas_proceed" value="">OK</button>\
|
||||
<button id="vm_saveas_cancel" value="">Cancel</button>\
|
||||
</div>\
|
||||
</fieldset>\
|
||||
</form>');
|
||||
|
||||
@ -681,7 +719,7 @@ function setupSaveasDialog(){
|
||||
var id = $('#vm_id',this).text();
|
||||
var disk_id = $('#vm_disk_id',this).val();
|
||||
var image_name = $('#image_name',this).val();
|
||||
var type = $('#image_type',this).val();
|
||||
//var type = $('#image_type',this).val();
|
||||
|
||||
if (!id.length || !disk_id.length || !image_name.length) {
|
||||
notifyError("Skipping VM "+id+
|
||||
@ -691,8 +729,8 @@ function setupSaveasDialog(){
|
||||
var obj = {
|
||||
vm_id: id,
|
||||
disk_id : disk_id,
|
||||
image_name : image_name,
|
||||
type: type
|
||||
image_name : image_name
|
||||
//type: type
|
||||
};
|
||||
args.push(id);
|
||||
Sunstone.runAction("VM.saveas",obj);
|
||||
@ -725,35 +763,68 @@ function popUpSaveasDialog(elems){
|
||||
<div id="vm_id_text">Saveas for VM with ID <span id="vm_id">'+this+'</span></div>\
|
||||
<fieldset>\
|
||||
<div>\
|
||||
<label for="vm_disk_id">Disk id:</label>\
|
||||
<input type="text" id="vm_disk_id" name="vm_disk_id" value="" size="2"/>\
|
||||
<label for="vm_disk_id">Select disk:</label>\
|
||||
<select id="vm_disk_id" name="vm_disk_id">\
|
||||
<option value="">Retrieving...</option>\
|
||||
</select>\
|
||||
</div>\
|
||||
<div>\
|
||||
<label for="image_name">Image name:</label>\
|
||||
<input type="text" id="image_name" name="image_name" value="" />\
|
||||
</div>\
|
||||
<!-- not used anymore\
|
||||
<div>\
|
||||
<label for="img_attr_value">Type:</label>\
|
||||
<select id="image_type" name="image_type">\
|
||||
<option value="">Default</option>\
|
||||
<option value="disk">Disk</option>\
|
||||
<option value="floppy">Floppy</option>\
|
||||
<option value="cdrom">CD-ROM</option>\
|
||||
<option value="swap">Swap</option>\
|
||||
<option value="fs">FS</option>\
|
||||
<option value="block">Block</option>\
|
||||
</select>\
|
||||
<option value="disk">Disk</option>\
|
||||
<option value="floppy">Floppy</option>\
|
||||
<option value="cdrom">CD-ROM</option>\
|
||||
<option value="swap">Swap</option>\
|
||||
<option value="fs">FS</option>\
|
||||
<option value="block">Block</option>\
|
||||
</select>\
|
||||
</div>\
|
||||
-->\
|
||||
</fieldset>\
|
||||
</div>';
|
||||
$('#saveas_vm_dialog #saveas_tabs').append(tab);
|
||||
Sunstone.runAction("VM.saveas_disks",this);
|
||||
});
|
||||
$('#saveas_vm_dialog #saveas_tabs').tabs();
|
||||
$('#saveas_vm_dialog button').button();
|
||||
|
||||
$('#saveas_vm_dialog').dialog('open');
|
||||
}
|
||||
|
||||
function saveasDisksCallback(req,response){
|
||||
var vm_info = response.VM;
|
||||
var id=vm_info.ID;
|
||||
var select="";
|
||||
|
||||
var gen_option = function(id, name, source){
|
||||
if (name){
|
||||
return '<option value="'+id+'">'+name+' (disk id: '+id+')</option>';
|
||||
}
|
||||
else {
|
||||
return '<option value="'+id+'">'+source+' (disk id: '+id+')</option>';
|
||||
}
|
||||
}
|
||||
|
||||
var disks = vm_info.TEMPLATE.DISK;
|
||||
if (!disks) { select = '<option value="">No disks defined</option>';}
|
||||
else if (disks.constructor == Array) //several disks
|
||||
{
|
||||
for (var i=0;i<disks.length;i++){
|
||||
select += gen_option(disks[i].DISK_ID,disks[i].IMAGE,disks[i].SOURCE);
|
||||
}
|
||||
} else {
|
||||
select+= gen_option(disks.DISK_ID,disks.IMAGE,disks.SOURCE);
|
||||
}
|
||||
//introduce options in the right tab
|
||||
$('#saveas_tabs #saveas_tab_'+id+' #vm_disk_id').html(select);
|
||||
|
||||
}
|
||||
|
||||
//Prepares autorefresh
|
||||
function setVMAutorefresh(){
|
||||
setInterval(function(){
|
||||
@ -765,6 +836,131 @@ function setVMAutorefresh(){
|
||||
},INTERVAL+someTime()); //so that not all refreshing is done at the same time
|
||||
}
|
||||
|
||||
|
||||
function updateVNCState(rfb, state, oldstate, msg) {
|
||||
var s, sb, cad, klass;
|
||||
s = $D('VNC_status');
|
||||
sb = $D('VNC_status_bar');
|
||||
cad = $D('sendCtrlAltDelButton');
|
||||
switch (state) {
|
||||
case 'failed':
|
||||
case 'fatal':
|
||||
klass = "VNC_status_error";
|
||||
break;
|
||||
case 'normal':
|
||||
klass = "VNC_status_normal";
|
||||
break;
|
||||
case 'disconnected':
|
||||
case 'loaded':
|
||||
klass = "VNC_status_normal";
|
||||
break;
|
||||
case 'password':
|
||||
klass = "VNC_status_warn";
|
||||
break;
|
||||
default:
|
||||
klass = "VNC_status_warn";
|
||||
}
|
||||
|
||||
if (state === "normal") { cad.disabled = false; }
|
||||
else { cad.disabled = true; }
|
||||
|
||||
if (typeof(msg) !== 'undefined') {
|
||||
sb.setAttribute("class", klass);
|
||||
s.innerHTML = msg;
|
||||
}
|
||||
}
|
||||
|
||||
//setups VNC application
|
||||
function setupVNC(){
|
||||
|
||||
//Append to DOM
|
||||
$('div#dialogs').append('<div id="vnc_dialog" title="VNC connection"></div>');
|
||||
|
||||
$('#vnc_dialog').html('\
|
||||
<div id="VNC_status_bar" class="VNC_status_bar" style="margin-top: 0px;">\
|
||||
<table border=0 width="100%"><tr>\
|
||||
<td><div id="VNC_status">Loading</div></td>\
|
||||
<td width="1%"><div id="VNC_buttons">\
|
||||
<input type=button value="Send CtrlAltDel"\
|
||||
id="sendCtrlAltDelButton">\
|
||||
</div></td>\
|
||||
</tr></table>\
|
||||
</div>\
|
||||
<canvas id="VNC_canvas" width="640px" height="20px">\
|
||||
Canvas not supported.\
|
||||
</canvas>\
|
||||
');
|
||||
|
||||
$('#sendCtrlAltDelButton').click(function(){
|
||||
rfb.sendCtrlAltDel();
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#vnc_dialog').dialog({
|
||||
autoOpen:false,
|
||||
width:700,
|
||||
modal:true,
|
||||
height:500,
|
||||
resizable:true,
|
||||
});
|
||||
|
||||
$( "#vnc_dialog" ).bind( "dialogclose", function(event, ui) {
|
||||
var id = $("#vnc_dialog").attr("vm_id");
|
||||
Sunstone.runAction("VM.stopvnc",id);
|
||||
|
||||
});
|
||||
|
||||
$('.vnc').live("click",function(){
|
||||
//Which VM is it?
|
||||
var id = $(this).attr("vm_id");
|
||||
//Set attribute to dialog
|
||||
$('#vnc_dialog').attr("vm_id",id);
|
||||
//Request proxy server start
|
||||
Sunstone.runAction("VM.startvnc",id);
|
||||
return false;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function vncCallback(request,response){
|
||||
rfb = new RFB({'target': $D('VNC_canvas'),
|
||||
'encrypt': false,
|
||||
'true_color': true,
|
||||
'local_cursor': true,
|
||||
'shared': true,
|
||||
'updateState': updateVNCState});
|
||||
//fetch things from clicked element host - port - password
|
||||
vnc_port = response["port"];
|
||||
|
||||
//Hopefully this is returning sunstone server address, where
|
||||
//the proxy is running
|
||||
vnc_host = window.location.hostname;
|
||||
vnc_pw = response["password"];
|
||||
|
||||
setTimeout(function(){
|
||||
rfb.connect(vnc_host, vnc_port, vnc_pw);
|
||||
$('#vnc_dialog').dialog('open');
|
||||
},4000);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function vncIcon(vm){
|
||||
var graphics = vm.TEMPLATE.GRAPHICS;
|
||||
var state = OpenNebula.Helper.resource_state("vm_lcm",vm.LCM_STATE);
|
||||
var gr_icon;
|
||||
if (graphics && graphics.TYPE == "vnc" && state == "RUNNING"){
|
||||
gr_icon = '<a class="vnc" href="#" vm_id="'+vm.ID+'">';
|
||||
gr_icon += '<img src="images/vnc_on.png" alt="Open VNC Session" /></a>';
|
||||
}
|
||||
else {
|
||||
gr_icon = '<img src="images/vnc_off.png" alt="VNC Disabled" />';
|
||||
}
|
||||
return gr_icon;
|
||||
|
||||
}
|
||||
|
||||
// At this point the DOM is ready and the sunstone.js ready() has been run.
|
||||
$(document).ready(function(){
|
||||
|
||||
@ -776,7 +972,7 @@ $(document).ready(function(){
|
||||
"aoColumnDefs": [
|
||||
{ "bSortable": false, "aTargets": ["check"] },
|
||||
{ "sWidth": "60px", "aTargets": [0] },
|
||||
{ "sWidth": "35px", "aTargets": [1] },
|
||||
{ "sWidth": "35px", "aTargets": [1,9] },
|
||||
{ "sWidth": "100px", "aTargets": [2] }
|
||||
]
|
||||
});
|
||||
@ -784,12 +980,13 @@ $(document).ready(function(){
|
||||
dataTable_vMachines.fnClearTable();
|
||||
addElement([
|
||||
spinner,
|
||||
'','','','','','','',''],dataTable_vMachines);
|
||||
'','','','','','','','',''],dataTable_vMachines);
|
||||
Sunstone.runAction("VM.list");
|
||||
|
||||
setupCreateVMDialog();
|
||||
setupSaveasDialog();
|
||||
setVMAutorefresh();
|
||||
setupVNC();
|
||||
|
||||
initCheckAllBoxes(dataTable_vMachines);
|
||||
tableCheckboxesListener(dataTable_vMachines);
|
||||
|
@ -381,7 +381,7 @@ function updateVNetworkInfo(request,vn){
|
||||
<thead>\
|
||||
<tr><th colspan="2">Leases information</th></tr>\
|
||||
</thead>'+
|
||||
prettyPrintJSON(vn_info.LEASES)+
|
||||
prettyPrintJSON(vn_info.LEASES.LEASE)+
|
||||
'</table>';
|
||||
}
|
||||
|
||||
|
@ -187,23 +187,86 @@ function notifyError(msg){
|
||||
$.jGrowl(msg, {theme: "jGrowl-notify-error", sticky: true });
|
||||
}
|
||||
|
||||
function notifyMessage(msg){
|
||||
msg = "<h1>Info</h1>" + msg;
|
||||
|
||||
$.jGrowl(msg, {theme: "jGrowl-notify-submit"});
|
||||
}
|
||||
|
||||
// Returns an HTML string with the json keys and values in the form
|
||||
// key: value<br />
|
||||
// It recursively explores objects
|
||||
function prettyPrintJSON(template_json,padding,weight, border_bottom){
|
||||
function prettyPrintJSON(template_json,padding,weight, border_bottom,padding_top_bottom){
|
||||
var str = ""
|
||||
if (!template_json){ return "Not defined";}
|
||||
if (!padding) {padding=0};
|
||||
if (!weight) {weight="bold";}
|
||||
if (!border_bottom) {border_bottom = "1px solid #CCCCCC";}
|
||||
if (!padding_top_bottom) {padding_top_bottom=6;}
|
||||
var field = null;
|
||||
|
||||
for (field in template_json) {
|
||||
if (typeof template_json[field] == 'object'){
|
||||
str += '<tr><td class="key_td" style="padding-left:'+padding+'px;font-weight:'+weight+';border-bottom:'+border_bottom+'">'+field+'</td><td class="value_td" style="border-bottom:'+border_bottom+'"></td></tr>';
|
||||
str += prettyPrintJSON(template_json[field],padding+25,"normal","0") + '<tr><td class="key_td" style="padding-left:'+(padding+10)+'px"></td><td class="value_td"></td></tr>';
|
||||
if (template_json.constructor == Array){
|
||||
for (field = 0; field < template_json.length; ++field){
|
||||
str += prettyPrintRowJSON(field,template_json[field],padding,weight, border_bottom,padding_top_bottom);
|
||||
}
|
||||
} else {
|
||||
for (field in template_json) {
|
||||
str += prettyPrintRowJSON(field,template_json[field],padding,weight, border_bottom,padding_top_bottom);
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
function prettyPrintRowJSON(field,value,padding,weight, border_bottom,padding_top_bottom){
|
||||
var str="";
|
||||
|
||||
if (typeof value == 'object'){
|
||||
//name of field row
|
||||
str += '<tr>\
|
||||
<td class="key_td" style=\
|
||||
"padding-left:'+padding+'px;\
|
||||
font-weight:'+weight+';\
|
||||
border-bottom:'+border_bottom+';\
|
||||
padding-top:'+padding_top_bottom+'px;\
|
||||
padding-bottom:'+padding_top_bottom+'px;">'
|
||||
+field+
|
||||
'</td>\
|
||||
<td class="value_td" style=\
|
||||
"border-bottom:'+border_bottom+';\
|
||||
padding-top:'+padding_top_bottom+'px;\
|
||||
padding-bottom:'+padding_top_bottom+'px">\
|
||||
</td>\
|
||||
</tr>';
|
||||
//attributes rows
|
||||
//empty row - prettyprint - empty row
|
||||
str += '<tr>\
|
||||
<td class="key_td" style="border-bottom:0"></td>\
|
||||
<td class="value_td" style="border-bottom:0"></td>\
|
||||
</tr>' +
|
||||
prettyPrintJSON(value,padding+25,"normal","0",1) +
|
||||
'<tr>\
|
||||
<td class="key_td"></td>\
|
||||
<td class="value_td"></td>\
|
||||
</tr>';
|
||||
} else {
|
||||
str += '<tr><td class="key_td" style="padding-left:'+padding+'px;font-weight:'+weight+';border-bottom:'+border_bottom+'">'+field+'</td><td class="value_td" style="border-bottom:'+border_bottom+'">'+template_json[field]+'</td></tr>';
|
||||
};
|
||||
str += '<tr>\
|
||||
<td class="key_td" style="\
|
||||
padding-left:'+padding+'px;\
|
||||
font-weight:'+weight+';\
|
||||
border-bottom:'+border_bottom+';\
|
||||
padding-top:'+padding_top_bottom+'px;\
|
||||
padding-bottom:'+padding_top_bottom+'px">'+
|
||||
field+
|
||||
'</td>\
|
||||
<td class="value_td" style="\
|
||||
border-bottom:'+border_bottom+';\
|
||||
padding-top:'+padding_top_bottom+'px;\
|
||||
padding-bottom:'+padding_top_bottom+'px">'+
|
||||
value+
|
||||
'</td>\
|
||||
</tr>';
|
||||
};
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
@ -289,7 +352,7 @@ function onError(request,error_json) {
|
||||
var value;
|
||||
rows = ["method","action","object","id","reason"];
|
||||
message = "";
|
||||
for (i in rows){
|
||||
for (i = 0; i<rows.length; i++){
|
||||
key = rows[i];
|
||||
value = eval(key);
|
||||
if (value)
|
||||
|
@ -16,20 +16,40 @@
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
ONE_LOCATION = ENV["ONE_LOCATION"]
|
||||
|
||||
if !ONE_LOCATION
|
||||
LOG_LOCATION = "/var/log/one"
|
||||
VAR_LOCATION = "/var/lib/one"
|
||||
RUBY_LIB_LOCATION = "/usr/lib/one/ruby"
|
||||
CONFIGURATION_FILE = "/etc/one/sunstone-server.conf"
|
||||
else
|
||||
VAR_LOCATION = ONE_LOCATION+"/var"
|
||||
LOG_LOCATION = ONE_LOCATION+"/var"
|
||||
RUBY_LIB_LOCATION = ONE_LOCATION+"/lib/ruby"
|
||||
CONFIGURATION_FILE = ONE_LOCATION+"/etc/sunstone-server.conf"
|
||||
end
|
||||
|
||||
$: << RUBY_LIB_LOCATION
|
||||
$: << File.dirname(__FILE__)+'/models'
|
||||
|
||||
##############################################################################
|
||||
# Required libraries
|
||||
##############################################################################
|
||||
require 'rubygems'
|
||||
require 'sinatra'
|
||||
|
||||
require 'models/SunstoneServer'
|
||||
require 'cloud/Configuration'
|
||||
require 'SunstoneServer'
|
||||
|
||||
set :config, Configuration.new(CONFIGURATION_FILE)
|
||||
|
||||
##############################################################################
|
||||
# Sinatra Configuration
|
||||
##############################################################################
|
||||
use Rack::Session::Pool
|
||||
|
||||
set :host, settings.config[:host]
|
||||
set :port, settings.config[:port]
|
||||
|
||||
##############################################################################
|
||||
# Helpers
|
||||
@ -163,6 +183,56 @@ post '/:pool' do
|
||||
@SunstoneServer.create_resource(params[:pool], request.body.read)
|
||||
end
|
||||
|
||||
##############################################################################
|
||||
# Stop the VNC Session of a target VM
|
||||
##############################################################################
|
||||
post '/vm/:id/stopvnc' do
|
||||
vm_id = params[:id]
|
||||
vnc_hash = session['vnc']
|
||||
|
||||
if !vnc_hash || !vnc_hash[vm_id]
|
||||
msg = "It seems there is no VNC proxy running for this machine"
|
||||
return [403, OpenNebula::Error.new(msg).to_json]
|
||||
end
|
||||
|
||||
rc = @SunstoneServer.stopvnc(vm_id, vnc_hash[vm_id][:pipe])
|
||||
if rc[0] == 200
|
||||
session['vnc'].delete(vm_id)
|
||||
end
|
||||
|
||||
rc
|
||||
end
|
||||
|
||||
##############################################################################
|
||||
# Start a VNC Session for a target VM
|
||||
##############################################################################
|
||||
post '/vm/:id/startvnc' do
|
||||
vm_id = params[:id]
|
||||
|
||||
vnc_hash = session['vnc']
|
||||
|
||||
if !vnc_hash
|
||||
session['vnc']= {}
|
||||
elsif vnc_hash[vm_id]
|
||||
#return existing information
|
||||
info = vnc_hash[vm_id].clone
|
||||
info.delete(:pipe)
|
||||
|
||||
return [200, info.to_json]
|
||||
end
|
||||
|
||||
rc = @SunstoneServer.startvnc(vm_id, settings.config)
|
||||
if rc[0] == 200
|
||||
info = rc[1]
|
||||
session['vnc'][vm_id] = info.clone
|
||||
info.delete(:pipe)
|
||||
|
||||
[200, info.to_json]
|
||||
else
|
||||
rc
|
||||
end
|
||||
end
|
||||
|
||||
##############################################################################
|
||||
# Perform an action on a Resource
|
||||
##############################################################################
|
||||
|
@ -3,18 +3,21 @@
|
||||
<head>
|
||||
<title>OpenNebula Admin Console</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
|
||||
|
||||
|
||||
<!-- Vendor Libraries -->
|
||||
<link rel="stylesheet" type="text/css" href="/vendor/dataTables/demo_table_jui.css" />
|
||||
<link rel="stylesheet" type="text/css" href="/vendor/jQueryUI/jquery-ui-1.8.7.custom.css" />
|
||||
<link rel="stylesheet" type="text/css" href="/vendor/jGrowl/jquery.jgrowl.css" />
|
||||
<link rel="stylesheet" type="text/css" href="/vendor/jQueryLayout/layout-default-latest.css" />
|
||||
<link rel="stylesheet" href="/vendor/noVNC/include/plain.css">
|
||||
|
||||
<script type="text/javascript" src="/vendor/jQuery/jquery-1.4.4.min.js"></script>
|
||||
<script type="text/javascript" src="/vendor/jGrowl/jquery.jgrowl_minimized.js"></script>
|
||||
<script type="text/javascript" src="/vendor/jQueryUI/jquery-ui-1.8.7.custom.min.js"></script>
|
||||
<script type="text/javascript" src="/vendor/jQueryLayout/jquery.layout.min-1.2.0.js"></script>
|
||||
<script type="text/javascript" src="/vendor/dataTables/jquery.dataTables.min.js"></script>
|
||||
|
||||
|
||||
<!-- End Vendor Libraries -->
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="/css/application.css" />
|
||||
|
@ -149,7 +149,7 @@ void Nebula::start()
|
||||
log_location = nebula_location + "var/";
|
||||
var_location = nebula_location + "var/";
|
||||
hook_location = nebula_location + "share/hooks/";
|
||||
remotes_location = nebula_location + "lib/remotes/";
|
||||
remotes_location = nebula_location + "var/remotes/";
|
||||
|
||||
if ( nebula_configuration != 0)
|
||||
{
|
||||
|
@ -52,7 +52,7 @@ exec_and_log "mkdir -p $ISO_DIR"
|
||||
for f in $SRC; do
|
||||
case $f in
|
||||
http://*)
|
||||
exec_and_log "$WGET -O $ISO_DIR $f"
|
||||
exec_and_log "$WGET -P $ISO_DIR $f"
|
||||
;;
|
||||
|
||||
*)
|
||||
|
@ -48,7 +48,7 @@ exec_and_log "mkdir -p $ISO_DIR"
|
||||
for f in $SRC; do
|
||||
case $f in
|
||||
http://*)
|
||||
exec_and_log "$WGET -O $ISO_DIR $f" \
|
||||
exec_and_log "$WGET -P $ISO_DIR $f" \
|
||||
"Error downloading $f"
|
||||
;;
|
||||
|
||||
|
@ -53,7 +53,7 @@ exec_and_log "mkdir -p $ISO_DIR" \
|
||||
for f in $SRC; do
|
||||
case $f in
|
||||
http://*)
|
||||
exec_and_log "$WGET -O $ISO_DIR $f" \
|
||||
exec_and_log "$WGET -P $ISO_DIR $f" \
|
||||
"Error downloading $f"
|
||||
;;
|
||||
|
||||
|
@ -20,8 +20,6 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include <openssl/evp.h>
|
||||
#include <iomanip>
|
||||
|
||||
#include "User.h"
|
||||
@ -208,29 +206,3 @@ int User::split_secret(const string secret, string& user, string& pass)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
string User::sha1_digest(const string& pass)
|
||||
{
|
||||
EVP_MD_CTX mdctx;
|
||||
unsigned char md_value[EVP_MAX_MD_SIZE];
|
||||
unsigned int md_len;
|
||||
ostringstream oss;
|
||||
|
||||
EVP_MD_CTX_init(&mdctx);
|
||||
EVP_DigestInit_ex(&mdctx, EVP_sha1(), NULL);
|
||||
|
||||
EVP_DigestUpdate(&mdctx, pass.c_str(), pass.length());
|
||||
|
||||
EVP_DigestFinal_ex(&mdctx,md_value,&md_len);
|
||||
EVP_MD_CTX_cleanup(&mdctx);
|
||||
|
||||
for(unsigned int i = 0; i<md_len; i++)
|
||||
{
|
||||
oss << setfill('0') << setw(2) << hex << nouppercase
|
||||
<< (unsigned short) md_value[i];
|
||||
}
|
||||
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "NebulaLog.h"
|
||||
#include "Nebula.h"
|
||||
#include "AuthManager.h"
|
||||
#include "SSLTools.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <sys/types.h>
|
||||
@ -85,7 +86,7 @@ UserPool::UserPool(SqlDB * db):PoolSQL(db,User::table)
|
||||
if (User::split_secret(one_token,one_name,one_pass) == 0)
|
||||
{
|
||||
string error_str;
|
||||
string sha1_pass = User::sha1_digest(one_pass);
|
||||
string sha1_pass = SSLTools::sha1_digest(one_pass);
|
||||
|
||||
allocate(&one_uid, one_name, sha1_pass, true,
|
||||
GroupPool::ONEADMIN_ID, error_str);
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include "UserPool.h"
|
||||
#include "PoolTest.h"
|
||||
#include "SSLTools.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -119,7 +120,7 @@ public:
|
||||
string st = "top_secret_string";
|
||||
string sha1 = "773260f433f7fd6f89c1f1bfc32e080fc0748478";
|
||||
|
||||
CPPUNIT_ASSERT( sha1 == User::sha1_digest(st) );
|
||||
CPPUNIT_ASSERT( sha1 == SSLTools::sha1_digest(st) );
|
||||
}
|
||||
|
||||
void split_secret()
|
||||
@ -151,7 +152,7 @@ public:
|
||||
|
||||
CPPUNIT_ASSERT( user->get_oid() == 0 );
|
||||
CPPUNIT_ASSERT( user->get_name() == "one_user_test" );
|
||||
CPPUNIT_ASSERT( user->get_password() == User::sha1_digest("password") );
|
||||
CPPUNIT_ASSERT( user->get_password() == SSLTools::sha1_digest("password") );
|
||||
}
|
||||
|
||||
void authenticate()
|
||||
|
@ -21,11 +21,36 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static void parse_vm_arguments(VirtualMachine *vm, string& parsed)
|
||||
{
|
||||
size_t found;
|
||||
|
||||
found = parsed.find("$VMID");
|
||||
|
||||
if ( found !=string::npos )
|
||||
{
|
||||
ostringstream oss;
|
||||
oss << vm->get_oid();
|
||||
|
||||
parsed.replace(found,5,oss.str());
|
||||
}
|
||||
|
||||
found = parsed.find("$TEMPLATE");
|
||||
|
||||
if ( found != string::npos )
|
||||
{
|
||||
string templ;
|
||||
parsed.replace(found,9,vm->to_xml64(templ));
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void VirtualMachineAllocateHook::do_hook(void *arg)
|
||||
{
|
||||
VirtualMachine * vm;
|
||||
int rc;
|
||||
string parsed_args;
|
||||
string parsed_args = args;
|
||||
|
||||
vm = static_cast<VirtualMachine *>(arg);
|
||||
|
||||
@ -34,18 +59,15 @@ void VirtualMachineAllocateHook::do_hook(void *arg)
|
||||
return;
|
||||
}
|
||||
|
||||
rc = vm->parse_template_attribute(args, parsed_args);
|
||||
parse_vm_arguments(vm, parsed_args);
|
||||
|
||||
if ( rc == 0)
|
||||
Nebula& ne = Nebula::instance();
|
||||
HookManager * hm = ne.get_hm();
|
||||
const HookManagerDriver * hmd = hm->get();
|
||||
|
||||
if ( hmd != 0 )
|
||||
{
|
||||
Nebula& ne = Nebula::instance();
|
||||
HookManager * hm = ne.get_hm();
|
||||
const HookManagerDriver * hmd = hm->get();
|
||||
|
||||
if ( hmd != 0 )
|
||||
{
|
||||
hmd->execute(vm->get_oid(),name,cmd,parsed_args);
|
||||
}
|
||||
hmd->execute(vm->get_oid(),name,cmd,parsed_args);
|
||||
}
|
||||
}
|
||||
|
||||
@ -143,29 +165,28 @@ void VirtualMachineStateHook::do_hook(void *arg)
|
||||
|
||||
if ( cur_lcm == lcm && cur_vm == this->vm )
|
||||
{
|
||||
string parsed_args;
|
||||
string parsed_args = args;
|
||||
|
||||
if ( vm->parse_template_attribute(args, parsed_args) == 0)
|
||||
parse_vm_arguments(vm,parsed_args);
|
||||
|
||||
Nebula& ne = Nebula::instance();
|
||||
HookManager * hm = ne.get_hm();
|
||||
|
||||
const HookManagerDriver * hmd = hm->get();
|
||||
|
||||
if ( hmd != 0 )
|
||||
{
|
||||
Nebula& ne = Nebula::instance();
|
||||
HookManager * hm = ne.get_hm();
|
||||
|
||||
const HookManagerDriver * hmd = hm->get();
|
||||
|
||||
if ( hmd != 0 )
|
||||
if ( ! remote )
|
||||
{
|
||||
if ( ! remote )
|
||||
{
|
||||
hmd->execute(vm->get_oid(),name,cmd,parsed_args);
|
||||
}
|
||||
else if ( vm->hasHistory() )
|
||||
{
|
||||
hmd->execute(vm->get_oid(),
|
||||
name,
|
||||
vm->get_hostname(),
|
||||
cmd,
|
||||
parsed_args);
|
||||
}
|
||||
hmd->execute(vm->get_oid(),name,cmd,parsed_args);
|
||||
}
|
||||
else if ( vm->hasHistory() )
|
||||
{
|
||||
hmd->execute(vm->get_oid(),
|
||||
name,
|
||||
vm->get_hostname(),
|
||||
cmd,
|
||||
parsed_args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -392,8 +392,8 @@ static void yy_fatal_error (yyconst char msg[] );
|
||||
*yy_cp = '\0'; \
|
||||
(yy_c_buf_p) = yy_cp;
|
||||
|
||||
#define YY_NUM_RULES 11
|
||||
#define YY_END_OF_BUFFER 12
|
||||
#define YY_NUM_RULES 12
|
||||
#define YY_END_OF_BUFFER 13
|
||||
/* This struct is not used in this scanner,
|
||||
but its presence is necessary. */
|
||||
struct yy_trans_info
|
||||
@ -401,11 +401,12 @@ struct yy_trans_info
|
||||
flex_int32_t yy_verify;
|
||||
flex_int32_t yy_nxt;
|
||||
};
|
||||
static yyconst flex_int16_t yy_accept[30] =
|
||||
static yyconst flex_int16_t yy_accept[34] =
|
||||
{ 0,
|
||||
0, 0, 0, 0, 12, 10, 1, 9, 9, 11,
|
||||
9, 8, 3, 6, 2, 4, 5, 10, 0, 3,
|
||||
2, 5, 0, 7, 3, 6, 2, 4, 0
|
||||
0, 0, 0, 0, 0, 0, 13, 11, 1, 10,
|
||||
10, 12, 9, 3, 6, 2, 4, 5, 12, 8,
|
||||
11, 0, 3, 2, 5, 3, 6, 2, 4, 0,
|
||||
7, 8, 0
|
||||
} ;
|
||||
|
||||
static yyconst flex_int32_t yy_ec[256] =
|
||||
@ -419,7 +420,7 @@ static yyconst flex_int32_t yy_ec[256] =
|
||||
8, 1, 1, 1, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
9, 1, 10, 1, 7, 1, 7, 7, 7, 7,
|
||||
9, 1, 10, 1, 11, 1, 7, 7, 7, 7,
|
||||
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
@ -440,49 +441,52 @@ static yyconst flex_int32_t yy_ec[256] =
|
||||
1, 1, 1, 1, 1
|
||||
} ;
|
||||
|
||||
static yyconst flex_int32_t yy_meta[11] =
|
||||
static yyconst flex_int32_t yy_meta[12] =
|
||||
{ 0,
|
||||
1, 1, 1, 1, 2, 1, 1, 1, 1, 1
|
||||
1, 1, 1, 1, 2, 1, 3, 1, 1, 1,
|
||||
3
|
||||
} ;
|
||||
|
||||
static yyconst flex_int16_t yy_base[33] =
|
||||
static yyconst flex_int16_t yy_base[39] =
|
||||
{ 0,
|
||||
29, 28, 0, 0, 32, 0, 35, 35, 9, 35,
|
||||
27, 35, 28, 22, 26, 25, 35, 0, 0, 24,
|
||||
23, 35, 20, 35, 16, 9, 12, 11, 35, 19,
|
||||
11, 21
|
||||
41, 40, 0, 0, 8, 12, 44, 0, 47, 47,
|
||||
18, 47, 47, 41, 0, 40, 39, 47, 32, 20,
|
||||
0, 0, 23, 21, 47, 20, 0, 19, 16, 13,
|
||||
47, 7, 47, 28, 31, 34, 10, 37
|
||||
} ;
|
||||
|
||||
static yyconst flex_int16_t yy_def[33] =
|
||||
static yyconst flex_int16_t yy_def[39] =
|
||||
{ 0,
|
||||
30, 30, 29, 3, 29, 31, 29, 29, 29, 29,
|
||||
32, 29, 29, 29, 29, 29, 29, 31, 9, 29,
|
||||
29, 29, 32, 29, 29, 29, 29, 29, 0, 29,
|
||||
29, 29
|
||||
34, 34, 33, 3, 35, 35, 33, 36, 33, 33,
|
||||
33, 33, 33, 33, 37, 33, 33, 33, 38, 33,
|
||||
36, 11, 33, 33, 33, 33, 37, 33, 33, 38,
|
||||
33, 33, 0, 33, 33, 33, 33, 33
|
||||
} ;
|
||||
|
||||
static yyconst flex_int16_t yy_nxt[46] =
|
||||
static yyconst flex_int16_t yy_nxt[59] =
|
||||
{ 0,
|
||||
8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
|
||||
19, 18, 28, 27, 20, 26, 21, 25, 22, 6,
|
||||
6, 23, 23, 24, 27, 25, 28, 27, 26, 25,
|
||||
24, 29, 7, 7, 5, 29, 29, 29, 29, 29,
|
||||
29, 29, 29, 29, 29
|
||||
10, 11, 12, 10, 13, 14, 15, 16, 17, 18,
|
||||
15, 19, 27, 32, 20, 19, 31, 29, 20, 22,
|
||||
28, 26, 28, 23, 26, 24, 32, 25, 8, 8,
|
||||
8, 12, 12, 12, 21, 31, 21, 30, 30, 30,
|
||||
29, 28, 26, 33, 9, 9, 7, 33, 33, 33,
|
||||
33, 33, 33, 33, 33, 33, 33, 33
|
||||
} ;
|
||||
|
||||
static yyconst flex_int16_t yy_chk[46] =
|
||||
static yyconst flex_int16_t yy_chk[59] =
|
||||
{ 0,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
9, 31, 28, 27, 9, 26, 9, 25, 9, 30,
|
||||
30, 32, 32, 23, 21, 20, 16, 15, 14, 13,
|
||||
11, 5, 2, 1, 29, 29, 29, 29, 29, 29,
|
||||
29, 29, 29, 29, 29
|
||||
3, 5, 37, 32, 5, 6, 30, 29, 6, 11,
|
||||
28, 26, 24, 11, 23, 11, 20, 11, 34, 34,
|
||||
34, 35, 35, 35, 36, 19, 36, 38, 38, 38,
|
||||
17, 16, 14, 7, 2, 1, 33, 33, 33, 33,
|
||||
33, 33, 33, 33, 33, 33, 33, 33
|
||||
} ;
|
||||
|
||||
/* Table of booleans, true if rule could match eol. */
|
||||
static yyconst flex_int32_t yy_rule_can_match_eol[12] =
|
||||
static yyconst flex_int32_t yy_rule_can_match_eol[13] =
|
||||
{ 0,
|
||||
0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, };
|
||||
0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, };
|
||||
|
||||
static yy_state_type yy_last_accepting_state;
|
||||
static char *yy_last_accepting_cpos;
|
||||
@ -532,10 +536,12 @@ char *vm_var_text;
|
||||
llocp->first_column = llocp->last_column; \
|
||||
llocp->last_column += vm_var_leng;
|
||||
|
||||
#line 536 "vm_var_parser.c"
|
||||
|
||||
#line 541 "vm_var_parser.c"
|
||||
|
||||
#define INITIAL 0
|
||||
#define VAR 1
|
||||
#define VALUE 2
|
||||
|
||||
#ifndef YY_NO_UNISTD_H
|
||||
/* Special case for "unistd.h", since it is non-ANSI. We include it way
|
||||
@ -713,7 +719,7 @@ YY_DECL
|
||||
register char *yy_cp, *yy_bp;
|
||||
register int yy_act;
|
||||
|
||||
#line 42 "vm_var_parser.l"
|
||||
#line 43 "vm_var_parser.l"
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -724,7 +730,7 @@ YY_DECL
|
||||
/* $NUM.CONTEXT_VARIABLE */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#line 728 "vm_var_parser.c"
|
||||
#line 734 "vm_var_parser.c"
|
||||
|
||||
if ( !(yy_init) )
|
||||
{
|
||||
@ -777,13 +783,13 @@ yy_match:
|
||||
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
|
||||
{
|
||||
yy_current_state = (int) yy_def[yy_current_state];
|
||||
if ( yy_current_state >= 30 )
|
||||
if ( yy_current_state >= 34 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
++yy_cp;
|
||||
}
|
||||
while ( yy_base[yy_current_state] != 35 );
|
||||
while ( yy_base[yy_current_state] != 47 );
|
||||
|
||||
yy_find_action:
|
||||
yy_act = yy_accept[yy_current_state];
|
||||
@ -819,60 +825,69 @@ do_action: /* This label is used only to access EOF actions. */
|
||||
|
||||
case 1:
|
||||
YY_RULE_SETUP
|
||||
#line 52 "vm_var_parser.l"
|
||||
#line 53 "vm_var_parser.l"
|
||||
{ BEGIN VAR;}
|
||||
YY_BREAK
|
||||
case 2:
|
||||
YY_RULE_SETUP
|
||||
#line 54 "vm_var_parser.l"
|
||||
{ return EQUAL;}
|
||||
#line 55 "vm_var_parser.l"
|
||||
{ BEGIN VALUE; return EQUAL; }
|
||||
YY_BREAK
|
||||
case 3:
|
||||
YY_RULE_SETUP
|
||||
#line 55 "vm_var_parser.l"
|
||||
#line 56 "vm_var_parser.l"
|
||||
{ return COMMA;}
|
||||
YY_BREAK
|
||||
case 4:
|
||||
YY_RULE_SETUP
|
||||
#line 56 "vm_var_parser.l"
|
||||
#line 57 "vm_var_parser.l"
|
||||
{ return OBRACKET;}
|
||||
YY_BREAK
|
||||
case 5:
|
||||
YY_RULE_SETUP
|
||||
#line 57 "vm_var_parser.l"
|
||||
#line 58 "vm_var_parser.l"
|
||||
{ return CBRACKET;}
|
||||
YY_BREAK
|
||||
case 6:
|
||||
YY_RULE_SETUP
|
||||
#line 59 "vm_var_parser.l"
|
||||
#line 60 "vm_var_parser.l"
|
||||
{ lvalp->val_str =
|
||||
mem_collector_strdup(mc,vm_var_text);
|
||||
mem_collector_strdup(mc,vm_var_text);
|
||||
return VARIABLE;}
|
||||
YY_BREAK
|
||||
case 7:
|
||||
/* rule 7 can match eol */
|
||||
YY_RULE_SETUP
|
||||
#line 63 "vm_var_parser.l"
|
||||
#line 64 "vm_var_parser.l"
|
||||
{ lvalp->val_str =
|
||||
mem_collector_strdup(mc,vm_var_text+1);
|
||||
mem_collector_strdup(mc,vm_var_text+1);
|
||||
lvalp->val_str[vm_var_leng-2] = '\0';
|
||||
BEGIN(VAR);
|
||||
return STRING;}
|
||||
YY_BREAK
|
||||
case 8:
|
||||
YY_RULE_SETUP
|
||||
#line 68 "vm_var_parser.l"
|
||||
{ lvalp->val_char = '\0';
|
||||
return EOA;}
|
||||
#line 70 "vm_var_parser.l"
|
||||
{ lvalp->val_str =
|
||||
mem_collector_strdup(mc,vm_var_text);
|
||||
BEGIN(VAR);
|
||||
return STRING;}
|
||||
YY_BREAK
|
||||
case 9:
|
||||
YY_RULE_SETUP
|
||||
#line 71 "vm_var_parser.l"
|
||||
#line 75 "vm_var_parser.l"
|
||||
{ lvalp->val_char = '\0';
|
||||
return EOA;}
|
||||
YY_BREAK
|
||||
case 10:
|
||||
YY_RULE_SETUP
|
||||
#line 78 "vm_var_parser.l"
|
||||
{ lvalp->val_char = *vm_var_text;
|
||||
BEGIN(INITIAL);
|
||||
return EOA;}
|
||||
YY_BREAK
|
||||
case YY_STATE_EOF(VAR):
|
||||
#line 75 "vm_var_parser.l"
|
||||
#line 82 "vm_var_parser.l"
|
||||
{ lvalp->val_char = '\0';
|
||||
BEGIN(INITIAL);
|
||||
return EOA;}
|
||||
@ -880,19 +895,20 @@ case YY_STATE_EOF(VAR):
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Just copy the string verbatim till we find a variable (starts with $) */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
case 10:
|
||||
/* rule 10 can match eol */
|
||||
case 11:
|
||||
/* rule 11 can match eol */
|
||||
YY_RULE_SETUP
|
||||
#line 83 "vm_var_parser.l"
|
||||
#line 90 "vm_var_parser.l"
|
||||
{ lvalp->val_str = mem_collector_strdup(mc,vm_var_text); return RSTRING;}
|
||||
YY_BREAK
|
||||
case 11:
|
||||
case 12:
|
||||
YY_RULE_SETUP
|
||||
#line 85 "vm_var_parser.l"
|
||||
#line 92 "vm_var_parser.l"
|
||||
ECHO;
|
||||
YY_BREAK
|
||||
#line 895 "vm_var_parser.c"
|
||||
#line 910 "vm_var_parser.c"
|
||||
case YY_STATE_EOF(INITIAL):
|
||||
case YY_STATE_EOF(VALUE):
|
||||
yyterminate();
|
||||
|
||||
case YY_END_OF_BUFFER:
|
||||
@ -1183,7 +1199,7 @@ static int yy_get_next_buffer (void)
|
||||
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
|
||||
{
|
||||
yy_current_state = (int) yy_def[yy_current_state];
|
||||
if ( yy_current_state >= 30 )
|
||||
if ( yy_current_state >= 34 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
@ -1211,11 +1227,11 @@ static int yy_get_next_buffer (void)
|
||||
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
|
||||
{
|
||||
yy_current_state = (int) yy_def[yy_current_state];
|
||||
if ( yy_current_state >= 30 )
|
||||
if ( yy_current_state >= 34 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
yy_is_jam = (yy_current_state == 29);
|
||||
yy_is_jam = (yy_current_state == 33);
|
||||
|
||||
return yy_is_jam ? 0 : yy_current_state;
|
||||
}
|
||||
@ -1860,7 +1876,7 @@ void vm_var_free (void * ptr )
|
||||
|
||||
#define YYTABLES_NAME "yytables"
|
||||
|
||||
#line 85 "vm_var_parser.l"
|
||||
#line 92 "vm_var_parser.l"
|
||||
|
||||
|
||||
|
||||
|
@ -39,6 +39,7 @@
|
||||
%option yylineno
|
||||
|
||||
%x VAR
|
||||
%x VALUE
|
||||
%%
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@ -51,18 +52,24 @@
|
||||
|
||||
\$ { BEGIN VAR;}
|
||||
|
||||
<VAR>[[:blank:]]*=[[:blank:]]* { return EQUAL;}
|
||||
<VAR>[[:blank:]]*=[[:blank:]]* { BEGIN VALUE; return EQUAL; }
|
||||
<VAR>[[:blank:]]*,[[:blank:]]* { return COMMA;}
|
||||
<VAR>\[[[:blank:]]* { return OBRACKET;}
|
||||
<VAR>[[:blank:]]*\] { return CBRACKET;}
|
||||
|
||||
<VAR>[[:alnum:]_]+ { lvalp->val_str =
|
||||
mem_collector_strdup(mc,yytext);
|
||||
mem_collector_strdup(mc,yytext);
|
||||
return VARIABLE;}
|
||||
|
||||
<VAR>\"[^\"]*\" { lvalp->val_str =
|
||||
mem_collector_strdup(mc,yytext+1);
|
||||
<VALUE>\"[^\"]*\" { lvalp->val_str =
|
||||
mem_collector_strdup(mc,yytext+1);
|
||||
lvalp->val_str[yyleng-2] = '\0';
|
||||
BEGIN(VAR);
|
||||
return STRING;}
|
||||
|
||||
<VALUE>[[:alnum:]]+ { lvalp->val_str =
|
||||
mem_collector_strdup(mc,yytext);
|
||||
BEGIN(VAR);
|
||||
return STRING;}
|
||||
|
||||
<VAR>\$ { lvalp->val_char = '\0';
|
||||
|
@ -136,6 +136,92 @@ extern "C"
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void get_image_attribute(VirtualMachine * vm,
|
||||
const string& attr_name,
|
||||
const string& img_name,
|
||||
const string& img_value,
|
||||
string& attr_value)
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
||||
ImagePool * ipool = nd.get_ipool();
|
||||
Image * img;
|
||||
int iid = -1;
|
||||
string iid_str;
|
||||
|
||||
int num;
|
||||
vector<const Attribute *> attrs;
|
||||
const VectorAttribute * disk;
|
||||
|
||||
attr_value.clear();
|
||||
|
||||
if (img_name.empty() || img_name != "IMAGE_ID")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
// Check that the image is in the template, so
|
||||
// are sure that we can access the image template
|
||||
// ----------------------------------------------
|
||||
num = vm->get_template_attribute("DISK",attrs);
|
||||
|
||||
for (int i=0; i < num ;i++)
|
||||
{
|
||||
disk = dynamic_cast<const VectorAttribute *>(attrs[i]);
|
||||
|
||||
if ( disk == 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
iid_str = disk->vector_value("IMAGE_ID");
|
||||
|
||||
if ( iid_str == img_value )
|
||||
{
|
||||
istringstream iss(img_value);
|
||||
|
||||
iss >> iid;
|
||||
|
||||
if (iss.fail())
|
||||
{
|
||||
iid = -1;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (iid == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
// Get the attribute template from the image
|
||||
// ----------------------------------------------
|
||||
img = ipool->get(iid, true);
|
||||
|
||||
if ( img == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (attr_name == "TEMPLATE")
|
||||
{
|
||||
attr_value = img->to_xml64(attr_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
img->get_template_attribute(attr_name.c_str(),attr_value);
|
||||
}
|
||||
|
||||
img->unlock();
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void get_network_attribute(VirtualMachine * vm,
|
||||
const string& attr_name,
|
||||
const string& net_name,
|
||||
@ -146,52 +232,112 @@ void get_network_attribute(VirtualMachine * vm,
|
||||
|
||||
VirtualNetworkPool * vnpool = nd.get_vnpool();
|
||||
VirtualNetwork * vn;
|
||||
int vnet_id = -1;
|
||||
string vnet_id_str;
|
||||
|
||||
string network = "";
|
||||
int num;
|
||||
vector<const Attribute *> attrs;
|
||||
const VectorAttribute * net;
|
||||
|
||||
attr_value = "";
|
||||
attr_value.clear();
|
||||
|
||||
if (net_name.empty())
|
||||
{
|
||||
vector<const Attribute *> nics;
|
||||
const VectorAttribute * nic;
|
||||
|
||||
if (vm->get_template_attribute("NIC",nics) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
nic = dynamic_cast<const VectorAttribute * >(nics[0]);
|
||||
|
||||
if ( nic == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
network = nic->vector_value("NETWORK");
|
||||
}
|
||||
else if (net_name == "NAME")
|
||||
{
|
||||
network = net_value;
|
||||
}
|
||||
|
||||
if ( network.empty() )
|
||||
if (net_name.empty() || net_name != "NETWORK_ID")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vn = vnpool->get(network, vm->get_uid(), true);
|
||||
// ----------------------------------------------
|
||||
// Check that the network is in the template, so
|
||||
// are sure that we can access its template
|
||||
// ----------------------------------------------
|
||||
num = vm->get_template_attribute("NIC",attrs);
|
||||
|
||||
for (int i=0; i < num ;i++)
|
||||
{
|
||||
net = dynamic_cast<const VectorAttribute *>(attrs[i]);
|
||||
|
||||
if ( net == 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
vnet_id_str = net->vector_value("NETWORK_ID");
|
||||
|
||||
if ( vnet_id_str == net_value )
|
||||
{
|
||||
istringstream iss(net_value);
|
||||
|
||||
iss >> vnet_id;
|
||||
|
||||
if (iss.fail())
|
||||
{
|
||||
vnet_id = -1;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (vnet_id == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
// Get the attribute template from the image
|
||||
// ----------------------------------------------
|
||||
vn = vnpool->get(vnet_id, true);
|
||||
|
||||
if ( vn == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vn->get_template_attribute(attr_name.c_str(),attr_value);
|
||||
if (attr_name == "TEMPLATE")
|
||||
{
|
||||
attr_value = vn->to_xml64(attr_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
vn->get_template_attribute(attr_name.c_str(),attr_value);
|
||||
}
|
||||
|
||||
vn->unlock();
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/*
|
||||
void get_user_attribute(VirtualMachine * vm,
|
||||
const string& attr_name,
|
||||
string& attr_value)
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
||||
UserPool * upool = nd.get_upool();
|
||||
User * user;
|
||||
|
||||
attr_value.clear();
|
||||
|
||||
user = upool->get(vm->get_uid(), true);
|
||||
|
||||
if ( user == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (attr_name == "TEMPLATE")
|
||||
{
|
||||
attr_value = user->to_xml64(attr_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
user->get_template_attribute(attr_name.c_str(),attr_value);
|
||||
}
|
||||
|
||||
user->unlock();
|
||||
}
|
||||
*/
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
@ -201,9 +347,23 @@ void insert_single(VirtualMachine * vm,
|
||||
{
|
||||
string value = "";
|
||||
|
||||
vm->get_template_attribute(name.c_str(),value);
|
||||
if (name == "TEMPLATE")
|
||||
{
|
||||
vm->to_xml64(value);
|
||||
}
|
||||
else if (name == "UID")
|
||||
{
|
||||
parsed << vm->get_uid();
|
||||
}
|
||||
else
|
||||
{
|
||||
vm->get_template_attribute(name.c_str(),value);
|
||||
}
|
||||
|
||||
parsed << value;
|
||||
if (!value.empty())
|
||||
{
|
||||
parsed << value;
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@ -222,7 +382,7 @@ void insert_vector(VirtualMachine * vm,
|
||||
|
||||
int num;
|
||||
|
||||
if ( name == "NETWORK")
|
||||
if (name == "NETWORK")
|
||||
{
|
||||
string value;
|
||||
|
||||
@ -235,35 +395,50 @@ void insert_vector(VirtualMachine * vm,
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ( num = vm->get_template_attribute(name.c_str(),values) ) <= 0 )
|
||||
else if (name == "IMAGE")
|
||||
{
|
||||
string value;
|
||||
|
||||
get_image_attribute(vm,vname,vvar,vval,value);
|
||||
|
||||
if (!value.empty())
|
||||
{
|
||||
parsed << value;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( vvar.empty() )
|
||||
{
|
||||
vattr = dynamic_cast<const VectorAttribute *>(values[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
const VectorAttribute * tmp = 0;
|
||||
|
||||
for (int i=0 ; i < num ; i++)
|
||||
if ( ( num = vm->get_template_attribute(name.c_str(),values) ) <= 0 )
|
||||
{
|
||||
tmp = dynamic_cast<const VectorAttribute *>(values[i]);
|
||||
return;
|
||||
}
|
||||
|
||||
if ( tmp && ( tmp->vector_value(vvar.c_str()) == vval ))
|
||||
if ( vvar.empty() )
|
||||
{
|
||||
vattr = dynamic_cast<const VectorAttribute *>(values[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
const VectorAttribute * tmp = 0;
|
||||
|
||||
for (int i=0 ; i < num ; i++)
|
||||
{
|
||||
vattr = tmp;
|
||||
break;
|
||||
tmp = dynamic_cast<const VectorAttribute *>(values[i]);
|
||||
|
||||
if ( tmp && ( tmp->vector_value(vvar.c_str()) == vval ))
|
||||
{
|
||||
vattr = tmp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( vattr != 0 )
|
||||
{
|
||||
parsed << vattr->vector_value(vname.c_str());
|
||||
if ( vattr != 0 )
|
||||
{
|
||||
parsed << vattr->vector_value(vname.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -273,7 +448,7 @@ void insert_vector(VirtualMachine * vm,
|
||||
|
||||
|
||||
/* Line 189 of yacc.c */
|
||||
#line 277 "vm_var_syntax.cc"
|
||||
#line 452 "vm_var_syntax.cc"
|
||||
|
||||
/* Enabling traces. */
|
||||
#ifndef YYDEBUG
|
||||
@ -319,7 +494,7 @@ typedef union YYSTYPE
|
||||
{
|
||||
|
||||
/* Line 214 of yacc.c */
|
||||
#line 220 "vm_var_syntax.y"
|
||||
#line 395 "vm_var_syntax.y"
|
||||
|
||||
char * val_str;
|
||||
int val_int;
|
||||
@ -328,7 +503,7 @@ typedef union YYSTYPE
|
||||
|
||||
|
||||
/* Line 214 of yacc.c */
|
||||
#line 332 "vm_var_syntax.cc"
|
||||
#line 507 "vm_var_syntax.cc"
|
||||
} YYSTYPE;
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
@ -353,7 +528,7 @@ typedef struct YYLTYPE
|
||||
|
||||
|
||||
/* Line 264 of yacc.c */
|
||||
#line 357 "vm_var_syntax.cc"
|
||||
#line 532 "vm_var_syntax.cc"
|
||||
|
||||
#ifdef short
|
||||
# undef short
|
||||
@ -639,7 +814,7 @@ static const yytype_int8 yyrhs[] =
|
||||
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
|
||||
static const yytype_uint16 yyrline[] =
|
||||
{
|
||||
0, 244, 244, 245, 248, 252, 265, 280
|
||||
0, 419, 419, 420, 423, 427, 440, 455
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -1612,7 +1787,7 @@ yyreduce:
|
||||
case 4:
|
||||
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 249 "vm_var_syntax.y"
|
||||
#line 424 "vm_var_syntax.y"
|
||||
{
|
||||
(*parsed) << (yyvsp[(1) - (1)].val_str);
|
||||
;}
|
||||
@ -1621,7 +1796,7 @@ yyreduce:
|
||||
case 5:
|
||||
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 253 "vm_var_syntax.y"
|
||||
#line 428 "vm_var_syntax.y"
|
||||
{
|
||||
string name((yyvsp[(1) - (2)].val_str));
|
||||
|
||||
@ -1639,7 +1814,7 @@ yyreduce:
|
||||
case 6:
|
||||
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 266 "vm_var_syntax.y"
|
||||
#line 441 "vm_var_syntax.y"
|
||||
{
|
||||
string name((yyvsp[(1) - (5)].val_str));
|
||||
string vname((yyvsp[(3) - (5)].val_str));
|
||||
@ -1659,7 +1834,7 @@ yyreduce:
|
||||
case 7:
|
||||
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 281 "vm_var_syntax.y"
|
||||
#line 456 "vm_var_syntax.y"
|
||||
{
|
||||
string name((yyvsp[(1) - (9)].val_str));
|
||||
string vname((yyvsp[(3) - (9)].val_str));
|
||||
@ -1682,7 +1857,7 @@ yyreduce:
|
||||
|
||||
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 1686 "vm_var_syntax.cc"
|
||||
#line 1861 "vm_var_syntax.cc"
|
||||
default: break;
|
||||
}
|
||||
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
|
||||
@ -1901,7 +2076,7 @@ yyreturn:
|
||||
|
||||
|
||||
/* Line 1684 of yacc.c */
|
||||
#line 299 "vm_var_syntax.y"
|
||||
#line 474 "vm_var_syntax.y"
|
||||
|
||||
|
||||
extern "C" void vm_var__error(
|
||||
|
@ -57,7 +57,7 @@ typedef union YYSTYPE
|
||||
{
|
||||
|
||||
/* Line 1685 of yacc.c */
|
||||
#line 220 "vm_var_syntax.y"
|
||||
#line 395 "vm_var_syntax.y"
|
||||
|
||||
char * val_str;
|
||||
int val_int;
|
||||
|
@ -74,6 +74,92 @@ extern "C"
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void get_image_attribute(VirtualMachine * vm,
|
||||
const string& attr_name,
|
||||
const string& img_name,
|
||||
const string& img_value,
|
||||
string& attr_value)
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
||||
ImagePool * ipool = nd.get_ipool();
|
||||
Image * img;
|
||||
int iid = -1;
|
||||
string iid_str;
|
||||
|
||||
int num;
|
||||
vector<const Attribute *> attrs;
|
||||
const VectorAttribute * disk;
|
||||
|
||||
attr_value.clear();
|
||||
|
||||
if (img_name.empty() || img_name != "IMAGE_ID")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
// Check that the image is in the template, so
|
||||
// are sure that we can access the image template
|
||||
// ----------------------------------------------
|
||||
num = vm->get_template_attribute("DISK",attrs);
|
||||
|
||||
for (int i=0; i < num ;i++)
|
||||
{
|
||||
disk = dynamic_cast<const VectorAttribute *>(attrs[i]);
|
||||
|
||||
if ( disk == 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
iid_str = disk->vector_value("IMAGE_ID");
|
||||
|
||||
if ( iid_str == img_value )
|
||||
{
|
||||
istringstream iss(img_value);
|
||||
|
||||
iss >> iid;
|
||||
|
||||
if (iss.fail())
|
||||
{
|
||||
iid = -1;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (iid == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
// Get the attribute template from the image
|
||||
// ----------------------------------------------
|
||||
img = ipool->get(iid, true);
|
||||
|
||||
if ( img == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (attr_name == "TEMPLATE")
|
||||
{
|
||||
attr_value = img->to_xml64(attr_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
img->get_template_attribute(attr_name.c_str(),attr_value);
|
||||
}
|
||||
|
||||
img->unlock();
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void get_network_attribute(VirtualMachine * vm,
|
||||
const string& attr_name,
|
||||
const string& net_name,
|
||||
@ -84,52 +170,112 @@ void get_network_attribute(VirtualMachine * vm,
|
||||
|
||||
VirtualNetworkPool * vnpool = nd.get_vnpool();
|
||||
VirtualNetwork * vn;
|
||||
int vnet_id = -1;
|
||||
string vnet_id_str;
|
||||
|
||||
string network = "";
|
||||
int num;
|
||||
vector<const Attribute *> attrs;
|
||||
const VectorAttribute * net;
|
||||
|
||||
attr_value = "";
|
||||
attr_value.clear();
|
||||
|
||||
if (net_name.empty())
|
||||
{
|
||||
vector<const Attribute *> nics;
|
||||
const VectorAttribute * nic;
|
||||
|
||||
if (vm->get_template_attribute("NIC",nics) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
nic = dynamic_cast<const VectorAttribute * >(nics[0]);
|
||||
|
||||
if ( nic == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
network = nic->vector_value("NETWORK");
|
||||
}
|
||||
else if (net_name == "NAME")
|
||||
{
|
||||
network = net_value;
|
||||
}
|
||||
|
||||
if ( network.empty() )
|
||||
if (net_name.empty() || net_name != "NETWORK_ID")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vn = vnpool->get(network, vm->get_uid(), true);
|
||||
// ----------------------------------------------
|
||||
// Check that the network is in the template, so
|
||||
// are sure that we can access its template
|
||||
// ----------------------------------------------
|
||||
num = vm->get_template_attribute("NIC",attrs);
|
||||
|
||||
for (int i=0; i < num ;i++)
|
||||
{
|
||||
net = dynamic_cast<const VectorAttribute *>(attrs[i]);
|
||||
|
||||
if ( net == 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
vnet_id_str = net->vector_value("NETWORK_ID");
|
||||
|
||||
if ( vnet_id_str == net_value )
|
||||
{
|
||||
istringstream iss(net_value);
|
||||
|
||||
iss >> vnet_id;
|
||||
|
||||
if (iss.fail())
|
||||
{
|
||||
vnet_id = -1;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (vnet_id == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
// Get the attribute template from the image
|
||||
// ----------------------------------------------
|
||||
vn = vnpool->get(vnet_id, true);
|
||||
|
||||
if ( vn == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vn->get_template_attribute(attr_name.c_str(),attr_value);
|
||||
if (attr_name == "TEMPLATE")
|
||||
{
|
||||
attr_value = vn->to_xml64(attr_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
vn->get_template_attribute(attr_name.c_str(),attr_value);
|
||||
}
|
||||
|
||||
vn->unlock();
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/*
|
||||
void get_user_attribute(VirtualMachine * vm,
|
||||
const string& attr_name,
|
||||
string& attr_value)
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
||||
UserPool * upool = nd.get_upool();
|
||||
User * user;
|
||||
|
||||
attr_value.clear();
|
||||
|
||||
user = upool->get(vm->get_uid(), true);
|
||||
|
||||
if ( user == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (attr_name == "TEMPLATE")
|
||||
{
|
||||
attr_value = user->to_xml64(attr_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
user->get_template_attribute(attr_name.c_str(),attr_value);
|
||||
}
|
||||
|
||||
user->unlock();
|
||||
}
|
||||
*/
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
@ -139,9 +285,23 @@ void insert_single(VirtualMachine * vm,
|
||||
{
|
||||
string value = "";
|
||||
|
||||
vm->get_template_attribute(name.c_str(),value);
|
||||
if (name == "TEMPLATE")
|
||||
{
|
||||
vm->to_xml64(value);
|
||||
}
|
||||
else if (name == "UID")
|
||||
{
|
||||
parsed << vm->get_uid();
|
||||
}
|
||||
else
|
||||
{
|
||||
vm->get_template_attribute(name.c_str(),value);
|
||||
}
|
||||
|
||||
parsed << value;
|
||||
if (!value.empty())
|
||||
{
|
||||
parsed << value;
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@ -160,7 +320,7 @@ void insert_vector(VirtualMachine * vm,
|
||||
|
||||
int num;
|
||||
|
||||
if ( name == "NETWORK")
|
||||
if (name == "NETWORK")
|
||||
{
|
||||
string value;
|
||||
|
||||
@ -173,35 +333,50 @@ void insert_vector(VirtualMachine * vm,
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ( num = vm->get_template_attribute(name.c_str(),values) ) <= 0 )
|
||||
else if (name == "IMAGE")
|
||||
{
|
||||
string value;
|
||||
|
||||
get_image_attribute(vm,vname,vvar,vval,value);
|
||||
|
||||
if (!value.empty())
|
||||
{
|
||||
parsed << value;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( vvar.empty() )
|
||||
{
|
||||
vattr = dynamic_cast<const VectorAttribute *>(values[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
const VectorAttribute * tmp = 0;
|
||||
|
||||
for (int i=0 ; i < num ; i++)
|
||||
if ( ( num = vm->get_template_attribute(name.c_str(),values) ) <= 0 )
|
||||
{
|
||||
tmp = dynamic_cast<const VectorAttribute *>(values[i]);
|
||||
return;
|
||||
}
|
||||
|
||||
if ( tmp && ( tmp->vector_value(vvar.c_str()) == vval ))
|
||||
if ( vvar.empty() )
|
||||
{
|
||||
vattr = dynamic_cast<const VectorAttribute *>(values[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
const VectorAttribute * tmp = 0;
|
||||
|
||||
for (int i=0 ; i < num ; i++)
|
||||
{
|
||||
vattr = tmp;
|
||||
break;
|
||||
tmp = dynamic_cast<const VectorAttribute *>(values[i]);
|
||||
|
||||
if ( tmp && ( tmp->vector_value(vvar.c_str()) == vval ))
|
||||
{
|
||||
vattr = tmp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( vattr != 0 )
|
||||
{
|
||||
parsed << vattr->vector_value(vname.c_str());
|
||||
if ( vattr != 0 )
|
||||
{
|
||||
parsed << vattr->vector_value(vname.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user