Example #1
0
 def test_update_vnf_invalid_config_format(self):
     self._insert_dummy_vnf_template()
     dummy_vnf_obj = self._insert_dummy_vnf()
     vnf_config_obj = utils.get_dummy_vnf_config_obj()
     vnf_config_obj['vnf']['attributes']['config'] = {'vdus': {
         'vdu1': {'config': {'firewall': 'dummy_firewall_values'}}}}
     result = self.vnfm_plugin.update_vnf(self.context, dummy_vnf_obj[
         'id'], vnf_config_obj)
     self.assertEqual(constants.ACTIVE, result['status'])
Example #2
0
 def test_create_vnf_with_config_option(self):
     self._insert_dummy_vnf_template()
     vnf_obj = utils.get_dummy_vnf_obj()
     config = utils.get_dummy_vnf_config_obj()
     vnf_obj['vnf']['attributes'] = config['vnf']['attributes']
     result = self.vnfm_plugin.create_vnf(self.context, vnf_obj)
     self.assertEqual(vnf_obj['vnf']['attributes']['config'],
                      result['attributes']['config'])
     self.assertEqual('ACTIVE', result['status'])
Example #3
0
 def test_create_vnf_with_config_option(self):
     self._insert_dummy_vnf_template()
     vnf_obj = utils.get_dummy_vnf_obj()
     config = utils.get_dummy_vnf_config_obj()
     vnf_obj['vnf']['attributes'] = config['vnf']['attributes']
     result = self.vnfm_plugin.create_vnf(self.context, vnf_obj)
     self.assertEqual(vnf_obj['vnf']['attributes']['config'],
                      result['attributes']['config'])
     self.assertEqual('ACTIVE', result['status'])
Example #4
0
 def test_update_vnf_fail_mgmt_driver_error(
         self, mock_mgmt_call, mock_set_vnf_error_status_reason):
     self._insert_dummy_vnf_template()
     dummy_vnf_obj = self._insert_dummy_vnf()
     vnf_config_obj = utils.get_dummy_vnf_config_obj()
     mock_mgmt_call.side_effect = exceptions.MgmtDriverException
     vnf_dict = self.vnfm_plugin.update_vnf(self.context,
                                            dummy_vnf_obj['id'],
                                            vnf_config_obj)
     self.assertEqual(constants.ERROR, vnf_dict['status'])
     mock_set_vnf_error_status_reason.assert_called_once_with(
         self.context, dummy_vnf_obj['id'], 'VNF configuration failed')
Example #5
0
 def test_update_vnf(self):
     self._insert_dummy_device_template()
     dummy_device_obj = self._insert_dummy_device()
     vnf_config_obj = utils.get_dummy_vnf_config_obj()
     result = self.vnfm_plugin.update_vnf(self.context, dummy_device_obj[
         'id'], vnf_config_obj)
     self.assertIsNotNone(result)
     self.assertEqual(dummy_device_obj['id'], result['id'])
     self.assertIn('instance_id', result)
     self.assertIn('status', result)
     self.assertIn('attributes', result)
     self.assertIn('mgmt_url', result)
     self._pool.spawn_n.assert_called_once_with(mock.ANY, mock.ANY,
                                                mock.ANY, mock.ANY)
Example #6
0
 def test_update_vnf_fail_update_wait_error(
         self, mock_set_vnf_error_status_reason):
     self._insert_dummy_vnf_template()
     dummy_vnf_obj = self._insert_dummy_vnf()
     vnf_config_obj = utils.get_dummy_vnf_config_obj()
     self.update_wait.side_effect = vnfm.VNFUpdateWaitFailed(
         reason='failed')
     self.assertRaises(vnfm.VNFUpdateWaitFailed,
                       self.vnfm_plugin.update_vnf, self.context,
                       dummy_vnf_obj['id'], vnf_config_obj)
     self._vnf_monitor.\
         delete_hosting_vnf.assert_called_once_with(dummy_vnf_obj['id'])
     mock_set_vnf_error_status_reason.assert_called_once_with(
         self.context, dummy_vnf_obj['id'], 'VNF Update failed')
Example #7
0
 def test_update_vnf_fail_mgmt_driver_error(self, mock_mgmt_call,
                                         mock_set_vnf_error_status_reason):
     self._insert_dummy_vnf_template()
     dummy_vnf_obj = self._insert_dummy_vnf()
     vnf_config_obj = utils.get_dummy_vnf_config_obj()
     mock_mgmt_call.side_effect = exceptions.MgmtDriverException
     vnf_dict = self.vnfm_plugin.update_vnf(self.context,
                                            dummy_vnf_obj['id'],
                                            vnf_config_obj)
     self.assertEqual(constants.ERROR,
                      vnf_dict['status'])
     mock_set_vnf_error_status_reason.assert_called_once_with(self.context,
                                                       dummy_vnf_obj['id'],
                                                'VNF configuration failed')
Example #8
0
 def test_update_vnf_fail_update_wait_error(self,
                                         mock_set_vnf_error_status_reason):
     self._insert_dummy_vnf_template()
     dummy_vnf_obj = self._insert_dummy_vnf()
     vnf_config_obj = utils.get_dummy_vnf_config_obj()
     self.update_wait.side_effect = vnfm.VNFUpdateWaitFailed(
         reason='failed')
     self.assertRaises(vnfm.VNFUpdateWaitFailed,
                       self.vnfm_plugin.update_vnf, self.context,
                       dummy_vnf_obj['id'], vnf_config_obj)
     self._vnf_monitor.\
         delete_hosting_vnf.assert_called_once_with(dummy_vnf_obj['id'])
     mock_set_vnf_error_status_reason.assert_called_once_with(self.context,
                                                     dummy_vnf_obj['id'],
                                                 'VNF Update failed')
