Merge branch 'one-4.4' into feature-2345

This commit is contained in:
Jaime Melis committed 2013-11-15 16:19:42 +01:00
commit 1adce277a0
144 files changed
+2686 -2853

No files matched your search

+1 -1
View File
@@ -50,7 +50,7 @@ end
module CloudClient
# OpenNebula version
VERSION = '4.3.80'
VERSION = '4.3.85'
# #########################################################################
# Default location for the authentication file
+21
View File
@@ -217,3 +217,24 @@ string one_util::random_password()
return sha1_digest(sstr.str());
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
vector<string> one_util::split(const string& st, char delim, bool clean_empty)
{
vector<string> parts;
string part;
stringstream ss(st);
while (getline(ss, part, delim))
{
if (!(clean_empty && part.empty()))
{
parts.push_back(part);
}
}
return parts;
}
+16 -1
View File
@@ -71,10 +71,15 @@ Datastore::Datastore(
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
int Datastore::disk_attribute(VectorAttribute * disk)
int Datastore::disk_attribute(
VectorAttribute * disk,
const vector<string>& inherit_attrs)
{
ostringstream oss;
string st;
string inherit_val;
vector<string>::const_iterator it;
oss << oid;
@@ -104,6 +109,16 @@ int Datastore::disk_attribute(VectorAttribute * disk)
disk->replace("LN_TARGET", st);
}
for (it = inherit_attrs.begin(); it != inherit_attrs.end(); it++)
{
get_template_attribute((*it).c_str(), inherit_val);
if (!inherit_val.empty())
{
disk->replace(*it, inherit_val);
}
}
return 0;
}
-97
View File
@@ -1,97 +0,0 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
###############################################################################
# This script is used to copy a VM image (SRC) to the image repository as DST
# Several SRC types are supported
###############################################################################
# -------- Set up the environment to source common tools & conf ------------
if [ -z "${ONE_LOCATION}" ]; then
LIB_LOCATION=/usr/lib/one
else
LIB_LOCATION=$ONE_LOCATION/lib
fi
. $LIB_LOCATION/sh/scripts_common.sh
DRIVER_PATH=$(dirname $0)
source ${DRIVER_PATH}/../libfs.sh
source ${DRIVER_PATH}/iscsi.conf
# -------- Get cp and datastore arguments from OpenNebula core ------------
DRV_ACTION=$1
ID=$2
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"
unset i j XPATH_ELEMENTS
while IFS= read -r -d '' element; do
XPATH_ELEMENTS[i++]="$element"
done < <($XPATH /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/RESTRICTED_DIRS \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/SAFE_DIRS \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/BRIDGE_LIST \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/VG_NAME \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/BASE_IQN \
/DS_DRIVER_ACTION_DATA/IMAGE/PATH \
/DS_DRIVER_ACTION_DATA/IMAGE/SIZE)
BASE_PATH="${XPATH_ELEMENTS[j++]}"
RESTRICTED_DIRS="${XPATH_ELEMENTS[j++]}"
SAFE_DIRS="${XPATH_ELEMENTS[j++]}"
BRIDGE_LIST="${XPATH_ELEMENTS[j++]}"
VG_NAME="${XPATH_ELEMENTS[j++]:-$VG_NAME}"
BASE_IQN="${XPATH_ELEMENTS[j++]:-$BASE_IQN}"
SRC="${XPATH_ELEMENTS[j++]}"
SIZE="${XPATH_ELEMENTS[j++]}"
DST_HOST=`get_destination_host $ID`
if [ -z "$DST_HOST" ]; then
error_message "Datastore template missing 'BRIDGE_LIST' attribute."
exit -1
fi
# Check if 'TGTSETUPLUN' is installed
tgt_setup_lun_install "$DST_HOST" "$BASE_PATH"
set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS"
LV_NAME="lv-one-${ID}"
IQN="$BASE_IQN:$DST_HOST.$VG_NAME.$LV_NAME"
DEV="/dev/$VG_NAME/$LV_NAME"
LV_SRC=$(echo $SRC|awk -F. '{print $NF}')
DEV_SRC="/dev/$VG_NAME/$LV_SRC"
CLONE_CMD=$(cat <<EOF
set -e
$SUDO $LVCREATE -L${SIZE}M ${VG_NAME} -n ${LV_NAME}
$SUDO $DD if=$DEV_SRC of=$DEV bs=2M
$SUDO $(tgt_setup_lun "$IQN" "$DEV")
$SUDO $(tgt_admin_dump_config "$TARGET_CONF")
EOF
)
ssh_exec_and_log "$DST_HOST" "$CLONE_CMD" \
"Error cloning $DEV_SRC to $DEV in $DST_HOST"
echo "$IQN"
-131
View File
@@ -1,131 +0,0 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
###############################################################################
# This script is used to copy a VM image (SRC) to the image repository as DST
# Several SRC types are supported
###############################################################################
# -------- Set up the environment to source common tools & conf ------------
if [ -z "${ONE_LOCATION}" ]; then
LIB_LOCATION=/usr/lib/one
else
LIB_LOCATION=$ONE_LOCATION/lib
fi
. $LIB_LOCATION/sh/scripts_common.sh
DRIVER_PATH=$(dirname $0)
source ${DRIVER_PATH}/../libfs.sh
source ${DRIVER_PATH}/iscsi.conf
# -------- Get cp and datastore arguments from OpenNebula core ------------
DRV_ACTION=$1
ID=$2
UTILS_PATH="${DRIVER_PATH}/.."
XPATH="$UTILS_PATH/xpath.rb -b $DRV_ACTION"
unset i j XPATH_ELEMENTS
while IFS= read -r -d '' element; do
XPATH_ELEMENTS[i++]="$element"
done < <($XPATH /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/RESTRICTED_DIRS \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/SAFE_DIRS \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/BRIDGE_LIST \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/VG_NAME \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/BASE_IQN \
/DS_DRIVER_ACTION_DATA/IMAGE/PATH \
/DS_DRIVER_ACTION_DATA/IMAGE/SIZE \
/DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/MD5 \
/DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/SHA1 \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/NO_DECOMPRESS \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/LIMIT_TRANSFER_BW)
BASE_PATH="${XPATH_ELEMENTS[j++]}"
RESTRICTED_DIRS="${XPATH_ELEMENTS[j++]}"
SAFE_DIRS="${XPATH_ELEMENTS[j++]}"
BRIDGE_LIST="${XPATH_ELEMENTS[j++]}"
VG_NAME="${XPATH_ELEMENTS[j++]:-$VG_NAME}"
BASE_IQN="${XPATH_ELEMENTS[j++]:-$BASE_IQN}"
SRC="${XPATH_ELEMENTS[j++]}"
SIZE="${XPATH_ELEMENTS[j++]}"
MD5="${XPATH_ELEMENTS[j++]}"
SHA1="${XPATH_ELEMENTS[j++]}"
NO_DECOMPRESS="${XPATH_ELEMENTS[j++]}"
LIMIT_TRANSFER_BW="${XPATH_ELEMENTS[j++]}"
DST_HOST=`get_destination_host $ID`
if [ -z "$DST_HOST" ]; then
error_message "Datastore template missing 'BRIDGE_LIST' attribute."
exit -1
fi
# Check if 'TGTSETUPLUN' is installed
tgt_setup_lun_install "$DST_HOST" "$BASE_PATH"
set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS"
LV_NAME="lv-one-${ID}"
IQN="$BASE_IQN:$DST_HOST.$VG_NAME.$LV_NAME"
DEV="/dev/$VG_NAME/$LV_NAME"
REGISTER_CMD=$(cat <<EOF
set -e
$SUDO $LVCREATE -L${SIZE}M ${VG_NAME} -n ${LV_NAME}
$SUDO $(tgt_setup_lun "$IQN" "$DEV")
$SUDO $(tgt_admin_dump_config "$TARGET_CONF")
EOF
)
DOWNLOADER_ARGS=`set_downloader_args "$MD5" "$SHA1" "$NO_DECOMPRESS" "$LIMIT_TRANSFER_BW" "$SRC" -`
COPY_COMMAND="$UTILS_PATH/downloader.sh $DOWNLOADER_ARGS"
case $SRC in
http://*|https://*)
log "Downloading $SRC to the image repository"
DUMP="$COPY_COMMAND"
;;
*)
if [ `check_restricted $SRC` -eq 1 ]; then
log_error "Not allowed to copy images from $RESTRICTED_DIRS"
error_message "Not allowed to copy image file $SRC"
exit -1
fi
log "Copying local image $SRC to the image repository"
DUMP="$COPY_COMMAND"
;;
esac
ssh_exec_and_log "$DST_HOST" "$REGISTER_CMD" "Error registering $DST_HOST:$DEV"
exec_and_log "eval $DUMP | $SSH $DST_HOST $SUDO $DD of=$DEV bs=2M" \
"Error dumping $SRC to $DST_HOST:$DEV"
echo "$IQN"
-99
View File
@@ -1,99 +0,0 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
###############################################################################
# This script is used to create a VM image (SRC) of size (SIZE) and formatted
# as (FS)
###############################################################################
# -------- Set up the environment to source common tools & conf ------------
if [ -z "${ONE_LOCATION}" ]; then
LIB_LOCATION=/usr/lib/one
else
LIB_LOCATION=$ONE_LOCATION/lib
fi
. $LIB_LOCATION/sh/scripts_common.sh
DRIVER_PATH=$(dirname $0)
source ${DRIVER_PATH}/../libfs.sh
source ${DRIVER_PATH}/iscsi.conf
# -------- Get mkfs and datastore arguments from OpenNebula core ------------
DRV_ACTION=$1
ID=$2
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"
unset i j XPATH_ELEMENTS
while IFS= read -r -d '' element; do
XPATH_ELEMENTS[i++]="$element"
done < <($XPATH /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/RESTRICTED_DIRS \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/SAFE_DIRS \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/BRIDGE_LIST \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/VG_NAME \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/BASE_IQN \
/DS_DRIVER_ACTION_DATA/IMAGE/FSTYPE \
/DS_DRIVER_ACTION_DATA/IMAGE/SIZE)
BASE_PATH="${XPATH_ELEMENTS[j++]}"
RESTRICTED_DIRS="${XPATH_ELEMENTS[j++]}"
SAFE_DIRS="${XPATH_ELEMENTS[j++]}"
BRIDGE_LIST="${XPATH_ELEMENTS[j++]}"
VG_NAME="${XPATH_ELEMENTS[j++]:-$VG_NAME}"
BASE_IQN="${XPATH_ELEMENTS[j++]:-$BASE_IQN}"
FSTYPE="${XPATH_ELEMENTS[j++]}"
SIZE="${XPATH_ELEMENTS[j++]:-0}"
DST_HOST=`get_destination_host $ID`
if [ -z "$DST_HOST" ]; then
error_message "Datastore template missing 'BRIDGE_LIST' attribute."
exit -1
fi
# Check if 'TGTSETUPLUN' is installed
tgt_setup_lun_install "$DST_HOST" "$BASE_PATH"
set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS"
LV_NAME="lv-one-${ID}"
IQN="$BASE_IQN:$DST_HOST.$VG_NAME.$LV_NAME"
DEV="/dev/$VG_NAME/$LV_NAME"
REGISTER_CMD=$(cat <<EOF
set -e
$SUDO $LVCREATE -L${SIZE}M ${VG_NAME} -n ${LV_NAME}
$SUDO $(tgt_setup_lun "$IQN" "$DEV")
$SUDO $(tgt_admin_dump_config "$TARGET_CONF")
if [ "$FSTYPE" != "save_as" ]; then
$SUDO $(mkfs_command "$DEV" "$FSTYPE")
fi
EOF
)
ssh_exec_and_log "$DST_HOST" "$REGISTER_CMD" \
"Error registering $DST_HOST:$DEV"
echo "$IQN"
-86
View File
@@ -1,86 +0,0 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
###############################################################################
# This script is used to monitor the free and used space of a datastore
###############################################################################
# -------- Set up the environment to source common tools & conf ------------
if [ -z "${ONE_LOCATION}" ]; then
LIB_LOCATION=/usr/lib/one
else
LIB_LOCATION=$ONE_LOCATION/lib
fi
. $LIB_LOCATION/sh/scripts_common.sh
DRIVER_PATH=$(dirname $0)
source ${DRIVER_PATH}/../libfs.sh
source ${DRIVER_PATH}/iscsi.conf
# -------- Get datastore arguments from OpenNebula core ------------
DRV_ACTION=$1
ID=$2
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"
unset i j XPATH_ELEMENTS
while IFS= read -r -d '' element; do
XPATH_ELEMENTS[i++]="$element"
done < <($XPATH /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/BRIDGE_LIST \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/VG_NAME)
BRIDGE_LIST="${XPATH_ELEMENTS[j++]}"
VG_NAME="${XPATH_ELEMENTS[j++]:-$VG_NAME}"
HOST=`get_destination_host`
if [ -z "$HOST" ]; then
error_message "Datastore template missing 'BRIDGE_LIST' attribute."
exit -1
fi
# ------------ Compute datastore usage -------------
MONITOR_SCRIPT=$(cat <<EOF
set -e
VG_OPTS="--units M -C --noheadings --nosuffix $VG_NAME"
TOTAL_MB=\$($SUDO $VGDISPLAY -o vg_size \$VG_OPTS | $TR -d ' ')
FREE_MB=\$($SUDO $VGDISPLAY -o vg_free \$VG_OPTS | $TR -d ' ')
USED_MB=\$($AWK "BEGIN {print \$TOTAL_MB - \$FREE_MB}")
echo "USED_MB=\$USED_MB"
echo "TOTAL_MB=\$TOTAL_MB"
echo "FREE_MB=\$FREE_MB"
EOF
)
MONITOR_DATA=$(ssh_monitor_and_log $HOST "$MONITOR_SCRIPT" 2>&1)
MONITOR_STATUS=$?
if [ "$MONITOR_STATUS" = "0" ]; then
echo "$MONITOR_DATA" | tr ' ' '\n'
else
echo "$MONITOR_DATA"
exit $MONITOR_STATUS
fi
-85
View File
@@ -1,85 +0,0 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
###############################################################################
# This script is used to remove a VM image (SRC) from the image repository
###############################################################################
# ------------ Set up the environment to source common tools ------------
if [ -z "${ONE_LOCATION}" ]; then
LIB_LOCATION=/usr/lib/one
else
LIB_LOCATION=$ONE_LOCATION/lib
fi
. $LIB_LOCATION/sh/scripts_common.sh
DRIVER_PATH=$(dirname $0)
source ${DRIVER_PATH}/../libfs.sh
source ${DRIVER_PATH}/iscsi.conf
# -------- Get rm and datastore arguments from OpenNebula core ------------
DRV_ACTION=$1
ID=$2
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"
unset i j XPATH_ELEMENTS
while IFS= read -r -d '' element; do
XPATH_ELEMENTS[i++]="$element"
done < <($XPATH /DS_DRIVER_ACTION_DATA/IMAGE/SOURCE \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/BRIDGE_LIST)
SRC="${XPATH_ELEMENTS[j++]}"
BRIDGE_LIST="${XPATH_ELEMENTS[j++]}"
DST_HOST=`get_destination_host $ID`
if [ -z "$DST_HOST" ]; then
error_message "Datastore template missing 'BRIDGE_LIST' attribute."
exit -1
fi
BASE_IQN=`echo $SRC|$CUT -d: -f1`
TARGET=`echo $SRC|$CUT -d: -f2`
LV_NAME=`echo $TARGET|$AWK -F. '{print $(NF)}'`
VG_NAME=`echo $TARGET|$AWK -F. '{print $(NF-1)}'`
DEV="/dev/$VG_NAME/$LV_NAME"
IQN="$BASE_IQN:$DST_HOST.$VG_NAME.$LV_NAME"
RM_COMMAND=$(cat <<EOF
set -e
TID=\$($SUDO $(tgtadm_get_tid_for_iqn "$IQN"))
$SUDO $(tgtadm_target_delete "\$TID")
$SUDO $SYNC
$SUDO $LVREMOVE -f $VG_NAME/$LV_NAME
$SUDO $(tgt_admin_dump_config "$TARGET_CONF")
EOF
)
log "Removing $DST_HOST:$DEV from the image repository"
ssh_exec_and_log "$DST_HOST" "$RM_COMMAND" \
"Error removing $DST_HOST:$DEV"
exit 0
-1
View File
@@ -1 +0,0 @@
../common/stat
+2 -3
View File
@@ -65,9 +65,8 @@ fi
SAFE_DIRS=""
SRC_HOST=`echo $SRC|cut -d. -f1`
SRC_PATH=`echo $SRC|cut -d. -f2`
SRC_HOST=`echo $SRC|cut -d: -f1`
SRC_PATH=`echo $SRC|awk -F. '{print $NF}'`
LV_SRC=$(echo $SRC_PATH|cut -d. -f2)
DEV_SRC="/dev/$VG_NAME/$LV_SRC"
+1 -1
View File
@@ -338,7 +338,7 @@ void InformationManager::timer_action()
oss << "Monitoring host " << host->get_name() << " ("
<< host->get_oid() << ")";
NebulaLog::log("InM",Log::INFO,oss);
NebulaLog::log("InM",Log::DEBUG,oss);
imd = get(host->get_im_mad());
+1 -1
View File
@@ -219,7 +219,7 @@ void InformationManagerDriver::protocol(const string& message) const
oss << "Datastore " << ds->get_name() <<
" (" << ds->get_oid() << ") successfully monitored.";
NebulaLog::log("ImM", Log::INFO, oss);
NebulaLog::log("ImM", Log::DEBUG, oss);
dspool->update(ds);
}
+12 -3
View File
@@ -5,7 +5,12 @@ HYPERVISOR=$1
DATASTORE_LOCATION=${2:-"/var/lib/one/datastores"}
LVM_VG_PREFIX="vg-one-"
LVM_SIZE_CMD="sudo vgdisplay --separator : --units m -o vg_size,vg_free --nosuffix --noheadings -C"
PATH=$PATH:/sbin:/bin:/usr/sbin:/usr/bin which vgdisplay &> /dev/null
if [ $? == 0 ]; then
LVM_SIZE_CMD="sudo vgdisplay --separator : --units m -o vg_size,vg_free --nosuffix --noheadings -C"
fi
USED_MB=$(du -sLm $DATASTORE_LOCATION 2>/dev/null | cut -f1)
TOTAL_MB=$(df -B1M -P $DATASTORE_LOCATION 2>/dev/null | tail -n 1 | awk '{print $2}')
@@ -26,8 +31,12 @@ for ds in $dirs; do
TOTAL_MB=$(df -B1M -P $dir 2>/dev/null | tail -n 1 | awk '{print $2}')
FREE_MB=$(df -B1M -P $dir 2>/dev/null | tail -n 1 | awk '{print $4}')
LVM_SIZE=$($LVM_SIZE_CMD ${LVM_VG_PREFIX}${ds} 2>/dev/null)
LVM_STATUS=$?
if [ -n "$LVM_SIZE_CMD" ]; then
LVM_SIZE=$($LVM_SIZE_CMD ${LVM_VG_PREFIX}${ds} 2>/dev/null)
LVM_STATUS=$?
else
LVM_STATUS=255
fi
echo "DS = ["
echo " ID = $ds,"
+17 -3
View File
@@ -467,18 +467,22 @@ int Image::from_xml(const string& xml)
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
int Image::disk_attribute( VectorAttribute * disk,
ImageType& img_type,
string& dev_prefix)
int Image::disk_attribute( VectorAttribute * disk,
ImageType& img_type,
string& dev_prefix,
const vector<string>& inherit_attrs)
{
string target;
string driver;
string disk_attr_type;
string inherit_val;
bool ro;
ostringstream iid;
vector<string>::const_iterator it;
img_type = type;
target = disk->vector_value("TARGET");
driver = disk->vector_value("DRIVER");
@@ -614,6 +618,16 @@ int Image::disk_attribute( VectorAttribute * disk,
disk->replace("TARGET", template_target);
}
for (it = inherit_attrs.begin(); it != inherit_attrs.end(); it++)
{
get_template_attribute((*it).c_str(), inherit_val);
if (!inherit_val.empty())
{
disk->replace(*it, inherit_val);
}
}
return 0;
}
+1 -1
View File
@@ -223,7 +223,7 @@ void ImageManager::monitor_datastore(int ds_id)
oss << "Monitoring datastore " << ds->get_name() << " (" << ds_id << ")";
NebulaLog::log("InM", Log::INFO, oss);
NebulaLog::log("InM", Log::DEBUG, oss);
ds->unlock();
+3 -2
View File
@@ -195,7 +195,8 @@ static int cp_action(istringstream& is,
image->unlock();
NebulaLog::log("ImM", Log::INFO, "Image copied and ready to use.");
oss << "Image (" << id << ") copied and ready to use.";
NebulaLog::log("ImM", Log::INFO, oss);
return ds_id;
@@ -661,7 +662,7 @@ static void monitor_action(istringstream& is,
oss << "Datastore " << ds_name << " (" << id << ") successfully monitored.";
NebulaLog::log("ImM", Log::INFO, oss);
NebulaLog::log("ImM", Log::DEBUG, oss);
return;
}
+28 -10
View File
@@ -31,20 +31,38 @@ string ImagePool::_default_dev_prefix;
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
ImagePool::ImagePool(SqlDB * db,
const string& __default_type,
const string& __default_dev_prefix,
vector<const Attribute *>& restricted_attrs,
vector<const Attribute *> hook_mads,
const string& remotes_location)
ImagePool::ImagePool(
SqlDB * db,
const string& __default_type,
const string& __default_dev_prefix,
vector<const Attribute *>& restricted_attrs,
vector<const Attribute *> hook_mads,
const string& remotes_location,
const vector<const Attribute *>& _inherit_image_attrs,
const vector<const Attribute *>& _inherit_datastore_attrs)
:PoolSQL(db, Image::table, true)
{
ostringstream sql;
// Init static defaults
_default_type = __default_type;
_default_dev_prefix = __default_dev_prefix;
// Init inherit attributes
vector<const Attribute *>::const_iterator it;
for (it = _inherit_image_attrs.begin(); it != _inherit_image_attrs.end(); it++)
{
const SingleAttribute* sattr = static_cast<const SingleAttribute *>(*it);
inherit_image_attrs.push_back(sattr->value());
}
for (it = _inherit_datastore_attrs.begin(); it != _inherit_datastore_attrs.end(); it++)
{
const SingleAttribute* sattr = static_cast<const SingleAttribute *>(*it);
inherit_datastore_attrs.push_back(sattr->value());
}
// Set default type
if (_default_type != "OS" &&
_default_type != "CDROM" &&
@@ -385,7 +403,7 @@ int ImagePool::disk_attribute(int vm_id,
Datastore * ds;
iid = img->get_oid();
rc = img->disk_attribute(disk, img_type, dev_prefix);
rc = img->disk_attribute(disk, img_type, dev_prefix, inherit_image_attrs);
image_id = img->get_oid();
datastore_id = img->get_ds_id();
@@ -410,7 +428,7 @@ int ImagePool::disk_attribute(int vm_id,
return -1;
}
ds->disk_attribute(disk);
ds->disk_attribute(disk, inherit_datastore_attrs);
ds->unlock();
}
+3
View File
@@ -855,6 +855,9 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose, int& imag
vm->delete_snapshots();
map<string, string> empty;
vm->update_info(0, 0, -1, -1, empty);
vmpool->update(vm);
vm->set_etime(the_time);
+33
View File
@@ -47,6 +47,9 @@ void LifeCycleManager::save_success_action(int vid)
vm->delete_snapshots();
map<string, string> empty;
vm->update_info(0, 0, -1, -1, empty);
vmpool->update(vm);
vm->set_previous_etime(the_time);
@@ -85,6 +88,9 @@ void LifeCycleManager::save_success_action(int vid)
vm->delete_snapshots();
map<string, string> empty;
vm->update_info(0, 0, -1, -1, empty);
vmpool->update(vm);
vm->set_running_etime(the_time);
@@ -115,6 +121,9 @@ void LifeCycleManager::save_success_action(int vid)
vm->delete_snapshots();
map<string, string> empty;
vm->update_info(0, 0, -1, -1, empty);
vmpool->update(vm);
vm->set_epilog_stime(the_time);
@@ -509,6 +518,9 @@ void LifeCycleManager::shutdown_success_action(int vid)
vm->delete_snapshots();
map<string, string> empty;
vm->update_info(0, 0, -1, -1, empty);
vmpool->update(vm);
vm->set_epilog_stime(the_time);
@@ -533,6 +545,9 @@ void LifeCycleManager::shutdown_success_action(int vid)
vm->delete_snapshots();
map<string, string> empty;
vm->update_info(0, 0, -1, -1, empty);
vmpool->update(vm);
vm->set_running_etime(the_time);
@@ -559,6 +574,9 @@ void LifeCycleManager::shutdown_success_action(int vid)
vm->delete_snapshots();
map<string, string> empty;
vm->update_info(0, 0, -1, -1, empty);
vmpool->update(vm);
vm->set_epilog_stime(the_time);
@@ -987,6 +1005,9 @@ void LifeCycleManager::cancel_success_action(int vid)
vm->delete_snapshots();
map<string, string> empty;
vm->update_info(0, 0, -1, -1, empty);
vmpool->update(vm);
vm->set_reason(History::USER);
@@ -1013,6 +1034,9 @@ void LifeCycleManager::cancel_success_action(int vid)
vm->delete_snapshots();
map<string, string> empty;
vm->update_info(0, 0, -1, -1, empty);
vmpool->update(vm);
vm->set_epilog_stime(the_time);
@@ -1037,6 +1061,9 @@ void LifeCycleManager::cancel_success_action(int vid)
vm->delete_snapshots();
map<string, string> empty;
vm->update_info(0, 0, -1, -1, empty);
vmpool->update(vm);
vm->set_running_etime(the_time);
@@ -1172,6 +1199,9 @@ void LifeCycleManager::monitor_suspend_action(int vid)
vm->delete_snapshots();
map<string, string> empty;
vm->update_info(0, 0, -1, -1, empty);
vmpool->update(vm);
vm->set_running_etime(the_time);
@@ -1255,6 +1285,9 @@ void LifeCycleManager::failure_action(VirtualMachine * vm)
vm->delete_snapshots();
map<string, string> empty;
vm->update_info(0, 0, -1, -1, empty);
vmpool->update(vm);
vm->set_etime(the_time);
+30
View File
@@ -148,6 +148,33 @@ function exec_and_log
fi
}
# Executes a command, if it fails returns error message and exits. Similar to
# exec_and_log, except that it allows multiline commands.
# If a second parameter is present it is used as the error message when
# the command fails.
function multiline_exec_and_log
{
message=$2
EXEC_LOG_ERR=`bash -s 2>&1 1>/dev/null <<EOF
export LANG=C
export LC_ALL=C
$1
EOF`
EXEC_LOG_RC=$?
if [ $EXEC_LOG_RC -ne 0 ]; then
log_error "Command \"$1\" failed: $EXEC_LOG_ERR"
if [ -n "$2" ]; then
error_message "$2"
else
error_message "Error executing $1: $EXEC_LOG_ERR"
fi
exit $EXEC_LOG_RC
fi
}
# Like exec_and_log but does not exit on failure. Just sets the variable
# ERROR to the error message.
function exec_and_set_error
@@ -367,6 +394,9 @@ EOF`
fi
}
# TODO -> Use a dynamically loaded scripts directory. Not removing this due
#  to iSCSI addon: https://github.com/OpenNebula/addon-iscsi
# ------------------------------------------------------------------------------
# iSCSI functions
+15 -2
View File
@@ -555,6 +555,10 @@ void Nebula::start(bool bootstrap_only)
vector<const Attribute *> vm_restricted_attrs;
vector<const Attribute *> img_restricted_attrs;
vector<const Attribute *> inherit_image_attrs;
vector<const Attribute *> inherit_datastore_attrs;
vector<const Attribute *> inherit_vnet_attrs;
clpool = new ClusterPool(db);
docpool = new DocumentPool(db);
@@ -568,6 +572,10 @@ void Nebula::start(bool bootstrap_only)
nebula_configuration->get("VM_RESTRICTED_ATTR", vm_restricted_attrs);
nebula_configuration->get("IMAGE_RESTRICTED_ATTR", img_restricted_attrs);
nebula_configuration->get("INHERIT_IMAGE_ATTR", inherit_image_attrs);
nebula_configuration->get("INHERIT_DATASTORE_ATTR", inherit_datastore_attrs);
nebula_configuration->get("INHERIT_VNET_ATTR", inherit_vnet_attrs);
nebula_configuration->get("VM_MONITORING_EXPIRATION_TIME",vm_expiration);
nebula_configuration->get("HOST_MONITORING_EXPIRATION_TIME",host_expiration);
@@ -593,7 +601,8 @@ void Nebula::start(bool bootstrap_only)
mac_prefix,
size,
vnet_hooks,
remotes_location);
remotes_location,
inherit_vnet_attrs);
gpool = new GroupPool(db, group_hooks, remotes_location);
@@ -609,7 +618,9 @@ void Nebula::start(bool bootstrap_only)
default_device_prefix,
img_restricted_attrs,
image_hooks,
remotes_location);
remotes_location,
inherit_image_attrs,
inherit_datastore_attrs);
tpool = new VMTemplatePool(db);
@@ -989,6 +1000,8 @@ void Nebula::start(bool bootstrap_only)
NebulaLog::log("ONE", Log::INFO, "All modules finalized, exiting.\n");
return;
error_mad:
NebulaLog::log("ONE", Log::ERROR, "Could not load driver");
throw runtime_error("Could not load an OpenNebula driver");
@@ -32,7 +32,7 @@ public class OneSystem
private static final String GROUP_QUOTA_INFO = "groupquota.info";
private static final String GROUP_QUOTA_UPDATE = "groupquota.update";
public static final String VERSION = "4.3.80";
public static final String VERSION = "4.3.85";
public OneSystem(Client client)
{
+2 -9
View File
@@ -390,7 +390,7 @@ VM_MAD = [ name="dummy", executable="one_vmm_dummy", type="xml" ]
TM_MAD = [
executable = "one_tm",
arguments = "-t 15 -d dummy,lvm,shared,shared_lvm,qcow2,ssh,vmfs,iscsi,ceph"
arguments = "-t 15 -d dummy,lvm,shared,shared_lvm,qcow2,ssh,vmfs,ceph"
]
TM_MAD_CONF = [
@@ -442,13 +442,6 @@ TM_MAD_CONF = [
shared = "yes"
]
TM_MAD_CONF = [
name = "iscsi",
ln_target = "NONE",
clone_target= "SELF",
shared = "yes"
]
TM_MAD_CONF = [
name = "ceph",
ln_target = "NONE",
@@ -471,7 +464,7 @@ TM_MAD_CONF = [
DATASTORE_MAD = [
executable = "one_datastore",
arguments = "-t 15 -d dummy,fs,vmfs,iscsi,lvm,ceph"
arguments = "-t 15 -d dummy,fs,vmfs,lvm,ceph"
]
#*******************************************************************************
+1 -1
View File
@@ -54,5 +54,5 @@ require 'opennebula/system'
module OpenNebula
# OpenNebula version
VERSION = '4.3.80'
VERSION = '4.3.85'
end
@@ -14,16 +14,16 @@
# limitations under the License. #
#--------------------------------------------------------------------------- #
# Default IQN path
BASE_IQN=iqn.2012-02.org.opennebula
module Migrator
def db_version
"4.3.85"
end
# Default volume group
VG_NAME=vg-one
def one_version
"OpenNebula 4.3.85"
end
# Lists of hosts (separated by spaces) for which no iscsiadm login or logout
# is performed.
NO_ISCSI="$HOSTNAME"
# File where the iSCSI configured is dumped to (tgt-admin --dump)
# If it poings to /dev/null, iSCSI targets will not be persistent
TARGET_CONF=/etc/tgt/targets.conf
def up
return true
end
end
+1 -1
View File
@@ -20,7 +20,7 @@ require 'ipaddr'
require 'set'
module OneDBFsck
VERSION = "4.3.80"
VERSION = "4.3.85"
def db_version
VERSION
+1 -1
View File
@@ -65,7 +65,7 @@
</div>
<div id="footer" style="overflow:visible;" class="ui-layout-south">
<a href="http://opennebula.org" target="_blank">OpenNebula 4.3.80</a> by <a href="http://c12g.com" target="_blank">C12G Labs</a>.
<a href="http://opennebula.org" target="_blank">OpenNebula 4.3.85</a> by <a href="http://c12g.com" target="_blank">C12G Labs</a>.
</div>
<div id="dialogs">
+1 -1
View File
@@ -49,7 +49,7 @@
</form>
</div>
<div id="footer" style="overflow:visible;">
<a href="http://opennebula.org" target="_blank">OpenNebula 4.3.80</a> by <a href="http://c12g.com" target="_blank">C12G Labs</a>.
<a href="http://opennebula.org" target="_blank">OpenNebula 4.3.85</a> by <a href="http://c12g.com" target="_blank">C12G Labs</a>.
</div>
</body>
</html>
@@ -16,6 +16,7 @@
#include "VirtualMachinePoolXML.h"
#include <stdexcept>
#include <iomanip>
int VirtualMachinePoolXML::set_up()
{
@@ -32,7 +33,14 @@ int VirtualMachinePoolXML::set_up()
if (NebulaLog::log_level() == Log::DEBUG)
{
ostringstream oss;
oss << "Pending/rescheduling VM and capacity requirements:";
oss << "Pending/rescheduling VM and capacity requirements:" << endl;
oss << right << setw(8) << "VM" << " "
<< right << setw(4) << "CPU" << " "
<< right << setw(11) << "Memory" << " "
<< right << setw(11) << "System DS" << " "
<< " Image DS"
<< endl << setw(60) << setfill('-') << "-" << setfill(' ');
for (map<int,ObjectXML*>::iterator it=objects.begin();it!=objects.end();it++)
{
@@ -44,18 +52,17 @@ int VirtualMachinePoolXML::set_up()
vm->get_requirements(cpu, mem, disk);
oss << endl
<< "\tVM: " << it->first << endl
<< "\t CPU: " << cpu << endl
<< "\t Memory: " << mem << endl
<< "\t System DS: " << disk << endl;
<< right << setw(8) << it->first << " "
<< right << setw(4) << cpu << " "
<< right << setw(11) << mem << " "
<< right << setw(11) << disk << " ";
map<int,long long> ds_usage = vm->get_storage_usage();
for (map<int,long long>::const_iterator ds_it = ds_usage.begin();
ds_it != ds_usage.end(); ds_it++)
{
oss << "\t Image DS " << ds_it->first << ": " << ds_it->second
<< endl;
oss << " DS " << ds_it->first << ": " << ds_it->second << " ";
}
}
+6 -1
View File
@@ -80,6 +80,8 @@ class OpenNebulaVNC
@proxy_path = File.join(SHARE_LOCATION, "websockify/websocketproxy.py")
@proxy_port = config[:vnc_proxy_port]
@proxy_ipv6 = config[:vnc_proxy_ipv6]
@wss = config[:vnc_proxy_support_wss]
@lock_file = NOVNC_LOCK_FILE
@@ -113,6 +115,10 @@ class OpenNebulaVNC
proxy_options << " --ssl-only" if @wss == "only"
end
if @proxy_ipv6
proxy_options << " -6"
end
cmd ="python #{@proxy_path} #{proxy_options} #{@proxy_port}"
begin
@@ -267,7 +273,6 @@ class OpenNebulaVNC
Dir.glob("#{@token_folder}/*").each do |file|
File.delete(file)
end
Dir.rmdir(@token_folder)
rescue => e
@logger.error "Error deleting token folder"
@logger.error e.message
+2
View File
@@ -81,10 +81,12 @@
# supported.
# vnc_proxy_cert: Certificate to encrypt wss connections.
# vnc_proxy_key: Key for wss connections. Only necessary if not included in cert.
# vnc_proxy_ipv6: Enable ipv6 support for novnc-server
:vnc_proxy_port: 29876
:vnc_proxy_support_wss: no
:vnc_proxy_cert:
:vnc_proxy_key:
:vnc_proxy_ipv6: false
# Default language setting
@@ -65,10 +65,6 @@ module OpenNebulaJSON
template = template_to_str(template_hash)
end
# Substitue single quotes (not supported by ONE core)
# with \" (supported)
template.gsub!(/'/,"\\\"")
super(template)
end
@@ -102,7 +102,6 @@ var create_datastore_tmpl =
<select id="presets" name="presets">\
<option value="fs">' + tr("Filesystem") + '</option>\
<option value="vmware_vmfs">' + tr("VMware VMFS") + '</option>\
<option value="iscsi">' + tr("iSCSI") + '</option>\
<option value="block_lvm">' + tr("Block LVM") + '</option>\
<option value="fs_lvm">' + tr("FS LVM") + '</option>\
<option value="ceph">' + tr("Ceph") + '</option>\
@@ -168,7 +167,6 @@ var create_datastore_tmpl =
<select id="ds_mad" name="ds_mad">\
<option value="fs">' + tr("Filesystem") + '</option>\
<option value="vmware">' + tr("VMware") + '</option>\
<option value="iscsi">' + tr("iSCSI") + '</option>\
<option value="lvm">' + tr("LVM") + '</option>\
<option value="vmfs">' + tr("VMFS") + '</option>\
<option value="ceph">' + tr("Ceph") + '</option>\
@@ -191,10 +189,9 @@ var create_datastore_tmpl =
<option value="shared">' + tr("Shared") + '</option>\
<option value="ssh">' + tr("SSH") + '</option>\
<option value="qcow2">' + tr("qcow2") + '</option>\
<option value="iscsi">' + tr("iSCSI") + '</option>\
<option value="dummy">' + tr("Dummy") + '</option>\
<option value="lvm">' + tr("LVM") + '</option>\
<option value="shared_lvm">' + tr("Shared LVM") + '</option>\
<option value="fs_lvm">' + tr("FS LVM") + '</option>\
<option value="vmfs">' + tr("VMFS") + '</option>\
<option value="ceph">' + tr("Ceph") + '</option>\
<option value="custom">' + tr("Custom") + '</option>\
@@ -497,7 +494,7 @@ var datastore_actions = {
type: "multiple",
call: function(params, success){
var cluster = params.data.extra_param;
var ds = params.data.id[0];
var ds = params.data.id;
if (cluster == -1){
//get cluster name
@@ -740,7 +737,7 @@ function updateDatastoreInfo(request,ds){
cluster_str = insert_cluster_dropdown("Datastore",info.ID,info.CLUSTER,info.CLUSTER_ID);
}
var is_system = (info.TYPE == 1)
var is_system_ssh = (info.TEMPLATE.SHARED == "NO")
var info_tab_content = '<div class="">\
<div class="six columns">\
@@ -773,15 +770,15 @@ function updateDatastoreInfo(request,ds){
<thead><tr><th colspan="3" style="width:130px">'+tr("Capacity")+'</th>\</tr></thead>\
<tr>\
<td class="key_td">' + tr("Total") + '</td>\
<td class="value_td" colspan="2">'+(is_system ? '-' : humanize_size_from_mb(info.TOTAL_MB))+'</td>\
<td class="value_td" colspan="2">'+(is_system_ssh ? '-' : humanize_size_from_mb(info.TOTAL_MB))+'</td>\
</tr>\
<tr>\
<td class="key_td">' + tr("Used") + '</td>\
<td class="value_td" colspan="2">'+(is_system ? '-' : humanize_size_from_mb(info.USED_MB))+'</td>\
<td class="value_td" colspan="2">'+(is_system_ssh ? '-' : humanize_size_from_mb(info.USED_MB))+'</td>\
</tr>\
<tr>\
<td class="key_td">' + tr("Free") + '</td>\
<td class="value_td" colspan="2">'+(is_system ? '-' : humanize_size_from_mb(info.FREE_MB))+'</td>\
<td class="value_td" colspan="2">'+(is_system_ssh ? '-' : humanize_size_from_mb(info.FREE_MB))+'</td>\
</tr>\
</tbody>\
</table>'
@@ -943,9 +940,6 @@ function setupCreateDatastoreDialog(){
case 'fs_lvm':
select_fs_lvm();
break;
case 'iscsi':
select_iscsi();
break;
case 'ceph':
select_ceph();
break;
@@ -1099,25 +1093,6 @@ function select_vmware_vmfs(){
$('select#disk_type').attr('disabled', 'disabled');
}
function select_iscsi(){
$('select#ds_mad').val('iscsi');
$('select#ds_mad').attr('disabled', 'disabled');
$('select#tm_mad').val('iscsi');
$('select#tm_mad').attr('disabled', 'disabled');
$('label[for="bridge_list"],input#bridge_list').parent().parent().fadeIn();
$('label[for="base_iqn"],input#base_iqn').fadeIn();
$('label[for="vg_name"],input#vg_name').fadeIn();
$('select#disk_type').children('option').each(function() {
var value_str = $(this).val();
$(this).attr('disabled', 'disabled');
if (value_str == "file" ||
value_str == "block")
{
$(this).removeAttr('disabled');
}
});
}
function select_ceph(){
$('select#ds_mad').val('ceph');
$('select#ds_mad').attr('disabled', 'disabled');
@@ -1144,7 +1119,7 @@ function select_block_lvm(){
function select_fs_lvm(){
$('select#ds_mad').val('fs');
$('select#ds_mad').attr('disabled', 'disabled');
$('select#tm_mad').val('shared_lvm');
$('select#tm_mad').val('fs_lvm');
$('select#tm_mad').attr('disabled', 'disabled');
$('input#image_ds_type').attr('checked', 'true');
$('input[name=ds_type]').attr('disabled', 'disabled');
@@ -4148,16 +4148,12 @@ function setupCreateTemplateDialog(){
//
// RAW
//
function addslashes( str ) {
return (str + '').replace(/[\\"']/g, '\\$&').replace(/\u0000/g, '\\0');
}
vm_json["RAW"] = {}
t = addslashes($('#raw_type', dialog).val());
t = $('#raw_type', dialog).val();
if (t) { vm_json["RAW"]['TYPE'] = t; }
t = addslashes($('#raw_data', dialog).val());
t = escapeDoubleQuotes($('#raw_data', dialog).val());
if (t) { vm_json["RAW"]['DATA'] = t; }
t = addslashes($('#raw_data_vmx', dialog).val());
t = escapeDoubleQuotes($('#raw_data_vmx', dialog).val());
if (t) { vm_json["RAW"]['DATA_VMX'] = t; }
$('#custom_tags tr', $('li#rawTab')).each(function(){
@@ -4199,8 +4195,6 @@ function setupCreateTemplateDialog(){
vm_json = {vmtemplate: vm_json};
vm_json =JSON.stringify(vm_json);
vm_json=vm_json.replace(/\\\"/g,"'");
Sunstone.runAction("Template.update",template_to_update_id,vm_json);
$create_template_dialog.trigger("reveal:close")
@@ -4215,8 +4209,6 @@ function setupCreateTemplateDialog(){
template = {"vmtemplate": {"template_raw": template}};
var vm_json = JSON.stringify(template);
vm_json=vm_json.replace(/\\\"/g,"'");
Sunstone.runAction("Template.update",template_to_update_id,vm_json);
$create_template_dialog.trigger("reveal:close")
@@ -4901,10 +4893,10 @@ function fillTemplatePopUp(request, response){
return $('<div/>').html(value).text();
}
$('#raw_type', raw_section).val(htmlDecode(raw['TYPE']));
$('#raw_type', raw_section).val(raw['TYPE']);
$('#raw_type', raw_section).change();
$('#raw_data', raw_section).val(htmlDecode(raw['DATA']));
$('#raw_data_vmx', raw_section).val(htmlDecode(raw['DATA_VMX']));
$('#raw_data', raw_section).val(raw['DATA']);
$('#raw_data_vmx', raw_section).val(raw['DATA_VMX']);
delete template.RAW
}
+30 -15
View File
@@ -1339,37 +1339,48 @@ function updateVMachinesView(request, vmachine_list){
// Some calculations are performed, inspired from what is done
// in the CLI
function generatePlacementTable(vm){
var requirements_str = "-";
var rank_str = "-";
var requirements_str = vm.USER_TEMPLATE.SCHED_REQUIREMENTS ? vm.USER_TEMPLATE.SCHED_REQUIREMENTS : "-";
var rank_str = vm.USER_TEMPLATE.SCHED_RANK ? vm.USER_TEMPLATE.SCHED_RANK : "-";
var ds_requirements_str = vm.USER_TEMPLATE.SCHED_DS_REQUIREMENTS ? vm.USER_TEMPLATE.SCHED_DS_REQUIREMENTS : "-";
var ds_rank_str = vm.USER_TEMPLATE.SCHED_DS_RANK ? vm.USER_TEMPLATE.SCHED_DS_RANK : "-";
if (vm.USER_TEMPLATE.SCHED_REQUIREMENTS)
{
requirements_str = vm.USER_TEMPLATE.SCHED_REQUIREMENTS;
}
if (vm.USER_TEMPLATE.SCHED_RANK)
{
rank_str = vm.USER_TEMPLATE.SCHED_RANK;
}
var html = '<div class=""><div class="six columns">\
<table id="vm_placement_table" class="extended_table twelve">\
<thead>\
<tr>\
<th colspan="2" align="center">'+tr("Placement")+'</th>\
<th colspan="2" align="center">'+tr("Placement - Host")+'</th>\
</tr>\
</thead>\
<tbody>\
<tr>\
<td>REQUIREMENTS</td>\
<td>'+ tr("Requirements")+'</td>\
<td>'+requirements_str+'</td>\
</tr>\
<tr>\
<td>RANK</td>\
<td>'+ tr("Rank")+'</td>\
<td>'+rank_str+'</td>\
</tr>\
</tbody>\
</table>\
</div><div class="six columns">\
<table id="vm_ds_placement_table" class="extended_table twelve">\
<thead>\
<tr>\
<th colspan="2" align="center">'+tr("Placement - Datastore")+'</th>\
</tr>\
</thead>\
<tbody>\
<tr>\
<td>'+ tr("DS Requirements")+'</td>\
<td>'+ds_requirements_str+'</td>\
</tr>\
<tr>\
<td>'+ tr("DS Rank")+'</td>\
<td>'+ds_rank_str+'</td>\
</tr>\
</tbody>\
</table>\
</div></div>\
<div class="twelve columns">\
<table id="vm_history_table" class="extended_table twelve">\
@@ -1392,7 +1403,11 @@ function generatePlacementTable(vm){
history = vm.HISTORY_RECORDS.HISTORY;
else if (vm.HISTORY_RECORDS.HISTORY.SEQ)
history = [vm.HISTORY_RECORDS.HISTORY];
};
} else {
html += ' <tr>\
<td colspan="8" style="width:5%">'+tr("No data avialable in table")+'</td>\
</tr>'
}
var now = Math.round(new Date().getTime() / 1000);
+3 -3
View File
@@ -736,8 +736,7 @@ function makeSelectOptions(dataTable,
//Escape doublequote in a string and return it
function escapeDoubleQuotes(string){
string = string.replace(/\\"/g,'"');
return string.replace(/"/g,'\\"');
return string.replace(/\\/g,'\\').replace(/"/g,'\\"');
}
function derivative(data) {
@@ -1930,7 +1929,8 @@ function insert_extended_template_table(template_json,resource_type,resource_id,
var key_str=this.firstElementChild.id.substring(9,this.firstElementChild.id.length);
var value_str = $("#value_td_input_"+key_str).text();
$("#value_td_input_"+key_str).html('<input class="input_edit_value" id="input_edit_'+key_str+'" type="text" value="'+value_str+'"/>');
input = $("#value_td_input_"+key_str).html('<input class="input_edit_value" id="input_edit_'+key_str+'" type="text"/>');
$('#input_edit_'+key_str).val(value_str);
});
+1 -1
View File
@@ -86,7 +86,7 @@
</div>
<div id="footer" style="overflow:visible;text-align:center;padding:8px;font-size:12px">
<a href="http://opennebula.org" target="_blank">OpenNebula 4.3.80</a> by <a href="http://c12g.com" target="_blank">C12G Labs</a>.
<a href="http://opennebula.org" target="_blank">OpenNebula 4.3.85</a> by <a href="http://c12g.com" target="_blank">C12G Labs</a>.
</div>
</div>
<div id="dialogs"></div>
+1 -1
View File
@@ -26,7 +26,7 @@
<div id="footer" style="overflow:visible;">
<a href="http://opennebula.org" target="_blank">OpenNebula 4.3.80</a> by <a href="http://c12g.com" target="_blank">C12G Labs</a>.
<a href="http://opennebula.org" target="_blank">OpenNebula 4.3.85</a> by <a href="http://c12g.com" target="_blank">C12G Labs</a>.
</div>
</body>
</html>
File diff suppressed because it is too large. Load diff
+29 -32
View File
@@ -1,19 +1,19 @@
/* A Bison parser, made by GNU Bison 2.7.12-4996. */
/* A Bison parser, made by GNU Bison 3.0. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
@@ -26,13 +26,13 @@
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef YY_TEMPLATE_TEMPLATE_SYNTAX_HH_INCLUDED
# define YY_TEMPLATE_TEMPLATE_SYNTAX_HH_INCLUDED
/* Enabling traces. */
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
@@ -40,50 +40,47 @@
extern int template__debug;
#endif
/* Tokens. */
/* Token type. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
EQUAL = 258,
COMMA = 259,
OBRACKET = 260,
CBRACKET = 261,
EQUAL_EMPTY = 262,
STRING = 263,
VARIABLE = 264
};
enum yytokentype
{
EQUAL = 258,
COMMA = 259,
OBRACKET = 260,
CBRACKET = 261,
EQUAL_EMPTY = 262,
STRING = 263,
VARIABLE = 264
};
#endif
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
typedef union YYSTYPE YYSTYPE;
union YYSTYPE
{
/* Line 2053 of yacc.c */
#line 74 "template_syntax.y"
#line 74 "template_syntax.y" /* yacc.c:1909 */
char * val_str;
void * val_attr;
/* Line 2053 of yacc.c */
#line 72 "template_syntax.hh"
} YYSTYPE;
#line 69 "template_syntax.hh" /* yacc.c:1909 */
};
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
#endif
/* Location type. */
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
typedef struct YYLTYPE
typedef struct YYLTYPE YYLTYPE;
struct YYLTYPE
{
int first_line;
int first_column;
int last_line;
int last_column;
} YYLTYPE;
# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
};
# define YYLTYPE_IS_DECLARED 1
# define YYLTYPE_IS_TRIVIAL 1
#endif
+2 -2
View File
@@ -165,9 +165,9 @@ array_val: VARIABLE EQUAL STRING
string& unescape (string &str)
{
size_t pos;
size_t pos = 0;
while ((pos = str.find("\\\"")) != string::npos)
while ((pos = str.find("\\\"", pos)) != string::npos)
{
str.replace(pos,2,"\"");
}
@@ -42,13 +42,17 @@ source ${DRIVER_PATH}/../../datastore/libfs.sh
# Set dst path and dir
#-------------------------------------------------------------------------------
SRC_HOST=`arg_host $SRC`
SRC_PATH=`arg_path $SRC`
DST_PATH=`arg_path $DST`
DST_HOST=`arg_host $DST`
DST_DIR=`dirname $DST_PATH`
SRC_ARG_PATH=`arg_path $SRC`
DST_DS_PATH="$(dirname $(dirname $(dirname $DST_PATH)))"
SRC_DS_PATH="$(dirname $(dirname $SRC_ARG_PATH))"
SRC_PATH="${DST_DS_PATH}${SRC_ARG_PATH##$SRC_DS_PATH}"
DS_SYS_ID=$(echo $DST_DIR | $AWK -F '/' '{print $(NF-1)}')
SIZE=`file_size $SRC_PATH`
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
-118
View File
@@ -1,118 +0,0 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
# clone fe:SOURCE host:remote_system_ds/disk.i size vmid dsid
# - fe is the front-end hostname
# - SOURCE is the path of the disk image in the form DS_BASE_PATH/disk
# - host is the target host to deploy the VM
# - remote_system_ds is the path for the system datastore in the host
# - vmid is the id of the VM
# - dsid is the target datastore (0 is the system datastore)
SRC=$1
DST=$2
VMID=$3
DSID=$4
if [ -z "${ONE_LOCATION}" ]; then
TMCOMMON=/var/lib/one/remotes/tm/tm_common.sh
else
TMCOMMON=$ONE_LOCATION/var/remotes/tm/tm_common.sh
fi
DRIVER_PATH=$(dirname $0)
. $TMCOMMON
source ${DRIVER_PATH}/../../datastore/iscsi/iscsi.conf
#-------------------------------------------------------------------------------
# Set src, dst path and dir
#-------------------------------------------------------------------------------
TARGET=`arg_path $SRC`
DST_PATH=`arg_path $DST`
DST_HOST=`arg_host $DST`
DST_DIR=`dirname $DST_PATH`
#-------------------------------------------------------------------------------
# IQN and TARGETs
#-------------------------------------------------------------------------------
IQN=$SRC
NEW_IQN=$IQN-$VMID
VG_NAME=`echo $TARGET|$AWK -F. '{print $(NF-1)}'`
LV_NAME=`echo $TARGET|$AWK -F. '{print $(NF)}'`
SOURCE_DEV="/dev/$VG_NAME/$LV_NAME"
TARGET_LV_NAME=`echo $LV_NAME-$VMID`
TARGET_DEV="/dev/${VG_NAME}/${TARGET_LV_NAME}"
TARGET_HOST="${TARGET%.$VG_NAME.$LV_NAME}"
#-------------------------------------------------------------------------------
# Clone script
#-------------------------------------------------------------------------------
CLONE_CMD=$(cat <<EOF
set -e
# get size
SIZE=\$($SUDO $LVS --noheadings -o lv_size "$SOURCE_DEV")
# create lv
$SUDO $LVCREATE -L\${SIZE} ${VG_NAME} -n ${TARGET_LV_NAME}
# clone lv with dd
$SUDO $DD if=$SOURCE_DEV of=$TARGET_DEV bs=2M
# new iscsi target
$SUDO $(tgt_setup_lun "$NEW_IQN" "$TARGET_DEV")
$SUDO $(tgt_admin_dump_config "$TARGET_CONF")
EOF
)
ssh_exec_and_log "$TARGET_HOST" "$CLONE_CMD" \
"Error cloning $DST_HOST:$TARGET_DEV"
LINK_CMD=$(cat <<EOF
set -e
# discover and login
mkdir -p $DST_DIR
$SUDO $(iscsiadm_discovery "$TARGET_HOST")
$SUDO $(iscsiadm_login "$NEW_IQN" "$TARGET_HOST")
# poll
while [ ! -L /dev/disk/by-path/*$NEW_IQN-lun-1 ]; do
sleep 1
done
# link
DISK_BY_PATH=\$(ls /dev/disk/by-path/*$NEW_IQN-lun-1)
ln -s "\$DISK_BY_PATH" "$DST_PATH"
DISK_DEVNAME=\$(readlink -f \$DISK_BY_PATH | awk -F'/' '{ print \$NF }')
EOF
)
ssh_exec_and_log "$DST_HOST" "$LINK_CMD" \
"Error linking $NEW_IQN in $DST_HOST"
exit 0
-92
View File
@@ -1,92 +0,0 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
# mvds host:remote_system_ds/disk.i fe:SOURCE
# - fe is the front-end hostname
# - SOURCE is the path of the disk image in the form DS_BASE_PATH/disk
# - host is the target host to deploy the VM
# - remote_system_ds is the path for the system datastore in the host
# - vmid is the id of the VM
# - dsid is the target datastore (0 is the system datastore)
SRC=$1
DST=$2
VMID=$3
DSID=$4
if [ -z "${ONE_LOCATION}" ]; then
TMCOMMON=/var/lib/one/remotes/tm/tm_common.sh
else
TMCOMMON=$ONE_LOCATION/var/remotes/tm/tm_common.sh
fi
DRIVER_PATH=$(dirname $0)
. $TMCOMMON
source ${DRIVER_PATH}/../../datastore/iscsi/iscsi.conf
SRC_HOST=`arg_host $SRC`
NEW_IQN="$DST"
DISK_ID=$(echo $SRC|awk -F. '{print $NF}')
#-------------------------------------------------------------------------------
# Get image information
#-------------------------------------------------------------------------------
XPATH="${DRIVER_PATH}/../../datastore/xpath.rb --stdin"
unset i j XPATH_ELEMENTS
while IFS= read -r -d '' element; do
XPATH_ELEMENTS[i++]="$element"
done < <(onevm show -x $VMID| $XPATH \
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/SOURCE \
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/SAVE_AS \
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/PERSISTENT)
IQN="${XPATH_ELEMENTS[j++]}"
SAVE_AS="${XPATH_ELEMENTS[j++]}"
PERSISTENT="${XPATH_ELEMENTS[j++]}"
if [ -z "$PERSISTENT" ]; then
IQN=$IQN-$VMID
fi
#-------------------------------------------------------------------------------
# IQN and TARGETs
#-------------------------------------------------------------------------------
LV_NAME=`echo $IQN|$AWK -F. '{print $(NF)}'`
VG_NAME=`echo $IQN|$AWK -F. '{print $(NF-1)}'`
SOURCE_DEV="/dev/$VG_NAME/$LV_NAME"
TARGET=`arg_path $IQN`
TARGET_LV_NAME=`echo $NEW_IQN|$AWK -F. '{print $(NF)}'`
TARGET_DEV="/dev/$VG_NAME/$TARGET_LV_NAME"
TARGET_HOST="${TARGET%.$VG_NAME.$LV_NAME}"
CLONE_CMD=$(cat <<EOF
$SUDO $DD if=$SOURCE_DEV of=$TARGET_DEV bs=2M
EOF
)
ssh_exec_and_log "$TARGET_HOST" "$CLONE_CMD" \
"Error cloning $DST_HOST:$TARGET_DEV"
-133
View File
@@ -1,133 +0,0 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
# DELETE <host:remote_system_ds/disk.i|host:remote_system_ds/> vmid dsid
# - host is the target host to deploy the VM
# - remote_system_ds is the path for the system datastore in the host
# - vmid is the id of the VM
# - dsid is the target datastore (0 is the system datastore)
DST=$1
VMID=$2
DSID=$3
if [ -z "${ONE_LOCATION}" ]; then
TMCOMMON=/var/lib/one/remotes/tm/tm_common.sh
else
TMCOMMON=$ONE_LOCATION/var/remotes/tm/tm_common.sh
fi
. $TMCOMMON
DRIVER_PATH=$(dirname $0)
source ${DRIVER_PATH}/../../datastore/iscsi/iscsi.conf
#-------------------------------------------------------------------------------
# Return if deleting a disk, we will delete them when removing the
# remote_system_ds directory for the VM (remotely)
#-------------------------------------------------------------------------------
DST_PATH=`arg_path $DST`
DST_HOST=`arg_host $DST`
#-------------------------------------------------------------------------------
# Get IQN information
#-------------------------------------------------------------------------------
DISK_ID=$(echo "$DST_PATH" | $AWK -F. '{print $NF}')
XPATH="${DRIVER_PATH}/../../datastore/xpath.rb --stdin"
unset i j XPATH_ELEMENTS
while IFS= read -r -d '' element; do
XPATH_ELEMENTS[i++]="$element"
done < <(onevm show -x $VMID| $XPATH \
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/SOURCE \
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/PERSISTENT)
IQN="${XPATH_ELEMENTS[j++]}"
PERSISTENT="${XPATH_ELEMENTS[j++]}"
if [ -z "$PERSISTENT" ]; then
NEW_IQN=$IQN-$VMID
else
NEW_IQN=$IQN
fi
TARGET=`arg_path $IQN`
VG_NAME=`echo $TARGET|$AWK -F. '{print $(NF-1)}'`
LV_NAME=`echo $TARGET|$AWK -F. '{print $(NF)}'`
DEV="/dev/$VG_NAME/$LV_NAME"
TARGET_HOST="${TARGET%.$VG_NAME.$LV_NAME}"
TARGET_LV_NAME=`echo $NEW_IQN|$AWK -F. '{print $(NF)}'`
#-------------------------------------------------------------------------------
# Remove directory if dst_path is a directory
#-------------------------------------------------------------------------------
if [ `is_disk $DST_PATH` -eq 0 ]; then
# Directory
log "Deleting $DST_PATH"
ssh_exec_and_log "$DST_HOST" "rm -rf $DST_PATH" "Error deleting $DST_PATH"
exit 0
fi
#-------------------------------------------------------------------------------
# Logout from the iSCSI target in the hypervisor
#-------------------------------------------------------------------------------
LOGOUT_CMD=$(cat <<EOF
set -e
$SUDO $(iscsiadm_logout $NEW_IQN)
EOF
)
ssh_exec_and_log "$DST_HOST" "$LOGOUT_CMD" \
"Error logging out $NEW_IQN"
if [ "$PERSISTENT" = "YES" ]; then
exit 0
fi
#-------------------------------------------------------------------------------
# Remove target and LV in the iSCSI server
#-------------------------------------------------------------------------------
DELETE_CMD=$(cat <<EOF
set -e
# get tid for IQN
TID=\$($SUDO $(tgtadm_get_tid_for_iqn "$NEW_IQN"))
# remove iscsi target
$SUDO $(tgtadm_target_delete "\$TID")
# dump configuration
$SUDO $(tgt_admin_dump_config "$TARGET_CONF")
# remove lv
$SUDO $LVREMOVE -f $VG_NAME/$TARGET_LV_NAME
EOF
)
ssh_exec_and_log "$TARGET_HOST" "$DELETE_CMD" \
"Error logging out $IQN"
exit 0
-83
View File
@@ -1,83 +0,0 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
# clone fe:SOURCE host:remote_system_ds/disk.i size vmid dsid
# - fe is the front-end hostname
# - SOURCE is the path of the disk image in the form DS_BASE_PATH/disk
# - host is the target host to deploy the VM
# - remote_system_ds is the path for the system datastore in the host
# - vmid is the id of the VM
# - dsid is the target datastore (0 is the system datastore)
SRC=$1
DST=$2
VMID=$3
DSID=$4
if [ -z "${ONE_LOCATION}" ]; then
TMCOMMON=/var/lib/one/remotes/tm/tm_common.sh
else
TMCOMMON=$ONE_LOCATION/var/remotes/tm/tm_common.sh
fi
. $TMCOMMON
DRIVER_PATH=$(dirname $0)
source ${DRIVER_PATH}/../../datastore/iscsi/iscsi.conf
#-------------------------------------------------------------------------------
# Set dst path and dir
#-------------------------------------------------------------------------------
IQN=$SRC
TARGET=`arg_path $SRC`
DST_PATH=`arg_path $DST`
DST_HOST=`arg_host $DST`
DST_DIR=`dirname $DST_PATH`
BASE_IQN=`echo $IQN|$CUT -d: -f1`
TARGET=`echo $IQN|$CUT -d: -f2`
LV_NAME=`echo $TARGET|$AWK -F. '{print $(NF)}'`
VG_NAME=`echo $TARGET|$AWK -F. '{print $(NF-1)}'`
TARGET_DEV="/dev/$VG_NAME/$LV_NAME"
TARGET_HOST=${TARGET%.$VG_NAME.$LV_NAME}
LINK_CMD=$(cat <<EOF
set -e
# discover and login
mkdir -p $DST_DIR
$SUDO $(iscsiadm_discovery "$TARGET_HOST")
$SUDO $(iscsiadm_login "$IQN" "$TARGET_HOST")
# poll
while [ ! -L /dev/disk/by-path/*$IQN-lun-1 ]; do
sleep 1
done
# link
DISK_BY_PATH=\$(ls /dev/disk/by-path/*$IQN-lun-1)
ln -s "\$DISK_BY_PATH" "$DST_PATH"
EOF
)
ssh_exec_and_log "$DST_HOST" "$LINK_CMD" \
"Error linking $DST_HOST:$TARGET_DEV"
exit 0
-142
View File
@@ -1,142 +0,0 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
# MV <hostA:system_ds/disk.i|hostB:system_ds/disk.i> vmid dsid
# <hostA:system_ds/|hostB:system_ds/>
# - hostX is the target host to deploy the VM
# - system_ds is the path for the system datastore in the host
# - vmid is the id of the VM
# - dsid is the target datastore (0 is the system datastore)
SRC=$1
DST=$2
VMID=$3
DSID=$4
if [ -z "${ONE_LOCATION}" ]; then
TMCOMMON=/var/lib/one/remotes/tm/tm_common.sh
else
TMCOMMON=$ONE_LOCATION/var/remotes/tm/tm_common.sh
fi
. $TMCOMMON
DRIVER_PATH=$(dirname $0)
source ${DRIVER_PATH}/../../datastore/iscsi/iscsi.conf
#-------------------------------------------------------------------------------
# Return if moving a disk, we will move them when moving the whole system_ds
# directory for the VM
#-------------------------------------------------------------------------------
SRC_PATH=`arg_path $SRC`
DST_PATH=`arg_path $DST`
SRC_HOST=`arg_host $SRC`
DST_HOST=`arg_host $DST`
DST_DIR=`dirname $DST_PATH`
if [ `is_disk $SRC_PATH` -eq 0 ]; then
ssh_make_path $DST_HOST $DST_DIR
log "Moving $SRC to $DST"
exec_and_log "$SCP -r $SRC $DST" "Could not copy $SRC to $DST"
ssh_exec_and_log "$SRC_HOST" "rm -rf $SRC_PATH" \
"Could not remove $SRC_HOST:$SRC_PATH"
exit 0
fi
if [ "$SRC" == "$DST" ]; then
log "Not moving $SRC to $DST, they are the same path"
exit 0
fi
#-------------------------------------------------------------------------------
# Get image information
#-------------------------------------------------------------------------------
XPATH="${DRIVER_PATH}/../../datastore/xpath.rb --stdin"
unset i j XPATH_ELEMENTS
DISK_ID=$(echo "$SRC_PATH" | $AWK -F. '{print $NF}')
while IFS= read -r -d '' element; do
XPATH_ELEMENTS[i++]="$element"
done < <(onevm show -x $VMID| $XPATH \
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/SOURCE \
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/PERSISTENT)
IQN="${XPATH_ELEMENTS[j++]}"
PERSISTENT="${XPATH_ELEMENTS[j++]}"
if [ -z "$PERSISTENT" ]; then
IQN=$IQN-$VMID
fi
#-------------------------------------------------------------------------------
# Start actions
#-------------------------------------------------------------------------------
if is_iscsi "$SRC_HOST"; then
log "Logging out of $IQN in $SRC_HOST"
LOGOUT_CMD=$(cat <<EOF
set -e
$SUDO $(iscsiadm_logout "$IQN")
EOF
)
ssh_exec_and_log "$SRC_HOST" "$LOGOUT_CMD" \
"Error logging out $SRC_HOST:$SRC_PATH ($IQN)"
fi
if is_iscsi "$DST_HOST"; then
log "Logging in to $IQN in $SRC_HOST"
TARGET_HOST=$(iqn_get_host "$IQN")
LINK_CMD=$(cat <<EOF
set -e
# discover and login
mkdir -p $DST_DIR
$SUDO $(iscsiadm_discovery "$TARGET_HOST")
$SUDO $(iscsiadm_login "$IQN" "$TARGET_HOST")
# poll
while [ ! -L /dev/disk/by-path/*$IQN-lun-1 ]; do
sleep 1
done
# link
DISK_BY_PATH=\$(ls /dev/disk/by-path/*$IQN-lun-1)
ln -sf "\$DISK_BY_PATH" "$DST_PATH"
EOF
)
ssh_exec_and_log "$DST_HOST" "$LINK_CMD" \
"Error linking to $DISK_BY_PATH $DST_PATH"
fi
exit 0
-119
View File
@@ -1,119 +0,0 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
# mvds host:remote_system_ds/disk.i fe:SOURCE
# - fe is the front-end hostname
# - SOURCE is the path of the disk image in the form DS_BASE_PATH/disk
# - host is the target host to deploy the VM
# - remote_system_ds is the path for the system datastore in the host
# - vmid is the id of the VM
# - dsid is the target datastore (0 is the system datastore)
SRC=$1
DST=$2
VMID=$3
DSID=$4
if [ -z "${ONE_LOCATION}" ]; then
TMCOMMON=/var/lib/one/remotes/tm/tm_common.sh
else
TMCOMMON=$ONE_LOCATION/var/remotes/tm/tm_common.sh
fi
DRIVER_PATH=$(dirname $0)
. $TMCOMMON
source ${DRIVER_PATH}/../../datastore/iscsi/iscsi.conf
SRC_HOST=`arg_host $SRC`
NEW_IQN="$DST"
DISK_ID=$(echo $SRC|awk -F. '{print $NF}')
#-------------------------------------------------------------------------------
# Get image information
#-------------------------------------------------------------------------------
XPATH="${DRIVER_PATH}/../../datastore/xpath.rb --stdin"
unset i j XPATH_ELEMENTS
while IFS= read -r -d '' element; do
XPATH_ELEMENTS[i++]="$element"
done < <(onevm show -x $VMID| $XPATH \
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/SOURCE \
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/SAVE_AS \
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/PERSISTENT)
IQN="${XPATH_ELEMENTS[j++]}"
SAVE_AS="${XPATH_ELEMENTS[j++]}"
PERSISTENT="${XPATH_ELEMENTS[j++]}"
if [ -z "$PERSISTENT" ]; then
IQN=$IQN-$VMID
fi
log "Logging out $IQN"
LOGOUT_CMD=$(cat <<EOF
set -e
$SUDO $(iscsiadm_logout "$IQN")
EOF
)
ssh_exec_and_log "$SRC_HOST" "$LOGOUT_CMD" \
"Error logging out $IQN"
# Exit if not save_as. We are finished if this was a persistent image.
[ -z "$SAVE_AS" ] && exit 0
#-------------------------------------------------------------------------------
# IQN and TARGETs
#-------------------------------------------------------------------------------
LV_NAME=`echo $IQN|$AWK -F. '{print $(NF)}'`
VG_NAME=`echo $IQN|$AWK -F. '{print $(NF-1)}'`
SOURCE_DEV="/dev/$VG_NAME/$LV_NAME"
TARGET=`arg_path $IQN`
TARGET_LV_NAME=`echo $NEW_IQN|$AWK -F. '{print $(NF)}'`
TARGET_DEV="/dev/$VG_NAME/$TARGET_LV_NAME"
TARGET_HOST="${TARGET%.$VG_NAME.$LV_NAME}"
CLONE_CMD=$(cat <<EOF
set -e
# clone lv with dd
$SUDO $DD if=$SOURCE_DEV of=$TARGET_DEV bs=2M
# remove if source_dev is not persistent
if [ -z "$PERSISTENT" ]; then
TID=\$($SUDO $(tgtadm_get_tid_for_iqn "$IQN"))
$SUDO $(tgtadm_target_delete "\$TID")
$SUDO $SYNC
$SUDO $LVREMOVE -f $VG_NAME/$LV_NAME
$SUDO $(tgt_admin_dump_config "$TARGET_CONF")
fi
EOF
)
ssh_exec_and_log "$TARGET_HOST" "$CLONE_CMD" \
"Error cloning $DST_HOST:$TARGET_DEV or removing nonpersistent $IQN"
-1
View File
@@ -1 +0,0 @@
../common/postmigrate
-1
View File
@@ -1 +0,0 @@
../common/premigrate
+12
View File
@@ -686,6 +686,7 @@ int VirtualMachine::parse_context(string& error_str)
string name = vatt->vector_value("NETWORK");
string ip = vatt->vector_value("IP");
string mac = vatt->vector_value("MAC");
string ip6 = vatt->vector_value("IP6_GLOBAL");
string nic_id = vatt->vector_value("NIC_ID");
@@ -697,6 +698,11 @@ int VirtualMachine::parse_context(string& error_str)
var.str(""); val.str("");
var << "ETH" << nic_id << "_MAC";
context->replace(var.str(), mac);
var.str(""); val.str("");
var << "ETH" << nic_id << "_NETWORK";
val << "$NETWORK[NETWORK_ADDRESS, NETWORK=\"" << name << "\"]";
context->replace(var.str(), val.str());
@@ -725,6 +731,12 @@ int VirtualMachine::parse_context(string& error_str)
val << "$NETWORK[DNS, NETWORK=\"" << name << "\"]";
context->replace(var.str(), val.str());
var.str(""); val.str("");
var << "ETH" << nic_id << "_SEARCH_DOMAIN";
val << "$NETWORK[SEARCH_DOMAIN, NETWORK=\"" << name << "\"]";
context->replace(var.str(), val.str());
if (!ip6.empty())
{
var.str(""); val.str("");
+315 -512
View File
File diff suppressed because it is too large. Load diff
+31 -34
View File
@@ -1,19 +1,19 @@
/* A Bison parser, made by GNU Bison 2.7.12-4996. */
/* A Bison parser, made by GNU Bison 3.0. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
@@ -26,13 +26,13 @@
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef YY_VM_VAR_VM_VAR_SYNTAX_HH_INCLUDED
# define YY_VM_VAR_VM_VAR_SYNTAX_HH_INCLUDED
/* Enabling traces. */
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
@@ -40,53 +40,50 @@
extern int vm_var__debug;
#endif
/* Tokens. */
/* Token type. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
EQUAL = 258,
COMMA = 259,
OBRACKET = 260,
CBRACKET = 261,
EOA = 262,
STRING = 263,
VARIABLE = 264,
RSTRING = 265,
INTEGER = 266
};
enum yytokentype
{
EQUAL = 258,
COMMA = 259,
OBRACKET = 260,
CBRACKET = 261,
EOA = 262,
STRING = 263,
VARIABLE = 264,
RSTRING = 265,
INTEGER = 266
};
#endif
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
typedef union YYSTYPE YYSTYPE;
union YYSTYPE
{
/* Line 2053 of yacc.c */
#line 427 "vm_var_syntax.y"
#line 427 "vm_var_syntax.y" /* yacc.c:1909 */
char * val_str;
int val_int;
char val_char;
/* Line 2053 of yacc.c */
#line 75 "vm_var_syntax.hh"
} YYSTYPE;
#line 72 "vm_var_syntax.hh" /* yacc.c:1909 */
};
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
#endif
/* Location type. */
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
typedef struct YYLTYPE
typedef struct YYLTYPE YYLTYPE;
struct YYLTYPE
{
int first_line;
int first_column;
int last_line;
int last_column;
} YYLTYPE;
# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
};
# define YYLTYPE_IS_DECLARED 1
# define YYLTYPE_IS_TRIVIAL 1
#endif
+52 -9
View File
@@ -59,6 +59,8 @@ int LibVirtDriver::deployment_description_kvm(
string disk_io = "";
string source = "";
string clone = "";
string ceph_host = "";
string ceph_secret= "";
int disk_id;
string default_driver = "";
@@ -311,14 +313,16 @@ int LibVirtDriver::deployment_description_kvm(
continue;
}
type = disk->vector_value("TYPE");
target = disk->vector_value("TARGET");
ro = disk->vector_value("READONLY");
driver = disk->vector_value("DRIVER");
cache = disk->vector_value("CACHE");
disk_io= disk->vector_value("IO");
source = disk->vector_value("SOURCE");
clone = disk->vector_value("CLONE");
type = disk->vector_value("TYPE");
target = disk->vector_value("TARGET");
ro = disk->vector_value("READONLY");
driver = disk->vector_value("DRIVER");
cache = disk->vector_value("CACHE");
disk_io = disk->vector_value("IO");
source = disk->vector_value("SOURCE");
clone = disk->vector_value("CLONE");
ceph_host = disk->vector_value("CEPH_HOST");
ceph_secret = disk->vector_value("CEPH_SECRET");
disk->vector_value_str("DISK_ID", disk_id);
@@ -360,7 +364,46 @@ int LibVirtDriver::deployment_description_kvm(
file << "-" << vm->get_oid() << "-" << disk_id;
}
file << "'/>" << endl;
if ( ceph_host.empty() )
{
file << "'/>" << endl;
}
else
{
vector<string>::const_iterator it;
vector<string> hosts = one_util::split(ceph_host, ' ');
file << "'>" << endl;
for (it = hosts.begin(); it != hosts.end(); it++)
{
vector<string> parts = one_util::split(*it, ':');
if (parts.empty())
{
continue;
}
file << "\t\t\t\t<host name='" << parts[0];
if (parts.size() > 1)
{
file << "' port='" << parts[1];
}
file << "'/>" << endl;
}
file << "\t\t\t</source>" << endl;
}
if ( !ceph_secret.empty() )
{
file << "\t\t\t<auth username='libvirt'>" << endl
<< "\t\t\t\t<secret type='ceph' uuid='"
<< ceph_secret <<"'/>" << endl
<< "\t\t\t</auth>" << endl;
}
}
else if ( type == "RBD_CDROM" )
{
+1 -1
View File
@@ -1551,7 +1551,7 @@ void VirtualMachineManager::timer_action()
os.str("");
os << "Monitoring VM " << *it << ".";
NebulaLog::log("VMM", Log::INFO, os);
NebulaLog::log("VMM", Log::DEBUG, os);
vmd = get(vm->get_vmm_mad());
+1 -1
View File
@@ -635,7 +635,7 @@ void VirtualMachineManagerDriver::process_poll(
}
oss << "VM " << vm->get_oid() << " successfully monitored: " << monitor_str;
NebulaLog::log("VMM", Log::INFO, oss);
NebulaLog::log("VMM", Log::DEBUG, oss);
vm->update_info(memory, cpu, net_tx, net_rx, custom);
+1
View File
@@ -454,6 +454,7 @@ int XenDriver::deployment_description(
goto error_vncdisplay;
}
file << ",vncunused=0";
file << ",vncdisplay=" << display - 5900;
}
+8 -1
View File
@@ -772,6 +772,13 @@ class ExecDriver < VirtualMachineDriver
model = model.strip if !model.nil?
model = "-" if model.nil?
net_drv = xml_data.elements["NET_DRV"]
net_drv = net_drv.text if !net_drv.nil?
net_drv = net_drv.strip if !net_drv.nil?
net_drv = "-" if net_drv.nil?
action = VmmAction.new(self, id, :attach_nic, drv_message)
steps=[
@@ -784,7 +791,7 @@ class ExecDriver < VirtualMachineDriver
{
:driver => :vmm,
:action => :attach_nic,
:parameters => [:deploy_id, mac, source, model]
:parameters => [:deploy_id, mac, source, model, net_drv]
},
# Execute post-boot networking setup
{
+30 -8
View File
@@ -21,14 +21,36 @@ source $(dirname $0)/../../scripts_common.sh
DOMAIN=$1
MAC=$2
SOURCE=$3
MODEL=$4
BRIDGE=$3
THE_MODEL=$4
NET_DRV=$5
ATTACH_ARGS="--domain $DOMAIN --type bridge --source $SOURCE --mac $MAC"
if [ "$MODEL" != "-" ]; then
ATTACH_ARGS="$ATTACH_ARGS --model $MODEL"
if [ "$THE_MODEL" != "-" ]; then
MODEL="<model type='$THE_MODEL'/>"
fi
exec_and_log "virsh --connect $LIBVIRT_URI attach-interface $ATTACH_ARGS" \
"Could not attach NIC ($MAC) to $DOMAIN"
if [ "$NET_DRV" = "ovswitch" ]; then
VIRTUALPORT="<virtualport type='openvswitch'/>"
fi
DEVICE=$(cat <<EOF
<interface type='bridge'>
<source bridge='$BRIDGE'/>
<mac address='$MAC'/>
$MODEL
$VIRTUALPORT
</interface>
EOF
)
ATTACH_CMD=$(cat <<EOF
virsh --connect $LIBVIRT_URI attach-device $DOMAIN <(
cat <<EOT
$DEVICE
EOT
)
EOF
)
multiline_exec_and_log "$ATTACH_CMD" \
"Could not attach $SOURCE ($TARGET) to $DOMAIN"
+1 -1
View File
@@ -33,7 +33,7 @@ deploy_id = ARGV[0]
mac = ARGV[1]
bridge = ARGV[2]
model = ARGV[3]
host = ARGV[5]
host = ARGV[6]
VIDriver::initialize(host, false)
+17 -1
View File
@@ -706,18 +706,24 @@ int VirtualNetwork::from_xml(const string &xml_str)
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int VirtualNetwork::nic_attribute(VectorAttribute *nic, int vid)
int VirtualNetwork::nic_attribute(
VectorAttribute * nic,
int vid,
const vector<string>& inherit_attrs)
{
int rc;
string ip;
string mac;
string inherit_val;
unsigned int eui64[2];
unsigned int prefix[2] = {0, 0};
ostringstream oss;
vector<string>::const_iterator it;
ip = nic->vector_value("IP");
oss << oid;
@@ -792,6 +798,16 @@ int VirtualNetwork::nic_attribute(VectorAttribute *nic, int vid)
nic->replace("CLUSTER_ID", oss.str());
}
for (it = inherit_attrs.begin(); it != inherit_attrs.end(); it++)
{
get_template_attribute((*it).c_str(), inherit_val);
if (!inherit_val.empty())
{
nic->replace(*it, inherit_val);
}
}
return 0;
}
+16 -6
View File
@@ -32,11 +32,12 @@ unsigned int VirtualNetworkPool::_default_size;
/* -------------------------------------------------------------------------- */
VirtualNetworkPool::VirtualNetworkPool(
SqlDB * db,
const string& prefix,
int __default_size,
vector<const Attribute *> hook_mads,
const string& remotes_location):
SqlDB * db,
const string& prefix,
int __default_size,
vector<const Attribute *> hook_mads,
const string& remotes_location,
const vector<const Attribute *>& _inherit_attrs):
PoolSQL(db, VirtualNetwork::table, true)
{
istringstream iss;
@@ -44,6 +45,8 @@ VirtualNetworkPool::VirtualNetworkPool(
int count = 0;
unsigned int tmp;
vector<const Attribute *>::const_iterator it;
string mac = prefix;
_mac_prefix = 0;
@@ -71,6 +74,13 @@ VirtualNetworkPool::VirtualNetworkPool(
_mac_prefix += tmp;
register_hooks(hook_mads, remotes_location);
for (it = _inherit_attrs.begin(); it != _inherit_attrs.end(); it++)
{
const SingleAttribute* sattr = static_cast<const SingleAttribute *>(*it);
inherit_attrs.push_back(sattr->value());
}
}
/* -------------------------------------------------------------------------- */
@@ -250,7 +260,7 @@ int VirtualNetworkPool::nic_attribute(VectorAttribute * nic,
return -1;
}
int rc = vnet->nic_attribute(nic,vid);
int rc = vnet->nic_attribute(nic, vid, inherit_attrs);
if ( rc == 0 )
{