Merge "Add option to specify mac adress in devstack/.../create-node.sh"

This commit is contained in:
Zuul 2018-02-05 05:25:03 +00:00 committed by Gerrit Code Review
commit 70a86cd8b5
3 changed files with 13 additions and 2 deletions

View File

@ -73,6 +73,8 @@ def main():
help='The libvirt network driver to use')
parser.add_argument('--interface-count', default=1, type=int,
help='The number of interfaces to add to VM.'),
parser.add_argument('--mac', default=None,
help='The mac for the first interface on the vm')
parser.add_argument('--console-log',
help='File to log console')
parser.add_argument('--emulator', default=None,
@ -99,6 +101,7 @@ def main():
'cpus': args.cpus,
'bootdev': args.bootdev,
'interface_count': args.interface_count,
'mac': args.mac,
'nicdriver': args.libvirt_nic_driver,
'emulator': args.emulator,
'disk_format': args.disk_format,

View File

@ -12,7 +12,7 @@ export PS4='+ ${BASH_SOURCE:-}:${FUNCNAME[0]:-}:L${LINENO:-}: '
# Keep track of the DevStack directory
TOP_DIR=$(cd $(dirname "$0")/.. && pwd)
while getopts "n:c:i:m:M:d:a:b:e:E:p:o:f:l:L:N:" arg; do
while getopts "n:c:i:m:M:d:a:b:e:E:p:o:f:l:L:N:A:" arg; do
case $arg in
n) NAME=$OPTARG;;
c) CPU=$OPTARG;;
@ -32,6 +32,7 @@ while getopts "n:c:i:m:M:d:a:b:e:E:p:o:f:l:L:N:" arg; do
l) LOGDIR=$OPTARG;;
L) UEFI_LOADER=$OPTARG;;
N) UEFI_NVRAM=$OPTARG;;
A) MAC_ADDRESS=$OPTARG;;
esac
done
@ -105,6 +106,10 @@ for int in $(seq 1 $INTERFACE_COUNT); do
sudo ovs-vsctl add-port $BRIDGE $ovsif
done
if [ -n "$MAC_ADDRESS" ] ; then
MAC_ADDRESS="--mac $MAC_ADDRESS"
fi
if ! virsh list --all | grep -q $NAME; then
virsh vol-list --pool $LIBVIRT_STORAGE_POOL | grep -q $VOL_NAME &&
virsh vol-delete $VOL_NAME --pool $LIBVIRT_STORAGE_POOL >&2
@ -121,7 +126,7 @@ if ! virsh list --all | grep -q $NAME; then
--bootdev network --name $NAME --image "$volume_path" \
--arch $ARCH --cpus $CPU --memory $MEM --libvirt-nic-driver $LIBVIRT_NIC_DRIVER \
--disk-format $DISK_FORMAT $VM_LOGGING --engine $ENGINE $UEFI_OPTS $vm_opts \
--interface-count $INTERFACE_COUNT >&2
--interface-count $INTERFACE_COUNT $MAC_ADDRESS >&2
# Createa Virtual BMC for the node if IPMI is used
if [[ $(type -P vbmc) != "" ]]; then

View File

@ -46,6 +46,9 @@
</controller>
{% for n in range(1, interface_count+1) %}
<interface type='direct'>
{% if n == 1 and mac %}
<mac address='{{ mac }}'/>
{% endif %}
<source dev='{{ "tap-" + name + "i" + n|string }}'/>
<model type='{{ nicdriver }}'/>
<address type='pci' domain='0x0000' bus='0x01' slot='{{ "0x0" + n|string }}' function='0x0'/>