summaryrefslogtreecommitdiff
path: root/devstack
diff options
context:
space:
mode:
authorDerek Higgins <derekh@redhat.com>2017-10-04 12:33:26 +0100
committerDerek Higgins <derekh@redhat.com>2018-02-01 11:46:56 +0000
commite209a6cf02bc26e704814242d7179b248f214d9b (patch)
tree816409c1e2e07289e83fb877d18a7c5a2b835052 /devstack
parente882dfbd52238744e86d6cc8f829bc3fc28ed50a (diff)
downloadironic-e209a6cf02bc26e704814242d7179b248f214d9b.tar.gz
Add option to specify mac adress in devstack/.../create-node.sh
Add an option that allows the caller to specify a MAC for the created node. Change-Id: I341aa23b45901ee5e96254508c6327ebf67f2c9e
Diffstat (limited to 'devstack')
-rwxr-xr-xdevstack/tools/ironic/scripts/configure-vm.py3
-rwxr-xr-xdevstack/tools/ironic/scripts/create-node.sh9
-rw-r--r--devstack/tools/ironic/templates/vm.xml3
3 files changed, 13 insertions, 2 deletions
diff --git a/devstack/tools/ironic/scripts/configure-vm.py b/devstack/tools/ironic/scripts/configure-vm.py
index 14df8feb4..144ec97d0 100755
--- a/devstack/tools/ironic/scripts/configure-vm.py
+++ b/devstack/tools/ironic/scripts/configure-vm.py
@@ -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,
diff --git a/devstack/tools/ironic/scripts/create-node.sh b/devstack/tools/ironic/scripts/create-node.sh
index 9c1144a5d..8cead28ad 100755
--- a/devstack/tools/ironic/scripts/create-node.sh
+++ b/devstack/tools/ironic/scripts/create-node.sh
@@ -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
diff --git a/devstack/tools/ironic/templates/vm.xml b/devstack/tools/ironic/templates/vm.xml
index dc6093e0b..f88d705b2 100644
--- a/devstack/tools/ironic/templates/vm.xml
+++ b/devstack/tools/ironic/templates/vm.xml
@@ -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'/>