Ejemplo n.º 1
0
def main(argv):
    isHttps = "0"

    inputs = brcd_util.generic_input(argv, usage)

    session = pyfos_auth.login(inputs["login"], inputs["password"],
                               inputs["ipaddr"], isHttps)
    if pyfos_auth.is_failed_login(session):
        print("login failed because",
              session.get(pyfos_auth.CREDENTIAL_KEY)
              [pyfos_auth.LOGIN_ERROR_KEY])
        usage()
        sys.exit()

    brcd_util.exit_register(session)

    vfid = None
    if 'vfid' in inputs:
        vfid = inputs['vfid']

    if vfid is not None:
        pyfos_auth.vfid_set(session, vfid)

    if 'compare' not in inputs or inputs['compare'] is None:
        usage()
        sys.exit()

    dir_name = inputs['compare']

    diff_object(session, dir_name, pyfos_switch.fibrechannel_switch)
    diff_object_list(session, dir_name, pyfos_switchfcport.fibrechannel)
    diff_object(session, dir_name, pyfos_zone.defined_configuration)
    diff_object(session, dir_name, pyfos_zone.effective_configuration)

    pyfos_auth.logout(session)
Ejemplo n.º 2
0
def main(argv):
    inputs = brcd_util.generic_input(argv, usage)

    session = pyfos_auth.login(inputs["login"], inputs["password"],
                               inputs["ipaddr"], isHttps)
    if pyfos_auth.is_failed_login(session):
        print(
            "login failed because",
            session.get(pyfos_auth.CREDENTIAL_KEY)[pyfos_auth.LOGIN_ERROR_KEY])
        usage()
        sys.exit()

    brcd_util.exit_register(session)

    vfid = None
    if 'vfid' in inputs:
        vfid = inputs['vfid']

    if vfid is not None:
        pyfos_auth.vfid_set(session, vfid)

    fabric = pyfos_fabric.fabric_switch.get(session)
    if isinstance(fabric, list):
        for switch in fabric:
            pyfos_util.response_print(switch)
    else:
        pyfos_util.response_print(fabric)

    pyfos_auth.logout(session)
Ejemplo n.º 3
0
def main(argv):
    valid_options = ["name"]
    inputs = brcd_util.generic_input(argv, usage, valid_options)

    session = pyfos_auth.login(inputs["login"],
                               inputs["password"],
                               inputs["ipaddr"],
                               inputs["secured"],
                               verbose=inputs["verbose"])
    if pyfos_auth.is_failed_login(session):
        print(
            "login failed because",
            session.get(pyfos_auth.CREDENTIAL_KEY)[pyfos_auth.LOGIN_ERROR_KEY])
        brcd_util.full_usage(usage)
        sys.exit()

    brcd_util.exit_register(session)

    vfid = None
    if 'vfid' in inputs:
        vfid = inputs['vfid']

    if vfid is not None:
        pyfos_auth.vfid_set(session, vfid)

    brcd_zone_util.zone_name_func(session, inputs, usage, __zonedelete)

    pyfos_auth.logout(session)
Ejemplo n.º 4
0
def main(argv):
    inputs = brcd_util.generic_input(argv, usage)

    session = pyfos_auth.login(inputs["login"], inputs["password"],
                               inputs["ipaddr"], isHttps)
    if pyfos_auth.is_failed_login(session):
        print("login failed because",
              session.get(pyfos_auth.CREDENTIAL_KEY)
              [pyfos_auth.LOGIN_ERROR_KEY])
        usage()
        sys.exit()

    brcd_util.exit_register(session)

    vfid = None
    if 'vfid' in inputs:
        vfid = inputs['vfid']

    if vfid is not None:
        pyfos_auth.vfid_set(session, vfid)

    current_effective = pyfos_zone.effective_configuration.get(session)
    result = cfgdisable(session, current_effective.peek_checksum())
    pyfos_util.response_print(result)

    pyfos_auth.logout(session)
Ejemplo n.º 5
0
def main(argv):
    inputs = brcd_util.generic_input(argv, usage)

    session = pyfos_auth.login(inputs["login"], inputs["password"],
                               inputs["ipaddr"], isHttps)
    if pyfos_auth.is_failed_login(session):
        print(
            "login failed because",
            session.get(pyfos_auth.CREDENTIAL_KEY)[pyfos_auth.LOGIN_ERROR_KEY])
        usage()
        sys.exit()

    brcd_util.exit_register(session)

    vfid = None
    if 'vfid' in inputs:
        vfid = inputs['vfid']

    if vfid is not None:
        pyfos_auth.vfid_set(session, vfid)

    brcd_zone_util.zone_name_members_pmembers_func(session, inputs, usage,
                                                   __pzoneadd)

    pyfos_auth.logout(session)
