Changeset 10391 in genesis
- Timestamp:
- Apr 8, 2012, 10:52:22 AM (13 years ago)
- Location:
- tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/gformat.py
r10378 r10391 75 75 DOWN = 20 76 76 UNKNOWN = 90 77 78 def get_yaml(item): 79 """ Get configuration yaml for 'item'""" 80 gfile = os.path.join(NODE_DIR,item,'wleiden.yaml') 81 82 f = open(gfile, 'r') 83 datadump = yaml.load(f,Loader=Loader) 84 f.close() 85 86 # Preformat certain needed variables for formatting and push those into special object 87 datadump['autogen_iface_keys'] = get_interface_keys(datadump) 88 89 wlan_count=0 90 for key in datadump['autogen_iface_keys']: 91 if datadump[key]['type'] in ['11a', '11b', '11g', 'wireless']: 92 datadump[key]['autogen_ifname'] = 'wlan%i' % wlan_count 93 wlan_count += 1 94 else: 95 datadump[key]['autogen_ifname'] = datadump[key]['interface'].split(':')[0] 96 97 dhcp_interfaces = [datadump[key]['autogen_ifname'] for key in datadump['autogen_iface_keys'] if datadump[key]['dhcp'] != 'no'] 98 datadump['autogen_dhcp_interfaces'] = ' '.join(dhcp_interfaces) 99 datadump['autogen_item'] = item 100 101 datadump['autogen_realname'] = get_realname(datadump) 102 datadump['autogen_domain'] = datadump['domain'] if datadump.has_key('domain') else 'wleiden.net.' 103 datadump['autogen_fqdn'] = datadump['autogen_realname'] + '.' + datadump['autogen_domain'] 104 return datadump 105 106 107 def store_yaml(datadump, header=False): 108 """ Store configuration yaml for 'item'""" 109 item = datadump['autogen_item'] 110 gfile = os.path.join(NODE_DIR,item,'wleiden.yaml') 111 112 f = open(gfile, 'w') 113 f.write(generate_wleiden_yaml(datadump, header)) 114 f.close() 115 77 116 78 117 … … 302 341 dhcp-authoritative 303 342 dhcp-fqdn 304 domain=dhcp.{{ autogen_fqdn }} .{{ autogen_domain }}343 domain=dhcp.{{ autogen_fqdn }} 305 344 domain-needed 306 345 expand-hosts … … 353 392 output = generate_header("#"); 354 393 output += Template("""\ 355 hostname='{{ autogen_fqdn }} .{{ autogen_domain }}'394 hostname='{{ autogen_fqdn }}' 356 395 location='{{ location }}' 357 396 nodetype="{{ nodetype }}" … … 495 534 return output 496 535 497 498 499 def get_yaml(item):500 """ Get configuration yaml for 'item'"""501 gfile = os.path.join(NODE_DIR,item,'wleiden.yaml')502 503 f = open(gfile, 'r')504 datadump = yaml.load(f,Loader=Loader)505 f.close()506 507 # Preformat certain needed variables for formatting and push those into special object508 datadump['autogen_iface_keys'] = get_interface_keys(datadump)509 510 wlan_count=0511 for key in datadump['autogen_iface_keys']:512 if datadump[key]['type'] in ['11a', '11b', '11g', 'wireless']:513 datadump[key]['autogen_ifname'] = 'wlan%i' % wlan_count514 wlan_count += 1515 else:516 datadump[key]['autogen_ifname'] = datadump[key]['interface'].split(':')[0]517 518 dhcp_interfaces = [datadump[key]['autogen_ifname'] for key in datadump['autogen_iface_keys'] if datadump[key]['dhcp'] != 'no']519 datadump['autogen_dhcp_interfaces'] = ' '.join(dhcp_interfaces)520 datadump['autogen_item'] = item521 datadump['autogen_fqdn'] = get_fqdn(datadump)522 523 datadump['autogen_domain'] = datadump['domain'] if datadump.has_key('domain') else 'wleiden.net'524 return datadump525 526 527 def store_yaml(datadump, header=False):528 """ Store configuration yaml for 'item'"""529 item = datadump['autogen_item']530 gfile = os.path.join(NODE_DIR,item,'wleiden.yaml')531 532 f = open(gfile, 'w')533 f.write(generate_wleiden_yaml(datadump, header))534 f.close()535 536 536 537 … … 607 608 FreeBSD 9.0-RELEASE (kernel.wleiden) #0 r230587: Sun Jan 29 17:09:57 CET 2012 608 609 609 WWW: %(autogen_fqdn)s .wleiden.net- http://www.wirelessleiden.nl610 WWW: %(autogen_fqdn)s - http://www.wirelessleiden.nl 610 611 Loc: %(location)s 611 612 … … 756 757 print output 757 758 758 def get_ fqdn(datadump):759 def get_realname(datadump): 759 760 # Proxy naming convention is special, as the proxy name is also included in 760 761 # the nodename, when it comes to the numbered proxies. 761 762 if datadump['nodetype'] == 'Proxy': 762 fqdn= datadump['nodetype'] + datadump['nodename'].replace('proxy','')763 realname = datadump['nodetype'] + datadump['nodename'].replace('proxy','') 763 764 else: 764 765 # By default the full name is listed and also a shortname CNAME for easy use. 765 fqdn= datadump['nodetype'] + datadump['nodename']766 return( fqdn)766 realname = datadump['nodetype'] + datadump['nodename'] 767 return(realname) 767 768 768 769 … … 781 782 782 783 # Proxy naming convention is special 783 fqdn = get_fqdn(datadump)784 fqdn = datadump['autogen_realname'] 784 785 if datadump['nodetype'] == 'CNode': 785 786 wleiden_cname[datadump['nodename']] = fqdn … … 1073 1074 logger.info("# Processing: %s", host) 1074 1075 datadump = get_yaml(host) 1075 datadumps[ get_fqdn(datadump)] = datadump1076 datadumps[datadump['autogen_realname']] = datadump 1076 1077 1077 1078 for host,datadump in datadumps.iteritems(): -
tools/yaml2nag.py
r10388 r10391 36 36 37 37 if datadump['ileiden']: 38 hostgroups.append('node -ileiden')38 hostgroups.append('nodes-ileiden') 39 39 40 40 datadump['hostgroups'] = ','.join(hostgroups) … … 42 42 define host{ 43 43 use host-pnp 44 host_name %( nodename)s45 alias %( nodename)s44 host_name %(autogen_realname)s 45 alias %(autogen_realname)s 46 46 address %(masterip)s 47 47 hostgroups %(hostgroups)s
Note:
See TracChangeset
for help on using the changeset viewer.