Esempio n. 1
0
    def handle_request(self, action):
        try:
            cs = ContainerSnapshot(bootstrap.container_instance)
            if action.clear_all:
                cs.clear_snapshots()
                log.info(
                    "Container %s snapshot cleared (id=%s)"
                    % (bootstrap.container_instance.id, bootstrap.container_instance.proc_manager.cc_id)
                )
                return

            cs.take_snapshot(
                snapshot_id=action.snapshot_id,
                snapshot_kwargs=action.snapshot_kwargs,
                include_list=action.include_snapshots,
                exclude_list=action.exclude_snapshots,
            )
            if action.persist_snapshot:
                cs.persist_snapshot()
                log.info(
                    "Container %s snapshot persisted (id=%s)"
                    % (bootstrap.container_instance.id, bootstrap.container_instance.proc_manager.cc_id)
                )
            else:
                cs.log_snapshot()
        except Exception as ex:
            log.warn("Error taking container snapshot", exc_info=True)
Esempio n. 2
0
def bootstrap_pyon(logging_config_override=None, pyon_cfg=None):
    """
    This function initializes the core elements of the Pyon framework in a controlled way.
    It does not initialize the ION container or the ION system.
    @param logging_config_override  A dict to initialize the Python logging subsystem (None loads default files)
    @param pyon_cfg   A DotDict with the fully loaded pyon configuration to merge into CFG (None loads default files)
    """
    log.info("pyon.bootstrap (bootstrap_pyon) executing...")

    # Make sure Pyon is only initialized only once
    global pyon_initialized
    if pyon_initialized:
        log.warn("WARNING -- bootstrap_pyon() called again!")
        return

    # ENVIRONMENT. Check we are called in an expected environment (files, directories, etc)
    assert_environment()

    # LOGGING. Initialize logging from config
    if not logutil.is_logging_configured():
        logutil.configure_logging(
            logutil.DEFAULT_LOGGING_PATHS,
            logging_config_override=logging_config_override)

    # YAML patch: OrderedDicts instead of dicts
    from pyon.util.yaml_ordered_dict import apply_yaml_patch
    apply_yaml_patch()

    # CONFIG. Initialize pyon global configuration from local files
    set_config(pyon_cfg)
    log.debug("CFG set to %s", CFG)

    # OBJECTS. Object and message definitions.
    from pyon.core.registry import IonObjectRegistry
    global _obj_registry
    _obj_registry = IonObjectRegistry()

    # SERVICES. Service definitions
    # TODO: change the following to read service definitions from directory and import selectively
    from pyon.ion.service import IonServiceRegistry
    import interface.services
    global _service_registry
    _service_registry = IonServiceRegistry()
    _service_registry.load_service_mods(interface.services)
    _service_registry.build_service_map()

    # RESOURCES. Load and initialize definitions
    from pyon.ion import resource
    resource.load_definitions()

    # Fix a weird bug on Ubuntu that resets time.sleep to un-monkey patched version on import threading
    from gevent import monkey
    monkey.patch_time()

    # Set initialized flag
    pyon_initialized = True
    log.debug("Pyon initialized OK")
