Add in option to report internal IP (--report_internal_ip).
--report_internal_ip will report the internal IP instead of the external
IP. This is needed when someone is connecting to the AVD GCE instance from
another GCE instance.
Note: I ignored pylint duplicate code errors since common_operations,
create_cuttlefish_action, and create_goldfish_action are so similar. The
create work will refactor out the common code into 1 place so it's safe
to ignore for now.
Bug: 113535553
Test: ./run_tests.sh and acloud create
m acloud_test && acloud_test
Change-Id: I6ac840048eb0854f7dcdc223b846826e266b0ad5
diff --git a/public/actions/common_operations.py b/public/actions/common_operations.py
index 5a6d1d2..de72232 100644
--- a/public/actions/common_operations.py
+++ b/public/actions/common_operations.py
@@ -124,7 +124,7 @@
return self._devices
-def CreateDevices(command, cfg, device_factory, num):
+def CreateDevices(command, cfg, device_factory, num, report_internal_ip=False):
"""Create a set of devices using the given factory.
Args:
@@ -132,6 +132,8 @@
cfg: An AcloudConfig instance.
device_factory: A factory capable of producing a single device.
num: The number of devices to create.
+ report_internal_ip: Boolean to report the internal ip instead of
+ external ip.
Returns:
A Report instance.
@@ -145,7 +147,8 @@
# Write result to report.
for device in device_pool.devices:
device_dict = {
- "ip": device.ip,
+ "ip": (device.ip.internal if report_internal_ip
+ else device.ip.external),
"instance_name": device.instance_name
}
if device.instance_name in failures: