Updated Branches: refs/heads/master 338463383 -> c39ec1eb8
CLOUDSTACK-6062: nic device ids don't always correspond to 'eth' device numbers, but vpc scripts require it. Now we match based on mac. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/c39ec1eb Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c39ec1eb Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c39ec1eb Branch: refs/heads/master Commit: c39ec1eb8fe26dc720539a00f4ec771bcf7ef0e2 Parents: 3384633 Author: Marcus Sorensen <mar...@betterservers.com> Authored: Fri Feb 7 14:59:40 2014 -0700 Committer: Marcus Sorensen <mar...@betterservers.com> Committed: Fri Feb 7 14:59:40 2014 -0700 ---------------------------------------------------------------------- .../virtualnetwork/VirtualRoutingResource.java | 2 + .../debian/config/opt/cloud/bin/vpc_acl.sh | 19 ++++++++- .../debian/config/opt/cloud/bin/vpc_guestnw.sh | 44 +++++++++++++++----- 3 files changed, 53 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c39ec1eb/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java ---------------------------------------------------------------------- diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java index 1ed3864..a11261e 100755 --- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java +++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java @@ -637,6 +637,7 @@ public class VirtualRoutingResource { String netmask = NetUtils.getSubNet(routerGIP, nic.getNetmask()); String args = " -C"; + args += " -M " + nic.getMac(); args += " -d " + dev; args += " -i " + routerGIP; args += " -g " + gateway; @@ -677,6 +678,7 @@ public class VirtualRoutingResource { ExecutionResult result; String args = " -d " + dev; + args += " -M " + nic.getMac(); if (privateGw != null) { args += " -a " + rule; result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "vpc_privategw_acl.sh", args); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c39ec1eb/systemvm/patches/debian/config/opt/cloud/bin/vpc_acl.sh ---------------------------------------------------------------------- diff --git a/systemvm/patches/debian/config/opt/cloud/bin/vpc_acl.sh b/systemvm/patches/debian/config/opt/cloud/bin/vpc_acl.sh index 903d6d6..0a791c6 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/vpc_acl.sh +++ b/systemvm/patches/debian/config/opt/cloud/bin/vpc_acl.sh @@ -155,11 +155,13 @@ acl_entry_for_guest_network() { dflag=0 gflag=0 aflag=0 +Mflag=0 rules="" rules_list="" ip="" dev="" -while getopts 'd:i:m:a:' OPTION +mac="" +while getopts 'd:i:m:M:a:' OPTION do case $OPTION in d) dflag=1 @@ -171,6 +173,9 @@ do m) mflag=1 mask="$OPTARG" ;; + M) Mflag=1 + mac="$OPTARG" + ;; a) aflag=1 rules="$OPTARG" ;; @@ -186,6 +191,18 @@ then unlock_exit 2 $lock $locked fi +# override dev with mac address match, if provided +if [[ ! -z "$mac" ]]; then + logger -t cloud "$(basename $0): mac $mac passed, trying to match to device" + for i in `ls /sys/class/net`; do + if grep -q $mac /sys/class/net/$i/address; then + dev=$i + logger -t cloud "$(basename $0): matched dev $i to mac $mac, dev is now $dev" + break + fi + done +fi + gcidr="$ip/$mask" if [ -n "$rules" ] then http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c39ec1eb/systemvm/patches/debian/config/opt/cloud/bin/vpc_guestnw.sh ---------------------------------------------------------------------- diff --git a/systemvm/patches/debian/config/opt/cloud/bin/vpc_guestnw.sh b/systemvm/patches/debian/config/opt/cloud/bin/vpc_guestnw.sh index e5da2e0..0115ab2 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/vpc_guestnw.sh +++ b/systemvm/patches/debian/config/opt/cloud/bin/vpc_guestnw.sh @@ -30,7 +30,7 @@ then fi usage() { - printf "Usage:\n %s -A -d <dev> -i <ip address> -g <gateway> -m <network mask> -s <dns ip> -e < domain> [-f] \n" $(basename $0) >&2 + printf "Usage:\n %s -A -M <mac> -d <dev> -i <ip address> -g <gateway> -m <network mask> -s <dns ip> -e < domain> [-f] \n" $(basename $0) >&2 printf " %s -D -d <dev> -i <ip address> \n" $(basename $0) >&2 } @@ -131,15 +131,33 @@ desetup_passwdsvcs() { create_guest_network() { # need to wait for eth device to appear before configuring it timer=0 - while ! `grep -q $dev /proc/net/dev` ; do - logger -t cloud "$(basename $0):Waiting for interface $dev to appear, $timer seconds" - sleep 1; - if [ $timer -gt 15 ]; then - logger -t cloud "$(basename $0):interface $dev never appeared" - break - fi - timer=$[timer + 1] - done + + # match dev based on mac, if passed + if [[ ! -z "$mac" ]]; then + logger -t cloud "$(basename $0): mac $mac passed, trying to match to device" + while [ ! $timer -gt 15 ]; do + for i in `ls /sys/class/net`; do + if grep -q $mac /sys/class/net/$i/address; then + dev=$i + logger -t cloud "$(basename $0): matched dev $i to mac $mac, dev is now $dev" + timer=15 + break + fi + done + sleep 1; + timer=$[timer + 1] + done + else + while ! `grep -q $dev /proc/net/dev` ; do + logger -t cloud "$(basename $0):Waiting for interface $dev to appear, $timer seconds" + sleep 1; + if [ $timer -gt 15 ]; then + logger -t cloud "$(basename $0):interface $dev never appeared" + break + fi + timer=$[timer + 1] + done + fi logger -t cloud " $(basename $0): Create network on interface $dev, gateway $gw, network $ip/$mask " # setup ip configuration @@ -225,11 +243,12 @@ dflag= gflag= Cflag= Dflag= +Mflag= op="" -while getopts 'CDn:m:d:i:g:s:e:' OPTION +while getopts 'CDn:m:M:d:i:g:s:e:' OPTION do case $OPTION in C) Cflag=1 @@ -244,6 +263,9 @@ do m) mflag=1 mask="$OPTARG" ;; + M) Mflag=1 + mac="$OPTARG" + ;; d) dflag=1 dev="$OPTARG" ;;