Fix policy effectiveness period
authorChristos KK Loverdos <loverdos@gmail.com>
Thu, 14 Jun 2012 13:40:43 +0000 (16:40 +0300)
committerChristos KK Loverdos <loverdos@gmail.com>
Thu, 14 Jun 2012 13:40:43 +0000 (16:40 +0300)
Previously, the policy loaded from policy.yaml was taken to be effective
starting from the time the loading happended. Normally, we need to set
a proper effectivess period for the policy. Until then and in order for
some other test cases to proceed, we consider a better starting time.

src/main/scala/gr/grnet/aquarium/logic/accounting/Policy.scala
src/main/scala/gr/grnet/aquarium/logic/accounting/dsl/DSLPolicy.scala

index 6b600c5..be6f4c6 100644 (file)
@@ -192,8 +192,7 @@ object Policy extends DSL with Loggable {
     if (updated) {
       val ts = TimeHelpers.nowMillis()
       val parsedNew = loadPolicyFromFile(policyf)
-      val newPolicy = parsedNew.toPolicyEntry.copy(occurredMillis = ts,
-        receivedMillis = ts, validFrom = ts)
+      val newPolicy = parsedNew.toPolicyEntry
 
       config.policyStore.findPolicyEntry(newPolicy.id) match {
         case Some(x) =>
index a7b48e9..dd27c9e 100644 (file)
@@ -91,10 +91,11 @@ case class DSLPolicy (
 
   def toPolicyEntry: PolicyEntry = {
     val yaml = toYAML
-    val ts = TimeHelpers.nowMillis()
-    PolicyEntry(CryptoUtils.sha1(yaml), ts, ts, yaml, ts + 1, Long.MaxValue)
+    val now = TimeHelpers.nowMillis()
+    // FIXME: Define proper validity period instead of [0L, Long.MaxValue)
+    PolicyEntry(CryptoUtils.sha1(yaml), now, now, yaml, 0L, Long.MaxValue)
   }
-  
+
   def toPolicyEntry(occurredMillis: Long, validFromMillis: Long, validToMillis: Long = Long.MaxValue) = {
     val yaml = toYAML
     val id = CryptoUtils.sha1(yaml)