Remove unused way to lease device from engprod client.
Bug: 222602807
Test: acloud-dev create
Change-Id: Id4147beec04d153201ee3ca6925e95ea4247ad75
diff --git a/create/remote_image_remote_instance.py b/create/remote_image_remote_instance.py
index de01f7e..18822a4 100644
--- a/create/remote_image_remote_instance.py
+++ b/create/remote_image_remote_instance.py
@@ -36,7 +36,6 @@
logger = logging.getLogger(__name__)
_DEVICE = "device"
_DEVICES = "devices"
-_DEVICE_KEY_MAPPING = {"serverUrl": "ip", "sessionId": "instance_name"}
_LAUNCH_CVD_TIME = "launch_cvd_time"
_RE_SESSION_ID = re.compile(r".*session_id:\"(?P<session_id>[^\"]+)")
_RE_SERVER_URL = re.compile(r".*server_url:\"(?P<server_url>[^\"]+)")
@@ -153,21 +152,3 @@
server_url = server_url_match.group("server_url")
break
return session_id, server_url
-
- @staticmethod
- def _ReplaceDeviceDataKeys(device_data):
- """Replace keys of device data from oxygen response.
-
- To keep the device data using the same keys in Acloud report. Before
- writing data to report, it needs to update the keys.
-
- Values:
- device_data: Dict of device data. e.g. {'sessionId': 'b01ead68',
- 'serverUrl': '10.1.1.1'}
- """
- for key, val in _DEVICE_KEY_MAPPING.items():
- if key in device_data:
- device_data[val] = device_data[key]
- del device_data[key]
- else:
- logger.debug("There is no '%s' data in response.", key)
diff --git a/create/remote_image_remote_instance_test.py b/create/remote_image_remote_instance_test.py
index 33bba17..86db42d 100644
--- a/create/remote_image_remote_instance_test.py
+++ b/create/remote_image_remote_instance_test.py
@@ -132,13 +132,6 @@
MULTIPLE_LINES_LEASE_RESPONSE),
(expect_session_id, expect_server_url))
- def testReplaceDeviceDataKeys(self):
- """test ReplaceDeviceDataKeys."""
- device_data = {"sessionId": "fake_device", "serverUrl": "10.1.1.1"}
- expected_result = {"instance_name": "fake_device", "ip": "10.1.1.1"}
- self.remote_image_remote_instance._ReplaceDeviceDataKeys(device_data)
- self.assertEqual(device_data, expected_result)
-
if __name__ == '__main__':
unittest.main()
diff --git a/internal/lib/engprod_client.py b/internal/lib/engprod_client.py
deleted file mode 100644
index 5f9ffe1..0000000
--- a/internal/lib/engprod_client.py
+++ /dev/null
@@ -1,47 +0,0 @@
-# Copyright 2021 - The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""A client that talks to EngProd APIs."""
-
-import json
-import subprocess
-
-from urllib.parse import urljoin
-
-
-class EngProdClient():
- """Client that manages EngProd api."""
-
- @staticmethod
- def LeaseDevice(build_target, build_id, api_key, api_url):
- """Lease one cuttlefish device.
-
- Args:
- build_target: Target name, e.g. "aosp_cf_x86_64_phone-userdebug"
- build_id: Build ID, a string, e.g. "2263051", "P2804227"
- api_key: String of api key.
- api_url: String of api url.
-
- Returns:
- The response of curl command.
- """
- request_data = "{\"target\": \"%s\", \"build_id\": \"%s\"}" % (
- build_target, build_id)
- lease_url = urljoin(api_url, "lease?key=%s" % api_key)
- response = subprocess.check_output([
- "curl", "--request", "POST", lease_url, "-H",
- "Accept: application/json", "-H", "Content-Type: application/json",
- "-d", request_data
- ])
- return json.loads(response)
diff --git a/public/config.py b/public/config.py
index a8b6dc8..0e60fc0 100755
--- a/public/config.py
+++ b/public/config.py
@@ -236,8 +236,6 @@
self.hw_property = usr_cfg.hw_property
self.launch_args = usr_cfg.launch_args
- self.api_key = usr_cfg.api_key
- self.api_url = usr_cfg.api_url
self.oxygen_client = usr_cfg.oxygen_client
self.oxygen_lease_args = usr_cfg.oxygen_lease_args
self.instance_name_pattern = (