72 lines
1.7 KiB
Bash
Executable File
72 lines
1.7 KiB
Bash
Executable File
#!/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
|