コード例 #1
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)
コード例 #2
0
ファイル: brcd_zone_util.py プロジェクト: sun-deepv/Pyfostest
def zone_name_members_func(session, inputs, usage, func):
    # comment zone helper to execute & commit
    # name, and member based operations
    if "name" not in inputs:
        print("*** missing input: name")
        pyfos_auth.logout(session)
        brcd_util.full_usage(usage)
        sys.exit()
    name = inputs["name"]

    if "members" not in inputs:
        print("*** missing input: members")
        pyfos_auth.logout(session)
        brcd_util.full_usage(usage)
        sys.exit()
    members = inputs["members"]

    current_effective = pyfos_zone.effective_configuration.get(session)

    print("executing", func.__name__)
    result = func(session, name, members)
    if pyfos_util.is_failed_resp(result):
        pyfos_util.response_print(result)
        print(func.__name__, "failed. Aborting transaction.")
        result = cfgabort.cfgabort(session)
        pyfos_util.response_print(result)
    else:
        pyfos_util.response_print(result)
        print(func.__name__, "succeeded. Saving transaction.")
        result = cfgsave.cfgsave(session, current_effective.peek_checksum())
        if pyfos_util.is_failed_resp(result):
            pyfos_util.response_print(result)
            print(func.__name__, "failed. Aborting transaction.")
            result = cfgabort.cfgabort(session)
            pyfos_util.response_print(result)
コード例 #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)
コード例 #4
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)
コード例 #5
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)
        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)
コード例 #6
0
ファイル: license_install.py プロジェクト: brocade/pyfos
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, valid_options)
        sys.exit()

    brcd_util.exit_register(session)

    if "name" not in inputs:
        print("License key is required")
        brcd_util.full_usage(usage, valid_options)
        sys.exit()

    l_obj = license_parameters()
    l_obj.set_action("install")
    l_obj.set_name(inputs["name"])
    l_rsp_obj = l_obj.post(session)
    if ("info-message" in l_rsp_obj and
       l_rsp_obj["info-message"] ==
       "Switch version is lower than the object"):
        pyfos_util.response_print(l_rsp_obj)
        pyfos_auth.logout(session)
        sys.exit()
    else:
        pyfos_util.response_print(l_rsp_obj)

    pyfos_auth.logout(session)
コード例 #7
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)
コード例 #8
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)
コード例 #9
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, 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)

    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. \n\nAborting transaction.")
            result = cfgabort.cfgabort(session)
            pyfos_util.response_print(result)

    pyfos_auth.logout(session)
コード例 #10
0
def main(argv):
    filters = ["name", "enabled_state"]
    inputs = brcd_util.parse(argv, fibrechannel, filters, validate)

    fcObject = inputs['utilobject']
    if fcObject.peek_enabled_state() == 1:
        fcObject.set_enabled_state(2)
    elif fcObject.peek_enabled_state() == 0:
        fcObject.set_enabled_state(6)
    else:
        print("Invalid value for enabled_state")
        brcd_util.full_usage(usage, filters)
        sys.exit()
    session = brcd_util.getsession(inputs)

    result = fcObject.patch(session)
    pyfos_util.response_print(result)

    pyfos_auth.logout(session)
