@@ -2664,22 +2664,6 @@ def warm_restart_bgp_eoiu(ctx, enable):
26642664 db = ctx .obj ['db' ]
26652665 db .mod_entry ('WARM_RESTART' , 'bgp' , {'bgp_eoiu' : enable })
26662666
2667- def mvrf_restart_services ():
2668- """Restart interfaces-config service and NTP service when mvrf is changed"""
2669- """
2670- When mvrf is enabled, eth0 should be moved to mvrf; when it is disabled,
2671- move it back to default vrf. Restarting the "interfaces-config" service
2672- will recreate the /etc/network/interfaces file and restart the
2673- "networking" service that takes care of the eth0 movement.
2674- NTP service should also be restarted to rerun the NTP service with or
2675- without "cgexec" accordingly.
2676- """
2677- cmd = "service ntp stop"
2678- os .system (cmd )
2679- cmd = "systemctl restart interfaces-config"
2680- os .system (cmd )
2681- cmd = "service ntp start"
2682- os .system (cmd )
26832667
26842668def vrf_add_management_vrf (config_db ):
26852669 """Enable management vrf in config DB"""
@@ -2689,22 +2673,7 @@ def vrf_add_management_vrf(config_db):
26892673 click .echo ("ManagementVRF is already Enabled." )
26902674 return None
26912675 config_db .mod_entry ('MGMT_VRF_CONFIG' , "vrf_global" , {"mgmtVrfEnabled" : "true" })
2692- mvrf_restart_services ()
2693- """
2694- The regular expression for grep in below cmd is to match eth0 line in /proc/net/route, sample file:
2695- $ cat /proc/net/route
2696- Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT
2697- eth0 00000000 01803B0A 0003 0 0 202 00000000 0 0 0
2698- """
2699- cmd = r"cat /proc/net/route | grep -E \"eth0\s+00000000\s+[0-9A-Z]+\s+[0-9]+\s+[0-9]+\s+[0-9]+\s+202\" | wc -l"
2700- proc = subprocess .Popen (cmd , shell = True , stdout = subprocess .PIPE )
2701- output = proc .communicate ()
2702- if int (output [0 ]) >= 1 :
2703- cmd = "ip -4 route del default dev eth0 metric 202"
2704- proc = subprocess .Popen (cmd , shell = True , stdout = subprocess .PIPE )
2705- proc .communicate ()
2706- if proc .returncode != 0 :
2707- click .echo ("Could not delete eth0 route" )
2676+
27082677
27092678def vrf_delete_management_vrf (config_db ):
27102679 """Disable management vrf in config DB"""
@@ -2714,7 +2683,7 @@ def vrf_delete_management_vrf(config_db):
27142683 click .echo ("ManagementVRF is already Disabled." )
27152684 return None
27162685 config_db .mod_entry ('MGMT_VRF_CONFIG' , "vrf_global" , {"mgmtVrfEnabled" : "false" })
2717- mvrf_restart_services ()
2686+
27182687
27192688@config .group (cls = clicommon .AbbreviationGroup )
27202689@click .pass_context
@@ -3920,20 +3889,6 @@ def _get_all_mgmtinterface_keys():
39203889 config_db .connect ()
39213890 return list (config_db .get_table ('MGMT_INTERFACE' ).keys ())
39223891
3923- def mgmt_ip_restart_services ():
3924- """Restart the required services when mgmt inteface IP address is changed"""
3925- """
3926- Whenever the eth0 IP address is changed, restart the "interfaces-config"
3927- service which regenerates the /etc/network/interfaces file and restarts
3928- the networking service to make the new/null IP address effective for eth0.
3929- "ntp-config" service should also be restarted based on the new
3930- eth0 IP address since the ntp.conf (generated from ntp.conf.j2) is
3931- made to listen on that particular eth0 IP address or reset it back.
3932- """
3933- cmd = "systemctl restart interfaces-config"
3934- os .system (cmd )
3935- cmd = "systemctl restart ntp-config"
3936- os .system (cmd )
39373892
39383893#
39393894# 'mtu' subcommand
@@ -4081,7 +4036,6 @@ def add(ctx, interface_name, ip_addr, gw):
40814036 config_db .set_entry ("MGMT_INTERFACE" , (interface_name , str (ip_address )), {"NULL" : "NULL" })
40824037 else :
40834038 config_db .set_entry ("MGMT_INTERFACE" , (interface_name , str (ip_address )), {"gwaddr" : gw })
4084- mgmt_ip_restart_services ()
40854039
40864040 return
40874041
@@ -4121,7 +4075,6 @@ def remove(ctx, interface_name, ip_addr):
41214075
41224076 if interface_name == 'eth0' :
41234077 config_db .set_entry ("MGMT_INTERFACE" , (interface_name , str (ip_address )), None )
4124- mgmt_ip_restart_services ()
41254078 return
41264079
41274080 table_name = get_interface_table_name (interface_name )
0 commit comments