Esempio n. 1
0
 def check_plugin_app_exec_status(self, plugin_inst, **kwargs):
     """
     Check a plugin's app execution status. It connects to the remote
     service to determine job status.
     """
     # pudb.set_trace()
     chris2service = charm.Charm(plugin_inst=plugin_inst, **kwargs)
     chris2service.app_statusCheckAndRegister()
Esempio n. 2
0
 def check_plugin_app_exec_status(plugin_inst):
     """
     Check a plugin's app execution status. It connects to the remote
     service to determine job status.
     """
     # pudb.set_trace()
     chris_service = charm.Charm(plugin_inst=plugin_inst)
     str_responseStatus = chris_service.app_statusCheckAndRegister()
     return str_responseStatus
Esempio n. 3
0
 def shutdown_apps_exec_server(self, **kwargs):
     """
     Shutdown a remote server instance
     :return:
     """
     # pudb.set_trace()
     chris_service   = charm.Charm(**kwargs)
     chris_service.app_service_shutdown(**kwargs)
     # Wait a bit for transients
     time.sleep(5)
Esempio n. 4
0
 def check_apps_exec_server(self, **kwargs):
     """
     check if a remote server instance is servicing requests
     :return:
     """
     # pudb.set_trace()
     chris_service = charm.Charm(**kwargs)
     chris_service.app_service_checkIfAvailable(**kwargs)
     # Wait a bit for transients
     time.sleep(5)
Esempio n. 5
0
    def test_plugin_instance_detail_success(self):

        user = User.objects.get(username=self.username)
        plugin = Plugin.objects.get(name="pacspull")
        (pl_inst, tf) = PluginInstance.objects.get_or_create(plugin=plugin,
                                                             owner=user)
        # pudb.set_trace()
        pl_manager = PluginManager()
        pl_manager.check_apps_exec_server(clearDB=True)

        chris2service = charm.Charm(d_args={'dir': './'},
                                    plugin_inst=pl_inst,
                                    plugin_repr={
                                        'selfpath': '/bin',
                                        'selfexec': 'ls',
                                        'execshell': ''
                                    })

        chris2service.app_manage(method='pfcon')
        time.sleep(5)

        self.client.login(username=self.username, password=self.password)
        response = self.client.get(self.read_url)
        self.assertContains(response, "pacspull")
Esempio n. 6
0
    def run_plugin_app(self, plugin_inst, parameter_dict, **kwargs):
        """
        Run a plugin's app.
        """

        # These directory overrides allow for mapping from the original ChRIS dir space
        # to the plugin input and output dir spaces.
        str_inputDirOverride        = ''
        str_outputDirOverride       = ''
        str_IOPhost                 = ''

        for k, v in kwargs.items():
            if k == 'useDebug':             self.b_useDebug         = v
            if k == 'debugFile':            self.str_debugFile      = v
            if k == 'quiet':                self.b_quiet            = v
            if k == 'service':              self.str_service        = v
            if k == 'inputDirOverride':     str_inputDirOverride    = v
            if k == 'outputDirOverride':    str_outputDirOverride   = v
            if k == 'IOPhost':              self.str_IOPhost        = v

        # pudb.set_trace()

        plugin_repr = self.get_plugin_app_representation(plugin_inst.plugin.dock_image)
        # get input dir
        inputdir            = ""
        inputdirManagerFS   = ""
        if plugin_inst.previous:
            inputdirManagerFS   = plugin_inst.previous.get_output_path()
            inputdir            = inputdirManagerFS
        if len(str_inputDirOverride):
            inputdir = str_inputDirOverride
        # get output dir
        outputdirManagerFS      = plugin_inst.get_output_path()
        outputdir               = outputdirManagerFS
        if len(str_outputDirOverride):
            outputdir = str_outputDirOverride
        app_args = []
        # append input dir to app's argument list (only for ds plugins)
        if plugin_repr['type'] == 'ds' and inputdir:
            app_args.append(inputdir)
        # append output dir to app's argument list
        app_args.append(outputdir)
        # append flag to save input meta data (passed options)
        app_args.append("--saveinputmeta")
        # append flag to save output meta data (output description)
        app_args.append("--saveoutputmeta")
        # append the parameters to app's argument list
        if parameter_dict:
            for param_name in parameter_dict:
                param_value = parameter_dict[param_name]
                for plugin_param in plugin_repr['parameters']:
                    if plugin_param['name'] == param_name:
                        app_args.append(plugin_param['flag'])
                        if plugin_param['action'] == 'store':
                            app_args.append(param_value)
                        break

        # run the app via an external REST service...
        chris_service = charm.Charm(
            app_args    = app_args,
            d_args      = parameter_dict,
            plugin_inst = plugin_inst,
            plugin_repr = plugin_repr,
            inputdir    = inputdirManagerFS,
            outputdir   = outputdirManagerFS,
            IOPhost     = self.str_IOPhost
        )

        #
        # Some dev notes...
        #
        # To run the app directly on the CLI via 'crunner', use
        #         chris_service.app_manage(method = 'crunner')
        # Note that this call blocks until the CLI process returns.
        #
        # To run the app 'internally', i.e. not as a CLI but by calling the app 
        # run() method directly in python:
        #         chris_service.app_manage(method = 'internal')
        # Again, this blocks on the app run() method.
        #
        # The call to "method = 'pman'|'pfcon'" does not block but dispatches 
        # to a completely asynchronous external server process and returns 
        # immediately. The check on output is performed when views are updated,
        # again by talking to the application server.
        #

        chris_service.app_manage(method     = self.str_service,
                                 IOPhost    = self.str_IOPhost   )