コード例 #11
0
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)
コード例 #12
0
def main(argv):
    valid_options = ["name", "enable", "disable", "show"]
    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)

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

    config = 0

    if "enable" not in inputs and "disable" not in inputs:
        pyfos_auth.logout(session)
        brcd_util.full_usage(usage, valid_options)
        sys.exit()
    if "enable" in inputs and "disable" in inputs:
        pyfos_auth.logout(session)
        brcd_util.full_usage(usage, valid_options)
        sys.exit()
    if "enable" in inputs:
        config = 1
    if "disable" in inputs:
        config = 2

    validport = pyfos_switchfcport.fibrechannel.get(session, name)
    if pyfos_util.is_failed_resp(validport):
        pyfos_util.response_print(validport)
        pyfos_auth.logout(session)
        sys.exit()

    if config in (1, 2):
        if config == 1:
            print("Trying to enable resilience on port ", name)
            newport = changeResilienceStateOfPort(session, name, 1)
        elif config == 2:
            print("Trying to disable the resilience on port ", name)
            newport = changeResilienceStateOfPort(session, name, 0)
    else:
        newport = pyfos_switchfcport.fibrechannel.get(session, name)
        if pyfos_util.is_failed_resp(newport):
            pyfos_util.test_explicit_result_failed(newport)
            sys.exit()

    cr_enabled = newport.peek_credit_recovery_enabled()
    cr_active = newport.peek_credit_recovery_active()

    if ((cr_active == 1) and (cr_enabled == 1)):
        print("Credit Recovery is enabled and active on port ", name)
    elif ((cr_active == 0) and (cr_enabled == 1)):
        print("Credit Recovery is enabled, but not active on port ", name)
    elif cr_enabled == 0:
        print("Credit Recovery is disabled on port ", name)

    fec_enabled = newport.peek_fec_enabled()
    fec_active = newport.peek_fec_active()

    if ((fec_active == 1) and (fec_enabled == 1)):
        print("Forward Error Correction is enabled and active on port ", name)
    elif ((fec_active == 0) and (fec_enabled == 1)):
        print(
            "Forward Error Correction is enabled but \
                                    not active on port ", name)
    elif fec_enabled == 0:
        print("Forward Error Correction is disabled on port ", name)

    pyfos_auth.logout(session)
コード例 #13
0
def main(argv):
    valid_options = [
        "hostname", "username", "userpassword", "filename", "protocol",
        "acceptEULA", "displayEULA"
    ]
    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)

    fci = firmwarecleaninstall()

    if "protocol" not in inputs:
        print("Missing protocol")
        usage()
        pyfos_auth.logout(session)
        sys.exit()
    else:
        fci.set_protocol(inputs["protocol"])

    if "hostname" not in inputs:
        print("Missing hostname")
        usage()
        pyfos_auth.logout(session)
        sys.exit()
    else:
        fci.set_host(inputs["hostname"])

    if "username" not in inputs:
        print("Missing username")
        usage()
        pyfos_auth.logout(session)
        sys.exit()
    else:
        fci.set_user_name(inputs["username"])

    if "userpassword" not in inputs:
        password = getpass.getpass()
        fci.set_password(password)
    else:
        fci.set_password(inputs["userpassword"])

    if "filename" not in inputs:
        print("Missing filename")
        usage()
        pyfos_auth.logout(session)
        sys.exit()
    else:
        fci.set_remote_directory(inputs["filename"])

    if "acceptEULA" in inputs or "displayEULA" in inputs:
        if "acceptEULA" in inputs:
            fci.set_eula_action("accept-eula")
        else:
            fci.set_eula_action("display-eula")
    else:
        fci.set_eula_action("decline_eula")

    fci_rsp_obj = fci.post(session)
    if ("info-message" in fci_rsp_obj and fci_rsp_obj["info-message"]
            == "Switch version is lower than the object"):
        pyfos_util.response_print(fci_rsp_obj)
        pyfos_auth.logout(session)
        sys.exit()
    if pyfos_util.is_failed_resp(fci_rsp_obj):
        print("Firmwarecleaninstall operation failed.\n")
        pyfos_util.response_print(fci_rsp_obj)
        pyfos_auth.logout(session)
    else:
        pyfos_util.response_print(fci_rsp_obj)
コード例 #14
0
ファイル: zoning_to_yml.py プロジェクト: db0/brocade-ansible
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)

    print("aliases:")
    for alias in defined_zone.peek_alias():
        print("  - name:", alias["alias-name"])
        print("    members:")
        for member in alias["member-entry"]["alias-entry-name"]:
            print("      - ", member)

    print()

    print("zones:")
    for zone in defined_zone.peek_zone():
        print("  - name:", zone["zone-name"])
        if len(zone["member-entry"]["entry-name"]) > 0:
            print("    members:")
            for member in zone["member-entry"]["entry-name"]:
                print("      - ", member)
        if len(zone["member-entry"]["principal-entry-name"]) > 0:
            print("    principal_members:")
            for member in zone["member-entry"]["principal-entry-name"]:
                print("      - ", member)

    print()

    print("cfgs:")
    for cfg in defined_zone.peek_cfg():
        print("  - name:", cfg["cfg-name"])
        print("    members:")
        for member in cfg["member-zone"]["zone-name"]:
            print("      - ", member)

    # 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)
