Exemple #1
0
def main(argv):
    """
    This function shows the following sequence of operation.

    **Support for login/logout sequence for Sessionless**
        *login* returns a pseudo session without actual Login.
        *REST operation support* for GET Examples.
        *logout* no-operation logout.

    **Dummy session creation and operations**
        *Pseudo session* using dummy function without login.
        *REST operation support* for GET/PATCH examples.

    """
    # Login to the switch
    login_sessionless = example_login(sessionless=True)
    if pyfos_auth.is_failed_login(login_sessionless):
        print(
            "login failed because",
            login_sessionless.get(
                pyfos_auth.CREDENTIAL_KEY)[pyfos_auth.LOGIN_ERROR_KEY])
        sys.exit(3)
    print("Login to Switch with session-less option, Actually there is no ",
          "login done to switch.")

    # Using sessionless Session for operation
    print("\nGet the swithshow with session-less")
    fcobj = fibrechannel_switch.get(login_sessionless)
    pyfos_util.response_print(fcobj)

    # Sessionless Session logout(No-operation)
    pyfos_auth.logout(login_sessionless)
    print("\nLogout session-less based login session no-op.")

    # Dummy session to the switch
    pseudosession = dummy_session()
    print("\nGet swithshow using pseudo-session with session-less [Allowed].")
    fcobj = fibrechannel_switch.get(pseudosession)
    pyfos_util.response_print(fcobj)

    # Patch operation example.
    print("\nPatch using pseudo-session for session-less [Forbidden]")
    fcobjnew = fibrechannel_switch()
    fcobjnew.set_name(fcobj.peek_name())
    fcobjnew.set_user_friendly_name("mybanner")
    print("Patch with banner :", fcobjnew.peek_user_friendly_name())
    ret = fcobjnew.patch(pseudosession)
    pyfos_util.response_print(ret)

    # Revert the banner to original
    print("\nPatch using pseudo-session for session-less[Forbidden]")
    print("Revert Patch with banner :", fcobj.peek_user_friendly_name())
    fcobjnew.set_user_friendly_name(fcobj.peek_user_friendly_name())
    ret = fcobjnew.patch(pseudosession)
    pyfos_util.response_print(ret)
    print("No logout required for pseudo-session")
Exemple #2
0
def set_ag_mode(session, ag_mode):
    sw_obj = fibrechannel_switch()
    current_sw = fibrechannel_switch.get(session)
    if pyfos_util.is_failed_resp(current_sw):
        return current_sw

    sw_obj.set_name(current_sw.peek_name())
    sw_obj.set_ag_mode(ag_mode)
    # print(settings_obj)
    return sw_obj.patch(session)
Exemple #3
0
def modify_switch_ip_config_params(session,
                                   ip_addresses=None,
                                   gateways=None,
                                   subnet_mask=None):
    swobject = fibrechannel_switch()
    if ip_addresses is not None:
        swobject.set_ip_address_ip_address(ip_addresses)
    if gateways is not None:
        swobject.set_ip_static_gateway_list_ip_static_gateway(gateways)
    if subnet_mask is not None:
        swobject.set_subnet_mask(subnet_mask)
    result = _modify_switch_ip_config_params(session, swobject)
    return result
def main(argv):
    valid_options = ["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 "username" not in inputs:
        usage()
        sys.exit()
    username = inputs["username"]

    current_switch = pyfos_switch.fibrechannel_switch.get(session)

    switch = pyfos_switch.fibrechannel_switch()
    name = current_switch.peek_name()
    switch.set_name(name)
    switch.set_user_friendly_name(username)
    result = switch.patch(session)
    pyfos_util.response_print(result)

    pyfos_auth.logout(session)
def modify_fibrechannel_switch(session, name=None, dynamic_load_sharing=None):
    fibrechannel_switchObj = fibrechannel_switch()
    fibrechannel_switchObj.set_name(name)
    fibrechannel_switchObj.set_dynamic_load_sharing(dynamic_load_sharing)
    return _modify_fibrechannel_switch(session, fibrechannel_switchObj)
Exemple #6
0
def modify_fibrechannel_switch(session, name=None, lacp_system_priority=None):
    fibrechannel_switchObj = fibrechannel_switch()
    fibrechannel_switchObj.set_name(name)
    fibrechannel_switchObj.set_lacp_system_priority(lacp_system_priority)
    return _modify_fibrechannel_switch(session, fibrechannel_switchObj)
def main(argv):
    # Login to the switch
    print("\nLogin to the switch")
    session = example_login()
    if pyfos_auth.is_failed_login(session):
        print(
            "login failed because",
            session.get(pyfos_auth.CREDENTIAL_KEY)[pyfos_auth.LOGIN_ERROR_KEY])
        sys.exit(3)
    # Get an instance of auth token manager
    print("Get Auth Token Manager instance")
    examplemgrauthtoken = exampleTokenManager()

    # Display authtoken manager details
    print("Display the Auth Token Manager details.")
    examplemgrauthtoken.show()

    # Delete any existing authtoken
    ret = examplemgrauthtoken.delete(session)
    print("Delete Auth Token from the switch\nRet:")
    pyfos_util.response_print(ret)

    # Display authtoken manager details
    print("Display the Auth Token Manager details.")
    examplemgrauthtoken.show()

    # Generate the authtoken
    ret = examplemgrauthtoken.generateToken(session)
    print("Generate Auth Token from the switch\nRet:")
    pyfos_util.response_print(ret)

    # Display authtoken manager details
    print("Display the Auth Token Manager details.")
    examplemgrauthtoken.show()

    print("Get the swithshow with regular session")
    ret = fibrechannel_switch.get(session)
    pyfos_util.response_print(ret)

    # Session Logout
    pyfos_auth.logout(session)

    # Token based authentication session error scenario with default
    # password used and not None.
    print("AuthToken Login error scenario")
    tokensession = example_login(tokenArg=examplemgrauthtoken)
    if pyfos_auth.is_failed_login(tokensession):
        print(
            "Token based login failed because",
            tokensession.get(
                pyfos_auth.CREDENTIAL_KEY)[pyfos_auth.LOGIN_ERROR_KEY])

    print("AuthToken Login Success scenario.")
    # Token based authentication session Success scenario
    tokensession = example_login(password=None, tokenArg=examplemgrauthtoken)
    if pyfos_auth.is_failed_login(tokensession):
        print(
            "Token based login failed because",
            tokensession.get(
                pyfos_auth.CREDENTIAL_KEY)[pyfos_auth.LOGIN_ERROR_KEY])
        sys.exit(3)

    # Using Token Session for operation
    print("Get the swithshow with authToken based login session.")
    fcobj = fibrechannel_switch.get(tokensession)
    pyfos_util.response_print(fcobj)

    # Patch operation example.
    fcobjnew = fibrechannel_switch()
    fcobjnew.set_name(fcobj.peek_name())
    fcobjnew.set_user_friendly_name("mybanner")
    print("AuthToken login session patch with banner :",
          fcobjnew.peek_user_friendly_name())
    ret = fcobjnew.patch(tokensession)
    pyfos_util.response_print(ret)

    # Revert the banner to original
    print("AuthToken login session patch revert banner :",
          fcobj.peek_user_friendly_name())
    fcobjnew.set_user_friendly_name(fcobj.peek_user_friendly_name())
    ret = fcobjnew.patch(tokensession)
    pyfos_util.response_print(ret)

    print("AuthToken login session Logout")
    # Token Session logout
    pyfos_auth.logout(tokensession)