Esempio n. 3
0
def bootstrap_pyon(logging_config_override=None, pyon_cfg=None):
    """
    This function initializes the core elements of the Pyon framework in a controlled way.
    It does not initialize the ION container or the ION system.
    @param logging_config_override  A dict to initialize the Python logging subsystem (None loads default files)
    @param pyon_cfg   A DotDict with the fully loaded pyon configuration to merge into CFG (None loads default files)
    """
    log.info("pyon.bootstrap (bootstrap_pyon) executing...")

    # Make sure Pyon is only initialized only once
    global pyon_initialized
    if pyon_initialized:
        log.warn("WARNING -- bootstrap_pyon() called again!")
        return

    # ENVIRONMENT. Check we are called in an expected environment (files, directories, etc)
    assert_environment()

    # LOGGING. Initialize logging from config
    if not logutil.is_logging_configured():
        logutil.configure_logging(logutil.DEFAULT_LOGGING_PATHS, logging_config_override=logging_config_override)

    # YAML patch: OrderedDicts instead of dicts
    from pyon.util.yaml_ordered_dict import apply_yaml_patch
    apply_yaml_patch()

    # CONFIG. Initialize pyon global configuration from local files
    set_config(pyon_cfg)
    log.debug("CFG set to %s", CFG)

    # OBJECTS. Object and message definitions.
    from pyon.core.registry import IonObjectRegistry
    global _obj_registry
    _obj_registry = IonObjectRegistry()

    # SERVICES. Service definitions
    # TODO: change the following to read service definitions from directory and import selectively
    from pyon.ion.service import IonServiceRegistry
    import interface.services
    global _service_registry
    _service_registry = IonServiceRegistry()
    _service_registry.load_service_mods(interface.services)
    _service_registry.build_service_map()

    # RESOURCES. Load and initialize definitions
    from pyon.ion import resource
    resource.load_definitions()

    # Fix a weird bug on Ubuntu that resets time.sleep to un-monkey patched version on import threading
    from gevent import monkey; monkey.patch_time()

    # Set initialized flag
    pyon_initialized = True
    log.debug("Pyon initialized OK")
Esempio n. 4
0
 def _perform_action(self, action):
     handlers = self._get_handlers(action)
     if not handlers:
         log.info('action accepted but no handlers found: %s', action)
         result = 'unhandled'
         self.sender.publish_event(origin=self.container.id, action=action, outcome=str(result))
         log.debug('received action: %s, outcome: %s', action, result)
     else:
         for handler in handlers:
             try:
                 result = handler.handle_request(action) or "completed"
             except Exception,e:
                 log.error("handler %r failed to perform action: %s", handler, action, exc_info=True)
                 result = e
             self.sender.publish_event(origin=self.container.id, action=action, outcome=str(result))
             log.debug('performed action: %s, outcome: %s', action, result)
Esempio n. 5
0
 def _perform_action(self, action):
     handlers = self._get_handlers(action)
     if not handlers:
         log.info("action accepted but no handlers found: %s", action)
         result = "unhandled"
         self.sender.publish_event(origin=self.container.id, action=action, outcome=str(result))
         log.debug("received action: %s, outcome: %s", action, result)
     else:
         for handler in handlers:
             try:
                 result = handler.handle_request(action) or "completed"
             except Exception, e:
                 log.error("handler %r failed to perform action: %s", handler, action, exc_info=True)
                 result = e
             self.sender.publish_event(origin=self.container.id, action=action, outcome=str(result))
             log.debug("performed action: %s, outcome: %s", action, result)
Esempio n. 6
0
    def handle_request(self, action):
        try:
            cs = ContainerSnapshot(bootstrap.container_instance)
            if action.clear_all:
                cs.clear_snapshots()
                log.info("Container %s snapshot cleared (id=%s)" % (bootstrap.container_instance.id,
                                                                    bootstrap.container_instance.proc_manager.cc_id))
                return

            cs.take_snapshot(snapshot_id=action.snapshot_id, snapshot_kwargs=action.snapshot_kwargs,
                             include_list=action.include_snapshots, exclude_list=action.exclude_snapshots)
            if action.persist_snapshot:
                cs.persist_snapshot()
                log.info("Container %s snapshot persisted (id=%s)" % (bootstrap.container_instance.id,
                                                                      bootstrap.container_instance.proc_manager.cc_id))
            else:
                cs.log_snapshot()
        except Exception as ex:
            log.warn("Error taking container snapshot", exc_info=True)
Esempio n. 7
0
def set_sys_name(sysname=None):
    global sys_name
    old_sys_name = sys_name
    sys_name = sysname
    log.info("pyon: sys_name changed from '%s' to '%s'", old_sys_name, sys_name)
Esempio n. 8
0
def set_sys_name(sysname=None):
    global sys_name
    old_sys_name = sys_name
    sys_name = sysname
    log.info("sys_name changed from '%s' to '%s'", old_sys_name, sys_name)