~ubuntu-branches/ubuntu/vivid/ironic/vivid-updates

« back to all changes in this revision

Viewing changes to ironic/drivers/modules/iscsi_deploy.py

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2015-01-05 12:21:37 UTC
  • mfrom: (1.2.4)
  • Revision ID: package-import@ubuntu.com-20150105122137-171bqrdpcxqipunk
Tags: 2015.1~b1-0ubuntu1
* New upstream beta release:
  - d/control: Align version requirements with upstream release.
* d/watch: Update uversionmangle to deal with kilo beta versioning
  changes.
* d/control: Bumped Standards-Version to 3.9.6, no changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
from ironic.common import keystone
27
27
from ironic.common import states
28
28
from ironic.common import utils
29
 
from ironic.conductor import utils as manager_utils
30
29
from ironic.drivers.modules import deploy_utils
31
30
from ironic.drivers.modules import image_cache
32
31
from ironic.drivers import utils as driver_utils
116
115
    i_info['image_source'] = info.get('image_source')
117
116
    i_info['root_gb'] = info.get('root_gb')
118
117
 
119
 
    error_msg = _("Cannot validate iSCSI deploy")
 
118
    error_msg = _("Cannot validate iSCSI deploy. Some parameters were missing"
 
119
                  " in node's instance_info")
120
120
    deploy_utils.check_for_missing_params(i_info, error_msg)
121
121
 
122
122
    # Internal use only
186
186
    LOG.debug("Fetching image %(ami)s for node %(uuid)s",
187
187
              {'ami': uuid, 'uuid': node.uuid})
188
188
 
189
 
    deploy_utils.fetch_images(ctx, InstanceImageCache(), [(uuid, image_path)])
 
189
    deploy_utils.fetch_images(ctx, InstanceImageCache(), [(uuid, image_path)],
 
190
                              CONF.force_raw_images)
190
191
 
191
192
    return (uuid, image_path)
192
193
 
202
203
 
203
204
 
204
205
def get_deploy_info(node, **kwargs):
205
 
    """Returns the information required for doing iSCSI deploy in a
206
 
    dictionary.
 
206
    """Returns the information required for doing iSCSI deploy in a dictionary.
207
207
 
208
208
    :param node: ironic node object
209
209
    :param kwargs: the keyword args passed from the conductor node.
242
242
    return params
243
243
 
244
244
 
245
 
def set_failed_state(task, msg):
246
 
    """Sets the deploy status as failed with relevant messages.
247
 
 
248
 
    This method sets the deployment as fail with the given message.
249
 
    It sets node's provision_state to DEPLOYFAIL and updates last_error
250
 
    with the given error message. It also powers off the baremetal node.
251
 
 
252
 
    :param task: a TaskManager instance containing the node to act on.
253
 
    :param msg: the message to set in last_error of the node.
254
 
    """
255
 
    node = task.node
256
 
    node.provision_state = states.DEPLOYFAIL
257
 
    node.target_provision_state = states.NOSTATE
258
 
    node.save()
259
 
    try:
260
 
        manager_utils.node_power_action(task, states.POWER_OFF)
261
 
    except Exception:
262
 
        msg2 = (_('Node %s failed to power off while handling deploy '
263
 
                 'failure. This may be a serious condition. Node '
264
 
                 'should be removed from Ironic or put in maintenance '
265
 
                 'mode until the problem is resolved.') % node.uuid)
266
 
        LOG.exception(msg2)
267
 
    finally:
268
 
        # NOTE(deva): node_power_action() erases node.last_error
269
 
        #             so we need to set it again here.
270
 
        node.last_error = msg
271
 
        node.save()
272
 
 
273
 
 
274
245
def continue_deploy(task, **kwargs):
275
246
    """Resume a deployment upon getting POST data from deploy ramdisk.
276
247
 
292
263
    if ramdisk_error:
293
264
        LOG.error(_LE('Error returned from deploy ramdisk: %s'),
294
265
                  ramdisk_error)
295
 
        set_failed_state(task, _('Failure in deploy ramdisk.'))
 
266
        deploy_utils.set_failed_state(task, _('Failure in deploy ramdisk.'))
296
267
        destroy_images(node.uuid)
297
268
        return
298
269
 
306
277
        LOG.error(_LE('Deploy failed for instance %(instance)s. '
307
278
                      'Error: %(error)s'),
308
279
                  {'instance': node.instance_uuid, 'error': e})
309
 
        set_failed_state(task, _('Failed to continue iSCSI deployment.'))
 
280
        deploy_utils.set_failed_state(task, _('Failed to continue '
 
281
                                              'iSCSI deployment.'))
310
282
 
311
283
    destroy_images(node.uuid)
312
284
    return root_uuid
391
363
    file or from keystone.
392
364
 
393
365
    :param task: a TaskManager instance containing the node to act on.
394
 
    :raises: InvalidParameterValue if no ports are enrolled for the given node.
 
366
    :raises: InvalidParameterValue if the URL of the Ironic API service is not
 
367
             configured in config file and is not accessible via Keystone
 
368
             catalog.
 
369
    :raises: MissingParameterValue if no ports are enrolled for the given node.
395
370
    """
396
371
    node = task.node
397
372
    if not driver_utils.get_node_mac_addresses(task):
398
 
        raise exception.InvalidParameterValue(_("Node %s does not have "
 
373
        raise exception.MissingParameterValue(_("Node %s does not have "
399
374
                            "any port associated with it.") % node.uuid)
400
375
 
401
376
    try:
402
377
        # TODO(lucasagomes): Validate the format of the URL
403
378
        CONF.conductor.api_url or keystone.get_service_url()
404
 
    except (exception.CatalogFailure,
 
379
    except (exception.KeystoneFailure,
405
380
            exception.CatalogNotFound,
406
 
            exception.CatalogUnauthorized):
 
381
            exception.KeystoneUnauthorized) as e:
407
382
        raise exception.InvalidParameterValue(_(
408
383
            "Couldn't get the URL of the Ironic API service from the "
409
 
            "configuration file or keystone catalog."))
 
384
            "configuration file or keystone catalog. Keystone error: %s") % e)