CLOUDSTACK-9187 - Fixes interface allocation to VRRP instances
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/c99d6f18 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c99d6f18 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c99d6f18 Branch: refs/heads/master Commit: c99d6f18c9fccdc44698a30af1b20701a2e85df4 Parents: b1e4210 Author: Wilder Rodrigues <[email protected]> Authored: Fri Dec 18 18:36:02 2015 +0100 Committer: Wilder Rodrigues <[email protected]> Committed: Tue Dec 22 14:52:06 2015 +0100 ---------------------------------------------------------------------- .../debian/config/opt/cloud/bin/cs/CsAddress.py | 14 ++++++++------ .../debian/config/opt/cloud/bin/cs/CsRedundant.py | 11 +++++++---- 2 files changed, 15 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c99d6f18/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py ---------------------------------------------------------------------- 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 d320d0a..3eb9447 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): """ http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c99d6f18/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py ---------------------------------------------------------------------- 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 f975871..84771ce 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
