On Fri, Nov 5, 2010 at 3:29 PM, Aurelien Degremont <aurelien.degremont@cea.fr> wrote:
nap a écrit :
>
> Now with the last commit, you can have a sort of key generator :
> define host {
>    host_name   SuperSwitch
>    [...]
>    _ports     Unit [1-6] Port [1-48]
> }
>
> ...
>
> And that's all :)
>
> Quite cool isn't it? :)
>
> I think the only part of IT where this is useful is for this port thing
> of switches/routers. But it will save quite a lot of configuration lines
> I think :)

I was looking for this closely since you were working on generators.
I've got full-featured Python code to manipulate ranges.

In fact, this feature is not usefull only for switches/routers, it is near mandatory for HPC clusters.
We are setting up a 4300-nodes clusters, and you can imagine what that mean declaring more than 4000 servers in
Nagios-like configuration files :), with all this node near the same.

We are using nodesets to point to them.
 nodes[1-4000] is really common for us.
We can use quite complex node range description like :
 nodes[1-400,489,568,600-800/3]

And even operation between them like:
 foo[1-50],bar[1-5],qui

 foo[1-50]&foo[45-60] => foo[45-50]
 foo[1-50]!foo[45-60] => foo[1-45]
 foo[1-50]^foo[45-60] => foo[1-45,51-60]

And you could manipulate this easily in Python

 for node in NodeSet("foo[1-50]^foo[45-60]):
    iters => foo1 foo2 foo3 ...

 if "foo4" in nodeset:
   ...


I do not know what's your code for handling such ranges but maybe NodeSet could be interesting for you?
Oh yes! It's quite interesting. Not only for the service generator, but for the host generator proposed by Hermann Lauer!!

So in fact you can generate hosts by using a template like:

define host{
   register 0
   use LinuxNode,WebNode,etc (so here you can "call" the service/properties you want
   duplicate_foreach   nodes[1-400,489,568,600-800/3]
}

Then you generate with this all your ~480 hosts in a single template!

First let add the "simple" [X-Y]then we can start the more complex /3 or & | :p

Thanks a lot for this idea. This will help quite a lot cluster managers :p

Let's code it :)
(Now I already got the hard regexp/parsing part, it's will be quite more simple :p)


Jean
 


--
Aurelien Degremont

------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a
Billion" shares his insights and actions to help propel your
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
Shinken-devel mailing list
Shinken-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/shinken-devel