def _set_monitor_stubs(self):
        self.mock_config = global_config.FakeGlobalConfig()
        self.god.stub_with(global_config, 'global_config', self.mock_config)

        # Clear the instance cache as this is a brand new database.
        scheduler_models.DBObject._clear_instance_cache()

        self._database = (
            database_connection.TranslatingDatabase.get_test_database(
                translators=scheduler_lib._DB_TRANSLATORS))
        self._database.connect(db_type='django')
        self._database.debug = _DEBUG

        connection_manager = scheduler_lib.ConnectionManager(autocommit=False)
        self.god.stub_with(connection_manager, 'db_connection', self._database)
        self.god.stub_with(monitor_db, '_db_manager', connection_manager)
        self.god.stub_with(monitor_db, '_db', self._database)

        self.god.stub_with(monitor_db.BaseDispatcher,
                           '_get_pending_queue_entries',
                           self._get_pending_hqes)
        self.god.stub_with(scheduler_models, '_db', self._database)
        self.god.stub_with(drone_manager.instance(), '_results_dir',
                           '/test/path')
        self.god.stub_with(drone_manager.instance(), '_temporary_directory',
                           '/test/path/tmp')
        self.god.stub_with(drone_manager.instance(), 'initialize',
                           lambda *args: None)
        self.god.stub_with(drone_manager.instance(), 'execute_actions',
                           lambda *args: None)

        monitor_db.initialize_globals()
        scheduler_models.initialize_globals()
 def __init__(self):
     self._drone_manager = drone_manager.instance()
     self.lost_process = False
     self._start_time = None
     self.pidfile_id = None
     self._killed = False
     self._state = drone_manager.PidfileContents()
Beispiel #3
0
    def __init__(self):
        address = ('', _PORT)
        # HTTPServer is an old-style class :(
        BaseHTTPServer.HTTPServer.__init__(self, address,
                                           StatusServerRequestHandler)
        self._shutting_down = False
        self._drone_manager = drone_manager.instance()

        # ensure the listening socket is not inherited by child processes
        old_flags = fcntl.fcntl(self.fileno(), fcntl.F_GETFD)
        fcntl.fcntl(self.fileno(), fcntl.F_SETFD, old_flags | fcntl.FD_CLOEXEC)
 def __init__(self, log_file_name=None):
     """
     @param log_file_name: (optional) name of file to log command output to
     """
     self._drone_manager = drone_manager.instance()
     self.done = False
     self.started = False
     self.success = None
     self.aborted = False
     self.monitor = None
     self.queue_entry_ids = []
     self.host_ids = []
     # A map between host id and hostname.
     self.hostnames = {}
     self._log_file_name = log_file_name
Beispiel #5
0
def initialize_globals():
    global _drone_manager
    _drone_manager = drone_manager.instance()
Beispiel #6
0
def initialize_globals():
    global _drone_manager
    _drone_manager = drone_manager.instance()