Ejemplo n.º 1
0
 def test_create_vnfd_duplicate_name(self):
     self._insert_dummy_device_template()
     vnfd_obj = utils.get_dummy_vnfd_obj()
     vnfd_obj['vnfd']['name'] = 'fake_template'
     self.assertRaises(exceptions.DuplicateResourceName,
                       self.vnfm_plugin.create_vnfd,
                       self.context, vnfd_obj)
Ejemplo n.º 2
0
    def test_create_vnfd(self, mock_get_mgmt_driver, mock_tosca_template,
                        mock_update_imports):
        mock_get_mgmt_driver.return_value = 'dummy_mgmt_driver'
        mock_tosca_template.return_value = mock.ANY

        vnfd_obj = utils.get_dummy_vnfd_obj()
        result = self.vnfm_plugin.create_vnfd(self.context, vnfd_obj)
        self.assertIsNotNone(result)
        self.assertIn('id', result)
        self.assertEqual('dummy_vnfd', result['name'])
        self.assertEqual('dummy_vnfd_description', result['description'])
        self.assertEqual('dummy_mgmt_driver', result['mgmt_driver'])
        self.assertIn('service_types', result)
        self.assertIn('attributes', result)
        self.assertIn('created_at', result)
        self.assertIn('updated_at', result)
        self.assertIn('template_source', result)
        yaml_dict = yaml.safe_load(utils.tosca_vnfd_openwrt)
        mock_tosca_template.assert_called_once_with(
            a_file=False, yaml_dict_tpl=yaml_dict)
        mock_get_mgmt_driver.assert_called_once_with(mock.ANY)
        mock_update_imports.assert_called_once_with(yaml_dict)
        self._cos_db_plugin.create_event.assert_called_once_with(
            self.context, evt_type=constants.RES_EVT_CREATE, res_id=mock.ANY,
            res_state=constants.RES_EVT_ONBOARDED,
            res_type=constants.RES_TYPE_VNFD, tstamp=mock.ANY)
Ejemplo n.º 3
0
    def test_create_vnfd(self, mock_get_mgmt_driver, mock_tosca_template,
                        mock_update_imports):
        mock_get_mgmt_driver.return_value = 'noop'
        mock_tosca_template.return_value = mock.ANY

        vnfd_obj = utils.get_dummy_vnfd_obj()
        result = self.vnfm_plugin.create_vnfd(self.context, vnfd_obj)
        self.assertIsNotNone(result)
        self.assertIn('id', result)
        self.assertEqual('dummy_vnfd', result['name'])
        self.assertEqual('dummy_vnfd_description', result['description'])
        self.assertEqual('noop', result['mgmt_driver'])
        self.assertIn('service_types', result)
        self.assertIn('attributes', result)
        self.assertIn('created_at', result)
        self.assertIn('updated_at', result)
        self.assertIn('template_source', result)
        yaml_dict = yaml.safe_load(utils.tosca_vnfd_openwrt)
        mock_tosca_template.assert_called_once_with(
            a_file=False, yaml_dict_tpl=yaml_dict)
        mock_get_mgmt_driver.assert_called_once_with(mock.ANY)
        mock_update_imports.assert_called_once_with(yaml_dict)
        self._cos_db_plugin.create_event.assert_called_once_with(
            self.context, evt_type=constants.RES_EVT_CREATE, res_id=mock.ANY,
            res_state=constants.RES_EVT_ONBOARDED,
            res_type=constants.RES_TYPE_VNFD, tstamp=mock.ANY)
Ejemplo n.º 4
0
    def test_mgmt_driver(self, mock_get_mgmt_driver):
        mock_get_mgmt_driver.return_value = 'dummy_mgmt_driver'

        vnfd_obj = utils.get_dummy_vnfd_obj()
        self.assertRaises(vnfm.InvalidMgmtDriver,
                          self.vnfm_plugin.create_vnfd,
                          self.context, vnfd_obj)
Ejemplo n.º 5
0
 def test_create_vnfd_duplicate_name(self):
     self._insert_dummy_device_template()
     vnfd_obj = utils.get_dummy_vnfd_obj()
     vnfd_obj['vnfd']['name'] = 'fake_template'
     self.assertRaises(exceptions.DuplicateResourceName,
                       self.vnfm_plugin.create_vnfd,
                       self.context, vnfd_obj)
Ejemplo n.º 6
0
 def test_create_vnfd_without_dict_type_attributes(self):
     vnfd_obj = utils.get_dummy_vnfd_obj()
     # Convert dict to string.
     vnfd_obj['vnfd']['attributes']['vnfd'] = str(
         vnfd_obj['vnfd']['attributes']['vnfd'])
     self.assertRaises(vnfm.InvalidAPIAttributeType,
                       self.vnfm_plugin.create_vnfd, self.context, vnfd_obj)
Ejemplo n.º 7
0
    def test_mgmt_driver(self, mock_get_mgmt_driver):
        mock_get_mgmt_driver.return_value = 'dummy_mgmt_driver'

        vnfd_obj = utils.get_dummy_vnfd_obj()
        self.assertRaises(vnfm.InvalidMgmtDriver,
                          self.vnfm_plugin.create_vnfd,
                          self.context, vnfd_obj)
Ejemplo n.º 8
0
 def test_create_vnfd_without_dict_type_attributes(self):
     vnfd_obj = utils.get_dummy_vnfd_obj()
     # Convert dict to string.
     vnfd_obj['vnfd']['attributes']['vnfd'] = str(
         vnfd_obj['vnfd']['attributes']['vnfd'])
     self.assertRaises(vnfm.InvalidAPIAttributeType,
                       self.vnfm_plugin.create_vnfd,
                       self.context, vnfd_obj)
