Revision 74b3f734
b/src/Ganeti/DataCollectors/InstStatusTypes.hs | ||
---|---|---|
43 | 43 |
, simpleField "actualState" [t| ActualState |] |
44 | 44 |
, optionalNullSerField $ |
45 | 45 |
simpleField "uptime" [t| String |] |
46 |
, simpleField "mtime" [t| Double |]
|
|
46 |
, timeAsDoubleField "mtime"
|
|
47 | 47 |
, simpleField "state_reason" [t| ReasonTrail |] |
48 | 48 |
, simpleField "status" [t| DCStatus |] |
49 | 49 |
]) |
b/src/Ganeti/Objects.hs | ||
---|---|---|
94 | 94 |
import qualified Data.Map as Map |
95 | 95 |
import qualified Data.Set as Set |
96 | 96 |
import Data.Word |
97 |
import System.Time (ClockTime(..)) |
|
97 | 98 |
import Text.JSON (showJSON, readJSON, JSON, JSValue(..), fromJSString) |
98 | 99 |
import qualified Text.JSON as J |
99 | 100 |
|
... | ... | |
125 | 126 |
|
126 | 127 |
-- | Class of objects that have timestamps. |
127 | 128 |
class TimeStampObject a where |
128 |
cTimeOf :: a -> Double
|
|
129 |
mTimeOf :: a -> Double
|
|
129 |
cTimeOf :: a -> ClockTime
|
|
130 |
mTimeOf :: a -> ClockTime
|
|
130 | 131 |
|
131 | 132 |
-- | Class of objects that have an UUID. |
132 | 133 |
class UuidObject a where |
b/src/Ganeti/Query/Common.hs | ||
---|---|---|
135 | 135 |
timeStampFields :: (TimeStampObject a) => FieldList a b |
136 | 136 |
timeStampFields = |
137 | 137 |
[ (FieldDefinition "ctime" "CTime" QFTTimestamp "Creation timestamp", |
138 |
FieldSimple (rsNormal . cTimeOf), QffNormal) |
|
138 |
FieldSimple (rsNormal . TimeAsDoubleJSON . cTimeOf), QffNormal)
|
|
139 | 139 |
, (FieldDefinition "mtime" "MTime" QFTTimestamp "Modification timestamp", |
140 |
FieldSimple (rsNormal . mTimeOf), QffNormal) |
|
140 |
FieldSimple (rsNormal . TimeAsDoubleJSON . mTimeOf), QffNormal)
|
|
141 | 141 |
] |
142 | 142 |
|
143 | 143 |
-- | The list of UUID fields. |
b/src/Ganeti/Query/Server.hs | ||
---|---|---|
53 | 53 |
import Ganeti.BasicTypes |
54 | 54 |
import Ganeti.JQueue |
55 | 55 |
import Ganeti.JQScheduler |
56 |
import Ganeti.JSON (TimeAsDoubleJSON(..)) |
|
56 | 57 |
import Ganeti.Logging |
57 | 58 |
import Ganeti.Luxi |
58 | 59 |
import qualified Ganeti.Query.Language as Qlang |
... | ... | |
143 | 144 |
showJSON $ clusterGlusterStorageDir cluster) |
144 | 145 |
, ("maintain_node_health", |
145 | 146 |
showJSON $ clusterMaintainNodeHealth cluster) |
146 |
, ("ctime", showJSON $ clusterCtime cluster) |
|
147 |
, ("mtime", showJSON $ clusterMtime cluster) |
|
147 |
, ("ctime", showJSON . TimeAsDoubleJSON $ clusterCtime cluster)
|
|
148 |
, ("mtime", showJSON . TimeAsDoubleJSON $ clusterMtime cluster)
|
|
148 | 149 |
, ("uuid", showJSON $ clusterUuid cluster) |
149 | 150 |
, ("tags", showJSON $ clusterTags cluster) |
150 | 151 |
, ("uid_pool", showJSON $ clusterUidPool cluster) |
b/src/Ganeti/THH.hs | ||
---|---|---|
316 | 316 |
|
317 | 317 |
-- | Timestamp fields description. |
318 | 318 |
timeStampFields :: [Field] |
319 |
timeStampFields = |
|
320 |
[ defaultField [| 0::Double |] $ simpleField "ctime" [t| Double |] |
|
321 |
, defaultField [| 0::Double |] $ simpleField "mtime" [t| Double |] |
|
322 |
] |
|
319 |
timeStampFields = map (defaultField [| TOD 0 0 |] . timeAsDoubleField) |
|
320 |
["ctime", "mtime"] |
|
321 |
|
|
323 | 322 |
|
324 | 323 |
-- | Serial number fields description. |
325 | 324 |
serialFields :: [Field] |
b/test/hs/Test/Ganeti/Query/Instance.hs | ||
---|---|---|
32 | 32 |
|
33 | 33 |
import qualified Data.Map as Map |
34 | 34 |
import qualified Data.Set as Set |
35 |
import System.Time (ClockTime(..)) |
|
35 | 36 |
|
36 | 37 |
import Ganeti.JSON |
37 | 38 |
import Ganeti.Objects |
... | ... | |
52 | 53 |
(GenericContainer Map.empty) |
53 | 54 |
(PartialBeParams Nothing Nothing Nothing Nothing Nothing Nothing) |
54 | 55 |
(GenericContainer Map.empty) |
55 |
adminState [] [] DTDrbd8 False Nothing 0.0 0.0 "" 0 Set.empty |
|
56 |
adminState [] [] DTDrbd8 False Nothing epochTime epochTime "" 0 Set.empty |
|
57 |
where epochTime = TOD 0 0 |
|
56 | 58 |
|
57 | 59 |
-- | A fake InstanceInfo to be used to check values. |
58 | 60 |
fakeInstanceInfo :: InstanceInfo |
Also available in: Unified diff