You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by wi...@apache.org on 2015/09/11 14:57:32 UTC
[3/3] git commit: updated refs/heads/master to b66dcda
CLOUDSTACK-8799 fixed the defalut routes
CLOUDSTACK-8799 made changes to fix CsRedundant.py
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/1a02773b
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/1a02773b
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/1a02773b
Branch: refs/heads/master
Commit: 1a02773b556a0efa277cf18cd099fc62a4e27706
Parents: a04b8f6
Author: Bharat Kumar <bh...@citrix.com>
Authored: Fri Sep 4 12:44:46 2015 +0530
Committer: Wido den Hollander <wi...@widodh.nl>
Committed: Fri Sep 11 14:57:32 2015 +0200
----------------------------------------------------------------------
.../debian/config/opt/cloud/bin/cs/CsAddress.py | 32 ++++++++++++++------
.../debian/config/opt/cloud/bin/cs/CsDatabag.py | 4 +++
.../config/opt/cloud/bin/cs/CsRedundant.py | 17 ++---------
3 files changed, 29 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1a02773b/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 767e748..a855f83 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py
@@ -95,9 +95,17 @@ class CsAddress(CsDataBag):
return ip
return None
+ def check_if_link_up(self,dev):
+ cmd="ip link show dev %s | tr '\n' ' ' | cut -d ' ' -f 9"%dev
+ result=CsHelper.execute(cmd)
+ if(result[0].lower()=="up"):
+ return True
+ else:
+ return False
+
+
def process(self):
route = CsRoute()
- found_defaultroute = False
for dev in self.dbag:
if dev == "id":
@@ -105,8 +113,14 @@ class CsAddress(CsDataBag):
ip = CsIP(dev, self.config)
for address in self.dbag[dev]:
+ if(address["nw_type"]!="public"):
+ continue
+
+ #check if link is up
+ if not self.check_if_link_up(dev):
+ cmd="ip link set %s up"%dev
+ CsHelper.execute(cmd)
- gateway = str(address["gateway"])
network = str(address["network"])
ip.setAddress(address)
@@ -122,16 +136,14 @@ class CsAddress(CsDataBag):
"Address %s on device %s not configured", ip.ip(), dev)
if CsDevice(dev, self.config).waitfordevice():
ip.configure()
+ route.add_route(dev, network)
- if address["nw_type"] != "control":
- route.add_route(dev, network)
+ # once we start processing public ip's we need to verify there
+ # is a default route and add if needed
+ if not route.defaultroute_exists():
+ cmdline=self.config.get_cmdline_instance()
+ route.add_defaultroute(cmdline.get_gateway())
- # once we start processing public ip's we need to verify there
- # is a default route and add if needed
- if address["nw_type"] == "public" and not found_defaultroute:
- if not route.defaultroute_exists():
- if route.add_defaultroute(gateway):
- found_defaultroute = True
class CsInterface:
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1a02773b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsDatabag.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsDatabag.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsDatabag.py
index 2a37b0a..f04961b 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsDatabag.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsDatabag.py
@@ -134,3 +134,7 @@ class CsCmdLine(CsDataBag):
md5 = hashlib.md5()
md5.update(passwd)
return md5.hexdigest()
+ def get_gateway(self):
+ if "gateway" in self.idata():
+ return self.idata()['gateway']
+ return False
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1a02773b/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 da9b887..3f1cbe0 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
@@ -261,20 +261,9 @@ class CsRedundant(object):
self.set_lock()
logging.debug("Setting router to master")
- ads = [o for o in self.address.get_ips() if o.is_public()]
- dev = ''
- for o in ads:
- if dev == o.get_device():
- continue
- cmd2 = "ip link set %s up" % o.get_device()
- if CsDevice(o.get_device(), self.config).waitfordevice():
- CsHelper.execute(cmd2)
- dev = o.get_device()
- logging.info("Bringing public interface %s up" %
- o.get_device())
- else:
- logging.error(
- "Device %s was not ready could not bring it up" % o.get_device())
+ self.address.process()
+ logging.info("added default rotue")
+
# ip route add default via $gw table Table_$dev proto static
cmd = "%s -C %s" % (self.CONNTRACKD_BIN, self.CONNTRACKD_CONF)
CsHelper.execute("%s -c" % cmd)