Example #1
0
def singleton_get(login, password, fos_ip_addr, module_name, obj_name, fos_version, is_https, auth, vfid, result, ssh_hostkeymust):
    """
        retrieve existing user config configuration 

        :param fos_ip_addr: ip address of FOS switch
        :type fos_ip_addr: str
        :param is_https: indicate to use HTTP or HTTPS
        :type is_https: bool
        :param auth: authorization struct from login
        :type struct: dict
        :param result: dict to keep track of execution msgs
        :type result: dict
        :return: code to indicate failure or success
        :rtype: int
        :return: dict of ipfilter policy configurations
        :rtype: dict
    """
    full_url, validate_certs = full_url_get(is_https,
                                            fos_ip_addr,
                                            REST_PREFIX + module_name + "/" + obj_name)

    ret, resp = url_get_to_dict(fos_ip_addr, is_https, auth, vfid,
                                result, full_url)

    if ret == -2:
        # return empty dict. GET isn't supported
        result["daniel1"] = "here"
        return 0, ({"Response" : {obj_name: {}}})

    result["daniel2"] = "why"
    return ret, resp
Example #2
0
def system_get(login, password, fos_ip_addr, fos_version, is_https, auth, vfid, result):
    """
        retrieve existing snmp system configurations

        :param fos_ip_addr: ip address of FOS switch
        :type fos_ip_addr: str
        :param is_https: indicate to use HTTP or HTTPS
        :type is_https: bool
        :param auth: authorization struct from login
        :type auth: dict
        :param result: dict to keep track of execution msgs
        :type result: dict
        :return: code to indicate failure or success
        :rtype: int
        :return: dict of switch configurations
        :rtype: dict
    """
    full_url, validate_certs = full_url_get(is_https,
                                            fos_ip_addr,
                                            REST_SNMP_SYSTEM)

    rtype, rdict = url_get_to_dict(fos_ip_addr, is_https, auth, vfid,
                           result, full_url)

    if rtype != 0:
        result["failed"] = True
        result["msg"] = "API failed to return data"
        return -1, None

    return 0, rdict
def fabric_get(login, password, fos_ip_addr, fos_version, is_https, auth, vfid,
               result, ssh_hostkeymust):
    """
        retrieve existing switch configurations

        :param fos_ip_addr: ip address of FOS switch
        :type fos_ip_addr: str
        :param is_https: indicate to use HTTP or HTTPS
        :type is_https: bool
        :param auth: authorization struct from login
        :type auth: dict
        :param result: dict to keep track of execution msgs
        :type result: dict
        :return: code to indicate failure or success
        :rtype: int
        :return: dict of fabric configurations
        :rtype: dict
    """
    full_fabric_url, validate_certs = full_url_get(is_https, fos_ip_addr,
                                                   REST_FABRIC)

    rtype, rdict = url_get_to_dict(fos_ip_addr, is_https, auth, vfid, result,
                                   full_fabric_url)
    if rtype != 0:
        result["failed"] = True
        result["msg"] = "API failed to return data"
        return -1, None

    rssh, sshstr = ssh_and_configure(login, password, fos_ip_addr,
                                     ssh_hostkeymust, "iodshow", "showcommand")
    if rssh == 0:
        if "IOD is not set" in sshstr:
            rdict["Response"]["fabric"]["in-order-delivery-enabled"] = "false"
        elif "IOD is set" in sshstr:
            rdict["Response"]["fabric"]["in-order-delivery-enabled"] = "true"
        else:
            result["failed"] = True
            result["msg"] = "IOD returned unknown string. " + sshstr
            return -1, None

    enabled_err, enabled, priority_err, priority = fabric_principal(
        login, password, fos_ip_addr, ssh_hostkeymust)
    if enabled_err == None:
        if enabled:
            rdict["Response"]["fabric"]["fabric-principal-enabled"] = "true"
        else:
            rdict["Response"]["fabric"]["fabric-principal-enabled"] = "false"
    else:
        result["failed"] = True
        result["msg"] = enabled_err
        return -1, None

    if priority_err == None:
        rdict["Response"]["fabric"]["fabric-principal-priority"] = priority
    else:
        result["failed"] = True
        result["msg"] = priority_err
        return -1, None

    return 0, rdict
