示例#1
0
    def test_activate_node(self):
        self._create_node()
        self.instance['uuid'] = 'fake-uuid'
        self.flags(pxe_deploy_timeout=1, group='baremetal')

        db.bm_node_update(self.context, 1, {
            'task_state': baremetal_states.DEPLOYING,
            'instance_uuid': 'fake-uuid'
        })

        # test timeout
        self.assertRaises(exception.InstanceDeployFailure,
                          self.driver.activate_node, self.context, self.node,
                          self.instance)

        # test DEPLOYDONE
        db.bm_node_update(self.context, 1,
                          {'task_state': baremetal_states.DEPLOYDONE})
        self.driver.activate_node(self.context, self.node, self.instance)

        # test no deploy -- state is just ACTIVE
        db.bm_node_update(self.context, 1,
                          {'task_state': baremetal_states.ACTIVE})
        self.driver.activate_node(self.context, self.node, self.instance)

        # test node gone
        db.bm_node_destroy(self.context, 1)
        self.assertRaises(exception.InstanceDeployFailure,
                          self.driver.activate_node, self.context, self.node,
                          self.instance)
示例#2
0
    def test_activate_node(self):
        self._create_node()
        self.instance['uuid'] = 'fake-uuid'
        self.flags(pxe_deploy_timeout=1, group='baremetal')

        db.bm_node_update(self.context, 1,
                {'task_state': baremetal_states.DEPLOYING,
                 'instance_uuid': 'fake-uuid'})

        # test timeout
        self.assertRaises(exception.InstanceDeployFailure,
                self.driver.activate_node,
                self.context, self.node, self.instance)

        # test DEPLOYDONE
        db.bm_node_update(self.context, 1,
                {'task_state': baremetal_states.DEPLOYDONE})
        self.driver.activate_node(self.context, self.node, self.instance)

        # test no deploy -- state is just ACTIVE
        db.bm_node_update(self.context, 1,
                {'task_state': baremetal_states.ACTIVE})
        self.driver.activate_node(self.context, self.node, self.instance)

        # test node gone
        db.bm_node_destroy(self.context, 1)
        self.assertRaises(exception.InstanceDeployFailure,
                self.driver.activate_node,
                self.context, self.node, self.instance)
示例#3
0
    def test_destroy_with_interfaces(self):
        self._create_nodes()

        if_a_id = db.bm_interface_create(self.context, self.ids[0],
                                         'aa:aa:aa:aa:aa:aa', None, None)
        if_b_id = db.bm_interface_create(self.context, self.ids[0],
                                         'bb:bb:bb:bb:bb:bb', None, None)
        if_x_id = db.bm_interface_create(self.context, self.ids[1],
                                         '11:22:33:44:55:66', None, None)

        db.bm_node_destroy(self.context, self.ids[0])

        self.assertRaises(
              exception.NovaException,
              db.bm_interface_get,
              self.context, if_a_id)

        self.assertRaises(
              exception.NovaException,
              db.bm_interface_get,
              self.context, if_b_id)

        # Another node's interface is not affected
        if_x = db.bm_interface_get(self.context, if_x_id)
        self.assertEqual(self.ids[1], if_x['bm_node_id'])

        self.assertRaises(
              exception.NodeNotFound,
              db.bm_node_get,
              self.context, self.ids[0])

        r = db.bm_node_get_all(self.context)
        self.assertEquals(len(r), 5)
示例#4
0
    def test_destroy_with_interfaces(self):
        self._create_nodes()

        if_a_id = db.bm_interface_create(self.context, self.ids[0],
                                         'aa:aa:aa:aa:aa:aa', None, None)
        if_b_id = db.bm_interface_create(self.context, self.ids[0],
                                         'bb:bb:bb:bb:bb:bb', None, None)
        if_x_id = db.bm_interface_create(self.context, self.ids[1],
                                         '11:22:33:44:55:66', None, None)

        db.bm_node_destroy(self.context, self.ids[0])

        self.assertRaises(exception.NovaException, db.bm_interface_get,
                          self.context, if_a_id)

        self.assertRaises(exception.NovaException, db.bm_interface_get,
                          self.context, if_b_id)

        # Another node's interface is not affected
        if_x = db.bm_interface_get(self.context, if_x_id)
        self.assertEqual(self.ids[1], if_x['bm_node_id'])

        self.assertRaises(exception.NodeNotFound, db.bm_node_get, self.context,
                          self.ids[0])

        r = db.bm_node_get_all(self.context)
        self.assertEquals(len(r), 5)
示例#5
0
 def test_delete_node_not_found(self):
     self.mox.StubOutWithMock(db, 'bm_node_destroy')
     db.bm_node_destroy(self.context, 1).\
             AndRaise(exception.NodeNotFound(node_id=1))
     self.mox.ReplayAll()
     self.assertRaises(exc.HTTPNotFound, self.controller.delete,
                       self.request, 1)
