From 33c62a1e368ed358514b015b3778415580b895a2 Mon Sep 17 00:00:00 2001 From: Jim Rollenhagen Date: Thu, 6 Oct 2016 06:59:08 -0400 Subject: [PATCH] Fix _lookup() method for node API routing While not currently broken, calling /v1/nodes emits an error: RuntimeWarning: Got exception calling lookup(): _lookup() takes at least 3 arguments (2 given) (('_lookup() takes at least 3 arguments (2 given)',)) Pecan will continue routing normally in this case, but it looks cscary in logs. Fix _lookup() to not require so many arguments that it blows up in this case. Change-Id: I2b634d41aeb438a6f6ccbde33aeaa41678a6b67a --- ironic/api/controllers/v1/node.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ironic/api/controllers/v1/node.py b/ironic/api/controllers/v1/node.py index 670a48f528..a8bb7d8127 100644 --- a/ironic/api/controllers/v1/node.py +++ b/ironic/api/controllers/v1/node.py @@ -1063,14 +1063,15 @@ class NodesController(rest.RestController): } @pecan.expose() - def _lookup(self, ident, subres, *remainder): + def _lookup(self, ident, *remainder): try: ident = types.uuid_or_name.validate(ident) except exception.InvalidUuidOrName as e: pecan.abort(http_client.BAD_REQUEST, e.args[0]) - subcontroller = self._subcontroller_map.get(subres) - if subcontroller: - return subcontroller(node_ident=ident), remainder + if remainder: + subcontroller = self._subcontroller_map.get(remainder[0]) + if subcontroller: + return subcontroller(node_ident=ident), remainder[1:] def _get_nodes_collection(self, chassis_uuid, instance_uuid, associated, maintenance, provision_state, marker, limit,