Fix relative import warnings from pylint
W0403 relative-import is no longer suppressed by pylint.rc Note: six.moves.urllib.request was considered a relative import from six.moves import urllib is considered valid. The code is updated to satisfy pylint and pep8. nfv_scenario_tests main.py still needs to use a relative import based on how it is invoked. Story: 2004515 Task: 28575 Change-Id: I3f576f3990352e9456fe3ee5d3a80cb1307f31e0 Signed-off-by: Al Bailey <Al.Bailey@windriver.com>
This commit is contained in:
parent
b27c6b86f6
commit
86601b800c
|
@ -4,9 +4,7 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
import json
|
||||
|
||||
from six.moves.urllib import error as urllib_error
|
||||
from six.moves.urllib import request as urllib_request
|
||||
from six.moves import urllib
|
||||
|
||||
from nfv_client.openstack.objects import Token
|
||||
|
||||
|
@ -37,7 +35,7 @@ def get_token(auth_uri, project_name, project_domain_name, username, password,
|
|||
try:
|
||||
url = auth_uri + "/auth/tokens"
|
||||
|
||||
request_info = urllib_request.Request(url)
|
||||
request_info = urllib.request.Request(url)
|
||||
request_info.add_header("Content-Type", "application/json")
|
||||
request_info.add_header("Accept", "application/json")
|
||||
|
||||
|
@ -63,7 +61,7 @@ def get_token(auth_uri, project_name, project_domain_name, username, password,
|
|||
|
||||
request_info.add_data(payload)
|
||||
|
||||
request = urllib_request.urlopen(request_info)
|
||||
request = urllib.request.urlopen(request_info)
|
||||
# Identity API v3 returns token id in X-Subject-Token
|
||||
# response header.
|
||||
token_id = request.info().getheader('X-Subject-Token')
|
||||
|
@ -71,10 +69,10 @@ def get_token(auth_uri, project_name, project_domain_name, username, password,
|
|||
request.close()
|
||||
return Token(response, token_id)
|
||||
|
||||
except urllib_error.HTTPError as e:
|
||||
except urllib.error.HTTPError as e:
|
||||
print(e)
|
||||
return None
|
||||
|
||||
except urllib_error.URLError as e:
|
||||
except urllib.error.URLError as e:
|
||||
print(e)
|
||||
return None
|
||||
|
|
|
@ -4,9 +4,8 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
import json
|
||||
from six.moves.urllib import error as urllib_error
|
||||
from six.moves.urllib import request as urllib_request
|
||||
from six.moves import http_client as httplib
|
||||
from six.moves import urllib
|
||||
|
||||
|
||||
def request(token_id, method, api_cmd, api_cmd_headers=None, api_cmd_payload=None):
|
||||
|
@ -18,7 +17,7 @@ def request(token_id, method, api_cmd, api_cmd_headers=None, api_cmd_payload=Non
|
|||
'transfer-encoding', 'upgrade']
|
||||
|
||||
try:
|
||||
request_info = urllib_request.Request(api_cmd)
|
||||
request_info = urllib.request.Request(api_cmd)
|
||||
request_info.get_method = lambda: method
|
||||
if token_id is not None:
|
||||
request_info.add_header("X-Auth-Token", token_id)
|
||||
|
@ -31,7 +30,7 @@ def request(token_id, method, api_cmd, api_cmd_headers=None, api_cmd_payload=Non
|
|||
if api_cmd_payload is not None:
|
||||
request_info.add_data(api_cmd_payload)
|
||||
|
||||
url_request = urllib_request.urlopen(request_info)
|
||||
url_request = urllib.request.urlopen(request_info)
|
||||
|
||||
headers = list() # list of tuples
|
||||
for key, value in url_request.info().items():
|
||||
|
@ -50,7 +49,7 @@ def request(token_id, method, api_cmd, api_cmd_headers=None, api_cmd_payload=Non
|
|||
|
||||
return response
|
||||
|
||||
except urllib_error.HTTPError as e:
|
||||
except urllib.error.HTTPError as e:
|
||||
headers = list()
|
||||
response_raw = dict()
|
||||
|
||||
|
@ -97,7 +96,7 @@ def request(token_id, method, api_cmd, api_cmd_headers=None, api_cmd_payload=Non
|
|||
response_raw))
|
||||
raise
|
||||
|
||||
except urllib_error.URLError as e:
|
||||
except urllib.error.URLError as e:
|
||||
print("Rest-API status=ERR, %s, %s, headers=%s, payload=%s"
|
||||
% (method, api_cmd, api_cmd_headers, api_cmd_payload,))
|
||||
raise
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
import os
|
||||
import sys
|
||||
import argparse
|
||||
import os
|
||||
from six.moves import urllib
|
||||
import sys
|
||||
|
||||
from six.moves.urllib import request as urllib_request
|
||||
from nfv_client import sw_update
|
||||
|
||||
|
||||
|
@ -156,9 +156,9 @@ def process_main(argv=sys.argv[1:]): # pylint: disable=dangerous-default-value
|
|||
|
||||
if args.debug:
|
||||
# Enable Debug
|
||||
handler = urllib_request.HTTPHandler(debuglevel=1)
|
||||
opener = urllib_request.build_opener(handler)
|
||||
urllib_request.install_opener(opener)
|
||||
handler = urllib.request.HTTPHandler(debuglevel=1)
|
||||
opener = urllib.request.build_opener(handler)
|
||||
urllib.request.install_opener(opener)
|
||||
|
||||
if args.os_auth_url is None:
|
||||
args.os_auth_url = os.environ.get('OS_AUTH_URL', None)
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
from nfv_common import debug
|
||||
|
||||
import _parsers
|
||||
from nfv_common.forensic import _parsers
|
||||
|
||||
DLOG = debug.debug_get_logger('forensic-evidence')
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
import _parsers
|
||||
from nfv_common.forensic import _parsers
|
||||
|
||||
|
||||
def forensic_initialize():
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
import _nfv_vim_parser
|
||||
from nfv_common.forensic import _nfv_vim_parser
|
||||
|
||||
_parsers = dict()
|
||||
|
||||
|
|
|
@ -4,15 +4,13 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
import json
|
||||
from six.moves.urllib import error as urllib_error
|
||||
from six.moves.urllib import request as urllib_request
|
||||
from six.moves import urllib
|
||||
|
||||
from nfv_common import debug
|
||||
|
||||
from nfv_plugins.nfvi_plugins.openstack.objects import Directory
|
||||
from nfv_plugins.nfvi_plugins.openstack.objects import OPENSTACK_SERVICE
|
||||
from nfv_plugins.nfvi_plugins.openstack.objects import PLATFORM_SERVICE
|
||||
from nfv_plugins.nfvi_plugins.openstack.objects import SERVICE_CATEGORY
|
||||
from nfv_plugins.nfvi_plugins.openstack.objects import Directory
|
||||
from nfv_plugins.nfvi_plugins.openstack.objects import Token
|
||||
|
||||
DLOG = debug.debug_get_logger('nfv_plugins.nfvi_plugins.openstack')
|
||||
|
@ -30,7 +28,7 @@ def get_token(directory):
|
|||
else:
|
||||
url = directory.auth_uri + "/v3/auth/tokens"
|
||||
|
||||
request_info = urllib_request.Request(url)
|
||||
request_info = urllib.request.Request(url)
|
||||
request_info.add_header("Content-Type", "application/json")
|
||||
request_info.add_header("Accept", "application/json")
|
||||
|
||||
|
@ -62,7 +60,7 @@ def get_token(directory):
|
|||
}}}})
|
||||
request_info.add_data(payload)
|
||||
|
||||
request = urllib_request.urlopen(request_info)
|
||||
request = urllib.request.urlopen(request_info)
|
||||
# Identity API v3 returns token id in X-Subject-Token
|
||||
# response header.
|
||||
token_id = request.info().getheader('X-Subject-Token')
|
||||
|
@ -70,11 +68,11 @@ def get_token(directory):
|
|||
request.close()
|
||||
return Token(response, directory, token_id)
|
||||
|
||||
except urllib_error.HTTPError as e:
|
||||
except urllib.error.HTTPError as e:
|
||||
DLOG.error("%s" % e)
|
||||
return None
|
||||
|
||||
except urllib_error.URLError as e:
|
||||
except urllib.error.URLError as e:
|
||||
DLOG.error("%s" % e)
|
||||
return None
|
||||
|
||||
|
|
|
@ -3,13 +3,12 @@
|
|||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
from six.moves import http_client as httplib
|
||||
import json
|
||||
import re
|
||||
from six.moves import http_client as httplib
|
||||
from six.moves import urllib
|
||||
import socket
|
||||
import struct
|
||||
from six.moves.urllib import error as urllib_error
|
||||
from six.moves.urllib import request as urllib_request
|
||||
|
||||
import BaseHTTPServer
|
||||
import SocketServer
|
||||
|
@ -17,14 +16,15 @@ import SocketServer
|
|||
from nfv_common import debug
|
||||
from nfv_common import selobj
|
||||
from nfv_common import timers
|
||||
|
||||
from nfv_common.helpers import coroutine
|
||||
from nfv_common.helpers import Object
|
||||
from nfv_common.helpers import Result
|
||||
|
||||
from nfv_plugins.nfvi_plugins.openstack.openstack_log import log_error
|
||||
from nfv_plugins.nfvi_plugins.openstack.openstack_log import log_info
|
||||
from nfv_plugins.nfvi_plugins.openstack.exceptions import OpenStackException
|
||||
from nfv_plugins.nfvi_plugins.openstack.exceptions import OpenStackRestAPIException
|
||||
from nfv_plugins.nfvi_plugins.openstack.openstack_log import log_error
|
||||
from nfv_plugins.nfvi_plugins.openstack.openstack_log import log_info
|
||||
|
||||
DLOG = debug.debug_get_logger('nfv_plugins.nfvi_plugins.openstack.rest_api')
|
||||
|
||||
|
@ -299,7 +299,7 @@ def _rest_api_request(token_id, method, api_cmd, api_cmd_headers=None,
|
|||
start_ms = timers.get_monotonic_timestamp_in_ms()
|
||||
|
||||
try:
|
||||
request_info = urllib_request.Request(api_cmd)
|
||||
request_info = urllib.request.Request(api_cmd)
|
||||
request_info.get_method = lambda: method
|
||||
request_info.add_header("X-Auth-Token", token_id)
|
||||
request_info.add_header("Accept", "application/json")
|
||||
|
@ -316,11 +316,11 @@ def _rest_api_request(token_id, method, api_cmd, api_cmd_headers=None,
|
|||
api_cmd_payload))
|
||||
|
||||
# Enable Debug
|
||||
# handler = urllib_request.HTTPHandler(debuglevel=1)
|
||||
# opener = urllib_request.build_opener(handler)
|
||||
# urllib_request.install_opener(opener)
|
||||
# handler = urllib.request.HTTPHandler(debuglevel=1)
|
||||
# opener = urllib.request.build_opener(handler)
|
||||
# urllib.request.install_opener(opener)
|
||||
|
||||
request = urllib_request.urlopen(request_info)
|
||||
request = urllib.request.urlopen(request_info)
|
||||
|
||||
headers = list() # list of tuples
|
||||
for key, value in request.info().items():
|
||||
|
@ -352,7 +352,7 @@ def _rest_api_request(token_id, method, api_cmd, api_cmd_headers=None,
|
|||
response=response_raw,
|
||||
execution_time=elapsed_secs))
|
||||
|
||||
except urllib_error.HTTPError as e:
|
||||
except urllib.error.HTTPError as e:
|
||||
headers = list()
|
||||
response_raw = dict()
|
||||
|
||||
|
@ -413,7 +413,7 @@ def _rest_api_request(token_id, method, api_cmd, api_cmd_headers=None,
|
|||
api_cmd_payload, e.code, str(e),
|
||||
str(e), headers, response_raw, reason)
|
||||
|
||||
except urllib_error.URLError as e:
|
||||
except urllib.error.URLError as e:
|
||||
now_ms = timers.get_monotonic_timestamp_in_ms()
|
||||
elapsed_ms = now_ms - start_ms
|
||||
|
||||
|
|
|
@ -5,20 +5,20 @@
|
|||
#
|
||||
import argparse
|
||||
import config
|
||||
import time
|
||||
import socket
|
||||
from six.moves import http_client as httplib
|
||||
import socket
|
||||
import time
|
||||
|
||||
from nfv_plugins.nfvi_plugins.openstack import openstack
|
||||
from nfv_plugins.nfvi_plugins.openstack import ceilometer
|
||||
from nfv_plugins.nfvi_plugins.openstack import cinder
|
||||
from nfv_plugins.nfvi_plugins.openstack import exceptions
|
||||
from nfv_plugins.nfvi_plugins.openstack import glance
|
||||
from nfv_plugins.nfvi_plugins.openstack import guest
|
||||
from nfv_plugins.nfvi_plugins.openstack import heat
|
||||
from nfv_plugins.nfvi_plugins.openstack import keystone
|
||||
from nfv_plugins.nfvi_plugins.openstack import neutron
|
||||
from nfv_plugins.nfvi_plugins.openstack import nova
|
||||
from nfv_plugins.nfvi_plugins.openstack import heat
|
||||
from nfv_plugins.nfvi_plugins.openstack import openstack
|
||||
from nfv_plugins.nfvi_plugins.openstack import sysinv
|
||||
|
||||
|
||||
|
@ -455,10 +455,10 @@ def do_unit_tests(test_set=None, rest_api_debug=False, test_config=None):
|
|||
"""
|
||||
if rest_api_debug:
|
||||
# Enable debugging of request and response headers for rest-api calls
|
||||
from six.moves.urllib import request as urllib_request
|
||||
handler = urllib_request.HTTPHandler(debuglevel=1)
|
||||
opener = urllib_request.build_opener(handler)
|
||||
urllib_request.install_opener(opener)
|
||||
from six.moves import urllib
|
||||
handler = urllib.request.HTTPHandler(debuglevel=1)
|
||||
opener = urllib.request.build_opener(handler)
|
||||
urllib.request.install_opener(opener)
|
||||
|
||||
platform_directory = openstack.get_directory(
|
||||
config, openstack.SERVICE_CATEGORY.PLATFORM)
|
||||
|
|
|
@ -23,7 +23,8 @@ from nfv_common import debug
|
|||
from nfv_common import forensic
|
||||
from nfv_plugins.nfvi_plugins import config
|
||||
|
||||
import tests
|
||||
import tests # pylint: disable=relative-import
|
||||
|
||||
|
||||
DLOG = debug.debug_get_logger('nfv_tests')
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ from nfv_plugins.nfvi_plugins import config
|
|||
from nfv_plugins.nfvi_plugins.openstack import nova
|
||||
from nfv_plugins.nfvi_plugins.openstack import openstack
|
||||
|
||||
import _alarms
|
||||
import _event_logs
|
||||
from tests import _alarms
|
||||
from tests import _event_logs
|
||||
|
||||
DLOG = debug.debug_get_logger('nfv_tests.instances')
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import subprocess
|
|||
from nfv_vim import database
|
||||
from nfv_vim import tables
|
||||
|
||||
from . import testcase
|
||||
from . import testcase # noqa: H304
|
||||
|
||||
|
||||
class TestNFVDatabaseUpgrade(testcase.NFVTestCase):
|
||||
|
|
|
@ -12,20 +12,19 @@ from nfv_vim import host_fsm
|
|||
from nfv_vim import nfvi
|
||||
from nfv_vim import objects
|
||||
|
||||
from nfv_vim.nfvi.objects import v1 as nfvi_objects
|
||||
from nfv_vim.objects import HOST_PERSONALITY
|
||||
from nfv_vim.tables._table import Table
|
||||
from nfv_vim.tables._host_table import HostTable
|
||||
from nfv_vim.tables._host_group_table import HostGroupTable
|
||||
from nfv_vim.tables._host_aggregate_table import HostAggregateTable
|
||||
from nfv_vim.tables._instance_table import InstanceTable
|
||||
from nfv_vim.tables._instance_type_table import InstanceTypeTable
|
||||
from nfv_vim.tables._host_group_table import HostGroupTable
|
||||
from nfv_vim.tables._host_table import HostTable
|
||||
from nfv_vim.tables._image_table import ImageTable
|
||||
from nfv_vim.tables._instance_group_table import InstanceGroupTable
|
||||
from nfv_vim.tables._instance_table import InstanceTable
|
||||
from nfv_vim.tables._instance_type_table import InstanceTypeTable
|
||||
from nfv_vim.tables._table import Table
|
||||
|
||||
from nfv_vim.nfvi.objects import v1 as nfvi_objects
|
||||
|
||||
from . import testcase
|
||||
from . import utils
|
||||
from . import testcase # noqa: H304
|
||||
from . import utils # noqa: H304
|
||||
|
||||
|
||||
def fake_event_issue(a, b, c, d):
|
||||
|
|
|
@ -9,12 +9,12 @@ import uuid
|
|||
from nfv_vim import nfvi
|
||||
from nfv_vim import objects
|
||||
|
||||
from nfv_vim.directors._instance_director import InstanceDirector
|
||||
from nfv_vim.tables._image_table import ImageTable
|
||||
from nfv_vim.tables._table import Table
|
||||
from nfv_vim.directors._instance_director import InstanceDirector
|
||||
|
||||
from . import testcase
|
||||
from . import utils
|
||||
from . import testcase # noqa: H304
|
||||
from . import utils # noqa: H304
|
||||
|
||||
# Constants
|
||||
_audit_interval = 330
|
||||
|
|
|
@ -5,9 +5,11 @@
|
|||
#
|
||||
import mock
|
||||
import os
|
||||
from . import testcase
|
||||
|
||||
from nfv_client import shell
|
||||
|
||||
from . import testcase # noqa: H304
|
||||
|
||||
|
||||
class TestNFVClientShell(testcase.NFVTestCase):
|
||||
|
||||
|
|
|
@ -3,12 +3,14 @@
|
|||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
import mock
|
||||
import kubernetes
|
||||
from kubernetes.client.rest import ApiException
|
||||
from . import testcase
|
||||
import mock
|
||||
|
||||
from nfv_plugins.nfvi_plugins.clients import kubernetes_client
|
||||
|
||||
from . import testcase # noqa: H304
|
||||
|
||||
|
||||
def mock_load_kube_config(path):
|
||||
return
|
||||
|
|
|
@ -13,22 +13,22 @@ from nfv_vim import host_fsm
|
|||
from nfv_vim import nfvi
|
||||
from nfv_vim import objects
|
||||
|
||||
from nfv_vim.objects import SW_UPDATE_APPLY_TYPE
|
||||
from nfv_vim.objects import SW_UPDATE_INSTANCE_ACTION
|
||||
from nfv_vim.objects import SW_UPDATE_ALARM_RESTRICTION
|
||||
from nfv_vim.objects import HOST_PERSONALITY
|
||||
from nfv_vim.objects import SW_UPDATE_APPLY_TYPE
|
||||
from nfv_vim.objects import SW_UPDATE_ALARM_RESTRICTION
|
||||
from nfv_vim.objects import SW_UPDATE_INSTANCE_ACTION
|
||||
from nfv_vim.objects import SwPatch
|
||||
from nfv_vim.tables._table import Table
|
||||
from nfv_vim.tables._host_table import HostTable
|
||||
from nfv_vim.tables._host_group_table import HostGroupTable
|
||||
from nfv_vim.tables._host_aggregate_table import HostAggregateTable
|
||||
from nfv_vim.tables._instance_table import InstanceTable
|
||||
from nfv_vim.tables._instance_group_table import InstanceGroupTable
|
||||
from nfv_vim.strategy._strategy import strategy_rebuild_from_dict
|
||||
from nfv_vim.strategy._strategy import SwPatchStrategy
|
||||
from nfv_vim.tables._host_aggregate_table import HostAggregateTable
|
||||
from nfv_vim.tables._host_group_table import HostGroupTable
|
||||
from nfv_vim.tables._host_table import HostTable
|
||||
from nfv_vim.tables._instance_group_table import InstanceGroupTable
|
||||
from nfv_vim.tables._instance_table import InstanceTable
|
||||
from nfv_vim.tables._table import Table
|
||||
|
||||
from . import testcase
|
||||
from . import utils
|
||||
from . import testcase # noqa: H304
|
||||
from . import utils # noqa: H304
|
||||
|
||||
|
||||
DEBUG_PRINTING = False
|
||||
|
|
|
@ -30,8 +30,8 @@ from nfv_vim.strategy._strategy import strategy_rebuild_from_dict
|
|||
|
||||
from nfv_vim.nfvi.objects.v1 import UPGRADE_STATE
|
||||
|
||||
from . import testcase
|
||||
from . import utils
|
||||
from . import testcase # noqa: H304
|
||||
from . import utils # noqa: H304
|
||||
|
||||
|
||||
DEBUG_PRINTING = False
|
||||
|
|
|
@ -5,10 +5,9 @@
|
|||
#
|
||||
import pecan
|
||||
|
||||
import _config
|
||||
import _hooks
|
||||
|
||||
from nfv_vim.api import acl
|
||||
from nfv_vim.api import _config
|
||||
from nfv_vim.api import _hooks
|
||||
|
||||
|
||||
def get_pecan_config():
|
||||
|
|
|
@ -3,15 +3,14 @@
|
|||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
from six.moves import http_client as httplib
|
||||
import pecan
|
||||
from pecan import rest
|
||||
from six.moves import http_client as httplib
|
||||
from wsme import types as wsme_types
|
||||
import wsmeext.pecan as wsme_pecan
|
||||
|
||||
from .._link import Link
|
||||
|
||||
from nfv_vim.api.controllers.v1 import APIController
|
||||
from nfv_vim.api._link import Link
|
||||
|
||||
|
||||
class Root(wsme_types.Base):
|
||||
|
|
|
@ -3,17 +3,16 @@
|
|||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
from six.moves import http_client as httplib
|
||||
import pecan
|
||||
from pecan import rest
|
||||
from six.moves import http_client as httplib
|
||||
from wsme import types as wsme_types
|
||||
import wsmeext.pecan as wsme_pecan
|
||||
|
||||
from ..._link import Link
|
||||
|
||||
from nfv_vim.api.controllers.v1 import openstack
|
||||
from nfv_vim.api.controllers.v1 import orchestration
|
||||
from nfv_vim.api.controllers.v1 import virtualised_resources
|
||||
from nfv_vim.api._link import Link
|
||||
|
||||
|
||||
class APIVersion(wsme_types.Base):
|
||||
|
|
|
@ -3,14 +3,14 @@
|
|||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
from six.moves import http_client as httplib
|
||||
import pecan
|
||||
from pecan import rest
|
||||
from six.moves import http_client as httplib
|
||||
from wsme import types as wsme_types
|
||||
import wsmeext.pecan as wsme_pecan
|
||||
|
||||
from ...._link import Link
|
||||
from nfv_vim.api.controllers.v1.openstack._heat_api import HeatAPI
|
||||
from nfv_vim.api._link import Link
|
||||
|
||||
|
||||
class OpenStackDescription(wsme_types.Base):
|
||||
|
|
|
@ -3,15 +3,15 @@
|
|||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
from six.moves import http_client as httplib
|
||||
import pecan
|
||||
from pecan import rest
|
||||
from six.moves import http_client as httplib
|
||||
from wsme import types as wsme_types
|
||||
import wsmeext.pecan as wsme_pecan
|
||||
|
||||
from ...._link import Link
|
||||
from nfv_vim.api.controllers.v1.orchestration.sw_update import SwPatchAPI
|
||||
from nfv_vim.api.controllers.v1.orchestration.sw_update import SwUpgradeAPI
|
||||
from nfv_vim.api._link import Link
|
||||
|
||||
|
||||
class OrchestrationDescription(wsme_types.Base):
|
||||
|
|
|
@ -3,17 +3,15 @@
|
|||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
from six.moves import http_client as httplib
|
||||
import pecan
|
||||
from pecan import rest
|
||||
from six.moves import http_client as httplib
|
||||
from wsme import types as wsme_types
|
||||
import wsmeext.pecan as wsme_pecan
|
||||
|
||||
from ....._link import Link
|
||||
|
||||
from nfv_common import debug
|
||||
|
||||
from nfv_vim.api.controllers.v1.orchestration.sw_update._sw_update_strategy import SwPatchStrategyAPI
|
||||
from nfv_vim.api._link import Link
|
||||
|
||||
DLOG = debug.debug_get_logger('nfv_vim.api.sw_patch')
|
||||
|
||||
|
|
|
@ -3,17 +3,15 @@
|
|||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
from six.moves import http_client as httplib
|
||||
import pecan
|
||||
from pecan import rest
|
||||
from six.moves import http_client as httplib
|
||||
from wsme import types as wsme_types
|
||||
import wsmeext.pecan as wsme_pecan
|
||||
|
||||
from ....._link import Link
|
||||
|
||||
from nfv_common import debug
|
||||
|
||||
from nfv_vim.api.controllers.v1.orchestration.sw_update._sw_update_strategy import SwUpgradeStrategyAPI
|
||||
from nfv_vim.api._link import Link
|
||||
|
||||
DLOG = debug.debug_get_logger('nfv_vim.api.sw_upgrade')
|
||||
|
||||
|
|
|
@ -3,17 +3,17 @@
|
|||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
from six.moves import http_client as httplib
|
||||
import pecan
|
||||
from pecan import rest
|
||||
from six.moves import http_client as httplib
|
||||
from wsme import types as wsme_types
|
||||
import wsmeext.pecan as wsme_pecan
|
||||
|
||||
from ...._link import Link
|
||||
from nfv_vim.api.controllers.v1.virtualised_resources._computes_api import ComputesAPI
|
||||
from nfv_vim.api.controllers.v1.virtualised_resources._networks_api import NetworksAPI
|
||||
from nfv_vim.api.controllers.v1.virtualised_resources._image_api import ImageAPI
|
||||
from nfv_vim.api.controllers.v1.virtualised_resources._networks_api import NetworksAPI
|
||||
from nfv_vim.api.controllers.v1.virtualised_resources._volume_api import VolumeAPI
|
||||
from nfv_vim.api._link import Link
|
||||
|
||||
|
||||
class VirtualisedResourcesDescription(wsme_types.Base):
|
||||
|
|
|
@ -4,15 +4,13 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
import json
|
||||
from six.moves.urllib import error as urllib_error
|
||||
from six.moves.urllib import request as urllib_request
|
||||
from six.moves import urllib
|
||||
|
||||
from nfv_common import debug
|
||||
|
||||
from nfv_vim.api.openstack._objects import OPENSTACK_SERVICE
|
||||
from nfv_plugins.nfvi_plugins.openstack.objects import PLATFORM_SERVICE
|
||||
from nfv_plugins.nfvi_plugins.openstack.objects import SERVICE_CATEGORY
|
||||
from nfv_vim.api.openstack._objects import Directory
|
||||
from nfv_vim.api.openstack._objects import OPENSTACK_SERVICE
|
||||
from nfv_vim.api.openstack._objects import Token
|
||||
|
||||
DLOG = debug.debug_get_logger('nfv_vim.api.openstack')
|
||||
|
@ -30,7 +28,7 @@ def validate_token(directory, admin_token, token_id):
|
|||
else:
|
||||
url = directory.auth_uri + "/v3/auth/tokens"
|
||||
|
||||
request_info = urllib_request.Request(url)
|
||||
request_info = urllib.request.Request(url)
|
||||
request_info.add_header("Content-Type", "application/json")
|
||||
request_info.add_header("Accept", "application/json")
|
||||
request_info.add_header("X-Auth-Token", admin_token.get_id())
|
||||
|
@ -57,7 +55,7 @@ def validate_token(directory, admin_token, token_id):
|
|||
|
||||
request_info.add_data(payload)
|
||||
|
||||
request = urllib_request.urlopen(request_info)
|
||||
request = urllib.request.urlopen(request_info)
|
||||
# Identity API v3 returns token id in X-Subject-Token
|
||||
# response header.
|
||||
token_id = request.info().getheader('X-Subject-Token')
|
||||
|
@ -65,11 +63,11 @@ def validate_token(directory, admin_token, token_id):
|
|||
request.close()
|
||||
return Token(response, directory, token_id)
|
||||
|
||||
except urllib_error.HTTPError as e:
|
||||
except urllib.error.HTTPError as e:
|
||||
DLOG.error("%s" % e)
|
||||
return None
|
||||
|
||||
except urllib_error.URLError as e:
|
||||
except urllib.error.URLError as e:
|
||||
DLOG.error("%s" % e)
|
||||
return None
|
||||
|
||||
|
@ -86,7 +84,7 @@ def get_token(directory):
|
|||
else:
|
||||
url = directory.auth_uri + "/v3/auth/tokens"
|
||||
|
||||
request_info = urllib_request.Request(url)
|
||||
request_info = urllib.request.Request(url)
|
||||
request_info.add_header("Content-Type", "application/json")
|
||||
request_info.add_header("Accept", "application/json")
|
||||
|
||||
|
@ -118,7 +116,7 @@ def get_token(directory):
|
|||
}}}})
|
||||
request_info.add_data(payload)
|
||||
|
||||
request = urllib_request.urlopen(request_info)
|
||||
request = urllib.request.urlopen(request_info)
|
||||
# Identity API v3 returns token id in X-Subject-Token
|
||||
# response header.
|
||||
token_id = request.info().getheader('X-Subject-Token')
|
||||
|
@ -126,11 +124,11 @@ def get_token(directory):
|
|||
request.close()
|
||||
return Token(response, directory, token_id)
|
||||
|
||||
except urllib_error.HTTPError as e:
|
||||
except urllib.error.HTTPError as e:
|
||||
DLOG.error("%s" % e)
|
||||
return None
|
||||
|
||||
except urllib_error.URLError as e:
|
||||
except urllib.error.URLError as e:
|
||||
DLOG.error("%s" % e)
|
||||
return None
|
||||
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
from six.moves import http_client as httplib
|
||||
from six.moves.urllib import error as urllib_error
|
||||
from six.moves.urllib import request as urllib_request
|
||||
from six.moves import urllib
|
||||
|
||||
from nfv_common import debug
|
||||
|
||||
|
@ -21,12 +20,12 @@ def rest_api_request(token, method, url, headers=None, body=None):
|
|||
'transfer-encoding', 'upgrade']
|
||||
|
||||
try:
|
||||
request_info = urllib_request.Request(url)
|
||||
request_info = urllib.request.Request(url)
|
||||
request_info.get_method = lambda: method
|
||||
|
||||
if headers is not None:
|
||||
for header_type, header_value in headers.items():
|
||||
# Allow the Content-Length to be set by urllib2
|
||||
# Allow the Content-Length to be set by urllib
|
||||
if 'Content-Length' != header_type and 'Host' != header_type:
|
||||
request_info.add_header(header_type, header_value)
|
||||
|
||||
|
@ -39,11 +38,11 @@ def rest_api_request(token, method, url, headers=None, body=None):
|
|||
request_info.add_data(body)
|
||||
|
||||
# Enable Debug
|
||||
# handler = urllib_request.HTTPHandler(debuglevel=1)
|
||||
# opener = urllib_request.build_opener(handler)
|
||||
# urllib_request.install_opener(opener)
|
||||
# handler = urllib.request.HTTPHandler(debuglevel=1)
|
||||
# opener = urllib.request.build_opener(handler)
|
||||
# urllib.request.install_opener(opener)
|
||||
|
||||
request = urllib_request.urlopen(request_info)
|
||||
request = urllib.request.urlopen(request_info)
|
||||
|
||||
headers = list() # list of tuples
|
||||
for key, value in request.info().items():
|
||||
|
@ -55,7 +54,7 @@ def rest_api_request(token, method, url, headers=None, body=None):
|
|||
request.close()
|
||||
return httplib.OK, headers, response
|
||||
|
||||
except urllib_error.HTTPError as e:
|
||||
except urllib.error.HTTPError as e:
|
||||
if e.fp is not None:
|
||||
headers = list() # list of tuples
|
||||
for key, value in e.fp.info().items():
|
||||
|
|
|
@ -34,7 +34,6 @@ load-plugins=
|
|||
# W0231 super-init-not-called
|
||||
# W0235 useless-super-delegation
|
||||
# W0401 wildcard-import
|
||||
# W0403 relative-import warning
|
||||
# W0404 reimported
|
||||
# W0511 fixme
|
||||
# W0603 Using the global statement warning
|
||||
|
@ -45,7 +44,7 @@ load-plugins=
|
|||
# W0703 broad except warning
|
||||
# W1401 anomalous-backslash-in-string
|
||||
disable=C, R, W0120, W0125, W0212, W0221, W0223, W0231, W0235,
|
||||
W0401, W0403, W0404, W0511, W0603, W0612, W0613, W0621, W0622, W0703, W1401
|
||||
W0401, W0404, W0511, W0603, W0612, W0613, W0621, W0622, W0703, W1401
|
||||
|
||||
|
||||
[REPORTS]
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
|
14
nfv/tox.ini
14
nfv/tox.ini
|
@ -73,12 +73,9 @@ verbosity=2
|
|||
# H501: Do not use self.__dict__ for string formatting
|
||||
# - flake8 codes -
|
||||
# F821 undefined name 'unicode' (python3 specific)
|
||||
# - bugbear codes -
|
||||
# B007 Loop control variable 'X' not used within the loop body. If this is intended, start the name with an underscore.
|
||||
ignore = E121,E122,E123,E124,E126,E127,E128,E129,E501,
|
||||
H104,H306,H404,H405,H501,
|
||||
F821,
|
||||
B007
|
||||
# F823 local variable referenced before assignment
|
||||
# F841 local variable 'e' is assigned to but never used
|
||||
ignore = E121,E122,E123,E124,E126,E127,E128,E129,E501,H104,H306,H404,H405,H501,F821,F823,F841
|
||||
# H106 Don’t put vim configuration in source files (off by default).
|
||||
# H203 Use assertIs(Not)None to check for None (off by default).
|
||||
# TODO: enable: H904 Delay string interpolations at logging calls (off by default).
|
||||
|
@ -89,10 +86,7 @@ max-line-length = 84
|
|||
basepython = python3.5
|
||||
usedevelop = False
|
||||
skip_install = True
|
||||
deps =
|
||||
hacking
|
||||
flake8-bugbear
|
||||
flake8<3.6.0
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
commands =
|
||||
flake8 {[nfv]nfv_base_dir}
|
||||
|
||||
|
|
Loading…
Reference in New Issue