Add py3 support for repositories packages
Story: 2000975 Task: 12579 Change-Id: Iaf01fcf9e600d1f89eb202f6a908d6de50c9578f
This commit is contained in:
parent
a3c138ecb0
commit
6af07fb0fc
|
@ -14,10 +14,12 @@
|
|||
# under the License.
|
||||
|
||||
import binascii
|
||||
from builtins import str as text
|
||||
from collections import namedtuple
|
||||
from datetime import datetime
|
||||
from datetime import timedelta
|
||||
import itertools
|
||||
import six
|
||||
import urllib
|
||||
|
||||
from cassandra.auth import PlainTextAuthProvider
|
||||
|
@ -650,7 +652,8 @@ class MetricsRepository(metrics_repository.AbstractMetricsRepository):
|
|||
end_timestamp, offset_timestamp,
|
||||
limit=None, fetch_size=FETCH_SIZE_UNSET):
|
||||
conditions = [METRIC_ID_EQ]
|
||||
params = [bytearray.fromhex(metric_id)]
|
||||
decode_metric_id = metric_id if six.PY2 else metric_id.decode('utf-8')
|
||||
params = [bytearray.fromhex(decode_metric_id)]
|
||||
|
||||
if offset_timestamp:
|
||||
conditions.append(OFFSET_TIME_GT)
|
||||
|
@ -756,7 +759,7 @@ class MetricsRepository(metrics_repository.AbstractMetricsRepository):
|
|||
st = st[:23] + 'Z'
|
||||
else:
|
||||
st += '.000Z'
|
||||
return st.decode('utf8')
|
||||
return text(st)
|
||||
|
||||
def metrics_statistics(self, tenant_id, region, name, dimensions,
|
||||
start_timestamp, end_timestamp, statistics,
|
||||
|
@ -849,7 +852,7 @@ class MetricsRepository(metrics_repository.AbstractMetricsRepository):
|
|||
if stats_end_time > end_time:
|
||||
stats_end_time = end_time
|
||||
|
||||
statistic = {u'name': name.decode('utf8'),
|
||||
statistic = {u'name': text(name),
|
||||
u'id': series['id'],
|
||||
u'dimensions': series['dimensions'],
|
||||
u'columns': columns,
|
||||
|
|
|
@ -418,7 +418,7 @@ class MetricsRepository(metrics_repository.AbstractMetricsRepository):
|
|||
for name in dim_name_set:
|
||||
json_dim_name_list.append({u'dimension_name': name})
|
||||
|
||||
json_dim_name_list = sorted(json_dim_name_list)
|
||||
json_dim_name_list = sorted(json_dim_name_list, key=lambda x: x[u'dimension_name'])
|
||||
return json_dim_name_list
|
||||
|
||||
def _build_serie_metric_list_to_v0_11_0(self, series_names, tenant_id, region,
|
||||
|
|
|
@ -216,8 +216,9 @@ class TestRepoMetricsInfluxDB(base.BaseTestCase):
|
|||
|
||||
mock_client.query.assert_called_once_with(
|
||||
'show tag values from "custom_metric" with key = "hostname"'
|
||||
' where _tenant_id = \'38dc2a2549f94d2e9a4fa1cc45a4970c\''
|
||||
' and _region = \'useast\' ')
|
||||
' where _tenant_id = \'{tenant}\''
|
||||
' and _region = \'{region}\' '.format(tenant=b'38dc2a2549f94d2e9a4fa1cc45a4970c',
|
||||
region=b'useast'))
|
||||
|
||||
@patch("monasca_api.common.repositories.influxdb."
|
||||
"metrics_repository.client.InfluxDBClient")
|
||||
|
@ -325,7 +326,7 @@ class TestRepoMetricsCassandra(base.BaseTestCase):
|
|||
limit=1)
|
||||
|
||||
self.assertEqual([{
|
||||
u'id': u'01d39f19798ed27bbf458300bf843edd17654614',
|
||||
u'id': b'01d39f19798ed27bbf458300bf843edd17654614',
|
||||
u'name': u'disk.space_used_perc',
|
||||
u'dimensions': {
|
||||
u'device': u'rootfs',
|
||||
|
@ -492,7 +493,7 @@ class TestRepoMetricsCassandra(base.BaseTestCase):
|
|||
u'statistics': [[u'2016-05-19T11:58:24.000Z', 95.5, 94.0, 97.0, 4, 382.0]],
|
||||
u'name': u'cpu.idle_perc',
|
||||
u'columns': [u'timestamp', 'avg', 'min', 'max', 'count', 'sum'],
|
||||
u'id': '01d39f19798ed27bbf458300bf843edd17654614'
|
||||
u'id': b'01d39f19798ed27bbf458300bf843edd17654614'
|
||||
}
|
||||
], result)
|
||||
|
||||
|
@ -540,7 +541,7 @@ class TestRepoMetricsCassandra(base.BaseTestCase):
|
|||
u'statistics': [[u'2016-05-19T11:58:24.000Z', 95.5, 94.0, 97.0, 4, 382.0]],
|
||||
u'name': u'cpu.idle_perc',
|
||||
u'columns': [u'timestamp', 'avg', 'min', 'max', 'count', 'sum'],
|
||||
u'id': '01d39f19798ed27bbf458300bf843edd17654614'
|
||||
u'id': b'01d39f19798ed27bbf458300bf843edd17654614'
|
||||
}
|
||||
], result)
|
||||
|
||||
|
|
Loading…
Reference in New Issue