Browse Source

Fix new pylint errors

Pylint 2.6.0 added two new checkers [1] that make pep8 validation to
fail:

- raise-missing-from (W0707)
- super-with-arguments (R1725)

[1] http://pylint.pycqa.org/en/latest/technical_reference/features.html

Change-Id: I15fd7082646d95414bdd8f0815ee44b5867b3ed0
changes/05/747405/1
Carlos Goncalves 1 year ago
parent
commit
bf3d5372b9
  1. 4
      octavia/amphorae/backends/agent/api_server/keepalivedlvs.py
  2. 16
      octavia/amphorae/backends/agent/api_server/osutils.py
  3. 9
      octavia/amphorae/backends/agent/api_server/server.py
  4. 5
      octavia/amphorae/backends/utils/haproxy_query.py
  5. 4
      octavia/amphorae/backends/utils/network_utils.py
  6. 4
      octavia/amphorae/driver_exceptions/exceptions.py
  7. 2
      octavia/amphorae/drivers/haproxy/exceptions.py
  8. 18
      octavia/amphorae/drivers/haproxy/rest_api_driver.py
  9. 2
      octavia/amphorae/drivers/keepalived/jinja/jinja_cfg.py
  10. 2
      octavia/amphorae/drivers/keepalived/vrrp_rest_driver.py
  11. 4
      octavia/amphorae/drivers/noop_driver/driver.py
  12. 9
      octavia/api/common/pagination.py
  13. 18
      octavia/api/common/types.py
  14. 2
      octavia/api/drivers/amphora_driver/v1/driver.py
  15. 2
      octavia/api/drivers/amphora_driver/v2/driver.py
  16. 2
      octavia/api/drivers/driver_agent/driver_updater.py
  17. 4
      octavia/api/drivers/noop_driver/driver.py
  18. 4
      octavia/api/healthcheck/healthcheck_plugins.py
  19. 2
      octavia/api/root_controller.py
  20. 6
      octavia/api/v2/controllers/__init__.py
  21. 8
      octavia/api/v2/controllers/amphora.py
  22. 18
      octavia/api/v2/controllers/availability_zone_profiles.py
  23. 16
      octavia/api/v2/controllers/availability_zones.py
  24. 2
      octavia/api/v2/controllers/base.py
  25. 20
      octavia/api/v2/controllers/flavor_profiles.py
  26. 14
      octavia/api/v2/controllers/flavors.py
  27. 14
      octavia/api/v2/controllers/health_monitor.py
  28. 10
      octavia/api/v2/controllers/l7policy.py
  29. 10
      octavia/api/v2/controllers/l7rule.py
  30. 8
      octavia/api/v2/controllers/listener.py
  31. 28
      octavia/api/v2/controllers/load_balancer.py
  32. 8
      octavia/api/v2/controllers/member.py
  33. 10
      octavia/api/v2/controllers/pool.py
  34. 6
      octavia/api/v2/controllers/provider.py
  35. 4
      octavia/api/v2/controllers/quotas.py
  36. 2
      octavia/api/v2/types/quotas.py
  37. 12
      octavia/certificates/generator/local.py
  38. 2
      octavia/certificates/manager/barbican.py
  39. 2
      octavia/certificates/manager/barbican_legacy.py
  40. 2
      octavia/certificates/manager/castellan_mgr.py
  41. 13
      octavia/certificates/manager/local.py
  42. 2
      octavia/cmd/agent.py
  43. 9
      octavia/common/base_taskflow.py
  44. 2
      octavia/common/context.py
  45. 6
      octavia/common/exceptions.py
  46. 2
      octavia/common/keystone.py
  47. 8
      octavia/common/policy.py
  48. 2
      octavia/common/stats.py
  49. 32
      octavia/common/tls_utils/cert_parser.py
  50. 32
      octavia/common/validate.py
  51. 4
      octavia/compute/drivers/noop_driver/driver.py
  52. 22
      octavia/compute/drivers/nova_driver.py
  53. 2
      octavia/controller/healthmanager/health_drivers/update_db.py
  54. 4
      octavia/controller/queue/v1/consumer.py
  55. 4
      octavia/controller/queue/v2/consumer.py
  56. 2
      octavia/controller/worker/task_utils.py
  57. 2
      octavia/controller/worker/v1/controller_worker.py
  58. 2
      octavia/controller/worker/v1/tasks/amphora_driver_tasks.py
  59. 2
      octavia/controller/worker/v1/tasks/cert_task.py
  60. 4
      octavia/controller/worker/v1/tasks/compute_tasks.py
  61. 8
      octavia/controller/worker/v1/tasks/database_tasks.py
  62. 6
      octavia/controller/worker/v1/tasks/lifecycle_tasks.py
  63. 2
      octavia/controller/worker/v1/tasks/network_tasks.py
  64. 2
      octavia/controller/worker/v1/tasks/retry_tasks.py
  65. 2
      octavia/controller/worker/v2/tasks/amphora_driver_tasks.py
  66. 2
      octavia/controller/worker/v2/tasks/cert_task.py
  67. 4
      octavia/controller/worker/v2/tasks/compute_tasks.py
  68. 8
      octavia/controller/worker/v2/tasks/database_tasks.py
  69. 6
      octavia/controller/worker/v2/tasks/lifecycle_tasks.py
  70. 2
      octavia/controller/worker/v2/tasks/network_tasks.py
  71. 22
      octavia/db/repositories.py
  72. 6
      octavia/distributor/drivers/noop_driver/driver.py
  73. 38
      octavia/network/drivers/neutron/allowed_address_pairs.py
  74. 18
      octavia/network/drivers/neutron/base.py
  75. 4
      octavia/network/drivers/noop_driver/driver.py
  76. 2
      octavia/tests/functional/amphorae/backend/agent/api_server/test_keepalivedlvs.py
  77. 2
      octavia/tests/functional/amphorae/backend/agent/api_server/test_server.py
  78. 2
      octavia/tests/functional/api/drivers/driver_agent/test_driver_agent.py
  79. 2
      octavia/tests/functional/api/test_healthcheck.py
  80. 2
      octavia/tests/functional/api/test_root_controller.py
  81. 2
      octavia/tests/functional/api/v2/base.py
  82. 2
      octavia/tests/functional/api/v2/test_amphora.py
  83. 2
      octavia/tests/functional/api/v2/test_availability_zones.py
  84. 2
      octavia/tests/functional/api/v2/test_flavors.py
  85. 2
      octavia/tests/functional/api/v2/test_health_monitor.py
  86. 2
      octavia/tests/functional/api/v2/test_l7policy.py
  87. 2
      octavia/tests/functional/api/v2/test_l7rule.py
  88. 2
      octavia/tests/functional/api/v2/test_listener.py
  89. 4
      octavia/tests/functional/api/v2/test_load_balancer.py
  90. 2
      octavia/tests/functional/api/v2/test_member.py
  91. 2
      octavia/tests/functional/api/v2/test_pool.py
  92. 6
      octavia/tests/functional/api/v2/test_provider.py
  93. 2
      octavia/tests/functional/api/v2/test_quotas.py
  94. 2
      octavia/tests/functional/db/base.py
  95. 26
      octavia/tests/functional/db/test_models.py
  96. 30
      octavia/tests/functional/db/test_repositories.py
  97. 2
      octavia/tests/unit/amphorae/backends/agent/api_server/test_amphora_info.py
  98. 2
      octavia/tests/unit/amphorae/backends/agent/api_server/test_haproxy_compatibility.py
  99. 2
      octavia/tests/unit/amphorae/backends/agent/api_server/test_keepalived.py
  100. 2
      octavia/tests/unit/amphorae/backends/agent/api_server/test_keepalivedlvs.py

