コード例 #1
0
 def test_detach_interface(self, mock_detach_interface):
     fake_server = db_utils.get_test_server(user_id=self.user_id,
                                            project_id=self.project_id)
     fake_server_obj = self._create_fake_server_obj(fake_server)
     self.engine_api.detach_interface(self.context, fake_server_obj,
                                      fake_server_obj['nics'][0]['port_id'])
     self.assertTrue(mock_detach_interface.called)
コード例 #2
0
ファイル: test_engine_api.py プロジェクト: weizai118/mogan
 def test_lock_by_admin(self):
     fake_server = db_utils.get_test_server(user_id=self.user_id,
                                            project_id=self.project_id)
     fake_server_obj = self._create_fake_server_obj(fake_server)
     admin_context = context.get_admin_context()
     self.engine_api.lock(admin_context, fake_server_obj)
     self.assertEqual('admin', fake_server_obj.locked_by)
コード例 #3
0
 def test_lock_by_owner(self):
     fake_server = db_utils.get_test_server(user_id=self.user_id,
                                            project_id=self.project_id)
     fake_server_obj = self._create_fake_server_obj(fake_server)
     self.engine_api.lock(self.context, fake_server_obj)
     self.assertTrue(fake_server_obj.locked)
     self.assertEqual('owner', fake_server_obj.locked_by)
コード例 #4
0
ファイル: test_engine_api.py プロジェクト: weizai118/mogan
 def test_unlock_by_owner(self):
     fake_server = db_utils.get_test_server(user_id=self.user_id,
                                            project_id=self.project_id,
                                            locked_by='owner')
     fake_server_obj = self._create_fake_server_obj(fake_server)
     self.engine_api.unlock(self.context, fake_server_obj)
     self.assertIsNone(fake_server_obj.locked_by)
コード例 #5
0
ファイル: test_engine_api.py プロジェクト: weizai118/mogan
 def test_rebuild_server(self, mock_rebuild, mock_get_image):
     fake_server = db_utils.get_test_server(user_id=self.user_id,
                                            project_id=self.project_id)
     fake_server_obj = self._create_fake_server_obj(fake_server)
     mock_get_image.side_effect = None
     self.engine_api.rebuild(self.context, fake_server_obj)
     self.assertTrue(mock_get_image.called)
     self.assertTrue(mock_rebuild.called)
コード例 #6
0
ファイル: test_engine_api.py プロジェクト: weizai118/mogan
 def test_rebuild_locked_server_with_non_admin(self, mock_rebuild):
     fake_server = db_utils.get_test_server(user_id=self.user_id,
                                            project_id=self.project_id,
                                            locked_by='owner')
     fake_server_obj = self._create_fake_server_obj(fake_server)
     self.assertRaises(exception.ServerIsLocked, self.engine_api.rebuild,
                       self.context, fake_server_obj)
     mock_rebuild.assert_not_called()
コード例 #7
0
ファイル: test_engine_api.py プロジェクト: weizai118/mogan
 def test_power_locked_server_with_admin(self, mock_powered):
     fake_server = db_utils.get_test_server(user_id=self.user_id,
                                            project_id=self.project_id,
                                            locked_by='owner')
     fake_server_obj = self._create_fake_server_obj(fake_server)
     admin_context = context.get_admin_context()
     self.engine_api.power(admin_context, fake_server_obj, 'reboot')
     self.assertTrue(mock_powered.called)
コード例 #8
0
 def test_rebuild_locked_server_with_admin(self, mock_rebuild):
     fake_server = db_utils.get_test_server(user_id=self.user_id,
                                            project_id=self.project_id,
                                            locked=True,
                                            locked_by='owner')
     fake_server_obj = self._create_fake_server_obj(fake_server)
     admin_context = context.get_admin_context()
     self.engine_api.rebuild(admin_context, fake_server_obj)
     self.assertTrue(mock_rebuild.called)
コード例 #9
0
 def setUp(self):
     super(RPCAPITestCase, self).setUp()
     self.fake_server = dbutils.get_test_server()
     self.fake_server_obj = objects.Server._from_db_object(
         objects.Server(self.context), self.fake_server)
     self.fake_type = dbutils.get_test_flavor()
     self.fake_type['extra_specs'] = {}
     self.fake_type_obj = objects.Flavor._from_db_object(
         self.context, objects.Flavor(self.context), self.fake_type)
コード例 #10
0
 def test_unlock_by_admin(self):
     fake_server = db_utils.get_test_server(user_id=self.user_id,
                                            project_id=self.project_id,
                                            locked=True,
                                            locked_by='owner')
     fake_server_obj = self._create_fake_server_obj(fake_server)
     admin_context = context.get_admin_context()
     self.engine_api.unlock(admin_context, fake_server_obj)
     self.assertFalse(fake_server_obj.locked)
     self.assertIsNone(fake_server_obj.locked_by)
コード例 #11
0
 def setUp(self):
     super(TestServerObject, self).setUp()
     self.ctxt = context.get_admin_context()
     self.fake_server = utils.get_test_server(context=self.ctxt)
     self.server = obj_utils.get_test_server(self.ctxt, **self.fake_server)