示例#1
0
文件: api.py 项目: mkscala/magnum
    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
示例#2
0
 def test_NodeAlreadyExists(self):
     self.assertRaises(exception.NodeAlreadyExists,
                       lambda: self.raise_(exception.NodeAlreadyExists()))