devserver: Deprecate setnexupdate API
This API is not used anywhere, deprecate it.
Also deprecates forced_update_label attribute.
BUG=chromium:872441
TEST=devserver_integration_test.py
TEST=autoupdate_unittest.py
TEST=./devserver.py
Change-Id: I243a83e9a0f37884eb1092ee44b2da1cf2cedddb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/1828165
Commit-Queue: Amin Hassani <ahassani@chromium.org>
Tested-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: David Haddock <dhaddock@chromium.org>
diff --git a/autoupdate.py b/autoupdate.py
index f11820b..56cb859 100644
--- a/autoupdate.py
+++ b/autoupdate.py
@@ -182,8 +182,7 @@
Returns:
A named tuple containing attributes of the update requests as the
- following fields: 'forced_update_label', 'board',
- 'event_result' and 'event_type'.
+ following fields: 'board', 'event_result' and 'event_type'.
"""
# Initialize an empty dictionary for event attributes to log.
log_message = {}
@@ -226,12 +225,9 @@
UpdateRequestAttrs = collections.namedtuple(
'UpdateRequestAttrs',
- ('forced_update_label', 'client_version', 'board', 'event_result',
- 'event_type'))
+ ('client_version', 'board', 'event_result', 'event_type'))
- return UpdateRequestAttrs(
- curr_host_info.attrs.pop('forced_update_label', None),
- client_version, board, event_result, event_type)
+ return UpdateRequestAttrs(client_version, board, event_result, event_type)
def GetDevserverUrl(self):
"""Returns the devserver url base."""
@@ -371,12 +367,6 @@
nebraska_obj = nebraska.Nebraska()
return nebraska_obj.GetResponseToRequest(request, no_update=True)
- if request_attrs.forced_update_label:
- if label:
- _Log('Label: %s set but being overwritten to %s by request', label,
- request_attrs.forced_update_label)
- label = request_attrs.forced_update_label
-
_Log('Update Check Received.')
try:
@@ -414,9 +404,3 @@
# If no events were logged for this IP, return an empty log.
return json.dumps([])
-
- def HandleSetUpdatePing(self, ip, label):
- """Sets forced_update_label for a given host."""
- assert ip, 'No ip provided.'
- assert label, 'No label provided.'
- self.host_infos.GetInitHostInfo(ip).attrs['forced_update_label'] = label
diff --git a/autoupdate_unittest.py b/autoupdate_unittest.py
index 79e1fd0..1a2c73b 100755
--- a/autoupdate_unittest.py
+++ b/autoupdate_unittest.py
@@ -95,51 +95,6 @@
self.assertEqual(
json.loads(au_mock.HandleHostInfoPing(test_ip)), self.test_dict)
- def testHandleSetUpdatePing(self):
- au_mock = self._DummyAutoupdateConstructor()
- test_ip = '1.2.3.4'
- test_label = 'test/old-update'
- self.assertRaises(
- AssertionError, au_mock.HandleSetUpdatePing, test_ip, None)
- self.assertRaises(
- AssertionError, au_mock.HandleSetUpdatePing, None, test_label)
- self.assertRaises(
- AssertionError, au_mock.HandleSetUpdatePing, None, None)
-
- au_mock.HandleSetUpdatePing(test_ip, test_label)
- self.assertEqual(
- au_mock.host_infos.GetHostInfo(test_ip).attrs['forced_update_label'],
- test_label)
-
- def testHandleUpdatePingWithSetUpdate(self):
- """If update is set, it should use the update found in that directory."""
- au_mock = self._DummyAutoupdateConstructor()
- self.mox.StubOutWithMock(autoupdate.Autoupdate, 'GetPathToPayload')
- self.mox.StubOutWithMock(nebraska.Nebraska, 'GetResponseToRequest')
-
- test_label = 'new_update-test/the-new-update'
- new_image_dir = os.path.join(self.static_image_dir, test_label)
-
- # Generate a fake payload.
- common_util.MkDirP(new_image_dir)
- update_gz = os.path.join(new_image_dir, constants.UPDATE_FILE)
- with open(update_gz, 'w') as fh:
- fh.write('')
-
- nebraska.Nebraska.GetResponseToRequest(
- mox.IgnoreArg(), critical_update=False).AndReturn(self.payload)
- au_mock.GetPathToPayload(test_label, self.test_board)
-
- self.mox.ReplayAll()
- au_mock.HandleSetUpdatePing('127.0.0.1', test_label)
- self.assertEqual(
- au_mock.host_infos.GetHostInfo('127.0.0.1').
- attrs['forced_update_label'],
- test_label)
- self.assertEqual(au_mock.HandleUpdatePing(self.test_data), self.payload)
- self.assertFalse(
- 'forced_update_label' in
- au_mock.host_infos.GetHostInfo('127.0.0.1').attrs)
if __name__ == '__main__':
unittest.main()
diff --git a/devserver.py b/devserver.py
index 062e296..de1ec56 100755
--- a/devserver.py
+++ b/devserver.py
@@ -552,8 +552,6 @@
last_event_type (int): last update event type received
last_event_status (int): last update event status received
last_known_version (string): last known version reported in update ping
- forced_update_label (string): update label to force next update ping to
- use, set by setnextupdate
See the OmahaEvent class in update_engine/omaha_request_action.h for
event type and status code definitions. If the ip does not exist an empty
string is returned.
@@ -581,23 +579,6 @@
return updater.HandleHostLogPing(ip)
@cherrypy.expose
- def setnextupdate(self, ip):
- """Allows the response to the next update ping from a host to be set.
-
- Takes the IP of the host and an update label as normally provided to the
- /update command.
- """
- body_length = int(cherrypy.request.headers['Content-Length'])
- label = cherrypy.request.rfile.read(body_length)
-
- if label:
- label = label.strip()
- if label:
- return updater.HandleSetUpdatePing(ip, label)
- raise common_util.DevServerHTTPError(httplib.BAD_REQUEST,
- 'No label provided.')
-
- @cherrypy.expose
def fileinfo(self, *args):
"""Returns information about a given staged file.
diff --git a/devserver_integration_test.py b/devserver_integration_test.py
index 6209ab2..155bb20 100755
--- a/devserver_integration_test.py
+++ b/devserver_integration_test.py
@@ -65,7 +65,6 @@
# API rpcs and constants.
API_HOST_INFO = 'api/hostinfo'
-API_SET_NEXT_UPDATE = 'api/setnextupdate'
API_SET_UPDATE_REQUEST = 'new_update-test/the-new-update'
API_TEST_IP_ADDR = '127.0.0.1'
@@ -324,37 +323,12 @@
def testHandleUpdateV3(self):
self.VerifyHandleUpdate(label=LABEL)
- def testApiBadSetNextUpdateRequest(self):
- """Tests sending a bad setnextupdate request."""
- # Send bad request and ensure it fails...
- self.assertRaises(urllib2.URLError,
- self._MakeRPC,
- '/'.join([API_SET_NEXT_UPDATE, API_TEST_IP_ADDR]))
-
- def testApiBadSetNextUpdateURL(self):
- """Tests contacting a bad setnextupdate url."""
- # Send bad request and ensure it fails...
- self.assertRaises(urllib2.URLError,
- self._MakeRPC, API_SET_NEXT_UPDATE)
-
def testApiBadHostInfoURL(self):
"""Tests contacting a bad hostinfo url."""
# Host info should be invalid without a specified address.
self.assertRaises(urllib2.URLError,
self._MakeRPC, API_HOST_INFO)
- def testApiHostInfoAndSetNextUpdate(self):
- """Tests using the setnextupdate and hostinfo api commands."""
- # Send setnextupdate command.
- self._MakeRPC('/'.join([API_SET_NEXT_UPDATE, API_TEST_IP_ADDR]),
- data=API_SET_UPDATE_REQUEST)
-
- # Send hostinfo command and verify the setnextupdate worked.
- response = self._MakeRPC('/'.join([API_HOST_INFO, API_TEST_IP_ADDR]))
-
- self.assertEqual(
- json.loads(response)['forced_update_label'], API_SET_UPDATE_REQUEST)
-
def testXBuddyLocalAlias(self):
"""Extensive local image xbuddy unittest.