Пример #1
0
    def _do_update_node(self, node_id, values):
        session = get_session()
        with session.begin():
            query = model_query(models.Node, session=session)
            query = add_identity_filter(query, node_id)
            try:
                ref = query.with_lockmode('update').one()
            except NoResultFound:
                raise exception.NodeNotFound(node=node_id)

            # Prevent ironic_node_id overwriting
            if values.get("ironic_node_id") and ref.ironic_node_id:
                raise exception.NodeAssociated(node=node_id,
                                               instance=ref.ironic_node_id)

            ref.update(values)
        return ref
Пример #2
0
 def test_NodeAssociated(self):
     self.assertRaises(exception.NodeAssociated,
                       lambda: self.raise_(exception.NodeAssociated()))