From 27657e6aa94666955b8db4688f17211fb16da56f Mon Sep 17 00:00:00 2001 From: narindergupta Date: Wed, 26 Apr 2017 15:58:50 +0200 Subject: [PATCH] modify the maas to use the interface name as per yaml file Change-Id: I6a060757a39786c073c2567ca73502267d8c271b Signed-off-by: Narinder Gupta --- ci/03-maasdeploy.sh | 17 +++++++++++------ labconfig/cengn/pod1/labconfig.yaml | 34 +++++++++++++++++----------------- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/ci/03-maasdeploy.sh b/ci/03-maasdeploy.sh index 04066c9b..d439951d 100755 --- a/ci/03-maasdeploy.sh +++ b/ci/03-maasdeploy.sh @@ -559,7 +559,7 @@ if [ -e ./labconfig.json ]; then echo ">>> Configuring node $NODE_NAME [$NODE_ID][$NODE_SYS_ID]" # Recover the network interfaces list and configure each one # with sorting the list, we have hardware interface first, than the vlan interfaces - IF_LIST=$(cat labconfig.json | jq --raw-output ".lab.racks[0].nodes[$NODE_ID].nics[] ".ifname | sort -u) + IF_LIST=$(cat labconfig.json | jq --raw-output ".lab.racks[0].nodes[$NODE_ID].nics[] ".ifname ) for IF_NAME in $IF_LIST; do # get the space of the interface IF_SPACE=$(cat labconfig.json | jq --raw-output ".lab.racks[0].nodes[$NODE_ID].nics[] | select(.ifname==\"$IF_NAME\") ".spaces[]) @@ -579,7 +579,16 @@ if [ -e ./labconfig.json ]; then IF_VLAN = ${IF_NAME##*.}; fi # in case of interface renaming - IF_NEWNAME=$(cat labconfig.json | jq --raw-output ".lab.racks[0].nodes[$NODE_ID].nics[] | select(.ifname==\"$IF_NAME\") ".rename) + IF_NEWNAME=$IF_NAME + + if ([ $IF_NEWNAME ] && [ "$IF_NEWNAME" != "null" ]); then + # rename interface if needed + IF_MACLOWER=$( cat labconfig.json | jq ".lab.racks[0].nodes[$NODE_ID].nics[] | select(.ifname==\"$IF_NEWNAME\")".mac[0]) + IF_MAC=(${IF_MACLOWER,,}) + IF_ID=$( maas ubuntu interfaces read $NODE_SYS_ID | jq ".[] | select(.mac_address==$IF_MAC)".id) + maas $PROFILE interface update $NODE_SYS_ID $IF_ID name=$IF_NEWNAME + IF_NAME=$IF_NEWNAME + fi # In case of a VLAN interface if ([ $IF_VLAN ] && [ "$IF_VLAN" != "null" ]); then @@ -603,10 +612,6 @@ if [ -e ./labconfig.json ]; then INTERFACE=$(maas $PROFILE interfaces read $NODE_SYS_ID | jq ".[] | select(.vlan.fabric_id==$FABRICID)".id) fi maas $PROFILE interfaces create-vlan $NODE_SYS_ID vlan=$VLANID parent=$INTERFACE || true - elif ([ $IF_NEWNAME ] && [ "$IF_NEWNAME" != "null" ]); then - # rename interface if needed - maas $PROFILE interface update $NODE_SYS_ID $IF_NAME name=$IF_NEWNAME - IF_NAME=$IF_NEWNAME fi # Configure the interface if ([ $SUBNET_CIDR ] && [ "$SUBNET_CIDR" != "null" ]); then diff --git a/labconfig/cengn/pod1/labconfig.yaml b/labconfig/cengn/pod1/labconfig.yaml index 2d344670..ae51c359 100644 --- a/labconfig/cengn/pod1/labconfig.yaml +++ b/labconfig/cengn/pod1/labconfig.yaml @@ -7,13 +7,13 @@ lab: architecture: x86_64 roles: [network,control] nics: - - ifname: enp11s0 + - ifname: intf100 spaces: [admin] mac: ["00:A0:A5:90:89:66"] - - ifname: enp12s0 + - ifname: intf101 spaces: [floating] mac: ["00:A0:A5:90:89:67"] - - ifname: enp3s0f1 + - ifname: intf102 spaces: [data] mac: ["00:A0:A5:90:89:65"] power: @@ -25,13 +25,13 @@ lab: architecture: x86_64 roles: [compute,control,storage] nics: - - ifname: enp11s0 + - ifname: intf100 spaces: [admin] mac: ["00:A0:A5:90:89:A8"] - - ifname: enp12s0 + - ifname: intf101 spaces: [floating] mac: ["00:A0:A5:90:89:A9"] - - ifname: enp3s0f1 + - ifname: intf102 spaces: [data] mac: ["00:A0:A5:90:89:A7"] power: @@ -43,13 +43,13 @@ lab: architecture: x86_64 roles: [compute,control,storage] nics: - - ifname: enp11s0 + - ifname: intf100 spaces: [admin] mac: ["00:A0:A5:90:89:28"] - - ifname: enp12s0 + - ifname: intf101 spaces: [floating] mac: ["00:A0:A5:90:89:29"] - - ifname: enp3s0f1 + - ifname: intf102 spaces: [data] mac: ["00:A0:A5:90:89:27"] power: @@ -61,13 +61,13 @@ lab: architecture: x86_64 roles: [compute,storage] nics: - - ifname: enp11s0 + - ifname: intf100 spaces: [admin] mac: ["00:A0:A5:89:30:C6"] - - ifname: enp12s0 + - ifname: intf101 spaces: [floating] mac: ["00:A0:A5:89:30:C7"] - - ifname: enp3s0f1 + - ifname: intf102 spaces: [data] mac: ["00:A0:A5:89:30:C5"] power: @@ -79,13 +79,13 @@ lab: architecture: x86_64 roles: [compute,storage] nics: - - ifname: enp11s0 + - ifname: intf100 spaces: [admin] mac: ["00:A0:A5:90:89:94"] - - ifname: enp12s0 + - ifname: intf101 spaces: [floating] mac: ["00:A0:A5:90:89:95"] - - ifname: enp3s0f1 + - ifname: intf102 spaces: [data] mac: ["00:A0:A5:90:89:93"] power: @@ -94,7 +94,7 @@ lab: user: admin pass: admin floating-ip-range: 10.21.6.6,10.21.6.250,10.21.6.254,10.21.6.0/24 - ext-port: "enp12s0" + ext-port: "intf101" dns: 8.8.8.8 osdomainname: opnfv: @@ -123,4 +123,4 @@ opnfv: bridge: brData cidr: 192.168.20.0/24 gateway: 192.168.20.254 - vlan: \ No newline at end of file + vlan: -- 2.16.6