Merge "Bump ovsdbapp to 2.8.0"
This commit is contained in:
commit
ba4115cc84
@ -138,11 +138,6 @@ ADVERTISEMENT_METHOD_SUBNET = 'subnet'
|
||||
OVN_CLUSTER_ROUTER = 'bgp-router'
|
||||
OVN_CLUSTER_ROUTER_INTERNAL_MAC = '40:44:00:00:00:06'
|
||||
|
||||
# FIXME(ltomasbo): This can be removed once ovsdbapp version is >=1.13.0
|
||||
POLICY_ACTION_REROUTE = 'reroute'
|
||||
POLICY_ACTION_TYPES = (POLICY_ACTION_REROUTE)
|
||||
LR_POLICY_PRIORITY_MAX = 32767
|
||||
|
||||
ROUTE_DISCARD = 'discard'
|
||||
ROUTE_TYPE_UNICAST = 1
|
||||
|
||||
|
@ -12,11 +12,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import netaddr
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
||||
from ovs.stream import Stream
|
||||
from ovsdbapp.backend import ovs_idl
|
||||
from ovsdbapp.backend.ovs_idl import command
|
||||
@ -158,126 +155,6 @@ class Backend(ovs_idl.Backend):
|
||||
return self.idl.tables
|
||||
|
||||
|
||||
# FIXME(ltomasbo): This can be removed once ovsdbapp version is >=2.3.0
|
||||
class LSGetLocalnetPortsCommand(command.ReadOnlyCommand):
|
||||
def __init__(self, api, switch, if_exists=False):
|
||||
super().__init__(api)
|
||||
self.switch = switch
|
||||
self.if_exists = if_exists
|
||||
|
||||
def localnet_port(self, row):
|
||||
return row.type == constants.OVN_LOCALNET_VIF_PORT_TYPE
|
||||
|
||||
def run_idl(self, txn):
|
||||
try:
|
||||
lswitch = self.api.lookup('Logical_Switch', self.switch)
|
||||
self.result = [rowview.RowView(p) for p in lswitch.ports
|
||||
if self.localnet_port(p)]
|
||||
except idlutils.RowNotFound as e:
|
||||
if self.if_exists:
|
||||
self.result = []
|
||||
return
|
||||
msg = "Logical Switch %s does not exist" % self.switch
|
||||
raise RuntimeError(msg) from e
|
||||
|
||||
|
||||
# FIXME(ltomasbo): This can be removed once ovsdbapp version is >=2.1.0
|
||||
class _LrpNetworksCommand(command.BaseCommand):
|
||||
table = 'Logical_Router_Port'
|
||||
|
||||
def __init__(self, api, port, networks, exists):
|
||||
super().__init__(api)
|
||||
self.port = port
|
||||
self.exists = exists
|
||||
if isinstance(networks, (str, bytes)):
|
||||
networks = [networks]
|
||||
self.networks = [str(netaddr.IPNetwork(network))
|
||||
for network in networks]
|
||||
|
||||
|
||||
# FIXME(ltomasbo): This can be removed once ovsdbapp version is >=2.1.0
|
||||
class LrpAddNetworksCommand(_LrpNetworksCommand):
|
||||
def run_idl(self, txn):
|
||||
lrp = self.api.lookup(self.table, self.port)
|
||||
for network in self.networks:
|
||||
if network in lrp.networks and not self.exists:
|
||||
msg = "Network '%s' already exist in networks of port %s" % (
|
||||
network, lrp.uuid)
|
||||
raise RuntimeError(msg)
|
||||
lrp.addvalue('networks', network)
|
||||
|
||||
|
||||
# FIXME(ltomasbo): This can be removed once ovsdbapp supports it
|
||||
class LrRouteAddCommand(command.BaseCommand):
|
||||
def __init__(self, api, router, prefix, nexthop, port=None,
|
||||
policy='dst-ip', ecmp=False, may_exist=False):
|
||||
prefix = str(netaddr.IPNetwork(prefix))
|
||||
if nexthop != constants.ROUTE_DISCARD:
|
||||
nexthop = str(netaddr.IPAddress(nexthop))
|
||||
super().__init__(api)
|
||||
self.router = router
|
||||
self.prefix = prefix
|
||||
self.nexthop = nexthop
|
||||
self.port = port
|
||||
self.policy = policy
|
||||
self.ecmp = ecmp
|
||||
self.may_exist = may_exist
|
||||
|
||||
def run_idl(self, txn):
|
||||
lr = self.api.lookup('Logical_Router', self.router)
|
||||
for route in lr.static_routes:
|
||||
if self.prefix == route.ip_prefix:
|
||||
if self.ecmp and self.nexthop != route.nexthop:
|
||||
continue
|
||||
if not self.may_exist:
|
||||
msg = "Route %s already exists on router %s" % (
|
||||
self.prefix, self.router)
|
||||
raise RuntimeError(msg)
|
||||
route.nexthop = self.nexthop
|
||||
route.policy = self.policy
|
||||
if self.port:
|
||||
route.output_port = self.port
|
||||
self.result = rowview.RowView(route)
|
||||
return
|
||||
route = txn.insert(self.api.tables['Logical_Router_Static_Route'])
|
||||
route.ip_prefix = self.prefix
|
||||
route.nexthop = self.nexthop
|
||||
route.policy = self.policy
|
||||
if self.port:
|
||||
route.output_port = self.port
|
||||
lr.addvalue('static_routes', route)
|
||||
self.result = route.uuid
|
||||
|
||||
|
||||
# FIXME(ltomasbo): This can be removed once ovsdbapp supports it
|
||||
class LrRouteDelCommand(command.BaseCommand):
|
||||
def __init__(self, api, router,
|
||||
prefix=None, nexthop=None, if_exists=False):
|
||||
if prefix is not None:
|
||||
prefix = str(netaddr.IPNetwork(prefix))
|
||||
super().__init__(api)
|
||||
self.router = router
|
||||
self.prefix = prefix
|
||||
self.nexthop = nexthop
|
||||
self.if_exists = if_exists
|
||||
|
||||
def run_idl(self, txn):
|
||||
lr = self.api.lookup('Logical_Router', self.router)
|
||||
if not self.prefix:
|
||||
lr.static_routes = []
|
||||
return
|
||||
for route in lr.static_routes:
|
||||
if self.prefix == route.ip_prefix:
|
||||
if self.nexthop and route.nexthop != self.nexthop:
|
||||
continue
|
||||
lr.delvalue('static_routes', route)
|
||||
return
|
||||
if not self.if_exists:
|
||||
msg = "Route for %s in router %s does not exist" % (
|
||||
self.prefix, self.router)
|
||||
raise RuntimeError(msg)
|
||||
|
||||
|
||||
class StaticMACBindingFindCommand(command.DbFindCommand):
|
||||
table = 'Static_MAC_Binding'
|
||||
|
||||
@ -503,23 +380,6 @@ class OvsdbNbOvnIdl(nb_impl_idl.OvnNbApiIdlImpl, Backend):
|
||||
continue
|
||||
return lbs
|
||||
|
||||
# FIXME(ltomasbo): This can be removed once ovsdbapp version is >=2.3.0
|
||||
def ls_get_localnet_ports(self, logical_switch, if_exists=True):
|
||||
return LSGetLocalnetPortsCommand(self, logical_switch,
|
||||
if_exists=if_exists)
|
||||
|
||||
# FIXME(ltomasbo): This can be removed once ovsdbapp version is >=2.1.0
|
||||
def lrp_add_networks(self, port, networks, may_exist=False):
|
||||
return LrpAddNetworksCommand(self, port, networks, may_exist)
|
||||
|
||||
def lr_route_add(self, router, prefix, nexthop, port=None,
|
||||
policy='dst-ip', ecmp=False, may_exist=False):
|
||||
return LrRouteAddCommand(self, router, prefix, nexthop, port,
|
||||
policy, ecmp, may_exist)
|
||||
|
||||
def lr_route_del(self, router, prefix=None, nexthop=None, if_exists=False):
|
||||
return LrRouteDelCommand(self, router, prefix, nexthop, if_exists)
|
||||
|
||||
def static_mac_binding_add(self, port, ip, mac, override_dynamic_mac=False,
|
||||
may_exist=False):
|
||||
return StaticMACBindingAddCommand(self, port, ip, mac,
|
||||
|
@ -13,7 +13,7 @@ oslo.privsep>=2.3.0 # Apache-2.0
|
||||
oslo.rootwrap>=5.15.0 # Apache-2.0
|
||||
oslo.service>=1.40.2 # Apache-2.0
|
||||
ovs>=2.8.0 # Apache-2.0
|
||||
ovsdbapp>=1.16.0 # Apache-2.0
|
||||
ovsdbapp>=2.8.0 # Apache-2.0
|
||||
pyroute2>=0.6.6;sys_platform!='win32' # Apache-2.0 (+ dual licensed GPL2)
|
||||
stevedore>=1.20.0 # Apache-2.0
|
||||
tenacity>=6.0.0 # Apache-2.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user