コード例 #1
0
 def setUpClass(cls):
     cls.conf = cfg.ConfigOpts()
     cls.conf.register_opts(cls.PROCESSOR_OPTS, group='entity_graph')
     cls.conf.register_opts(cls.EVALUATOR_OPTS, group='evaluator')
     cls.conf.register_opts(cls.DATASOURCES_OPTS, group='datasources')
     TestScenarioEvaluator.load_datasources(cls.conf)
     cls.scenario_repository = ScenarioRepository(cls.conf)
コード例 #2
0
ファイル: test_consistency.py プロジェクト: pczerkas/vitrage
    def setUpClass(cls):
        super(TestConsistencyFunctional, cls).setUpClass()
        cls.conf = cfg.ConfigOpts()
        cls.conf.register_opts(cls.CONSISTENCY_OPTS, group='consistency')
        cls.conf.register_opts(cls.PROCESSOR_OPTS, group='entity_graph')
        cls.conf.register_opts(cls.EVALUATOR_OPTS, group='evaluator')
        cls.conf.register_opts(cls.DATASOURCES_OPTS, group='datasources')
        cls.conf.register_opts(database_opts, group='database')
        cls.conf.set_override('connection',
                              'sqlite:///:memory:',
                              group='database')
        cls.load_datasources(cls.conf)

        cls.graph = NXGraph("Entity Graph")
        cls.initialization_status = VitrageInit(cls.conf, cls.graph)
        cls.processor = Processor(cls.conf, cls.initialization_status,
                                  cls.graph)

        cls.event_queue = queue.Queue()

        def actions_callback(event_type, data):
            """Mock notify method

            Mocks vitrage.messaging.VitrageNotifier.notify(event_type, data)

            :param event_type: is currently always the same and is ignored
            :param data:
            """
            cls.event_queue.put(data)

        scenario_repo = ScenarioRepository(cls.conf)
        cls.evaluator = ScenarioEvaluator(cls.conf, cls.processor.entity_graph,
                                          scenario_repo, actions_callback)
        cls.consistency_enforcer = ConsistencyEnforcer(
            cls.conf, actions_callback, cls.processor.entity_graph)
コード例 #3
0
 def setUp(self):
     super(ScenarioRepositoryTest, self).setUp()
     self.add_db()
     templates_dir = utils.get_resources_dir() + '/templates/general'
     self.add_templates(templates_dir)
     templates_dir_path = templates_dir
     self.template_defs = file_utils.load_yaml_files(templates_dir_path)
     self.scenario_repository = ScenarioRepository()
コード例 #4
0
    def setUpClass(cls):

        cls.conf = cfg.ConfigOpts()
        cls.conf.register_opts(cls.OPTS, group='evaluator')

        templates_dir_path = cls.conf.evaluator.templates_dir
        cls.template_defs = file_utils.load_yaml_files(templates_dir_path)

        cls.scenario_repository = ScenarioRepository(cls.conf)
コード例 #5
0
ファイル: workers.py プロジェクト: wookiist/vitrage
 def _init_instance(self):
     scenario_repo = ScenarioRepository(self.worker_id, self._workers_num)
     actions_callback = messaging.VitrageNotifier(
         publisher_id='vitrage_evaluator', topics=[EVALUATOR_TOPIC]).notify
     self._evaluator = ScenarioEvaluator(self._entity_graph,
                                         scenario_repo,
                                         actions_callback,
                                         enabled=False)
     self._evaluator.scenario_repo.log_enabled_scenarios()
コード例 #6
0
    def test_template_loader(self):

        # Test Action
        scenario_repository = ScenarioRepository(self.conf)

        # Test assertions
        self.assertIsNotNone(scenario_repository)
        path, dirs, files = next(os.walk(self.conf.evaluator.templates_dir))
        self.assertEqual(len(files), len(scenario_repository.templates))
