cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [04/12] git commit: updated refs/heads/master to ca9e934
Date Thu, 08 Oct 2015 23:49:27 GMT
CLOUDSTACK-8915 - Rearrenging a bit the default route code in order to make it more clear


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/0c752eab
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/0c752eab
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/0c752eab

Branch: refs/heads/master
Commit: 0c752eab60ed2b56708e7e48bcdf73c63e76f986
Parents: c17fb0f
Author: Wilder Rodrigues <wrodrigues@schubergphilis.com>
Authored: Tue Sep 29 14:35:48 2015 +0200
Committer: Wilder Rodrigues <wrodrigues@schubergphilis.com>
Committed: Tue Oct 6 16:41:13 2015 +0200

----------------------------------------------------------------------
 .../debian/config/opt/cloud/bin/configure.py    |  2 +-
 .../debian/config/opt/cloud/bin/cs/CsAddress.py | 73 +++++++++++---------
 .../debian/config/opt/cloud/bin/cs/CsRoute.py   |  9 ++-
 3 files changed, 46 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0c752eab/systemvm/patches/debian/config/opt/cloud/bin/configure.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/configure.py b/systemvm/patches/debian/config/opt/cloud/bin/configure.py
index 29e19c4..ae24ac5 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/configure.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/configure.py
@@ -663,7 +663,7 @@ class CsForwardingRules(CsDataBag):
                 elif rule["type"] == "staticnat":
                     self.processStaticNatRule(rule)
 
-    #return the VR guest interface ipo
+    #return the VR guest interface ip
     def getGuestIp(self):
         ipr = []
         ipAddr = None

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0c752eab/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 3e8fbca..a473277 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py
@@ -112,9 +112,6 @@ class CsAddress(CsDataBag):
             return False
 
     def process(self):
-        route = CsRoute()
-        found_defaultroute = False
-
         for dev in self.dbag:
             if dev == "id":
                 continue
@@ -123,42 +120,21 @@ class CsAddress(CsDataBag):
             for address in self.dbag[dev]:
                 #check if link is up
                 if not self.check_if_link_up(dev):
-                   cmd="ip link set %s up"%dev
+                   cmd="ip link set %s up" % dev
                    CsHelper.execute(cmd)
 
-                gateway = str(address["gateway"])
-                network = str(address["network"])
-
                 ip.setAddress(address)
 
                 if ip.configured():
                     logging.info(
                         "Address %s on device %s already configured", ip.ip(), dev)
 
-                    ip.post_configure()
-
+                    ip.post_configure(address)
                 else:
                     logging.info(
                         "Address %s on device %s not configured", ip.ip(), dev)
                     if CsDevice(dev, self.config).waitfordevice():
-                        ip.configure()
-                        
-                        route.add_route(dev, network)
-
-                        # The code looks redundant here, but we actually have to cater for
routers and
-                        # VPC routers in a different manner. Please do not remove this block
otherwise
-                        # The VPC default route will be broken.
-                        if address["nw_type"] == "public" and not found_defaultroute:
-                            if not route.defaultroute_exists():
-                                if route.add_defaultroute(gateway):
-                                    found_defaultroute = True
-
-        # 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.cmdline()
-            if(cmdline.get_gateway()):
-                route.add_defaultroute(cmdline.get_gateway())
+                        ip.configure(address)
 
 
 class CsInterface:
@@ -307,28 +283,43 @@ class CsIP:
     def getAddress(self):
         return self.address
 
-    def configure(self):
+    def configure(self, address):
         logging.info(
             "Configuring address %s on device %s", self.ip(), self.dev)
         cmd = "ip addr add dev %s %s brd +" % (self.dev, self.ip())
         subprocess.call(cmd, shell=True)
-        self.post_configure()
+        self.post_configure(address)
 
-    def post_configure(self):
+    def post_configure(self, address):
         """ The steps that must be done after a device is configured """
         if not self.get_type() in ["control"]:
             route = CsRoute()
             route.add_table(self.dev)
