def psuedo_main(): """Basically the main(). Did it this way so it can easily be used as a standalone module or called from another. :return: Exit code. See exist codes in brcddb.brcddb_common :rtype: int """ # Get user input ip, user_id, pw, sec, log, nl = parse_args() if sec is None: sec = 'none' ml = ['WARNING!!! Debug is enabled'] if _DEBUG else list() ml.append('IP: ' + brcdapi_util.mask_ip_addr(ip, True)) ml.append('ID: ' + user_id) ml.append('security: ' + sec) # Open the log file brcdapi_log.open_log(log) brcdapi_log.log(ml, True) # Login brcdapi_log.log('Attempting login', True) session = sannav_auth.login(user_id, pw, ip, sec) if sannav_auth.is_error(session): brcdapi_log.log('Login failed. Error message is:', True) brcdapi_log.log(sannav_auth.formatted_error_msg(session), True) return brcddb_common.EXIT_STATUS_API_ERROR # Logout brcdapi_log.log('Login succeeded. Attempting logout', True) obj = sannav_auth.logout(session) if sannav_auth.is_error(obj): brcdapi_log.log('Logout failed. Error message is:', True) brcdapi_log.log(sannav_auth.formatted_error_msg(obj), True) return -1 brcdapi_log.log('Logout succeeded.', True) # Close the log file brcdapi_log.close_log('') return brcddb_common.EXIT_STATUS_OK
brcdapi_log.log('Sending zone updates to FID ' + str(fid), True) obj = api_zone.replace_zoning(session, fab_obj, fid) if fos_auth.is_error(obj): brcdapi_log.log(fos_auth.formatted_error_msg(obj), True) else: brcdapi_log.log('Zone restore completed successfully.', True) except BaseException as e: brcdapi_log.log(['', 'Software error.', 'Exception: ' + str(e)], True) # Logout obj = brcdapi_rest.logout(session) if fos_auth.is_error(obj): brcdapi_log.log(fos_auth.formatted_error_msg(obj), True) return ec ################################################################## # # Main Entry Point # ################################################################### if _DOC_STRING: print('_DOC_STRING is True. No processing') exit(brcddb_common.EXIT_STATUS_OK) _ec = pseudo_main() brcdapi_log.close_log('Processing complete. Exit status: ' + str(_ec)) exit(_ec)
ec = -1 else: brcdapi_log.log( 'Successfully set all ports for FID ' + str(fid) + ' to the default configuration', True) except: brcdapi_log.log('Encountered a programming error', True) ec = -1 # Logout obj = brcdapi_rest.logout(session) if brcdapi_auth.is_error(obj): brcdapi_log.log( 'Logout failed:\n' + brcdapi_auth.formatted_error_msg(obj), True) return ec ################################################################### # # Main Entry Point # ################################################################### if _DOC_STRING: print('_DOC_STRING set. No processing') exit(0) _ec = pseudo_main() brcdapi_log.close_log('Processing Complete. Exit code: ' + str(_ec)) exit(_ec)
if fos_auth.is_error(obj): brcdapi_log.log('Logout failed. Error message is:', True) brcdapi_log.log(fos_auth.formatted_error_msg(obj), True) return -1 brcdapi_log.log('Logout succeeded.', True) # Display the certificates if fos_auth.is_error(cert_obj): brcdapi_log.exception( 'Failed to capture certificates.' + fos_auth.formatted_error_msg(cert_obj), True) return -1 _cert_detail_report(cert_obj) _cert_summary_report(cert_obj) return 0 ################################################################### # # Main Entry Point # ################################################################### if _DOC_STRING: print('_DOC_STRING is True. No processing') exit(0) _ec = pseudo_main() brcdapi_log.close_log('All processing complete. Exit code: ' + str(_ec)) exit(_ec)
# Get a list of ports to move to the new switch port_d, ge_port_d = _parse_ports(session, fid, i_ports, i_ge_ports, echo) # We're done with conditioning the user input. Now create the logical switch. ec = create_ls(session, fid, name, did, idid, xisl, base, ficon, port_d, ge_port_d, es, ep, echo) except: brcdapi_log.log('Encountered a programming error', True) ec = -1 # Logout obj = brcdapi_rest.logout(session) if pyfos_auth.is_error(obj): brcdapi_log.log([ 'Logout failed. API error message is:', pyfos_auth.formatted_error_msg(obj) ], True) return ec ################################################################### # # Main Entry Point # ################################################################### if not _DOC_STRING: brcdapi_log.close_log(str(pseudo_main()), True)
return ec _working_obj_l.append(proj_obj) for action_d in action_l: for k, v in action_d.items(): if k in _action_d: _action_d[k](v) else: brcdapi_log.log('Invalid action item, ' + str(k)) if _wb is not None and _report_name is not None: brcdapi_log.log('Saving ' + _report_name, True) excel_util.save_report(_wb, _report_name) return brcddb_common.EXIT_STATUS_OK ################################################################## # # Main Entry Point # ################################################################### if _DOC_STRING: brcdapi_log.close_log('_DOC_STRING is True. No processing', True) exit(brcddb_common.EXIT_STATUS_OK) else: _ec = psuedo_main() brcdapi_log.close_log(['', str(_ec)]) exit(_ec)
if brcdapi_auth.is_error(session): brcdapi_log.log('Login failed', True) brcdapi_log.log(brcdapi_auth.formatted_error_msg(session), True) return -1 brcdapi_log.log('Login succeeded', True) try: ec = _clear_dashboard(session, fid) except: # Base except because I don't care what went wrong, I just want to make sure we logout. brcdapi_log.exception('Encountered a programming error', True) ec = -1 obj = brcdapi_rest.logout(session) if brcdapi_auth.is_error(obj): brcdapi_log.log('Logout failed:\n' + brcdapi_auth.formatted_error_msg(obj), True) return ec ################################################################### # # Main Entry Point # ################################################################### if _DOC_STRING: print('_DOC_STRING is True. No processing') exit(0) _ec = pseudo_main() brcdapi_log.close_log(str(_ec)) exit(_ec)
return -1 save_flag = False # Enabling a zone configuration does a configuration save if save_flag: if _is_error(session, fid, brcdapi_zone.save(session, fid, checksum, True)): _logout(session) return -1 except: brcdapi_log.log('Logging out', True) _logout(session) brcdapi_log.exception('Exception', True) return -1 brcdapi_log.log('Logging out', True) _logout(session) return 0 ################################################################### # # Main Entry Point # ################################################################### if not _DOC_STRING: brcdapi_log.close_log( str( pseudo_main(_DEBUG_ID, _DEBUG_PW, _DEBUG_IP, _DEBUG_SEC, _DEBUG_VERBOSE, _DEBUG_LOG, _DEBUG_NL)))
): # Get a zone analysis on all fabrics brcdapi_log.log( 'Performing zone analysis for fabric ' + brcddb_fabric.best_fab_name(obj), True) brcddb_fabric.zone_analysis(obj) # Generate the report brcddb_report.report(proj_obj, outf) _custom_report(proj_obj, custom_parms) return brcddb_common.EXIT_STATUS_ERROR if proj_obj.r_is_any_error( ) else brcddb_common.EXIT_STATUS_OK ################################################################## # # Main Entry Point # ################################################################### # Read in the project file from which the report is to be created and convert to a project object # Create project if _DOC_STRING: brcdapi_log.close_log('_DOC_STRING is True. No processing', True) exit(0) _ec = pseudo_main() brcdapi_log.close_log(['', 'Processing Complete. Exit code: ' + str(_ec)], True) exit(_ec)