summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-11-14 11:28:22 +0000
committerGerrit Code Review <review@openstack.org>2018-11-14 11:28:22 +0000
commit4fc6df38bcd26217350fc746745600ccc4f26bbf (patch)
tree5a0b4df7ad16a41d903ff8c0081f8624833ecb7d
parent605ad27f053a1ef9ffb3601c6023987ddb6a22e1 (diff)
parent09bc91f3024ac9addd0e6f000303327ff8f7de9f (diff)
Merge "Clean up: Remove unused ovsdb commands"
-rw-r--r--networking_ovn/ovsdb/commands.py65
-rw-r--r--networking_ovn/ovsdb/impl_idl_ovn.py6
-rw-r--r--networking_ovn/ovsdb/ovn_api.py22
-rw-r--r--networking_ovn/tests/unit/fakes.py2
4 files changed, 0 insertions, 95 deletions
diff --git a/networking_ovn/ovsdb/commands.py b/networking_ovn/ovsdb/commands.py
index d07e2b7..f0f48ce 100644
--- a/networking_ovn/ovsdb/commands.py
+++ b/networking_ovn/ovsdb/commands.py
@@ -971,71 +971,6 @@ class SetNATRuleInLRouterCommand(command.BaseCommand):
971 break 971 break
972 972
973 973
974class AddNatIpToLRPortPeerOptionsCommand(command.BaseCommand):
975 # TODO(chandrav): Add unit tests, bug #1638715.
976 def __init__(self, api, lport, nat_ip):
977 super(AddNatIpToLRPortPeerOptionsCommand, self).__init__(api)
978 self.lport = lport
979 self.nat_ip = nat_ip
980
981 def run_idl(self, txn):
982 try:
983 lport = idlutils.row_by_value(self.api.idl, 'Logical_Switch_Port',
984 'name', self.lport)
985 except idlutils.RowNotFound:
986 msg = _("Logical Switch Port %s does not exist") % self.lport
987 raise RuntimeError(msg)
988
989 lport.verify('addresses')
990 addresses = getattr(lport, 'addresses', [])
991 lport.verify('options')
992 options = getattr(lport, 'options', {})
993
994 nat_ip_list = options.get('nat-addresses', '').split()
995 if not nat_ip_list:
996 nat_ips = addresses[0].split()[0] + ' ' + self.nat_ip
997 elif self.nat_ip not in nat_ip_list:
998 nat_ip_list.append(self.nat_ip)
999 nat_ips = ' '.join(nat_ip_list)
1000 else:
1001 return
1002 options['nat-addresses'] = nat_ips
1003 lport.options = options
1004
1005
1006class DeleteNatIpFromLRPortPeerOptionsCommand(command.BaseCommand):
1007 # TODO(chandrav): Add unit tests, bug #1638715.
1008 def __init__(self, api, lport, nat_ip):
1009 super(DeleteNatIpFromLRPortPeerOptionsCommand, self).__init__(api)
1010 self.lport = lport
1011 self.nat_ip = nat_ip
1012
1013 def run_idl(self, txn):
1014 try:
1015 lport = idlutils.row_by_value(self.api.idl, 'Logical_Switch_Port',
1016 'name', self.lport)
1017
1018 except idlutils.RowNotFound:
1019 msg = _("Logical Switch Port %s does not exist") % self.lport
1020 raise RuntimeError(msg)
1021
1022 lport.verify('options')
1023 options = getattr(lport, 'options', {})
1024 nat_ip_list = options.get('nat-addresses', '').split()
1025 if self.nat_ip not in nat_ip_list:
1026 return
1027 nat_ip_list.remove(self.nat_ip)
1028 if len(nat_ip_list) is 1:
1029 nat_ips = ''
1030 else:
1031 nat_ips = ' '.join(nat_ip_list)
1032 if not nat_ips:
1033 del options['nat-addresses']
1034 else:
1035 options['nat-addresses'] = nat_ips
1036 lport.options = options
1037
1038
1039class CheckRevisionNumberCommand(command.BaseCommand): 974class CheckRevisionNumberCommand(command.BaseCommand):
1040 975
1041 def __init__(self, api, name, resource, resource_type, if_exists): 976 def __init__(self, api, name, resource, resource_type, if_exists):
diff --git a/networking_ovn/ovsdb/impl_idl_ovn.py b/networking_ovn/ovsdb/impl_idl_ovn.py
index ccedfaa..70d7068 100644
--- a/networking_ovn/ovsdb/impl_idl_ovn.py
+++ b/networking_ovn/ovsdb/impl_idl_ovn.py
@@ -567,12 +567,6 @@ class OvsdbNbOvnIdl(nb_impl_idl.OvnNbApiIdlImpl, Backend):
567 return cmd.SetNATRuleInLRouterCommand(self, lrouter, nat_rule_uuid, 567 return cmd.SetNATRuleInLRouterCommand(self, lrouter, nat_rule_uuid,
568 **columns) 568 **columns)
569 569
570 def add_nat_ip_to_lrport_peer_options(self, lport, nat_ip):
571 return cmd.AddNatIpToLRPortPeerOptionsCommand(self, lport, nat_ip)
572
573 def delete_nat_ip_from_lrport_peer_options(self, lport, nat_ip):
574 return cmd.DeleteNatIpFromLRPortPeerOptionsCommand(self, lport, nat_ip)
575
576 def get_lswitch_port(self, lsp_name): 570 def get_lswitch_port(self, lsp_name):
577 try: 571 try:
578 return self.lookup('Logical_Switch_Port', lsp_name) 572 return self.lookup('Logical_Switch_Port', lsp_name)
diff --git a/networking_ovn/ovsdb/ovn_api.py b/networking_ovn/ovsdb/ovn_api.py
index a05b2ba..dc0d004 100644
--- a/networking_ovn/ovsdb/ovn_api.py
+++ b/networking_ovn/ovsdb/ovn_api.py
@@ -475,28 +475,6 @@ class API(api.API):
475 """ 475 """
476 476
477 @abc.abstractmethod 477 @abc.abstractmethod
478 def add_nat_ip_to_lrport_peer_options(self, lport, nat_ip):
479 """Add nat address in peer port of lrouter port
480
481 :param lport: The unique name of the lswitch port
482 :type lport: string
483 :param nat_ip: nat ip to be added
484 :type nat_ip: string
485 :returns: :class:`Command` with no result
486 """
487
488 @abc.abstractmethod
489 def delete_nat_ip_from_lrport_peer_options(self, lport, nat_ip):
490 """Delete nat address from peer port of lrouter port
491
492 :param lport: The unique name of the lswitch port
493 :type lport: string
494 :param nat_ip: nat ip to be removed
495 :type nat_ip: string
496 :returns: :class:`Command` with no result
497 """
498
499 @abc.abstractmethod
500 def get_lrouter_nat_rules(self, lrouter): 478 def get_lrouter_nat_rules(self, lrouter):
501 """Returns the nat rules of a router 479 """Returns the nat rules of a router
502 480
diff --git a/networking_ovn/tests/unit/fakes.py b/networking_ovn/tests/unit/fakes.py
index 9825593..c5c6f53 100644
--- a/networking_ovn/tests/unit/fakes.py
+++ b/networking_ovn/tests/unit/fakes.py
@@ -90,8 +90,6 @@ class FakeOvsdbNbOvnIdl(object):
90 self.get_router_port_options.return_value = {} 90 self.get_router_port_options.return_value = {}
91 self.add_nat_rule_in_lrouter = mock.Mock() 91 self.add_nat_rule_in_lrouter = mock.Mock()
92 self.delete_nat_rule_in_lrouter = mock.Mock() 92 self.delete_nat_rule_in_lrouter = mock.Mock()
93 self.add_nat_ip_to_lrport_peer_options = mock.Mock()
94 self.delete_nat_ip_from_lrport_peer_options = mock.Mock()
95 self.get_lrouter_nat_rules = mock.Mock() 93 self.get_lrouter_nat_rules = mock.Mock()
96 self.get_lrouter_nat_rules.return_value = [] 94 self.get_lrouter_nat_rules.return_value = []
97 self.set_nat_rule_in_lrouter = mock.Mock() 95 self.set_nat_rule_in_lrouter = mock.Mock()