def fc_switch_get(login, password, fos_ip_addr, fos_version, is_https, auth,
                  vfid, result, ssh_hostkeymust, timeout):
    """
        retrieve existing switch configurations

        :param fos_ip_addr: ip address of FOS switch
        :type fos_ip_addr: str
        :param is_https: indicate to use HTTP or HTTPS
        :type is_https: bool
        :param auth: authorization struct from login
        :type auth: dict
        :param result: dict to keep track of execution msgs
        :type result: dict
        :return: code to indicate failure or success
        :rtype: int
        :return: dict of switch configurations
        :rtype: dict
    """
    full_fc_switch_url, validate_certs = full_url_get(is_https, fos_ip_addr,
                                                      REST_SWITCH)

    rtype, rdict = url_get_to_dict(fos_ip_addr, is_https, auth, vfid, result,
                                   full_fc_switch_url, timeout)

    if rtype != 0:
        result["failed"] = True
        result["msg"] = "API failed to return data"
        return -1, None

    result["fos_version"] = fos_version
    result["fos_version_check"] = fos_version < "v9.0"
    if fos_version < "v9.0":
        rssh, sshstr = ssh_and_configure(login, password, fos_ip_addr,
                                         ssh_hostkeymust, "dlsshow",
                                         "showcommand")
        if rssh == 0:
            if "DLS is not set with Lossless disabled" in sshstr or "Error: This command is not supported in AG mode" in sshstr:
                rdict["Response"]["fibrechannel-switch"][
                    "dynamic-load-sharing"] = "disabled"
            elif "DLS is set with Lossless disabled" in sshstr:
                rdict["Response"]["fibrechannel-switch"][
                    "dynamic-load-sharing"] = "dls"
            elif "DLS is set with Lossless enabled, Two-hop Lossless disabled" in sshstr:
                rdict["Response"]["fibrechannel-switch"][
                    "dynamic-load-sharing"] = "lossless-dls"
            elif "DLS is set with Two-hop Lossless enabled" in sshstr:
                rdict["Response"]["fibrechannel-switch"][
                    "dynamic-load-sharing"] = "two-hop-lossless-dls"
            else:
                result["failed"] = True
                result["msg"] = "DLS returned unknown string"
                return -1, None

    return 0, rdict
Example #5
0
def singleton_get(login, password, fos_ip_addr, module_name, obj_name,
                  fos_version, is_https, auth, vfid, result, ssh_hostkeymust,
                  timeout):
    """
        retrieve existing user config configuration 

        :param fos_ip_addr: ip address of FOS switch
        :type fos_ip_addr: str
        :param is_https: indicate to use HTTP or HTTPS
        :type is_https: bool
        :param auth: authorization struct from login
        :type struct: dict
        :param result: dict to keep track of execution msgs
        :type result: dict
        :return: code to indicate failure or success
        :rtype: int
        :return: dict of ipfilter policy configurations
        :rtype: dict
    """
    if module_name == "brocade_chassis" and obj_name == "chassis":
        return chassis_get(login, password, fos_ip_addr, fos_version, is_https,
                           auth, vfid, result, ssh_hostkeymust, timeout)

    if module_name == "brocade_fibrechannel_configuration" and obj_name == "fabric":
        return fabric_get(login, password, fos_ip_addr, fos_version, is_https,
                          auth, vfid, result, ssh_hostkeymust, timeout)

    if module_name == "brocade_fibrechannel_configuration" and obj_name == "port_configuration":
        return port_configuration_get(login, password, fos_ip_addr,
                                      fos_version, is_https, auth, vfid,
                                      result, ssh_hostkeymust, timeout)

    # get is not support for these modules. Just return empty
    if module_name == "brocade_security" and obj_name == "security_certificate_action":
        return 0, ({"Response": {str_to_yang(obj_name): {}}})
    if module_name == "brocade_security" and obj_name == "security_certificate_generate":
        return 0, ({"Response": {str_to_yang(obj_name): {}}})
    if module_name == "brocade_security" and obj_name == "sshutil_public_key_action":
        return 0, ({"Response": {str_to_yang(obj_name): {}}})

    full_url, validate_certs = full_url_get(
        is_https, fos_ip_addr, REST_PREFIX + module_name + "/" + obj_name)

    ret, resp = url_get_to_dict(fos_ip_addr, is_https, auth, vfid, result,
                                full_url, timeout)

    if ret == ERROR_LIST_EMPTY:
        # return empty dict. GET isn't supported
        return 0, ({"Response": {str_to_yang(obj_name): {}}})

    return ret, resp