示例#6
0
 def delete(self, req, id):
     context = req.environ['nova.context']
     authorize(context)
     try:
         db.bm_node_destroy(context, id)
     except exception.NodeNotFound as e:
         raise webob.exc.HTTPNotFound(explanation=e.format_message())
     return webob.Response(status_int=202)
示例#7
0
 def delete(self, req, id):
     context = req.environ['nova.context']
     authorize(context)
     try:
         db.bm_node_destroy(context, id)
     except exception.NodeNotFound as e:
         raise webob.exc.HTTPNotFound(explanation=e.format_message())
     return webob.Response(status_int=202)
示例#8
0
 def delete(self, req, id):
     context = req.environ['nova.context']
     authorize(context)
     try:
         db.bm_node_destroy(context, id)
     except exception.InstanceNotFound:
         raise webob.exc.HTTPNotFound
     return webob.Response(status_int=202)
 def delete(self, req, id):
     context = req.environ['nova.context']
     authorize(context)
     try:
         db.bm_node_destroy(context, id)
     except exception.NodeNotFound:
         raise webob.exc.HTTPNotFound
     return webob.Response(status_int=202)
示例#10
0
 def test_delete_node_not_found(self):
     self.mox.StubOutWithMock(db, 'bm_node_destroy')
     db.bm_node_destroy(self.context, 1).\
             AndRaise(exception.NodeNotFound(node_id=1))
     self.mox.ReplayAll()
     self.assertRaises(
             exc.HTTPNotFound,
             self.controller.delete,
             self.request,
             1)
示例#11
0
    def test_destroy(self):
        self._create_nodes()

        db.bm_node_destroy(self.context, self.ids[0])

        r = db.bm_node_get(self.context, self.ids[0])
        self.assertTrue(r is None)

        r = db.bm_node_get_all(self.context)
        self.assertEquals(len(r), 5)
示例#12
0
    def test_destroy(self):
        self._create_nodes()

        db.bm_node_destroy(self.context, self.ids[0])

        r = db.bm_node_get(self.context, self.ids[0])
        self.assertTrue(r is None)

        r = db.bm_node_get_all(self.context)
        self.assertEquals(len(r), 5)
示例#13
0
    def test_destroy(self):
        self._create_nodes()

        db.bm_node_destroy(self.context, self.ids[0])

        self.assertRaises(exception.InstanceNotFound, db.bm_node_get,
                          self.context, self.ids[0])

        r = db.bm_node_get_all(self.context)
        self.assertEquals(len(r), 5)
示例#14
0
    def delete(self, req, id):
        if _use_ironic():
            _no_ironic_proxy("node-delete")

        context = req.environ['nova.context']
        authorize(context)
        try:
            db.bm_node_destroy(context, id)
        except exception.NodeNotFound:
            raise webob.exc.HTTPNotFound()
        return webob.Response(status_int=202)
示例#15
0
    def delete(self, req, id):
        if _use_ironic():
            _no_ironic_proxy("node-delete")

        context = req.environ['nova.context']
        authorize(context)
        try:
            db.bm_node_destroy(context, id)
        except exception.NodeNotFound:
            raise webob.exc.HTTPNotFound()
        return webob.Response(status_int=202)
示例#16
0
    def test_destroy(self):
        self._create_nodes()

        db.bm_node_destroy(self.context, self.ids[0])

        self.assertRaises(
              exception.NodeNotFound,
              db.bm_node_get,
              self.context, self.ids[0])

        r = db.bm_node_get_all(self.context)
        self.assertEquals(len(r), 5)
示例#17
0
    def test_activate_node(self):
        self._create_node()
        self.instance["uuid"] = "fake-uuid"

        db.bm_node_update(self.context, 1, {"task_state": baremetal_states.DEPLOYING, "instance_uuid": "fake-uuid"})

        # test DEPLOYDONE
        db.bm_node_update(self.context, 1, {"task_state": baremetal_states.DEPLOYDONE})
        self.driver.activate_node(self.context, self.node, self.instance)

        # test no deploy -- state is just ACTIVE
        db.bm_node_update(self.context, 1, {"task_state": baremetal_states.ACTIVE})
        self.driver.activate_node(self.context, self.node, self.instance)

        # test node gone
        db.bm_node_destroy(self.context, 1)
        self.assertRaises(
            exception.InstanceDeployFailure, self.driver.activate_node, self.context, self.node, self.instance
        )
示例#18
0
 def test_delete(self):
     self.mox.StubOutWithMock(db, 'bm_node_destroy')
     db.bm_node_destroy(self.context, 1)
     self.mox.ReplayAll()
     self.controller.delete(self.request, 1)
示例#19
0
 def test_delete(self):
     self.mox.StubOutWithMock(db, 'bm_node_destroy')
     db.bm_node_destroy(self.context, 1)
     self.mox.ReplayAll()
     self.controller.delete(self.request, 1)