コード例 #15
0
ファイル: configdownload.py プロジェクト: brocade/pyfos
def main(argv):
    valid_options = [
        "hostname", "username", "userpassword", "filename", "protocol", "type"
    ]
    inputs = brcd_util.generic_input(argv,
                                     usage,
                                     valid_options,
                                     sessionless=False)

    if 'vfid' in inputs:
        print("-f/--vfid is a no-op for config operations. Please remove.")
        usage()
        sys.exit()

    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, sessionless=False)
        sys.exit()

    brcd_util.exit_register(session)

    cobj = config()

    if "protocol" not in inputs:
        print("Missing protocol")
        usage()
        pyfos_auth.logout(session)
        sys.exit()
    else:
        cobj.set_protocol(inputs["protocol"])

    if "hostname" not in inputs:
        print("Missing hostname")
        usage()
        pyfos_auth.logout(session)
        sys.exit()
    else:
        cobj.set_host(inputs["hostname"])

    if "username" not in inputs:
        print("Missing username")
        usage()
        pyfos_auth.logout(session)
        sys.exit()
    else:
        cobj.set_user_name(inputs["username"])

    if "userpassword" not in inputs:
        password = getpass.getpass()
        cobj.set_password(password)
    else:
        cobj.set_password(inputs["userpassword"])

    if "filename" not in inputs:
        print("Missing filename")
        usage()
        pyfos_auth.logout(session)
        sys.exit()
    else:
        cobj.set_path(inputs["filename"])

    if "type" not in inputs or ("type" in inputs and inputs["type"] != "all"
                                and inputs["type"] != "vf"
                                and "fid" not in inputs["type"]
                                and "map" not in inputs["type"]):
        print("Missing type")
        usage()
        pyfos_auth.logout(session)
        sys.exit()
    else:
        cobj.set_type(inputs["type"])

    cobj.set_upload(False)

    config_rsp_obj = cobj.post(session)
    if ("info-message" in config_rsp_obj and config_rsp_obj["info-message"]
            == "Switch version is lower than the object"):
        pyfos_util.response_print(config_rsp_obj)
        pyfos_auth.logout(session)
        sys.exit()
    if pyfos_util.is_failed_resp(config_rsp_obj):
        print("configdownload operation failed.\n")
        pyfos_util.response_print(config_rsp_obj)
        pyfos_auth.logout(session)
    else:
        pyfos_util.response_print(config_rsp_obj)
コード例 #16
0
def main(argv):
    valid_options = [
        "hostname", "username", "userpassword", "filename", "protocol",
        "activate", "stage"
    ]
    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)

    fd = firmwaredownload()

    if "protocol" not in inputs:
        print("Missing protocol")
        usage()
        pyfos_auth.logout(session)
        sys.exit()
    else:
        fd.set_protocol(inputs["protocol"])

    if "hostname" not in inputs:
        print("Missing hostname")
        usage()
        pyfos_auth.logout(session)
        sys.exit()
    else:
        fd.set_host(inputs["hostname"])

    if "username" not in inputs:
        print("Missing username")
        usage()
        pyfos_auth.logout(session)
        sys.exit()
    else:
        fd.set_user_name(inputs["username"])

    if "userpassword" not in inputs:
        password = getpass.getpass()
        fd.set_password(password)
    else:
        fd.set_password(inputs["userpassword"])

    if "filename" not in inputs:
        print("Missing filename")
        usage()
        pyfos_auth.logout(session)
        sys.exit()
    else:
        fd.set_remote_directory(inputs["filename"])

    if "activate" in inputs:
        fd.set_activate(inputs["activate"])

    if "stage" in inputs:
        fd.set_stage(inputs["stage"])

    fd_rsp_obj = fd.post(session)
    if ("info-message" in fd_rsp_obj and fd_rsp_obj["info-message"]
            == "Switch version is lower than the object"):
        pyfos_util.response_print(fd_rsp_obj)
        pyfos_auth.logout(session)
        sys.exit()
    if pyfos_util.is_failed_resp(fd_rsp_obj):
        print("Firmwaredownload operation failed.\n")
        pyfos_util.response_print(fd_rsp_obj)
    else:
        fd_show_status(session, fd_rsp_obj)

    pyfos_auth.logout(session)