def port_configuration_get(login, password, fos_ip_addr, fos_version, is_https,
                           auth, vfid, result, ssh_hostkeymust, timeout):
    """
        retrieve existing port configurations

        :param fos_ip_addr: ip address of FOS switch
        :type fos_ip_addr: str
        :param is_https: indicate to use HTTP or HTTPS
        :type is_https: bool
        :param auth: authorization struct from login
        :type auth: dict
        :param result: dict to keep track of execution msgs
        :type result: dict
        :return: code to indicate failure or success
        :rtype: int
        :return: dict of fabric configurations
        :rtype: dict
    """
    full_port_config_url, validate_certs = full_url_get(
        is_https, fos_ip_addr, REST_PORT_CONFIGURATION)

    rtype, rdict = url_get_to_dict(fos_ip_addr, is_https, auth, vfid, result,
                                   full_port_config_url, timeout)
    if rtype != 0:
        result["failed"] = True
        result["msg"] = "API failed to return data"
        return -1, None

    rssh, sshstr = ssh_and_configure(login, password, fos_ip_addr,
                                     ssh_hostkeymust, "creditrecovmode --show",
                                     "showcommand")
    if rssh == 0:
        if "Internal port credit recovery is Disabled" in sshstr:
            rdict["Response"]["port-configuration"][
                "credit-recovery-mode"] = "off"
        elif "Internal port credit recovery is Enabled with LrOnly" in sshstr:
            rdict["Response"]["port-configuration"][
                "credit-recovery-mode"] = "onLrOnly"
        elif "Internal port credit recovery is Enabled with LrThresh" in sshstr:
            rdict["Response"]["port-configuration"][
                "credit-recovery-mode"] = "onLrThresh"
        elif "Not supported on this platform" in sshstr:
            result["credit_recovery_mode"] = "Not supported on this platform"
        else:
            result["failed"] = True
            result["msg"] = "credit-recovery-mode returned unknown string"
            return -1, None

    return 0, rdict
Example #7
0
def system_get(login, password, fos_ip_addr, fos_version, is_https, auth, vfid,
               result):
    """
        retrieve existing snmp system configurations

        :param fos_ip_addr: ip address of FOS switch
        :type fos_ip_addr: str
        :param is_https: indicate to use HTTP or HTTPS
        :type is_https: bool
        :param auth: authorization struct from login
        :type auth: dict
        :param result: dict to keep track of execution msgs
        :type result: dict
        :return: code to indicate failure or success
        :rtype: int
        :return: dict of switch configurations
        :rtype: dict
    """
    full_url, validate_certs = full_url_get(is_https, fos_ip_addr,
                                            REST_SNMP_SYSTEM)

    rtype, rdict = url_get_to_dict(fos_ip_addr, is_https, auth, vfid, result,
                                   full_url)

    if rtype != 0:
        result["failed"] = True
        result["msg"] = "API failed to return data"
        return -1, None


