示例#1
0
 def __init__(self, host, conf=None):
     if conf:
         self.conf = conf
     else:
         self.conf = CONF
     super(Conductor, self).__init__(host=self.conf.host)
     self.vnfm_plugin = plugin.VNFMPlugin()
     self.vnflcm_driver = vnflcm_driver.VnfLcmDriver()
 def setUp(self):
     super(TestVNFActionVduAutoheal, self).setUp()
     self.context = context.get_admin_context()
     self._mock_device_manager()
     self._mock_vnf_monitor()
     self._insert_dummy_vim()
     self.vnfm_plugin = plugin.VNFMPlugin()
     self.vdu_autoheal = vdu_autoheal.VNFActionVduAutoheal()
     self.addCleanup(mock.patch.stopall)
示例#3
0
    def test_init_monitoring(self, mock_run, mock_get_vnfs):
        vnf_id = uuidutils.generate_uuid()
        vnfs = [{
            'id': vnf_id,
            'vnf': {
                'id': vnf_id,
                'status': 'ACTIVE',
                'name': 'fake_vnf',
                'attributes': {
                    'monitoring_policy':
                    '{"vdus": '
                    '{"VDU1": {"ping": {"actions": {"failure": "respawn"},'
                    '"name": "ping", "parameters": {"count": 3,'
                    '"interval": 1, "monitoring_delay": 45, "timeout": 2},'
                    '"monitoring_params": {"count": 3, "interval": 1,'
                    '"monitoring_delay": 45, "timeout": 2}}}}}'
                }
            },
            'name': 'fake_vnf',
            'tenant_id': 'ad7ebc56538745a08ef7c5e97f8bd437',
            'description': 'fake_vnf_description',
            'instance_id': 'da85ea1a-4ec4-4201-bbb2-8d9249eca7ec',
            'vnfd_id': 'eb094833-995e-49f0-a047-dfb56aaf7c4e',
            'vim_id': '6261579e-d6f3-49ad-8bc3-a9cb974778ff',
            'placement_attr': {
                'region': 'RegionOne'
            },
            'status': 'ACTIVE',
            'attributes': {
                'monitoring_policy':
                '{"vdus": '
                '{"VDU1": {"ping": {"actions": {"failure": "respawn"},'
                '"name": "ping", "parameters": {"count": 3,'
                '"interval": 1, "monitoring_delay": 45, "timeout": 2},'
                '"monitoring_params": {"count": 3, "interval": 1,'
                '"monitoring_delay": 45, "timeout": 2}}}}}'
            },
            'mgmt_ip_address': '{"VDU1": "a.b.c.d"}',
            'deleted_at': datetime.min,
            'mgmt_ip_addresses': 'a.b.c.d'
        }]

        mock_get_vnfs.return_value = vnfs
        # NOTE(bhagyashris): VNFMonitor class is using a singleton pattern
        # and '_hosting_vnfs' is defined as a class level attribute.
        # If one of the unit test adds a VNF to monitor it will show up here
        # provided both the unit tests runs in the same process.
        # Hence, you must reinitialize '_hosting_vnfs' to empty dict.
        monitor.VNFMonitor._hosting_vnfs = dict()
        vnfm_plugin = plugin.VNFMPlugin()
        hosting_vnfs = vnfm_plugin._vnf_monitor._hosting_vnfs.values()
        hosting_vnf = list(hosting_vnfs)[0]['vnf']
        self.assertEqual('{"VDU1": "a.b.c.d"}', hosting_vnf['mgmt_ip_address'])
        self.assertEqual(1, len(hosting_vnfs))
示例#4
0
 def setUp(self):
     super(TestVNFMPlugin, self).setUp()
     self.addCleanup(mock.patch.stopall)
     self.context = context.get_admin_context()
     self._mock_vim_client()
     self._stub_get_vim()
     self._mock_device_manager()
     self._mock_vnf_monitor()
     self._mock_vnf_alarm_monitor()
     self._mock_green_pool()
     self._insert_dummy_vim()
     self.vnfm_plugin = plugin.VNFMPlugin()
     mock.patch('tacker.db.common_services.common_services_db.'
                'CommonServicesPluginDb.create_event').start()
     self._cos_db_plugin = common_services_db.CommonServicesPluginDb()
