Cacti (home)ForumsRepositoryDocumentation
Cacti: offical forums and support  

 FAQFAQ   SearchSearch   MemberlistMemberlist    RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in    


INCLUDE statement to include other config files

 
Post new topic   Reply to topic    Cacti Forum Index -> Plugin: (Network Weather Map)
Author Message
BorisL
Cacti User


Joined: 31 Mar 2007
Posts: 55

PostPosted: Fri Jun 05, 2009 8:16 am    Post subject: INCLUDE statement to include other config files Reply with quote

Hello!

Here's patch that enables INCLUDE command that will allow to include some other config file into another.

Typically it is handy to store template options in some "header" files.

Syntax:
Code:
INCLUDE configs/some_themplate_file.conf



INCLUDE.patch
 Description:

Download
 Filename:  INCLUDE.patch
 Filesize:  2.23 KB
 Downloaded:  55 Time(s)

Back to top
Howie
Cacti Guru User


Joined: 16 Sep 2004
Posts: 3437
Location: United Kingdom

PostPosted: Fri Jun 05, 2009 9:23 am    Post subject: Reply with quote

I won't be including this patch in the normal release because it will cause problems with the editor. The editor has no way to tell if the config came from an include or not, so the first time you use the editor to edit the map, you'll lose the include, and have all of it's contents in the main file.

I do agree that it would be a useful feature, but it's not quite so simple to add
Back to top
BorisL
Cacti User


Joined: 31 Mar 2007
Posts: 55

PostPosted: Fri Jun 05, 2009 12:20 pm    Post subject: Reply with quote

Hmm,
(IN|OUT)BWFORMAT are copied from 'LINK TEMPLATE' the first time config is saved. So I thought some features can be set accurately through text config only .

Is there any way to disable visual editor (for writing only) for particular config file? Weathermap can detect INCLUDE statement(s) and control this ability.


edit:
that logic can be implemented as WeatherMap object property (storing INCLUDE presence status) and check in WriteConfig().
Back to top
BorisL
Cacti User


Joined: 31 Mar 2007
Posts: 55

PostPosted: Fri Jun 05, 2009 12:52 pm    Post subject: Reply with quote

New version of patch: disallow writing new config when current map was build from config file with INCLUDE statement.


INCLUDE.patch
 Description:

Download
 Filename:  INCLUDE.patch
 Filesize:  2.92 KB
 Downloaded:  63 Time(s)

Back to top
Howie
Cacti Guru User


Joined: 16 Sep 2004
Posts: 3437
Location: United Kingdom

PostPosted: Sun Jun 14, 2009 12:38 pm    Post subject: Reply with quote

I've been playing with this a little today. Now each node and link knows which file it was defined in, so WriteConfig will skip nodes or links that weren't defined in the 'main file'. It will also add 'INCLUDE blah.conf' lines for all included files.

I added a restriction that INCLUDE will ONLY be allowed in the global section, so that I don't need to track the state of the parser so much. If you had some nodes, then an include, then the last node before the include would be defined somewhere different in the order than you expected. Since templates are done at ReadConfig time currently, that might be a problem.

The remaining problem is global commands like BACKGROUND or SCALE commands, or font definitions. They will still get written into the main file if they were defined in the include.

However, since the includes are placed at the end of the global section by WriteConfig, whatever is in them will override any settings in the main file. This means the include will 'stick' OK, but will make the editor a little confusing. I think that it's probably good enough for now though.

If you use INCLUDE only to define templates, or to add standard nodes for company logo etc, then the editor will work completely normally.

Sometime soon I'll be changing the templates stuff to work at runtime instead, which means that some ordering restrictions will go away, and hopefully the parser can be a bit smarter about things like preserving comments and order.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Cacti Forum Index -> Plugin: (Network Weather Map) All times are GMT - 5 Hours
Page 1 of 1

 



Powered by phpBB © 2001, 2005 phpBB Group