Ejemplo n.º 6
0
def main(argv):
    inputs = brcd_util.generic_input(argv, usage)

    session = pyfos_auth.login(inputs["login"], inputs["password"],
                               inputs["ipaddr"], isHttps)
    if pyfos_auth.is_failed_login(session):
        print(
            "login failed because",
            session.get(pyfos_auth.CREDENTIAL_KEY)[pyfos_auth.LOGIN_ERROR_KEY])
        usage()
        sys.exit()

    brcd_util.exit_register(session)

    vfid = None
    if 'vfid' in inputs:
        vfid = inputs['vfid']

    if vfid is not None:
        pyfos_auth.vfid_set(session, vfid)

    if "name" not in inputs:
        ports = pyfos_switchfcport.fibrechannel_statistics.get(session)
        for port in ports:
            pyfos_util.response_print(port)
    else:
        name = inputs["name"]
        port = pyfos_switchfcport.fibrechannel_statistics.get(session, name)
        pyfos_util.response_print(port)

    pyfos_auth.logout(session)
Ejemplo n.º 7
0
def main(argv):
    valid_options = []
    inputs = brcd_util.generic_input(argv, usage, valid_options)

    session = pyfos_auth.login(inputs["login"], inputs["password"],
                               inputs["ipaddr"], inputs["secured"],
                               verbose=inputs["verbose"])
    if pyfos_auth.is_failed_login(session):
        print("login failed because",
              session.get(pyfos_auth.CREDENTIAL_KEY)
              [pyfos_auth.LOGIN_ERROR_KEY])
        brcd_util.full_usage(usage, valid_options)
        sys.exit()

    brcd_util.exit_register(session)

    vfid = None
    if 'vfid' in inputs:
        vfid = inputs['vfid']

    if vfid is not None:
        pyfos_auth.vfid_set(session, vfid)

    defined_zone = pyfos_zone.defined_configuration.get(session)
    pyfos_util.response_print(defined_zone)

    effective_zone = pyfos_zone.effective_configuration.get(session)
    pyfos_util.response_print(effective_zone)

    # options = effective_zone.options(session)
    # print(options)

    pyfos_auth.logout(session)
def main(argv):
    valid_options = []
    inputs = brcd_util.generic_input(argv, usage, valid_options)

    session = pyfos_auth.login(inputs["login"],
                               inputs["password"],
                               inputs["ipaddr"],
                               inputs["secured"],
                               verbose=inputs["verbose"])
    if pyfos_auth.is_failed_login(session):
        print(
            "login failed because",
            session.get(pyfos_auth.CREDENTIAL_KEY)[pyfos_auth.LOGIN_ERROR_KEY])
        usage()
        sys.exit()

    brcd_util.exit_register(session)

    vfid = None
    if 'vfid' in inputs:
        vfid = inputs['vfid']

    if vfid is not None:
        pyfos_auth.vfid_set(session, vfid)

    switch = pyfos_switch.fibrechannel_switch.get(session)
    pyfos_util.response_print(switch)

    pyfos_auth.logout(session)
Ejemplo n.º 9
0
def main(argv):
    isHttps = "0"

    inputs = brcd_util.generic_input(argv, usage)

    session = pyfos_auth.login(inputs["login"], inputs["password"],
                               inputs["ipaddr"], isHttps)
    if pyfos_auth.is_failed_login(session):
        print(
            "login failed because",
            session.get(pyfos_auth.CREDENTIAL_KEY)[pyfos_auth.LOGIN_ERROR_KEY])
        usage()
        sys.exit()

    brcd_util.exit_register(session)

    vfid = None
    if 'vfid' in inputs:
        vfid = inputs['vfid']

    if vfid is not None:
        pyfos_auth.vfid_set(session, vfid)

    defined_zone = pyfos_zone.defined_configuration.get(session)
    pyfos_util.response_print(defined_zone)

    effective_zone = pyfos_zone.effective_configuration.get(session)
    pyfos_util.response_print(effective_zone)

    pyfos_auth.logout(session)
