Remove log translations from octavia

Log messages are no longer being translated. This removes all use of
the _LE, _LI, and _LW translation markers to simplify logging and to
avoid confusion with new contributions.

This patch also adds hacking rules for the translation tags.

See: http://lists.openstack.org/pipermail/openstack-i18n/2016-November/002574.html
http://lists.openstack.org/pipermail/openstack-dev/2017-March/113365.html

Co-Authored-By: Michael Johnson <johnsomor@gmail.com>
Change-Id: Ic95111d09e38b3f44fd6c85d0bcf0355c21ef545
changes/72/447872/8
e 6 years ago committed by Michael Johnson
parent 7829ed96f6
commit dc882e9d27
  1. 3
      HACKING.rst
  2. 15
      octavia/amphorae/backends/agent/api_server/listener.py
  3. 14
      octavia/amphorae/backends/agent/api_server/osutils.py
  4. 15
      octavia/amphorae/backends/agent/api_server/plug.py
  5. 7
      octavia/amphorae/backends/health_daemon/health_daemon.py
  6. 9
      octavia/amphorae/backends/health_daemon/health_sender.py
  7. 7
      octavia/amphorae/backends/health_daemon/status_message.py
  8. 2
      octavia/amphorae/backends/utils/haproxy_query.py
  9. 21
      octavia/amphorae/drivers/haproxy/rest_api_driver.py
  10. 6
      octavia/amphorae/drivers/health/heartbeat_udp.py
  11. 7
      octavia/amphorae/drivers/keepalived/vrrp_rest_driver.py
  12. 81
      octavia/api/handlers/controller_simulator/handler.py
  13. 3
      octavia/api/v1/controllers/base.py
  14. 20
      octavia/api/v1/controllers/health_monitor.py
  15. 14
      octavia/api/v1/controllers/l7policy.py
  16. 12
      octavia/api/v1/controllers/l7rule.py
  17. 16
      octavia/api/v1/controllers/listener.py
  18. 32
      octavia/api/v1/controllers/load_balancer.py
  19. 12
      octavia/api/v1/controllers/member.py
  20. 16
      octavia/api/v1/controllers/pool.py
  21. 3
      octavia/api/v2/controllers/base.py
  22. 17
      octavia/api/v2/controllers/health_monitor.py
  23. 13
      octavia/api/v2/controllers/l7policy.py
  24. 13
      octavia/api/v2/controllers/l7rule.py
  25. 14
      octavia/api/v2/controllers/listener.py
  26. 14
      octavia/api/v2/controllers/load_balancer.py
  27. 13
      octavia/api/v2/controllers/member.py
  28. 15
      octavia/api/v2/controllers/pool.py
  29. 4
      octavia/certificates/common/auth/barbican_acl.py
  30. 7
      octavia/certificates/common/barbican.py
  31. 8
      octavia/certificates/generator/anchor.py
  32. 20
      octavia/certificates/generator/local.py
  33. 42
      octavia/certificates/manager/barbican.py
  34. 3
      octavia/cmd/api.py
  35. 7
      octavia/cmd/health_manager.py
  36. 18
      octavia/cmd/house_keeping.py
  37. 7
      octavia/common/clients.py
  38. 3
      octavia/common/config.py
  39. 4
      octavia/common/exceptions.py
  40. 3
      octavia/common/policy.py
  41. 7
      octavia/common/stats.py
  42. 20
      octavia/common/tls_utils/cert_parser.py
  43. 34
      octavia/compute/drivers/nova_driver.py
  44. 5
      octavia/controller/healthmanager/health_manager.py
  45. 33
      octavia/controller/healthmanager/update_db.py
  46. 18
      octavia/controller/housekeeping/house_keeping.py
  47. 12
      octavia/controller/queue/consumer.py
  48. 43
      octavia/controller/queue/endpoint.py
  49. 6
      octavia/controller/worker/controller_worker.py
  50. 6
      octavia/controller/worker/flows/load_balancer_flows.py
  51. 68
      octavia/controller/worker/task_utils.py
  52. 42
      octavia/controller/worker/tasks/amphora_driver_tasks.py
  53. 21
      octavia/controller/worker/tasks/compute_tasks.py
  54. 351
      octavia/controller/worker/tasks/database_tasks.py
  55. 32
      octavia/controller/worker/tasks/network_tasks.py
  56. 2
      octavia/db/migration/cli.py
  57. 63
      octavia/db/repositories.py
  58. 118
      octavia/hacking/checks.py
  59. 40
      octavia/network/drivers/neutron/allowed_address_pairs.py

@ -13,7 +13,6 @@ Octavia Specific Commandments
- [O318] Change assert(Not)Equal(A, None) or assert(Not)Equal(None, A)
by optimal assert like assertIs(Not)None(A).
- [O319] Validate that debug level logs are not translated.
- [O320] Validate that LOG messages, except debug ones, have translations
- [O321] Validate that jsonutils module is used instead of json
- [O322] Don't use author tags
- [O323] Change assertEqual(True, A) or assertEqual(False, A) to the more
@ -24,6 +23,8 @@ Octavia Specific Commandments
specific assertIn/NotIn(A, B)
- [O339] LOG.warn() is not allowed. Use LOG.warning()
- [O340] Don't use xrange()
- [O341] Don't translate logs.
- [0342] Exception messages should be translated
Creating Unit Tests
-------------------

