summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Baker <sbaker@redhat.com>2020-09-09 13:38:26 +1200
committerSteve Baker <sbaker@redhat.com>2020-11-16 10:49:56 +1300
commitca53858db05c462e44aaeac9553255a76db5a315 (patch)
treea69a1268c6f308cd9198509cf28d1a4674687530
parent989064a742852928bcdb6012f4958ea0758bb9d2 (diff)
downloadironic-ca53858db05c462e44aaeac9553255a76db5a315.tar.gz
Convert ramdisk endpoint to plain JSON
Change-Id: Ib7f1875051eed0fc5882cf675eead56694db76d7 Story: 1651346 Task: 10551
-rw-r--r--ironic/api/controllers/v1/ramdisk.py34
1 files changed, 13 insertions, 21 deletions
diff --git a/ironic/api/controllers/v1/ramdisk.py b/ironic/api/controllers/v1/ramdisk.py
index 6cf234b70..705389534 100644
--- a/ironic/api/controllers/v1/ramdisk.py
+++ b/ironic/api/controllers/v1/ramdisk.py
@@ -19,11 +19,10 @@ from oslo_log import log
from pecan import rest
from ironic import api
-from ironic.api.controllers import base
from ironic.api.controllers.v1 import node as node_ctl
-from ironic.api.controllers.v1 import types
from ironic.api.controllers.v1 import utils as api_utils
-from ironic.api import expose
+from ironic.api import method
+from ironic.common import args
from ironic.common import exception
from ironic.common.i18n import _
from ironic.common import policy
@@ -61,20 +60,10 @@ def config(token):
}
-class LookupResult(base.APIBase):
- """API representation of the node lookup result."""
-
- node = None
- """The short node representation."""
-
- config = {str: types.jsontype}
- """The configuration to pass to the ramdisk."""
-
- @classmethod
- def convert_with_links(cls, node):
- token = node.driver_internal_info.get('agent_secret_token')
- node = node_ctl.node_convert_with_links(node, _LOOKUP_RETURN_FIELDS)
- return cls(node=node, config=config(token))
+def convert_with_links(node):
+ token = node.driver_internal_info.get('agent_secret_token')
+ node = node_ctl.node_convert_with_links(node, _LOOKUP_RETURN_FIELDS)
+ return {'node': node, 'config': config(token)}
class LookupController(rest.RestController):
@@ -86,7 +75,8 @@ class LookupController(rest.RestController):
return states.FASTTRACK_LOOKUP_ALLOWED_STATES
return states.LOOKUP_ALLOWED_STATES
- @expose.expose(LookupResult, types.listtype, types.uuid)
+ @method.expose()
+ @args.validate(addresses=args.string_list, node_uuid=args.uuid)
def get_all(self, addresses=None, node_uuid=None):
"""Look up a node by its MAC addresses and optionally UUID.
@@ -161,14 +151,16 @@ class LookupController(rest.RestController):
api.request.context, node.uuid, topic=topic)
else:
found_node = node
- return LookupResult.convert_with_links(found_node)
+ return convert_with_links(found_node)
class HeartbeatController(rest.RestController):
"""Controller handling heartbeats from deploy ramdisk."""
- @expose.expose(None, types.uuid_or_name, str,
- str, str, str, status_code=http_client.ACCEPTED)
+ @method.expose(status_code=http_client.ACCEPTED)
+ @args.validate(node_ident=args.uuid_or_name, callback_url=args.string,
+ agent_version=args.string, agent_token=args.string,
+ agent_verify_ca=args.string)
def post(self, node_ident, callback_url, agent_version=None,
agent_token=None, agent_verify_ca=None):
"""Process a heartbeat from the deploy ramdisk.