Ejemplo n.º 9
0
 def test_create_vnfd_empty_name(self):
     vnfd_obj = utils.get_dummy_vnfd_obj()
     vnfd_obj['vnfd']['name'] = ''
     result = self.vnfm_plugin.create_vnfd(self.context, vnfd_obj)
     self.assertIsNotNone(result)
     # If vnfd name is an empty string, it sets the name of vnfd to
     # the name that is present in the vnfd tosca template.
     self.assertEqual(yaml.safe_load(vnfd_obj['vnfd']['attributes']
                 ['vnfd'])['metadata']['template_name'], result['name'])
Ejemplo n.º 10
0
 def test_create_vnfd_empty_name(self):
     vnfd_obj = utils.get_dummy_vnfd_obj()
     vnfd_obj['vnfd']['name'] = ''
     result = self.vnfm_plugin.create_vnfd(self.context, vnfd_obj)
     self.assertIsNotNone(result)
     # If vnfd name is an empty string, it sets the name of vnfd to
     # the name that is present in the vnfd tosca template.
     self.assertEqual(
         yaml.safe_load(vnfd_obj['vnfd']['attributes']['vnfd'])['metadata']
         ['template_name'], result['name'])
Ejemplo n.º 11
0
 def test_create_vnfd_with_empty_description(self):
     vnfd_obj = utils.get_dummy_vnfd_obj()
     vnfd_obj['vnfd']['description'] = ''
     result = self.vnfm_plugin.create_vnfd(self.context, vnfd_obj)
     self.assertIsNotNone(result)
     # If vnfd description is an empty string, it sets the description of
     # vnfd to the description that is present in the vnfd tosca template.
     self.assertEqual(yaml.safe_load(
         vnfd_obj['vnfd']['attributes']['vnfd'])['description'],
         result['description'])
Ejemplo n.º 12
0
 def test_create_vnfd_with_empty_description(self):
     vnfd_obj = utils.get_dummy_vnfd_obj()
     vnfd_obj['vnfd']['description'] = ''
     result = self.vnfm_plugin.create_vnfd(self.context, vnfd_obj)
     self.assertIsNotNone(result)
     # If vnfd description is an empty string, it sets the description of
     # vnfd to the description that is present in the vnfd tosca template.
     self.assertEqual(
         yaml.safe_load(
             vnfd_obj['vnfd']['attributes']['vnfd'])['description'],
         result['description'])
Ejemplo n.º 13
0
 def test_create_vnfd(self):
     vnfd_obj = utils.get_dummy_vnfd_obj()
     result = self.vnfm_plugin.create_vnfd(self.context, vnfd_obj)
     self.assertIsNotNone(result)
     self.assertIn('id', result)
     self.assertIn('service_types', result)
     self.assertIn('attributes', result)
     self._device_manager.invoke.assert_called_once_with(
         mock.ANY,
         mock.ANY,
         plugin=mock.ANY,
         context=mock.ANY,
         device_template=mock.ANY)
Ejemplo n.º 14
0
 def test_create_vnfd(self):
     vnfd_obj = utils.get_dummy_vnfd_obj()
     result = self.vnfm_plugin.create_vnfd(self.context, vnfd_obj)
     self.assertIsNotNone(result)
     self.assertIn('id', result)
     self.assertIn('service_types', result)
     self.assertIn('attributes', result)
     self.assertIn('created_at', result)
     self.assertIn('updated_at', result)
     self._device_manager.invoke.assert_called_once_with(mock.ANY,
                                                         mock.ANY,
                                                         plugin=mock.ANY,
                                                         context=mock.ANY,
                                                         vnfd=mock.ANY)
     self._cos_db_plugin.create_event.assert_called_once_with(
         self.context,
         evt_type=constants.RES_EVT_CREATE,
         res_id=mock.ANY,
         res_state=constants.RES_EVT_VNFD_NA_STATE,
         res_type=constants.RES_TYPE_VNFD,
         tstamp=mock.ANY)
Ejemplo n.º 15
0
 def test_create_vnfd_no_mgmt_driver(self):
     vnfd_obj = utils.get_dummy_vnfd_obj()
     vnfd_obj['vnfd'].pop('mgmt_driver')
     self.assertRaises(vnfm.MGMTDriverNotSpecified,
                       self.vnfm_plugin.create_vnfd,
                       self.context, vnfd_obj)
Ejemplo n.º 16
0
 def test_create_vnfd_without_tosca_definitions_version(self):
     vnfd_obj = utils.get_dummy_vnfd_obj()
     vnfd_obj['vnfd']['attributes']['vnfd'].pop('tosca_definitions_version')
     self.assertRaises(exceptions.Invalid,
                       self.vnfm_plugin.create_vnfd,
                       self.context, vnfd_obj)
Ejemplo n.º 17
0
 def test_create_vnfd_no_service_types(self):
     vnfd_obj = utils.get_dummy_vnfd_obj()
     vnfd_obj['vnfd'].pop('service_types')
     self.assertRaises(vnfm.ServiceTypesNotSpecified,
                       self.vnfm_plugin.create_vnfd,
                       self.context, vnfd_obj)
Ejemplo n.º 18
0
 def test_create_vnfd_without_tosca_definitions_version(self):
     vnfd_obj = utils.get_dummy_vnfd_obj()
     vnfd_obj['vnfd']['attributes']['vnfd'].pop('tosca_definitions_version')
     self.assertRaises(exceptions.Invalid, self.vnfm_plugin.create_vnfd,
                       self.context, vnfd_obj)