PaulAngus closed pull request #3018: Prevent error on GroupAnswers on VR 
creation
URL: https://github.com/apache/cloudstack/pull/3018
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/systemvm/debian/opt/cloud/bin/cs/CsAddress.py 
b/systemvm/debian/opt/cloud/bin/cs/CsAddress.py
index 10b6d3cfdbe..ab0cee60039 100755
--- a/systemvm/debian/opt/cloud/bin/cs/CsAddress.py
+++ b/systemvm/debian/opt/cloud/bin/cs/CsAddress.py
@@ -524,15 +524,16 @@ def post_config_change(self, method):
                     CsHelper.execute("sudo ip route add throw " + 
self.config.address().dbag['eth1'][0]['network'] + " table " + tableName + " 
proto static")
 
                 # add 'defaul via gateway' rule in the device specific routing 
table
-                if "gateway" in self.address and self.address["gateway"] != 
"None":
+                if "gateway" in self.address and self.address["gateway"] and 
self.address["gateway"] != "None":
                     route.add_route(self.dev, self.address["gateway"])
-                route.add_network_route(self.dev, str(self.address["network"]))
+                if "network" in self.address and self.address["network"]:
+                    route.add_network_route(self.dev, 
str(self.address["network"]))
 
                 if self.get_type() in ["public"]:
                     CsRule(self.dev).addRule("from " + 
str(self.address["network"]))
 
             if self.config.is_vpc():
-                if self.get_type() in ["public"] and "gateway" in self.address 
and self.address["gateway"] != "None":
+                if self.get_type() in ["public"] and "gateway" in self.address 
and self.address["gateway"] and self.address["gateway"] != "None":
                     route.add_route(self.dev, self.address["gateway"])
                     for inf, addresses in 
self.config.address().dbag.iteritems():
                         if not inf.startswith("eth"):
diff --git a/systemvm/debian/opt/cloud/bin/cs/CsRoute.py 
b/systemvm/debian/opt/cloud/bin/cs/CsRoute.py
index 47d3d2a91af..ce87bb0533c 100755
--- a/systemvm/debian/opt/cloud/bin/cs/CsRoute.py
+++ b/systemvm/debian/opt/cloud/bin/cs/CsRoute.py
@@ -50,20 +50,29 @@ def add_route(self, dev, address):
         """ Wrapper method that adds table name and device to route statement 
"""
         # ip route add dev eth1 table Table_eth1 10.0.2.0/24
         table = self.get_tablename(dev)
-        logging.info("Adding route: dev " + dev + " table: " +
-                     table + " network: " + address + " if not present")
-        cmd = "dev %s table %s %s" % (dev, table, address)
-        cmd = "default via %s table %s proto static" % (address, table)
-        self.set_route(cmd)
+
+        if not table or not address:
+            empty_param = "table" if not table else "address"
+            logging.info("Empty parameter received %s while trying to add 
route, skipping" % empty_param)
+        else:
+            logging.info("Adding route: dev " + dev + " table: " +
+                         table + " network: " + address + " if not present")
+            cmd = "default via %s table %s proto static" % (address, table)
+            self.set_route(cmd)
 
     def add_network_route(self, dev, address):
         """ Wrapper method that adds table name and device to route statement 
"""
         # ip route add dev eth1 table Table_eth1 10.0.2.0/24
         table = self.get_tablename(dev)
-        logging.info("Adding route: dev " + dev + " table: " +
-                     table + " network: " + address + " if not present")
-        cmd = "throw %s table %s proto static" % (address, table)
-        self.set_route(cmd)
+
+        if not table or not address:
+            empty_param = "table" if not table else "address"
+            logging.info("Empty parameter received %s while trying to add 
network route, skipping" % empty_param)
+        else:
+            logging.info("Adding route: dev " + dev + " table: " +
+                         table + " network: " + address + " if not present")
+            cmd = "throw %s table %s proto static" % (address, table)
+            self.set_route(cmd)
 
     def set_route(self, cmd, method="add"):
         """ Add a route if it is not already defined """


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to