From f84e033c97957ec31763251ee910f81dd5b2a00a Mon Sep 17 00:00:00 2001
From: Henrik Thostrup Jensen <htj@nordu.net>
Date: Wed, 11 Jun 2014 14:33:15 +0200
Subject: [PATCH] add support for empty start time in database service
 connections (aggregator) and core schedule representation (third patch)

---
 datafiles/schema.sql | 2 +-
 opennsa/nsa.py       | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/datafiles/schema.sql b/datafiles/schema.sql
index 6239ff33..ad8d25f5 100644
--- a/datafiles/schema.sql
+++ b/datafiles/schema.sql
@@ -39,7 +39,7 @@ CREATE TABLE service_connections (
     dest_network            text                        NOT NULL,
     dest_port               text                        NOT NULL,
     dest_label              label,
-    start_time              timestamp                   NOT NULL,
+    start_time              timestamp,                            -- null = now
     end_time                timestamp                   NOT NULL,
     symmetrical             boolean                     NOT NULL,
     directionality          directionality              NOT NULL,
diff --git a/opennsa/nsa.py b/opennsa/nsa.py
index a1a2b0b8..4b56c9a8 100644
--- a/opennsa/nsa.py
+++ b/opennsa/nsa.py
@@ -375,7 +375,8 @@ class Schedule(object):
 
     def __init__(self, start_time, end_time):
         # Must be datetime instances without tzinfo
-        assert start_time.tzinfo is None, 'Start time must NOT have time zone'
+        if start_time is not None:
+            assert start_time.tzinfo is None, 'Start time must NOT have time zone'
         assert end_time.tzinfo   is None, 'End time must NOT have time zone'
 
         self.start_time = start_time
-- 
GitLab