Ejemplo n.º 10
0
def main(argv):
    inputs = brcd_util.generic_input(argv, usage)

    session = pyfos_auth.login(inputs["login"], inputs["password"],
                               inputs["ipaddr"], isHttps)
    if pyfos_auth.is_failed_login(session):
        print("login failed because",
              session.get(pyfos_auth.CREDENTIAL_KEY)
              [pyfos_auth.LOGIN_ERROR_KEY])
        usage()
        sys.exit()

    brcd_util.exit_register(session)

    vfid = None
    if 'vfid' in inputs:
        vfid = inputs['vfid']

    if vfid is not None:
        pyfos_auth.vfid_set(session, vfid)

    ret_code, details = zone_allow_pair_to_peer(
            session, ZONE_PREFIX, inputs["hostport"],
            inputs["targetname"], inputs["targetport"], CFG_NAME, False)

    if ret_code > 0:
        print("zone db updated", ret_code)
    else:
        print("zone db remains", ret_code)

    print(details)

    pyfos_auth.logout(session)
Ejemplo n.º 11
0
def main(argv):
    #myinput=str("-i 10.17.3.70  -n 4/19 ")
    #argv = myinput.split()
    value_dict = dict()
    inputs = dict()
    ret = parse_tunnel(argv, inputs, value_dict)

    session = pyfos_auth.login(inputs["login"], inputs["password"],
                               inputs["switch"], isHttps)
    if pyfos_auth.is_failed_login(session):
        print(
            "login failed because",
            session.get(pyfos_auth.CREDENTIAL_KEY)[pyfos_auth.LOGIN_ERROR_KEY])
        usage()
        sys.exit()

    brcd_util.exit_register(session)

    vfid = None
    if 'vfid' in inputs:
        vfid = inputs['vfid']

    if vfid is not None:
        pyfos_auth.vfid_set(session, vfid)

    if "name" not in value_dict:
        pyfos_auth.logout(session)
        usage()
        sys.exit()

    result = _delete_extension_tunnel(session, value_dict)
    pyfos_util.response_print(result)
    pyfos_auth.logout(session)
Ejemplo n.º 12
0
def main(argv):
    valid_options = ["name"]
    inputs = brcd_util.generic_input(argv, usage, valid_options)

    session = brcd_util.getsession(inputs)

    vfid = None
    if 'vfid' in inputs:
        vfid = inputs['vfid']

    if vfid is not None:
        pyfos_auth.vfid_set(session, vfid)

    if "name" in inputs:
        name = inputs["name"]
        result = pyfos_switchfcport.fibrechannel.get(session, name)
    else:
        result = pyfos_switchfcport.fibrechannel.get(session)

    if not pyfos_util.is_failed_resp(result):
        available_ports = []
        if isinstance(result, list):
            for port in result:
                id_avail_port(port, available_ports)
        else:
            id_avail_port(result, available_ports)

        pyfos_util.response_print(available_ports)
    else:
        if "name" in inputs:
            print("failed to get information on", inputs["name"])
        else:
            print("failed to get information on ports")

    pyfos_auth.logout(session)
Ejemplo n.º 13
0
def main(argv):
    valid_options = ["hbaid"]
    inputs = brcd_util.generic_input(argv, usage, valid_options)

    # Login to switch
    session = pyfos_auth.login(inputs["login"], inputs["password"],
                               inputs["ipaddr"], inputs["secured"],
                               verbose=inputs["verbose"])
    if pyfos_auth.is_failed_login(session):
        print("login failed because",
              session.get(pyfos_auth.CREDENTIAL_KEY)
              [pyfos_auth.LOGIN_ERROR_KEY])
        brcd_util.full_usage(usage, valid_options)
        sys.exit()

    brcd_util.exit_register(session)

    # Set VF ID, if necessary
    vfid = None
    if 'vfid' in inputs:
        vfid = inputs['vfid']
    if vfid is not None:
        pyfos_auth.vfid_set(session, vfid)

    # Call fdmishow
    fdmishow(session, inputs)

    # Log out
    pyfos_auth.logout(session)
