Files
neutron-fwaas/neutron_fwaas/services/firewall/service_drivers/agents/firewall_service.py
elajkat 070113c906 pyupgrade changes for Python3.9+
As discussed at the Epoxy PTG meeting, run an automated
upgrade tool to make code python 3.9+ compliant.

Result of running:

$ pyupgrade --py39-plus $(git ls-files | grep ".py$")

Fixed PEP8 errors introduced by pyupgrade by running:

$ autopep8 --select=E127,E128,E501 --max-line-length 79 -r \
  --in-place neutron_fwaas

Also did manual updates as necessary to fix other errors
and warnings after above commands.

Inspired by Octavia and Nova [0].

[0] https://review.opendev.org/c/openstack/nova/+/896986

Change-Id: I28003aa9e42479ac966a05edd174fc0435e57e3a
2024-11-14 09:14:53 +00:00

45 lines
1.6 KiB
Python

# Copyright 2014 OpenStack Foundation.
# All Rights Reserved.
#
# 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from neutron.services import provider_configuration as provconf
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import importutils
from neutron_fwaas._i18n import _
LOG = logging.getLogger(__name__)
FIREWALL_DRIVERS = 'firewall_drivers'
class FirewallService:
"""Firewall Service observer."""
def load_device_drivers(self):
"""Loads a single device driver for FWaaS."""
device_driver = provconf.get_provider_driver_class(
cfg.CONF.fwaas.driver, FIREWALL_DRIVERS)
try:
driver = importutils.import_object(device_driver)
LOG.debug('Loaded FWaaS device driver: %s', device_driver)
return driver
except ImportError:
msg = _('Error importing FWaaS device driver: %s')
raise ImportError(msg % device_driver)
except ValueError:
msg = _('Configuration error - no FWaaS device_driver specified')
raise ValueError(msg)