How to use metalsmith - 5 common examples

To help you get started, we’ve selected a few metalsmith examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openstack / tripleo-common / tripleo_common / actions / baremetal_deploy.py View on Github external
def _provisioner(context):
    session = keystone.get_session(context)
    return metalsmith.Provisioner(session=session)
github openstack / tripleo-common / tripleo_common / actions / baremetal_deploy.py View on Github external
def _get_source(instance):
    image = instance.get('image', {})
    return sources.detect(image=image.get('href'),
                          kernel=image.get('kernel'),
                          ramdisk=image.get('ramdisk'),
                          checksum=image.get('checksum'))
github openstack / tripleo-common / tripleo_common / actions / baremetal_deploy.py View on Github external
def __init__(self, instance, node, ssh_keys=None,
                 # For compatibility with deployment based on heat+nova
                 ssh_user_name='heat-admin',
                 default_network='ctlplane',
                 # 50 is the default for old flavors, subtracting 1G to account
                 # for partitioning and configdrive.
                 default_root_size=49):
        super(DeployNodeAction, self).__init__()
        self.instance = instance
        self.node = node
        self.config = instance_config.CloudInitConfig(ssh_keys=ssh_keys)
        self.config.add_user(ssh_user_name, admin=True, sudo=True)
        self.default_network = default_network
        self.default_root_size = default_root_size
github openstack / tripleo-common / tripleo_common / actions / baremetal_deploy.py View on Github external
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))
github openstack / tripleo-common / tripleo_common / actions / baremetal_deploy.py View on Github external
_validate_instances(self.instances)
        except Exception as exc:
            LOG.error('Failed to validate provided instances. %s', exc)
            return actions.Result(error=six.text_type(exc))

        provisioner = _provisioner(context)

        not_found = []
        found = []
        for request in self.instances:
            ident = request.get('name', request['hostname'])

            try:
                instance = provisioner.show_instance(ident)
            # TODO(dtantsur): replace Error with a specific exception
            except (sdk_exc.ResourceNotFound, metalsmith.exceptions.Error):
                not_found.append(request)
            except Exception as exc:
                message = ('Failed to request instance information for %s'
                           % ident)
                LOG.exception(message)
                return actions.Result(
                    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 "

metalsmith

Deployment and Scheduling tool for Bare Metal

Apache-2.0
Latest version published 5 months ago

Package Health Score

52 / 100
Full package analysis