Example #1
0
class ExperimentSuiteServer(BaseServer):
    def __init__(self, root_dir, log_level, 
            xml, repetitions, duration, wait_guids, 
            communication = DC.ACCESS_LOCAL,
            host = None, 
            port = None, 
            user = None, 
            ident_key = None, 
            agent = None,
            sudo = False, 
            environment_setup = "", 
            clean_root = False):
        super(ExperimentSuiteServer, self).__init__(root_dir, log_level, 
            environment_setup = environment_setup, clean_root = clean_root)
        access_config = AccessConfiguration()
        access_config.set_attribute_value(DC.ROOT_DIRECTORY, root_dir)
        access_config.set_attribute_value(DC.LOG_LEVEL, log_level)
        access_config.set_attribute_value(DC.DEPLOYMENT_ENVIRONMENT_SETUP, environment_setup)
        if user:
            access_config.set_attribute_value(DC.DEPLOYMENT_USER, user)
        if host:
            access_config.set_attribute_value(DC.DEPLOYMENT_HOST, host)
        if port:
            access_config.set_attribute_value(DC.DEPLOYMENT_PORT, port)
        if agent:    
            access_config.set_attribute_value(DC.USE_AGENT, agent)
        if sudo:
            acess_config.set_attribute_value(DC.USE_SUDO, sudo)
        if ident_key:
            access_config.set_attribute_value(DC.DEPLOYMENT_KEY, ident_key)
        if communication:
            access_config.set_attribute_value(DC.DEPLOYMENT_COMMUNICATION, communication)
        if clean_root:
            access_config.set_attribute_value(DC.CLEAN_ROOT, clean_root)
        self._experiment_xml = xml
        self._duration = duration
        self._repetitions = repetitions
        self._wait_guids = wait_guids
        self._access_config = access_config
        self._experiment_suite = None

    def post_daemonize(self):
        from nepi.core.execute import ExperimentSuite
        self._experiment_suite = ExperimentSuite(
                self._experiment_xml, self._access_config, 
                self._repetitions, self._duration, self._wait_guids)

    @Marshalling.handles(CURRENT)
    @Marshalling.args()
    @Marshalling.retval(int)
    def current(self):
        return self._experiment_suite.current()
   
    @Marshalling.handles(STATUS)
    @Marshalling.args()
    @Marshalling.retval(int)
    def status(self):
        return self._experiment_suite.status()
    
    @Marshalling.handles(FINISHED)
    @Marshalling.args()
    @Marshalling.retval(Marshalling.bool)
    def is_finished(self):
        return self._experiment_suite.is_finished()

    @Marshalling.handles(ACCESS_CONFIGURATIONS)
    @Marshalling.args()
    @Marshalling.retval( Marshalling.pickled_data )
    def get_access_configurations(self):
        return self._experiment_suite.get_access_configurations()

    @Marshalling.handles(START)
    @Marshalling.args()
    @Marshalling.retvoid
    def start(self):
        self._experiment_suite.start()

    @Marshalling.handles(SHUTDOWN)
    @Marshalling.args()
    @Marshalling.retvoid
    def shutdown(self):
        self._experiment_suite.shutdown()

    @Marshalling.handles(CURRENT_ACCESS_CONFIG)
    @Marshalling.args()
    @Marshalling.retval( Marshalling.pickled_data )
    def get_current_access_config(self):
        return self._experiment_suite.get_current_access_config()