cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sw...@apache.org
Subject [2/3] git commit: updated refs/heads/4.7 to 3fab757
Date Thu, 12 May 2016 15:03:26 GMT
Handle private gateways more reliably


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

Branch: refs/heads/4.7
Commit: f4f9b3ab4ef2ef34e4d8a04c6ebfbf0784497227
Parents: 65cb222
Author: Remi Bergsma <github@remi.nl>
Authored: Thu Feb 25 14:07:21 2016 +0100
Committer: Remi Bergsma <github@remi.nl>
Committed: Sun Apr 10 20:06:44 2016 +0200

----------------------------------------------------------------------
 .../debian/config/opt/cloud/bin/cs/CsHelper.py  |  2 +-
 .../debian/config/opt/cloud/bin/merge.py        | 46 ++++++++++++++++++++
 2 files changed, 47 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f4f9b3ab/systemvm/patches/debian/config/opt/cloud/bin/cs/CsHelper.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsHelper.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsHelper.py
index 9095558..835c189 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsHelper.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsHelper.py
@@ -224,4 +224,4 @@ def copy(src, dest):
     except IOError:
         logging.Error("Could not copy %s to %s" % (src, dest))
     else:
-        logging.info("Copied %s to %s" % (src, dest))
\ No newline at end of file
+        logging.info("Copied %s to %s" % (src, dest))

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f4f9b3ab/systemvm/patches/debian/config/opt/cloud/bin/merge.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/merge.py b/systemvm/patches/debian/config/opt/cloud/bin/merge.py
index 374cf2c..aa67682 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/merge.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/merge.py
@@ -145,10 +145,13 @@ class updateDataBag:
         dp['gateway'] = d['router_guest_gateway']
         dp['nic_dev_id'] = d['device'][3]
         dp['nw_type'] = 'guest'
+        dp = PrivateGatewayHack.update_network_type_for_privategateway(dbag, dp)
         qf = QueueFile()
         qf.load({'ip_address': [dp], 'type': 'ips'})
         if 'domain_name' not in d.keys() or d['domain_name'] == '':
             d['domain_name'] = "cloudnine.internal"
+
+        d = PrivateGatewayHack.update_network_type_for_privategateway(dbag, d)
         return cs_guestnetwork.merge(dbag, d)
 
     def process_dhcp_entry(self, dbag):
@@ -274,3 +277,46 @@ class QueueFile:
             os.makedirs(path)
         timestamp = str(int(round(time.time())))
         os.rename(origPath, path + "/" + self.fileName + "." + timestamp)
+
+
+class PrivateGatewayHack:
+
+
+    @classmethod
+    def update_network_type_for_privategateway(cls, dbag, data):
+        ip = data['router_guest_ip'] if 'router_guest_ip' in data.keys() else data['public_ip']
+
+        initial_data = cls.load_inital_data()
+        has_private_gw_ip = cls.if_config_has_privategateway(initial_data)
+        private_gw_matches = 'privategateway' in initial_data['config'] and cls.ip_matches_private_gateway_ip(ip,
initial_data['config']['privategateway'])
+
+        if has_private_gw_ip and private_gw_matches:
+            data['nw_type'] = "public"
+            logging.debug("Updating nw_type for ip %s" % ip)
+        else:
+            logging.debug("Not updating nw_type for ip %s because has_private_gw_ip = %s
and private_gw_matches = %s " % (ip, has_private_gw_ip, private_gw_matches))
+        return data
+
+
+    @classmethod
+    def if_config_has_privategateway(cls, dbag):
+        return 'privategateway' in dbag['config'].keys() and dbag['config']['privategateway']
!= "None"
+
+
+    @classmethod
+    def ip_matches_private_gateway_ip(cls, ip, private_gateway_ip):
+        new_ip_matches_private_gateway_ip = False
+        if ip == private_gateway_ip:
+            new_ip_matches_private_gateway_ip = True
+        return new_ip_matches_private_gateway_ip
+
+
+    @classmethod
+    def load_inital_data(cls):
+        initial_data_bag = DataBag()
+        initial_data_bag.setKey('cmdline')
+        initial_data_bag.load()
+        initial_data = initial_data_bag.getDataBag()
+        logging.debug("Initial data = %s" % initial_data)
+
+        return initial_data


Mime
View raw message