Migration from old to new API - user realms

Discussions on developing plugins for the Cacti Plugin Architecture

Moderators: Developers, Moderators

Post Reply
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Migration from old to new API - user realms

Post by Howie »

Is there anything in the API to make it nicer to move from the old, fixed realm numbers to dynamically allocated ones?

I can't see how I can migrate old permissions with confidence that I'm not just rewriting some other plugins permissions - I know that weathermap used to use 42 and 43.

If I get allocated a dynamic realm number, how do I know that the 42 and 43 in the user's system are old weathermap permissions and not some other plugin's dynamic realm?

The alternative is not to migrate them at all, which makes the user suffer for something that's not their fault.
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
User avatar
gthe
Cacti User
Posts: 410
Joined: Sat Jul 29, 2006 1:23 pm
Location: RU

Post by gthe »

In snmptt plugin I use this to check snmptt admin realms status :

Code: Select all

function is_snmptt_admin () {
global $user_auth_realm_filenames;
$rezult = 0;
//get snmptt Plugin -> SNMPTT: Manage Realm ID
$snmptt_admin_realm_id = db_fetch_cell("SELECT `id`+100 FROM `plugin_realms` where `display` like 'plugin%snmptt%manage%'");

if (isset($snmptt_admin_realm_id)) {
	//Check this user - for snmptt admin realms
	if ((db_fetch_assoc("select user_auth_realm.realm_id from user_auth_realm
		where user_auth_realm.user_id='" . $_SESSION["sess_user_id"] . "'
		and user_auth_realm.realm_id='$snmptt_admin_realm_id'")) && (!empty($snmptt_admin_realm_id))) {
			$rezult = 1;
		}	
}

return $rezult;

}
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

But that also doesn't check that it isn't already in use by another plugin.
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
User avatar
gthe
Cacti User
Posts: 410
Joined: Sat Jul 29, 2006 1:23 pm
Location: RU

Post by gthe »

1. I think is made specially for this purpose what not to be crossed with old realms

Code: Select all

`id`+100
2. Why You need to know who uses old realmID ? After installing new version of Weathermap with PA 2.x admin must recheck users permission and new realmID will be added.
My cacti plugin -[url=http://forums.cacti.net/viewtopic.php?p=156769#156769]CaMM[/url]
[size=75]Sorry for my English. [/size]
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

gthe wrote:1. I think is made specially for this purpose what not to be crossed with old realms

Code: Select all

`id`+100
No, that only finds a realm 100 above the other one. You don't check if it's already in use. Some plugins use large fixed numbers to try and avoid clashes too. Most of the time you will be lucky, but it's not right.
2. Why You need to know who uses old realmID ? After installing new version of Weathermap with PA 2.x admin must recheck users permission and new realmID will be added.
I see that as a failure. Suppose the user has set up hundreds of users... why should they be forced to repeat that work?
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
User avatar
gthe
Cacti User
Posts: 410
Joined: Sat Jul 29, 2006 1:23 pm
Location: RU

Post by gthe »

Howie wrote:
gthe wrote:1. I think is made specially for this purpose what not to be crossed with old realms

Code: Select all

`id`+100
No, that only finds a realm 100 above the other one. You don't check if it's already in use. Some plugins use large fixed numbers to try and avoid clashes too. Most of the time you will be lucky, but it's not right.
But even if you find unused realmID for install pia2.x plugin - there are no guarantees that then in future user don't install old plugin with you new realmID.
Howie wrote:
2. Why You need to know who uses old realmID ? After installing new version of Weathermap with PA 2.x admin must recheck users permission and new realmID will be added.
I see that as a failure. Suppose the user has set up hundreds of users... why should they be forced to repeat that work?
I think it is a way go away from using realmID.
My cacti plugin -[url=http://forums.cacti.net/viewtopic.php?p=156769#156769]CaMM[/url]
[size=75]Sorry for my English. [/size]
User avatar
phalek
Developer
Posts: 2838
Joined: Thu Jan 31, 2008 6:39 am
Location: Kressbronn, Germany
Contact:

Post by phalek »

I guess it would be first sufficient if there was a table containing all used realm ids, maybe also some process for actually requesting fixed IDs ?

Kindof:
1-1000 reserverd
1000-5000 realmid needs to be registered centrally
5000-6000 realmids that can be freely used but maybe overwritten by other plugins

?

Other than that, dynamic would be to use the MAX(ID)+1 statement, I guess?
Greetings,
Phalek
---
Need more help ? Read the Cacti documentation or my new Cacti 1.x Book
Need on-site support ? Look here Cacti Workshop
Need professional Cacti support ? Look here CereusService
---
Plugins : CereusReporting
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests