from NaServer import * import syslog, logging, xmltodict, json, ConfigParser, os, json from datetime import timedelta # Set to DEBUG if stuff is broken logging.basicConfig(level=logging.WARN) config = ConfigParser.RawConfigParser() cfg_file = 'cred.properties' if(os.path.exists(cfg_file)): config.read(cfg_file) else: syslog.syslog("ERROR - cred.properties not found") raise SystemExit user = '' pw = '' cluster = '' s = NaServer(cluster, 1, 20) s.set_server_type("FILER") s.set_transport_type("HTTP") s.set_style("LOGIN") s.set_admin_user(user, pw) volume_list = NaElement('volume-get-iter') volume_list.child_add_string('max-records', '10000') filename_space_eff = str(cluster + '_volume_iter') out = s.invoke_elem(volume_list) if (out.results_status() == "failed"): raise SystemExit if out.child_get_int("num-records") == "0": raise SystemExit xml_parser = out.sprintf() volume_data_dump = xmltodict.parse(xml_parser) with open('%s.json' % filename_space_eff, 'w') as outfile: json.dump(volume_data_dump, outfile)