Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
error="%s. %s: %s" % (message, type(exc).__name__, exc)
)
else:
# NOTE(dtantsur): metalsmith can match instances by node names,
# provide a safeguard to avoid conflicts.
if (instance.hostname and
instance.hostname != request['hostname']):
error = ("Requested hostname %s was not found, but the "
"deployed node %s has a matching name. Refusing "
"to proceed to avoid confusing results. Please "
"either rename the node or use a different "
"hostname") % (request['hostname'], instance.uuid)
return actions.Result(error=error)
if (not instance.allocation
and instance.state == metalsmith.InstanceState.ACTIVE
and 'name' in request):
# Existing node is missing an allocation record,
# so create one without triggering allocation
LOG.debug('Reserving existing %s' % request['name'])
self.get_baremetal_client(context).allocation.create(
resource_class=request.get('resource_class') or
self.default_resource_class,
name=request['hostname'],
node=request['name']
)
found.append(_instance_to_dict(provisioner.connection,
instance))
if found:
LOG.info('Found existing instances: %s',
', '.join(r['hostname'] for r in found))