Merge "Update i18n translation for Midonet plugin"
This commit is contained in:
commit
fab2ea0e2f
@ -83,7 +83,7 @@ def _directory_to_check_translation(filename):
|
||||
#"neutron/plugins/ibm",
|
||||
"neutron/plugins/linuxbridge",
|
||||
#"neutron/plugins/metaplugin",
|
||||
#"neutron/plugins/midonet",
|
||||
"neutron/plugins/midonet",
|
||||
"neutron/plugins/ml2",
|
||||
"neutron/plugins/mlnx",
|
||||
#"neutron/plugins/nec",
|
||||
|
@ -18,6 +18,7 @@ from midonetclient import exc
|
||||
from webob import exc as w_exc
|
||||
|
||||
from neutron.common import exceptions as n_exc
|
||||
from neutron.i18n import _LW
|
||||
from neutron.openstack.common import log as logging
|
||||
from neutron.plugins.midonet.common import net_util
|
||||
|
||||
@ -74,8 +75,8 @@ class MidoClient:
|
||||
:param \**kwargs: configuration of the new bridge
|
||||
:returns: newly created bridge
|
||||
"""
|
||||
LOG.debug(_("MidoClient.create_bridge called: "
|
||||
"kwargs=%(kwargs)s"), {'kwargs': kwargs})
|
||||
LOG.debug("MidoClient.create_bridge called: "
|
||||
"kwargs=%(kwargs)s", {'kwargs': kwargs})
|
||||
return self._create_dto(self.mido_api.add_bridge(), kwargs)
|
||||
|
||||
@handle_api_error
|
||||
@ -84,7 +85,7 @@ class MidoClient:
|
||||
|
||||
:param id: id of the bridge
|
||||
"""
|
||||
LOG.debug(_("MidoClient.delete_bridge called: id=%(id)s"), {'id': id})
|
||||
LOG.debug("MidoClient.delete_bridge called: id=%(id)s", {'id': id})
|
||||
return self.mido_api.delete_bridge(id)
|
||||
|
||||
@handle_api_error
|
||||
@ -94,7 +95,7 @@ class MidoClient:
|
||||
:param id: id of the bridge
|
||||
:returns: requested bridge. None if bridge does not exist.
|
||||
"""
|
||||
LOG.debug(_("MidoClient.get_bridge called: id=%s"), id)
|
||||
LOG.debug("MidoClient.get_bridge called: id=%s", id)
|
||||
try:
|
||||
return self.mido_api.get_bridge(id)
|
||||
except w_exc.HTTPNotFound:
|
||||
@ -108,8 +109,8 @@ class MidoClient:
|
||||
:param \**kwargs: the fields to update and their values
|
||||
:returns: bridge object
|
||||
"""
|
||||
LOG.debug(_("MidoClient.update_bridge called: "
|
||||
"id=%(id)s, kwargs=%(kwargs)s"),
|
||||
LOG.debug("MidoClient.update_bridge called: "
|
||||
"id=%(id)s, kwargs=%(kwargs)s",
|
||||
{'id': id, 'kwargs': kwargs})
|
||||
try:
|
||||
return self._update_dto(self.mido_api.get_bridge(id), kwargs)
|
||||
@ -128,9 +129,9 @@ class MidoClient:
|
||||
:param dns_servers: list of dns servers
|
||||
:returns: newly created dhcp
|
||||
"""
|
||||
LOG.debug(_("MidoClient.create_dhcp called: bridge=%(bridge)s, "
|
||||
"cidr=%(cidr)s, gateway_ip=%(gateway_ip)s, "
|
||||
"host_rts=%(host_rts)s, dns_servers=%(dns_servers)s"),
|
||||
LOG.debug("MidoClient.create_dhcp called: bridge=%(bridge)s, "
|
||||
"cidr=%(cidr)s, gateway_ip=%(gateway_ip)s, "
|
||||
"host_rts=%(host_rts)s, dns_servers=%(dns_servers)s",
|
||||
{'bridge': bridge, 'cidr': cidr, 'gateway_ip': gateway_ip,
|
||||
'host_rts': host_rts, 'dns_servers': dns_servers})
|
||||
self.mido_api.add_bridge_dhcp(bridge, gateway_ip, cidr,
|
||||
@ -146,8 +147,8 @@ class MidoClient:
|
||||
:param ip: IP address
|
||||
:param mac: MAC address
|
||||
"""
|
||||
LOG.debug(_("MidoClient.add_dhcp_host called: bridge=%(bridge)s, "
|
||||
"cidr=%(cidr)s, ip=%(ip)s, mac=%(mac)s"),
|
||||
LOG.debug("MidoClient.add_dhcp_host called: bridge=%(bridge)s, "
|
||||
"cidr=%(cidr)s, ip=%(ip)s, mac=%(mac)s",
|
||||
{'bridge': bridge, 'cidr': cidr, 'ip': ip, 'mac': mac})
|
||||
subnet = bridge.get_dhcp_subnet(net_util.subnet_str(cidr))
|
||||
if subnet is None:
|
||||
@ -165,17 +166,17 @@ class MidoClient:
|
||||
:param ip: IP address
|
||||
:param mac: MAC address
|
||||
"""
|
||||
LOG.debug(_("MidoClient.remove_dhcp_host called: bridge=%(bridge)s, "
|
||||
"cidr=%(cidr)s, ip=%(ip)s, mac=%(mac)s"),
|
||||
LOG.debug("MidoClient.remove_dhcp_host called: bridge=%(bridge)s, "
|
||||
"cidr=%(cidr)s, ip=%(ip)s, mac=%(mac)s",
|
||||
{'bridge': bridge, 'cidr': cidr, 'ip': ip, 'mac': mac})
|
||||
subnet = bridge.get_dhcp_subnet(net_util.subnet_str(cidr))
|
||||
if subnet is None:
|
||||
LOG.warn(_("Tried to delete mapping from non-existent subnet"))
|
||||
LOG.warn(_LW("Tried to delete mapping from non-existent subnet"))
|
||||
return
|
||||
|
||||
for dh in subnet.get_dhcp_hosts():
|
||||
if dh.get_mac_addr() == mac and dh.get_ip_addr() == ip:
|
||||
LOG.debug(_("MidoClient.remove_dhcp_host: Deleting %(dh)r"),
|
||||
LOG.debug("MidoClient.remove_dhcp_host: Deleting %(dh)r",
|
||||
{"dh": dh})
|
||||
dh.delete()
|
||||
|
||||
@ -188,11 +189,11 @@ class MidoClient:
|
||||
:param ip: IP address
|
||||
:param mac: MAC address
|
||||
"""
|
||||
LOG.debug(_("MidoClient.delete_dhcp_host called: "
|
||||
"bridge_id=%(bridge_id)s, cidr=%(cidr)s, ip=%(ip)s, "
|
||||
"mac=%(mac)s"), {'bridge_id': bridge_id,
|
||||
'cidr': cidr,
|
||||
'ip': ip, 'mac': mac})
|
||||
LOG.debug("MidoClient.delete_dhcp_host called: "
|
||||
"bridge_id=%(bridge_id)s, cidr=%(cidr)s, ip=%(ip)s, "
|
||||
"mac=%(mac)s", {'bridge_id': bridge_id,
|
||||
'cidr': cidr,
|
||||
'ip': ip, 'mac': mac})
|
||||
bridge = self.get_bridge(bridge_id)
|
||||
self.remove_dhcp_host(bridge, net_util.subnet_str(cidr), ip, mac)
|
||||
|
||||
@ -203,8 +204,8 @@ class MidoClient:
|
||||
:param bridge: bridge to remove DHCP from
|
||||
:param cidr: subnet represented as x.x.x.x/y
|
||||
"""
|
||||
LOG.debug(_("MidoClient.delete_dhcp called: bridge=%(bridge)s, "
|
||||
"cidr=%(cidr)s"),
|
||||
LOG.debug("MidoClient.delete_dhcp called: bridge=%(bridge)s, "
|
||||
"cidr=%(cidr)s",
|
||||
{'bridge': bridge, 'cidr': cidr})
|
||||
dhcp_subnets = bridge.get_dhcp_subnets()
|
||||
net_addr, net_len = net_util.net_addr(cidr)
|
||||
@ -223,8 +224,8 @@ class MidoClient:
|
||||
|
||||
:param id: id of the port
|
||||
"""
|
||||
LOG.debug(_("MidoClient.delete_port called: id=%(id)s, "
|
||||
"delete_chains=%(delete_chains)s"),
|
||||
LOG.debug("MidoClient.delete_port called: id=%(id)s, "
|
||||
"delete_chains=%(delete_chains)s",
|
||||
{'id': id, 'delete_chains': delete_chains})
|
||||
if delete_chains:
|
||||
self.delete_port_chains(id)
|
||||
@ -238,7 +239,7 @@ class MidoClient:
|
||||
:param id: id of the port
|
||||
:returns: requested port. None if it does not exist
|
||||
"""
|
||||
LOG.debug(_("MidoClient.get_port called: id=%(id)s"), {'id': id})
|
||||
LOG.debug("MidoClient.get_port called: id=%(id)s", {'id': id})
|
||||
try:
|
||||
return self.mido_api.get_port(id)
|
||||
except w_exc.HTTPNotFound:
|
||||
@ -252,8 +253,8 @@ class MidoClient:
|
||||
:param \**kwargs: configuration of the new port
|
||||
:returns: newly created port
|
||||
"""
|
||||
LOG.debug(_("MidoClient.add_bridge_port called: "
|
||||
"bridge=%(bridge)s, kwargs=%(kwargs)s"),
|
||||
LOG.debug("MidoClient.add_bridge_port called: "
|
||||
"bridge=%(bridge)s, kwargs=%(kwargs)s",
|
||||
{'bridge': bridge, 'kwargs': kwargs})
|
||||
return self._create_dto(self.mido_api.add_bridge_port(bridge), kwargs)
|
||||
|
||||
@ -264,8 +265,8 @@ class MidoClient:
|
||||
:param id: id of the port
|
||||
:param \**kwargs: the fields to update and their values
|
||||
"""
|
||||
LOG.debug(_("MidoClient.update_port called: "
|
||||
"id=%(id)s, kwargs=%(kwargs)s"),
|
||||
LOG.debug("MidoClient.update_port called: "
|
||||
"id=%(id)s, kwargs=%(kwargs)s",
|
||||
{'id': id, 'kwargs': kwargs})
|
||||
try:
|
||||
return self._update_dto(self.mido_api.get_port(id), kwargs)
|
||||
@ -289,8 +290,8 @@ class MidoClient:
|
||||
:param \**kwargs: configuration of the new router
|
||||
:returns: newly created router
|
||||
"""
|
||||
LOG.debug(_("MidoClient.create_router called: "
|
||||
"kwargs=%(kwargs)s"), {'kwargs': kwargs})
|
||||
LOG.debug("MidoClient.create_router called: "
|
||||
"kwargs=%(kwargs)s", {'kwargs': kwargs})
|
||||
return self._create_dto(self.mido_api.add_router(), kwargs)
|
||||
|
||||
@handle_api_error
|
||||
@ -299,7 +300,7 @@ class MidoClient:
|
||||
|
||||
:param id: id of the router
|
||||
"""
|
||||
LOG.debug(_("MidoClient.delete_router called: id=%(id)s"), {'id': id})
|
||||
LOG.debug("MidoClient.delete_router called: id=%(id)s", {'id': id})
|
||||
return self.mido_api.delete_router(id)
|
||||
|
||||
@handle_api_error
|
||||
@ -309,7 +310,7 @@ class MidoClient:
|
||||
:param id: id of the router
|
||||
:returns: requested router object. None if it does not exist.
|
||||
"""
|
||||
LOG.debug(_("MidoClient.get_router called: id=%(id)s"), {'id': id})
|
||||
LOG.debug("MidoClient.get_router called: id=%(id)s", {'id': id})
|
||||
try:
|
||||
return self.mido_api.get_router(id)
|
||||
except w_exc.HTTPNotFound:
|
||||
@ -323,8 +324,8 @@ class MidoClient:
|
||||
:param \**kwargs: the fields to update and their values
|
||||
:returns: router object
|
||||
"""
|
||||
LOG.debug(_("MidoClient.update_router called: "
|
||||
"id=%(id)s, kwargs=%(kwargs)s"),
|
||||
LOG.debug("MidoClient.update_router called: "
|
||||
"id=%(id)s, kwargs=%(kwargs)s",
|
||||
{'id': id, 'kwargs': kwargs})
|
||||
try:
|
||||
return self._update_dto(self.mido_api.get_router(id), kwargs)
|
||||
@ -344,9 +345,9 @@ class MidoClient:
|
||||
:param gw_ip: IP address of the next hop
|
||||
:param dst_ip: IP address of the destination, in x.x.x.x/y format
|
||||
"""
|
||||
LOG.debug(_("MidoClient.add_dhcp_route_option called: "
|
||||
"bridge=%(bridge)s, cidr=%(cidr)s, gw_ip=%(gw_ip)s"
|
||||
"dst_ip=%(dst_ip)s"),
|
||||
LOG.debug("MidoClient.add_dhcp_route_option called: "
|
||||
"bridge=%(bridge)s, cidr=%(cidr)s, gw_ip=%(gw_ip)s"
|
||||
"dst_ip=%(dst_ip)s",
|
||||
{"bridge": bridge, "cidr": cidr, "gw_ip": gw_ip,
|
||||
"dst_ip": dst_ip})
|
||||
subnet = bridge.get_dhcp_subnet(net_util.subnet_str(cidr))
|
||||
@ -384,20 +385,20 @@ class MidoClient:
|
||||
|
||||
:param port: port object
|
||||
"""
|
||||
LOG.debug(_("MidoClient.unlink called: port=%(port)s"),
|
||||
LOG.debug("MidoClient.unlink called: port=%(port)s",
|
||||
{'port': port})
|
||||
if port.get_peer_id():
|
||||
self.mido_api.unlink(port)
|
||||
else:
|
||||
LOG.warn(_("Attempted to unlink a port that was not linked. %s"),
|
||||
LOG.warn(_LW("Attempted to unlink a port that was not linked. %s"),
|
||||
port.get_id())
|
||||
|
||||
@handle_api_error
|
||||
def remove_rules_by_property(self, tenant_id, chain_name, key, value):
|
||||
"""Remove all the rules that match the provided key and value."""
|
||||
LOG.debug(_("MidoClient.remove_rules_by_property called: "
|
||||
"tenant_id=%(tenant_id)s, chain_name=%(chain_name)s"
|
||||
"key=%(key)s, value=%(value)s"),
|
||||
LOG.debug("MidoClient.remove_rules_by_property called: "
|
||||
"tenant_id=%(tenant_id)s, chain_name=%(chain_name)s"
|
||||
"key=%(key)s, value=%(value)s",
|
||||
{'tenant_id': tenant_id, 'chain_name': chain_name,
|
||||
'key': key, 'value': value})
|
||||
chain = self.get_chain_by_name(tenant_id, chain_name)
|
||||
@ -422,9 +423,9 @@ class MidoClient:
|
||||
:param inbound_chain_name: Name of the inbound chain
|
||||
:param outbound_chain_name: Name of the outbound chain
|
||||
"""
|
||||
LOG.debug(_("MidoClient.create_router_chains called: "
|
||||
"router=%(router)s, inbound_chain_name=%(in_chain)s, "
|
||||
"outbound_chain_name=%(out_chain)s"),
|
||||
LOG.debug("MidoClient.create_router_chains called: "
|
||||
"router=%(router)s, inbound_chain_name=%(in_chain)s, "
|
||||
"outbound_chain_name=%(out_chain)s",
|
||||
{"router": router, "in_chain": inbound_chain_name,
|
||||
"out_chain": outbound_chain_name})
|
||||
tenant_id = router.get_tenant_id()
|
||||
@ -445,8 +446,8 @@ class MidoClient:
|
||||
|
||||
:param id: router ID to delete chains of
|
||||
"""
|
||||
LOG.debug(_("MidoClient.delete_router_chains called: "
|
||||
"id=%(id)s"), {'id': id})
|
||||
LOG.debug("MidoClient.delete_router_chains called: "
|
||||
"id=%(id)s", {'id': id})
|
||||
router = self.get_router(id)
|
||||
if (router.get_inbound_filter_id()):
|
||||
self.mido_api.delete_chain(router.get_inbound_filter_id())
|
||||
@ -460,8 +461,8 @@ class MidoClient:
|
||||
|
||||
:param id: port ID to delete chains of
|
||||
"""
|
||||
LOG.debug(_("MidoClient.delete_port_chains called: "
|
||||
"id=%(id)s"), {'id': id})
|
||||
LOG.debug("MidoClient.delete_port_chains called: "
|
||||
"id=%(id)s", {'id': id})
|
||||
port = self.get_port(id)
|
||||
if (port.get_inbound_filter_id()):
|
||||
self.mido_api.delete_chain(port.get_inbound_filter_id())
|
||||
@ -472,8 +473,8 @@ class MidoClient:
|
||||
@handle_api_error
|
||||
def get_link_port(self, router, peer_router_id):
|
||||
"""Setup a route on the router to the next hop router."""
|
||||
LOG.debug(_("MidoClient.get_link_port called: "
|
||||
"router=%(router)s, peer_router_id=%(peer_router_id)s"),
|
||||
LOG.debug("MidoClient.get_link_port called: "
|
||||
"router=%(router)s, peer_router_id=%(peer_router_id)s",
|
||||
{'router': router, 'peer_router_id': peer_router_id})
|
||||
# Find the port linked between the two routers
|
||||
link_port = None
|
||||
@ -511,10 +512,10 @@ class MidoClient:
|
||||
:param port_id: port to match on
|
||||
:param nat_type: 'dnat' or 'snat'
|
||||
"""
|
||||
LOG.debug(_("MidoClient.add_static_nat called: "
|
||||
"tenant_id=%(tenant_id)s, chain_name=%(chain_name)s, "
|
||||
"from_ip=%(from_ip)s, to_ip=%(to_ip)s, "
|
||||
"port_id=%(port_id)s, nat_type=%(nat_type)s"),
|
||||
LOG.debug("MidoClient.add_static_nat called: "
|
||||
"tenant_id=%(tenant_id)s, chain_name=%(chain_name)s, "
|
||||
"from_ip=%(from_ip)s, to_ip=%(to_ip)s, "
|
||||
"port_id=%(port_id)s, nat_type=%(nat_type)s",
|
||||
{'tenant_id': tenant_id, 'chain_name': chain_name,
|
||||
'from_ip': from_ip, 'to_ip': to_ip,
|
||||
'portid': port_id, 'nat_type': nat_type})
|
||||
@ -571,8 +572,8 @@ class MidoClient:
|
||||
:param router: next hop router to remove the routes to
|
||||
:param ip: IP address of the route to remove
|
||||
"""
|
||||
LOG.debug(_("MidoClient.remote_static_route called: "
|
||||
"router=%(router)s, ip=%(ip)s"),
|
||||
LOG.debug("MidoClient.remote_static_route called: "
|
||||
"router=%(router)s, ip=%(ip)s",
|
||||
{'router': router, 'ip': ip})
|
||||
for r in router.get_routes():
|
||||
if (r.get_dst_network_addr() == ip and
|
||||
@ -582,9 +583,9 @@ class MidoClient:
|
||||
@handle_api_error
|
||||
def update_port_chains(self, port, inbound_chain_id, outbound_chain_id):
|
||||
"""Bind inbound and outbound chains to the port."""
|
||||
LOG.debug(_("MidoClient.update_port_chains called: port=%(port)s"
|
||||
"inbound_chain_id=%(inbound_chain_id)s, "
|
||||
"outbound_chain_id=%(outbound_chain_id)s"),
|
||||
LOG.debug("MidoClient.update_port_chains called: port=%(port)s"
|
||||
"inbound_chain_id=%(inbound_chain_id)s, "
|
||||
"outbound_chain_id=%(outbound_chain_id)s",
|
||||
{"port": port, "inbound_chain_id": inbound_chain_id,
|
||||
"outbound_chain_id": outbound_chain_id})
|
||||
port.inbound_filter_id(inbound_chain_id).outbound_filter_id(
|
||||
@ -593,22 +594,22 @@ class MidoClient:
|
||||
@handle_api_error
|
||||
def create_chain(self, tenant_id, name):
|
||||
"""Create a new chain."""
|
||||
LOG.debug(_("MidoClient.create_chain called: tenant_id=%(tenant_id)s "
|
||||
" name=%(name)s"), {"tenant_id": tenant_id, "name": name})
|
||||
LOG.debug("MidoClient.create_chain called: tenant_id=%(tenant_id)s "
|
||||
" name=%(name)s", {"tenant_id": tenant_id, "name": name})
|
||||
return self.mido_api.add_chain().tenant_id(tenant_id).name(
|
||||
name).create()
|
||||
|
||||
@handle_api_error
|
||||
def delete_chain(self, id):
|
||||
"""Delete chain matching the ID."""
|
||||
LOG.debug(_("MidoClient.delete_chain called: id=%(id)s"), {"id": id})
|
||||
LOG.debug("MidoClient.delete_chain called: id=%(id)s", {"id": id})
|
||||
self.mido_api.delete_chain(id)
|
||||
|
||||
@handle_api_error
|
||||
def delete_chains_by_names(self, tenant_id, names):
|
||||
"""Delete chains matching the names given for a tenant."""
|
||||
LOG.debug(_("MidoClient.delete_chains_by_names called: "
|
||||
"tenant_id=%(tenant_id)s names=%(names)s "),
|
||||
LOG.debug("MidoClient.delete_chains_by_names called: "
|
||||
"tenant_id=%(tenant_id)s names=%(names)s ",
|
||||
{"tenant_id": tenant_id, "names": names})
|
||||
chains = self.mido_api.get_chains({'tenant_id': tenant_id})
|
||||
for c in chains:
|
||||
@ -618,8 +619,8 @@ class MidoClient:
|
||||
@handle_api_error
|
||||
def get_chain_by_name(self, tenant_id, name):
|
||||
"""Get the chain by its name."""
|
||||
LOG.debug(_("MidoClient.get_chain_by_name called: "
|
||||
"tenant_id=%(tenant_id)s name=%(name)s "),
|
||||
LOG.debug("MidoClient.get_chain_by_name called: "
|
||||
"tenant_id=%(tenant_id)s name=%(name)s ",
|
||||
{"tenant_id": tenant_id, "name": name})
|
||||
for c in self.mido_api.get_chains({'tenant_id': tenant_id}):
|
||||
if c.get_name() == name:
|
||||
@ -629,8 +630,8 @@ class MidoClient:
|
||||
@handle_api_error
|
||||
def get_port_group_by_name(self, tenant_id, name):
|
||||
"""Get the port group by name."""
|
||||
LOG.debug(_("MidoClient.get_port_group_by_name called: "
|
||||
"tenant_id=%(tenant_id)s name=%(name)s "),
|
||||
LOG.debug("MidoClient.get_port_group_by_name called: "
|
||||
"tenant_id=%(tenant_id)s name=%(name)s ",
|
||||
{"tenant_id": tenant_id, "name": name})
|
||||
for p in self.mido_api.get_port_groups({'tenant_id': tenant_id}):
|
||||
if p.get_name() == name:
|
||||
@ -643,8 +644,8 @@ class MidoClient:
|
||||
|
||||
Create a new port group for a given name and ID.
|
||||
"""
|
||||
LOG.debug(_("MidoClient.create_port_group called: "
|
||||
"tenant_id=%(tenant_id)s name=%(name)s"),
|
||||
LOG.debug("MidoClient.create_port_group called: "
|
||||
"tenant_id=%(tenant_id)s name=%(name)s",
|
||||
{"tenant_id": tenant_id, "name": name})
|
||||
return self.mido_api.add_port_group().tenant_id(tenant_id).name(
|
||||
name).create()
|
||||
@ -652,21 +653,21 @@ class MidoClient:
|
||||
@handle_api_error
|
||||
def delete_port_group_by_name(self, tenant_id, name):
|
||||
"""Delete port group matching the name given for a tenant."""
|
||||
LOG.debug(_("MidoClient.delete_port_group_by_name called: "
|
||||
"tenant_id=%(tenant_id)s name=%(name)s "),
|
||||
LOG.debug("MidoClient.delete_port_group_by_name called: "
|
||||
"tenant_id=%(tenant_id)s name=%(name)s ",
|
||||
{"tenant_id": tenant_id, "name": name})
|
||||
pgs = self.mido_api.get_port_groups({'tenant_id': tenant_id})
|
||||
for pg in pgs:
|
||||
if pg.get_name() == name:
|
||||
LOG.debug(_("Deleting pg %(id)s"), {"id": pg.get_id()})
|
||||
LOG.debug("Deleting pg %(id)s", {"id": pg.get_id()})
|
||||
self.mido_api.delete_port_group(pg.get_id())
|
||||
|
||||
@handle_api_error
|
||||
def add_port_to_port_group_by_name(self, tenant_id, name, port_id):
|
||||
"""Add a port to a port group with the given name."""
|
||||
LOG.debug(_("MidoClient.add_port_to_port_group_by_name called: "
|
||||
"tenant_id=%(tenant_id)s name=%(name)s "
|
||||
"port_id=%(port_id)s"),
|
||||
LOG.debug("MidoClient.add_port_to_port_group_by_name called: "
|
||||
"tenant_id=%(tenant_id)s name=%(name)s "
|
||||
"port_id=%(port_id)s",
|
||||
{"tenant_id": tenant_id, "name": name, "port_id": port_id})
|
||||
pg = self.get_port_group_by_name(tenant_id, name)
|
||||
if pg is None:
|
||||
@ -678,8 +679,8 @@ class MidoClient:
|
||||
@handle_api_error
|
||||
def remove_port_from_port_groups(self, port_id):
|
||||
"""Remove a port binding from all the port groups."""
|
||||
LOG.debug(_("MidoClient.remove_port_from_port_groups called: "
|
||||
"port_id=%(port_id)s"), {"port_id": port_id})
|
||||
LOG.debug("MidoClient.remove_port_from_port_groups called: "
|
||||
"port_id=%(port_id)s", {"port_id": port_id})
|
||||
port = self.get_port(port_id)
|
||||
for pg in port.get_port_groups():
|
||||
pg.delete()
|
||||
|
@ -43,6 +43,7 @@ from neutron.extensions import external_net as ext_net
|
||||
from neutron.extensions import l3
|
||||
from neutron.extensions import portbindings
|
||||
from neutron.extensions import securitygroup as ext_sg
|
||||
from neutron.i18n import _LE, _LW
|
||||
from neutron.openstack.common import log as logging
|
||||
from neutron.plugins.midonet.common import config # noqa
|
||||
from neutron.plugins.midonet.common import net_util
|
||||
@ -183,7 +184,7 @@ def _check_resource_exists(func, id, name, raise_exc=False):
|
||||
try:
|
||||
func(id)
|
||||
except midonet_lib.MidonetResourceNotFound as exc:
|
||||
LOG.error(_("There is no %(name)s with ID %(id)s in MidoNet."),
|
||||
LOG.error(_LE("There is no %(name)s with ID %(id)s in MidoNet."),
|
||||
{"name": name, "id": id})
|
||||
if raise_exc:
|
||||
raise MidonetPluginException(msg=exc)
|
||||
@ -398,7 +399,7 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
|
||||
Creates a Neutron subnet and a DHCP entry in MidoNet bridge.
|
||||
"""
|
||||
LOG.debug(_("MidonetPluginV2.create_subnet called: subnet=%r"), subnet)
|
||||
LOG.debug("MidonetPluginV2.create_subnet called: subnet=%r", subnet)
|
||||
|
||||
s = subnet["subnet"]
|
||||
net = super(MidonetPluginV2, self).get_network(
|
||||
@ -430,7 +431,7 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
self._link_bridge_to_gw_router(
|
||||
bridge, self._get_provider_router(), gateway_ip, cidr)
|
||||
|
||||
LOG.debug(_("MidonetPluginV2.create_subnet exiting: sn_entry=%r"),
|
||||
LOG.debug("MidonetPluginV2.create_subnet exiting: sn_entry=%r",
|
||||
sn_entry)
|
||||
return sn_entry
|
||||
|
||||
@ -439,7 +440,7 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
|
||||
Delete neutron network and its corresponding MidoNet bridge.
|
||||
"""
|
||||
LOG.debug(_("MidonetPluginV2.delete_subnet called: id=%s"), id)
|
||||
LOG.debug("MidonetPluginV2.delete_subnet called: id=%s", id)
|
||||
subnet = super(MidonetPluginV2, self).get_subnet(context, id,
|
||||
fields=None)
|
||||
net = super(MidonetPluginV2, self).get_network(context,
|
||||
@ -458,7 +459,7 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
self._unlink_bridge_from_gw_router(
|
||||
bridge, self._get_provider_router())
|
||||
|
||||
LOG.debug(_("MidonetPluginV2.delete_subnet exiting"))
|
||||
LOG.debug("MidonetPluginV2.delete_subnet exiting")
|
||||
|
||||
@handle_api_error
|
||||
def create_network(self, context, network):
|
||||
@ -515,7 +516,7 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
|
||||
def create_port(self, context, port):
|
||||
"""Create a L2 port in Neutron/MidoNet."""
|
||||
LOG.debug(_("MidonetPluginV2.create_port called: port=%r"), port)
|
||||
LOG.debug("MidonetPluginV2.create_port called: port=%r", port)
|
||||
port_data = port['port']
|
||||
|
||||
# Create a bridge port in MidoNet and set the bridge port ID as the
|
||||
@ -576,34 +577,34 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
except Exception as ex:
|
||||
# Try removing the MidoNet port before raising an exception.
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.error(_("Failed to create a port on network %(net_id)s: "
|
||||
LOG.error(_LE("Failed to create a port on network %(net_id)s: "
|
||||
"%(err)s"),
|
||||
{"net_id": port_data["network_id"], "err": ex})
|
||||
self.client.delete_port(bridge_port.get_id())
|
||||
|
||||
LOG.debug(_("MidonetPluginV2.create_port exiting: port=%r"), new_port)
|
||||
LOG.debug("MidonetPluginV2.create_port exiting: port=%r", new_port)
|
||||
return new_port
|
||||
|
||||
def get_port(self, context, id, fields=None):
|
||||
"""Retrieve port."""
|
||||
LOG.debug(_("MidonetPluginV2.get_port called: id=%(id)s "
|
||||
"fields=%(fields)r"), {'id': id, 'fields': fields})
|
||||
LOG.debug("MidonetPluginV2.get_port called: id=%(id)s "
|
||||
"fields=%(fields)r", {'id': id, 'fields': fields})
|
||||
port = super(MidonetPluginV2, self).get_port(context, id, fields)
|
||||
"Check if the port exists in MidoNet DB"""
|
||||
try:
|
||||
self.client.get_port(id)
|
||||
except midonet_lib.MidonetResourceNotFound as exc:
|
||||
LOG.error(_("There is no port with ID %(id)s in MidoNet."),
|
||||
LOG.error(_LE("There is no port with ID %(id)s in MidoNet."),
|
||||
{"id": id})
|
||||
port['status'] = constants.PORT_STATUS_ERROR
|
||||
raise exc
|
||||
LOG.debug(_("MidonetPluginV2.get_port exiting: port=%r"), port)
|
||||
LOG.debug("MidonetPluginV2.get_port exiting: port=%r", port)
|
||||
return port
|
||||
|
||||
def get_ports(self, context, filters=None, fields=None):
|
||||
"""List neutron ports and verify that they exist in MidoNet."""
|
||||
LOG.debug(_("MidonetPluginV2.get_ports called: filters=%(filters)s "
|
||||
"fields=%(fields)r"),
|
||||
LOG.debug("MidonetPluginV2.get_ports called: filters=%(filters)s "
|
||||
"fields=%(fields)r",
|
||||
{'filters': filters, 'fields': fields})
|
||||
ports = super(MidonetPluginV2, self).get_ports(context, filters,
|
||||
fields)
|
||||
@ -611,8 +612,8 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
|
||||
def delete_port(self, context, id, l3_port_check=True):
|
||||
"""Delete a neutron port and corresponding MidoNet bridge port."""
|
||||
LOG.debug(_("MidonetPluginV2.delete_port called: id=%(id)s "
|
||||
"l3_port_check=%(l3_port_check)r"),
|
||||
LOG.debug("MidonetPluginV2.delete_port called: id=%(id)s "
|
||||
"l3_port_check=%(l3_port_check)r",
|
||||
{'id': id, 'l3_port_check': l3_port_check})
|
||||
# if needed, check to see if this is a port owned by
|
||||
# and l3-router. If so, we should prevent deletion.
|
||||
@ -645,7 +646,7 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
self.client.delete_dhcp_host(port["network_id"], cidr, ip,
|
||||
mac)
|
||||
except Exception:
|
||||
LOG.error(_("Failed to delete DHCP mapping for port %(id)s"),
|
||||
LOG.error(_LE("Failed to delete DHCP mapping for port %(id)s"),
|
||||
{"id": id})
|
||||
|
||||
super(MidonetPluginV2, self).delete_port(context, id)
|
||||
@ -720,7 +721,7 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
# this method in order to be able to use the MidoNet ID as Neutron ID
|
||||
# TODO(dcahill): Propose upstream patch for allowing
|
||||
# 3rd parties to specify IDs as we do with l2 plugin
|
||||
LOG.debug(_("MidonetPluginV2.create_router called: router=%(router)s"),
|
||||
LOG.debug("MidonetPluginV2.create_router called: router=%(router)s",
|
||||
{"router": router})
|
||||
r = router['router']
|
||||
tenant_id = self._get_tenant_id_for_create(context, r)
|
||||
@ -767,8 +768,8 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
r['status'] = router_data['status']
|
||||
context.session.add(r)
|
||||
|
||||
LOG.debug(_("MidonetPluginV2.create_router exiting: "
|
||||
"router_data=%(router_data)s."),
|
||||
LOG.debug("MidonetPluginV2.create_router exiting: "
|
||||
"router_data=%(router_data)s.",
|
||||
{"router_data": router_data})
|
||||
return router_data
|
||||
|
||||
@ -779,8 +780,8 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
:param gw_router: gateway router to link to
|
||||
:param gw_ip: gateway IP address
|
||||
"""
|
||||
LOG.debug(_("MidonetPluginV2.set_router_gateway called: id=%(id)s, "
|
||||
"gw_router=%(gw_router)s, gw_ip=%(gw_ip)s"),
|
||||
LOG.debug("MidonetPluginV2.set_router_gateway called: id=%(id)s, "
|
||||
"gw_router=%(gw_router)s, gw_ip=%(gw_ip)s",
|
||||
{'id': id, 'gw_router': gw_router, 'gw_ip': gw_ip}),
|
||||
|
||||
router = self.client.get_router(id)
|
||||
@ -823,8 +824,8 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
|
||||
:param ID: ID of the router
|
||||
"""
|
||||
LOG.debug(_("MidonetPluginV2.remove_router_gateway called: "
|
||||
"id=%(id)s"), {'id': id})
|
||||
LOG.debug("MidonetPluginV2.remove_router_gateway called: "
|
||||
"id=%(id)s", {'id': id})
|
||||
router = self.client.get_router(id)
|
||||
|
||||
# delete the port that is connected to the gateway router
|
||||
@ -843,8 +844,8 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
|
||||
def update_router(self, context, id, router):
|
||||
"""Handle router updates."""
|
||||
LOG.debug(_("MidonetPluginV2.update_router called: id=%(id)s "
|
||||
"router=%(router)r"), {"id": id, "router": router})
|
||||
LOG.debug("MidonetPluginV2.update_router called: id=%(id)s "
|
||||
"router=%(router)r", {"id": id, "router": router})
|
||||
|
||||
router_data = router["router"]
|
||||
|
||||
@ -883,7 +884,7 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
|
||||
self.client.update_router(id, **router_data)
|
||||
|
||||
LOG.debug(_("MidonetPluginV2.update_router exiting: router=%r"), r)
|
||||
LOG.debug("MidonetPluginV2.update_router exiting: router=%r", r)
|
||||
return r
|
||||
|
||||
def delete_router(self, context, id):
|
||||
@ -894,7 +895,7 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
|
||||
:param id: router ID to remove
|
||||
"""
|
||||
LOG.debug(_("MidonetPluginV2.delete_router called: id=%s"), id)
|
||||
LOG.debug("MidonetPluginV2.delete_router called: id=%s", id)
|
||||
|
||||
self.client.delete_router_chains(id)
|
||||
self.client.delete_router(id)
|
||||
@ -994,9 +995,9 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
|
||||
def add_router_interface(self, context, router_id, interface_info):
|
||||
"""Handle router linking with network."""
|
||||
LOG.debug(_("MidonetPluginV2.add_router_interface called: "
|
||||
"router_id=%(router_id)s "
|
||||
"interface_info=%(interface_info)r"),
|
||||
LOG.debug("MidonetPluginV2.add_router_interface called: "
|
||||
"router_id=%(router_id)s "
|
||||
"interface_info=%(interface_info)r",
|
||||
{'router_id': router_id, 'interface_info': interface_info})
|
||||
|
||||
with context.session.begin(subtransactions=True):
|
||||
@ -1018,8 +1019,8 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
if dhcp_ports and dhcp_ports[0].fixed_ips:
|
||||
metadata_gw_ip = dhcp_ports[0].fixed_ips[0].ip_address
|
||||
else:
|
||||
LOG.warn(_("DHCP agent is not working correctly. No port "
|
||||
"to reach the Metadata server on this network"))
|
||||
LOG.warn(_LW("DHCP agent is not working correctly. No port "
|
||||
"to reach the Metadata server on this network"))
|
||||
# Link the router and the bridge
|
||||
port = super(MidonetPluginV2, self).get_port(context,
|
||||
info["port_id"])
|
||||
@ -1027,15 +1028,15 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
net_len, subnet["gateway_ip"],
|
||||
metadata_gw_ip)
|
||||
except Exception:
|
||||
LOG.error(_("Failed to create MidoNet resources to add router "
|
||||
"interface. info=%(info)s, router_id=%(router_id)s"),
|
||||
LOG.error(_LE("Failed to create MidoNet resources to add router "
|
||||
"interface. info=%(info)s, router_id=%(router_id)s"),
|
||||
{"info": info, "router_id": router_id})
|
||||
with excutils.save_and_reraise_exception():
|
||||
with context.session.begin(subtransactions=True):
|
||||
self.remove_router_interface(context, router_id, info)
|
||||
|
||||
LOG.debug(_("MidonetPluginV2.add_router_interface exiting: "
|
||||
"info=%r"), info)
|
||||
LOG.debug("MidonetPluginV2.add_router_interface exiting: "
|
||||
"info=%r", info)
|
||||
return info
|
||||
|
||||
def _assoc_fip(self, fip):
|
||||
@ -1074,8 +1075,8 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
|
||||
def update_floatingip(self, context, id, floatingip):
|
||||
"""Handle floating IP association and disassociation."""
|
||||
LOG.debug(_("MidonetPluginV2.update_floatingip called: id=%(id)s "
|
||||
"floatingip=%(floatingip)s "),
|
||||
LOG.debug("MidonetPluginV2.update_floatingip called: id=%(id)s "
|
||||
"floatingip=%(floatingip)s ",
|
||||
{'id': id, 'floatingip': floatingip})
|
||||
|
||||
session = context.session
|
||||
@ -1093,7 +1094,7 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
super(MidonetPluginV2, self).update_floatingip(context, id,
|
||||
floatingip)
|
||||
|
||||
LOG.debug(_("MidonetPluginV2.update_floating_ip exiting: fip=%s"), fip)
|
||||
LOG.debug("MidonetPluginV2.update_floating_ip exiting: fip=%s", fip)
|
||||
return fip
|
||||
|
||||
def disassociate_floatingips(self, context, port_id):
|
||||
@ -1115,9 +1116,9 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
In MidoNet, this means creating a pair of chains, inbound and outbound,
|
||||
as well as a new port group.
|
||||
"""
|
||||
LOG.debug(_("MidonetPluginV2.create_security_group called: "
|
||||
"security_group=%(security_group)s "
|
||||
"default_sg=%(default_sg)s "),
|
||||
LOG.debug("MidonetPluginV2.create_security_group called: "
|
||||
"security_group=%(security_group)s "
|
||||
"default_sg=%(default_sg)s ",
|
||||
{'security_group': security_group, 'default_sg': default_sg})
|
||||
|
||||
sg = security_group.get('security_group')
|
||||
@ -1144,20 +1145,20 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
self._create_accept_chain_rule(context, r,
|
||||
chain=chains[r['direction']])
|
||||
except Exception:
|
||||
LOG.error(_("Failed to create MidoNet resources for sg %(sg)r"),
|
||||
LOG.error(_LE("Failed to create MidoNet resources for sg %(sg)r"),
|
||||
{"sg": sg})
|
||||
with excutils.save_and_reraise_exception():
|
||||
with context.session.begin(subtransactions=True):
|
||||
sg = self._get_security_group(context, sg["id"])
|
||||
context.session.delete(sg)
|
||||
|
||||
LOG.debug(_("MidonetPluginV2.create_security_group exiting: sg=%r"),
|
||||
LOG.debug("MidonetPluginV2.create_security_group exiting: sg=%r",
|
||||
sg)
|
||||
return sg
|
||||
|
||||
def delete_security_group(self, context, id):
|
||||
"""Delete chains for Neutron security group."""
|
||||
LOG.debug(_("MidonetPluginV2.delete_security_group called: id=%s"), id)
|
||||
LOG.debug("MidonetPluginV2.delete_security_group called: id=%s", id)
|
||||
|
||||
with context.session.begin(subtransactions=True):
|
||||
sg = super(MidonetPluginV2, self).get_security_group(context, id)
|
||||
@ -1189,8 +1190,8 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
Create a security group rule in the Neutron DB and corresponding
|
||||
MidoNet resources in its data store.
|
||||
"""
|
||||
LOG.debug(_("MidonetPluginV2.create_security_group_rule called: "
|
||||
"security_group_rule=%(security_group_rule)r"),
|
||||
LOG.debug("MidonetPluginV2.create_security_group_rule called: "
|
||||
"security_group_rule=%(security_group_rule)r",
|
||||
{'security_group_rule': security_group_rule})
|
||||
|
||||
with context.session.begin(subtransactions=True):
|
||||
@ -1199,8 +1200,8 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
|
||||
self._create_accept_chain_rule(context, rule)
|
||||
|
||||
LOG.debug(_("MidonetPluginV2.create_security_group_rule exiting: "
|
||||
"rule=%r"), rule)
|
||||
LOG.debug("MidonetPluginV2.create_security_group_rule exiting: "
|
||||
"rule=%r", rule)
|
||||
return rule
|
||||
|
||||
def delete_security_group_rule(self, context, sg_rule_id):
|
||||
@ -1209,8 +1210,8 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
Delete a security group rule from the Neutron DB and corresponding
|
||||
MidoNet resources from its data store.
|
||||
"""
|
||||
LOG.debug(_("MidonetPluginV2.delete_security_group_rule called: "
|
||||
"sg_rule_id=%s"), sg_rule_id)
|
||||
LOG.debug("MidonetPluginV2.delete_security_group_rule called: "
|
||||
"sg_rule_id=%s", sg_rule_id)
|
||||
with context.session.begin(subtransactions=True):
|
||||
rule = super(MidonetPluginV2, self).get_security_group_rule(
|
||||
context, sg_rule_id)
|
||||
|
Loading…
x
Reference in New Issue
Block a user