From: Mohamed Larabi Date: Fri, 24 May 2013 08:00:16 +0000 (+0200) Subject: Express Lease start_time in RFC3339 date format not in epoch X-Git-Tag: sfa-2.1-26~10^2~1 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=87d41525fbcfc03496dbae741387bae93b1bce2d;p=sfa.git Express Lease start_time in RFC3339 date format not in epoch --- diff --git a/sfa/rspecs/elements/versions/nitosv1Lease.py b/sfa/rspecs/elements/versions/nitosv1Lease.py index dda33e96..158f0ba1 100644 --- a/sfa/rspecs/elements/versions/nitosv1Lease.py +++ b/sfa/rspecs/elements/versions/nitosv1Lease.py @@ -1,6 +1,7 @@ from sfa.util.sfalogging import logger from sfa.util.xml import XpathFilter from sfa.util.xrn import Xrn +from sfa.util.sfatime import utcparse, datetime_to_string, datetime_to_epoch from sfa.rspecs.elements.element import Element from sfa.rspecs.elements.node import Node @@ -53,7 +54,8 @@ class NITOSv1Lease: lease_elems = [] for lease in grouped_leases: - #lease_fields = ['lease_id', 'component_id', 'slice_id', 'start_time', 'duration'] + lease[0]['start_time'] = datetime_to_string(utcparse(lease[0]['start_time'])) + lease_fields = ['slice_id', 'start_time', 'duration'] lease_elem = network_elem.add_instance('lease', lease[0], lease_fields) lease_elems.append(lease_elem) @@ -65,6 +67,7 @@ class NITOSv1Lease: # add reserved channels of this lease #channels = [{'channel_id': 1}, {'channel_id': 2}] for channel in channels: + channel['start_time'] = datetime_to_string(utcparse(channel['start_time'])) if channel['slice_id'] == lease[0]['slice_id'] and channel['start_time'] == lease[0]['start_time'] and channel['duration'] == lease[0]['duration']: lease_elem.add_instance('channel', channel, ['channel_num']) @@ -85,7 +88,7 @@ class NITOSv1Lease: for node_elem in node_elems: lease = Lease(lease_elem.attrib, lease_elem) lease['slice_id'] = lease_elem.attrib['slice_id'] - lease['start_time'] = lease_elem.attrib['start_time'] + lease['start_time'] = datetime_to_epoch(utcparse(lease_elem.attrib['start_time'])) lease['duration'] = lease_elem.attrib['duration'] lease['component_id'] = node_elem.attrib['component_id'] leases.append(lease) @@ -94,7 +97,7 @@ class NITOSv1Lease: for channel_elem in channel_elems: channel = Channel(channel_elem.attrib, channel_elem) channel['slice_id'] = lease_elem.attrib['slice_id'] - channel['start_time'] = lease_elem.attrib['start_time'] + channel['start_time'] = datetime_to_epoch(utcparse(lease_elem.attrib['start_time'])) channel['duration'] = lease_elem.attrib['duration'] channel['channel_num'] = channel_elem.attrib['channel_num'] channels.append(channel) diff --git a/sfa/rspecs/elements/versions/pgv2Lease.py b/sfa/rspecs/elements/versions/pgv2Lease.py index 8ba53cbc..952aec2a 100644 --- a/sfa/rspecs/elements/versions/pgv2Lease.py +++ b/sfa/rspecs/elements/versions/pgv2Lease.py @@ -1,5 +1,6 @@ from sfa.util.xrn import Xrn from sfa.util.xml import XpathFilter +from sfa.util.sfatime import utcparse, datetime_to_string, datetime_to_epoch from sfa.rspecs.elements.node import Node from sfa.rspecs.elements.sliver import Sliver @@ -39,6 +40,8 @@ class PGv2Lease: lease_elems = [] for lease in grouped_leases: + lease[0]['start_time'] = datetime_to_string(utcparse(lease[0]['start_time'])) + lease_fields = ['slice_id', 'start_time', 'duration'] lease_elem = xml.add_instance('lease', lease[0], lease_fields) lease_elems.append(lease_elem) @@ -64,7 +67,7 @@ class PGv2Lease: for node_elem in node_elems: lease = Lease(lease_elem.attrib, lease_elem) lease['slice_id'] = lease_elem.attrib['slice_id'] - lease['start_time'] = lease_elem.attrib['start_time'] + lease['start_time'] = datetime_to_epoch(utcparse(lease_elem.attrib['start_time'])) lease['duration'] = lease_elem.attrib['duration'] lease['component_id'] = node_elem.attrib['component_id'] leases.append(lease) diff --git a/sfa/rspecs/elements/versions/sfav1Lease.py b/sfa/rspecs/elements/versions/sfav1Lease.py index 03a43422..7effc833 100644 --- a/sfa/rspecs/elements/versions/sfav1Lease.py +++ b/sfa/rspecs/elements/versions/sfav1Lease.py @@ -1,6 +1,7 @@ from sfa.util.sfalogging import logger from sfa.util.xml import XpathFilter from sfa.util.xrn import Xrn +from sfa.util.sfatime import utcparse, datetime_to_string, datetime_to_epoch from sfa.rspecs.elements.element import Element from sfa.rspecs.elements.node import Node @@ -52,7 +53,8 @@ class SFAv1Lease: lease_elems = [] for lease in grouped_leases: - #lease_fields = ['lease_id', 'component_id', 'slice_id', 'start_time', 'duration'] + lease[0]['start_time'] = datetime_to_string(utcparse(lease[0]['start_time'])) + lease_fields = ['slice_id', 'start_time', 'duration'] lease_elem = network_elem.add_instance('lease', lease[0], lease_fields) lease_elems.append(lease_elem) @@ -85,7 +87,7 @@ class SFAv1Lease: for node_elem in node_elems: lease = Lease(lease_elem.attrib, lease_elem) lease['slice_id'] = lease_elem.attrib['slice_id'] - lease['start_time'] = lease_elem.attrib['start_time'] + lease['start_time'] = datetime_to_epoch(utcparse(lease_elem.attrib['start_time'])) lease['duration'] = lease_elem.attrib['duration'] lease['component_id'] = node_elem.attrib['component_id'] leases.append(lease) diff --git a/sfa/rspecs/elements/versions/slabv1Lease.py b/sfa/rspecs/elements/versions/slabv1Lease.py index 787f2ce2..2991a490 100644 --- a/sfa/rspecs/elements/versions/slabv1Lease.py +++ b/sfa/rspecs/elements/versions/slabv1Lease.py @@ -1,7 +1,7 @@ from sfa.util.sfalogging import logger from sfa.util.xml import XpathFilter from sfa.util.xrn import Xrn - +from sfa.util.sfatime import utcparse, datetime_to_string, datetime_to_epoch #from sfa.rspecs.elements.versions.sfav1PLTag import SFAv1PLTag @@ -26,6 +26,8 @@ class Slabv1Lease: lease_elems = [] for lease in leases: + lease['start_time'] = datetime_to_string(utcparse(lease['start_time'])) + lease_fields = ['lease_id', 'component_id', 'slice_id', 'start_time', 'duration'] lease_elem = network_elem.add_instance('lease', lease, lease_fields) lease_elems.append(lease_elem) @@ -46,7 +48,7 @@ class Slabv1Lease: for node_elem in node_elems: lease = Lease(lease_elem.attrib, lease_elem) lease['slice_id'] = lease_elem.attrib['slice_id'] - lease['start_time'] = lease_elem.attrib['start_time'] + lease['start_time'] = datetime_to_epoch(utcparse(lease_elem.attrib['start_time'])) lease['duration'] = lease_elem.attrib['duration'] lease['component_id'] = node_elem.attrib['component_id'] leases.append(lease)