You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@ace.apache.org by "Passchier, I. (Igor)" <ig...@tno.nl> on 2013/03/01 17:35:13 UTC

deploying configuration data

Hello,

I am operating a set of OSGi platforms, based on apache Felix, which I would like to manage with apache ace. Most bundles are developed by ourselves, where dependency and configuration is automated with SCR. Currently platform management and configuration is done via Felix webconsole. I tried to find a way to supply configuration data via apache ace, but to no avail. In the various mailing list and source code, I found references to the xml metatype description, but deploying these via Ace fails in the deployment stage. I also found references to the use .cfg files containing key/value pairs, but these I cannot add on the server side ("no artifact recognizer").

How can I deploy configuration data to my osgi targets via Ace, preferably depending on some properties of my targets?

Igor Passchier

This e-mail and its contents are subject to the DISCLAIMER at http://www.tno.nl/emaildisclaimer

Re: deploying configuration data

Posted by Marcel Offermans <ma...@luminis.nl>.
Hello Igor,

Just to get you started, an example of a configuration file (slightly anonymized) from one of our applications (if I remember correctly we use a snapshot of autoconf, but I'm not sure how relevant that is):

<MetaData xmlns="http://www.osgi.org/xmlns/metatype/v1.0.0"> 
  <OCD name='ocd' id='ocd'>
  	<AD id='host' type='STRING' cardinality='0' />
    <AD id='namespace' type='STRING' cardinality='0' />
    <AD id='tenantId' type='STRING' cardinality='0' />
  </OCD>
  <Designate factoryPid='org.foo.memcached.factory' pid='org.foo.memcached.curriculum'  bundle="osgi-dp:org.foo.memcached">
    <Object ocdref='ocd'>
      <Attribute adref='host'>
        <Value><![CDATA[foo.com:11221 foo.com:11221]]></Value>
      </Attribute>	
      <Attribute adref='namespace'>
        <Value><![CDATA[content]]></Value>
      </Attribute>
      <Attribute adref='tenantId'>
        <Value><![CDATA[${context.fooname}]]></Value>
      </Attribute>
    </Object>
  </Designate>
</MetaData>

Greetings, Marcel


On Mar 1, 2013, at 22:23 PM, "Passchier, I. (Igor)" <ig...@tno.nl> wrote:

> Hello Marcel,
> 
> Thanks for your reply. Adding the auto configuration resource processor made that indeed the configuration files are accepted and deployed. However, they now fail on non conformance of my config file by the auto configuration resource processor. I think I have some xsd version issue, which I will trace down. Ace seems to be doing what I need. After fixing the non conformance, I will give Velocity a try.
> 
> Regards,
> 
> Igor Passchier
> 
> 
> -----Original Message-----
> From: Marcel Offermans [mailto:marcel.offermans@luminis.nl] 
> Sent: vrijdag 1 maart 2013 18:12
> To: users@ace.apache.org
> Subject: Re: deploying configuration data
> 
> Hello Igor,
> 
> On Mar 1, 2013, at 17:35 , "Passchier, I. (Igor)" <ig...@tno.nl> wrote:
> 
>> I am operating a set of OSGi platforms, based on apache Felix, which I would like to manage with apache ace. Most bundles are developed by ourselves, where dependency and configuration is automated with SCR. Currently platform management and configuration is done via Felix webconsole. I tried to find a way to supply configuration data via apache ace, but to no avail.
> 
> ACE supports the "Auto Configuration Specification" as described in the OSGi Compendium chapter 115.
> 
> We should probably do a better job at documenting how this works though.
> 
>> In the various mailing list and source code, I found references to the xml metatype description, but deploying these via Ace fails in the deployment stage. I also found references to the use .cfg files containing key/value pairs, but these I cannot add on the server side ("no artifact recognizer").
> 
> You should not use the .cfg files, unless you write a resource processor for them yourself, but that is not the easiest way.
> 
>> How can I deploy configuration data to my osgi targets via Ace, preferably depending on some properties of my targets?
> 
> There are a couple of things you need to do:
> 
> 1) Add an artifact to ACE that implements the Auto Configuration resource processor. I suggest you either download the latest release from [1] or build it from source (it's part of Apache Felix) yourself. Note that when you add this artifact to ACE, it will *not* become visible in the left most column, but it will be in the OBR. If you omit this step, things will seem to work, but you cannot deploy configurations as at deploy time it will try to ship the resource processor automatically along with the xml configurations.
> 
> 2) Create an xml configuration that complies to the specification, and upload that as an artifact as well. It should be visible, and you should be able to assign it to a feature and get it on a target just like you would with bundles.
> 
> 3) Now deploy. :)
> 
> To answer your final question, there is one extra feature that ACE supports for these xml config files, and that is they can be processed using Velocity. That means you can make a configuration file that really is a template, and in the template you can define variables that will be replaced with values.
> 
> Now how can you provide values for these variables?
> 
> Go to a target in the UI, double click it, then go to the tag editor. Here you can enter key/value pairs and these will be used to fill out your template. If you have a variable called "hostname" there, you should use the following in the xml file: "${context.hostname}". So, always prefix them with "context.".
> 
> If you want to do more fancy things, check out the Velocity website.
> 
> For more advanced use, you can also add tags to features or distributions. That is sometimes useful if you have a configuration value for a whole group of targets.
> 
> Hope this helps. If not, let me know!
> 
> Greetings, Marcel
> 
> 
> [1] http://felix.apache.org/downloads.cgi
> 
> This e-mail and its contents are subject to the DISCLAIMER at http://www.tno.nl/emaildisclaimer
> 
> 
> 