#    result["fos_version"] = fos_version
#    result["fos_version_check"] = fos_version < "v9.0"
#    if fos_version < "v9.0":
#        rssh, sshstr = ssh_and_configure(login, password, fos_ip_addr, False, "dlsshow", "showcommand")
#        if rssh == 0:
#            if "DLS is set with Lossless disabled" in sshstr:
#                rdict["Response"]["fibrechannel-switch"]["dynamic-load-sharing"] = "disabled"
#            elif "DLS is set with Lossless enabled, Two-hop Lossless disabled" in sshstr:
#                rdict["Response"]["fibrechannel-switch"]["dynamic-load-sharing"] = "lossless-dls"
#            elif "DLS is set with Two-hop Lossless enabled" in sshstr:
#                rdict["Response"]["fibrechannel-switch"]["dynamic-load-sharing"] = "two-hop-lossless-dls"
#            else:
#                result["failed"] = True
#                result["msg"] = "DLS returned unknown string"
#                return -1, None

    return 0, rdict
Example #8
0
def chassis_get(login, password, fos_ip_addr, fos_version, is_https, auth,
                vfid, result, ssh_hostkeymust, timeout):
    """
        retrieve existing switch configurations

        :param fos_ip_addr: ip address of FOS switch
        :type fos_ip_addr: str
        :param is_https: indicate to use HTTP or HTTPS
        :type is_https: bool
        :param auth: authorization struct from login
        :type auth: dict
        :param result: dict to keep track of execution msgs
        :type result: dict
        :return: code to indicate failure or success
        :rtype: int
        :return: dict of chassis configurations
        :rtype: dict
    """
    full_chassis_url, validate_certs = full_url_get(is_https, fos_ip_addr,
                                                    REST_CHASSIS)

    rtype, rdict = url_get_to_dict(fos_ip_addr, is_https, auth, vfid, result,
                                   full_chassis_url, timeout)
    if rtype != 0:
        result["failed"] = True
        result["msg"] = "API failed to return data"
        return -1, None

    rssh, sshstr = ssh_and_configure(login, password, fos_ip_addr,
                                     ssh_hostkeymust, "timeout", "showcommand")
    if rssh == 0:
        if "Current IDLE Timeout is " in sshstr:
            text = sshstr[len("Current IDLE Timeout is "):]
            timeout = text.split(" ")
            rdict["Response"]["chassis"]["telnet-timeout"] = timeout[0]
        elif "Shell Idle Timeout is " in sshstr:
            text = sshstr[len("Shell Idle Timeout is "):]
            timeout = text.split(" ")
            rdict["Response"]["chassis"]["telnet-timeout"] = timeout[0]
        else:
            result["failed"] = True
            result["msg"] = "telnet_timeout returned unknown string"
            return -1, None

    return 0, rdict
Example #9
0
def audit_get(fos_ip_addr, is_https, auth, vfid, result):
    """
        retrieve existing audit configurations

        :param fos_ip_addr: ip address of FOS switch
        :type fos_ip_addr: str
        :param is_https: indicate to use HTTP or HTTPS
        :type is_https: bool
        :param auth: authorization struct from login
        :type struct: dict
        :param result: dict to keep track of execution msgs
        :type result: dict
        :return: code to indicate failure or success
        :rtype: int
        :return: dict of clock server configurations
        :rtype: dict
    """
    full_url, validate_certs = full_url_get(is_https, fos_ip_addr,
                                            REST_LOGGING_AUDIT)

    return url_get_to_dict(fos_ip_addr, is_https, auth, vfid, result, full_url)
Example #10
0
def fc_port_get(fos_ip_addr, is_https, auth, vfid, result):
    """
        retrieve existing port configurations

        :param fos_ip_addr: ip address of FOS switch
        :type fos_ip_addr: str
        :param is_https: indicate to use HTTP or HTTPS
        :type is_https: bool
        :param auth: authorization struct from login
        :type auth: dict
        :param result: dict to keep track of execution msgs
        :type result: dict
        :return: code to indicate failure or success
        :rtype: int
        :return: list of dict of port configurations
        :rtype: list
    """
    full_fc_port_url = (HTTPS if is_https else HTTP) + fos_ip_addr + REST_FC

    return url_get_to_dict(fos_ip_addr, is_https, auth, vfid, result,
                           full_fc_port_url)
Example #11
0
def ipfilter_policy_get(fos_ip_addr, is_https, auth, vfid, result, timeout):
    """
        retrieve existing ipfilter policy configuration 

        :param fos_ip_addr: ip address of FOS switch
        :type fos_ip_addr: str
        :param is_https: indicate to use HTTP or HTTPS
        :type is_https: bool
        :param auth: authorization struct from login
        :type struct: dict
        :param result: dict to keep track of execution msgs
        :type result: dict
        :return: code to indicate failure or success
        :rtype: int
        :return: dict of ipfilter policy configurations
        :rtype: dict
    """
    full_url, validate_certs = full_url_get(is_https, fos_ip_addr,
                                            REST_IPFILTER_POLICY)

    return (url_get_to_dict(fos_ip_addr, is_https, auth, vfid, result,
                            full_url, timeout))
Example #12
0
def effective_get(fos_ip_addr, is_https, auth, vfid, result):
    """
        retrieve all of effective Zone Database

        :param fos_ip_addr: ip address of FOS switch
        :type fos_ip_addr: str
        :param is_https: indicate to use HTTP or HTTPS
        :type is_https: bool
        :param auth: authorization struct from login
        :type auth: dict
        :param result: dict to keep track of execution msgs
        :type result: dict
        :return: code to indicate failure or success
        :rtype: int
        :return: dict of full effective Zone DB content
        :rtype: dict
    """
    full_effective_url, validate_certs = full_url_get(is_https, fos_ip_addr,
                                                      REST_EFFECTIVE)

    return url_get_to_dict(fos_ip_addr, is_https, auth, vfid, result,
                           full_effective_url)
Example #13
0
def cfg_get(fos_ip_addr, is_https, auth, vfid, result):
    """
        retrieve existing cfgs

        :param fos_ip_addr: ip address of FOS switch
        :type fos_ip_addr: str
        :param is_https: indicate to use HTTP or HTTPS
        :type is_https: bool
        :param auth: authorization struct from login
        :type auth: dict
        :param result: dict to keep track of execution msgs
        :type result: dict
        :return: code to indicate failure or success
        :rtype: int
        :return: dict of cfg content
        :rtype: dict
    """
    full_defined_url, validate_certs = full_url_get(is_https, fos_ip_addr,
                                                    REST_DEFINED + "/cfg")

    return url_get_to_dict(fos_ip_addr, is_https, auth, vfid, result,
                           full_defined_url)
Example #14
0
def defined_get(fos_ip_addr, is_https, auth, vfid, result):
    """
        retrieve all of defined Zone Database

        :param fos_ip_addr: ip address of FOS switch
        :type fos_ip_addr: str
        :param is_https: indicate to use HTTP or HTTPS
        :type is_https: bool
        :param auth: authorization struct from login
        :type auth: dict
        :param result: dict to keep track of execution msgs
        :type result: dict
        :return: code to indicate failure or success
        :rtype: int
        :return: dict of full defined Zone DB content
        :rtype: dict
    """
    full_defined_url = (HTTPS if is_https else HTTP) +\
        fos_ip_addr + REST_DEFINED

    return url_get_to_dict(fos_ip_addr, is_https, auth, vfid, result,
                           full_defined_url)
Example #15
0
def ipfilter_rule_get(fos_ip_addr, is_https, auth, vfid, result):
    """
        retrieve existing ipfilter rule configuration 

        :param fos_ip_addr: ip address of FOS switch
        :type fos_ip_addr: str
        :param is_https: indicate to use HTTP or HTTPS
        :type is_https: bool
        :param auth: authorization struct from login
        :type struct: dict
        :param result: dict to keep track of execution msgs
        :type result: dict
        :return: code to indicate failure or success
        :rtype: int
        :return: dict of ipfilter rule configurations
        :rtype: dict
    """
    full_url = (HTTPS if is_https else HTTP) +\
        fos_ip_addr + REST_IPFILTER_RULE

    return (url_get_to_dict(fos_ip_addr, is_https, auth, vfid, result,
                            full_url))
Example #16
0
def fc_port_stats_get(fos_ip_addr, is_https, auth, vfid, result):
    """
        retrieve existing port stats

        :param fos_ip_addr: ip address of FOS switch
        :type fos_ip_addr: str
        :param is_https: indicate to use HTTP or HTTPS
        :type is_https: bool
        :param auth: authorization struct from login
        :type auth: dict
        :param result: dict to keep track of execution msgs
        :type result: dict
        :return: code to indicate failure or success
        :rtype: int
        :return: list of dict of port stats
        :rtype: list
    """
    full_fc_port_url, validate_certs = full_url_get(is_https, fos_ip_addr,
                                                    REST_FC_STATS)

    return url_get_to_dict(fos_ip_addr, is_https, auth, vfid, result,
                           full_fc_port_url)
Example #17
0
def clock_server_get(fos_ip_addr, is_https, auth, vfid, result):
    """
        retrieve existing clock-server configurations

        :param fos_ip_addr: ip address of FOS switch
        :type fos_ip_addr: str
        :param is_https: indicate to use HTTP or HTTPS
        :type is_https: bool
        :param auth: authorization struct from login
        :type struct: dict
        :param result: dict to keep track of execution msgs
        :type result: dict
        :return: code to indicate failure or success
        :rtype: int
        :return: dict of clock server configurations
        :rtype: dict
    """
    full_cs_url = (HTTPS if is_https else HTTP) +\
        fos_ip_addr + REST_CLOCK_SERVER

    return url_get_to_dict(fos_ip_addr, is_https, auth, vfid, result,
                           full_cs_url)
Example #18
0
def cfgname_checksum_get(fos_ip_addr, is_https, auth, vfid, result):
    """
        Gets the current cfgname and checksum of the effective config

        :param fos_ip_addr: fos switch ip address
        :type fos_ip_addr: str
        :param is_https: indicate to use HTTPS or HTTP
        :type fos_password: Bool
        :param auth: authorization struct at the time of login
        :type auth: dict
        :return: -1 if failed or 0 for success
        :rtype: int
        :return: name of the active_cfg or None if failure
        :rtype: str
        :return: returns checksum or 0 if failure
        :rtype: str
    """
    full_effective_url, validate_certs = full_url_get(is_https,
                                                      fos_ip_addr,
                                                      REST_EFFECTIVE)

    ret_code, effective_resp = url_get_to_dict(fos_ip_addr, is_https,
                                               auth, vfid, result,
                                               full_effective_url)
    if ret_code == -1:
        result["failed"] = True
        result["msg"] = "url_get_to_dict failed"
        return -1, None, 0

#    result["cfgname_checksum_resp"] = effective_resp

    effective_config = effective_resp["Response"]["effective-configuration"]

    cfgname = effective_config["cfg-name"]\
        if "cfg-name" in effective_config else None

    return 0, cfgname, effective_config["checksum"]
