Change upload sriov image script
To accept path to image Change-Id: I8b6da62a8c334b8201b2cb7892ef0976c2e143a2
This commit is contained in:
parent
38f580da4a
commit
fafdeeeee9
|
@ -14,14 +14,57 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
usage() {
|
||||
echo "Usage: `basename $0` [-f vm_flavor | -h]"
|
||||
echo " This script is used to start a VM with a flavor using SR-IOV image."
|
||||
echo " before starting the VM, make sure the SRIOV image is uploaded,"
|
||||
echo " please use upload_sriov_image script."
|
||||
|
||||
echo "
|
||||
Options:
|
||||
-h Display the help message.
|
||||
-f <flavor> Create <flavor> SR-IOV VM with direct port.
|
||||
"
|
||||
}
|
||||
|
||||
while getopts ":f:h" opt; do
|
||||
case $opt in
|
||||
h)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
f)
|
||||
flavor="${OPTARG}"
|
||||
logger_print info "SRIOV image flavor $flavor"
|
||||
;;
|
||||
[?])
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z $flavor ]
|
||||
then
|
||||
echo "ERROR: -f or -h must be included when a calling this script" >&2
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
. /root/openrc
|
||||
glance_line=`glance image-list | grep mellanox`
|
||||
if [[ $glance_line == *mellanox* ]]; then
|
||||
SRIOV_IMAGE=`echo $glance_line | head -n 1 | awk '{print $2}'`
|
||||
port_id=`neutron port-create admin_internal_net --name sriov_port --vnic-type direct | grep " id " | awk '{print $4}'`
|
||||
nova boot --flavor m1.tiny --image $SRIOV_IMAGE --nic port-id=$port_id "sriov_vm-$port_id"
|
||||
exit 0
|
||||
nova boot --flavor ${flavor} --image $SRIOV_IMAGE --nic port-id=$port_id "sriov_vm-$port_id"
|
||||
if [ $? -ne 0 ]; then
|
||||
logger_print error "Starting VM with SR-IOV support failed."
|
||||
exit 1
|
||||
else
|
||||
logger_print info "SR-IOV VM was successfully started."
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
echo "No Mellanox SR-IOV cirros found. Please use 'upload_sriov_cirros' script"
|
||||
echo "No Mellanox SR-IOV image was found. Please use 'upload_sriov_image' script"
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
#!/bin/bash
|
||||
# Copyright 2015 Mellanox Technologies, Ltd
|
||||
#
|
||||
# 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.
|
||||
|
||||
source /sbin/common
|
||||
|
||||
function install_cirros() {
|
||||
if [ $DISTRO == 'redhat' ]; then
|
||||
yum install -y $1
|
||||
elif [ $DISTRO == 'ubuntu' ]; then
|
||||
apt-get install -y $1
|
||||
fi
|
||||
}
|
||||
|
||||
if [ $SRIOV == false ]; then
|
||||
logger_print info "Skipping cirros image installation, Mellanox-Cirros is required
|
||||
only for SR-IOV deployments"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ $DRIVER == 'eth_ipoib' ]; then
|
||||
CIRROS_PACKAGE_NAME='cirros-testvm-mellanox-ib'
|
||||
else
|
||||
CIRROS_PACKAGE_NAME='cirros-testvm-mellanox'
|
||||
fi
|
||||
|
||||
puppet apply -e 'package { "cirros-testvm": ensure => absent }' &&
|
||||
puppet apply -e 'package { "cirros-testvm-mellanox": ensure => absent }' &&
|
||||
puppet apply -e 'package { "cirros-testvm-mellanox-ib": ensure => absent }' &&
|
||||
install_cirros $CIRROS_PACKAGE_NAME &&
|
||||
. /root/openrc &&
|
||||
glance image-create \
|
||||
--name $CIRROS_PACKAGE_NAME \
|
||||
--disk-format=qcow2 \
|
||||
--container-format=bare \
|
||||
--visibility public \
|
||||
--progress \
|
||||
--file /usr/share/cirros-testvm/cirros-x86_64-disk.img >> /var/log/mellanox-plugin.log
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
logger_print error "Installing Cirros image with Mellanox SR-IOV support failed"
|
||||
exit 1
|
||||
else
|
||||
logger_print info "Cirros mellanox SR-IOV image was successfully installed"
|
||||
exit 0
|
||||
fi
|
|
@ -0,0 +1,71 @@
|
|||
#!/bin/bash
|
||||
# Copyright 2015 Mellanox Technologies, Ltd
|
||||
#
|
||||
# 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.
|
||||
|
||||
source /sbin/common
|
||||
|
||||
usage() {
|
||||
echo "Usage: `basename $0` [-f file_location | -h]"
|
||||
echo " This script is used to upload SR-IOV image."
|
||||
echo " after uploading the image, please use start_sriov_vm script"
|
||||
echo " in order to test SR-IOV functionality in Openstack."
|
||||
|
||||
echo "
|
||||
Options:
|
||||
-h Display the help message.
|
||||
-f <file> Upload SR-IOV test image, located in <file> location
|
||||
"
|
||||
}
|
||||
|
||||
while getopts ":f:h" opt; do
|
||||
case $opt in
|
||||
h)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
f)
|
||||
file="${OPTARG}"
|
||||
logger_print info "Uploading $file"
|
||||
;;
|
||||
[?])
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z $file ]
|
||||
then
|
||||
echo "ERROR: -f or -h must be included when a calling this script" >&2
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
. /root/openrc &&
|
||||
glance image-create \
|
||||
--name "mellanox_sriov" \
|
||||
--disk-format=qcow2 \
|
||||
--container-format=bare \
|
||||
--visibility public \
|
||||
--progress \
|
||||
--file $file >> /var/log/mellanox-plugin.log
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
logger_print error "Installing image with SR-IOV support failed."
|
||||
exit 1
|
||||
else
|
||||
logger_print info "SR-IOV image was successfully installed."
|
||||
exit 0
|
||||
fi
|
|
@ -5,7 +5,7 @@ name: mellanox-plugin
|
|||
title: Mellanox ConnectX-4 Openstack Features
|
||||
|
||||
# Plugin version
|
||||
version: 3.1.9
|
||||
version: 3.1.12
|
||||
|
||||
# Description
|
||||
description: Enable features over Mellanox ConnectX-4 Adapters
|
||||
|
|
Loading…
Reference in New Issue