RE: deploying configuration data

Posted by "Passchier, I. (Igor)" <ig...@tno.nl>.
Hello Marcel,

Thanks for your reply. Adding the auto configuration resource processor made that indeed the configuration files are accepted and deployed. However, they now fail on non conformance of my config file by the auto configuration resource processor. I think I have some xsd version issue, which I will trace down. Ace seems to be doing what I need. After fixing the non conformance, I will give Velocity a try.

Regards,

Igor Passchier


-----Original Message-----
From: Marcel Offermans [mailto:marcel.offermans@luminis.nl] 
Sent: vrijdag 1 maart 2013 18:12
To: users@ace.apache.org
Subject: Re: deploying configuration data

Hello Igor,

On Mar 1, 2013, at 17:35 , "Passchier, I. (Igor)" <ig...@tno.nl> wrote:

> I am operating a set of OSGi platforms, based on apache Felix, which I would like to manage with apache ace. Most bundles are developed by ourselves, where dependency and configuration is automated with SCR. Currently platform management and configuration is done via Felix webconsole. I tried to find a way to supply configuration data via apache ace, but to no avail.

ACE supports the "Auto Configuration Specification" as described in the OSGi Compendium chapter 115.

We should probably do a better job at documenting how this works though.

> In the various mailing list and source code, I found references to the xml metatype description, but deploying these via Ace fails in the deployment stage. I also found references to the use .cfg files containing key/value pairs, but these I cannot add on the server side ("no artifact recognizer").

You should not use the .cfg files, unless you write a resource processor for them yourself, but that is not the easiest way.

> How can I deploy configuration data to my osgi targets via Ace, preferably depending on some properties of my targets?

There are a couple of things you need to do:

1) Add an artifact to ACE that implements the Auto Configuration resource processor. I suggest you either download the latest release from [1] or build it from source (it's part of Apache Felix) yourself. Note that when you add this artifact to ACE, it will *not* become visible in the left most column, but it will be in the OBR. If you omit this step, things will seem to work, but you cannot deploy configurations as at deploy time it will try to ship the resource processor automatically along with the xml configurations.

2) Create an xml configuration that complies to the specification, and upload that as an artifact as well. It should be visible, and you should be able to assign it to a feature and get it on a target just like you would with bundles.

3) Now deploy. :)

To answer your final question, there is one extra feature that ACE supports for these xml config files, and that is they can be processed using Velocity. That means you can make a configuration file that really is a template, and in the template you can define variables that will be replaced with values.

Now how can you provide values for these variables?

Go to a target in the UI, double click it, then go to the tag editor. Here you can enter key/value pairs and these will be used to fill out your template. If you have a variable called "hostname" there, you should use the following in the xml file: "${context.hostname}". So, always prefix them with "context.".

If you want to do more fancy things, check out the Velocity website.

For more advanced use, you can also add tags to features or distributions. That is sometimes useful if you have a configuration value for a whole group of targets.

Hope this helps. If not, let me know!

Greetings, Marcel


[1] http://felix.apache.org/downloads.cgi

This e-mail and its contents are subject to the DISCLAIMER at http://www.tno.nl/emaildisclaimer


Re: deploying configuration data

Posted by Marcel Offermans <ma...@luminis.nl>.
Hello Igor,

On Mar 1, 2013, at 17:35 , "Passchier, I. (Igor)" <ig...@tno.nl> wrote:

> I am operating a set of OSGi platforms, based on apache Felix, which I would like to manage with apache ace. Most bundles are developed by ourselves, where dependency and configuration is automated with SCR. Currently platform management and configuration is done via Felix webconsole. I tried to find a way to supply configuration data via apache ace, but to no avail.

ACE supports the "Auto Configuration Specification" as described in the OSGi Compendium chapter 115.

We should probably do a better job at documenting how this works though.

> In the various mailing list and source code, I found references to the xml metatype description, but deploying these via Ace fails in the deployment stage. I also found references to the use .cfg files containing key/value pairs, but these I cannot add on the server side ("no artifact recognizer").

You should not use the .cfg files, unless you write a resource processor for them yourself, but that is not the easiest way.

> How can I deploy configuration data to my osgi targets via Ace, preferably depending on some properties of my targets?

There are a couple of things you need to do:

1) Add an artifact to ACE that implements the Auto Configuration resource processor. I suggest you either download the latest release from [1] or build it from source (it's part of Apache Felix) yourself. Note that when you add this artifact to ACE, it will *not* become visible in the left most column, but it will be in the OBR. If you omit this step, things will seem to work, but you cannot deploy configurations as at deploy time it will try to ship the resource processor automatically along with the xml configurations.

2) Create an xml configuration that complies to the specification, and upload that as an artifact as well. It should be visible, and you should be able to assign it to a feature and get it on a target just like you would with bundles.

3) Now deploy. :)

To answer your final question, there is one extra feature that ACE supports for these xml config files, and that is they can be processed using Velocity. That means you can make a configuration file that really is a template, and in the template you can define variables that will be replaced with values.

Now how can you provide values for these variables?

Go to a target in the UI, double click it, then go to the tag editor. Here you can enter key/value pairs and these will be used to fill out your template. If you have a variable called "hostname" there, you should use the following in the xml file: "${context.hostname}". So, always prefix them with "context.".

If you want to do more fancy things, check out the Velocity website.

For more advanced use, you can also add tags to features or distributions. That is sometimes useful if you have a configuration value for a whole group of targets.

Hope this helps. If not, let me know!

Greetings, Marcel


[1] http://felix.apache.org/downloads.cgi