def main(): if not os.path.exists(CONFIGSDIR): os.makedirs(CONFIGSDIR) connections = load_data(fabrics_connections_path, []) fields = ['name', 'address', 'username', 'password'] connections = [[c[k] for k in fields] for c in connections] out = {} for args in connections: args.append([['zoneshow', 'zoneshow'],]) systemname, outs, errs, exception = ssh_run(args) if not exception: lines = outs['zoneshow'].split('\n') aliases = parse_aliases(lines) zones = parse_zones(lines) config = parse_config(lines) out[systemname] = { 'aliases': aliases, 'zones': zones, 'config': config, } if os.path.isfile(oldconfigpath): from_dt = datetime.fromtimestamp(os.path.getmtime(oldconfigpath)) else: from_dt = None if os.path.isfile(newconfigpath): os.rename(newconfigpath, oldconfigpath) till_dt = datetime.now() dump_data(newconfigpath, out) dump_data(os.path.join(JSONDIR, 'changes_dts'), {'From': str(from_dt) if from_dt else None, 'Till': str(till_dt)}) logging.info('%s | %s records' %(newconfigpath, len(out))) return
def main(): for connection in CONNECTIONS: if connection['model'] == '3PAR': args = [connection[key] for key in ['name', 'address', 'username', 'password']] args.append([]) systemname, outs, errs, exception = ssh_run(args) if exception: logging.warning('%s test failed - %s' %(systemname, exception)) else: logging.info('%s test success' %systemname) return
def run(): logger = get_logger(logfile, 'sanscript.fc') connections = [] dirpath = os.path.dirname(os.path.realpath(__file__)) for filename in ['FabricConnection.json', 'SwitchConnection.json']: filepath = os.path.join(dirpath, filename) connections += load_data(filepath, []) for connection in connections: args = [connection[key] for key in ['name', 'address', 'username', 'password']] args.append([]) system, outs, errs, exception = ssh_run(args) if exception: logger.warning('%s test failed - %s' %(system, exception)) else: logger.info('%s test success' %system)
def main(): for connection in CONNECTIONS: if connection['model'] == '3PAR': args = [connection[key] for key in ['name', 'address', 'username', 'password']] args = args + [COMMANDS] systemname, outs, errs, exception = ssh_run(args) if exception: logging.warning('%s - %s' %(systemname, exception)) for commandname, out in outs.items(): filename = '%s.%s' %(systemname, commandname) filepath = os.path.join(TEXTDIR, filename) with open(filepath, 'w') as f: f.write(out) logging.info('%s | %s lines' %( filename, len(out.strip().split('\n')))) return