Exemple #1
0
 def update(self,
            status,
            namespace,
            operation,
            operation_name,
            details,
            progress,
            owner_href,
            owner_name,
            owner_type,
            user_href,
            user_name,
            org_href=None,
            task_href=None,
            error_message=None):
     t = E.Task(status=status,
                serviceNamespace=namespace,
                type=EntityType.TASK.value,
                operation=operation,
                operationName=operation_name,
                name='task')
     t.append(E.Owner(href=owner_href, name=owner_name, type=owner_type))
     if error_message is not None:
         t.append(
             E.Error(stackTrace='',
                     majorErrorCode='500',
                     message=error_message,
                     minorErrorCode='INTERNAL_SERVER_ERROR'))
     t.append(
         E.User(href=user_href, name=user_name, type=EntityType.USER.value))
     if progress is not None:
         t.append(E.Progress(progress))
     t.append(E.Details(details))
     if task_href is None:
         org_resource = self.client.get_resource(org_href)
         link = find_link(org_resource, RelationType.DOWN,
                          EntityType.TASKS_LIST.value)
         return self.client.post_resource(link.href, t,
                                          EntityType.TASK.value)
     else:
         return self.client.put_resource(task_href, t,
                                         EntityType.TASK.value)
Exemple #2
0
    def update(self,
               status,
               namespace,
               operation,
               operation_name,
               details,
               progress,
               owner_href,
               owner_name,
               owner_type,
               user_href,
               user_name,
               org_href=None,
               task_href=None,
               error_message=None):
        """Update a task in vCD.

        :param str status: new status of the task.
        :param str namespace: identifier of the service that created the task.
            It must not start with com.vmware.vcloud and the length must be
            between 1 and 128 symbols.
        :param str operation: new message describing the operation that is
            being tracked by this task.
        :param str operation_name: new short name of the operation that is
            being tracked by the task.
        :param details: new detailed message about the task.
        :param str progress: read-only indicator of task progress as an
            approximate percentage between 0 and 100. Not available for all
            tasks.
        :param str owner_href: href of the owner of the task. This is typically
            the object that the task is creating or updating.
        :param str owner_name: name of the owner of the task.
        :param str owner_type: XML type of the owner object
        :param str user_href: href of the user who started the task.
        :param str user_name: name of the user who started the task.
        :param str org_href: href of the organization, which the user mentioned
            above belongs to.
        :param str task_href: href of the task.
        :param str error_message: represents error information from a failed
            task.

        :return: an object containing EntityType.TASK XML data representing the
            updated task.

        :rtype: lxml.objectify.ObjectifiedElement
        """
        t = E.Task(status=status,
                   serviceNamespace=namespace,
                   type=EntityType.TASK.value,
                   operation=operation,
                   operationName=operation_name,
                   name='task')
        t.append(E.Owner(href=owner_href, name=owner_name, type=owner_type))
        if error_message is not None:
            t.append(
                E.Error(stackTrace='',
                        majorErrorCode='500',
                        message=error_message,
                        minorErrorCode='INTERNAL_SERVER_ERROR'))
        t.append(
            E.User(href=user_href, name=user_name, type=EntityType.USER.value))
        if progress is not None:
            t.append(E.Progress(progress))
        t.append(E.Details(details))
        if task_href is None:
            org_resource = self.client.get_resource(org_href)
            link = find_link(org_resource, RelationType.DOWN,
                             EntityType.TASKS_LIST.value)
            return self.client.post_resource(link.href, t,
                                             EntityType.TASK.value)
        else:
            return self.client.put_resource(task_href, t,
                                            EntityType.TASK.value)