diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py index d320d0a1f1f..3eb944705ad 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py @@ -48,15 +48,17 @@ class CsAddress(CsDataBag): def get_guest_if(self): """ - Return CsInterface object for the lowest guest interface + Return CsInterface object for the lowest in use guest interface """ - ipr = [] + guest_interface = None + lowest_device = 99 for ip in self.get_ips(): if ip.is_guest() and ip.is_added(): - ipr.append(ip) - if len(ipr) > 0: - return sorted(ipr)[-1] - return None + devive_sufix = int(ip.get_device()[-1:]) + if devive_sufix < lowest_device: + lowest_device = devive_sufix + guest_interface = ip + return guest_interface def get_guest_ip(self): """ diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py index f975871e0df..84771ce7ee1 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py @@ -81,6 +81,7 @@ class CsRedundant(object): def _redundant_on(self): guest = self.address.get_guest_if() + # No redundancy if there is no guest network if guest is None: self._redundant_off() @@ -344,13 +345,15 @@ class CsRedundant(object): that could function as a router and VPC router at the same time """ lines = [] - for o in self.address.get_ips(): - if o.needs_vrrp(): + for ip in self.address.get_ips(): + if ip.needs_vrrp(): cmdline=self.config.get_cmdline_instance() + if not ip.is_added(): + continue if(cmdline.get_type()=='router'): - str = " %s brd %s dev %s\n" % (cmdline.get_guest_gw(), o.get_broadcast(), o.get_device()) + str = " %s brd %s dev %s\n" % (cmdline.get_guest_gw(), ip.get_broadcast(), ip.get_device()) else: - str = " %s brd %s dev %s\n" % (o.get_gateway_cidr(), o.get_broadcast(), o.get_device()) + str = " %s brd %s dev %s\n" % (ip.get_gateway_cidr(), ip.get_broadcast(), ip.get_device()) lines.append(str) return lines