Merge "Remove usage of future library"

This commit is contained in:
Zuul 2018-08-08 10:29:10 +00:00 committed by Gerrit Code Review
commit 0cef7b6220
5 changed files with 21 additions and 21 deletions

View File

@ -14,7 +14,6 @@
# under the License. # under the License.
import binascii import binascii
from builtins import str as text
from collections import namedtuple from collections import namedtuple
from datetime import datetime from datetime import datetime
from datetime import timedelta from datetime import timedelta
@ -26,14 +25,15 @@ from cassandra.auth import PlainTextAuthProvider
from cassandra.cluster import Cluster from cassandra.cluster import Cluster
from cassandra.query import FETCH_SIZE_UNSET from cassandra.query import FETCH_SIZE_UNSET
from cassandra.query import SimpleStatement from cassandra.query import SimpleStatement
from monasca_common.rest import utils as rest_utils
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log from oslo_log import log
from oslo_utils import encodeutils
from oslo_utils import timeutils from oslo_utils import timeutils
from monasca_api.common.repositories import exceptions from monasca_api.common.repositories import exceptions
from monasca_api.common.repositories import metrics_repository from monasca_api.common.repositories import metrics_repository
from monasca_common.rest import utils as rest_utils
CONF = cfg.CONF CONF = cfg.CONF
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
@ -817,10 +817,10 @@ class MetricsRepository(metrics_repository.AbstractMetricsRepository):
""" """
st = timestamp.isoformat() st = timestamp.isoformat()
if '.' in st: if '.' in st:
st = st[:23] + 'Z' st = st[:23] + u'Z'
else: else:
st += '.000Z' st += u'.000Z'
return text(st) return st
def metrics_statistics(self, tenant_id, region, name, dimensions, def metrics_statistics(self, tenant_id, region, name, dimensions,
start_timestamp, end_timestamp, statistics, start_timestamp, end_timestamp, statistics,
@ -914,7 +914,7 @@ class MetricsRepository(metrics_repository.AbstractMetricsRepository):
if stats_end_time > end_time: if stats_end_time > end_time:
stats_end_time = end_time stats_end_time = end_time
statistic = {u'name': text(name), statistic = {u'name': encodeutils.safe_decode(name, 'utf-8'),
u'id': series['id'], u'id': series['id'],
u'dimensions': series['dimensions'], u'dimensions': series['dimensions'],
u'columns': columns, u'columns': columns,

View File

@ -12,7 +12,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 builtins import str as text from oslo_utils import encodeutils
class SubAlarmDefinition(object): class SubAlarmDefinition(object):
@ -58,7 +58,7 @@ class SubAlarmDefinition(object):
self.metric_name = sub_expr.metric_name self.metric_name = sub_expr.metric_name
self.dimensions_str = sub_expr.dimensions_str self.dimensions_str = sub_expr.dimensions_str
self.dimensions = self._init_dimensions(sub_expr.dimensions_str) self.dimensions = self._init_dimensions(sub_expr.dimensions_str)
self.function = text(sub_expr.normalized_func) self.function = encodeutils.safe_decode(sub_expr.normalized_func, 'utf-8')
self.operator = sub_expr.normalized_operator self.operator = sub_expr.normalized_operator
self.period = sub_expr.period self.period = sub_expr.period
self.periods = sub_expr.periods self.periods = sub_expr.periods

View File

@ -13,20 +13,20 @@
# 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 builtins import str as strtext
import datetime import datetime
import six import six
from oslo_utils import encodeutils
from oslo_utils import uuidutils from oslo_utils import uuidutils
from sqlalchemy import MetaData, update, delete, insert
from sqlalchemy import select, text, bindparam, null, literal_column
from sqlalchemy import or_
from monasca_api.common.repositories import alarm_definitions_repository as adr from monasca_api.common.repositories import alarm_definitions_repository as adr
from monasca_api.common.repositories import exceptions from monasca_api.common.repositories import exceptions
from monasca_api.common.repositories.model import sub_alarm_definition from monasca_api.common.repositories.model import sub_alarm_definition
from monasca_api.common.repositories.sqla import models from monasca_api.common.repositories.sqla import models
from monasca_api.common.repositories.sqla import sql_repository from monasca_api.common.repositories.sqla import sql_repository
from sqlalchemy import MetaData, update, delete, insert
from sqlalchemy import select, text, bindparam, null, literal_column
from sqlalchemy import or_
class AlarmDefinitionsRepository(sql_repository.SQLRepository, class AlarmDefinitionsRepository(sql_repository.SQLRepository,
@ -557,7 +557,7 @@ class AlarmDefinitionsRepository(sql_repository.SQLRepository,
new_match_by = match.encode('utf8') if six.PY2 else match new_match_by = match.encode('utf8') if six.PY2 else match
if new_match_by != original_row['match_by']: if new_match_by != original_row['match_by']:
msg = strtext("match_by must not change") msg = u"match_by must not change"
raise exceptions.InvalidUpdateException(msg) raise exceptions.InvalidUpdateException(msg)
if actions_enabled is None: if actions_enabled is None:
@ -793,8 +793,8 @@ class AlarmDefinitionsRepository(sql_repository.SQLRepository,
if row is None: if row is None:
raise exceptions.InvalidUpdateException( raise exceptions.InvalidUpdateException(
"Non-existent notification id {} submitted for {} " "Non-existent notification id {} submitted for {} "
"notification action".format(strtext(action), "notification action".format(encodeutils.to_utf8(action),
strtext(alarm_state))) encodeutils.to_utf8(alarm_state)))
conn.execute(self.insert_aa_query, conn.execute(self.insert_aa_query,
b_alarm_definition_id=alarm_definition_id, b_alarm_definition_id=alarm_definition_id,
b_alarm_state=alarm_state.encode('utf8') if six.PY2 else alarm_state, b_alarm_state=alarm_state.encode('utf8') if six.PY2 else alarm_state,

View File

@ -13,7 +13,6 @@
# 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 builtins import str as text
import re import re
import falcon import falcon
@ -21,6 +20,7 @@ from monasca_common.simport import simport
from monasca_common.validation import metrics as metric_validation from monasca_common.validation import metrics as metric_validation
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log from oslo_log import log
from oslo_utils import encodeutils
import pyparsing import pyparsing
import six import six
@ -648,7 +648,7 @@ def get_query_alarm_definition_description(alarm_definition,
def get_query_alarm_definition_severity(alarm_definition, return_none=False): def get_query_alarm_definition_severity(alarm_definition, return_none=False):
if 'severity' in alarm_definition: if 'severity' in alarm_definition:
severity = text(alarm_definition['severity']).upper() severity = encodeutils.safe_decode(alarm_definition['severity'], 'utf-8').upper()
if severity not in ['LOW', 'MEDIUM', 'HIGH', 'CRITICAL']: if severity not in ['LOW', 'MEDIUM', 'HIGH', 'CRITICAL']:
raise HTTPUnprocessableEntityError('Unprocessable Entity', 'Invalid severity') raise HTTPUnprocessableEntityError('Unprocessable Entity', 'Invalid severity')
return severity return severity
@ -728,7 +728,7 @@ def get_comma_separated_str_as_list(comma_separated_str):
if not comma_separated_str: if not comma_separated_str:
return [] return []
else: else:
return text(comma_separated_str).split(',') return encodeutils.safe_decode(comma_separated_str, 'utf-8').split(',')
def is_definition_deterministic(expression): def is_definition_deterministic(expression):

View File

@ -15,11 +15,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.
from builtins import str as text
import datetime import datetime
import falcon import falcon
from oslo_log import log from oslo_log import log
from oslo_utils import encodeutils
from oslo_utils import timeutils from oslo_utils import timeutils
import six import six
import six.moves.urllib.parse as urlparse import six.moves.urllib.parse as urlparse
@ -356,7 +356,7 @@ def paginate(resource, uri, limit):
else: else:
resource = {u'links': ([{u'rel': u'self', resource = {u'links': ([{u'rel': u'self',
u'href': text(self_link)}]), u'href': encodeutils.safe_decode(self_link, 'utf-8')}]),
u'elements': resource} u'elements': resource}
return resource return resource