Commit 22ff02a7 authored by Christos Stavrakakis's avatar Christos Stavrakakis Committed by Guido Trotter
Browse files

Add support for querying network timestamps



Add creation and modified timestamps when creating a new network, and
extend the available query fields for networks with these fields,
namely 'ctime' and 'mtime'.
Signed-off-by: default avatarChristos Stavrakakis <cstavr@grnet.gr>
Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 927840bc
......@@ -2490,6 +2490,7 @@ class ConfigWriter:
self._EnsureUUID(net, ec_id)
net.serial_no = 1
net.ctime = net.mtime = time.time()
self._config_data.networks[net.uuid] = net
self._config_data.cluster.serial_no += 1
......
......@@ -2649,6 +2649,9 @@ def _BuildNetworkFields():
compat.partial(_GetNetworkStatsField, name, kind))
for (name, (title, kind, _, doc)) in _NETWORK_STATS_FIELDS.items()])
# Add timestamps
fields.extend(_GetItemTimestampFields(IQ_NETWORKS))
return _PrepareFieldList(fields, [])
#: Fields for cluster information
......
......@@ -186,6 +186,7 @@ $(buildObject "Network" "network" $
, optionalField $
simpleField "ext_reservations" [t| String |]
]
++ timeStampFields
++ serialFields
++ tagsFields)
......@@ -195,6 +196,10 @@ instance SerialNoObject Network where
instance TagsObject Network where
tagsOf = networkTags
instance TimeStampObject Network where
cTimeOf = networkCtime
mTimeOf = networkMtime
-- * NIC definitions
$(buildParam "Nic" "nicp"
......
......@@ -174,8 +174,10 @@ genValidNetwork = do
gateway6 <- genMaybe genIp6Addr
res <- liftM Just (genBitString $ netmask2NumHosts netmask)
ext_res <- liftM Just (genBitString $ netmask2NumHosts netmask)
ctime <- arbitrary
mtime <- arbitrary
let n = Network name mac_prefix net net6 gateway
gateway6 res ext_res 0 Set.empty
gateway6 res ext_res ctime mtime 0 Set.empty
return n
-- | Generate an arbitrary string consisting of '0' and '1' of the given length.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment