From: Tony Mack Date: Mon, 26 Dec 2011 04:53:34 +0000 (-0500) Subject: use utcparse and datetime_to_epoch to handle slice 'expires' field X-Git-Tag: sfa-2.0-7~13^2 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=a4d5ded2b254cb654c1b6a48c29f7b145bbf2cc5;p=sfa.git use utcparse and datetime_to_epoch to handle slice 'expires' field --- diff --git a/sfa/plc/plslices.py b/sfa/plc/plslices.py index dc214ec0..1bf60430 100644 --- a/sfa/plc/plslices.py +++ b/sfa/plc/plslices.py @@ -1,13 +1,12 @@ from types import StringTypes from collections import defaultdict +from sfa.util.sfatime import utcparse, datetime_to_epoch from sfa.util.sfalogging import logger from sfa.util.xrn import Xrn, get_leaf, get_authority, urn_to_hrn #from sfa.util.policy import Policy from sfa.util.xrn import Xrn - from sfa.rspecs.rspec import RSpec - from sfa.plc.vlink import VLink from sfa.util.plxrn import hrn_to_pl_slicename @@ -343,8 +342,9 @@ class PlSlices: # unbind from peer so we can modify if necessary. Will bind back later self.driver.shell.UnBindObjectFromPeer('slice', slice['slice_id'], peer['shortname']) #Update existing record (e.g. expires field) it with the latest info. - if slice_record and slice['expires'] != slice_record['expires']: - self.driver.shell.UpdateSlice( slice['slice_id'], {'expires' : slice_record['expires']}) + requested_expires = int(datetime_to_epoch(utcparse(slice_record['expires']))) + if requested_expires and slice['expires'] != requested_expires: + self.driver.shell.UpdateSlice( slice['slice_id'], {'expires' : requested_expires}) return slice