Example #9
0
 def test_update_vnf_invalid_config_format(self):
     self._insert_dummy_vnf_template()
     dummy_vnf_obj = self._insert_dummy_vnf()
     vnf_config_obj = utils.get_dummy_vnf_config_obj()
     vnf_config_obj['vnf']['attributes']['config'] = {
         'vdus': {
             'vdu1': {
                 'config': {
                     'firewall': 'dummy_firewall_values'
                 }
             }
         }
     }
     result = self.vnfm_plugin.update_vnf(self.context, dummy_vnf_obj['id'],
                                          vnf_config_obj)
     self.assertEqual(constants.ACTIVE, result['status'])
Example #10
0
 def test_update_vnf(self):
     self._insert_dummy_vnf_template()
     dummy_vnf_obj = self._insert_dummy_vnf()
     vnf_config_obj = utils.get_dummy_vnf_config_obj()
     result = self.vnfm_plugin.update_vnf(self.context, dummy_vnf_obj[
         'id'], vnf_config_obj)
     self.assertIsNotNone(result)
     self.assertEqual(dummy_vnf_obj['id'], result['id'])
     self.assertIn('instance_id', result)
     self.assertIn('status', result)
     self.assertIn('attributes', result)
     self.assertIn('mgmt_ip_address', result)
     self.assertIn('updated_at', result)
     self._cos_db_plugin.create_event.assert_called_with(
         self.context, evt_type=constants.RES_EVT_UPDATE, res_id=mock.ANY,
         res_state=mock.ANY, res_type=constants.RES_TYPE_VNF,
         tstamp=mock.ANY)
Example #11
0
 def test_update_vnf(self):
     self._insert_dummy_device_template()
     dummy_device_obj = self._insert_dummy_device()
     vnf_config_obj = utils.get_dummy_vnf_config_obj()
     result = self.vnfm_plugin.update_vnf(self.context, dummy_device_obj[
         'id'], vnf_config_obj)
     self.assertIsNotNone(result)
     self.assertEqual(dummy_device_obj['id'], result['id'])
     self.assertIn('instance_id', result)
     self.assertIn('status', result)
     self.assertIn('attributes', result)
     self.assertIn('mgmt_url', result)
     self.assertIn('updated_at', result)
     self._pool.spawn_n.assert_called_once_with(mock.ANY, mock.ANY,
                                                mock.ANY, mock.ANY,
                                                mock.ANY)
     self._cos_db_plugin.create_event.assert_called_with(
         self.context, evt_type=constants.RES_EVT_UPDATE, res_id=mock.ANY,
         res_state=mock.ANY, res_type=constants.RES_TYPE_VNF,
         tstamp=mock.ANY)
Example #12
0
    def test_update_vnf_with_exception(self, mock_update_vnf_post):
        self.update.side_effect = FakeException
        self._insert_dummy_vnf_template()
        dummy_device_obj = self._insert_dummy_vnf()
        vnf_config_obj = utils.get_dummy_vnf_config_obj()
        self.assertRaises(FakeException,
                          self.vnfm_plugin.update_vnf, self.context,
                          dummy_device_obj['id'], vnf_config_obj)
        self._vnf_monitor.delete_hosting_vnf.assert_called_once_with(
            dummy_device_obj['id'])
        mock_update_vnf_post.assert_called_once_with(self.context,
                                                     dummy_device_obj['id'],
                                                     constants.ERROR,
                                                     mock.ANY,
                                                     constants.PENDING_UPDATE,
                                                     constants.RES_EVT_UPDATE)

        self._cos_db_plugin.create_event.assert_called_with(
            self.context, evt_type=constants.RES_EVT_UPDATE, res_id=mock.ANY,
            res_state=mock.ANY, res_type=constants.RES_TYPE_VNF,
            tstamp=mock.ANY)
Example #13
0
    def test_update_vnf_with_exception(self, mock_update_vnf_post):
        self.update.side_effect = FakeException
        self._insert_dummy_vnf_template()
        dummy_device_obj = self._insert_dummy_vnf()
        vnf_config_obj = utils.get_dummy_vnf_config_obj()
        self.assertRaises(FakeException, self.vnfm_plugin.update_vnf,
                          self.context, dummy_device_obj['id'], vnf_config_obj)
        self._vnf_monitor.delete_hosting_vnf.assert_called_once_with(
            dummy_device_obj['id'])
        mock_update_vnf_post.assert_called_once_with(self.context,
                                                     dummy_device_obj['id'],
                                                     constants.ERROR, mock.ANY,
                                                     constants.PENDING_UPDATE,
                                                     constants.RES_EVT_UPDATE)

        self._cos_db_plugin.create_event.assert_called_with(
            self.context,
            evt_type=constants.RES_EVT_UPDATE,
            res_id=mock.ANY,
            res_state=mock.ANY,
            res_type=constants.RES_TYPE_VNF,
            tstamp=mock.ANY)