Exemplo n.º 1
0
def main():
    LOG.info('Watcher sync started.')

    service.prepare_service(sys.argv, CONF)
    syncer = sync.Syncer()
    syncer.sync()

    LOG.info('Watcher sync finished.')
Exemplo n.º 2
0
def main():
    watcher_service.prepare_service(sys.argv, CONF)
    gmr.register_gmr_plugins()

    LOG.info('Starting Watcher Decision Engine service in PID %s', os.getpid())

    syncer = sync.Syncer()
    syncer.sync()

    de_service = watcher_service.Service(manager.DecisionEngineManager)
    bg_scheduler_service = scheduling.DecisionEngineSchedulingService()

    # Only 1 process
    launcher = watcher_service.launch(CONF, de_service)
    launcher.launch_service(bg_scheduler_service)

    launcher.wait()
Exemplo n.º 3
0
    def setUp(self):
        super(TestSyncer, self).setUp()
        self.ctx = context.make_context()

        # This mock simulates the strategies discovery done in discover()
        self.m_available_strategies = mock.Mock(
            return_value={
                fake_strategies.FakeDummy1Strategy1.get_name():
                fake_strategies.FakeDummy1Strategy1,
                fake_strategies.FakeDummy1Strategy2.get_name():
                fake_strategies.FakeDummy1Strategy2,
                fake_strategies.FakeDummy2Strategy3.get_name():
                fake_strategies.FakeDummy2Strategy3,
                fake_strategies.FakeDummy2Strategy4.get_name():
                fake_strategies.FakeDummy2Strategy4,
            })

        self.m_available_goals = mock.Mock(
            return_value={
                fake_goals.FakeDummy1.get_name(): fake_goals.FakeDummy1,
                fake_goals.FakeDummy2.get_name(): fake_goals.FakeDummy2,
            })

        self.goal1_spec = fake_goals.FakeDummy1(
            config=mock.Mock()).get_efficacy_specification()
        self.goal2_spec = fake_goals.FakeDummy2(
            config=mock.Mock()).get_efficacy_specification()

        p_goals_load = mock.patch.object(
            default.DefaultGoalLoader,
            'load',
            side_effect=lambda goal: self.m_available_goals()[goal]())
        p_goals = mock.patch.object(default.DefaultGoalLoader,
                                    'list_available', self.m_available_goals)
        p_strategies = mock.patch.object(default.DefaultStrategyLoader,
                                         'list_available',
                                         self.m_available_strategies)

        p_goals.start()
        p_goals_load.start()
        p_strategies.start()

        self.syncer = sync.Syncer()
        self.addCleanup(p_goals.stop)
        self.addCleanup(p_goals_load.stop)
        self.addCleanup(p_strategies.stop)