4
octavia/amphorae/backends/agent/api_server/keepalivedlvs.py

@ -64,12 +64,12 @@ class KeepalivedLvs(udp_listener_base.UdpListenerApiServerBase):
assert True is os.path.exists(script_dir)
assert True is os.path.exists(os.path.join(
script_dir, CHECK_SCRIPT_NAME))
except Exception:
except Exception as e:
raise exceptions.Conflict(
description='%(file_name)s not Found for '
'UDP Listener %(listener_id)s' %
{'file_name': CHECK_SCRIPT_NAME,
'listener_id': listener_id})
'listener_id': listener_id}) from e
os.makedirs(util.keepalived_backend_check_script_dir())
shutil.copy2(os.path.join(script_dir, CHECK_SCRIPT_NAME),
util.keepalived_backend_check_script_path())

16
octavia/amphorae/backends/agent/api_server/osutils.py

@ -284,7 +284,7 @@ class Ubuntu(BaseOS):
network_dir = self.get_network_path()
if not ignore:
ignore = shutil.ignore_patterns('eth0*', 'openssh*')
super(Ubuntu, self).create_netns_dir(
super().create_netns_dir(
network_dir, netns_network_dir, ignore)
def write_interfaces_file(self):
@ -307,7 +307,7 @@ class Ubuntu(BaseOS):
render_host_routes, template_vip=None):
if not template_vip:
template_vip = j2_env.get_template(self.ETH_X_VIP_CONF)
super(Ubuntu, self).write_vip_interface_file(
super().write_vip_interface_file(
interface_file_path, primary_interface, vip, ip, broadcast,
netmask, gateway, mtu, vrrp_ip, vrrp_version, render_host_routes,
template_vip)
@ -320,7 +320,7 @@ class Ubuntu(BaseOS):
netns_interface)
if not template_port:
template_port = j2_env.get_template(self.ETH_X_PORT_CONF)
super(Ubuntu, self).write_port_interface_file(
super().write_port_interface_file(
netns_interface, fixed_ips, mtu, interface_file_path,
template_port)
@ -391,7 +391,7 @@ class RH(BaseOS):
network_dir = self.get_network_path()
if not ignore:
ignore = shutil.ignore_patterns('ifcfg-eth0*', 'ifcfg-lo*')
super(RH, self).create_netns_dir(
super().create_netns_dir(
network_dir, netns_network_dir, ignore)
# Copy /etc/sysconfig/network file
@ -410,7 +410,7 @@ class RH(BaseOS):
render_host_routes, template_vip=None):
if not template_vip:
template_vip = j2_env.get_template(self.ETH_X_VIP_CONF)
super(RH, self).write_vip_interface_file(
super().write_vip_interface_file(
interface_file_path, primary_interface, vip, ip, broadcast,
netmask, gateway, mtu, vrrp_ip, vrrp_version, render_host_routes,
template_vip)
@ -423,7 +423,7 @@ class RH(BaseOS):
alias_interface_file_path = self.get_alias_network_interface_file(
primary_interface)
template_vip_alias = j2_env.get_template(self.ETH_X_ALIAS_VIP_CONF)
super(RH, self).write_vip_interface_file(
super().write_vip_interface_file(
alias_interface_file_path, primary_interface, vip, ip,
broadcast, netmask, gateway, mtu, vrrp_ip, vrrp_version,
render_host_routes, template_vip_alias)
@ -486,7 +486,7 @@ class RH(BaseOS):
netns_interface)
if not template_port:
template_port = j2_env.get_template(self.ETH_X_PORT_CONF)
super(RH, self).write_port_interface_file(
super().write_port_interface_file(
netns_interface, fixed_ips, mtu, interface_file_path,
template_port)
@ -573,7 +573,7 @@ class RH(BaseOS):
class CentOS(RH):
def __init__(self, os_name):
super(CentOS, self).__init__(os_name)
super().__init__(os_name)
if distro.version() == '7':
self.package_name_map.update({'haproxy': 'haproxy18'})

9
octavia/amphorae/backends/agent/api_server/server.py

@ -186,9 +186,9 @@ class Server(object):
assert 'subnet_cidr' in net_info
assert 'gateway' in net_info
assert 'mac_address' in net_info
except Exception:
except Exception as e:
raise exceptions.BadRequest(
description='Invalid subnet information')
description='Invalid subnet information') from e
return self._plug.plug_vip(vip,
net_info['subnet_cidr'],
net_info['gateway'],
@ -202,8 +202,9 @@ class Server(object):
port_info = flask.request.get_json()
assert type(port_info) is dict
assert 'mac_address' in port_info
except Exception:
raise exceptions.BadRequest(description='Invalid port information')
except Exception as e:
raise exceptions.BadRequest(
description='Invalid port information') from e
return self._plug.plug_network(port_info['mac_address'],
port_info.get('fixed_ips'),
port_info.get('mtu'))

5
octavia/amphorae/backends/utils/haproxy_query.py

@ -47,8 +47,9 @@ class HAProxyQuery(object):
try:
sock.connect(self.socket)
except socket.error:
raise Exception(_("HAProxy '{0}' query failed.").format(query))
except socket.error as e:
raise Exception(
_("HAProxy '{0}' query failed.").format(query)) from e
try:
sock.send(octavia_utils.b(query + '\n'))

4
octavia/amphorae/backends/utils/network_utils.py

@ -69,8 +69,8 @@ def get_interface_name(ip_address, net_ns=None):
# fe80:0000:0000:0000:f816:3eff:fef2:2058 == fe80::f816:3eff:fef2:2058
try:
normalized_addr = ipaddress.ip_address(ip_address).compressed
except ValueError:
raise exceptions.InvalidIPAddress(ip_addr=ip_address)
except ValueError as e:
raise exceptions.InvalidIPAddress(ip_addr=ip_address) from e
if net_ns:
with pyroute2.NetNS(net_ns) as rtnl_api:

4
octavia/amphorae/driver_exceptions/exceptions.py

@ -23,14 +23,14 @@ class AmphoraDriverError(Exception):
def __init__(self, **kwargs):
try:
super(AmphoraDriverError, self).__init__(self.message % kwargs)
super().__init__(self.message % kwargs)
self.msg = self.message % kwargs
except Exception:
with excutils.save_and_reraise_exception() as ctxt:
if not self.use_fatal_exceptions():
ctxt.reraise = False
# at least get the core message out if something happened
super(AmphoraDriverError, self).__init__(self.message)
super().__init__(self.message)
def __unicode__(self):
return self.msg

2
octavia/amphorae/drivers/haproxy/exceptions.py

@ -52,7 +52,7 @@ class APIException(exc.HTTPClientError):
def __init__(self, **kwargs):
self.msg = self.msg % kwargs
super(APIException, self).__init__(detail=self.msg)
super().__init__(detail=self.msg)
class InvalidRequest(APIException):

18
octavia/amphorae/drivers/haproxy/rest_api_driver.py

@ -53,7 +53,7 @@ class HaproxyAmphoraLoadBalancerDriver(
vrrp_rest_driver.KeepalivedAmphoraDriverMixin):
def __init__(self):
super(HaproxyAmphoraLoadBalancerDriver, self).__init__()
super().__init__()
self.clients = {
'base': AmphoraAPIClientBase(),
'0.5': AmphoraAPIClient0_5(),
@ -587,10 +587,10 @@ class HaproxyAmphoraLoadBalancerDriver(
self._populate_amphora_api_version(amphora)
self.clients[amphora.api_version].update_agent_config(
amphora, agent_config, timeout_dict=timeout_dict)
except exc.NotFound:
except exc.NotFound as e:
LOG.debug('Amphora {} does not support the update_agent_config '
'API.'.format(amphora.id))
raise driver_except.AmpDriverNotImplementedError()
raise driver_except.AmpDriverNotImplementedError() from e
def get_interface_from_ip(self, amphora, ip_address, timeout_dict=None):
"""Get the interface name for an IP address.
@ -619,19 +619,17 @@ class HaproxyAmphoraLoadBalancerDriver(
class CustomHostNameCheckingAdapter(requests.adapters.HTTPAdapter):
def cert_verify(self, conn, url, verify, cert):
conn.assert_hostname = self.uuid
return super(CustomHostNameCheckingAdapter,
self).cert_verify(conn, url, verify, cert)
return super().cert_verify(conn, url, verify, cert)
def init_poolmanager(self, *pool_args, **pool_kwargs):
proto = CONF.amphora_agent.agent_tls_protocol.replace('.', '_')
pool_kwargs['ssl_version'] = getattr(ssl, "PROTOCOL_%s" % proto)
return super(CustomHostNameCheckingAdapter,
self).init_poolmanager(*pool_args, **pool_kwargs)
return super().init_poolmanager(*pool_args, **pool_kwargs)
class AmphoraAPIClientBase(object):
def __init__(self):
super(AmphoraAPIClientBase, self).__init__()
super().__init__()
self.get = functools.partial(self.request, 'get')
self.post = functools.partial(self.request, 'post')
@ -753,7 +751,7 @@ class AmphoraAPIClientBase(object):
class AmphoraAPIClient0_5(AmphoraAPIClientBase):
def __init__(self):
super(AmphoraAPIClient0_5, self).__init__()
super().__init__()
self.start_listener = functools.partial(self._action,
consts.AMP_ACTION_START)
@ -868,7 +866,7 @@ class AmphoraAPIClient0_5(AmphoraAPIClientBase):
class AmphoraAPIClient1_0(AmphoraAPIClientBase):
def __init__(self):
super(AmphoraAPIClient1_0, self).__init__()
super().__init__()
self.start_listener = functools.partial(self._action,
consts.AMP_ACTION_START)

2
octavia/amphorae/drivers/keepalived/jinja/jinja_cfg.py

@ -35,7 +35,7 @@ class KeepalivedJinjaTemplater(object):
:param keepalived_template: Absolute path to keepalived Jinja template
"""
super(KeepalivedJinjaTemplater, self).__init__()
super().__init__()
self.keepalived_template = (keepalived_template if
keepalived_template else
KEEPALIVED_TEMPLATE)

2
octavia/amphorae/drivers/keepalived/vrrp_rest_driver.py

@ -24,7 +24,7 @@ API_VERSION = constants.API_VERSION
class KeepalivedAmphoraDriverMixin(driver_base.VRRPDriverMixin):
def __init__(self):
super(KeepalivedAmphoraDriverMixin, self).__init__()
super().__init__()
# The Mixed class must define a self.client object for the
# AmphoraApiClient

4
octavia/amphorae/drivers/noop_driver/driver.py

@ -34,7 +34,7 @@ class LoggingUpdate(object):
class NoopManager(object):
def __init__(self):
super(NoopManager, self).__init__()
super().__init__()
self.amphoraconfig = {}
def update_amphora_listeners(self, loadbalancer, amphora, timeout_dict):
@ -135,7 +135,7 @@ class NoopAmphoraLoadBalancerDriver(
driver_base.AmphoraLoadBalancerDriver,
driver_base.VRRPDriverMixin):
def __init__(self):
super(NoopAmphoraLoadBalancerDriver, self).__init__()
super().__init__()
self.driver = NoopManager()
def update_amphora_listeners(self, loadbalancer, amphora, timeout_dict):

9
octavia/api/common/pagination.py

@ -77,8 +77,8 @@ class PaginationHelper(object):
# Otherwise, we need to compare against the max
else:
limit = min(int(limit), page_max_limit)
except ValueError:
raise exceptions.InvalidLimit(key=limit)
except ValueError as e:
raise exceptions.InvalidLimit(key=limit) from e
return limit
def _parse_sort_keys(self, params):
@ -318,8 +318,9 @@ class PaginationHelper(object):
try:
sort_key_attr = getattr(model, current_sort_key)
except AttributeError:
raise exceptions.InvalidSortKey(key=current_sort_key)
except AttributeError as e:
raise exceptions.InvalidSortKey(
key=current_sort_key) from e
query = query.order_by(sort_dir_func(sort_key_attr))
# Add pagination

18
octavia/api/common/types.py

@ -36,9 +36,9 @@ class IPAddressType(wtypes.UserType):
try:
wtypes.IPv6AddressType.validate(value)
return value
except ValueError:
except ValueError as e:
error = 'Value should be IPv4 or IPv6 format'
raise ValueError(error)
raise ValueError(error) from e
class CidrType(wtypes.UserType):
@ -50,9 +50,9 @@ class CidrType(wtypes.UserType):
"""Validates whether value is an IPv4 or IPv6 CIDR."""
try:
return str(netaddr.IPNetwork(value).cidr)
except (ValueError, netaddr.core.AddrFormatError):
except (ValueError, netaddr.core.AddrFormatError) as e:
error = 'Value should be IPv4 or IPv6 CIDR format'
raise ValueError(error)
raise ValueError(error) from e
class URLType(wtypes.UserType):
@ -60,15 +60,15 @@ class URLType(wtypes.UserType):
name = 'url'
def __init__(self, require_scheme=True):
super(URLType, self).__init__()
super().__init__()
self.require_scheme = require_scheme
def validate(self, value):
try:
validate.url(value, require_scheme=self.require_scheme)
except exceptions.InvalidURL:
except exceptions.InvalidURL as e:
error = 'Value must be a valid URL string'
raise ValueError(error)
raise ValueError(error) from e
return value
@ -80,9 +80,9 @@ class URLPathType(wtypes.UserType):
def validate(value):
try:
validate.url_path(value)
except exceptions.InvalidURLPath:
except exceptions.InvalidURLPath as e:
error = 'Value must be a valid URL Path string'
raise ValueError(error)
raise ValueError(error) from e
return value

2
octavia/api/drivers/amphora_driver/v1/driver.py

@ -46,7 +46,7 @@ AMPHORA_SUPPORTED_LB_ALGORITHMS = [
class AmphoraProviderDriver(driver_base.ProviderDriver):
def __init__(self):
super(AmphoraProviderDriver, self).__init__()
super().__init__()
topic = cfg.CONF.oslo_messaging.topic
self.target = messaging.Target(
namespace=consts.RPC_NAMESPACE_CONTROLLER_AGENT,

2
octavia/api/drivers/amphora_driver/v2/driver.py

@ -47,7 +47,7 @@ AMPHORA_SUPPORTED_LB_ALGORITHMS = [
class AmphoraProviderDriver(driver_base.ProviderDriver):
def __init__(self):
super(AmphoraProviderDriver, self).__init__()
super().__init__()
self.target = messaging.Target(
namespace=consts.RPC_NAMESPACE_CONTROLLER_AGENT,
topic=consts.TOPIC_AMPHORA_V2, version="2.0", fanout=False)

2
octavia/api/drivers/driver_agent/driver_updater.py

@ -34,7 +34,7 @@ class DriverUpdater(object):
self.listener_stats_repo = repo.ListenerStatisticsRepository()
self.db_session = db_apis.get_session()
super(DriverUpdater, self).__init__(**kwargs)
super().__init__(**kwargs)
def _check_for_lb_vip_deallocate(self, repo, lb_id):
lb = repo.get(self.db_session, id=lb_id)

4
octavia/api/drivers/noop_driver/driver.py

@ -23,7 +23,7 @@ LOG = logging.getLogger(__name__)
class NoopManager(object):
def __init__(self):
super(NoopManager, self).__init__()
super().__init__()
self.driverconfig = {}
# Load Balancer
@ -262,7 +262,7 @@ class NoopManager(object):
class NoopProviderDriver(driver_base.ProviderDriver):
def __init__(self):
super(NoopProviderDriver, self).__init__()
super().__init__()
self.driver = NoopManager()
# Load Balancer

4
octavia/api/healthcheck/healthcheck_plugins.py

@ -22,7 +22,7 @@ class OctaviaDBHealthcheck(pluginbase.HealthcheckBaseExtension):
UNAVAILABLE_REASON = 'The Octavia database is unavailable.'
def __init__(self, *args, **kwargs):
super(OctaviaDBHealthcheck, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
def healthcheck(self, server_port):
try:
@ -44,4 +44,4 @@ class OctaviaDBCheckResult(pluginbase.HealthcheckResult):
"""Result sub-class to provide a unique name in detail reports."""
def __init__(self, *args, **kwargs):
super(OctaviaDBCheckResult, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

2
octavia/api/root_controller.py

@ -31,7 +31,7 @@ class RootController(object):
"""The controller with which the pecan wsgi app should be created."""
def __init__(self):
super(RootController, self).__init__()
super().__init__()
setattr(self, 'v2.0', v2_controller.V2Controller())
setattr(self, 'v2', v2_controller.V2Controller())
if CONF.api_settings.healthcheck_enabled:

6
octavia/api/v2/controllers/__init__.py

@ -39,7 +39,7 @@ class BaseV2Controller(base.BaseController):
quotas = None
def __init__(self):
super(BaseV2Controller, self).__init__()
super().__init__()
self.loadbalancers = load_balancer.LoadBalancersController()
self.listeners = listener.ListenersController()
self.pools = pool.PoolsController()
@ -63,7 +63,7 @@ class OctaviaV2Controller(base.BaseController):
amphorae = None
def __init__(self):
super(OctaviaV2Controller, self).__init__()
super().__init__()
self.amphorae = amphora.AmphoraController()
@wsme_pecan.wsexpose(wtypes.text)
@ -75,6 +75,6 @@ class V2Controller(BaseV2Controller):
lbaas = None
def __init__(self):
super(V2Controller, self).__init__()
super().__init__()
self.lbaas = BaseV2Controller()
self.octavia = OctaviaV2Controller()

8
octavia/api/v2/controllers/amphora.py

@ -36,7 +36,7 @@ class AmphoraController(base.BaseController):
RBAC_TYPE = constants.RBAC_AMPHORA
def __init__(self):
super(AmphoraController, self).__init__()
super().__init__()
@wsme_pecan.wsexpose(amp_types.AmphoraRootResponse, wtypes.text,
[wtypes.text], ignore_extra_args=True)
@ -97,7 +97,7 @@ class FailoverController(base.BaseController):
RBAC_TYPE = constants.RBAC_AMPHORA
def __init__(self, amp_id):
super(FailoverController, self).__init__()
super().__init__()
if CONF.api_settings.default_provider_driver == constants.AMPHORAV2:
topic = constants.TOPIC_AMPHORA_V2
version = "2.0"
@ -147,7 +147,7 @@ class AmphoraUpdateController(base.BaseController):
RBAC_TYPE = constants.RBAC_AMPHORA
def __init__(self, amp_id):
super(AmphoraUpdateController, self).__init__()
super().__init__()
if CONF.api_settings.default_provider_driver == constants.AMPHORAV2:
topic = constants.TOPIC_AMPHORA_V2
@ -194,7 +194,7 @@ class AmphoraStatsController(base.BaseController):
RBAC_TYPE = constants.RBAC_AMPHORA
def __init__(self, amp_id):
super(AmphoraStatsController, self).__init__()
super().__init__()
self.amp_id = amp_id
@wsme_pecan.wsexpose(amp_types.StatisticsRootResponse, wtypes.text,

18
octavia/api/v2/controllers/availability_zone_profiles.py

@ -37,7 +37,7 @@ class AvailabilityZoneProfileController(base.BaseController):
RBAC_TYPE = constants.RBAC_AVAILABILITY_ZONE_PROFILE
def __init__(self):
super(AvailabilityZoneProfileController, self).__init__()
super().__init__()
@wsme_pecan.wsexpose(profile_types.AvailabilityZoneProfileRootResponse,
wtypes.text, [wtypes.text], ignore_extra_args=True)
@ -94,10 +94,10 @@ class AvailabilityZoneProfileController(base.BaseController):
try:
availability_zone_data_dict = jsonutils.loads(
availability_zone_profile.availability_zone_data)
except Exception:
except Exception as e:
raise exceptions.InvalidOption(
value=availability_zone_profile.availability_zone_data,
option=constants.AVAILABILITY_ZONE_DATA)
option=constants.AVAILABILITY_ZONE_DATA) from e
# Validate that the provider driver supports the metadata
driver = driver_factory.get_driver(
@ -115,9 +115,9 @@ class AvailabilityZoneProfileController(base.BaseController):
self.repositories.availability_zone_profile.create(
lock_session, **availability_zone_profile_dict))
lock_session.commit()
except odb_exceptions.DBDuplicateEntry:
except odb_exceptions.DBDuplicateEntry as e:
lock_session.rollback()
raise exceptions.IDAlreadyExists()
raise exceptions.IDAlreadyExists() from e
except Exception:
with excutils.save_and_reraise_exception():
lock_session.rollback()
@ -170,10 +170,10 @@ class AvailabilityZoneProfileController(base.BaseController):
try:
availability_zone_data_dict = jsonutils.loads(
availability_zone_profile.availability_zone_data)
except Exception:
except Exception as e:
raise exceptions.InvalidOption(
value=availability_zone_profile.availability_zone_data,
option=constants.FLAVOR_DATA)
option=constants.FLAVOR_DATA) from e
if isinstance(availability_zone_profile.provider_name,
wtypes.UnsetType):
@ -232,6 +232,6 @@ class AvailabilityZoneProfileController(base.BaseController):
try:
self.repositories.availability_zone_profile.delete(
context.session, id=availability_zone_profile_id)
except sa_exception.NoResultFound:
except sa_exception.NoResultFound as e:
raise exceptions.NotFound(resource='Availability Zone Profile',
id=availability_zone_profile_id)
id=availability_zone_profile_id) from e

16
octavia/api/v2/controllers/availability_zones.py

@ -34,7 +34,7 @@ class AvailabilityZonesController(base.BaseController):
RBAC_TYPE = constants.RBAC_AVAILABILITY_ZONE
def __init__(self):
super(AvailabilityZonesController, self).__init__()
super().__init__()
@wsme_pecan.wsexpose(availability_zone_types.AvailabilityZoneRootResponse,
wtypes.text, [wtypes.text], ignore_extra_args=True)
@ -93,10 +93,10 @@ class AvailabilityZonesController(base.BaseController):
db_availability_zone = self.repositories.availability_zone.create(
lock_session, **availability_zone_dict)
lock_session.commit()
except odb_exceptions.DBDuplicateEntry:
except odb_exceptions.DBDuplicateEntry as e:
lock_session.rollback()
raise exceptions.RecordAlreadyExists(field='availability zone',
name=availability_zone.name)
raise exceptions.RecordAlreadyExists(
field='availability zone', name=availability_zone.name) from e
except Exception:
with excutils.save_and_reraise_exception():
lock_session.rollback()
@ -159,14 +159,14 @@ class AvailabilityZonesController(base.BaseController):
serial_session, name=availability_zone_name)
serial_session.commit()
# Handle when load balancers still reference this availability_zone
except odb_exceptions.DBReferenceError:
except odb_exceptions.DBReferenceError as e:
serial_session.rollback()
raise exceptions.ObjectInUse(object='Availability Zone',
id=availability_zone_name)
except sa_exception.NoResultFound:
id=availability_zone_name) from e
except sa_exception.NoResultFound as e:
serial_session.rollback()
raise exceptions.NotFound(resource='Availability Zone',
id=availability_zone_name)
id=availability_zone_name) from e
except Exception as e:
with excutils.save_and_reraise_exception():
LOG.error(

2
octavia/api/v2/controllers/base.py

@ -36,7 +36,7 @@ class BaseController(pecan_rest.RestController):
RBAC_TYPE = None
def __init__(self):
super(BaseController, self).__init__()
super().__init__()
self.cert_manager = stevedore_driver.DriverManager(
namespace='octavia.cert_manager',
name=CONF.certificates.cert_manager,

20
octavia/api/v2/controllers/flavor_profiles.py

@ -38,7 +38,7 @@ class FlavorProfileController(base.BaseController):
RBAC_TYPE = constants.RBAC_FLAVOR_PROFILE
def __init__(self):
super(FlavorProfileController, self).__init__()
super().__init__()
@wsme_pecan.wsexpose(profile_types.FlavorProfileRootResponse, wtypes.text,
[wtypes.text], ignore_extra_args=True)
@ -87,10 +87,10 @@ class FlavorProfileController(base.BaseController):
# Do a basic JSON validation on the metadata
try:
flavor_data_dict = jsonutils.loads(flavorprofile.flavor_data)
except Exception:
except Exception as e:
raise exceptions.InvalidOption(
value=flavorprofile.flavor_data,
option=constants.FLAVOR_DATA)
option=constants.FLAVOR_DATA) from e
# Validate that the provider driver supports the metadata
driver = driver_factory.get_driver(flavorprofile.provider_name)
@ -104,9 +104,9 @@ class FlavorProfileController(base.BaseController):
db_flavor_profile = self.repositories.flavor_profile.create(
lock_session, **flavorprofile_dict)
lock_session.commit()
except odb_exceptions.DBDuplicateEntry:
except odb_exceptions.DBDuplicateEntry as e:
lock_session.rollback()
raise exceptions.IDAlreadyExists()
raise exceptions.IDAlreadyExists() from e
except Exception:
with excutils.save_and_reraise_exception():
lock_session.rollback()
@ -151,10 +151,10 @@ class FlavorProfileController(base.BaseController):
# Do a basic JSON validation on the metadata
try:
flavor_data_dict = jsonutils.loads(flavorprofile.flavor_data)
except Exception:
except Exception as e:
raise exceptions.InvalidOption(
value=flavorprofile.flavor_data,
option=constants.FLAVOR_DATA)
option=constants.FLAVOR_DATA) from e
if isinstance(flavorprofile.provider_name, wtypes.UnsetType):
db_flavor_profile = self._get_db_flavor_profile(
@ -207,6 +207,6 @@ class FlavorProfileController(base.BaseController):
try:
self.repositories.flavor_profile.delete(context.session,
id=flavor_profile_id)
except sa_exception.NoResultFound:
raise exceptions.NotFound(resource='Flavor profile',
id=flavor_profile_id)
except sa_exception.NoResultFound as e:
raise exceptions.NotFound(
resource='Flavor profile', id=flavor_profile_id) from e

14
octavia/api/v2/controllers/flavors.py

@ -36,7 +36,7 @@ class FlavorsController(base.BaseController):
RBAC_TYPE = constants.RBAC_FLAVOR
def __init__(self):
super(FlavorsController, self).__init__()
super().__init__()
@wsme_pecan.wsexpose(flavor_types.FlavorRootResponse, wtypes.text,
[wtypes.text], ignore_extra_args=True)
@ -90,10 +90,10 @@ class FlavorsController(base.BaseController):
db_flavor = self.repositories.flavor.create(lock_session,
**flavor_dict)
lock_session.commit()
except odb_exceptions.DBDuplicateEntry:
except odb_exceptions.DBDuplicateEntry as e:
lock_session.rollback()
raise exceptions.RecordAlreadyExists(field='flavor',
name=flavor.name)
name=flavor.name) from e
except Exception:
with excutils.save_and_reraise_exception():
lock_session.rollback()
@ -147,12 +147,12 @@ class FlavorsController(base.BaseController):
self.repositories.flavor.delete(serial_session, id=flavor_id)
serial_session.commit()
# Handle when load balancers still reference this flavor
except odb_exceptions.DBReferenceError:
except odb_exceptions.DBReferenceError as e:
serial_session.rollback()
raise exceptions.ObjectInUse(object='Flavor', id=flavor_id)
except sa_exception.NoResultFound:
raise exceptions.ObjectInUse(object='Flavor', id=flavor_id) from e
except sa_exception.NoResultFound as e:
serial_session.rollback()
raise exceptions.NotFound(resource='Flavor', id=flavor_id)
raise exceptions.NotFound(resource='Flavor', id=flavor_id) from e
except Exception as e:
with excutils.save_and_reraise_exception():
LOG.error('Unknown flavor delete exception: %s', str(e))

14
octavia/api/v2/controllers/health_monitor.py

@ -42,7 +42,7 @@ class HealthMonitorController(base.BaseController):
RBAC_TYPE = consts.RBAC_HEALTHMONITOR
def __init__(self):
super(HealthMonitorController, self).__init__()
super().__init__()
@wsme_pecan.wsexpose(hm_types.HealthMonitorRootResponse, wtypes.text,
[wtypes.text], ignore_extra_args=True)
@ -156,13 +156,13 @@ class HealthMonitorController(base.BaseController):
try:
return self.repositories.health_monitor.create(
lock_session, **hm_dict)
except odb_exceptions.DBDuplicateEntry:
raise exceptions.DuplicateHealthMonitor()
except odb_exceptions.DBError:
except odb_exceptions.DBDuplicateEntry as e:
raise exceptions.DuplicateHealthMonitor() from e
except odb_exceptions.DBError as e:
# TODO(blogan): will have to do separate validation protocol
# before creation or update since the exception messages
# do not give any information as to what constraint failed
raise exceptions.InvalidOption(value='', option='')
raise exceptions.InvalidOption(value='', option='') from e
def _validate_healthmonitor_request_for_udp(self, request):
if request.type not in (
@ -248,10 +248,10 @@ class HealthMonitorController(base.BaseController):
driver.name, driver.health_monitor_create, provider_healthmon)
lock_session.commit()
except odb_exceptions.DBError:
except odb_exceptions.DBError as e:
lock_session.rollback()
raise exceptions.InvalidOption(
value=hm_dict.get('type'), option='type')
value=hm_dict.get('type'), option='type') from e
except Exception:
with excutils.save_and_reraise_exception():
lock_session.rollback()

10
octavia/api/v2/controllers/l7policy.py

@ -43,7 +43,7 @@ class L7PolicyController(base.BaseController):
RBAC_TYPE = constants.RBAC_L7POLICY
def __init__(self):
super(L7PolicyController, self).__init__()
super().__init__()
@wsme_pecan.wsexpose(l7policy_types.L7PolicyRootResponse, wtypes.text,
[wtypes.text], ignore_extra_args=True)
@ -103,13 +103,13 @@ class L7PolicyController(base.BaseController):
return self.repositories.l7policy.create(lock_session,
**l7policy_dict)
except odb_exceptions.DBDuplicateEntry:
raise exceptions.IDAlreadyExists()
except odb_exceptions.DBError:
except odb_exceptions.DBDuplicateEntry as e:
raise exceptions.IDAlreadyExists() from e
except odb_exceptions.DBError as e:
# TODO(blogan): will have to do separate validation protocol
# before creation or update since the exception messages
# do not give any information as to what constraint failed
raise exceptions.InvalidOption(value='', option='')
raise exceptions.InvalidOption(value='', option='') from e
@wsme_pecan.wsexpose(l7policy_types.L7PolicyRootResponse,
body=l7policy_types.L7PolicyRootPOST, status_code=201)

10
octavia/api/v2/controllers/l7rule.py

@ -39,7 +39,7 @@ class L7RuleController(base.BaseController):
RBAC_TYPE = constants.RBAC_L7RULE
def __init__(self, l7policy_id):
super(L7RuleController, self).__init__()
super().__init__()
self.l7policy_id = l7policy_id
@wsme_pecan.wsexpose(l7rule_types.L7RuleRootResponse, wtypes.text,
@ -110,13 +110,13 @@ class L7RuleController(base.BaseController):
def _validate_create_l7rule(self, lock_session, l7rule_dict):
try:
return self.repositories.l7rule.create(lock_session, **l7rule_dict)
except odb_exceptions.DBDuplicateEntry:
raise exceptions.IDAlreadyExists()
except odb_exceptions.DBError:
except odb_exceptions.DBDuplicateEntry as e:
raise exceptions.IDAlreadyExists() from e
except odb_exceptions.DBError as e:
# TODO(blogan): will have to do separate validation protocol
# before creation or update since the exception messages
# do not give any information as to what constraint failed
raise exceptions.InvalidOption(value='', option='')
raise exceptions.InvalidOption(value='', option='') from e
@wsme_pecan.wsexpose(l7rule_types.L7RuleRootResponse,
body=l7rule_types.L7RuleRootPOST, status_code=201)

8
octavia/api/v2/controllers/listener.py

@ -47,7 +47,7 @@ class ListenersController(base.BaseController):
RBAC_TYPE = constants.RBAC_LISTENER
def __init__(self):
super(ListenersController, self).__init__()
super().__init__()
@wsme_pecan.wsexpose(listener_types.ListenerRootResponse, wtypes.text,
[wtypes.text], ignore_extra_args=True)
@ -323,9 +323,9 @@ class ListenersController(base.BaseController):
raise exceptions.DuplicateListenerEntry(
protocol=listener_dict.get('protocol'),
port=listener_dict.get('protocol_port'))
except odb_exceptions.DBError:
except odb_exceptions.DBError as e:
raise exceptions.InvalidOption(value=listener_dict.get('protocol'),
option='protocol')
option='protocol') from e
@wsme_pecan.wsexpose(listener_types.ListenerRootResponse,
body=listener_types.ListenerRootPOST, status_code=201)
@ -647,7 +647,7 @@ class StatisticsController(base.BaseController, stats.StatsMixin):
RBAC_TYPE = constants.RBAC_LISTENER
def __init__(self, listener_id):
super(StatisticsController, self).__init__()
super().__init__()
self.id = listener_id
@wsme_pecan.wsexpose(listener_types.StatisticsRootResponse, wtypes.text,

28
octavia/api/v2/controllers/load_balancer.py

@ -52,7 +52,7 @@ class LoadBalancersController(base.BaseController):
RBAC_TYPE = constants.RBAC_LOADBALANCER
def __init__(self):
super(LoadBalancersController, self).__init__()
super().__init__()
@wsme_pecan.wsexpose(lb_types.LoadBalancerRootResponse, wtypes.text,
[wtypes.text], ignore_extra_args=True)
@ -293,9 +293,9 @@ class LoadBalancersController(base.BaseController):
try:
provider = self.repositories.flavor.get_flavor_provider(
session, load_balancer.flavor_id)
except sa_exception.NoResultFound:
except sa_exception.NoResultFound as e:
raise exceptions.ValidationException(
detail=_("Invalid flavor_id."))
detail=_("Invalid flavor_id.")) from e
# No provider specified and no flavor specified, use conf default
if (isinstance(load_balancer.provider, wtypes.UnsetType) and
@ -322,9 +322,9 @@ class LoadBalancersController(base.BaseController):
flavor_dict = (
self.repositories.flavor.get_flavor_metadata_dict(
lock_session, lb_dict['flavor_id']))
except sa_exception.NoResultFound:
except sa_exception.NoResultFound as e:
raise exceptions.ValidationException(
detail=_("Invalid flavor_id."))
detail=_("Invalid flavor_id.")) from e
# Make sure the driver will still accept the flavor metadata
if flavor_dict:
@ -361,9 +361,9 @@ class LoadBalancersController(base.BaseController):
self.repositories.availability_zone
.get_availability_zone_metadata_dict(lock_session, az.name)
)
except sa_exception.NoResultFound:
except sa_exception.NoResultFound as e:
raise exceptions.ValidationException(
detail=_("Invalid availability_zone."))
detail=_("Invalid availability_zone.")) from e
# Make sure the driver will still accept the availability zone metadata
if az_dict:
@ -371,10 +371,10 @@ class LoadBalancersController(base.BaseController):
driver_utils.call_provider(driver.name,
driver.validate_availability_zone,
az_dict)
except NotImplementedError:
except NotImplementedError as e:
raise exceptions.ProviderNotImplementedError(
prov=driver.name, user_msg="This provider does not support"
" availability zones.")
" availability zones.") from e
return az_dict
@ -513,9 +513,9 @@ class LoadBalancersController(base.BaseController):
driver_dm.LoadBalancer.from_dict(driver_lb_dict))
lock_session.commit()
except odb_exceptions.DBDuplicateEntry:
except odb_exceptions.DBDuplicateEntry as e:
lock_session.rollback()
raise exceptions.IDAlreadyExists()
raise exceptions.IDAlreadyExists() from e
except Exception:
with excutils.save_and_reraise_exception():
lock_session.rollback()
@ -758,7 +758,7 @@ class StatusController(base.BaseController):
RBAC_TYPE = constants.RBAC_LOADBALANCER
def __init__(self, lb_id):
super(StatusController, self).__init__()
super().__init__()
self.id = lb_id
@wsme_pecan.wsexpose(lb_types.StatusRootResponse, wtypes.text,
@ -786,7 +786,7 @@ class StatisticsController(base.BaseController, stats.StatsMixin):
RBAC_TYPE = constants.RBAC_LOADBALANCER
def __init__(self, lb_id):
super(StatisticsController, self).__init__()
super().__init__()
self.id = lb_id
@wsme_pecan.wsexpose(lb_types.StatisticsRootResponse, wtypes.text,
@ -814,7 +814,7 @@ class StatisticsController(base.BaseController, stats.StatsMixin):
class FailoverController(LoadBalancersController):
def __init__(self, lb_id):
super(FailoverController, self).__init__()
super().__init__()
self.lb_id = lb_id
@wsme_pecan.wsexpose(None, wtypes.text, status_code=202)

8
octavia/api/v2/controllers/member.py

@ -41,7 +41,7 @@ class MemberController(base.BaseController):
RBAC_TYPE = constants.RBAC_MEMBER
def __init__(self, pool_id):
super(MemberController, self).__init__()
super().__init__()
self.pool_id = pool_id
@wsme_pecan.wsexpose(member_types.MemberRootResponse, wtypes.text,
@ -129,11 +129,11 @@ class MemberController(base.BaseController):
raise exceptions.DuplicateMemberEntry(
ip_address=member_dict.get('ip_address'),
port=member_dict.get('protocol_port'))
except odb_exceptions.DBError:
except odb_exceptions.DBError as e:
# TODO(blogan): will have to do separate validation protocol
# before creation or update since the exception messages
# do not give any information as to what constraint failed
raise exceptions.InvalidOption(value='', option='')
raise exceptions.InvalidOption(value='', option='') from e
def _validate_pool_id(self, member_id, db_member_pool_id):
if db_member_pool_id != self.pool_id:
@ -319,7 +319,7 @@ class MemberController(base.BaseController):
class MembersController(MemberController):
def __init__(self, pool_id):
super(MembersController, self).__init__(pool_id)
super().__init__(pool_id)
@wsme_pecan.wsexpose(None, wtypes.text,
body=member_types.MembersRootPUT, status_code=202)

10
octavia/api/v2/controllers/pool.py

@ -46,7 +46,7 @@ class PoolsController(base.BaseController):
RBAC_TYPE = constants.RBAC_POOL
def __init__(self):
super(PoolsController, self).__init__()
super().__init__()
@wsme_pecan.wsexpose(pool_types.PoolRootResponse, wtypes.text,
[wtypes.text], ignore_extra_args=True)
@ -141,13 +141,13 @@ class PoolsController(base.BaseController):
return self.repositories.create_pool_on_load_balancer(
lock_session, pool_dict,
listener_id=listener_id)
except odb_exceptions.DBDuplicateEntry:
raise exceptions.IDAlreadyExists()
except odb_exceptions.DBError:
except odb_exceptions.DBDuplicateEntry as e:
raise exceptions.IDAlreadyExists() from e
except odb_exceptions.DBError as e:
# TODO(blogan): will have to do separate validation protocol
# before creation or update since the exception messages
# do not give any information as to what constraint failed
raise exceptions.InvalidOption(value='', option='')
raise exceptions.InvalidOption(value='', option='') from e
def _is_only_specified_in_request(self, request, **kwargs):
request_attrs = []

6
octavia/api/v2/controllers/provider.py

@ -34,7 +34,7 @@ class ProviderController(base.BaseController):
RBAC_TYPE = constants.RBAC_PROVIDER
def __init__(self):
super(ProviderController, self).__init__()
super().__init__()
@wsme_pecan.wsexpose(provider_types.ProvidersRootResponse, [wtypes.text],
ignore_extra_args=True)
@ -76,7 +76,7 @@ class FlavorCapabilitiesController(base.BaseController):
RBAC_TYPE = constants.RBAC_PROVIDER_FLAVOR
def __init__(self, provider):
super(FlavorCapabilitiesController, self).__init__()
super().__init__()
self.provider = provider
@wsme_pecan.wsexpose(provider_types.FlavorCapabilitiesResponse,
@ -126,7 +126,7 @@ class AvailabilityZoneCapabilitiesController(base.BaseController):
RBAC_TYPE = constants.RBAC_PROVIDER_AVAILABILITY_ZONE
def __init__(self, provider):
super(AvailabilityZoneCapabilitiesController, self).__init__()
super().__init__()
self.provider = provider
@wsme_pecan.wsexpose(provider_types.AvailabilityZoneCapabilitiesResponse,

4
octavia/api/v2/controllers/quotas.py

@ -31,7 +31,7 @@ class QuotasController(base.BaseController):
RBAC_TYPE = constants.RBAC_QUOTA
def __init__(self):
super(QuotasController, self).__init__()
super().__init__()
@wsme_pecan.wsexpose(quota_types.QuotaResponse, wtypes.text)
def get(self, project_id):
@ -103,7 +103,7 @@ class QuotasDefaultController(base.BaseController):
RBAC_TYPE = constants.RBAC_QUOTA
def __init__(self, project_id):
super(QuotasDefaultController, self).__init__()
super().__init__()
self.project_id = project_id
@wsme_pecan.wsexpose(quota_types.QuotaResponse, wtypes.text)

2
octavia/api/v2/types/quotas.py

@ -42,7 +42,7 @@ class QuotaBase(base.BaseType):
minimum=consts.MIN_QUOTA, maximum=consts.MAX_QUOTA))
def to_dict(self, render_unsets=False):
quota_dict = super(QuotaBase, self).to_dict(render_unsets)
quota_dict = super().to_dict(render_unsets)
if 'loadbalancer' in quota_dict:
quota_dict['load_balancer'] = quota_dict.pop('loadbalancer')
if 'healthmonitor' in quota_dict:

12
octavia/certificates/generator/local.py

@ -46,20 +46,20 @@ class LocalCertGenerator(cert_gen.CertGenerator):
LOG.info("Using CA Certificate from config.")
try:
ca_cert = open(CONF.certificates.ca_certificate, 'rb').read()
except IOError:
except IOError as e:
raise exceptions.CertificateGenerationException(
msg="Failed to load CA Certificate {0}."
.format(CONF.certificates.ca_certificate)
)
) from e
if not ca_key:
LOG.info("Using CA Private Key from config.")
try:
ca_key = open(CONF.certificates.ca_private_key, 'rb').read()
except IOError:
except IOError as e:
raise exceptions.CertificateGenerationException(
msg="Failed to load CA Private Key {0}."
.format(CONF.certificates.ca_private_key)
)
) from e
if not ca_key_pass:
ca_key_pass = CONF.certificates.ca_private_key_passphrase
if ca_key_pass:
@ -92,10 +92,10 @@ class LocalCertGenerator(cert_gen.CertGenerator):
ca_digest = CONF.certificates.signing_digest
try:
algorithm = getattr(hashes, ca_digest.upper())()
except AttributeError:
except AttributeError as e:
raise crypto_exceptions.UnsupportedAlgorithm(
"Supplied digest method not found: %s" % ca_digest
)
) from e
if not ca_cert:
with open(CONF.certificates.ca_certificate, 'rb') as f:

2
octavia/certificates/manager/barbican.py

@ -38,7 +38,7 @@ class BarbicanCertManager(cert_mgr.CertManager):
"""Certificate Manager that wraps the Barbican client API."""
def __init__(self):
super(BarbicanCertManager, self).__init__()
super().__init__()
self.auth = stevedore_driver.DriverManager(
namespace='octavia.barbican_auth',
name=cfg.CONF.certificates.barbican_auth,

2
octavia/certificates/manager/barbican_legacy.py

@ -32,7 +32,7 @@ class BarbicanCertManager(cert_mgr.CertManager):
"""Certificate Manager that wraps the Barbican client API."""
def __init__(self, auth=None):
super(BarbicanCertManager, self).__init__()
super().__init__()
if auth:
self.auth = auth
else:

2
octavia/certificates/manager/castellan_mgr.py

@ -32,7 +32,7 @@ class CastellanCertManager(cert_mgr.CertManager):
"""Certificate Manager for the Castellan library."""
def __init__(self):
super(CastellanCertManager, self).__init__()
super().__init__()
self.manager = key_manager.API()
def store_cert(self, context, certificate, private_key, intermediates=None,

13
octavia/certificates/manager/local.py