示例#5
0
    def test_init_monitoring(self, mock_run, mock_get_vnfs):
        vnf_id = uuidutils.generate_uuid()
        vnfs = [{
            'id': vnf_id,
            'vnf': {
                'id': vnf_id,
                'status': 'ACTIVE',
                'name': 'fake_vnf',
                'attributes': {
                    'monitoring_policy':
                    '{"vdus": '
                    '{"VDU1": {"ping": {"actions": {"failure": "respawn"},'
                    '"name": "ping", "parameters": {"count": 3,'
                    '"interval": 1, "monitoring_delay": 45, "timeout": 2},'
                    '"monitoring_params": {"count": 3, "interval": 1,'
                    '"monitoring_delay": 45, "timeout": 2}}}}}'
                }
            },
            'name': 'fake_vnf',
            'tenant_id': 'ad7ebc56538745a08ef7c5e97f8bd437',
            'description': 'fake_vnf_description',
            'instance_id': 'da85ea1a-4ec4-4201-bbb2-8d9249eca7ec',
            'vnfd_id': 'eb094833-995e-49f0-a047-dfb56aaf7c4e',
            'vim_id': '6261579e-d6f3-49ad-8bc3-a9cb974778ff',
            'placement_attr': {
                'region': 'RegionOne'
            },
            'status': 'ACTIVE',
            'attributes': {
                'monitoring_policy':
                '{"vdus": '
                '{"VDU1": {"ping": {"actions": {"failure": "respawn"},'
                '"name": "ping", "parameters": {"count": 3,'
                '"interval": 1, "monitoring_delay": 45, "timeout": 2},'
                '"monitoring_params": {"count": 3, "interval": 1,'
                '"monitoring_delay": 45, "timeout": 2}}}}}'
            },
            'mgmt_url': '{"VDU1": "a.b.c.d"}',
            'deleted_at': datetime.min,
            'management_ip_addresses': 'a.b.c.d'
        }]

        mock_get_vnfs.return_value = vnfs
        vnfm_plugin = plugin.VNFMPlugin()
        hosting_vnfs = vnfm_plugin._vnf_monitor._hosting_vnfs.values()
        hosting_vnf = hosting_vnfs[0]['vnf']
        self.assertEqual('{"VDU1": "a.b.c.d"}', hosting_vnf['mgmt_url'])
        self.assertEqual(1, len(hosting_vnfs))
示例#6
0
    def setUp(self):
        super(TestCVNFMPlugin, self).setUp()
        self.addCleanup(mock.patch.stopall)
        self.context = context.get_admin_context()
        self._mock_vim_client()
        self._stub_get_vim()
        self._mock_vnf_monitor()
        self._mock_vnf_maintenance_monitor()
        self._mock_vnf_maintenance_plugin()
        self._insert_dummy_vim()
        self.vnfm_plugin = plugin.VNFMPlugin()
        mock.patch('tacker.db.common_services.common_services_db_plugin.'
                   'CommonServicesPluginDb.create_event'
                   ).start()
        mock.patch('tacker.db.vnfm.vnfm_db.VNFMPluginDb._mgmt_driver_name',
                   return_value='noop').start()
        self.create = mock.patch('tacker.vnfm.infra_drivers.kubernetes.'
                                 'kubernetes_driver.Kubernetes.create',
                                 return_value=uuidutils.
                                 generate_uuid()).start()
        self.create_wait = mock.patch('tacker.vnfm.infra_drivers.kubernetes.'
                                      'kubernetes_driver.Kubernetes.'
                                      'create_wait').start()
        self.update = mock.patch('tacker.vnfm.infra_drivers.kubernetes.'
                                 'kubernetes_driver.Kubernetes.update').start()
        self.update_wait = mock.patch('tacker.vnfm.infra_drivers.kubernetes.'
                                      'kubernetes_driver.Kubernetes.'
                                      'update_wait').start()
        self.delete = mock.patch('tacker.vnfm.infra_drivers.kubernetes.'
                                 'kubernetes_driver.Kubernetes.delete').start()
        self.delete_wait = mock.patch('tacker.vnfm.infra_drivers.kubernetes.'
                                      'kubernetes_driver.Kubernetes.'
                                      'delete_wait').start()
        self.scale = mock.patch('tacker.vnfm.infra_drivers.kubernetes.'
                                'kubernetes_driver.Kubernetes.scale',
                                return_value=uuidutils.generate_uuid()).start()
        self.scale_wait = mock.patch('tacker.vnfm.infra_drivers.kubernetes.'
                                     'kubernetes_driver.Kubernetes.scale_wait',
                                     return_value=uuidutils.
                                     generate_uuid()).start()

        def _fake_spawn(func, *args, **kwargs):
            func(*args, **kwargs)

        mock.patch.object(self.vnfm_plugin, 'spawn_n',
                          _fake_spawn).start()
        self._cos_db_plugin =\
            common_services_db_plugin.CommonServicesPluginDb()