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,
            False, template)
    if 'template' in inputs and 'reffcport' in inputs:
        switch_config_util.process_object(
                session, dir_name, pyfos_switchfcport.fibrechannel,
                False, template,
                [{"name": inputs['reffcport']}])
    else:
        switch_config_util.process_object(
                session, dir_name, pyfos_switchfcport.fibrechannel,
                False, template)
    switch_config_util.process_object(
            session, dir_name, pyfos_zone.defined_configuration,
            False, template)
    current_effective = pyfos_zone.effective_configuration.get(session)
    cfgsave.cfgsave(session, current_effective.peek_checksum())

    switch_config_util.process_object(
            session, dir_name, pyfos_zone.effective_configuration,
            False, template)

    pyfos_auth.logout(session)
Beispiel #2
0
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)
Beispiel #3
0
def main(argv):
    filters = ["zone_object"]
    inputs = brcd_util.parse(argv, zone_operation_parameters, filters,
                             validate)
    session = brcd_util.getsession(inputs)

    # Store the checksum before editing the zoneDB to use for the
    #  cfgsave at the end
    current_effective = pyfos_zone.effective_configuration.get(session)

    result = do_zone_object_expunge(session, inputs['utilobject'])
    pyfos_util.response_print(result)

    # If the expunge operation succeeds, perform an implicit cfgsave
    # If the expunge operation fails, it should get automatically aborted
    # in the FOS Zone module, so no need to abort the transaction.
    if pyfos_util.is_success_resp(result):
        result = cfgsave.cfgsave(session, current_effective.peek_checksum())

        # If the save operation fails, check to see if there is an open
        #  transaction. If there is, then abort the transaction
        if pyfos_util.is_failed_resp(result):
            print("Expunge succeeded, but the cfgSave failed.")
            current_effective = pyfos_zone.effective_configuration.get(session)
            if current_effective.peek_transaction_token() != 0:
                pyfos_util.response_print(result)
                print("\nAborting the transaction.")
                result = cfgabort.cfgabort(session)
                pyfos_util.response_print(result)

    pyfos_auth.logout(session)
Beispiel #4
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)