+            
             CsRule(self.dev).addMark()
             self.check_is_up()
             self.set_mark()
             self.arpPing()
+            
             CsRpsrfs(self.dev).enable()
             self.post_config_change("add")
 
         '''For isolated/redundant and dhcpsrvr routers, call this method after the post_config
is complete '''
         if not self.config.is_vpc():
             self.setup_router_control()
+        
+        if self.config.is_vpc():
+            # The code looks redundant here, but we actually have to cater for routers and
+            # VPC routers in a different manner. Please do not remove this block otherwise
+            # The VPC default route will be broken.
+            if self.get_type() in ["public"]:
+                gateway = str(address["gateway"])
+                route.add_defaultroute(gateway)
+        else:
+            # once we start processing public ip's we need to verify there
+            # is a default route and add if needed
+            if(self.cl.get_gateway()):
+                route.add_defaultroute(self.cl.get_gateway())
 
     def check_is_up(self):
         """ Ensure device is up """
@@ -543,19 +534,20 @@ class CsIP:
             CsDevice(self.dev, self.config).configure_rp()
 
             logging.error(
-                "Not able to setup sourcenat for a regular router yet")
+                "Not able to setup source-nat for a regular router yet")
             dns = CsDnsmasq(self)
             dns.add_firewall_rules()
             app = CsApache(self)
             app.setup()
 
+        cmdline = self.config.cmdline()
         # If redundant then this is dealt with by the master backup functions
-        if self.get_type() in ["guest"] and not self.config.cl.is_redundant():
+        if self.get_type() in ["guest"] and not cmdline.is_redundant():
             pwdsvc = CsPasswdSvc(self.address['public_ip']).start()
 
         if self.get_type() == "public" and self.config.is_vpc():
             if self.address["source_nat"]:
-                vpccidr = self.config.cmdline().get_vpccidr()
+                vpccidr = cmdline.get_vpccidr()
                 self.fw.append(
                     ["filter", "", "-A FORWARD -s %s ! -d %s -j ACCEPT" % (vpccidr, vpccidr)])
                 self.fw.append(
@@ -567,7 +559,15 @@ class CsIP:
         for i in CsHelper.execute(cmd):
             vals = i.lstrip().split()
             if (vals[0] == 'inet'):
-                self.iplist[vals[1]] = self.dev
+                
+                cidr = vals[1]
+                for ip, device in self.iplist.iteritems():
+                    logging.info(
+                                 "Iterating over the existing IPs. CIDR to be configured
==> %s, existing IP ==> %s on device ==> %s",
+                                 cidr, ip, device)
+
+                    if cidr[0] != ip[0] and device != self.dev:
+                        self.iplist[cidr] = self.dev
 
     def configured(self):
         if self.address['cidr'] in self.iplist.keys():
@@ -635,8 +635,13 @@ class CsIP:
         interface = CsInterface(bag, self.config)
         if not self.config.cl.is_redundant():
             return False
+
         rip = ip.split('/')[0]
+        logging.info("Checking if cidr is a gateway for rVPC. IP ==> %s / device ==>
%s", ip, self.dev)
+
         gw = interface.get_gateway()
+        logging.info("Interface has the following gateway ==> %s", gw)
+        
         if bag['nw_type'] == "guest" and rip == gw:
             return True
         return False

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0c752eab/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRoute.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRoute.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRoute.py
index fd2d989..1178fb0 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRoute.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRoute.py
@@ -71,13 +71,16 @@ class CsRoute:
         :param str gateway
         :return: bool
         """
-        if gateway is not None:
+        if not gateway:
+            raise Exception("Gateway cannot be None.")
+        
+        if self.defaultroute_exists():
+            return False
+        else:
             cmd = "default via " + gateway
             logging.info("Adding default route")
             self.set_route(cmd)
             return True
-        else:
-            return False
 
     def defaultroute_exists(self):
         """ Return True if a default route is present


Mime
View raw message