コード例 #7
0
def init():
    conf = service.prepare_service()
    event_queue = multiprocessing.Queue()
    e_graph = entity_graph.EntityGraph(
        'Entity Graph', '%s:%s' % (EntityCategory.RESOURCE, OPENSTACK_CLUSTER))
    scenario_repo = ScenarioRepository(conf)
    evaluator = ScenarioEvaluator(conf, e_graph, scenario_repo, event_queue)
    initialization_status = InitializationStatus()

    return conf, event_queue, evaluator, e_graph, initialization_status
コード例 #8
0
def init(conf):
    mp_queue = multiprocessing.Queue()
    evaluator_q = queue.Queue()
    e_graph = entity_graph.EntityGraph(
        'Entity Graph', '%s:%s' % (EntityCategory.RESOURCE, OPENSTACK_CLUSTER))
    scenario_repo = ScenarioRepository(conf)

    evaluator = ScenarioEvaluator(conf, e_graph, scenario_repo, evaluator_q)

    return mp_queue, evaluator_q, evaluator, e_graph
コード例 #9
0
ファイル: workers.py プロジェクト: ropodaing/vitrage
 def _enable_evaluator_templates(self, template_names):
     scenario_repo = ScenarioRepository(self._conf)
     for s in scenario_repo._all_scenarios:
         s.enabled = False
         for template_name in template_names:
             if s.id.startswith(template_name):
                 s.enabled = True
     self._evaluator.scenario_repo = scenario_repo
     self._evaluator.scenario_repo.log_enabled_scenarios()
     self._evaluator.enabled = True
コード例 #10
0
 def setUpClass(cls):
     super(EquivalentScenarioTest, cls).setUpClass()
     cls.conf = cfg.ConfigOpts()
     cls.conf.register_opts(cls.OPTS, group='evaluator')
     cls.add_db(cls.conf)
     cls.add_templates(cls.conf.evaluator.templates_dir)
     cls.add_templates(cls.conf.evaluator.equivalences_dir,
                       TType.EQUIVALENCE)
     cls.add_templates(cls.conf.evaluator.def_templates_dir,
                       TType.DEFINITION)
     cls.scenario_repository = ScenarioRepository(cls.conf)
コード例 #11
0
    def test_template_loader(self):

        # Test Action
        scenario_repository = ScenarioRepository(self.conf)

        # Test assertions
        self.assertIsNotNone(scenario_repository)
        self.assertThat(
            scenario_repository.templates, matchers.HasLength(2),
            'scenario_repository.templates '
            'should contain all valid templates')
コード例 #12
0
 def setUp(self):
     super(EquivalentScenarioTest, self).setUp()
     templates_dir = utils.get_resources_dir() + \
         '/templates/equivalent_scenarios/'
     equivalences_dir = templates_dir + '/equivalences'
     def_templates_dir = utils.get_resources_dir() + \
         '/templates/def_template_tests'
     self.add_db()
     self.add_templates(templates_dir)
     self.add_templates(equivalences_dir, TType.EQUIVALENCE)
     self.add_templates(def_templates_dir, TType.DEFINITION)
     self.scenario_repository = ScenarioRepository()
コード例 #13
0
 def _template_action(self, template_names, action_mode):
     # Here, we create a temporary ScenarioRepo to execute the needed
     # templates. Once _reload_templates is called, it will create a
     # non temporary ScenarioRepo, to replace this one
     scenario_repo = ScenarioRepository(self._conf)
     for s in scenario_repo._all_scenarios:
         s.enabled = False
         for template_name in template_names:
             if s.id.startswith(template_name):
                 s.enabled = True
     self._evaluator.scenario_repo = scenario_repo
     self._evaluator.scenario_repo.log_enabled_scenarios()
     self._evaluator.run_evaluator(action_mode)
