From c20110d15be37948ddd9ef5f38001328aabf5b1d Mon Sep 17 00:00:00 2001 From: Devananda van der Veen Date: Tue, 19 Feb 2013 12:39:55 -0800 Subject: Add better status to baremetal deployments. This patch introduces a few new baremetal states, which are used to track the deploy process. Now, nova-baremetal-deploy-helper updates the bm_nodes record directly when it begins and finishes deploying an image to that node. The next patch will add a LoopingCall inside driver.spawn() to wait for the deploy to complete. Also, since there can not be >1 active deployment per node, there is no need to have a separate table for storing them. This patch drops the table bm_deployments and adds the important information it contained to bm_nodes. Since the previous behavior was to mark a deployment as deleted once it completed, there is no need to copy any data from bm_deployments prior to dropping the table -- assuming that no active deployments are in process when the migration is run. Since this is the first migration for the baremetal database, it also adds a new test class, TestBaremetalMigrations, and refactors the test_migrations.py file to allow for multiple test classes. partially implements fix for bug 1096723 Change-Id: Iad30b462d49c88fc19babed43a2fb8540b1fad30 --- bin/nova-baremetal-deploy-helper | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'bin') diff --git a/bin/nova-baremetal-deploy-helper b/bin/nova-baremetal-deploy-helper index 894a42003..0d2d21984 100755 --- a/bin/nova-baremetal-deploy-helper +++ b/bin/nova-baremetal-deploy-helper @@ -47,6 +47,7 @@ from nova import config from nova import context as nova_context from nova.openstack.common import log as logging from nova import utils +from nova.virt.baremetal import baremetal_states from nova.virt.baremetal import db @@ -234,22 +235,27 @@ class Worker(threading.Thread): while not self.stop: try: # Set timeout to check self.stop periodically - (deployment_id, params) = QUEUE.get(block=True, + (node_id, params) = QUEUE.get(block=True, timeout=self.queue_timeout) except Queue.Empty: pass else: # Requests comes here from BareMetalDeploy.post() - LOG.info("start deployment: %s, %s", deployment_id, params) + LOG.info(_('start deployment for node %(node_id)s, ' + 'params %(params)s') % locals()) + context = nova_context.get_admin_context() try: + db.bm_node_update(context, node_id, + {'task_state': baremetal_states.DEPLOYING}) deploy(**params) except Exception: - LOG.exception('deployment %s failed' % deployment_id) + LOG.error(_('deployment to node %s failed') % node_id) + db.bm_node_update(context, node_id, + {'task_state': baremetal_states.DEPLOYFAIL}) else: - LOG.info("deployment %s done", deployment_id) - finally: - context = nova_context.get_admin_context() - db.bm_deployment_destroy(context, deployment_id) + LOG.info(_('deployment to node %s done') % node_id) + db.bm_node_update(context, node_id, + {'task_state': baremetal_states.DEPLOYDONE}) class BareMetalDeploy(object): @@ -276,8 +282,8 @@ class BareMetalDeploy(object): x = inpt.read(length) q = dict(cgi.parse_qsl(x)) try: - deployment_id = q['i'] - deployment_key = q['k'] + node_id = q['i'] + deploy_key = q['k'] address = q['a'] port = q.get('p', '3260') iqn = q['n'] @@ -287,9 +293,9 @@ class BareMetalDeploy(object): return "parameter '%s' is not defined" % e context = nova_context.get_admin_context() - d = db.bm_deployment_get(context, deployment_id) + d = db.bm_node_get(context, node_id) - if d['key'] != deployment_key: + if d['deploy_key'] != deploy_key: start_response('400 Bad Request', [('Content-type', 'text/plain')]) return 'key is not match' @@ -306,8 +312,8 @@ class BareMetalDeploy(object): if not self.worker.isAlive(): self.worker = Worker() self.worker.start() - LOG.info("request is queued: %s, %s", deployment_id, params) - QUEUE.put((deployment_id, params)) + LOG.info("request is queued: node %s, params %s", node_id, params) + QUEUE.put((node_id, params)) # Requests go to Worker.run() start_response('200 OK', [('Content-type', 'text/plain')]) return '' -- cgit