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    


PA 2.1 1st steps

 
Post new topic   Reply to topic    Cacti Forum Index -> Plugin Architecture
Author Message
divagater
Cacti User


Joined: 17 Nov 2004
Posts: 101
Location: Chapel Hill, NC.

PostPosted: Fri Apr 04, 2008 7:23 am    Post subject: PA 2.1 1st steps Reply with quote

I am trying to wrap my head around the flow/usage for the features in 2.1. Right off the bat I am stuck on api_plugin_install(). The 'Plugin Management' link calls plugins.php in the root of cacti/.

plugins.php 1st calls retrieve_plugin_list() which calls the following sql:

SELECT directory FROM plugin_config ORDER BY name

I only see one place where entries are added to the plugin_config table and that is in api_plugin_install(). api_plugin_install() is only called from cacti/plugins.php and is initiated from a web request which should include mode and id. id being the name of the plugin and mode being install, uninstall, enable, etc.

cacti/plugins.php includes some links for installing, uninstalling etc. however those links are in a foreach($plugins) loop and the list of plugins is built from plugin_config which is built from api_plugin_install... so I appear to be stuck in an evil loop.

Additionally, the existance of plugin_<plugin_name>_install() in setup.php will cause the plugin to not be available at all as is the case with aggregate, do to what looks like this line in the api_plugin_hook_function method:

Code:
if (function_exists($function)  && !function_exists('plugin_' . $pname . '_install') && !in_array($pname, $p)) {


So none of the methods in setup.php will be executed if a method called plugin_<plugin_name>_install exists. So the question is, what is missing to actually kick off the process of getting a plugin "installed" in PA 2.1? It sort of looks like we need to provide the users with a well formed url to kick off the install process. Any insight appreciated as I am probably missing something obvious.

Thanks,
Billy
Back to top
TheWitness
Developer


Joined: 14 May 2002
Posts: 9697
Location: MI, USA

PostPosted: Fri Apr 04, 2008 12:57 pm    Post subject: Reply with quote

Billy,

Have you looked at Manage's organization of Setup.php yet? Also, ping Jimmy, he wrote it and has some unpublished plugins that use it.

Larry
Back to top
divagater
Cacti User


Joined: 17 Nov 2004
Posts: 101
Location: Chapel Hill, NC.

PostPosted: Fri Apr 04, 2008 1:21 pm    Post subject: Reply with quote

Thanks for the tip, I will check out manage. I wanted to save hitting up Jimmy as a last resort hoping some one had found the solution.

Cheers,
Billy
Back to top
divagater
Cacti User


Joined: 17 Nov 2004
Posts: 101
Location: Chapel Hill, NC.

PostPosted: Fri Apr 04, 2008 7:15 pm    Post subject: Reply with quote

TheWitness wrote:
Billy,

Have you looked at Manage's organization of Setup.php yet? Also, ping Jimmy, he wrote it and has some unpublished plugins that use it.

Larry


The manage plugin was the secret sauce I needed. It was actually the readme file that saved me as it showed how a plugin should be installed in 2.x. In my case I was the cause of all the trouble. I had a copy of NPC in the plugins directory called npc-2.x.x or whatever so I could easily switch between versions for support. This was breaking the functionality of non-legacy plugins, those with a method called plugin_<plugin-name>_install. Because the new PA does a directory scan to find plugins it was finding both versions of NPC even though only one version was declared in global.php. This was causing the following fatal error breaking all 2.x plugins:

PHP Fatal error: Cannot redeclare plugin_init_npc()

Once the duplicate plugin was removed aggregate and manage show up under plugin management. I hope my folly can help others...

Cheers,
Billy
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Cacti Forum Index -> Plugin Architecture All times are GMT - 5 Hours
Page 1 of 1

 



Powered by phpBB © 2001, 2005 phpBB Group