[haizea-commit] r618 - in branches/TP2.0/src/haizea: cli core

haizea-commit at mailman.cs.uchicago.edu haizea-commit at mailman.cs.uchicago.edu
Thu Jul 30 12:30:18 CDT 2009


Author: borja
Date: 2009-07-30 12:30:12 -0500 (Thu, 30 Jul 2009)
New Revision: 618

Modified:
   branches/TP2.0/src/haizea/cli/rpc_commands.py
   branches/TP2.0/src/haizea/core/leases.py
Log:
Allow Timestamp to express "now", as well as "undefined" (best-effort) and an exact timestamp.

Modified: branches/TP2.0/src/haizea/cli/rpc_commands.py
===================================================================
--- branches/TP2.0/src/haizea/cli/rpc_commands.py	2009-07-28 18:09:02 UTC (rev 617)
+++ branches/TP2.0/src/haizea/cli/rpc_commands.py	2009-07-30 17:30:12 UTC (rev 618)
@@ -125,7 +125,7 @@
                 lease = Lease.create_new(
                               submit_time = None,
                               requested_resources = requested_resources, 
-                              start = Timestamp(None),
+                              start = Timestamp(Timestamp.NOW),
                               duration = Duration(duration),
                               deadline = None, 
                               preemptible=preemptible,
@@ -135,7 +135,7 @@
                 lease = Lease.create_new(
                               submit_time = None,
                               requested_resources = requested_resources, 
-                              start = Timestamp(None),
+                              start = Timestamp(Timestamp.UNSPECIFIED),
                               duration = Duration(duration),
                               deadline = None, 
                               preemptible=preemptible,

Modified: branches/TP2.0/src/haizea/core/leases.py
===================================================================
--- branches/TP2.0/src/haizea/core/leases.py	2009-07-28 18:09:02 UTC (rev 617)
+++ branches/TP2.0/src/haizea/core/leases.py	2009-07-30 17:30:12 UTC (rev 618)
@@ -260,12 +260,13 @@
         
         start = element.find("start")
         if len(start.getchildren()) == 0:
-            start = Timestamp(None)
+            start = Timestamp(Timestamp.UNSPECIFIED)
         else:
-            exact = start.find("exact")
-            if exact != None:
-                start = Timestamp(Parser.DateTimeFromString(exact.get("time")))
-            # TODO: Other starting times
+            child = start[0]
+            if child.tag == "now":
+                start = Timestamp(Timestamp.NOW)
+            elif child.tag == "exact":
+                start = Timestamp(Parser.DateTimeFromString(child.get("time")))
         
         duration = Duration(Parser.DateTimeDeltaFromString(element.find("duration").get("time")))
 
@@ -353,8 +354,10 @@
         Lease.IMMEDIATE
         
         """
-        if self.start.requested == None:
+        if self.start.requested == Timestamp.UNSPECIFIED:
             return Lease.BEST_EFFORT
+        elif self.start.requested == Timestamp.NOW:
+            return Lease.IMMEDIATE            
         else:
             return Lease.ADVANCE_RESERVATION
         
@@ -788,6 +791,10 @@
         """        
         return not self == other
             
+    def __repr__(self):
+        """Returns a string representation of the Capacity"""
+        return "  |  ".join("%s: %i" % (type,q[0]) for type, q in self.quantity.items())
+            
 
 class Timestamp(object):
     """An exact point in time.
@@ -799,6 +806,10 @@
     (which could differ from the requested one) and the
     actual timestamp (which could differ from the scheduled one).
     """        
+    
+    UNSPECIFIED = "none"
+    NOW = "now"
+    
     def __init__(self, requested):
         """Constructor
                         



More information about the Haizea-commit mailing list