Hi Daniil, Thanks for working on issue 475.
On Tue, Mar 22, 2016 at 10:25 AM, Даниил Лещёв <[email protected]> wrote: > Hi everybody, > > At the moment I'm dealing with issue 475 ( > https://code.google.com/p/ganeti/issues/detail?id=475), and have got > number of questions. > 1) Are cluster config files from test/data/htools valid for Rapi backend? > If so, do we really need default val for nets field or 'networks' field > will always exist (even empty)? I think it's not so, because for example > test/data/htools/rapi/groups.json hasn't this field. > Yes those should be valid json files. You can verify this by actually querying Rapi on a running cluster where you add and configure a network. Also "gnt-groups list" might be helpful here. 2) Do we need to generate some fake networks at Simu backend or it's > suitable to just leave it empty in createGroup function? > Would be nice to extend the data files loaded in the Simu backend with network data. I will be happy to hear any your comments. > At the moment, my diff is: > > 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) > > > Regards, > Daniil Leshchev >
