Browse Source

Merge "Clean up: Remove unused ovsdb commands"

Zuul 5 months ago
parent
commit
4fc6df38bc

+ 0
- 65
networking_ovn/ovsdb/commands.py View File

@@ -971,71 +971,6 @@ class SetNATRuleInLRouterCommand(command.BaseCommand):
971 971
                 break
972 972
 
973 973
 
974
-class 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
-
1006
-class 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
-
1039 974
 class CheckRevisionNumberCommand(command.BaseCommand):
1040 975
 
1041 976
     def __init__(self, api, name, resource, resource_type, if_exists):

+ 0
- 6
networking_ovn/ovsdb/impl_idl_ovn.py View File

@@ -567,12 +567,6 @@ class OvsdbNbOvnIdl(nb_impl_idl.OvnNbApiIdlImpl, Backend):
567 567
         return cmd.SetNATRuleInLRouterCommand(self, lrouter, nat_rule_uuid,
568 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 570
     def get_lswitch_port(self, lsp_name):
577 571
         try:
578 572
             return self.lookup('Logical_Switch_Port', lsp_name)

+ 0
- 22
networking_ovn/ovsdb/ovn_api.py View File

@@ -474,28 +474,6 @@ class API(api.API):
474 474
         :returns:            :class:`Command` with no result
475 475
         """
476 476
 
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 477
     @abc.abstractmethod
500 478
     def get_lrouter_nat_rules(self, lrouter):
501 479
         """Returns the nat rules of a router

+ 0
- 2
networking_ovn/tests/unit/fakes.py View File

@@ -90,8 +90,6 @@ class FakeOvsdbNbOvnIdl(object):
90 90
         self.get_router_port_options.return_value = {}
91 91
         self.add_nat_rule_in_lrouter = mock.Mock()
92 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 93
         self.get_lrouter_nat_rules = mock.Mock()
96 94
         self.get_lrouter_nat_rules.return_value = []
97 95
         self.set_nat_rule_in_lrouter = mock.Mock()

Loading…
Cancel
Save