473999f1077f09a95e982cde891fec55877851f4
[osm/SO.git] / rwlaunchpad / plugins / rwstagingmgr / rift / tasklets / rwstagingmgr / model / staging_area.py
1 #
2 # Copyright 2016 RIFT.IO Inc
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16 # Author(s): Varun Prasad
17 # Creation Date: 09/28/2016
18 #
19
20
21 import time
22
23 import gi
24 gi.require_version('RwStagingMgmtYang', '1.0')
25 from gi.repository import (
26 RwStagingMgmtYang,
27 )
28
29
30 class StagingArea(object):
31 """A pythonic wrapper around the GI object StagingArea
32 """
33 def __init__(self, model=None):
34 self._model = model
35 if not self._model:
36 self._model = RwStagingMgmtYang.StagingArea.from_dict({})
37
38 @property
39 def area_id(self):
40 return self._model.area_id
41
42 @property
43 def model(self):
44 return self._model
45
46 @property
47 def has_expired(self):
48 current_time = time.time()
49 expiry_time = self.model.created_time + self.model.validity_time
50 if expiry_time <= current_time:
51 return True
52 return False
53
54 def as_dict(self):
55 return self._model.as_dict()