summaryrefslogtreecommitdiffstats
path: root/lib/python/apex
diff options
context:
space:
mode:
authorFeng Pan <fpan@redhat.com>2016-05-07 16:04:00 -0400
committerFeng Pan <fpan@redhat.com>2016-05-08 19:55:46 -0400
commit683f9010b19232897648913e767a0dc05dbf498e (patch)
tree1e144355699651ce404f675e82a9de3147c48a05 /lib/python/apex
parent5c45d868e4cf4eaf54ae52eae6aadcd982898024 (diff)
Change NIC template format
Convert compute and controller NIC templates to jinja2 format. Added support for IPv6 for those NIC templates. Existing IPv4 template generation behavior does not change. The .template files are kept in tree for now, they will be removed after VLAN changes are made. Change-Id: I2ffc7c403af3659db780ece2bd9195cd62748f0c Signed-off-by: Feng Pan <fpan@redhat.com>
Diffstat (limited to 'lib/python/apex')
-rw-r--r--lib/python/apex/net_env.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/python/apex/net_env.py b/lib/python/apex/net_env.py
index ec46fe28..3ca28f8a 100644
--- a/lib/python/apex/net_env.py
+++ b/lib/python/apex/net_env.py
@@ -227,12 +227,26 @@ class NetworkSettings:
bash_str += "{}_{}={}\n".format(network, key, value)
bash_str += "enabled_network_list='{}'\n" \
.format(' '.join(self.enabled_network_list))
+ bash_str += "ip_addr_family={}\n".format(self.get_ip_addr_family())
if path:
with open(path, 'w') as file:
file.write(bash_str)
else:
print(bash_str)
+ def get_ip_addr_family(self):
+ """
+ Returns IP address family for current deployment.
+
+ If any enabled network has IPv6 CIDR, the deployment is classified as
+ IPv6.
+ """
+ for network in self.enabled_network_list:
+ cidr = ipaddress.ip_network(self.settings_obj[network]['cidr'])
+ if cidr.version == 6:
+ return 6
+
+ return 4
class NetworkSettingsException(Exception):
def __init__(self, value):