- ips_bnode_file = open('arg-ips-bnode', 'w')
- for plc_spec in all_plc_specs:
- for site_spec in plc_spec['sites']:
- for node_spec in site_spec['nodes']:
- ips_bnode_file.write("{}\n".format(node_spec['host_box']))
- ips_bnode_file.close()
- ips_vnode_file = open('arg-ips-vnode','w')
- for plc_spec in all_plc_specs:
- for site_spec in plc_spec['sites']:
- for node_spec in site_spec['nodes']:
- # back to normal (unqualified) form
- stripped = node_spec['node_fields']['hostname'].split('.')[0]
- ips_vnode_file.write("{}\n".format(stripped))
- ips_vnode_file.close()
+ with open('arg-ips-bnode', 'w') as ips_bnode_file:
+ for plc_spec in all_plc_specs:
+ for site_spec in plc_spec['sites']:
+ for node_spec in site_spec['nodes']:
+ ips_bnode_file.write("{}\n".format(node_spec['host_box']))
+ with open('arg-ips-vnode','w') as ips_vnode_file:
+ for plc_spec in all_plc_specs:
+ for site_spec in plc_spec['sites']:
+ for node_spec in site_spec['nodes']:
+ # back to normal (unqualified) form
+ stripped = node_spec['node_fields']['hostname'].split('.')[0]
+ ips_vnode_file.write("{}\n".format(stripped))