Ejemplo n.º 14
0
def main(argv):
    valid_options = ["hostname", "hostport", "targetname", "targetport"]
    inputs = brcd_util.generic_input(argv, usage, valid_options)

    session = pyfos_auth.login(inputs["login"],
                               inputs["password"],
                               inputs["ipaddr"],
                               inputs["secured"],
                               verbose=inputs["verbose"])
    if pyfos_auth.is_failed_login(session):
        print(
            "login failed because",
            session.get(pyfos_auth.CREDENTIAL_KEY)[pyfos_auth.LOGIN_ERROR_KEY])
        brcd_util.full_usage(usage)
        sys.exit()

    brcd_util.exit_register(session)

    vfid = None
    if 'vfid' in inputs:
        vfid = inputs['vfid']

    if vfid is not None:
        pyfos_auth.vfid_set(session, vfid)

    if "hostname" not in inputs:
        print("--hostname is mandatory")
        brcd_util.full_usage(usage)
        sys.exit()

    if "hostport" not in inputs:
        print("--hostport is mandatory")
        brcd_util.full_usage(usage)
        sys.exit()

    if "targetname" not in inputs:
        print("--targetname is mandatory")
        brcd_util.full_usage(usage)
        sys.exit()

    if "targetport" not in inputs:
        print("--targetport is mandatory")
        brcd_util.full_usage(usage)
        sys.exit()

    ret_code, details = zone_allow_pair(session, ZONE_PREFIX,
                                        inputs["hostname"], inputs["hostport"],
                                        inputs["targetname"],
                                        inputs["targetport"], CFG_NAME, False)

    if ret_code > 0:
        print("zone db updated")
    else:
        print("zone db remains")

    print(details)

    pyfos_auth.logout(session)
Ejemplo n.º 15
0
def main(argv):
    valid_options = ["compare", "template", "reffcport"]
    inputs = brcd_util.generic_input(argv, usage, valid_options)

    session = pyfos_auth.login(inputs["login"],
                               inputs["password"],
                               inputs["ipaddr"],
                               inputs["secured"],
                               verbose=inputs["verbose"])
    if pyfos_auth.is_failed_login(session):
        print(
            "login failed because",
            session.get(pyfos_auth.CREDENTIAL_KEY)[pyfos_auth.LOGIN_ERROR_KEY])
        usage()
        sys.exit()

    brcd_util.exit_register(session)

    vfid = None
    if 'vfid' in inputs:
        vfid = inputs['vfid']

    if vfid is not None:
        pyfos_auth.vfid_set(session, vfid)

    if 'compare' not in inputs or inputs['compare'] is None:
        usage()
        sys.exit()

    dir_name = inputs['compare']

    template = None
    if 'template' in inputs:
        template = switch_config_util.get_template(inputs['template'])

    switch_config_util.process_object(session, dir_name,
                                      pyfos_switch.fibrechannel_switch, True,
                                      template)
    if 'template' in inputs and 'reffcport' in inputs:
        switch_config_util.process_object(session, dir_name,
                                          pyfos_switchfcport.fibrechannel,
                                          True, template,
                                          [{
                                              "name": inputs['reffcport']
                                          }])
    else:
        switch_config_util.process_object(session, dir_name,
                                          pyfos_switchfcport.fibrechannel,
                                          True, template)
    switch_config_util.process_object(session, dir_name,
                                      pyfos_zone.defined_configuration, True,
                                      template)
    switch_config_util.process_object(session, dir_name,
                                      pyfos_zone.effective_configuration, True,
                                      template)

    pyfos_auth.logout(session)
Ejemplo n.º 16
0
def main(argv):
    #myinput=str("-i 10.17.3.70  -n 4/17 -d 0 -s 154.10.10.0 " +\
    #            "-g 134.10.10.125 -p 24 ")
    #argv = myinput.split()
    value_dict = dict()
    inputs = dict()
    ret = parse_iproute(argv, inputs, value_dict)
    if ret != 0:
        usage()
        sys.exit()

    #print(inputs, value_dict)
    session = pyfos_auth.login(inputs["login"], inputs["password"],
                               inputs["switch"], isHttps)
    if pyfos_auth.is_failed_login(session):
        print(
            "login failed because",
            session.get(pyfos_auth.CREDENTIAL_KEY)[pyfos_auth.LOGIN_ERROR_KEY])
        usage()
        sys.exit()

    brcd_util.exit_register(session)

    vfid = None
    if 'vfid' in inputs:
        vfid = inputs['vfid']

    if vfid is not None:
        pyfos_auth.vfid_set(session, vfid)

    if "name" not in value_dict:
        pyfos_auth.logout(session)
        usage()
        sys.exit()

    if "ip-address" not in value_dict:
        pyfos_auth.logout(session)
        usage()
        sys.exit()

    if "ip-prefix-length" not in value_dict:
        pyfos_auth.logout(session)
        usage()
        sys.exit()

    if "dp-id" not in value_dict:
        pyfos_auth.logout(session)
        usage()
        sys.exit()

    result = _modify_extension_iproute(session, value_dict)
    pyfos_util.response_print(result)
    pyfos_auth.logout(session)