コード例 #14
0
ファイル: evaluator_service.py プロジェクト: pczerkas/vitrage
    def _add_worker(self, enabled=False):
        """Create an EvaluatorWorker and it's task queue

        The new worker is initialized with a scenario repository
        that only contains a portion of the templates
        """
        scenario_repo = ScenarioRepository(self._conf,
                                           len(self._worker_queues),
                                           self._workers_num)
        tasks_queue = multiprocessing.JoinableQueue()
        w = EvaluatorWorker(self._conf, tasks_queue, self._entity_graph,
                            scenario_repo, enabled)
        self._p_launcher.launch_service(w)
        self._worker_queues.append(tasks_queue)
コード例 #15
0
    def setUpClass(cls):
        super(TemplateSyntaxValidatorTest, cls).setUpClass()

        cls.def_template_dir_path = utils.get_resources_dir() + \
            '/templates/def_template_tests'
        template_dir_path = '%s/templates/general' % utils.get_resources_dir()
        cls.version_dir_path = '%s/templates/version/' \
                               % utils.get_resources_dir()
        cls.template_yamls = file_utils.load_yaml_files(template_dir_path)
        cls.bad_template = \
            ScenarioRepository._load_template_file(template_dir_path
                                                   + '/' + BAD_YAML_PATH)
        cls.first_template = cls.template_yamls[0]

        cls._hide_useless_logging_messages()
コード例 #16
0
    def setUpClass(cls):
        super(TestConsistencyFunctional, cls).setUpClass()
        cls.initialization_status = InitializationStatus()
        cls.conf = cfg.ConfigOpts()
        cls.conf.register_opts(cls.CONSISTENCY_OPTS, group='consistency')
        cls.conf.register_opts(cls.PROCESSOR_OPTS, group='entity_graph')
        cls.conf.register_opts(cls.EVALUATOR_OPTS, group='evaluator')
        cls.conf.register_opts(cls.DATASOURCES_OPTS, group='datasources')
        cls.load_datasources(cls.conf)

        cls.processor = Processor(cls.conf, cls.initialization_status)
        cls.event_queue = queue.Queue()
        scenario_repo = ScenarioRepository(cls.conf)
        cls.evaluator = ScenarioEvaluator(cls.conf, cls.processor.entity_graph,
                                          scenario_repo, cls.event_queue)
        cls.consistency_enforcer = ConsistencyEnforcer(
            cls.conf, cls.event_queue, cls.evaluator,
            cls.processor.entity_graph, cls.initialization_status)
コード例 #17
0
ファイル: graph.py プロジェクト: pczerkas/vitrage
def main():
    """Starts all the Entity graph services

    1. Starts the Entity graph service
    2. Starts the api_handler service
    3. Starts the Consistency service
    """

    print(VITRAGE_TITLE)
    conf = service.prepare_service()
    e_graph = entity_graph.get_graph_driver(conf)('Entity Graph')
    launcher = os_service.ServiceLauncher(conf)
    full_scenario_repo = ScenarioRepository(conf)
    clear_db(conf)

    launcher.launch_service(VitrageGraphService(conf, e_graph))

    launcher.launch_service(
        VitrageApiHandlerService(conf, e_graph, full_scenario_repo))

    launcher.launch_service(VitrageConsistencyService(conf, e_graph))

    launcher.wait()
コード例 #18
0
 def setUp(self):
     super(RegExTemplateTest, self).setUp()
     templates_dir = utils.get_resources_dir() + '/templates/regex'
     self.add_db()
     self.add_templates(templates_dir)
     self.scenario_repository = ScenarioRepository()
コード例 #19
0
 def setUpClass(cls):
     super(RegExTemplateTest, cls).setUpClass()
     cls.conf = cfg.ConfigOpts()
     cls.conf.register_opts(cls.OPTS, group='evaluator')
     cls.scenario_repository = ScenarioRepository(cls.conf)
コード例 #20
0
ファイル: workers.py プロジェクト: ropodaing/vitrage
 def _reload_templates(self):
     LOG.info("reloading evaluator scenarios")
     scenario_repo = ScenarioRepository(self._conf, self.worker_id,
                                        self._workers_num)
     self._evaluator.scenario_repo = scenario_repo
     self._evaluator.scenario_repo.log_enabled_scenarios()