Created
June 14, 2017 14:02
-
-
Save dav1x/52e2223b2fb3d21a04cc74f37658a29e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = {} | |
data = '{ "clusters": [ { "nodes": [ ' | |
for i in range(0, int(self.node_number)): | |
#determine node_number increment on the number of nodes | |
if self.node_type == 'app': | |
node_ip = int(self.app_nodes) + i | |
guest_name = self.node_type + '-' + str(node_ip) | |
if self.node_type == 'infra': | |
node_ip = int(self.infra_nodes) + i | |
guest_name = self.node_type + '-' + str(node_ip) | |
if self.node_type == 'storage' and self.container_storage == 'crs': | |
node_ip = int(self.app_nodes) + i | |
guest_name = 'crs-' + str(node_ip) | |
if self.node_type == 'storage' and self.container_storage == 'cns': | |
node_ip = int(self.app_nodes) + i | |
guest_name = 'app-storage-' + str(node_ip) | |
if self.ocp_hostname_prefix: | |
guest_name = self.ocp_hostname_prefix + guest_name | |
d['host_inventory'][guest_name] = {} | |
d['host_inventory'][guest_name]['guestname'] = guest_name | |
d['host_inventory'][guest_name]['ip4addr'] = unusedip4addr[0] | |
d['host_inventory'][guest_name]['tag'] = self.node_type | |
data = data + '{ "node" : { "hostnames": {"manage": [ "%s" ],"storage": [ "%s" ]},"zone": %s },"devices": [ "/dev/sdd" ]}' % ( unusedip4addr[0], unusedip4addr[0], i ) | |
del unusedip4addr[0] | |
if unusedip4addr: | |
data = data + "," | |
data = data + "]}]}" | |
with open(self.inventory_file, 'w') as outfile: | |
json.dump(d, outfile) | |
if 'storage' in node_type: | |
# create the topology file | |
with open('topology.json', 'w') as topfile: | |
json.dump(ndata, topfile) | |
for line in fileinput.input('topology.json', inplace=True): | |
if line.endswith('"'): | |
line = line[:-1] | |
if line.startswith('"'): | |
line = line[1:] | |
line = line.replace("\\", "") | |
print line | |
print "Gluster topology file created topology.json" | |
print 'Inventory file created: %s' % self.inventory_file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment