Пример #1
0
def _status5(scan_task):
    """Check Satellite status to get api_version and connectivity.

    :param scan_task: The scan task
    :returns: tuple (status_code, api_version or None)
    """
    client, user, password = get_sat5_client(scan_task)
    try:
        key = client.auth.login(user, password)
        client.auth.logout(key)
    except xmlrpc.client.Fault as xml_error:
        invalid_auth = 'Either the password or username is incorrect.'
        if invalid_auth in str(xml_error):
            raise SatelliteAuthException(str(xml_error))
        else:
            raise SatelliteException(str(xml_error))
    except xmlrpc.client.ProtocolError as protocol_error:
        raise SatelliteException(str(protocol_error))

    api_version = SATELLITE_VERSION_5
    status_code = codes.HTTP_200_OK  # pylint: disable=no-member
    return (status_code, api_version, SATELLITE_VERSION_5)
Пример #2
0
def _status6(scan_task):
    """Check Satellite status to get api_version and connectivity.

    :param scan_task: The scan task
    :returns: tuple (status_code, api_version or None)
    """
    status_url = 'https://{sat_host}:{port}/api/status'
    response, url = execute_request(scan_task, status_url)
    status_code = response.status_code
    api_version = None

    if status_code == codes.HTTP_200_OK:
        status_data = response.json()
        api_version = status_data.get('api_version')
    elif status_code == codes.HTTP_401_UNAUTHORIZED:
        err_msg = 'Unable to authenticate against ' + url
        raise SatelliteAuthException(err_msg)
    else:
        err_msg = 'Failure while attempting Satellite 6'
        ' status check at {} for task {} with status code {}.'.format(
            url, scan_task.id, status_code)
        raise SatelliteException(err_msg)
    return (status_code, api_version, SATELLITE_VERSION_6)
Пример #3
0
def mock_sat_auth_exception(param1):  # pylint: disable=unused-argument
    """Mock method to throw satellite auth error."""
    raise SatelliteAuthException()