Пример #1
0
    def update_node(self, node_id, values):
        # NOTE(dtantsur): this can lead to very strange errors
        if 'uuid' in values:
            msg = _("Cannot overwrite UUID for an existing Node.")
            raise exception.InvalidParameterValue(err=msg)

        try:
            return self._do_update_node(node_id, values)
        except db_exc.DBDuplicateEntry:
            raise exception.InstanceAssociated(
                instance_uuid=values['ironic_node_id'], node=node_id)
Пример #2
0
    def create_node(self, values):
        # ensure defaults are present for new nodes
        if not values.get('uuid'):
            values['uuid'] = utils.generate_uuid()

        node = models.Node()
        node.update(values)
        try:
            node.save()
        except db_exc.DBDuplicateEntry as exc:
            if 'ironic_node_id' in exc.columns:
                raise exception.InstanceAssociated(
                    instance_uuid=values['ironic_node_id'],
                    node=values['uuid'])
            raise exception.NodeAlreadyExists(uuid=values['uuid'])
        return node
Пример #3
0
 def test_InstanceAssociated(self):
     self.assertRaises(exception.InstanceAssociated,
                       lambda: self.raise_(exception.InstanceAssociated()))