Hi,
Am 26.12.2010 14:30, schrieb nap:
>
>
> [snip..]
>
>
>>
>> the arbiter module code for loading conf was write for the
>> glpi module that need only the host.
>>
>>
>> If you are interested, I have attached a patch which uses the
>> types_creations of the configuration for dynamical
>> detection of
>> configuration "sections" and allows modules to add
>> properties to the
>> configuration, such as contacts, hostgroups, etc. pp.
>>
>> Cool :)
>>
>>
>> Sorry, if the code does not meet your formatting patterns
>> - I was just
>> glad to get it working for now. ;-)
>>
>> I'm adding it.
>>
>> If you decide to use the code, please double check it, as
>> I am not too
>> firm to python programming yet. Especially the existance
>> checks may not
>> be the optimal choice.. but they (seem to) work.
>>
>> Yes, a "in" can be easier in fact instead of the hammer Except ;)
>>
> Ah ok - looking foreward for your optimized code. :)
>
>
> It's pushed in the last commit. I remove one of the 2 test, because it
> looked at the existence of a type, when we loop for this type. So we
> are sure the type exist :)
> But I kept the 2nd, I just change it by a "in" because it's easier to
> read than a Try/Except.
Just tested your code and must disagree - I get an exception for the
first configuration section which is _not_ provided by the module.
"The instance MyModule raise an exception 'escalations'. I bypass it"
Using your not-in-pattern instead, the attached patch can be used as an
alternative for the try catch block. But either try-catch or not-in is
needed. Otherwise a module needs to provide all configuration sections
for valid input.
>
>
>>
>>
>> Thanks a lot for this patch, I'm adding it :)
>>
> You're welcome - just happy that it seems useful for someone else
> - and that I won't have to patch future arbiter versions. ;-)
>
> Oh yes, that's why propose patches is important :)
>
> Let us know when you more will be ready, and if it can be useful for
> other peole, you can propose it in the mainline and I'll grant you git
> access if you want :)
I will.
For the time being I guess it's better if someone reviews my code before
commiting it.. ;-) but I will keep you offer in mind.
Kristoffer
326c326
<
---
>
370,385c370,371
< types_creations = self.conf.types_creations
< for k in types_creations:
< (cls, clss, prop) = types_creations[k]
< try:
< for x in r[prop]:
< # test if raw_objects[k] is already set - if not, add empty array
< try:
< _test = raw_objects[k]
< except Exception, exExistanceTest2:
< raw_objects[k] = []
< # now append the object
< raw_objects[k].append(x)
< print "Added %i objects to %s from module %s" % (len(r[prop]), k, inst.get_name())
< except Exception, exExistanceTest1:
< # just ignore it - the property is not used by module
< _test = None # at least do something
---
> for h in r['hosts']:
> raw_objects['host'].append(h)
389c375,376
< ### Resume standard operations ###
---
>
> ### Resume standard operations ###
450a438,440
> # And link them
> self.conf.create_business_rules_dependencies()
>
------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and,
should the need arise, upgrade to a full multi-node Oracle RAC database
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Shinken-devel mailing list
Shinken-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/shinken-devel