summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Illfelder <illfelder@google.com>2016-12-12 16:08:29 -0800
committerMax Illfelder <illfelder@google.com>2016-12-12 16:08:29 -0800
commitc4793eaac79a1c83c2911e9abb3466e82542a0f8 (patch)
tree8b4cc8d0792154e9d70588138b1939d055e3f584
parent20ea00ef6f343d7e2d0eda5664d3d13459bd4111 (diff)
parent36cb06ecba72fdd9f8e7105a09531ee38dd7cee1 (diff)
downloadgoogle-compute-image-packages-c4793eaac79a1c83c2911e9abb3466e82542a0f8.tar.gz
Merge branch 'development'20161212
-rw-r--r--google_compute_engine/ip_forwarding/ip_forwarding_utils.py2
-rw-r--r--google_compute_engine/ip_forwarding/tests/ip_forwarding_utils_test.py12
-rwxr-xr-xsetup.py2
-rw-r--r--tox.ini31
4 files changed, 42 insertions, 5 deletions
diff --git a/google_compute_engine/ip_forwarding/ip_forwarding_utils.py b/google_compute_engine/ip_forwarding/ip_forwarding_utils.py
index 201d326..c131144 100644
--- a/google_compute_engine/ip_forwarding/ip_forwarding_utils.py
+++ b/google_compute_engine/ip_forwarding/ip_forwarding_utils.py
@@ -94,7 +94,7 @@ class IpForwardingUtils(object):
forwarded_ips = forwarded_ips or []
for ip in forwarded_ips:
if ip and (IP_REGEX.match(ip) or IP_ALIAS_REGEX.match(ip)):
- addresses.append(ip)
+ addresses.append(ip[:-3] if ip.endswith('/32') else ip)
else:
self.logger.warning('Could not parse IP address: "%s".', ip)
return addresses
diff --git a/google_compute_engine/ip_forwarding/tests/ip_forwarding_utils_test.py b/google_compute_engine/ip_forwarding/tests/ip_forwarding_utils_test.py
index 5543d13..8d7cf70 100644
--- a/google_compute_engine/ip_forwarding/tests/ip_forwarding_utils_test.py
+++ b/google_compute_engine/ip_forwarding/tests/ip_forwarding_utils_test.py
@@ -16,7 +16,6 @@
"""Unittest for ip_forwarding_utils.py module."""
from google_compute_engine.ip_forwarding import ip_forwarding_utils
-from google_compute_engine.test_compat import builtin
from google_compute_engine.test_compat import mock
from google_compute_engine.test_compat import unittest
@@ -152,6 +151,17 @@ class IpForwardingUtilsTest(unittest.TestCase):
expected_calls = [mock.call.warning(mock.ANY, ip) for ip in invalid_ips]
self.assertEqual(self.mock_logger.mock_calls, expected_calls)
+ def testParseForwardedIpsSubnet(self):
+ forwarded_ips = {
+ '1.1.1.1': '1.1.1.1',
+ '1.1.1.1/32': '1.1.1.1',
+ '1.1.1.1/1': '1.1.1.1/1',
+ '1.1.1.1/10': '1.1.1.1/10',
+ '1.1.1.1/24': '1.1.1.1/24',
+ }
+ for ip, value in forwarded_ips.items():
+ self.assertEqual(self.mock_utils.ParseForwardedIps([ip]), [value])
+
def testGetForwardedIps(self):
mock_options = mock.Mock()
mock_options.return_value = self.options
diff --git a/setup.py b/setup.py
index 568e9b4..405682a 100755
--- a/setup.py
+++ b/setup.py
@@ -32,7 +32,7 @@ setuptools.setup(
packages=setuptools.find_packages(),
scripts=glob.glob('scripts/*'),
url='https://github.com/GoogleCloudPlatform/compute-image-packages',
- version='2.3.1',
+ version='2.3.2',
# Entry points create scripts in /usr/bin that call a function.
entry_points={
'console_scripts': [
diff --git a/tox.ini b/tox.ini
index d3d4b7a..d3c13f0 100644
--- a/tox.ini
+++ b/tox.ini
@@ -28,10 +28,37 @@ commands =
-v \
{posargs:.}
-# Note: currently disabled.
[testenv:lint]
deps =
flake8
flake8-import-order
commands =
- flake8 --exclude=env --import-order-style=google
+ flake8 --import-order-style=google
+
+[flake8]
+# Temporarly disabling warnings until code is flake8 compliant.
+# E111 indentation is not a multiple of four
+# E114 indentation is not a multiple of four (comment)
+# E121 continuation line under-indented for hanging indent
+# E125 continuation line with same indent as next logical line
+# E128 continuation line under-indented for visual indent
+# E129 visually indented line with same indent as next logical line
+# E226 missing whitespace around arithmetic operator
+# E231 missing whitespace after ','
+# E261 at least two spaces before inline comment
+# E302 expected 2 blank lines, found 1
+# E501 line too long
+# F401 imported but unused
+ignore = E111,E114,E121,E125,E128,E129,E226,E231,E261,E302,E501,F401
+exclude =
+ .git,
+ .tox,
+ __pycache__,
+ dist,
+ env
+
+# This section configures tox-travis.
+# See https://github.com/ryanhiebert/tox-travis#advanced-configuration
+[travis]
+python =
+ 2.7: py27, lint