summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Illfelder <illfelder@users.noreply.github.com>2018-07-25 13:51:28 -0700
committerGitHub <noreply@github.com>2018-07-25 13:51:28 -0700
commita6c5af80f3144db1557a9524b4489c09eff63ac8 (patch)
treee9d458da6978f23f9d4d9011b6bb79ecefc2c6cc
parent34f831a8b0343d0908f9f69ce39129b330e399df (diff)
downloadgoogle-compute-image-packages-a6c5af80f3144db1557a9524b4489c09eff63ac8.tar.gz
Prevent setup of the default ethernet interface. (#630)
The default ethernet interface is already enabled. We should not run dhclient on the interface.
-rw-r--r--google_compute_engine/networking/network_daemon.py2
-rwxr-xr-xgoogle_compute_engine/networking/network_setup/network_setup.py2
-rw-r--r--google_compute_engine/networking/network_setup/tests/network_setup_test.py16
-rw-r--r--google_compute_engine/networking/tests/network_daemon_test.py2
4 files changed, 8 insertions, 14 deletions
diff --git a/google_compute_engine/networking/network_daemon.py b/google_compute_engine/networking/network_daemon.py
index 6af38f7..95b190b 100644
--- a/google_compute_engine/networking/network_daemon.py
+++ b/google_compute_engine/networking/network_daemon.py
@@ -91,7 +91,7 @@ class NetworkDaemon(object):
if self.network_setup_enabled:
self.network_setup.EnableNetworkInterfaces(
- [interface.name for interface in network_interfaces])
+ [interface.name for interface in network_interfaces[1:]])
for interface in network_interfaces:
if self.ip_forwarding_enabled:
diff --git a/google_compute_engine/networking/network_setup/network_setup.py b/google_compute_engine/networking/network_setup/network_setup.py
index 1408809..9166722 100755
--- a/google_compute_engine/networking/network_setup/network_setup.py
+++ b/google_compute_engine/networking/network_setup/network_setup.py
@@ -56,8 +56,6 @@ class NetworkSetup(object):
self.logger.info('Ethernet interfaces: %s.', interfaces)
self.interfaces = set(interfaces)
- if len(interfaces) <= 1:
- return
if self.dhcp_command:
try:
diff --git a/google_compute_engine/networking/network_setup/tests/network_setup_test.py b/google_compute_engine/networking/network_setup/tests/network_setup_test.py
index a148b78..644510a 100644
--- a/google_compute_engine/networking/network_setup/tests/network_setup_test.py
+++ b/google_compute_engine/networking/network_setup/tests/network_setup_test.py
@@ -72,29 +72,25 @@ class NetworkSetupTest(unittest.TestCase):
network_setup.NetworkSetup.EnableNetworkInterfaces(
self.mock_setup, ['A', 'B', 'C'])
self.assertEqual(self.mock_setup.interfaces, set(['A', 'B', 'C']))
- # A single interface is enabled by default.
- network_setup.NetworkSetup.EnableNetworkInterfaces(self.mock_setup, ['D'])
- self.assertEqual(self.mock_setup.interfaces, set(['D']))
# Run a user supplied command successfully.
self.mock_setup.dhcp_command = 'success'
network_setup.NetworkSetup.EnableNetworkInterfaces(
- self.mock_setup, ['E', 'F'])
- self.assertEqual(self.mock_setup.interfaces, set(['E', 'F']))
+ self.mock_setup, ['D', 'E'])
+ self.assertEqual(self.mock_setup.interfaces, set(['D', 'E']))
# Run a user supplied command and logger error messages.
self.mock_setup.dhcp_command = 'failure'
network_setup.NetworkSetup.EnableNetworkInterfaces(
- self.mock_setup, ['G', 'H'])
- self.assertEqual(self.mock_setup.interfaces, set(['G', 'H']))
+ self.mock_setup, ['F', 'G'])
+ self.assertEqual(self.mock_setup.interfaces, set(['F', 'G']))
expected_calls = [
mock.call.logger.info(mock.ANY, ['A', 'B']),
mock.call.enable(['A', 'B'], mock.ANY, dhclient_script='/bin/script'),
mock.call.logger.info(mock.ANY, ['A', 'B', 'C']),
mock.call.enable(
['A', 'B', 'C'], mock.ANY, dhclient_script='/bin/script'),
- mock.call.logger.info(mock.ANY, ['D']),
- mock.call.logger.info(mock.ANY, ['E', 'F']),
+ mock.call.logger.info(mock.ANY, ['D', 'E']),
mock.call.call(['success']),
- mock.call.logger.info(mock.ANY, ['G', 'H']),
+ mock.call.logger.info(mock.ANY, ['F', 'G']),
mock.call.call(['failure']),
mock.call.logger.warning(mock.ANY),
]
diff --git a/google_compute_engine/networking/tests/network_daemon_test.py b/google_compute_engine/networking/tests/network_daemon_test.py
index c52f832..acf0371 100644
--- a/google_compute_engine/networking/tests/network_daemon_test.py
+++ b/google_compute_engine/networking/tests/network_daemon_test.py
@@ -148,7 +148,7 @@ class NetworkDaemonTest(unittest.TestCase):
self.mock_setup, result)
expected_calls = [
mock.call.setup._ExtractInterfaceMetadata(result),
- mock.call.network_setup.EnableNetworkInterfaces(['a', 'b']),
+ mock.call.network_setup.EnableNetworkInterfaces(['b']),
mock.call.forwarding.HandleForwardedIps('a', None, None),
mock.call.forwarding.HandleForwardedIps('b', None, None),
]