Exemplo n.º 1
0
 def drainstatuses(self):
     """
     :returns: An object (dictionary) of drain statuses of sites
     :rtype: JSON
     """
     return {sitename: drain for sitename, _, drain in \
                 sitereadiness.i_site_readiness()}
Exemplo n.º 2
0
 def test_site_readiness(self):
     for site, stat, drain in sr.i_site_readiness():
         self.assertNotEqual(sr.site_readiness(site), 'none',
                             'Site not found: %s' % site)
         self.assertEqual(sr.site_readiness(site), stat,
                          'Inconsistent result: %s' % site)
         self.assertEqual(stat in ['green', 'yellow', 'red'], True,
                          'Status is not valid: %s' % site)
         self.assertEqual(drain in ['enabled', 'disabled', 'drain', 'test'],
                          True, 'Drain status is not valid: %s' % site)
Exemplo n.º 3
0
 def test_site_readiness(self):
     for site, stat, drain in sr.i_site_readiness():
         self.assertNotEqual(sr.site_readiness(site), 'none',
                             'Site not found: %s' % site)
         self.assertEqual(sr.site_readiness(site), stat,
                          'Inconsistent result: %s' % site)
         self.assertEqual(stat in ['green', 'yellow', 'red'], True,
                          'Status is not valid: %s' % site)
         self.assertEqual(drain in ['enabled', 'disabled', 'drain', 'test'], True,
                          'Drain status is not valid: %s' % site)
Exemplo n.º 4
0
    def sitestatuses(self):
        """
        :returns: An object (dictionary) of drain statuses of sites
        :rtype: JSON
        """

        self.readinesslock.acquire()

        try:
            if self.site_statuses is None:
                self.site_statuses = [{
                    'site': site,
                    'status': status,
                    'drain': drain
                } for site, status, drain in sitereadiness.i_site_readiness()]
        finally:
            self.readinesslock.release()

        return self.site_statuses
Exemplo n.º 5
0
    def submitaction(self, workflows='', action='', **kwargs):
        """Submits the action to Unified and notifies the user that this happened

        :param str workflows: is a list of workflows to apply the action to
        :param str action: is the suggested action for Unified to take
        :param kwargs: can include various reasons and additional datasets
        :returns: a confirmation page
        :rtype: str
        """

        cherrypy.log('args: {0}'.format(kwargs))

        if workflows == '':
            return render('scolduser.html', workflow='')

        if action == '':
            return render('scolduser.html', workflow=workflows[0])

        output = ''

        self.seeworkflowlock.acquire()
        try:

            workflows, reasons, params = manageactions.\
                submitaction(cherrypy.request.login, workflows, action, cherrypy.session,
                             **kwargs)

            # Immediately get actions to check the sites list
            check_actions = manageactions.get_actions()
            blank_sites_subtask = []
            sites_to_run = {}
            # Loop through all workflows just submitted
            for workflow in workflows:
                # Check sites of recovered workflows
                if check_actions[workflow]['Action'] in ['acdc', 'recovery']:
                    for subtask, params in check_actions[workflow][
                            'Parameters'].items():
                        # Empty sites are noted
                        if not params.get('sites'):
                            blank_sites_subtask.append('/%s/%s' %
                                                       (workflow, subtask))
                            sites_to_run['/%s/%s' % (workflow, subtask)] = \
                                globalerrors.check_session(cherrypy.session).\
                                get_workflow(workflow).site_to_run(subtask)

            if blank_sites_subtask:
                drain_statuses = {sitename: drain for sitename, _, drain in \
                                      sitereadiness.i_site_readiness()}
                output = render('picksites.html',
                                tasks=blank_sites_subtask,
                                statuses=drain_statuses,
                                sites_to_run=sites_to_run)

            else:
                output = render('actionsubmitted.html',
                                workflows=workflows,
                                action=action,
                                reasons=reasons,
                                params=params,
                                user=cherrypy.request.login)

        finally:
            self.seeworkflowlock.release()

        return output
Exemplo n.º 6
0
    def seeworkflow(self, workflow='', issuggested=''):
        """
        Located at ``https://localhost:8080/seeworkflow``,
        this shows detailed tables of errors for each step in a workflow.

        For the exit codes in each row, there is a link to view some of the output
        of the error message for jobs having the given exit code.
        This should help operators understand what the error means.

        At the top of the page, there are links back for :ref:`global-view-ref`,
        workflow logs, related JIRA tickets,
        and ReqMgr2 information about the workflow and prep ID.

        The main function of this page is to submit actions.
        Note that you will need to register in order to actually submit actions.
        See :ref:`new-user-ref` for more details.
        Depending on which action is selected, a menu will appear
        for the operator to adjust parameters for the workflows.

        Under the selection of the action and parameters, there is a button
        to show other workflows that are similar to the selected workflow,
        according to the :ref:`clustering-ref`.
        Each entry is a link to open a similar workflow view page in a new tab.
        The option to submit actions will not be on this page though
        (so that you can focus on the first workflow).
        If you think that a workflow in the cluster should have the same actions
        applied to it as the parent workflow,
        then check the box next to the workflow name before submitting the action.

        Finally, before submitting, you can submit reasons for your action selection.
        Clicking the Add Reason button will give you an additional reason field.
        Reasons submitted are stored based on the short reason you give.
        You can then select past reasons from the drop down menu to save time in the future.
        If you do not want to store your reason, do not fill in the Short Reason field.
        The long reason will be used for logging
        and communicating with the workflow requester (eventually).

        :param str workflow: is the name of the workflow to look at
        :param str issuggested: is a string to tell if the page
                                has been linked from another workflow page
        :returns: the error tables page for a given workflow
        :rtype: str
        :raises: 404 if a workflow doesn't seem to be in assistance anymore
                 Resets personal cache in the meanwhile, just in case
        """

        self.seeworkflowlock.acquire()

        output = ''

        try:
            if workflow not in \
                    globalerrors.check_session(
                            cherrypy.session, can_refresh=True).return_workflows():
                WorkflowTools.RESET_LOCK.acquire()
                info = globalerrors.check_session(cherrypy.session)
                if info:
                    info.teardown()
                    info.setup()
                WorkflowTools.RESET_LOCK.release()

                raise cherrypy.HTTPError(404)

            workflowdata = globalerrors.see_workflow(workflow,
                                                     cherrypy.session)

            drain_statuses = {sitename: drain for sitename, _, drain in \
                                  sitereadiness.i_site_readiness()}

            output = render(
                'workflowtables.html',
                workflowdata=workflowdata,
                workflow=workflow,
                issuggested=issuggested,
                workflowinfo=globalerrors.check_session(
                    cherrypy.session).get_workflow(workflow),
                readiness=globalerrors.check_session(
                    cherrypy.session).readiness,
                drain_statuses=drain_statuses,
                last_submitted=manageactions.get_datetime_submitted(workflow))
        finally:
            self.seeworkflowlock.release()

        return output