Example #19
0
def login(fos_ip_addr, fos_user_name, fos_password, is_https, throttle,
          result):
    """
        login to the fos switch at ip address specified

        :param fos_ip_addr: fos switch ip address
        :type fos_ip_addr: str
        :param fos_user_name: login name
        :type fos_user_name: str
        :param fos_password: password
        :type fos_password: password
        :param is_https: indicate to use HTTPS or HTTP
        :type fos_password: Bool
        :param throttle: throttle delay
        :type fos_password: float
        :return: returned header, None if not successfully logged in
        :rtype: dict
    """
    full_login_url = (HTTPS if is_https else HTTP) + fos_ip_addr + REST_LOGIN
    logininfo = fos_user_name + ":" + fos_password
    login_encoded = base64.b64encode(logininfo.encode())

    credential = {
        "Authorization": "Basic " + login_encoded.decode(),
        "User-Agent": "Rest-Conf"
    }
    try:
        login_resp = ansible_urls.open_url(full_login_url,
                                           headers=credential,
                                           method="POST")
    except urllib_error.HTTPError as e:
        result["login_resp_code"] = e.code
        result["login_resp_reason"] = e.reason
        ret_code, root_dict = bsn_xmltodict(result, e.read())
        result["login_resp_data"] = root_dict
        result["failed"] = True
        result["msg"] = "failed to login"
        return -1, None, None

    full_switch_url = (HTTPS if is_https else HTTP) + fos_ip_addr + REST_SWITCH

    auth = {}
    auth["auth"] = login_resp.info()["Authorization"]
    if throttle == None:
        auth["throttle"] = DEFAULT_THROTTLE
    else:
        auth["throttle"] = throttle

    # get fos version from the default switch
    rtype, rdict = url_get_to_dict(fos_ip_addr, is_https, auth, -1, result,
                                   full_switch_url)
    if rtype != 0:
        result["failed"] = True
        result["msg"] = "API failed to return switch firmware version"
        logout(fos_ip_addr, is_https, auth, result)
        return -1, None, None

    time.sleep(auth["throttle"] * 2)

    return 0, auth, rdict["Response"]["fibrechannel-switch"][
        "firmware-version"]
Example #20
0
def login(fos_ip_addr, fos_user_name, fos_password, is_https, throttle, result, timeout):
    """
        login to the fos switch at ip address specified

        :param fos_ip_addr: fos switch ip address
        :type fos_ip_addr: str
        :param fos_user_name: login name
        :type fos_user_name: str
        :param fos_password: password
        :type fos_password: password
        :param is_https: indicate to use HTTPS or HTTP
        :type fos_password: Bool
        :param throttle: throttle delay
        :type fos_password: float
        :return: returned header, None if not successfully logged in
        :rtype: dict
    """
    full_login_url, validate_certs = full_url_get(is_https,
                                                  fos_ip_addr,
                                                  REST_LOGIN)
    logininfo = fos_user_name + ":" + fos_password
    login_encoded = base64.b64encode(logininfo.encode())

    credential = {"Authorization": "Basic " + login_encoded.decode(),
                  "User-Agent": "Rest-Conf"}

    retval, eret, edict, login_resp = url_helper(full_login_url, None, "POST", None, result, validate_certs, timeout, credential=credential)
    if retval == ERROR_GENERIC:
        if eret == ERROR_SERVER_BUSY:
            if throttle == None:
                time.sleep(DEFAULT_THROTTLE)
            else:
                time.sleep(throttle)
            retval, eret, edict, login_resp = url_helper(full_login_url, None, "POST", None, result, validate_certs, timeout, credential=credential)
            if retval == ERROR_GENERIC:
                return eret, None, None
        else:
            return eret, None, None

    full_switch_url, validate_certs = full_url_get(is_https,
                                                   fos_ip_addr,
                                                   REST_SWITCH)

    auth = {}
    auth["auth"] = login_resp.info()["Authorization"]
    if throttle == None:
        auth["throttle"] = DEFAULT_THROTTLE
    else:
        auth["throttle"] = throttle

    # get fos version from the default switch
    rtype, rdict = url_get_to_dict(fos_ip_addr, is_https, auth, -1,
                                           result, full_switch_url, timeout)
    if rtype != 0:
        result["failed"] = True
        result["msg"] = "API failed to return switch firmware version"
        logout(fos_ip_addr, is_https, auth, result, timeout)
        return -1, None, None

#    time.sleep(auth["throttle"] * 2)

    return 0, auth, rdict["Response"]["fibrechannel-switch"]["firmware-version"]