[Libosinfo] [PATCHv4 02/11] loader: Parse OsinfoInstallConfigParam::value-map from XML

Christophe Fergeau cfergeau at redhat.com
Tue Dec 18 09:50:21 UTC 2012


On Tue, Dec 18, 2012 at 03:08:29AM +0200, Zeeshan Ali (Khattak) wrote:
> On Mon, Dec 17, 2012 at 11:07 PM, Christophe Fergeau
> <cfergeau at redhat.com> wrote:
> > ---
> >  data/schemas/libosinfo.rng           | 3 +++
> >  osinfo/osinfo_install_config_param.h | 5 +++--
> >  osinfo/osinfo_loader.c               | 7 +++++++
> >  3 files changed, 13 insertions(+), 2 deletions(-)
> >
> > diff --git a/data/schemas/libosinfo.rng b/data/schemas/libosinfo.rng
> > index 62be37d..90b0dfb 100644
> > --- a/data/schemas/libosinfo.rng
> > +++ b/data/schemas/libosinfo.rng
> > @@ -557,6 +557,9 @@
> >                  <attribute name="policy">
> >                    <ref name='policies'/>
> >                  </attribute>
> > +                <optional>
> > +                  <attribute name="value-map"/>
> > +                </optional>
> >                </element>
> >              </oneOrMore>
> >            </element>
> > diff --git a/osinfo/osinfo_install_config_param.h b/osinfo/osinfo_install_config_param.h
> > index ba5a77c..b0f2217 100644
> > --- a/osinfo/osinfo_install_config_param.h
> > +++ b/osinfo/osinfo_install_config_param.h
> > @@ -37,8 +37,9 @@
> >  #define OSINFO_IS_INSTALL_CONFIG_PARAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), OSINFO_TYPE_INSTALL_CONFIG_PARAM))
> >  #define OSINFO_INSTALL_CONFIG_PARAM_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), OSINFO_TYPE_INSTALL_CONFIG_PARAM, OsinfoInstallConfigParamClass))
> >
> > -#define OSINFO_INSTALL_CONFIG_PARAM_PROP_NAME   "name"
> > -#define OSINFO_INSTALL_CONFIG_PARAM_PROP_POLICY "policy"
> > +#define OSINFO_INSTALL_CONFIG_PARAM_PROP_DATAMAP "value-map"
> > +#define OSINFO_INSTALL_CONFIG_PARAM_PROP_NAME    "name"
> > +#define OSINFO_INSTALL_CONFIG_PARAM_PROP_POLICY  "policy"
> >
> >  typedef struct _OsinfoInstallConfigParam        OsinfoInstallConfigParam;
> >  typedef struct _OsinfoInstallConfigParamClass   OsinfoInstallConfigParamClass;
> > diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c
> > index a097039..efbbc97 100644
> > --- a/osinfo/osinfo_loader.c
> > +++ b/osinfo/osinfo_loader.c
> > @@ -642,12 +642,19 @@ static void osinfo_loader_install_config_params(OsinfoLoader *loader,
> >      for (i = 0 ; i < nnodes ; i++) {
> >          gchar *name = (gchar *)xmlGetProp(nodes[i], BAD_CAST OSINFO_INSTALL_CONFIG_PARAM_PROP_NAME);
> >          gchar *policy = (gchar *)xmlGetProp(nodes[i], BAD_CAST OSINFO_INSTALL_CONFIG_PARAM_PROP_POLICY);
> > +        gchar *mapid = (gchar *)xmlGetProp(nodes[i], BAD_CAST OSINFO_INSTALL_CONFIG_PARAM_PROP_DATAMAP);
> >          OsinfoInstallConfigParam *param = osinfo_install_config_param_new(name);
> >          osinfo_entity_set_param(OSINFO_ENTITY(param),
> >                                  OSINFO_INSTALL_CONFIG_PARAM_PROP_POLICY,
> >                                  policy);
> >          osinfo_install_script_add_config_param(OSINFO_INSTALL_SCRIPT(entity),
> >                                                 param);
> > +        if (mapid != NULL) {
> > +            OsinfoDatamap *map;
> > +            map = osinfo_loader_get_datamap(loader, mapid);
> 
> Its probably just me being blind but I can't find this
> osinfo_loader_get_datamap() being defined in this or the only previous
> patch in this series.

It's already in git master as of c983335d82c:

commit c983335d82cb3b9915be7bc28c784d9526679b77
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Fri Dec 7 13:01:26 2012 +0100

    loader: Load datamaps

    Install scripts can add a 'datamap' attribute when they declare
    their config parameters. The value of this attribute is the ID
    of a datamap, which is an XML file containing key/value pairs:

    <?xml version="1.0" encoding="UTF-8"?>
    <libosinfo version="0.0.1">
      <datamap id="http://example.com/osinfo/test">
        <entry inval="generic-val1" outval="foo"/>
        <entry> inval="generic-val2" outval="bar"/>
      </datamap>
    </libosinfo>

    This commit adds support for loading these datamaps. The next patches
    will then make use of these datamaps when the libosinfo user set
    a value for the corresponding config parameter.


Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libosinfo/attachments/20121218/de4b15de/attachment.sig>


More information about the Libosinfo mailing list