Ejemplo n.º 17
0
def main(argv):
    valid_options = ["name", "enable", "disable"]
    inputs = brcd_util.generic_input(argv, usage, valid_options)

    session = pyfos_auth.login(inputs["login"],
                               inputs["password"],
                               inputs["ipaddr"],
                               inputs["secured"],
                               verbose=inputs["verbose"])
    if pyfos_auth.is_failed_login(session):
        print(
            "login failed because",
            session.get(pyfos_auth.CREDENTIAL_KEY)[pyfos_auth.LOGIN_ERROR_KEY])
        usage()
        sys.exit()

    brcd_util.exit_register(session)

    vfid = None
    if 'vfid' in inputs:
        vfid = inputs['vfid']

    if vfid is not None:
        pyfos_auth.vfid_set(session, vfid)

    if "name" not in inputs:
        pyfos_auth.logout(session)
        usage()
        sys.exit()
    name = inputs["name"]

    if "enable" not in inputs and "disable" not in inputs:
        pyfos_auth.logout(session)
        usage()
        sys.exit()

    if "enable" in inputs:
        enabled = 1
    if "disable" in inputs:
        enabled = 0

    port = pyfos_switchfcport.fibrechannel()
    port.set_name(name)
    if enabled:
        port.set_enabled_state(pyfos_switchfcport.ENABLED_STATE_TYPE.ONLINE)
    else:
        port.set_enabled_state(pyfos_switchfcport.ENABLED_STATE_TYPE.OFFLINE)
    result = port.patch(session)
    pyfos_util.response_print(result)

    pyfos_auth.logout(session)
Ejemplo n.º 18
0
def main(argv):
    valid_options = ["filename", "usepeer", "xlscheck", "xlsapply"]
    inputs = brcd_util.generic_input(argv, usage, valid_options)

    session = pyfos_auth.login(inputs["login"],
                               inputs["password"],
                               inputs["ipaddr"],
                               inputs["secured"],
                               verbose=inputs["verbose"])
    if pyfos_auth.is_failed_login(session):
        print(
            "login failed because",
            session.get(pyfos_auth.CREDENTIAL_KEY)[pyfos_auth.LOGIN_ERROR_KEY])
        brcd_util.full_usage(usage)
        sys.exit()

    brcd_util.exit_register(session)

    vfid = None
    if 'vfid' in inputs:
        vfid = inputs['vfid']

    if vfid is not None:
        pyfos_auth.vfid_set(session, vfid)

    if "filename" not in inputs:
        print("filename missing")
        brcd_util.full_usage(usage)
        sys.exit()

    filename = inputs["filename"]
    if filename.endswith("txt"):
        process_txt(session, filename)
    elif filename.endswith("xlsx"):
        usepeer = False
        usepeer_wwn = False
        if "usepeer" in inputs:
            usepeer = True
            if inputs["usepeer"] == "WWN":
                usepeer_wwn = True
            else:
                usepeer_wwn = False

        if "xlscheck" in inputs:
            process_xlsx_direct_generic(session, filename, inputs["xlscheck"],
                                        False, usepeer, usepeer_wwn)
        elif "xlsapply" in inputs:
            process_xlsx_direct_generic(session, filename, inputs["xlsapply"],
                                        True, usepeer, usepeer_wwn)

    pyfos_auth.logout(session)
