Secondary migration from google3 into AOSP.
The 2nd revival of AOSP acloud is upon us!
The cl revision the acloud g3 code was pulled from is 195930083.
Things I did:
- Added AOSP copyright for new files and updated g3 imports to be relative.
- Merged in changes into existing files (easier to see changes here and
for future cls).
- Scrubbed default.config of project and build info.
- Merge acloud.py (from g3) into acloud_main.py (entry point for AOSP
acloud).
- Regenerated internal_config_pb2.py and user_config_pb2.py.
- Removed add_mock from gcomputer_client_test and added TODO in file
where to replace it and updated parameterized to import from
absl.testing.
- Updated references to gce_x86 to aosp_cf_x86_phone and updated branch
references to 'aosp-master'.
Thing to note:
- New files fail pylint (in order to make it easy to check history on new files,
formatting will be done using yapf in another cl).
- pip install acloud.zip seg faults so investigation and fix for that
will happen in another cl.
- User needs to 'pip install absl-py' for parameterized lib in unittests.
Bug: 79684654
Test: ./run_tests.sh
Change-Id: I060641227d7c9162a45557e732686f22b83895e9
diff --git a/internal/lib/android_build_client.py b/internal/lib/android_build_client.py
index b459f62..4f7ee57 100644
--- a/internal/lib/android_build_client.py
+++ b/internal/lib/android_build_client.py
@@ -38,7 +38,7 @@
# other variables.
DEFAULT_RESOURCE_ID = "0"
- # TODO(fdeng): We should use "latest".
+ # TODO(b/27269552): We should use "latest".
DEFAULT_ATTEMPT_ID = "0"
DEFAULT_CHUNK_SIZE = 20 * 1024 * 1024
NO_ACCESS_ERROR_PATTERN = "does not have storage.objects.create access"
@@ -57,7 +57,7 @@
"""Get Android build attempt information.
Args:
- build_target: Target name, e.g. "gce_x86-userdebug"
+ build_target: Target name, e.g. "aosp_cf_x86_phone-userdebug"
build_id: Build id, a string, e.g. "2263051", "P2804227"
resource_id: Id of the resource, e.g "avd-system.tar.gz".
local_dest: A local path where the artifact should be stored.
@@ -95,7 +95,7 @@
"""Copy an Android Build artifact to a storage bucket.
Args:
- build_target: Target name, e.g. "gce_x86-userdebug"
+ build_target: Target name, e.g. "aosp_cf_x86_phone-userdebug"
build_id: Build id, a string, e.g. "2263051", "P2804227"
artifact_name: Name of the artifact, e.g "avd-system.tar.gz".
destination_bucket: String, a google storage bucket name.
@@ -126,3 +126,17 @@
error_msg %= (destination_bucket, str(e))
raise errors.HttpError(e.code, message=error_msg)
raise
+
+ def GetBranch(self, build_target, build_id):
+ """Derives branch name.
+
+ Args:
+ build_target: Target name, e.g. "aosp_cf_x86_phone-userdebug"
+ build_id: Build ID, a string, e.g. "2263051", "P2804227"
+
+ Returns:
+ A string, the name of the branch
+ """
+ api = self.service.build().get(buildId=build_id, target=build_target)
+ build = self.Execute(api)
+ return build.get("branch", "")