Create multiple public_addresses files autocluster-0.10
authorAmitay Isaacs <amitay@gmail.com>
Thu, 20 Nov 2014 03:24:24 +0000 (14:24 +1100)
committerAmitay Isaacs <amitay@gmail.com>
Tue, 25 Nov 2014 02:56:27 +0000 (13:56 +1100)
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
base/all/root/scripts/cluster_configure/plugins/ctdb.py
base/all/root/scripts/cluster_configure/templates/rhel/00.ctdb/1.2.4#/files/etc/ctdb/public_addresses
base/all/root/scripts/cluster_configure/templates/rhel/00.ctdb/1.2.4#/files/etc/ctdb/public_addresses.dual [new file with mode: 0644]
base/all/root/scripts/cluster_configure/templates/rhel/00.ctdb/1.2.4#/files/etc/ctdb/public_addresses.ipv4 [new file with mode: 0644]
base/all/root/scripts/cluster_configure/templates/rhel/00.ctdb/1.2.4#/files/etc/ctdb/public_addresses.ipv6 [new file with mode: 0644]
base/all/root/scripts/nas.conf

index e84e6dcff3cfb342726812cb22f877731abed879..d326b1904e7b58c846c68ffe47af110aa731dd7d 100644 (file)
@@ -21,16 +21,31 @@ import logging
 
 import package
 
-def gen_public_addresses(config, pkg, dummy):
+def gen_public_addresses(config, pkg, req_ips):
     """Given a config object, return the formatted public addresses."""
 
+    stack = package.get(config, pkg, "network_stack")
     out = []
+    out6 = []
     foo = package.get(config, pkg, "public_addresses")
     for tmp in foo.split():
         (startip, num_addrs, iface) = tmp.split(',')
         (a,b,c,d) = startip.split('.')
         for i in xrange(int(num_addrs)):
             octet = int(d) + i
-            out.append('%s.%s.%s.%d/24 %s\n' % (a, b, c, octet, iface))
-
-    return "".join(out)
+            if stack == 'ipv4' and req_ips == 'default':
+                out.append('%s.%s.%s.%d/24 %s\n' % (a, b, c, octet, iface))
+            elif stack == 'ipv6' and req_ips == 'default':
+                out6.append('fc00:%s:%s:%s::%s/64 %s\n' % (a, b, c, octet, iface))
+            elif stack == 'dual':
+                if req_ips in ['ipv4', 'dual', 'default']:
+                    out.append('%s.%s.%s.%d/24 %s\n' % (a, b, c, octet, iface))
+                if req_ips in ['ipv6', 'dual', 'default']:
+                    out6.append('fc00:%s:%s:%s::%s/64 %s\n' % (a, b, c, octet, iface))
+
+    # Special case: if the file would be empty then it should be there...
+    ret = "".join(out) + "".join(out6)
+    if ret:
+        return ret
+    else:
+        return None
diff --git a/base/all/root/scripts/cluster_configure/templates/rhel/00.ctdb/1.2.4#/files/etc/ctdb/public_addresses.dual b/base/all/root/scripts/cluster_configure/templates/rhel/00.ctdb/1.2.4#/files/etc/ctdb/public_addresses.dual
new file mode 100644 (file)
index 0000000..9aecdac
--- /dev/null
@@ -0,0 +1 @@
+!!%ctdb:gen_public_addresses('dual')!!
diff --git a/base/all/root/scripts/cluster_configure/templates/rhel/00.ctdb/1.2.4#/files/etc/ctdb/public_addresses.ipv4 b/base/all/root/scripts/cluster_configure/templates/rhel/00.ctdb/1.2.4#/files/etc/ctdb/public_addresses.ipv4
new file mode 100644 (file)
index 0000000..3ab0921
--- /dev/null
@@ -0,0 +1 @@
+!!%ctdb:gen_public_addresses('ipv4')!!
diff --git a/base/all/root/scripts/cluster_configure/templates/rhel/00.ctdb/1.2.4#/files/etc/ctdb/public_addresses.ipv6 b/base/all/root/scripts/cluster_configure/templates/rhel/00.ctdb/1.2.4#/files/etc/ctdb/public_addresses.ipv6
new file mode 100644 (file)
index 0000000..4a67496
--- /dev/null
@@ -0,0 +1 @@
+!!%ctdb:gen_public_addresses('ipv6')!!
index 812e74c66cf67c73ae597aefe92f1d1bea6382dc..d3bef51e194608f9fa59d8bb3678fe1af700f80f 100644 (file)
@@ -7,6 +7,7 @@ chroot_parent = /var/lib/nas-chroot
 scp_chroot = %(chroot_parent)s/scp
 clusterfs_default_mountpoint = @@CLUSTERFS_DEFAULT_MOUNTPOINT@@
 auth_method = @@AUTH_METHOD@@
+network_stack = @@NETWORK_STACK@@
 
 [filesystem:0]
 type = @@CLUSTERFS_TYPE@@