Run pyupgrade to clean up Python 2 syntaxes
Python 2 support was removed long ago so we can clean up the syntaxes to support it. Change-Id: I1280301e162183644acc22b8c8bc787040e563a6
This commit is contained in:
@@ -23,3 +23,8 @@ repos:
|
||||
hooks:
|
||||
- id: hacking
|
||||
additional_dependencies: []
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v3.18.0
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
args: [--py3-only]
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
|
||||
@@ -31,10 +31,7 @@ class SessionClient(adapter.Adapter):
|
||||
# keystoneauth, where we need to raise the aodhclient errors.
|
||||
raise_exc = kwargs.pop('raise_exc', True)
|
||||
kwargs['headers'].update(web.get_trace_id_headers())
|
||||
resp = super(SessionClient, self).request(url,
|
||||
method,
|
||||
raise_exc=False,
|
||||
**kwargs)
|
||||
resp = super().request(url, method, raise_exc=False, **kwargs)
|
||||
|
||||
if raise_exc and resp.status_code >= 400:
|
||||
raise exceptions.from_response(resp, url, method)
|
||||
|
||||
@@ -30,9 +30,10 @@ class ClientException(Exception):
|
||||
return self.http_status
|
||||
|
||||
def __str__(self):
|
||||
formatted_string = "%s (HTTP %s)" % (self.message, self.http_status)
|
||||
formatted_string = "{} (HTTP {})".format(
|
||||
self.message, self.http_status)
|
||||
if self.request_id:
|
||||
formatted_string += " (Request-ID: %s)" % self.request_id
|
||||
formatted_string += " (Request-ID: {})".format(self.request_id)
|
||||
|
||||
return formatted_string
|
||||
|
||||
@@ -45,10 +46,10 @@ class RetryAfterException(ClientException):
|
||||
except (KeyError, ValueError):
|
||||
self.retry_after = 0
|
||||
|
||||
super(RetryAfterException, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
||||
class MutipleMeaningException(object):
|
||||
class MutipleMeaningException:
|
||||
"""An mixin for exception that can be enhanced by reading the details"""
|
||||
|
||||
|
||||
@@ -136,9 +137,9 @@ _error_classes = [BadRequest, Unauthorized, Forbidden, NotFound,
|
||||
MethodNotAllowed, NotAcceptable, Conflict, OverLimit,
|
||||
RateLimit, NotImplemented]
|
||||
_error_classes_enhanced = {}
|
||||
_code_map = dict(
|
||||
(c.http_status, (c, _error_classes_enhanced.get(c, [])))
|
||||
for c in _error_classes)
|
||||
_code_map = {
|
||||
c.http_status: (c, _error_classes_enhanced.get(c, []))
|
||||
for c in _error_classes}
|
||||
|
||||
|
||||
def from_response(response, url, method=None):
|
||||
|
||||
@@ -67,7 +67,7 @@ class AodhNoAuthLoader(loading.BaseLoader):
|
||||
plugin_class = AodhNoAuthPlugin
|
||||
|
||||
def get_options(self):
|
||||
options = super(AodhNoAuthLoader, self).get_options()
|
||||
options = super().get_options()
|
||||
options.extend([
|
||||
AodhOpt('user-id', help='User ID', required=True),
|
||||
AodhOpt('project-id', help='Project ID', required=True),
|
||||
|
||||
@@ -54,7 +54,7 @@ class AodhCommandManager(commandmanager.CommandManager):
|
||||
|
||||
class AodhShell(app.App):
|
||||
def __init__(self):
|
||||
super(AodhShell, self).__init__(
|
||||
super().__init__(
|
||||
description='Aodh command line client',
|
||||
version=__version__,
|
||||
command_manager=AodhCommandManager('aodhclient'),
|
||||
@@ -74,7 +74,7 @@ class AodhShell(app.App):
|
||||
:param version: version number for the application
|
||||
:paramtype version: str
|
||||
"""
|
||||
parser = super(AodhShell, self).build_option_parser(
|
||||
parser = super().build_option_parser(
|
||||
description, version, argparse_kwargs={'allow_abbrev': False})
|
||||
# Global arguments, one day this should go to keystoneauth1
|
||||
parser.add_argument(
|
||||
@@ -141,7 +141,7 @@ class AodhShell(app.App):
|
||||
# Set this here so cliff.app.configure_logging() can work
|
||||
self.options.verbose_level = 3
|
||||
|
||||
super(AodhShell, self).configure_logging()
|
||||
super().configure_logging()
|
||||
root_logger = logging.getLogger('')
|
||||
|
||||
# Set logging to the requested level
|
||||
|
||||
@@ -19,7 +19,7 @@ from tempest.lib.cli import base
|
||||
from tempest.lib import exceptions
|
||||
|
||||
|
||||
class AodhClient(object):
|
||||
class AodhClient:
|
||||
"""Aodh Client for tempest-lib
|
||||
|
||||
This client doesn't use any authentication system
|
||||
|
||||
@@ -60,13 +60,13 @@ class AodhClientTest(base.ClientTestBase):
|
||||
self.assertEqual("another-name",
|
||||
self.details_multiple(result)[0]['name'])
|
||||
|
||||
params = "update --name %s %s" % (name, alarm_id)
|
||||
params = "update --name {} {}".format(name, alarm_id)
|
||||
result = self.aodh('alarm', params=params)
|
||||
self.assertEqual(name,
|
||||
self.details_multiple(result)[0]['name'])
|
||||
|
||||
# Check update with no change is allowed
|
||||
params = "update --name %s %s" % (name, name)
|
||||
params = "update --name {} {}".format(name, name)
|
||||
result = self.aodh('alarm', params=params)
|
||||
self.assertEqual(name,
|
||||
self.details_multiple(result)[0]['name'])
|
||||
@@ -99,8 +99,8 @@ class AodhClientTest(base.ClientTestBase):
|
||||
PROJECT_ID = uuidutils.generate_uuid()
|
||||
|
||||
# CREATE
|
||||
result = self.aodh(u'alarm',
|
||||
params=(u"create --type event --name ev_alarm1 "
|
||||
result = self.aodh('alarm',
|
||||
params=("create --type event --name ev_alarm1 "
|
||||
"--project-id %s" % PROJECT_ID))
|
||||
alarm = self.details_multiple(result)[0]
|
||||
ALARM_ID = alarm['alarm_id']
|
||||
@@ -142,8 +142,8 @@ class AodhClientTest(base.ClientTestBase):
|
||||
|
||||
# GET BY NAME AND ID ERROR
|
||||
self.assertRaises(exceptions.CommandFailed,
|
||||
self.aodh, u'alarm',
|
||||
params=(u"show %s --name ev_alarm1" %
|
||||
self.aodh, 'alarm',
|
||||
params=("show %s --name ev_alarm1" %
|
||||
ALARM_ID))
|
||||
|
||||
# LIST
|
||||
@@ -190,8 +190,8 @@ class AodhClientTest(base.ClientTestBase):
|
||||
res_id = uuidutils.generate_uuid()
|
||||
# CREATE
|
||||
result = self.aodh(
|
||||
u'alarm',
|
||||
params=(u'create --type composite --name calarm1 --composite-rule '
|
||||
'alarm',
|
||||
params=('create --type composite --name calarm1 --composite-rule '
|
||||
'\'{"or":[{"threshold": 0.8, "metric": "cpu_util", '
|
||||
'"type": "gnocchi_resources_threshold", "resource_type": '
|
||||
'"generic", "resource_id": "%s", '
|
||||
@@ -213,8 +213,8 @@ class AodhClientTest(base.ClientTestBase):
|
||||
|
||||
# CREATE FAIL MISSING PARAM
|
||||
self.assertRaises(exceptions.CommandFailed,
|
||||
self.aodh, u'alarm',
|
||||
params=(u"create --type composite --name calarm1 "
|
||||
self.aodh, 'alarm',
|
||||
params=("create --type composite --name calarm1 "
|
||||
"--project-id %s" % project_id))
|
||||
|
||||
# UPDATE
|
||||
@@ -242,8 +242,8 @@ class AodhClientTest(base.ClientTestBase):
|
||||
|
||||
# GET BY NAME AND ID ERROR
|
||||
self.assertRaises(exceptions.CommandFailed,
|
||||
self.aodh, u'alarm',
|
||||
params=(u"show %s --name calarm1" %
|
||||
self.aodh, 'alarm',
|
||||
params=("show %s --name calarm1" %
|
||||
alarm_id))
|
||||
|
||||
# LIST
|
||||
@@ -340,8 +340,8 @@ class AodhClientTest(base.ClientTestBase):
|
||||
|
||||
res_id = uuidutils.generate_uuid()
|
||||
# CREATE
|
||||
result = self.aodh(u'alarm',
|
||||
params=(u"create --type event --name ev_alarm123"))
|
||||
result = self.aodh('alarm',
|
||||
params=("create --type event --name ev_alarm123"))
|
||||
alarm = self.details_multiple(result)[0]
|
||||
ALARM_ID = alarm['alarm_id']
|
||||
self.assertEqual('ev_alarm123', alarm['name'])
|
||||
@@ -399,8 +399,8 @@ class AodhClientGnocchiRulesTest(base.ClientTestBase):
|
||||
self.assertEqual(201, req.status_code)
|
||||
|
||||
# CREATE
|
||||
result = self.aodh(u'alarm',
|
||||
params=(u"create "
|
||||
result = self.aodh('alarm',
|
||||
params=("create "
|
||||
"--type gnocchi_resources_threshold "
|
||||
"--name alarm_gn1 --metric cpu_util "
|
||||
"--threshold 80 "
|
||||
@@ -420,8 +420,8 @@ class AodhClientGnocchiRulesTest(base.ClientTestBase):
|
||||
|
||||
# CREATE WITH --TIME-CONSTRAINT
|
||||
result = self.aodh(
|
||||
u'alarm',
|
||||
params=(u"create --type gnocchi_resources_threshold "
|
||||
'alarm',
|
||||
params=("create --type gnocchi_resources_threshold "
|
||||
"--name alarm_tc --metric cpu_util --threshold 80 "
|
||||
"--resource-id %s --resource-type generic "
|
||||
"--aggregation-method last --project-id %s "
|
||||
@@ -437,8 +437,8 @@ class AodhClientGnocchiRulesTest(base.ClientTestBase):
|
||||
|
||||
# CREATE FAIL MISSING PARAM
|
||||
self.assertRaises(exceptions.CommandFailed,
|
||||
self.aodh, u'alarm',
|
||||
params=(u"create "
|
||||
self.aodh, 'alarm',
|
||||
params=("create "
|
||||
"--type gnocchi_resources_threshold "
|
||||
"--name alarm1 --metric cpu_util "
|
||||
"--resource-id %s --resource-type generic "
|
||||
@@ -483,8 +483,8 @@ class AodhClientGnocchiRulesTest(base.ClientTestBase):
|
||||
|
||||
# GET BY NAME AND ID ERROR
|
||||
self.assertRaises(exceptions.CommandFailed,
|
||||
self.aodh, u'alarm',
|
||||
params=(u"show %s --name alarm_gn1" %
|
||||
self.aodh, 'alarm',
|
||||
params=("show %s --name alarm_gn1" %
|
||||
ALARM_ID))
|
||||
|
||||
# LIST
|
||||
@@ -513,8 +513,8 @@ class AodhClientGnocchiRulesTest(base.ClientTestBase):
|
||||
self.assertEqual(sorted_name, names)
|
||||
# list with sort with key=name dir=asc and key=alarm_id dir=asc
|
||||
result = self.aodh(
|
||||
u'alarm',
|
||||
params=(u"create --type gnocchi_resources_threshold "
|
||||
'alarm',
|
||||
params=("create --type gnocchi_resources_threshold "
|
||||
"--name alarm_th --metric cpu_util --threshold 80 "
|
||||
"--resource-id %s --resource-type generic "
|
||||
"--aggregation-method last --project-id %s "
|
||||
@@ -576,8 +576,8 @@ class AodhClientGnocchiRulesTest(base.ClientTestBase):
|
||||
|
||||
# CREATE
|
||||
result = self.aodh(
|
||||
u'alarm',
|
||||
params=(u"create "
|
||||
'alarm',
|
||||
params=("create "
|
||||
"--type "
|
||||
"gnocchi_aggregation_by_resources_threshold "
|
||||
"--name alarm1 --metric cpu --threshold 80 "
|
||||
@@ -598,8 +598,8 @@ class AodhClientGnocchiRulesTest(base.ClientTestBase):
|
||||
# CREATE FAIL MISSING PARAM
|
||||
self.assertRaises(
|
||||
exceptions.CommandFailed,
|
||||
self.aodh, u'alarm',
|
||||
params=(u"create "
|
||||
self.aodh, 'alarm',
|
||||
params=("create "
|
||||
"--type "
|
||||
"gnocchi_aggregation_by_resources_threshold "
|
||||
"--name alarm1 --metric cpu "
|
||||
@@ -668,8 +668,8 @@ class AodhClientGnocchiRulesTest(base.ClientTestBase):
|
||||
|
||||
# CREATE
|
||||
result = self.aodh(
|
||||
u'alarm',
|
||||
params=(u"create "
|
||||
'alarm',
|
||||
params=("create "
|
||||
"--type gnocchi_aggregation_by_metrics_threshold "
|
||||
"--name alarm1 "
|
||||
"--metrics %s "
|
||||
@@ -689,8 +689,8 @@ class AodhClientGnocchiRulesTest(base.ClientTestBase):
|
||||
# CREATE FAIL MISSING PARAM
|
||||
self.assertRaises(
|
||||
exceptions.CommandFailed,
|
||||
self.aodh, u'alarm',
|
||||
params=(u"create "
|
||||
self.aodh, 'alarm',
|
||||
params=("create "
|
||||
"--type gnocchi_aggregation_by_metrics_threshold "
|
||||
"--name alarm1 "
|
||||
"--metrics %s "
|
||||
@@ -764,8 +764,8 @@ class AodhClientGnocchiRulesTest(base.ClientTestBase):
|
||||
|
||||
RESOURCE_ID = uuidutils.generate_uuid()
|
||||
# CREATE
|
||||
result = self.aodh(u'alarm',
|
||||
params=(u"create "
|
||||
result = self.aodh('alarm',
|
||||
params=("create "
|
||||
"--type gnocchi_resources_threshold "
|
||||
"--name alarm_gn123 --metric cpu_util "
|
||||
"--resource-id %s --threshold 80 "
|
||||
@@ -830,8 +830,8 @@ class AodhClientGnocchiRulesTest(base.ClientTestBase):
|
||||
|
||||
# CREATE
|
||||
result = self.aodh(
|
||||
u'alarm',
|
||||
params=(u"create "
|
||||
'alarm',
|
||||
params=("create "
|
||||
"--type "
|
||||
"gnocchi_aggregation_by_resources_threshold "
|
||||
"--name alarm123 --metric cpu --threshold 80 "
|
||||
@@ -906,8 +906,8 @@ class AodhClientPrometheusRulesTest(base.ClientTestBase):
|
||||
self.assertEqual(200, req.status_code)
|
||||
|
||||
# CREATE
|
||||
result = self.aodh(u'alarm',
|
||||
params=(u"create "
|
||||
result = self.aodh('alarm',
|
||||
params=("create "
|
||||
"--type prometheus "
|
||||
"--name alarm_p1 "
|
||||
"--threshold 80 "
|
||||
@@ -921,8 +921,8 @@ class AodhClientPrometheusRulesTest(base.ClientTestBase):
|
||||
|
||||
# CREATE WITH --TIME-CONSTRAINT
|
||||
result = self.aodh(
|
||||
u'alarm',
|
||||
params=(u"create --type prometheus "
|
||||
'alarm',
|
||||
params=("create --type prometheus "
|
||||
"--name alarm_ptc --threshold 80 "
|
||||
"--time-constraint "
|
||||
"name=cons1;start='0 11 * * *';duration=300 "
|
||||
@@ -938,8 +938,8 @@ class AodhClientPrometheusRulesTest(base.ClientTestBase):
|
||||
|
||||
# CREATE FAIL MISSING PARAM
|
||||
self.assertRaises(exceptions.CommandFailed,
|
||||
self.aodh, u'alarm',
|
||||
params=(u"create "
|
||||
self.aodh, 'alarm',
|
||||
params=("create "
|
||||
"--type prometheus "
|
||||
"--name alarm1 "
|
||||
"--query %s "
|
||||
@@ -976,8 +976,8 @@ class AodhClientPrometheusRulesTest(base.ClientTestBase):
|
||||
|
||||
# GET BY NAME AND ID ERROR
|
||||
self.assertRaises(exceptions.CommandFailed,
|
||||
self.aodh, u'alarm',
|
||||
params=(u"show %s --name alarm_p1" %
|
||||
self.aodh, 'alarm',
|
||||
params=("show %s --name alarm_p1" %
|
||||
ALARM_ID))
|
||||
|
||||
# LIST
|
||||
@@ -1006,8 +1006,8 @@ class AodhClientPrometheusRulesTest(base.ClientTestBase):
|
||||
self.assertEqual(sorted_name, names)
|
||||
# list with sort with key=name dir=asc and key=alarm_id dir=asc
|
||||
result = self.aodh(
|
||||
u'alarm',
|
||||
params=(u"create --type prometheus "
|
||||
'alarm',
|
||||
params=("create --type prometheus "
|
||||
"--name alarm_p2 --threshold 80 "
|
||||
"--query %s"
|
||||
% QUERY))
|
||||
|
||||
@@ -27,8 +27,8 @@ class AlarmHistoryTest(base.ClientTestBase):
|
||||
PROJECT_ID = uuidutils.generate_uuid()
|
||||
RESOURCE_ID = uuidutils.generate_uuid()
|
||||
|
||||
result = self.aodh(u'alarm',
|
||||
params=(u"create "
|
||||
result = self.aodh('alarm',
|
||||
params=("create "
|
||||
"--type gnocchi_resources_threshold "
|
||||
"--name history1 --metric cpu_util "
|
||||
"--threshold 5 "
|
||||
@@ -38,8 +38,8 @@ class AlarmHistoryTest(base.ClientTestBase):
|
||||
% (RESOURCE_ID, PROJECT_ID)))
|
||||
alarm = self.details_multiple(result)[0]
|
||||
ALARM_ID = alarm['alarm_id']
|
||||
result = self.aodh(u'alarm',
|
||||
params=(u"create "
|
||||
result = self.aodh('alarm',
|
||||
params=("create "
|
||||
"--type gnocchi_resources_threshold "
|
||||
"--name history2 --metric cpu_util "
|
||||
"--threshold 10 "
|
||||
|
||||
@@ -24,7 +24,7 @@ from aodhclient.v2 import alarm_cli
|
||||
class CliAlarmCreateTest(testtools.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(CliAlarmCreateTest, self).setUp()
|
||||
super().setUp()
|
||||
self.app = mock.Mock()
|
||||
self.parser = mock.Mock()
|
||||
self.cli_alarm_create = (
|
||||
|
||||
@@ -24,7 +24,7 @@ from aodhclient.v2 import alarm_history
|
||||
class AlarmHistoryManagerTest(testtools.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(AlarmHistoryManagerTest, self).setUp()
|
||||
super().setUp()
|
||||
self.client = mock.Mock()
|
||||
|
||||
@mock.patch.object(alarm_history.AlarmHistoryManager, '_get')
|
||||
|
||||
@@ -22,7 +22,7 @@ from aodhclient.v2 import alarm
|
||||
class AlarmManagerTest(testtools.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(AlarmManagerTest, self).setUp()
|
||||
super().setUp()
|
||||
self.client = mock.Mock()
|
||||
self.alarms = {
|
||||
'event_alarm': {
|
||||
|
||||
@@ -19,7 +19,7 @@ from aodhclient.v2 import metrics_cli
|
||||
|
||||
class MetricsTest(testtools.TestCase):
|
||||
def setUp(self):
|
||||
super(MetricsTest, self).setUp()
|
||||
super().setUp()
|
||||
self.app = mock.Mock()
|
||||
self.metrics_mgr_mock = self.app.client_manager.alarming.metrics
|
||||
self.parser = mock.Mock()
|
||||
|
||||
@@ -20,7 +20,7 @@ from aodhclient.v2 import quota_cli
|
||||
|
||||
class QuotaShowTest(testtools.TestCase):
|
||||
def setUp(self):
|
||||
super(QuotaShowTest, self).setUp()
|
||||
super().setUp()
|
||||
self.app = mock.Mock()
|
||||
self.quota_mgr_mock = self.app.client_manager.alarming.quota
|
||||
self.parser = mock.Mock()
|
||||
@@ -50,7 +50,7 @@ class QuotaShowTest(testtools.TestCase):
|
||||
|
||||
class QuotaSetTest(testtools.TestCase):
|
||||
def setUp(self):
|
||||
super(QuotaSetTest, self).setUp()
|
||||
super().setUp()
|
||||
self.app = mock.Mock()
|
||||
self.quota_mgr_mock = self.app.client_manager.alarming.quota
|
||||
self.parser = mock.Mock()
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
@@ -17,11 +16,11 @@ from urllib import parse as urllib_parse
|
||||
import pyparsing as pp
|
||||
|
||||
uninary_operators = ("not", )
|
||||
binary_operator = (u">=", u"<=", u"!=", u">", u"<", u"=", u"==", u"eq", u"ne",
|
||||
u"lt", u"gt", u"ge", u"le")
|
||||
multiple_operators = (u"and", u"or")
|
||||
binary_operator = (">=", "<=", "!=", ">", "<", "=", "==", "eq", "ne",
|
||||
"lt", "gt", "ge", "le")
|
||||
multiple_operators = ("and", "or")
|
||||
|
||||
operator = pp.Regex(u"|".join(binary_operator))
|
||||
operator = pp.Regex("|".join(binary_operator))
|
||||
null = pp.Regex("None|none|null").setParseAction(pp.replaceWith(None))
|
||||
boolean = "False|True|false|true"
|
||||
boolean = pp.Regex(boolean).setParseAction(lambda t: t[0].lower() == "true")
|
||||
@@ -104,14 +103,14 @@ def format_string_list(objs, field):
|
||||
|
||||
def format_dict_list(objs, field):
|
||||
objs[field] = "\n".join(
|
||||
"- " + ", ".join("%s: %s" % (k, v)
|
||||
"- " + ", ".join("{}: {}".format(k, v)
|
||||
for k, v in elem.items())
|
||||
for elem in objs[field])
|
||||
|
||||
|
||||
def format_move_dict_to_root(obj, field):
|
||||
for attr in obj[field]:
|
||||
obj["%s/%s" % (field, attr)] = obj[field][attr]
|
||||
obj["{}/{}".format(field, attr)] = obj[field][attr]
|
||||
del obj[field]
|
||||
|
||||
|
||||
@@ -143,7 +142,7 @@ def dict_from_parsed_args(parsed_args, attrs):
|
||||
|
||||
|
||||
def dict_to_querystring(objs):
|
||||
return "&".join(["%s=%s" % (k, v)
|
||||
return "&".join(["{}={}".format(k, v)
|
||||
for k, v in objs.items()
|
||||
if v is not None])
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class AlarmManager(base.Manager):
|
||||
def _filtersdict_to_url(filters):
|
||||
urls = []
|
||||
for k, v in sorted(filters.items()):
|
||||
url = "q.field=%s&q.op=eq&q.value=%s" % (k, v)
|
||||
url = "q.field={}&q.op=eq&q.value={}".format(k, v)
|
||||
urls.append(url)
|
||||
return '&'.join(urls)
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ class CliAlarmList(lister.Lister):
|
||||
return key, value
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(CliAlarmList, self).get_parser(prog_name)
|
||||
parser = super().get_parser(prog_name)
|
||||
exclusive_group = parser.add_mutually_exclusive_group()
|
||||
exclusive_group.add_argument("--query",
|
||||
help="Rich query supported by aodh, "
|
||||
@@ -108,7 +108,7 @@ def _format_alarm(alarm):
|
||||
query_rows = []
|
||||
for q in alarm['query']:
|
||||
op = ALARM_OP_MAP.get(q['op'], q['op'])
|
||||
query_rows.append('%s %s %s' % (q['field'], op, q['value']))
|
||||
query_rows.append('{} {} {}'.format(q['field'], op, q['value']))
|
||||
alarm['query'] = ' AND\n'.join(query_rows)
|
||||
return alarm
|
||||
|
||||
@@ -174,7 +174,7 @@ class CliAlarmShow(show.ShowOne):
|
||||
def get_parser(self, prog_name):
|
||||
return _add_name_to_parser(
|
||||
_add_id_to_parser(
|
||||
super(CliAlarmShow, self).get_parser(prog_name)))
|
||||
super().get_parser(prog_name)))
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
_check_name_and_id(parsed_args, 'query')
|
||||
@@ -201,7 +201,7 @@ class CliAlarmCreate(show.ShowOne):
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = _add_name_to_parser(
|
||||
super(CliAlarmCreate, self).get_parser(prog_name),
|
||||
super().get_parser(prog_name),
|
||||
required=self.create)
|
||||
|
||||
parser.add_argument('-t', '--type', metavar='<TYPE>',
|
||||
@@ -491,7 +491,7 @@ class CliAlarmUpdate(CliAlarmCreate):
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
return _add_id_to_parser(
|
||||
super(CliAlarmUpdate, self).get_parser(prog_name))
|
||||
super().get_parser(prog_name))
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
attributes = self._alarm_from_args(parsed_args)
|
||||
@@ -522,7 +522,7 @@ class CliAlarmDelete(command.Command):
|
||||
def get_parser(self, prog_name):
|
||||
return _add_name_to_parser(
|
||||
_add_id_to_parser(
|
||||
super(CliAlarmDelete, self).get_parser(prog_name)))
|
||||
super().get_parser(prog_name)))
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
_check_name_and_id(parsed_args, 'delete')
|
||||
@@ -548,7 +548,7 @@ class CliAlarmStateGet(show.ShowOne):
|
||||
def get_parser(self, prog_name):
|
||||
return _add_name_to_parser(
|
||||
_add_id_to_parser(
|
||||
super(CliAlarmStateGet, self).get_parser(prog_name)))
|
||||
super().get_parser(prog_name)))
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
_check_name_and_id(parsed_args, 'get state of')
|
||||
@@ -577,7 +577,7 @@ class CliAlarmStateSet(show.ShowOne):
|
||||
def get_parser(self, prog_name):
|
||||
parser = _add_name_to_parser(
|
||||
_add_id_to_parser(
|
||||
super(CliAlarmStateSet, self).get_parser(prog_name)))
|
||||
super().get_parser(prog_name)))
|
||||
parser.add_argument('--state', metavar='<STATE>',
|
||||
required=True,
|
||||
choices=ALARM_STATES,
|
||||
|
||||
@@ -37,7 +37,7 @@ class AlarmHistoryManager(base.Manager):
|
||||
pagination = utils.get_pagination_options(limit, marker, sorts)
|
||||
url = self.url % alarm_id
|
||||
if pagination:
|
||||
url = "%s?%s" % (url, pagination)
|
||||
url = "{}?{}".format(url, pagination)
|
||||
return self._get(url).json()
|
||||
|
||||
def search(self, query=None):
|
||||
|
||||
@@ -22,7 +22,7 @@ class CliAlarmHistorySearch(lister.Lister):
|
||||
COLS = ('alarm_id', 'timestamp', 'type', 'detail')
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(CliAlarmHistorySearch, self).get_parser(prog_name)
|
||||
parser = super().get_parser(prog_name)
|
||||
parser.add_argument("--query",
|
||||
help="Rich query supported by aodh, "
|
||||
"e.g. project_id!=my-id "
|
||||
@@ -45,7 +45,7 @@ class CliAlarmHistoryShow(lister.Lister):
|
||||
COLS = ('timestamp', 'type', 'detail', 'event_id')
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(CliAlarmHistoryShow, self).get_parser(prog_name)
|
||||
parser = super().get_parser(prog_name)
|
||||
parser.add_argument("alarm_id", metavar="<alarm-id>",
|
||||
help="ID of an alarm")
|
||||
parser.add_argument("--limit", type=int, metavar="<LIMIT>",
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
# under the License.
|
||||
|
||||
|
||||
class Manager(object):
|
||||
class Manager:
|
||||
DEFAULT_HEADERS = {
|
||||
"Accept": "application/json",
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ from aodhclient.v2 import metrics
|
||||
from aodhclient.v2 import quota
|
||||
|
||||
|
||||
class Client(object):
|
||||
class Client:
|
||||
"""Client for the Aodh v2 API.
|
||||
|
||||
:param string session: session
|
||||
|
||||
@@ -37,7 +37,7 @@ class CliMetrics(lister.Lister):
|
||||
return METRIC_COLS, cols_data
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(CliMetrics, self).get_parser(prog_name)
|
||||
parser = super().get_parser(prog_name)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
|
||||
@@ -21,7 +21,7 @@ class QuotasManager(base.Manager):
|
||||
def list(self, project=None):
|
||||
url = self.base_url
|
||||
if project:
|
||||
url = "%s?project_id=%s" % (url, project)
|
||||
url = "{}?project_id={}".format(url, project)
|
||||
|
||||
return self._get(url).json()
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class QuotaShow(show.ShowOne):
|
||||
"""Show quota for a project"""
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(QuotaShow, self).get_parser(prog_name)
|
||||
parser = super().get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
"--project",
|
||||
help="Project ID. If not specified, get quota for the current "
|
||||
@@ -41,7 +41,7 @@ class QuotaShow(show.ShowOne):
|
||||
|
||||
class QuotaSet(show.ShowOne):
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(QuotaSet, self).get_parser(prog_name)
|
||||
parser = super().get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
"project",
|
||||
help="Project ID."
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
@@ -26,7 +25,7 @@ def gen_ref(ver, title, names):
|
||||
refdir = os.path.join(BASE_DIR, "ref")
|
||||
pkg = "aodhclient"
|
||||
if ver:
|
||||
pkg = "%s.%s" % (pkg, ver)
|
||||
pkg = "{}.{}".format(pkg, ver)
|
||||
refdir = os.path.join(refdir, ver)
|
||||
if not os.path.exists(refdir):
|
||||
os.makedirs(refdir)
|
||||
@@ -82,7 +81,7 @@ master_doc = 'index'
|
||||
openstackdocs_repo_name = 'openstack/python-aodhclient'
|
||||
openstackdocs_bug_project = 'python-aodhclient'
|
||||
openstackdocs_bug_tag = ''
|
||||
copyright = u'2015, OpenStack Foundation'
|
||||
copyright = '2015, OpenStack Foundation'
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
add_function_parentheses = True
|
||||
@@ -115,8 +114,8 @@ htmlhelp_basename = 'aodhclientdoc'
|
||||
latex_documents = [
|
||||
('index',
|
||||
'aodhclient.tex',
|
||||
u'aodhclient Documentation',
|
||||
u'OpenStack Foundation', 'manual'),
|
||||
'aodhclient Documentation',
|
||||
'OpenStack Foundation', 'manual'),
|
||||
]
|
||||
|
||||
# Example configuration for intersphinx: refer to the Python standard library.
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
@@ -55,7 +54,7 @@ master_doc = 'index'
|
||||
openstackdocs_repo_name = 'openstack/python-aodhclient'
|
||||
openstackdocs_bug_project = 'python-aodhclient'
|
||||
openstackdocs_bug_tag = ''
|
||||
copyright = u'2015-present, Aodh developers'
|
||||
copyright = '2015-present, Aodh developers'
|
||||
|
||||
# Release notes are version independent.
|
||||
# The short X.Y version.
|
||||
@@ -190,8 +189,8 @@ htmlhelp_basename = 'AodhClientReleaseNotestdoc'
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
('index', 'PythonAodhClient.tex',
|
||||
u'Aodh Client Release Notes Documentation',
|
||||
u'Aodh developers', 'manual'),
|
||||
'Aodh Client Release Notes Documentation',
|
||||
'Aodh developers', 'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
@@ -220,8 +219,8 @@ latex_documents = [
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
('index', 'pythonaodhclient', u'Aodh Client Release Notes Documentation',
|
||||
[u'Aodh developers'], 1)
|
||||
('index', 'pythonaodhclient', 'Aodh Client Release Notes Documentation',
|
||||
['Aodh developers'], 1)
|
||||
]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
@@ -234,8 +233,8 @@ man_pages = [
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
('index', 'PythonAodhClient', u'Aodh Client Release Notes Documentation',
|
||||
u'Aodh developers', 'PythonAodhClient',
|
||||
('index', 'PythonAodhClient', 'Aodh Client Release Notes Documentation',
|
||||
'Aodh developers', 'PythonAodhClient',
|
||||
'One line description of project.', 'Miscellaneous'),
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user