def is_admin_context(context): """Indicates if the request context is an administrator.""" if not context: LOG.warning(_LW('Use of empty request context is deprecated'), DeprecationWarning) raise Exception('die') return context.is_admin
def kill(self): """Destroy the service object in the datastore.""" self.stop() try: db.service_destroy(context.get_admin_context(), self.service_id) except exception.NotFound: LOG.warning(_LW('Service killed that has no database entry'))
def execute_operation(self, operation_id, triggered_time, expect_start_time, window_time, **kwargs): if self._check_operation(operation_id, self._CHECK_ITEMS.values()): LOG.warn(_LW("Execute operation(%s), it can't be executed"), operation_id) return end_time_for_run = expect_start_time + timedelta(seconds=window_time) ret = self._update_operation_state( operation_id, { 'state': constants.OPERATION_STATE_TRIGGERED, 'end_time_for_run': end_time_for_run }) if not ret: return param = { 'operation_id': operation_id, 'triggered_time': triggered_time, 'expect_start_time': expect_start_time, 'window_time': window_time, 'run_type': constants.OPERATION_RUN_TYPE_EXECUTE } self._execute_operation(operation_id, self._run_operation, param)
def wrapped(*args, **kwargs): while True: try: return f(*args, **kwargs) except db_exc.DBDeadlock: LOG.warning(_LW("Deadlock detected when running " "'%(func_name)s': Retrying..."), dict(func_name=f.__name__)) # Retry! time.sleep(0.5) continue
def wrapped(*args, **kwargs): while True: try: return f(*args, **kwargs) except db_exc.DBDeadlock: LOG.warning( _LW("Deadlock detected when running " "'%(func_name)s': Retrying..."), dict(func_name=f.__name__)) # Retry! time.sleep(0.5) continue
def basic_config_check(self): """Perform basic config checks before starting service.""" # Make sure report interval is less than service down time if self.report_interval: if CONF.service_down_time <= self.report_interval: new_down_time = int(self.report_interval * 2.5) LOG.warning( _LW("Report interval must be less than service down " "time. Current config service_down_time: " "%(service_down_time)s, report_interval for this: " "service is: %(report_interval)s. Setting global " "service_down_time to: %(new_down_time)s"), {'service_down_time': CONF.service_down_time, 'report_interval': self.report_interval, 'new_down_time': new_down_time}) CONF.set_override('service_down_time', new_down_time)
def execute_operation(self, operation_id, triggered_time, expect_start_time, window_time, **kwargs): if self._check_operation(operation_id, self._CHECK_ITEMS.values()): LOG.warn(_LW("Execute operation(%s), it can't be executed"), operation_id) return end_time_for_run = expect_start_time + timedelta(seconds=window_time) ret = self._update_operation_state( operation_id, {'state': constants.OPERATION_STATE_TRIGGERED, 'end_time_for_run': end_time_for_run}) if not ret: return param = { 'operation_id': operation_id, 'triggered_time': triggered_time, 'expect_start_time': expect_start_time, 'window_time': window_time, 'run_type': constants.OPERATION_RUN_TYPE_EXECUTE } self._execute_operation(operation_id, self._run_operation, param)