Ejemplo n.º 1
0
    def _register_task_reference(self, task, step, task_id):
        if self.debug_mode:
            return None

        try:
            link_to_task = MONITORING_TASK_LINK_FORMAT % task_id
            link_to_request = MONITORING_REQUEST_LINK_FORMAT % step.request.id

            ticket_summary = "Task %d" % task_id
            ticket_description = \
                "Task Id: %d\nName: %s\nUser: %s\nManager: %s\nLink to the task: %s\nLink to the request: %s" % \
                (task_id, task['taskName'], task['userName'], step.request.manager, link_to_task, link_to_request)

            its = ITS()
            its.authorize()

            if not step.request.reference:
                logger.warning("The request %d has empty reference" % int(step.request.id))
                return None

            issue_key = its.create_sub_issue(step.request.reference, ticket_summary, ticket_description)

            return issue_key
        except Exception as ex:
            logger.info("Exception: %s" % str(ex))
            return None
Ejemplo n.º 2
0
    def add_task_comment(self, task_id, comment_body, user=None):
        try:
            task = ProductionTask.objects.get(id=task_id)
        except ProductionTask.DoesNotExist:
            logger.info("The task %d is not found" % task_id)
            return
        self._task_action_log(comment_body, user)
        try:
            if task.reference:
                its = ITS()
                its.authorize()
                its.add_issue_comment(task.reference, comment_body)
        except Exception:
            from deftcore.log import get_exception_string

            logger.info("Exception occurred: %s" % get_exception_string())
Ejemplo n.º 3
0
    def inspect_tickets(self):
        from django.db.models import Q
        from taskengine.models import ProductionTask
        from deftcore.its import ITS

        its = ITS()
        its.authorize()

        tasks = ProductionTask.objects.filter(~Q(project='user'),
                                              status__in=['finished', 'done', 'failed', 'broken', 'aborted'])

        for task in tasks:
            print "Processing task %s" % str(task.id)
            issue_key = task.reference
            if issue_key:
                try:
                    its.close_issue(issue_key, "Task is processed with status '%s'" % task.status)
                    print '*Issue %s closed' % issue_key
                except Exception as ex:
                    print "Exception occurred: %s" % str(ex)
Ejemplo n.º 4
0
class ITSTest(TestCase):
    def setUp(self):
        self.its = ITS()

    def test_its(self):
        try:
            sso_cookies = self.its.authorize()
        except Exception as ex:
            print "test_its, exception occurred (1): %s" % str(ex)
            sso_cookies = None

        self.assertNotEqual(sso_cookies, None)

        try:
            issue_key = self.its.create_issue("test issue", "[%s] deftcore.api.tests.test_its" % str(timezone.now()))
        except Exception as ex:
            print "test_its, exception occurred (2): %s" % str(ex)
            issue_key = None

        self.assertNotEqual(issue_key, None)

        logger.debug("test issue key = \"%s\"" % issue_key)

        try:
            result = self.its.add_issue_comment(issue_key, "test comment")
        except Exception as ex:
            print "test_its, exception occurred (3): %s" % str(ex)
            result = False

        self.assertTrue(result)

        try:
            result = self.its.delete_issue(issue_key)
        except Exception as ex:
            print "test_its, exception occurred (4): %s" % str(ex)
            result = False

        self.assertTrue(result)
Ejemplo n.º 5
0
    def register_request_reference(request, debug_mode=False):
        if debug_mode:
            return None

        try:
            if not request.reference:
                link_to_request = MONITORING_REQUEST_LINK_FORMAT % request.id

                ticket_summary = "Request %d" % request.id
                ticket_description = \
                    "Request Id: %d\nDescription: %s\nReference link: %s\nManager: %s\nLink to the request: %s" % \
                    (request.id, request.description, request.ref_link, request.manager, link_to_request)

                its = ITS()
                its.authorize()

                issue_key = its.create_issue(ticket_summary, ticket_description)

                request.reference = issue_key
                request.save()
            return request.reference
        except Exception as ex:
            logger.info("Exception: %s" % str(ex))
            return None
Ejemplo n.º 6
0
 def setUp(self):
     self.its = ITS()