use urlparse from six
- six provides compatibility support for urlparse. lets use it. - cleanup import lines to be consistent. Change-Id: I655b64888a29dc1f34e51216f06b83e84fe25970
This commit is contained in:
parent
0ecfe09075
commit
5418ee4f01
@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
import collections
|
import collections
|
||||||
import itertools
|
import itertools
|
||||||
import urlparse
|
|
||||||
|
|
||||||
|
from six.moves.urllib import parse as urlparse
|
||||||
from stevedore import extension
|
from stevedore import extension
|
||||||
|
|
||||||
from ceilometer.openstack.common import context
|
from ceilometer.openstack.common import context
|
||||||
|
@ -17,10 +17,9 @@
|
|||||||
"""Rest alarm notifier."""
|
"""Rest alarm notifier."""
|
||||||
|
|
||||||
import eventlet
|
import eventlet
|
||||||
import requests
|
|
||||||
import six.moves.urllib.parse as urlparse
|
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
import requests
|
||||||
|
from six.moves.urllib import parse as urlparse
|
||||||
|
|
||||||
from ceilometer.alarm import notifier
|
from ceilometer.alarm import notifier
|
||||||
from ceilometer.openstack.common.gettextutils import _
|
from ceilometer.openstack.common.gettextutils import _
|
||||||
|
@ -17,10 +17,10 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
"""Inspector for collecting data over SNMP"""
|
"""Inspector for collecting data over SNMP"""
|
||||||
|
|
||||||
import urlparse
|
from pysnmp.entity.rfc3413.oneliner import cmdgen
|
||||||
|
from six.moves.urllib import parse as urlparse
|
||||||
|
|
||||||
from ceilometer.hardware.inspector import base
|
from ceilometer.hardware.inspector import base
|
||||||
from pysnmp.entity.rfc3413.oneliner import cmdgen
|
|
||||||
|
|
||||||
|
|
||||||
class SNMPException(Exception):
|
class SNMPException(Exception):
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
import urlparse
|
|
||||||
|
from six.moves.urllib import parse as urlparse
|
||||||
|
|
||||||
from ceilometer.openstack.common import timeutils
|
from ceilometer.openstack.common import timeutils
|
||||||
from ceilometer import sample
|
from ceilometer import sample
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
import abc
|
import abc
|
||||||
|
|
||||||
import six
|
import six
|
||||||
from six.moves.urllib import parse as url_parse
|
from six.moves.urllib import parse as urlparse
|
||||||
from stevedore import driver as _driver
|
from stevedore import driver as _driver
|
||||||
|
|
||||||
from ceilometer.central import plugin
|
from ceilometer.central import plugin
|
||||||
@ -47,8 +47,8 @@ class _Base(plugin.CentralPollster):
|
|||||||
|
|
||||||
parse_url = network_utils.urlsplit(resource)
|
parse_url = network_utils.urlsplit(resource)
|
||||||
|
|
||||||
params = url_parse.parse_qs(parse_url.query)
|
params = urlparse.parse_qs(parse_url.query)
|
||||||
parts = url_parse.ParseResult(parse_url.scheme,
|
parts = urlparse.ParseResult(parse_url.scheme,
|
||||||
parse_url.netloc,
|
parse_url.netloc,
|
||||||
parse_url.path,
|
parse_url.path,
|
||||||
None,
|
None,
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
import requests
|
import requests
|
||||||
import six
|
import six
|
||||||
from six.moves.urllib import parse as url_parse
|
from six.moves.urllib import parse as urlparse
|
||||||
|
|
||||||
from ceilometer.openstack.common.gettextutils import _
|
from ceilometer.openstack.common.gettextutils import _
|
||||||
from ceilometer.openstack.common import log
|
from ceilometer.openstack.common import log
|
||||||
@ -51,7 +51,7 @@ class AnalyticsAPIBaseClient(object):
|
|||||||
'domain': self.domain}
|
'domain': self.domain}
|
||||||
|
|
||||||
req_params = self._get_req_params(data=data)
|
req_params = self._get_req_params(data=data)
|
||||||
url = url_parse.urljoin(self.endpoint, path)
|
url = urlparse.urljoin(self.endpoint, path)
|
||||||
resp = requests.post(url, **req_params)
|
resp = requests.post(url, **req_params)
|
||||||
if resp.status_code != 302:
|
if resp.status_code != 302:
|
||||||
raise OpencontrailAPIFailed(
|
raise OpencontrailAPIFailed(
|
||||||
@ -71,7 +71,7 @@ class AnalyticsAPIBaseClient(object):
|
|||||||
req_params = self._get_req_params(data=data,
|
req_params = self._get_req_params(data=data,
|
||||||
cookies={'connect.sid': self.sid})
|
cookies={'connect.sid': self.sid})
|
||||||
|
|
||||||
url = url_parse.urljoin(self.endpoint, path)
|
url = urlparse.urljoin(self.endpoint, path)
|
||||||
self._log_req(url, req_params)
|
self._log_req(url, req_params)
|
||||||
resp = requests.get(url, **req_params)
|
resp = requests.get(url, **req_params)
|
||||||
self._log_res(resp)
|
self._log_res(resp)
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from six.moves.urllib import parse as url_parse
|
from six.moves.urllib import parse as urlparse
|
||||||
|
|
||||||
from ceilometer.network.statistics import driver
|
from ceilometer.network.statistics import driver
|
||||||
from ceilometer.network.statistics.opencontrail import client
|
from ceilometer.network.statistics.opencontrail import client
|
||||||
@ -73,13 +73,13 @@ class OpencontrailDriver(driver.Driver):
|
|||||||
|
|
||||||
def get_sample_data(self, meter_name, parse_url, params, cache):
|
def get_sample_data(self, meter_name, parse_url, params, cache):
|
||||||
|
|
||||||
parts = url_parse.ParseResult(params.get('scheme', ['http'])[0],
|
parts = urlparse.ParseResult(params.get('scheme', ['http'])[0],
|
||||||
parse_url.netloc,
|
parse_url.netloc,
|
||||||
parse_url.path,
|
parse_url.path,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
None)
|
None)
|
||||||
endpoint = url_parse.urlunparse(parts)
|
endpoint = urlparse.urlunparse(parts)
|
||||||
|
|
||||||
iter = self._get_iter(meter_name)
|
iter = self._get_iter(meter_name)
|
||||||
if iter is None:
|
if iter is None:
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
import six
|
import six
|
||||||
from six import moves
|
from six import moves
|
||||||
from six.moves.urllib import parse as url_parse
|
from six.moves.urllib import parse as urlparse
|
||||||
|
|
||||||
from ceilometer.network.statistics import driver
|
from ceilometer.network.statistics import driver
|
||||||
from ceilometer.network.statistics.opendaylight import client
|
from ceilometer.network.statistics.opendaylight import client
|
||||||
@ -187,13 +187,13 @@ class OpenDayLightDriver(driver.Driver):
|
|||||||
# OpenDaylight REST API has not api to getting meter.
|
# OpenDaylight REST API has not api to getting meter.
|
||||||
return None
|
return None
|
||||||
|
|
||||||
parts = url_parse.ParseResult(params.get('scheme', ['http'])[0],
|
parts = urlparse.ParseResult(params.get('scheme', ['http'])[0],
|
||||||
parse_url.netloc,
|
parse_url.netloc,
|
||||||
parse_url.path,
|
parse_url.path,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
None)
|
None)
|
||||||
endpoint = url_parse.urlunparse(parts)
|
endpoint = urlparse.urlunparse(parts)
|
||||||
|
|
||||||
data = self._prepare_cache(endpoint, params, cache)
|
data = self._prepare_cache(endpoint, params, cache)
|
||||||
|
|
||||||
|
@ -18,10 +18,10 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
import six.moves.urllib.parse as urlparse
|
|
||||||
|
|
||||||
from keystoneclient import exceptions
|
from keystoneclient import exceptions
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
from six.moves.urllib import parse as urlparse
|
||||||
from swiftclient import client as swift
|
from swiftclient import client as swift
|
||||||
|
|
||||||
from ceilometer.central import plugin
|
from ceilometer.central import plugin
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
import logging.handlers
|
import logging.handlers
|
||||||
import six.moves.urllib.parse as urlparse
|
|
||||||
|
from six.moves.urllib import parse as urlparse
|
||||||
|
|
||||||
from ceilometer.openstack.common.gettextutils import _
|
from ceilometer.openstack.common.gettextutils import _
|
||||||
from ceilometer.openstack.common import log
|
from ceilometer.openstack.common import log
|
||||||
|
@ -20,11 +20,11 @@
|
|||||||
|
|
||||||
import itertools
|
import itertools
|
||||||
import operator
|
import operator
|
||||||
import six.moves.urllib.parse as urlparse
|
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
import oslo.messaging
|
import oslo.messaging
|
||||||
import oslo.messaging._drivers.common
|
import oslo.messaging._drivers.common
|
||||||
|
from six.moves.urllib import parse as urlparse
|
||||||
|
|
||||||
from ceilometer import messaging
|
from ceilometer import messaging
|
||||||
from ceilometer.openstack.common.gettextutils import _
|
from ceilometer.openstack.common.gettextutils import _
|
||||||
|
@ -17,10 +17,9 @@
|
|||||||
"""Storage backend management
|
"""Storage backend management
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import six.moves.urllib.parse as urlparse
|
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
import six
|
import six
|
||||||
|
from six.moves.urllib import parse as urlparse
|
||||||
from stevedore import driver
|
from stevedore import driver
|
||||||
|
|
||||||
from ceilometer.openstack.common.gettextutils import _
|
from ceilometer.openstack.common.gettextutils import _
|
||||||
|
@ -16,10 +16,10 @@ import datetime
|
|||||||
import hashlib
|
import hashlib
|
||||||
import operator
|
import operator
|
||||||
import os
|
import os
|
||||||
import six.moves.urllib.parse as urlparse
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import happybase
|
import happybase
|
||||||
|
from six.moves.urllib import parse as urlparse
|
||||||
|
|
||||||
from ceilometer.alarm.storage import models as alarm_models
|
from ceilometer.alarm.storage import models as alarm_models
|
||||||
from ceilometer.openstack.common.gettextutils import _
|
from ceilometer.openstack.common.gettextutils import _
|
||||||
|
@ -14,10 +14,10 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
import six.moves.urllib.parse as urlparse
|
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
import requests
|
import requests
|
||||||
|
from six.moves.urllib import parse as urlparse
|
||||||
|
|
||||||
from ceilometer.alarm import service
|
from ceilometer.alarm import service
|
||||||
from ceilometer.openstack.common import context
|
from ceilometer.openstack.common import context
|
||||||
|
@ -20,11 +20,11 @@
|
|||||||
"""Base classes for API tests."""
|
"""Base classes for API tests."""
|
||||||
import fixtures
|
import fixtures
|
||||||
import os
|
import os
|
||||||
import urlparse
|
|
||||||
import uuid
|
import uuid
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
from six.moves.urllib import parse as urlparse
|
||||||
import testscenarios.testcase
|
import testscenarios.testcase
|
||||||
from testtools import testcase
|
from testtools import testcase
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from six.moves.urllib import parse as url_parse
|
from six.moves.urllib import parse as urlparse
|
||||||
|
|
||||||
from ceilometer.network.statistics.opencontrail import driver
|
from ceilometer.network.statistics.opencontrail import driver
|
||||||
from ceilometer.openstack.common import test
|
from ceilometer.openstack.common import test
|
||||||
@ -37,7 +37,7 @@ class TestOpencontrailDriver(test.BaseTestCase):
|
|||||||
self.nc_networks.start()
|
self.nc_networks.start()
|
||||||
|
|
||||||
self.driver = driver.OpencontrailDriver()
|
self.driver = driver.OpencontrailDriver()
|
||||||
self.parse_url = url_parse.ParseResult('opencontrail',
|
self.parse_url = urlparse.ParseResult('opencontrail',
|
||||||
'127.0.0.1:8143',
|
'127.0.0.1:8143',
|
||||||
'/', None, None, None)
|
'/', None, None, None)
|
||||||
self.params = {'password': ['admin'],
|
self.params = {'password': ['admin'],
|
||||||
|
@ -13,10 +13,9 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from requests import auth as req_auth
|
from requests import auth as req_auth
|
||||||
import six
|
import six
|
||||||
from six.moves.urllib import parse as url_parse
|
from six.moves.urllib import parse as urlparse
|
||||||
|
|
||||||
from ceilometer.network.statistics.opendaylight import client
|
from ceilometer.network.statistics.opendaylight import client
|
||||||
from ceilometer.openstack.common.gettextutils import _
|
from ceilometer.openstack.common.gettextutils import _
|
||||||
@ -30,13 +29,13 @@ class TestClientHTTPBasicAuth(test.BaseTestCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestClientHTTPBasicAuth, self).setUp()
|
super(TestClientHTTPBasicAuth, self).setUp()
|
||||||
self.parsed_url = url_parse.urlparse(
|
self.parsed_url = urlparse.urlparse(
|
||||||
'http://127.0.0.1:8080/controller/nb/v2?container_name=default&'
|
'http://127.0.0.1:8080/controller/nb/v2?container_name=default&'
|
||||||
'container_name=egg&auth=%s&user=admin&password=admin_pass&'
|
'container_name=egg&auth=%s&user=admin&password=admin_pass&'
|
||||||
'scheme=%s' % (self.auth_way, self.scheme))
|
'scheme=%s' % (self.auth_way, self.scheme))
|
||||||
self.params = url_parse.parse_qs(self.parsed_url.query)
|
self.params = urlparse.parse_qs(self.parsed_url.query)
|
||||||
self.endpoint = url_parse.urlunparse(
|
self.endpoint = urlparse.urlunparse(
|
||||||
url_parse.ParseResult(self.scheme,
|
urlparse.ParseResult(self.scheme,
|
||||||
self.parsed_url.netloc,
|
self.parsed_url.netloc,
|
||||||
self.parsed_url.path,
|
self.parsed_url.path,
|
||||||
None, None, None))
|
None, None, None))
|
||||||
|
@ -13,11 +13,11 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
import abc
|
import abc
|
||||||
import mock
|
|
||||||
|
|
||||||
|
import mock
|
||||||
import six
|
import six
|
||||||
from six import moves
|
from six import moves
|
||||||
from six.moves.urllib import parse as url_parse
|
from six.moves.urllib import parse as urlparse
|
||||||
|
|
||||||
from ceilometer.network.statistics.opendaylight import driver
|
from ceilometer.network.statistics.opendaylight import driver
|
||||||
from ceilometer.openstack.common import test
|
from ceilometer.openstack.common import test
|
||||||
@ -58,18 +58,18 @@ class _Base(test.BaseTestCase):
|
|||||||
def inactive_hosts_data(self):
|
def inactive_hosts_data(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
fake_odl_url = url_parse.ParseResult('opendaylight',
|
fake_odl_url = urlparse.ParseResult('opendaylight',
|
||||||
'localhost:8080',
|
'localhost:8080',
|
||||||
'controller/nb/v2',
|
'controller/nb/v2',
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
None)
|
None)
|
||||||
|
|
||||||
fake_params = url_parse.parse_qs('user=admin&password=admin&scheme=http&'
|
fake_params = urlparse.parse_qs('user=admin&password=admin&scheme=http&'
|
||||||
'container_name=default&auth=basic')
|
'container_name=default&auth=basic')
|
||||||
|
|
||||||
fake_params_multi_container = \
|
fake_params_multi_container = \
|
||||||
url_parse.parse_qs('user=admin&password=admin&scheme=http&'
|
urlparse.parse_qs('user=admin&password=admin&scheme=http&'
|
||||||
'container_name=first&container_name=second&'
|
'container_name=first&container_name=second&'
|
||||||
'auth=basic')
|
'auth=basic')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user