summaryrefslogtreecommitdiff
path: root/packages/python-google-compute-engine/google_compute_engine/distro_lib/debian_9
diff options
context:
space:
mode:
Diffstat (limited to 'packages/python-google-compute-engine/google_compute_engine/distro_lib/debian_9')
-rw-r--r--packages/python-google-compute-engine/google_compute_engine/distro_lib/debian_9/tests/utils_test.py22
-rw-r--r--packages/python-google-compute-engine/google_compute_engine/distro_lib/debian_9/utils.py10
2 files changed, 29 insertions, 3 deletions
diff --git a/packages/python-google-compute-engine/google_compute_engine/distro_lib/debian_9/tests/utils_test.py b/packages/python-google-compute-engine/google_compute_engine/distro_lib/debian_9/tests/utils_test.py
index fbb9a8e..4840753 100644
--- a/packages/python-google-compute-engine/google_compute_engine/distro_lib/debian_9/tests/utils_test.py
+++ b/packages/python-google-compute-engine/google_compute_engine/distro_lib/debian_9/tests/utils_test.py
@@ -27,12 +27,28 @@ class UtilsTest(unittest.TestCase):
self.mock_setup = mock.create_autospec(utils.Utils)
@mock.patch('google_compute_engine.distro_lib.helpers.CallDhclientIpv6')
- def testEnableIpv6(self, mock_call):
+ @mock.patch('google_compute_engine.distro_lib.helpers.CallEnableRouteAdvertisements')
+ def testEnableIpv6(self, mock_call_enable_ra, mock_call_dhclient):
mocks = mock.Mock()
- mocks.attach_mock(mock_call, 'call')
+ mocks.attach_mock(mock_call_dhclient, 'dhclient')
+ mocks.attach_mock(mock_call_enable_ra, 'enable_ra')
utils.Utils.EnableIpv6(self.mock_setup, ['A', 'B'], self.mock_logger)
- expected_calls = [mock.call.call(['A', 'B'], mock.ANY)]
+ expected_calls = [
+ mock.call.enable_ra(['A', 'B'], mock.ANY),
+ mock.call.dhclient(['A', 'B'], mock.ANY),
+ ]
+ self.assertEqual(mocks.mock_calls, expected_calls)
+
+ @mock.patch('google_compute_engine.distro_lib.helpers.CallDhclientIpv6')
+ def testDisableIpv6(self, mock_call_dhclient):
+ mocks = mock.Mock()
+ mocks.attach_mock(mock_call_dhclient, 'dhclient')
+
+ utils.Utils.DisableIpv6(self.mock_setup, ['A', 'B'], self.mock_logger)
+ expected_calls = [
+ mock.call.dhclient(['A', 'B'], mock.ANY, None, release_lease=True),
+ ]
self.assertEqual(mocks.mock_calls, expected_calls)
@mock.patch('google_compute_engine.distro_lib.helpers.CallDhclient')
diff --git a/packages/python-google-compute-engine/google_compute_engine/distro_lib/debian_9/utils.py b/packages/python-google-compute-engine/google_compute_engine/distro_lib/debian_9/utils.py
index 11a5cbd..9255214 100644
--- a/packages/python-google-compute-engine/google_compute_engine/distro_lib/debian_9/utils.py
+++ b/packages/python-google-compute-engine/google_compute_engine/distro_lib/debian_9/utils.py
@@ -31,8 +31,18 @@ class Utils(utils.Utils):
logger: logger object, used to write to SysLog and serial port.
dhclient_script: string, the path to a dhclient script used by dhclient.
"""
+ helpers.CallEnableRouteAdvertisements(interfaces, logger)
helpers.CallDhclientIpv6(interfaces, logger)
+ def DisableIpv6(self, interfaces, logger):
+ """Disable Ipv6 by giving up the DHCP lease using dhclient.
+
+ Args:
+ interface: string, the output device names for enabling IPv6.
+ logger: logger object, used to write to SysLog and serial port.
+ """
+ helpers.CallDhclientIpv6(interfaces, logger, None, release_lease=True)
+
def EnableNetworkInterfaces(self, interfaces, logger, dhclient_script=None):
"""Enable the list of network interfaces.