示例#1
0
 def test_add_hosting_vnf(self, mock_monitor_run):
     test_device_dict = {
         'id': MOCK_DEVICE_ID,
         'mgmt_url': '{"vdu1": "a.b.c.d"}',
         'attributes': {
             'monitoring_policy':
             json.dumps(MOCK_VNF_DEVICE['monitoring_policy'])
         },
         'status': 'ACTIVE'
     }
     action_cb = mock.MagicMock()
     test_boot_wait = 30
     test_vnfmonitor = monitor.VNFMonitor(test_boot_wait)
     new_dict = test_vnfmonitor.to_hosting_vnf(test_device_dict, action_cb)
     test_vnfmonitor.add_hosting_vnf(new_dict)
     test_device_id = list(test_vnfmonitor._hosting_vnfs.keys())[0]
     self.assertEqual(MOCK_DEVICE_ID, test_device_id)
     self._cos_db_plugin.create_event.assert_called_with(
         mock.ANY,
         res_id=mock.ANY,
         res_type=constants.RES_TYPE_VNF,
         res_state=mock.ANY,
         evt_type=constants.RES_EVT_MONITOR,
         tstamp=mock.ANY,
         details=mock.ANY)
示例#2
0
文件: plugin.py 项目: vintej/tacker
 def __init__(self):
     super(VNFMPlugin, self).__init__()
     self._pool = eventlet.GreenPool()
     self.boot_wait = cfg.CONF.tacker.boot_wait
     self.vim_client = vim_client.VimClient()
     self._vnf_manager = driver_manager.DriverManager(
         'tacker.tacker.vnfm.drivers', cfg.CONF.tacker.infra_driver)
     self._vnf_monitor = monitor.VNFMonitor(self.boot_wait)
     self._vnf_alarm_monitor = monitor.VNFAlarmMonitor()
示例#3
0
 def __init__(self):
     super(VNFMPlugin, self).__init__()
     self._pool = eventlet.GreenPool()
     self.boot_wait = cfg.CONF.tacker.boot_wait
     self.vim_client = vim_client.VimClient()
     self._vnf_manager = driver_manager.DriverManager(
         'tacker.tacker.vnfm.drivers', cfg.CONF.tacker.infra_driver)
     self._vnf_action = driver_manager.DriverManager(
         'tacker.tacker.policy.actions', cfg.CONF.tacker.policy_action)
     self._vnf_monitor = monitor.VNFMonitor(self.boot_wait)
     self._vnf_alarm_monitor = monitor.VNFAlarmMonitor()
     self._vnf_reservation_monitor = monitor.VNFReservationAlarmMonitor()
     self._vnf_app_monitor = monitor.VNFAppMonitor()
     self._init_monitoring()
示例#4
0
 def __init__(self):
     super(VNFMPlugin, self).__init__()
     self._pool = eventlet.GreenPool()
     self.boot_wait = cfg.CONF.tacker.boot_wait
     self.vim_client = vim_client.VimClient()
     #vnf被哪种vim进行管理,实现vnf的创建,删除,扩缩容
     self._vnf_manager = driver_manager.DriverManager(
         'tacker.tacker.vnfm.drivers', cfg.CONF.tacker.infra_driver)
     self._vnf_action = driver_manager.DriverManager(
         'tacker.tacker.policy.actions', cfg.CONF.tacker.policy_action)
     #vnf的几种监控驱动
     self._vnf_monitor = monitor.VNFMonitor(self.boot_wait)
     self._vnf_alarm_monitor = monitor.VNFAlarmMonitor()
     self._vnf_app_monitor = monitor.VNFAppMonitor()
示例#5
0
 def test_run_monitor(self, mock_monitor_run):
     test_hosting_vnf = MOCK_VNF_DEVICE
     test_hosting_vnf['vnf'] = {}
     test_boot_wait = 30
     mock_kwargs = {
         'count': 1,
         'monitoring_delay': 0,
         'interval': 0,
         'mgmt_ip': 'a.b.c.d',
         'timeout': 2
     }
     test_vnfmonitor = monitor.VNFMonitor(test_boot_wait)
     self.mock_monitor_manager.invoke = mock.MagicMock()
     test_vnfmonitor._monitor_manager = self.mock_monitor_manager
     test_vnfmonitor.run_monitor(test_hosting_vnf)
     self.mock_monitor_manager\
         .invoke.assert_called_once_with('ping', 'monitor_call', vnf={},
                                         kwargs=mock_kwargs)
示例#6
0
 def test_vdu_autoheal_action(self, mock_monitor_call, mock_monitor_run):
     test_hosting_vnf = MOCK_VNF_DEVICE_FOR_VDU_AUTOHEAL
     test_boot_wait = 30
     test_device_dict = {
         'status': 'ACTIVE',
         'id': MOCK_VNF_ID,
         'mgmt_ip_address': '{"vdu1": "a.b.c.d"}',
         'attributes': {
             'monitoring_policy': jsonutils.dump_as_bytes(
                 MOCK_VNF_DEVICE_FOR_VDU_AUTOHEAL['monitoring_policy'])
         }
     }
     test_hosting_vnf['vnf'] = test_device_dict
     mock_monitor_call.return_value = 'failure'
     test_vnfmonitor = monitor.VNFMonitor(test_boot_wait)
     test_vnfmonitor._monitor_manager = self.mock_monitor_manager
     test_vnfmonitor.run_monitor(test_hosting_vnf)
     test_hosting_vnf['action_cb'].assert_called_once_with(
         'vdu_autoheal', vdu_name='vdu1')
示例#7
0
    def test_update_hosting_vnf(self, mock_monitor_run):
        test_boot_wait = 30
        test_vnfmonitor = monitor.VNFMonitor(test_boot_wait)
        vnf_dict = {
            'id': MOCK_VNF_ID,
            'mgmt_ip_address': '{"vdu1": "a.b.c.d"}',
            'mgmt_ip_addresses': 'a.b.c.d',
            'vnf': {
                'id': MOCK_VNF_ID,
                'mgmt_ip_address': '{"vdu1": "a.b.c.d"}',
                'attributes': {
                    'monitoring_policy':
                    jsonutils.dump_as_bytes(MOCK_VNF['monitoring_policy'])
                },
                'status': 'ACTIVE',
            }
        }

        test_vnfmonitor.add_hosting_vnf(vnf_dict)
        vnf_dict['status'] = 'PENDING_HEAL'
        test_vnfmonitor.update_hosting_vnf(vnf_dict)
        test_device_status = test_vnfmonitor._hosting_vnfs[MOCK_VNF_ID]['vnf'][
            'status']
        self.assertEqual('PENDING_HEAL', test_device_status)