def modify_compute_resource(self, name, new_name, url, description,
                             maxjobexecsec):
     """
     Modify an existing compute resource and add the current date as a new
     modification date.
     """
     try:
         cr = ComputeResource.objects.get(name=name)
     except ComputeResource.DoesNotExist:
         raise NameError("Compute resource '%s' does not exists" % name)
     if new_name or url or description or maxjobexecsec:
         data = {}
         data['name'] = new_name if new_name else cr.name
         data['compute_url'] = url if url else cr.compute_url
         if description:
             data['description'] = description
         if maxjobexecsec:
             data['max_job_exec_seconds'] = maxjobexecsec
         compute_resource_serializer = ComputeResourceSerializer(cr,
                                                                 data=data)
         compute_resource_serializer.is_valid(raise_exception=True)
         cr = compute_resource_serializer.save()
         cr.modification_date = timezone.now()
         cr.save()
     return cr
Beispiel #2
0
 def add_compute_resource(self, name, description):
     """
     Add a new compute resource to the system.
     """
     # validate compute resource name
     try:
         cr = ComputeResource.objects.get(name=name)
     except ComputeResource.DoesNotExist:
         data = {'name': name, 'description': description}
         compute_resource_serializer = ComputeResourceSerializer(data=data)
         compute_resource_serializer.is_valid(raise_exception=True)
         cr = compute_resource_serializer.save()
     return cr
 def add_compute_resource(self, name, url, description, maxjobexecsec):
     """
     Add a new compute resource to the system.
     """
     # validate compute resource name
     try:
         cr = ComputeResource.objects.get(name=name)
     except ComputeResource.DoesNotExist:
         data = {
             'name': name,
             'compute_url': url,
             'description': description
         }
         if maxjobexecsec:
             data['max_job_exec_seconds'] = maxjobexecsec
         compute_resource_serializer = ComputeResourceSerializer(data=data)
         compute_resource_serializer.is_valid(raise_exception=True)
         cr = compute_resource_serializer.save()
     return cr
Beispiel #4
0
 def modify_compute_resource(self, name, new_name, description):
     """
     Modify an existing compute resource and add the current date as a new
     modification date.
     """
     try:
         cr = ComputeResource.objects.get(name=name)
     except ComputeResource.DoesNotExist:
         raise NameError("Compute resource '%s' does not exists" % name)
     if new_name or description:
         data = {'name': cr.name, 'description': cr.description}
         if new_name:
             data['name'] = new_name
         if description:
             data['description'] = description
         compute_resource_serializer = ComputeResourceSerializer(cr,
                                                                 data=data)
         compute_resource_serializer.is_valid(raise_exception=True)
         cr = compute_resource_serializer.save()
         cr.modification_date = timezone.now()
         cr.save()
     return cr