@ -33,7 +33,6 @@ from octavia.amphorae.backends.agent.api_server import util
from octavia.amphorae.backends.utils import haproxy_query as query
from octavia.common import constants as consts
from octavia.common import utils as octavia_utils
from octavia.i18n import _LE
LOG = logging.getLogger(__name__)
BUFFER = 100
@ -136,7 +135,7 @@ class Listener(object):
try:
subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
LOG.error(_LE("Failed to verify haproxy file: %s"), e)
LOG.error("Failed to verify haproxy file: %s", e)
os.remove(name) # delete file
return flask.make_response(flask.jsonify(dict(
message="Invalid request",
@ -166,7 +165,7 @@ class Listener(object):
raise util.UnknownInitError()
except util.UnknownInitError:
LOG.error(_LE("Unknown init system found."))
LOG.error("Unknown init system found.")
return flask.make_response(flask.jsonify(dict(
message="Unknown init system in amphora",
details="The amphora image is running an unknown init "
@ -203,8 +202,7 @@ class Listener(object):
subprocess.check_output(init_enable_cmd.split(),
stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
LOG.error(_LE("Failed to enable haproxy-%(list)s "
"service: %(err)s"),
LOG.error("Failed to enable haproxy-%(list)s service: %(err)s",
{'list': listener_id, 'err': e})
return flask.make_response(flask.jsonify(dict(
message="Error enabling haproxy-{0} service".format(
@ -276,7 +274,7 @@ class Listener(object):
try:
subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
LOG.error(_LE("Failed to stop HAProxy service: %s"), e)
LOG.error("Failed to stop HAProxy service: %s", e)
return flask.make_response(flask.jsonify(dict(
message="Error stopping haproxy",
details=e.output)), 500)
@ -311,9 +309,8 @@ class Listener(object):
subprocess.check_output(init_disable_cmd.split(),
stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
LOG.error(_LE("Failed to disable haproxy-%(list)s "
"service: %(err)s"),
{'list': listener_id, 'err': e})
LOG.error("Failed to disable haproxy-%(list)s service: "
"%(err)s", {'list': listener_id, 'err': e})
return flask.make_response(flask.jsonify(dict(
message="Error disabling haproxy-{0} service".format(
listener_id), details=e.output)), 500)

@ -29,7 +29,6 @@ from werkzeug import exceptions
from octavia.common import constants as consts
from octavia.common import exceptions as octavia_exceptions
from octavia.common import utils
from octavia.i18n import _LE
CONF = cfg.CONF
@ -144,12 +143,11 @@ class BaseOS(object):
try:
ip_addr = fixed_ip['ip_address']
cidr = fixed_ip['subnet_cidr']
ip = ipaddress.ip_address(
ip_addr if six.text_type == type(
ip_addr) else six.u(ip_addr))
ip = ipaddress.ip_address(ip_addr if isinstance(
ip_addr, six.text_type) else six.u(ip_addr))
network = ipaddress.ip_network(
cidr if six.text_type == type(
cidr) else six.u(cidr))
cidr if isinstance(
cidr, six.text_type) else six.u(cidr))
broadcast = network.broadcast_address.exploded
netmask = (network.prefixlen if ip.version is 6
else network.netmask.exploded)
@ -186,8 +184,8 @@ class BaseOS(object):
try:
subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
LOG.error(_LE('Failed to if up {0} due to '
'error: {1}').format(interface, str(e)))
LOG.error('Failed to if up {0} due to '
'error: {1}'.format(interface, str(e)))
raise exceptions.HTTPException(
response=flask.make_response(flask.jsonify(dict(
message='Error plugging {0}'.format(what),

@ -29,7 +29,6 @@ import six
from werkzeug import exceptions
from octavia.common import constants as consts
from octavia.i18n import _LI
CONF = cfg.CONF
@ -55,9 +54,9 @@ class Plug(object):
try:
render_host_routes = []
ip = ipaddress.ip_address(
vip if six.text_type == type(vip) else six.u(vip))
vip if isinstance(vip, six.text_type) else six.u(vip))
network = ipaddress.ip_network(
subnet_cidr if six.text_type == type(subnet_cidr)
subnet_cidr if isinstance(subnet_cidr, six.text_type)
else six.u(subnet_cidr))
vip = ip.exploded
broadcast = network.broadcast_address.exploded
@ -66,7 +65,7 @@ class Plug(object):
vrrp_version = None
if vrrp_ip:
vrrp_ip_obj = ipaddress.ip_address(
vrrp_ip if six.text_type == type(vrrp_ip)
vrrp_ip if isinstance(vrrp_ip, six.text_type)
else six.u(vrrp_ip)
)
vrrp_version = vrrp_ip_obj.version
@ -184,10 +183,10 @@ class Plug(object):
# Note, eth0 is skipped because that is the VIP interface
netns_interface = 'eth{0}'.format(len(netns.get_links()))
LOG.info(_LI('Plugged interface {0} will become {1} in the '
'namespace {2}').format(default_netns_interface,
netns_interface,
consts.AMPHORA_NAMESPACE))
LOG.info('Plugged interface {0} will become {1} in the '
'namespace {2}'.format(default_netns_interface,
netns_interface,
consts.AMPHORA_NAMESPACE))
interface_file_path = self._osutils.get_network_interface_file(
netns_interface)
self._osutils.write_port_interface_file(

@ -24,7 +24,6 @@ import six
from octavia.amphorae.backends.agent.api_server import util
from octavia.amphorae.backends.health_daemon import health_sender
from octavia.amphorae.backends.utils import haproxy_query
from octavia.i18n import _LI
if six.PY2:
import Queue as queue
@ -48,7 +47,7 @@ def list_sock_stat_files(hadir=None):
def run_sender(cmd_queue):
LOG.info(_LI('Health Manager Sender starting.'))
LOG.info('Health Manager Sender starting.')
sender = health_sender.UDPStatusSender()
while True:
message = build_stats_message()
@ -56,10 +55,10 @@ def run_sender(cmd_queue):
try:
cmd = cmd_queue.get_nowait()
if cmd is 'reload':
LOG.info(_LI('Reloading configuration'))
LOG.info('Reloading configuration')
CONF.reload_config_files()
elif cmd is 'shutdown':
LOG.info(_LI('Health Manager Sender shutting down.'))
LOG.info('Health Manager Sender shutting down.')
break
except queue.Empty:
pass

@ -18,7 +18,6 @@ from oslo_config import cfg
from oslo_log import log as logging
from octavia.amphorae.backends.health_daemon import status_message
from octavia.i18n import _LE
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
@ -39,9 +38,8 @@ class UDPStatusSender(object):
try:
ip, port = ipport.rsplit(':', 1)
except ValueError:
LOG.error(_LE("Invalid ip and port '%s' in "
"health_manager controller_ip_port_list"),
ipport)
LOG.error("Invalid ip and port '%s' in health_manager "
"controller_ip_port_list", ipport)
break
self.update(ip, port)
self.v4sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
@ -62,8 +60,7 @@ class UDPStatusSender(object):
# dest = (family, socktype, proto, canonname, sockaddr)
# e.g. 0 = sock family, 4 = sockaddr - what we actually need
if addrinfo is None:
LOG.error(_LE('No controller address found. '
'Unable to send heartbeat.'))
LOG.error('No controller address found. Unable to send heartbeat.')
return
try:
if addrinfo[0] == socket.AF_INET:

@ -22,7 +22,6 @@ from oslo_log import log as logging
from oslo_utils import secretutils
from octavia.common import exceptions
from octavia.i18n import _LW
LOG = logging.getLogger(__name__)
@ -58,9 +57,9 @@ def unwrap_envelope(envelope, key):
expected_hmc = envelope[-hash_len:]
calculated_hmc = get_hmac(payload, key)
if not secretutils.constant_time_compare(expected_hmc, calculated_hmc):
LOG.warning(_LW('calculated hmac: %(s1)s not equal to msg hmac: '
'%(s2)s dropping packet'), {'s1': to_hex(calculated_hmc),
's2': to_hex(expected_hmc)})
LOG.warning('calculated hmac: %(s1)s not equal to msg hmac: '
'%(s2)s dropping packet', {'s1': to_hex(calculated_hmc),
's2': to_hex(expected_hmc)})
fmt = 'calculated hmac: {0} not equal to msg hmac: {1} dropping packet'
raise exceptions.InvalidHMACException(fmt.format(
to_hex(calculated_hmc), to_hex(expected_hmc)))

@ -48,7 +48,7 @@ class HAProxyQuery(object):
try:
sock.connect(self.socket)
except socket.error:
raise Exception("HAProxy '{0}' query failed.".format(query))
raise Exception(_("HAProxy '{0}' query failed.").format(query))
try:
sock.send(six.b(query + '\n'))

@ -32,7 +32,6 @@ from octavia.common import constants as consts
from octavia.common.jinja.haproxy import jinja_cfg
from octavia.common.tls_utils import cert_parser
from octavia.common import utils
from octavia.i18n import _LE, _LW
LOG = logging.getLogger(__name__)
API_VERSION = consts.API_VERSION
@ -135,9 +134,9 @@ class HaproxyAmphoraLoadBalancerDriver(
load_balancer.vip.ip_address,
net_info)
except exc.Conflict:
LOG.warning(_LW('VIP with MAC {mac} already exists on '
'amphora, skipping post_vip_plug').format(
mac=port.mac_address))
LOG.warning(('VIP with MAC {mac} already exists on '
'amphora, skipping post_vip_plug').format(
mac=port.mac_address))
def post_network_plug(self, amphora, port):
fixed_ips = []
@ -155,9 +154,9 @@ class HaproxyAmphoraLoadBalancerDriver(
try:
self.client.plug_network(amphora, port_info)
except exc.Conflict:
LOG.warning(_LW('Network with MAC {mac} already exists on '
'amphora, skipping post_network_plug').format(
mac=port.mac_address))
LOG.warning(('Network with MAC {mac} already exists on '
'amphora, skipping post_network_plug').format(
mac=port.mac_address))
def get_vrrp_interface(self, amphora):
return self.client.get_interface(amphora, amphora.vrrp_ip)['interface']
@ -288,12 +287,12 @@ class AmphoraAPIClient(object):
return r
except (requests.ConnectionError, requests.Timeout) as e:
exception = e
LOG.warning(_LW("Could not connect to instance. Retrying."))
LOG.warning("Could not connect to instance. Retrying.")
time.sleep(CONF.haproxy_amphora.connection_retry_interval)
LOG.error(_LE("Connection retries (currently set to %(max_retries)s) "
"exhausted. The amphora is unavailable. Reason: "
"%(exception)s"),
LOG.error("Connection retries (currently set to %(max_retries)s) "
"exhausted. The amphora is unavailable. Reason: "
"%(exception)s",
{'max_retries': CONF.haproxy_amphora.connection_max_retries,
'exception': exception})
raise driver_except.TimeOutException()

@ -21,8 +21,6 @@ from oslo_log import log as logging
from octavia.amphorae.backends.health_daemon import status_message
from octavia.common import exceptions
from octavia.db import repositories
from octavia.i18n import _LI
UDP_MAX_SIZE = 64 * 1024
LOG = logging.getLogger(__name__)
@ -41,7 +39,7 @@ class UDPStatusGetter(object):
self.ip = cfg.CONF.health_manager.bind_ip
self.port = cfg.CONF.health_manager.bind_port
self.sockaddr = None
LOG.info(_LI('attempting to listen on %(ip)s port %(port)s'),
LOG.info('attempting to listen on %(ip)s port %(port)s',
{'ip': self.ip, 'port': self.port})
self.sock = None
self.update(self.key, self.ip, self.port)
@ -68,7 +66,7 @@ class UDPStatusGetter(object):
self.sock.bind(self.sockaddr)
if cfg.CONF.health_manager.sock_rlimit > 0:
rlimit = cfg.CONF.health_manager.sock_rlimit
LOG.info(_LI("setting sock rlimit to %s"), rlimit)
LOG.info("setting sock rlimit to %s", rlimit)
self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF,
rlimit)
break # just used the first addr getaddrinfo finds

@ -18,7 +18,6 @@ import six
from octavia.amphorae.drivers import driver_base as driver_base
from octavia.amphorae.drivers.keepalived.jinja import jinja_cfg
from octavia.common import constants
from octavia.i18n import _LI
LOG = logging.getLogger(__name__)
API_VERSION = constants.API_VERSION
@ -53,7 +52,7 @@ class KeepalivedAmphoraDriverMixin(driver_base.VRRPDriverMixin):
:param loadbalancer: loadbalancer object
"""
LOG.info(_LI("Stop loadbalancer %s amphora VRRP Service."),
LOG.info("Stop loadbalancer %s amphora VRRP Service.",
loadbalancer.id)
for amp in six.moves.filter(
@ -67,7 +66,7 @@ class KeepalivedAmphoraDriverMixin(driver_base.VRRPDriverMixin):
:param loadbalancer: loadbalancer object
"""
LOG.info(_LI("Start loadbalancer %s amphora VRRP Service."),
LOG.info("Start loadbalancer %s amphora VRRP Service.",
loadbalancer.id)
for amp in six.moves.filter(
@ -82,7 +81,7 @@ class KeepalivedAmphoraDriverMixin(driver_base.VRRPDriverMixin):
:param loadbalancer: loadbalancer object
"""
LOG.info(_LI("Reload loadbalancer %s amphora VRRP Service."),
LOG.info("Reload loadbalancer %s amphora VRRP Service.",
loadbalancer.id)
for amp in six.moves.filter(

@ -29,8 +29,6 @@ from octavia.common import constants
from octavia.common import data_models
from octavia.db import api as db_api
import octavia.db.repositories as repos
from octavia.i18n import _LI
LOG = logging.getLogger(__name__)
ASYNC_TIME = 1
@ -51,7 +49,7 @@ def simulate_controller(data_model, delete=False, update=False, create=False):
def member_controller(member, delete=False, update=False, create=False):
time.sleep(ASYNC_TIME)
LOG.info(_LI("Simulating controller operation for member..."))
LOG.info("Simulating controller operation for member...")
db_mem = None
if delete:
@ -83,12 +81,12 @@ def simulate_controller(data_model, delete=False, update=False, create=False):
member.pool.load_balancer.id,
operating_status=constants.ONLINE,
provisioning_status=constants.ACTIVE)
LOG.info(_LI("Simulated Controller Handler Thread Complete"))
LOG.info("Simulated Controller Handler Thread Complete")
def l7policy_controller(l7policy, delete=False, update=False,
create=False):
time.sleep(ASYNC_TIME)
LOG.info(_LI("Simulating controller operation for l7policy..."))
LOG.info("Simulating controller operation for l7policy...")
db_l7policy = None
if delete:
@ -110,11 +108,11 @@ def simulate_controller(data_model, delete=False, update=False, create=False):
db_l7policy.listener.load_balancer.id,
operating_status=constants.ONLINE,
provisioning_status=constants.ACTIVE)
LOG.info(_LI("Simulated Controller Handler Thread Complete"))
LOG.info("Simulated Controller Handler Thread Complete")
def l7rule_controller(l7rule, delete=False, update=False, create=False):
time.sleep(ASYNC_TIME)
LOG.info(_LI("Simulating controller operation for l7rule..."))
LOG.info("Simulating controller operation for l7rule...")
db_l7rule = None
if delete:
@ -135,12 +133,12 @@ def simulate_controller(data_model, delete=False, update=False, create=False):
listener.load_balancer.id,
operating_status=constants.ONLINE,
provisioning_status=constants.ACTIVE)
LOG.info(_LI("Simulated Controller Handler Thread Complete"))
LOG.info("Simulated Controller Handler Thread Complete")
def health_monitor_controller(health_monitor, delete=False, update=False,
create=False):
time.sleep(ASYNC_TIME)
LOG.info(_LI("Simulating controller operation for health monitor..."))
LOG.info("Simulating controller operation for health monitor...")
db_hm = None
if delete:
@ -182,11 +180,11 @@ def simulate_controller(data_model, delete=False, update=False, create=False):
health_monitor.pool.load_balancer.id,
operating_status=constants.ONLINE,
provisioning_status=constants.ACTIVE)
LOG.info(_LI("Simulated Controller Handler Thread Complete"))
LOG.info("Simulated Controller Handler Thread Complete")
def pool_controller(pool, delete=False, update=False, create=False):
time.sleep(ASYNC_TIME)
LOG.info(_LI("Simulating controller operation for pool..."))
LOG.info("Simulating controller operation for pool...")
db_pool = None
if delete:
@ -218,12 +216,12 @@ def simulate_controller(data_model, delete=False, update=False, create=False):
pool.load_balancer.id,
operating_status=constants.ONLINE,
provisioning_status=constants.ACTIVE)
LOG.info(_LI("Simulated Controller Handler Thread Complete"))
LOG.info("Simulated Controller Handler Thread Complete")
def listener_controller(listener, delete=False, update=False,
create=False):
time.sleep(ASYNC_TIME)
LOG.info(_LI("Simulating controller operation for listener..."))
LOG.info("Simulating controller operation for listener...")
if delete:
repo.listener.update(db_api.get_session(), listener.id,
@ -244,12 +242,12 @@ def simulate_controller(data_model, delete=False, update=False, create=False):
listener.load_balancer.id,
operating_status=constants.ONLINE,
provisioning_status=constants.ACTIVE)
LOG.info(_LI("Simulated Controller Handler Thread Complete"))
LOG.info("Simulated Controller Handler Thread Complete")
def loadbalancer_controller(loadbalancer, delete=False, update=False,
create=False):
time.sleep(ASYNC_TIME)
LOG.info(_LI("Simulating controller operation for loadbalancer..."))
LOG.info("Simulating controller operation for loadbalancer...")
if delete:
repo.load_balancer.update(
@ -266,7 +264,7 @@ def simulate_controller(data_model, delete=False, update=False, create=False):
repo.load_balancer.update(db_api.get_session(), id=loadbalancer.id,
operating_status=constants.ONLINE,
provisioning_status=constants.ACTIVE)
LOG.info(_LI("Simulated Controller Handler Thread Complete"))
LOG.info("Simulated Controller Handler Thread Complete")
controller = loadbalancer_controller
if isinstance(data_model, data_models.Member):
@ -294,22 +292,19 @@ class InvalidHandlerInputObject(Exception):
class LoadBalancerHandler(abstract_handler.BaseObjectHandler):
def create(self, load_balancer_id):
LOG.info(_LI("%(entity)s handling the creation of "
"load balancer %(id)s"),
LOG.info("%(entity)s handling the creation of load balancer %(id)s",
{"entity": self.__class__.__name__, "id": load_balancer_id})
simulate_controller(load_balancer_id, create=True)
def update(self, old_lb, load_balancer):
validate_input(data_models.LoadBalancer, load_balancer)
LOG.info(_LI("%(entity)s handling the update of "
"load balancer %(id)s"),
LOG.info("%(entity)s handling the update of load balancer %(id)s",
{"entity": self.__class__.__name__, "id": old_lb.id})
load_balancer.id = old_lb.id
simulate_controller(load_balancer, update=True)
def delete(self, load_balancer_id):
LOG.info(_LI("%(entity)s handling the deletion of "
"load balancer %(id)s"),
LOG.info("%(entity)s handling the deletion of load balancer %(id)s",
{"entity": self.__class__.__name__, "id": load_balancer_id})
simulate_controller(load_balancer_id, delete=True)
@ -317,19 +312,19 @@ class LoadBalancerHandler(abstract_handler.BaseObjectHandler):
class ListenerHandler(abstract_handler.BaseObjectHandler):
def create(self, listener_id):
LOG.info(_LI("%(entity)s handling the creation of listener %(id)s"),
LOG.info("%(entity)s handling the creation of listener %(id)s",
{"entity": self.__class__.__name__, "id": listener_id})
simulate_controller(listener_id, create=True)
def update(self, old_listener, listener):
validate_input(data_models.Listener, listener)
LOG.info(_LI("%(entity)s handling the update of listener %(id)s"),
LOG.info("%(entity)s handling the update of listener %(id)s",
{"entity": self.__class__.__name__, "id": old_listener.id})
listener.id = old_listener.id
simulate_controller(listener, update=True)
def delete(self, listener_id):
LOG.info(_LI("%(entity)s handling the deletion of listener %(id)s"),
LOG.info("%(entity)s handling the deletion of listener %(id)s",
{"entity": self.__class__.__name__, "id": listener_id})
simulate_controller(listener_id, delete=True)
@ -337,19 +332,19 @@ class ListenerHandler(abstract_handler.BaseObjectHandler):
class PoolHandler(abstract_handler.BaseObjectHandler):
def create(self, pool_id):
LOG.info(_LI("%(entity)s handling the creation of pool %(id)s"),
LOG.info("%(entity)s handling the creation of pool %(id)s",
{"entity": self.__class__.__name__, "id": pool_id})
simulate_controller(pool_id, create=True)
def update(self, old_pool, pool):
validate_input(data_models.Pool, pool)
LOG.info(_LI("%(entity)s handling the update of pool %(id)s"),
LOG.info("%(entity)s handling the update of pool %(id)s",
{"entity": self.__class__.__name__, "id": old_pool.id})
pool.id = old_pool.id
simulate_controller(pool, update=True)
def delete(self, pool_id):
LOG.info(_LI("%(entity)s handling the deletion of pool %(id)s"),
LOG.info("%(entity)s handling the deletion of pool %(id)s",
{"entity": self.__class__.__name__, "id": pool_id})
simulate_controller(pool_id, delete=True)
@ -357,23 +352,23 @@ class PoolHandler(abstract_handler.BaseObjectHandler):
class HealthMonitorHandler(abstract_handler.BaseObjectHandler):
def create(self, pool_id):
LOG.info(_LI("%(entity)s handling the creation of health monitor "
"on pool %(id)s"),
LOG.info("%(entity)s handling the creation of health monitor "
"on pool %(id)s",
{"entity": self.__class__.__name__, "id": pool_id})
simulate_controller(pool_id, create=True)
def update(self, old_health_monitor, health_monitor):
validate_input(data_models.HealthMonitor, health_monitor)
LOG.info(_LI("%(entity)s handling the update of health monitor "
"on pool %(id)s"),
LOG.info("%(entity)s handling the update of health monitor "
"on pool %(id)s",
{"entity": self.__class__.__name__,
"id": old_health_monitor.pool_id})
health_monitor.pool_id = old_health_monitor.pool_id
simulate_controller(health_monitor, update=True)
def delete(self, pool_id):
LOG.info(_LI("%(entity)s handling the deletion of health monitor "
"on pool %(id)s"),
LOG.info("%(entity)s handling the deletion of health monitor "
"on pool %(id)s",
{"entity": self.__class__.__name__, "id": pool_id})
simulate_controller(pool_id, delete=True)
@ -381,19 +376,19 @@ class HealthMonitorHandler(abstract_handler.BaseObjectHandler):
class MemberHandler(abstract_handler.BaseObjectHandler):
def create(self, member_id):
LOG.info(_LI("%(entity)s handling the creation of member %(id)s"),
LOG.info("%(entity)s handling the creation of member %(id)s",
{"entity": self.__class__.__name__, "id": member_id})
simulate_controller(member_id, create=True)
def update(self, old_member, member):
validate_input(data_models.Member, member)
LOG.info(_LI("%(entity)s handling the update of member %(id)s"),
LOG.info("%(entity)s handling the update of member %(id)s",
{"entity": self.__class__.__name__, "id": old_member.id})
member.id = old_member.id
simulate_controller(member, update=True)
def delete(self, member_id):
LOG.info(_LI("%(entity)s handling the deletion of member %(id)s"),
LOG.info("%(entity)s handling the deletion of member %(id)s",
{"entity": self.__class__.__name__, "id": member_id})
simulate_controller(member_id, delete=True)
@ -401,19 +396,19 @@ class MemberHandler(abstract_handler.BaseObjectHandler):
class L7PolicyHandler(abstract_handler.BaseObjectHandler):
def create(self, l7policy_id):
LOG.info(_LI("%(entity)s handling the creation of l7policy %(id)s"),
LOG.info("%(entity)s handling the creation of l7policy %(id)s",
{"entity": self.__class__.__name__, "id": l7policy_id})
simulate_controller(l7policy_id, create=True)
def update(self, old_l7policy, l7policy):
validate_input(data_models.L7Policy, l7policy)
LOG.info(_LI("%(entity)s handling the update of l7policy %(id)s"),
LOG.info("%(entity)s handling the update of l7policy %(id)s",
{"entity": self.__class__.__name__, "id": old_l7policy.id})
l7policy.id = old_l7policy.id
simulate_controller(l7policy, update=True)
def delete(self, l7policy_id):
LOG.info(_LI("%(entity)s handling the deletion of l7policy %(id)s"),
LOG.info("%(entity)s handling the deletion of l7policy %(id)s",
{"entity": self.__class__.__name__, "id": l7policy_id})
simulate_controller(l7policy_id, delete=True)
@ -421,19 +416,19 @@ class L7PolicyHandler(abstract_handler.BaseObjectHandler):
class L7RuleHandler(abstract_handler.BaseObjectHandler):
def create(self, l7rule):
LOG.info(_LI("%(entity)s handling the creation of l7rule %(id)s"),
LOG.info("%(entity)s handling the creation of l7rule %(id)s",
{"entity": self.__class__.__name__, "id": l7rule.id})
simulate_controller(l7rule, create=True)
def update(self, old_l7rule, l7rule):
validate_input(data_models.L7Rule, l7rule)
LOG.info(_LI("%(entity)s handling the update of l7rule %(id)s"),
LOG.info("%(entity)s handling the update of l7rule %(id)s",
{"entity": self.__class__.__name__, "id": old_l7rule.id})
l7rule.id = old_l7rule.id
simulate_controller(l7rule, update=True)
def delete(self, l7rule):
LOG.info(_LI("%(entity)s handling the deletion of l7rule %(id)s"),
LOG.info("%(entity)s handling the deletion of l7rule %(id)s",
{"entity": self.__class__.__name__, "id": l7rule.id})
simulate_controller(l7rule, delete=True)

@ -21,7 +21,6 @@ from stevedore import driver as stevedore_driver
from octavia.common import data_models
from octavia.common import exceptions
from octavia.db import repositories
from octavia.i18n import _LE
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
@ -61,7 +60,7 @@ class BaseController(rest.RestController):
"""Gets an object from the database and returns it."""
db_obj = repo.get(session, id=id)
if not db_obj:
LOG.exception(_LE("{name} {id} not found").format(
LOG.exception("{name} {id} not found".format(
name=data_model._name(), id=id))
raise exceptions.NotFound(
resource=data_model._name(), id=id)

@ -27,8 +27,6 @@ from octavia.common import data_models
from octavia.common import exceptions
from octavia.db import api as db_api
from octavia.db import prepare as db_prepare
from octavia.i18n import _LI
LOG = logging.getLogger(__name__)
@ -47,7 +45,7 @@ class HealthMonitorController(base.BaseController):
db_hm = self.repositories.health_monitor.get(
session, pool_id=self.pool_id)
if not db_hm:
LOG.info(_LI("Health Monitor for Pool %s was not found"),
LOG.info("Health Monitor for Pool %s was not found",
self.pool_id)
raise exceptions.NotFound(
resource=data_models.HealthMonitor._name(),
@ -83,8 +81,8 @@ class HealthMonitorController(base.BaseController):
session, self.load_balancer_id,
constants.PENDING_UPDATE, constants.PENDING_UPDATE,
listener_ids=self._get_affected_listener_ids(session, hm)):
LOG.info(_LI("Health Monitor cannot be created or modified "
"because the Load Balancer is in an immutable state"))
LOG.info("Health Monitor cannot be created or modified "
"because the Load Balancer is in an immutable state")
lb_repo = self.repositories.load_balancer
db_lb = lb_repo.get(session, id=self.load_balancer_id)
raise exceptions.ImmutableObject(resource=db_lb._name(),
@ -134,8 +132,8 @@ class HealthMonitorController(base.BaseController):
lock_session.rollback()
try:
LOG.info(_LI("Sending Creation of Health Monitor for Pool %s to "
"handler"), self.pool_id)
LOG.info("Sending Creation of Health Monitor for Pool %s to "
"handler", self.pool_id)
self.handler.create(db_hm)
except Exception:
for listener_id in self._get_affected_listener_ids(
@ -161,8 +159,8 @@ class HealthMonitorController(base.BaseController):
self._test_lb_and_listener_statuses(context.session, hm=db_hm)
try:
LOG.info(_LI("Sending Update of Health Monitor for Pool %s to "
"handler"), self.pool_id)
LOG.info("Sending Update of Health Monitor for Pool %s to handler",
self.pool_id)
self.handler.update(db_hm, health_monitor)
except Exception:
with excutils.save_and_reraise_exception(reraise=False):
@ -182,8 +180,8 @@ class HealthMonitorController(base.BaseController):
self._test_lb_and_listener_statuses(context.session, hm=db_hm)
try:
LOG.info(_LI("Sending Deletion of Health Monitor for Pool %s to "
"handler"), self.pool_id)
LOG.info("Sending Deletion of Health Monitor for Pool %s to "
"handler", self.pool_id)
self.handler.delete(db_hm)
except Exception:
with excutils.save_and_reraise_exception(reraise=False):

@ -28,8 +28,6 @@ from octavia.common import data_models
from octavia.common import exceptions
from octavia.common import validate
from octavia.db import prepare as db_prepare
from octavia.i18n import _LI
LOG = logging.getLogger(__name__)
@ -65,8 +63,8 @@ class L7PolicyController(base.BaseController):
session, self.load_balancer_id,
constants.PENDING_UPDATE, constants.PENDING_UPDATE,
listener_ids=[self.listener_id]):
LOG.info(_LI("L7Policy cannot be created or modified because the "
"Load Balancer is in an immutable state"))
LOG.info("L7Policy cannot be created or modified because the "
"Load Balancer is in an immutable state")
lb_repo = self.repositories.load_balancer
db_lb = lb_repo.get(session, id=self.load_balancer_id)
raise exceptions.ImmutableObject(resource=db_lb._name(),
@ -104,7 +102,7 @@ class L7PolicyController(base.BaseController):
if ['id'] == de.columns:
raise exceptions.IDAlreadyExists()
try:
LOG.info(_LI("Sending Creation of L7Policy %s to handler"),
LOG.info("Sending Creation of L7Policy %s to handler",
db_l7policy.id)
self.handler.create(db_l7policy)
except Exception:
@ -132,7 +130,7 @@ class L7PolicyController(base.BaseController):
self._test_lb_and_listener_statuses(context.session)
try:
LOG.info(_LI("Sending Update of L7Policy %s to handler"), id)
LOG.info("Sending Update of L7Policy %s to handler", id)
self.handler.update(
db_l7policy, l7policy_types.L7PolicyPUT(**l7policy_dict))
except Exception:
@ -152,7 +150,7 @@ class L7PolicyController(base.BaseController):
self._test_lb_and_listener_statuses(context.session)
try:
LOG.info(_LI("Sending Deletion of L7Policy %s to handler"),
LOG.info("Sending Deletion of L7Policy %s to handler",
db_l7policy.id)
self.handler.delete(db_l7policy)
except Exception:
@ -177,7 +175,7 @@ class L7PolicyController(base.BaseController):
db_l7policy = self.repositories.l7policy.get(
context.session, id=l7policy_id)
if not db_l7policy:
LOG.info(_LI("L7Policy %s not found."), l7policy_id)
LOG.info("L7Policy %s not found.", l7policy_id)
raise exceptions.NotFound(
resource=data_models.L7Policy._name(), id=l7policy_id)
return l7rule.L7RuleController(

@ -27,8 +27,6 @@ from octavia.common import data_models
from octavia.common import exceptions
from octavia.common import validate
from octavia.db import prepare as db_prepare
from octavia.i18n import _LI
LOG = logging.getLogger(__name__)
@ -65,8 +63,8 @@ class L7RuleController(base.BaseController):
session, self.load_balancer_id,
constants.PENDING_UPDATE, constants.PENDING_UPDATE,
listener_ids=[self.listener_id]):
LOG.info(_LI("L7Rule cannot be created or modified because the "
"Load Balancer is in an immutable state"))
LOG.info("L7Rule cannot be created or modified because the "
"Load Balancer is in an immutable state")
lb_repo = self.repositories.load_balancer
db_lb = lb_repo.get(session, id=self.load_balancer_id)
raise exceptions.ImmutableObject(resource=db_lb._name(),
@ -109,7 +107,7 @@ class L7RuleController(base.BaseController):
if ['id'] == de.columns:
raise exceptions.IDAlreadyExists()
try:
LOG.info(_LI("Sending Creation of L7Rule %s to handler"),
LOG.info("Sending Creation of L7Rule %s to handler",
db_l7rule.id)
self.handler.create(db_l7rule)
except Exception:
@ -138,7 +136,7 @@ class L7RuleController(base.BaseController):
self._test_lb_and_listener_statuses(context.session)
try:
LOG.info(_LI("Sending Update of L7Rule %s to handler"), id)
LOG.info("Sending Update of L7Rule %s to handler", id)
self.handler.update(db_l7rule, l7rule)
except Exception:
with excutils.save_and_reraise_exception(reraise=False):
@ -157,7 +155,7 @@ class L7RuleController(base.BaseController):
self._test_lb_and_listener_statuses(context.session)
try:
LOG.info(_LI("Sending Deletion of L7Rule %s to handler"),
LOG.info("Sending Deletion of L7Rule %s to handler",
db_l7rule.id)
self.handler.delete(db_l7rule)
except Exception:

@ -31,8 +31,6 @@ from octavia.common import data_models
from octavia.common import exceptions
from octavia.db import api as db_api
from octavia.db import prepare as db_prepare
from octavia.i18n import _LI
LOG = logging.getLogger(__name__)
@ -55,7 +53,7 @@ class ListenersController(base.BaseController):
db_listener = self.repositories.listener.get(
session, load_balancer_id=self.load_balancer_id, id=id)
if not db_listener:
LOG.info(_LI("Listener %s not found."), id)
LOG.info("Listener %s not found.", id)
raise exceptions.NotFound(
resource=data_models.Listener._name(), id=id)
return db_listener
@ -85,7 +83,7 @@ class ListenersController(base.BaseController):
if not self.repositories.test_and_set_lb_and_listeners_prov_status(
session, self.load_balancer_id, constants.PENDING_UPDATE,
listener_status, listener_ids=[id]):
LOG.info(_LI("Load Balancer %s is immutable."),
LOG.info("Load Balancer %s is immutable.",
self.load_balancer_id)
db_lb = lb_repo.get(session, id=self.load_balancer_id)
raise exceptions.ImmutableObject(resource=db_lb._name(),
@ -94,7 +92,7 @@ class ListenersController(base.BaseController):
if not lb_repo.test_and_set_provisioning_status(
session, self.load_balancer_id, constants.PENDING_UPDATE):
db_lb = lb_repo.get(session, id=self.load_balancer_id)
LOG.info(_LI("Load Balancer %s is immutable."), db_lb.id)
LOG.info("Load Balancer %s is immutable.", db_lb.id)
raise exceptions.ImmutableObject(resource=db_lb._name(),
id=self.load_balancer_id)
@ -144,7 +142,7 @@ class ListenersController(base.BaseController):
def _send_listener_to_handler(self, session, db_listener):
try:
LOG.info(_LI("Sending Creation of Listener %s to handler"),
LOG.info("Sending Creation of Listener %s to handler",
db_listener.id)
self.handler.create(db_listener)
except Exception:
@ -210,7 +208,7 @@ class ListenersController(base.BaseController):
self._test_lb_and_listener_statuses(context.session, id=id)
try:
LOG.info(_LI("Sending Update of Listener %s to handler"), id)
LOG.info("Sending Update of Listener %s to handler", id)
self.handler.update(db_listener, listener)
except Exception:
with excutils.save_and_reraise_exception(reraise=False):
@ -229,7 +227,7 @@ class ListenersController(base.BaseController):
context.session, id=id, listener_status=constants.PENDING_DELETE)
try:
LOG.info(_LI("Sending Deletion of Listener %s to handler"),
LOG.info("Sending Deletion of Listener %s to handler",
db_listener.id)
self.handler.delete(db_listener)
except Exception:
@ -258,7 +256,7 @@ class ListenersController(base.BaseController):
db_listener = self.repositories.listener.get(
context.session, id=listener_id)
if not db_listener:
LOG.info(_LI("Listener %s not found."), listener_id)
LOG.info("Listener %s not found.", listener_id)
raise exceptions.NotFound(
resource=data_models.Listener._name(), id=listener_id)
if controller == 'pools':

@ -33,7 +33,7 @@ from octavia.common import utils
import octavia.common.validate as validate
from octavia.db import api as db_api
from octavia.db import prepare as db_prepare
from octavia.i18n import _, _LI
from octavia.i18n import _
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
@ -72,7 +72,7 @@ class LoadBalancersController(base.BaseController):
lb_repo = self.repositories.load_balancer
if not lb_repo.test_and_set_provisioning_status(
session, id, lb_status):
LOG.info(_LI("Load Balancer %s is immutable."), id)
LOG.info("Load Balancer %s is immutable.", id)
db_lb = lb_repo.get(session, id=id)
raise exceptions.ImmutableObject(resource=db_lb._name(),
id=id)
@ -90,8 +90,8 @@ class LoadBalancersController(base.BaseController):
def _load_balancer_graph_to_handler(self, context, db_lb):
try:
LOG.info(_LI("Sending full load balancer configuration %s to "
"the handler"), db_lb.id)
LOG.info("Sending full load balancer configuration %s to "
"the handler", db_lb.id)
self.handler.create(db_lb)
except Exception:
with excutils.save_and_reraise_exception(reraise=False):
@ -197,7 +197,7 @@ class LoadBalancersController(base.BaseController):
# Handler will be responsible for sending to controller
try:
LOG.info(_LI("Sending created Load Balancer %s to the handler"),
LOG.info("Sending created Load Balancer %s to the handler",
db_lb.id)
self.handler.create(db_lb)
except Exception:
@ -217,7 +217,7 @@ class LoadBalancersController(base.BaseController):
self._test_lb_status(context.session, id)
try:
LOG.info(_LI("Sending updated Load Balancer %s to the handler"),
LOG.info("Sending updated Load Balancer %s to the handler",
id)
self.handler.update(db_lb, load_balancer)
except Exception:
@ -239,7 +239,7 @@ class LoadBalancersController(base.BaseController):
raise exceptions.ValidationException(detail=msg)
try:
LOG.info(_LI("Sending deleted Load Balancer %s to the handler"),
LOG.info("Sending deleted Load Balancer %s to the handler",
db_lb.id)
self.handler.delete(db_lb, cascade)
except Exception:
@ -270,7 +270,7 @@ class LoadBalancersController(base.BaseController):
db_lb = self.repositories.load_balancer.get(context.session,
id=lb_id)
if not db_lb:
LOG.info(_LI("Load Balancer %s was not found."), lb_id)
LOG.info("Load Balancer %s was not found.", lb_id)
raise exceptions.NotFound(
resource=data_models.LoadBalancer._name(), id=lb_id)
if controller == 'listeners':
@ -287,11 +287,11 @@ class LoadBalancersController(base.BaseController):
class LBCascadeDeleteController(LoadBalancersController):
def __init__(self, lb_id):
super(LBCascadeDeleteController, self).__init__()
self.lb_id = lb_id
@wsme_pecan.wsexpose(None, status_code=202)
def delete(self):
"""Deletes a load balancer."""
return self._delete(self.lb_id, cascade=True)
def __init__(self, lb_id):
super(LBCascadeDeleteController, self).__init__()
self.lb_id = lb_id
@wsme_pecan.wsexpose(None, status_code=202)
def delete(self):
"""Deletes a load balancer."""
return self._delete(self.lb_id, cascade=True)

@ -29,8 +29,6 @@ from octavia.common import exceptions
import octavia.common.validate as validate
from octavia.db import api as db_api
from octavia.db import prepare as db_prepare
from octavia.i18n import _LI
LOG = logging.getLogger(__name__)
@ -82,8 +80,8 @@ class MembersController(base.BaseController):
session, self.load_balancer_id,
constants.PENDING_UPDATE, constants.PENDING_UPDATE,
listener_ids=self._get_affected_listener_ids(session, member)):
LOG.info(_LI("Member cannot be created or modified because the "
"Load Balancer is in an immutable state"))
LOG.info("Member cannot be created or modified because the "
"Load Balancer is in an immutable state")
lb_repo = self.repositories.load_balancer
db_lb = lb_repo.get(session, id=self.load_balancer_id)
raise exceptions.ImmutableObject(resource=db_lb._name(),
@ -133,7 +131,7 @@ class MembersController(base.BaseController):
lock_session.rollback()
try:
LOG.info(_LI("Sending Creation of Member %s to handler"),
LOG.info("Sending Creation of Member %s to handler",
db_member.id)
self.handler.create(db_member)
except Exception:
@ -156,7 +154,7 @@ class MembersController(base.BaseController):
self._test_lb_and_listener_statuses(context.session, member=db_member)
try:
LOG.info(_LI("Sending Update of Member %s to handler"), id)
LOG.info("Sending Update of Member %s to handler", id)
self.handler.update(db_member, member