And also. Please reformat the short commit message to make it contain human-understandable description. It's better to move the issue number to the long part of the commit message.
On Monday, March 28, 2016 at 7:15:15 PM UTC+3, Даниил Лещёв wrote: > > From: Daniil Leshchev <[email protected] <javascript:>> > > Implement extraction of 'networks' field in Rapi and Luxi backends. > Add 'networks' field into Group query object. > > Signed-off-by: Daniil Leshchev <[email protected] <javascript:>> > --- > lib/query.py | 3 +++ > src/Ganeti/HTools/Backend/Luxi.hs | 8 ++++---- > src/Ganeti/HTools/Backend/Rapi.hs | 5 +++-- > src/Ganeti/Query/Group.hs | 2 ++ > 4 files changed, 12 insertions(+), 6 deletions(-) > > diff --git a/lib/query.py b/lib/query.py > index 43d8fad..222c14f 100644 > --- a/lib/query.py > +++ b/lib/query.py > @@ -2448,6 +2448,9 @@ def _BuildGroupFields(): > (_MakeField("ipolicy", "InstancePolicy", QFT_OTHER, > "Instance policy limitations (merged)"), > GQ_CONFIG, 0, lambda ctx, _: ctx.group_ipolicy), > + (_MakeField("networks", "Networks", QFT_OTHER, > + "Node group networks"), > + GQ_CONFIG, 0, _GetItemAttr("networks")), > (_MakeField("custom_ipolicy", "CustomInstancePolicy", QFT_OTHER, > "Custom instance policy limitations"), > GQ_CONFIG, 0, _GetItemAttr("ipolicy")), > diff --git a/src/Ganeti/HTools/Backend/Luxi.hs > b/src/Ganeti/HTools/Backend/Luxi.hs > index 5a3cb1d..2ac71e6 100644 > --- a/src/Ganeti/HTools/Backend/Luxi.hs > +++ b/src/Ganeti/HTools/Backend/Luxi.hs > @@ -149,7 +149,7 @@ queryClusterInfoMsg = L.QueryClusterInfo > queryGroupsMsg :: L.LuxiOp > queryGroupsMsg = > L.Query (Qlang.ItemTypeOpCode Qlang.QRGroup) > - ["uuid", "name", "alloc_policy", "ipolicy", "tags"] > + ["uuid", "name", "alloc_policy", "ipolicy", "tags", "networks"] > Qlang.EmptyFilter > > -- | Wraper over 'callMethod' doing node query. > @@ -276,15 +276,15 @@ getGroups jsv = extractArray jsv >>= mapM parseGroup > > -- | Parses a given group information. > parseGroup :: [(JSValue, JSValue)] -> Result (String, Group.Group) > -parseGroup [uuid, name, apol, ipol, tags] = do > +parseGroup [uuid, name, apol, ipol, tags, nets] = do > xname <- annotateResult "Parsing new group" (fromJValWithStatus name) > let convert a = genericConvert "Group" xname a > xuuid <- convert "uuid" uuid > xapol <- convert "alloc_policy" apol > xipol <- convert "ipolicy" ipol > xtags <- convert "tags" tags > - -- TODO: parse networks to which this group is connected > - return (xuuid, Group.create xname xuuid xapol [] xipol xtags) > + xnets <- convert "networks" nets > + return (xuuid, Group.create xname xuuid xapol xnets xipol xtags) > > parseGroup v = fail ("Invalid group query result: " ++ show v) > > diff --git a/src/Ganeti/HTools/Backend/Rapi.hs > b/src/Ganeti/HTools/Backend/Rapi.hs > index df93d6a..ce1bb10 100644 > --- a/src/Ganeti/HTools/Backend/Rapi.hs > +++ b/src/Ganeti/HTools/Backend/Rapi.hs > @@ -196,12 +196,13 @@ parseGroup :: JSRecord -> Result (String, > Group.Group) > parseGroup a = do > name <- tryFromObj "Parsing new group" a "name" > let extract s = tryFromObj ("Group '" ++ name ++ "'") a s > + let extractDef s d = fromObjWithDefault a s d > uuid <- extract "uuid" > apol <- extract "alloc_policy" > ipol <- extract "ipolicy" > tags <- extract "tags" > - -- TODO: parse networks to which this group is connected > - return (uuid, Group.create name uuid apol [] ipol tags) > + nets <- extractDef "networks" [] > + return (uuid, Group.create name uuid apol nets ipol tags) > > -- | Parse cluster data from the info resource. > parseCluster :: JSObject JSValue -> Result ([String], IPolicy, String) > diff --git a/src/Ganeti/Query/Group.hs b/src/Ganeti/Query/Group.hs > index 45bd81a..4989788 100644 > --- a/src/Ganeti/Query/Group.hs > +++ b/src/Ganeti/Query/Group.hs > @@ -55,6 +55,8 @@ groupFields = > , (FieldDefinition "custom_ipolicy" "CustomInstancePolicy" QFTOther > "Custom instance policy limitations", > FieldSimple (rsNormal . groupIpolicy), QffNormal) > + , (FieldDefinition "networks" "Networks" QFTOther "Node group > networks", > + FieldSimple (rsNormal . groupNetworks), QffNormal) > , (FieldDefinition "custom_ndparams" "CustomNDParams" QFTOther > "Custom node parameters", > FieldSimple (rsNormal . groupNdparams), QffNormal) > -- > 1.9.1 > >