Ejemplo n.º 19
0
def main(argv):
    valid_options = ["json", "compare", "template", "reffcport"]
    inputs = brcd_util.generic_input(argv, usage, valid_options)

    session = pyfos_auth.login(inputs["login"],
                               inputs["password"],
                               inputs["ipaddr"],
                               inputs["secured"],
                               verbose=inputs["verbose"])
    if pyfos_auth.is_failed_login(session):
        print(
            "login failed because",
            session.get(pyfos_auth.CREDENTIAL_KEY)[pyfos_auth.LOGIN_ERROR_KEY])
        usage()
        sys.exit()

    brcd_util.exit_register(session)

    vfid = None
    if 'vfid' in inputs:
        vfid = inputs['vfid']

    if vfid is not None:
        pyfos_auth.vfid_set(session, vfid)

    if 'compare' not in inputs or inputs['compare'] is None:
        usage()
        sys.exit()

    envelope_name = inputs['compare']

    in_json = False
    if 'json' in inputs:
        in_json = True

    if in_json:
        fmtfile = 'JSON'
        fmtobj = 'json'
        # ext = '.json'
    else:
        fmtfile = 'XLSX'
        fmtobj = 'attributes'
        # ext = '.xlsx'
    clsmanager.addsession(session, inputs["login"], inputs["password"])
    mgr = config_manager(fmtfile, fmtobj)
    fcmodechange = config_manager()
    fcmodechange.applygoldenobject(session, envelope_name,
                                   "fibrechannel-switch", 6)
    mgr.applydiff(envelope_name, session)
    pyfos_auth.logout(session)
Ejemplo n.º 20
0
def main(argv):
    valid_options = ["name"]
    inputs = brcd_util.generic_input(argv, usage, valid_options)

    session = pyfos_auth.login(inputs["login"],
                               inputs["password"],
                               inputs["ipaddr"],
                               inputs["secured"],
                               verbose=inputs["verbose"])
    if pyfos_auth.is_failed_login(session):
        print(
            "login failed because",
            session.get(pyfos_auth.CREDENTIAL_KEY)[pyfos_auth.LOGIN_ERROR_KEY])
        usage()
        sys.exit()

    brcd_util.exit_register(session)

    vfid = None
    if 'vfid' in inputs:
        vfid = inputs['vfid']

    if vfid is not None:
        pyfos_auth.vfid_set(session, vfid)

    if "name" in inputs:
        name = inputs["name"]
        result = pyfos_switchfcport.fibrechannel.get(session, name)
    else:
        result = pyfos_switchfcport.fibrechannel.get(session)

    if not pyfos_util.is_failed_resp(result):
        available_ports = []
        if isinstance(result, list):
            for port in result:
                id_avail_port(port, available_ports)
        else:
            id_avail_port(result, available_ports)

        pyfos_util.response_print(available_ports)
    else:
        if "name" in inputs:
            print("failed to get information on", inputs["name"])
        else:
            print("failed to get information on ports")

    pyfos_auth.logout(session)
Ejemplo n.º 21
0
def main(argv):
    valid_options = ["allaccess"]
    inputs = brcd_util.generic_input(argv, usage, valid_options)

    session = pyfos_auth.login(inputs["login"],
                               inputs["password"],
                               inputs["ipaddr"],
                               inputs["secured"],
                               verbose=inputs["verbose"])
    if pyfos_auth.is_failed_login(session):
        print(
            "login failed because",
            session.get(pyfos_auth.CREDENTIAL_KEY)[pyfos_auth.LOGIN_ERROR_KEY])
        brcd_util.full_usage(usage)
        sys.exit()

    brcd_util.exit_register(session)

    vfid = None
    if 'vfid' in inputs:
        vfid = inputs['vfid']

    if vfid is not None:
        pyfos_auth.vfid_set(session, vfid)

    if "allaccess" not in inputs:
        pyfos_auth.logout(session)
        usage()
        sys.exit()
    allaccess = inputs["allaccess"]

    current_effective = pyfos_zone.effective_configuration.get(session)

    result = defzone(session, allaccess)

    if pyfos_util.is_failed_resp(result):
        pyfos_util.response_print(result)
    else:
        pyfos_util.response_print(result)
        result = cfgsave.cfgsave(session, current_effective.peek_checksum())
        pyfos_util.response_print(result)
        if pyfos_util.is_failed_resp(result):
            print("failed. Aborting transaction.")
            result = cfgabort.cfgabort(session)
            pyfos_util.response_print(result)

    pyfos_auth.logout(session)
Ejemplo n.º 22
0
def main(argv):
    valid_options = []
    inputs = brcd_util.generic_input(argv, usage, valid_options)

    session = brcd_util.getsession(inputs)

    vfid = None
    if 'vfid' in inputs:
        vfid = inputs['vfid']

    if vfid is not None:
        pyfos_auth.vfid_set(session, vfid)

    eula = end_user_license_agreement.get(session)
    pyfos_util.response_print(eula)

    pyfos_auth.logout(session)
Ejemplo n.º 23
0
def main(argv):
    valid_options = ["hbaid"]
    inputs = brcd_util.generic_input(argv, usage, valid_options)

    session = brcd_util.getsession(inputs)

    # Set VF ID, if necessary
    vfid = None
    if 'vfid' in inputs:
        vfid = inputs['vfid']
    if vfid is not None:
        pyfos_auth.vfid_set(session, vfid)

    # Call fdmishow
    fdmishow(session, inputs)

    # Log out
    pyfos_auth.logout(session)
Ejemplo n.º 24
0
def main(argv):
    valid_options = ["name", "username"]
    inputs = brcd_util.generic_input(argv, usage, valid_options)

    session = pyfos_auth.login(inputs["login"],
                               inputs["password"],
                               inputs["ipaddr"],
                               inputs["secured"],
                               verbose=inputs["verbose"])
    if pyfos_auth.is_failed_login(session):
        print(
            "login failed because",
            session.get(pyfos_auth.CREDENTIAL_KEY)[pyfos_auth.LOGIN_ERROR_KEY])
        usage()
        sys.exit()

    brcd_util.exit_register(session)

    vfid = None
    if 'vfid' in inputs:
        vfid = inputs['vfid']

    if vfid is not None:
        pyfos_auth.vfid_set(session, vfid)

    if "name" not in inputs:
        pyfos_auth.logout(session)
        usage()
        sys.exit()
    name = inputs["name"]

    if "username" not in inputs:
        pyfos_auth.logout(session)
        usage()
        sys.exit()
    username = inputs["username"]

    port = pyfos_switchfcport.fibrechannel()
    port.set_name(name)
    port.set_user_friendly_name(username)
    result = port.patch(session)
    pyfos_util.response_print(result)

    pyfos_auth.logout(session)
Ejemplo n.º 25
0
def main(argv):
    valid_options = ["json", "compare"]
    inputs = brcd_util.generic_input(argv, usage, valid_options)

    session = pyfos_auth.login(inputs["login"],
                               inputs["password"],
                               inputs["ipaddr"],
                               inputs["secured"],
                               verbose=inputs["verbose"])
    if pyfos_auth.is_failed_login(session):
        print(
            "login failed because",
            session.get(pyfos_auth.CREDENTIAL_KEY)[pyfos_auth.LOGIN_ERROR_KEY])
        usage()
        sys.exit()

    brcd_util.exit_register(session)

    vfid = None
    if 'vfid' in inputs:
        vfid = inputs['vfid']

    if vfid is not None:
        pyfos_auth.vfid_set(session, vfid)

    in_json = False
    if 'json' in inputs:
        in_json = inputs['json']

    if in_json:
        fmtfile = 'JSON'
        fmtobj = 'json'
        ext = '.json'
    else:
        fmtfile = 'XLSX'
        fmtobj = 'attributes'
        ext = '.xlsx'
    envelope_name = get_envelope_name(inputs['ipaddr'])
    envelope_name += ext
    mgr = config_manager(fmtfile, fmtobj)
    mgr.dumptofile(session, envelope_name)
    print("done")

    pyfos_auth.logout(session)
Ejemplo n.º 26
0
def getsession(inputs):
    global session
    tokenManager = None
    ishttps = None
    if 'authtoken' in inputs.keys():
        # Always need to use the Default Token Manager config
        # if user wants to use a different configuration then user
        # config store should be set as default store using the set
        # default store option.
        if inputs['authtoken'] is None or \
           auth_token_manager.isvalidconfig(inputs['authtoken']):
            tokenManager = auth_token_manager(inputs['authtoken'])
        else:
            tokenManager = inputs['authtoken']
        # tokenManager.show()

    # Get the password or else None
    ip = inputs.get("ipaddr", None)
    user = inputs.get("login", None)
    password = inputs.get("password", None)
    sessionless = inputs.get('sessionless', False)
    nocred = inputs.get('nocredential', False)

    if 'secured' in inputs.keys():
        ishttps = inputs['secured']

    # Default DEFAULT_THROTTLE_DELAY 1.1
    session = pyfos_auth.login(user, password, ip, ishttps, 1.1, 0,
                               tokenManager, sessionless, nocred)

    if pyfos_auth.is_failed_login(session):
        print(
            "login failed because",
            session.get(pyfos_auth.CREDENTIAL_KEY)[pyfos_auth.LOGIN_ERROR_KEY])
        print(inputs['utilusage'])
        sys.exit(3)
    exit_register(session)
    if 'vfid' in inputs:
        pyfos_auth.vfid_set(session, inputs['vfid'])
    if 'verbose' in inputs and inputs['verbose'] != 0:
        pyfos_auth.debug_set(session, 1)
    inputs['session'] = session
    return session
