Exemplo n.º 1
0
    def set_node_vlan_id(self, task, **kwargs):
        """Sets an untagged vlan id for NIC 0 of node.

        @kwargs vlan_id: id of untagged vlan for NIC 0 of node
        """
        node = task.node
        vlan_id = kwargs.get('vlan_id')
        if not vlan_id:
            raise exception.MissingParameterValue(_("No vlan id provided"))

        seamicro_info = _parse_driver_info(node)
        try:
            server = _get_server(seamicro_info)

            # remove current vlan for server
            if len(server.nic['0']['untaggedVlan']) > 0:
                server.unset_untagged_vlan(server.nic['0']['untaggedVlan'])
            server = server.refresh(5)
            server.set_untagged_vlan(vlan_id)
        except seamicro_client_exception.ClientException as ex:
            LOG.error(_LE("SeaMicro client exception: %s"), ex.message)
            raise exception.VendorPassthruException(message=ex.message)

        properties = node.properties
        properties['seamicro_vlan_id'] = vlan_id
        node.properties = properties
        node.save()
Exemplo n.º 2
0
    def _attach_volume(self, task, **kwargs):
        """Attach volume from SeaMicro storage pools for ironic to node.
            If kwargs['volume_id'] not given, Create volume in SeaMicro
            storage pool and attach to node.

        @kwargs volume_id: id of pre-provisioned volume that is to be attached
                           as root volume of node
        @kwargs volume_size: size of new volume to be created and attached
                             as root volume of node
        """
        node = task.node
        seamicro_info = _parse_driver_info(node)
        volume_id = kwargs.get('volume_id')

        if volume_id is None:
            volume_size = kwargs.get('volume_size')
            if volume_size is None:
                raise exception.MissingParameterValue(
                    _("No volume size provided for creating volume"))
            volume_id = _create_volume(seamicro_info, volume_size)

        if _validate_volume(seamicro_info, volume_id):
            try:
                server = _get_server(seamicro_info)
                server.detach_volume()
                server = server.refresh(5)
                server.attach_volume(volume_id)
            except seamicro_client_exception.ClientException as ex:
                LOG.error(_LE("SeaMicro client exception: %s"), ex.message)
                raise exception.VendorPassthruException(message=ex.message)

            properties = node.properties
            properties['seamicro_volume_id'] = volume_id
            node.properties = properties
            node.save(task.context)
Exemplo n.º 3
0
    def vendor_passthru(self, task, **kwargs):
        """A node that knows its UUID should heartbeat to this passthru.

        It will get its node object back, with what Ironic thinks its provision
        state is and the target provision state is.
        """
        method = kwargs['method']  # Existence checked in mixin
        if method not in self.vendor_routes:
            raise exception.InvalidParameterValue(
                _('No handler for method '
                  '%s') % method)
        func = self.vendor_routes[method]
        try:
            return func(task, **kwargs)
        except exception.IronicException as e:
            with excutils.save_and_reraise_exception():
                # log this because even though the exception is being
                # reraised, it won't be handled if it is an async. call.
                LOG.exception(_LE('vendor_passthru failed with method %s'),
                              method)
        except Exception as e:
            # catch-all in case something bubbles up here
            # log this because even though the exception is being
            # reraised, it won't be handled if it is an async. call.
            LOG.exception(_LE('vendor_passthru failed with method %s'), method)
            raise exception.VendorPassthruException(message=e)
Exemplo n.º 4
0
 def passthru_handler(*args, **kwargs):
     try:
         return func(*args, **kwargs)
     except exception.IronicException as e:
         with excutils.save_and_reraise_exception():
             LOG.exception(passthru_logmessage, api_method)
     except Exception as e:
         # catch-all in case something bubbles up here
         LOG.exception(passthru_logmessage, api_method)
         raise exception.VendorPassthruException(message=e)
Exemplo n.º 5
0
def _create_volume(driver_info, volume_size):
    """Create volume in the SeaMicro storage pools designated for ironic."""

    ironic_pools = _get_pools(driver_info, filters={'id': 'ironic-'})
    if ironic_pools is None:
        raise exception.VendorPassthruException(
            _("No storage pools found for ironic"))

    least_used_pool = sorted(ironic_pools, key=lambda x: x.freeSize)[0]
    return _get_client(**driver_info).volumes.create(volume_size,
                                                     least_used_pool)
Exemplo n.º 6
0
    def _set_boot_device(self, task, **kwargs):
        """Set the boot device of the node.

        @kwargs device: Boot device. One of [pxe, disk]
        """
        boot_device = kwargs.get('device')

        if boot_device is None:
            raise exception.InvalidParameterValue(_("No boot device provided"))

        if boot_device not in VALID_BOOT_DEVICES:
            raise exception.InvalidParameterValue(_("Boot device is invalid"))

        seamicro_info = _parse_driver_info(task.node)
        try:
            server = _get_server(seamicro_info)
            if boot_device == "disk":
                boot_device = "hd0"

            server.set_boot_order(boot_device)
        except seamicro_client_exception.ClientException as ex:
            LOG.error(_("set_boot_device error:  %s"), ex.message)
            raise exception.VendorPassthruException(message=ex.message)