def test_create_vim_duplicate_name(self): self._insert_dummy_vim() vim_dict = utils.get_vim_obj() vim_dict['vim']['name'] = 'fake_vim' self.assertRaises(exceptions.DuplicateResourceName, self.nfvo_plugin.create_vim, self.context, vim_dict)
def test_create_vim(self): vim_dict = utils.get_vim_obj() vim_type = 'openstack' res = self.nfvo_plugin.create_vim(self.context, vim_dict) self._cos_db_plugin.create_event.assert_any_call( self.context, evt_type=constants.RES_EVT_CREATE, res_id=mock.ANY, res_state=mock.ANY, res_type=constants.RES_TYPE_VIM, tstamp=mock.ANY) self._cos_db_plugin.create_event.assert_any_call( mock.ANY, evt_type=constants.RES_EVT_MONITOR, res_id=mock.ANY, res_state=mock.ANY, res_type=constants.RES_TYPE_VIM, tstamp=mock.ANY) self._driver_manager.invoke.assert_any_call(vim_type, 'register_vim', vim_obj=vim_dict['vim']) self._driver_manager.invoke.assert_any_call( 'openstack', 'vim_status', auth_url='http://localhost:5000') self.assertIsNotNone(res) self.assertEqual(SECRET_PASSWORD, res['auth_cred']['password']) self.assertIn('id', res) self.assertIn('placement_attr', res) self.assertIn('created_at', res) self.assertIn('updated_at', res)
def test_create_vim(self): vim_dict = utils.get_vim_obj() vim_type = 'openstack' res = self.nfvo_plugin.create_vim(self.context, vim_dict) self._cos_db_plugin.create_event.assert_any_call( self.context, evt_type=constants.RES_EVT_CREATE, res_id=mock.ANY, res_state=mock.ANY, res_type=constants.RES_TYPE_VIM, tstamp=mock.ANY) self._cos_db_plugin.create_event.assert_any_call( mock.ANY, evt_type=constants.RES_EVT_MONITOR, res_id=mock.ANY, res_state=mock.ANY, res_type=constants.RES_TYPE_VIM, tstamp=mock.ANY) self._driver_manager.invoke.assert_any_call(vim_type, 'register_vim', vim_obj=vim_dict['vim']) self._driver_manager.invoke.assert_any_call('openstack', 'vim_status', auth_url='http://localhost:5000') self.assertIsNotNone(res) self.assertEqual(SECRET_PASSWORD, res['auth_cred']['password']) self.assertIn('id', res) self.assertIn('placement_attr', res) self.assertIn('created_at', res) self.assertIn('updated_at', res)