Ejemplo n.º 27
0
def get_fabric_from_seedswitch():

    fabric = []
    # Get session from input seed switch
    session = get_session(IPADDRESS)
    if pyfos_auth.is_failed_login(session):
        print(
            "Login failed due to",
            session.get(pyfos_auth.CREDENTIAL_KEY)[pyfos_auth.LOGIN_ERROR_KEY])
        sys.exit()
    else:
        pyfos_auth.vfid_set(session, VFID)

        # Get fabric from seed switch
        fabric = pyfos_fabric.fabric_switch.get(session)

        pyfos_auth.logout(session)

    return fabric
Ejemplo n.º 28
0
def getsession(inputs):
    ishttps = None
    if 'secured' in inputs.keys():
        ishttps = inputs['secured']
    session = pyfos_auth.login(inputs["login"], inputs["password"],
                               inputs["ipaddr"], ishttps)
    if pyfos_auth.is_failed_login(session):
        print(
            "login failed because",
            session.get(pyfos_auth.CREDENTIAL_KEY)[pyfos_auth.LOGIN_ERROR_KEY])
        print(inputs['utilusage'])
        sys.exit(3)
    exit_register(session)
    if 'vfid' in inputs:
        pyfos_auth.vfid_set(session, inputs['vfid'])
    if 'verbose' in inputs:
        pyfos_auth.debug_set(session, 1)
    inputs['session'] = session
    return session
def main(argv):
    # pylint: disable=W0603
    global g_session
    valid_options = ["hostport", "targetname", "targetport"]
    inputs = brcd_util.generic_input(argv, usage, valid_options)

    g_session = pyfos_auth.login(inputs["login"],
                                 inputs["password"],
                                 inputs["ipaddr"],
                                 inputs["secured"],
                                 verbose=inputs["verbose"])
    if pyfos_auth.is_failed_login(g_session):
        print(
            "login failed because",
            g_session.get(
                pyfos_auth.CREDENTIAL_KEY)[pyfos_auth.LOGIN_ERROR_KEY])
        brcd_util.full_usage(usage, valid_options)
        sys.exit()

    brcd_util.exit_register(g_session)

    vfid = None
    if 'vfid' in inputs:
        vfid = inputs['vfid']

    if vfid is not None:
        pyfos_auth.vfid_set(g_session, vfid)

    ret_code, details = zone_allow_pair_to_peer(g_session, ZONE_PREFIX,
                                                inputs["hostport"],
                                                inputs["targetname"],
                                                inputs["targetport"], CFG_NAME,
                                                False)

    if ret_code > 0:
        print("zone db updated", ret_code)
    else:
        print("zone db remains", ret_code)

    print(details)

    pyfos_auth.logout(g_session)
Ejemplo n.º 30
0
def main(argv):
    valid_options = []
    inputs = brcd_util.generic_input(argv, usage, valid_options)

    session = pyfos_auth.login(inputs["login"],
                               inputs["password"],
                               inputs["ipaddr"],
                               inputs["secured"],
                               verbose=inputs["verbose"])
    if pyfos_auth.is_failed_login(session):
        print(
            "login failed because",
            session.get(pyfos_auth.CREDENTIAL_KEY)[pyfos_auth.LOGIN_ERROR_KEY])
        usage()
        sys.exit()

    brcd_util.exit_register(session)

    vfid = None
    if 'vfid' in inputs:
        vfid = inputs['vfid']

    if vfid is not None:
        pyfos_auth.vfid_set(session, vfid)

    dir_name = switch_config_util.get_dirname(inputs['ipaddr'])
    try:
        os.stat(dir_name)
    except OSError:
        os.mkdir(dir_name)

    dump_object(session, dir_name, pyfos_switch.fibrechannel_switch)
    dump_object(session, dir_name, pyfos_switchfcport.fibrechannel)
    dump_object(session, dir_name, pyfos_fabric.fabric_switch)
    dump_object(session, dir_name, pyfos_zone.defined_configuration)
    dump_object(session, dir_name, pyfos_zone.effective_configuration)

    print("done")

    pyfos_auth.logout(session)