Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Thu Apr 25, 2019 7:04 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Change in API
PostPosted: Mon Oct 29, 2018 4:51 am 
Offline
Cacti User

Joined: Wed Dec 07, 2011 9:19 am
Posts: 322
Is it possible to make a general change in any evolution on API function ?
I mean when you decide to add a parameters, is it possible to:
1: add it at the end of the call
2: make it with a default value

So during migration at least current product are still able to work, and that let some time to adapt to the new definition ?

I'm using api_tree_item_save, and you decide to add the site_id in the middle of the call, an I don't think it's very good to act like that, since the CHANGELOG dosen't reflect that change:
1.2.0 Beta 1
-feature: Allow threads to be set a Data Collector level
-feature: Support Cacti 1.2's new data collection method
-feature: Escape strings more rubustly
-issue#50: make in Debian 7: undefined reference to `clock_gettime'
-issue#53: Variables are not being escaped properly when updating database
-issue#54: Spine should always report if ICMP fails
-issue#58: Error on poller.c: escaping string from snmp_sysLocation
-issue#63: Adjust Device Threads if a Device has fewer Data Sources
-issue: Align SQL_MODE's in spine with Cacti's database api

_________________
CentOS
Production
Cacti 0.8.8h
Spine 0.8.8h
PIA 3.1
Aggregate 0.75
Monitor 1.3
Settings 0.71
Weathermap 0.98
Thold 0.5
rrdclean 0.41

Own plugin: LinkDiscovery 0.3, Map 0.4

Test
Cacti 1.2.1
Spine 1.2.1
thold 1.0.6
monitor 2.3.5
php 7.2.11
mariadb 5.5.56
Own plugin:
ExtendDB 1.1.2
LinkDiscovery 1.2.4
Map 1.2.5


Top
 Profile  
 
 Post subject: Re: Change in API
PostPosted: Mon Oct 29, 2018 7:45 am 
Offline
Cacti Guru User

Joined: Sun Aug 27, 2017 12:05 am
Posts: 2414
Quote:
Now
function api_device_save($id, $host_template_id, $description, $hostname, $snmp_community, $snmp_version,
$snmp_username, $snmp_password, $snmp_port, $snmp_timeout, $disabled,
$availability_method, $ping_method, $ping_port, $ping_timeout, $ping_retries,
$notes, $snmp_auth_protocol, $snmp_priv_passphrase, $snmp_priv_protocol, $snmp_context, $snmp_engine_id,
$max_oids = 5, $device_threads = 1, $poller_id = 1, $site_id = 1, $external_id = '', $location = '') {


Working backwards:
Location was added in commit f6510d680585e6b4461c1f2f3116bb436beb9bc0
External ID was added in commit 2e33bc95b29ec52032fa78f7bff024cd99239a6d
Site ID and Poller ID were changed from a ZERO default ot ONE in commit 8f304f744cdf67c3f08236f4f0e5d7178ab425bf
SNMP Engine ID was added in the middle in commit 76d75b0de33f790a27b33190c3785ecc939d57e5 (it's a required field)
Site ID and Poller ID were added in 247228c84e9790fce4415734559761bbb3eeed4a

These are all v1.2 changes as far as I can tell and all follow the practice you are describing with the exception of snmp_engine_id which unusually was added in the middle and does NOT have a default. That is irregular in terms of an API function but as with any API that could happen as it's a different version. If you are using this function from your own plugin, you can use the CACTI_VERSION constant to compare and see if that field would be required.

As the documentation is slowly being updated, that will also highlight potential API function call issues but we are not there yet.

_________________
Official Cacti Developer

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation

My resources:
How to submit Pull Requests
Development Wiki and How To's
Updated NetSNMP Memory template for Cacti 1.x
Cisco SFP template for Cacti 0.8.8


Top
 Profile  
 
 Post subject: Re: Change in API
PostPosted: Mon Oct 29, 2018 8:31 am 
Offline
Cacti User

Joined: Wed Dec 07, 2011 9:19 am
Posts: 322
Hello,
Thanks,
But I'm talking about api_tree_item_save and can't find anything on when it change.

_________________
CentOS
Production
Cacti 0.8.8h
Spine 0.8.8h
PIA 3.1
Aggregate 0.75
Monitor 1.3
Settings 0.71
Weathermap 0.98
Thold 0.5
rrdclean 0.41

Own plugin: LinkDiscovery 0.3, Map 0.4

Test
Cacti 1.2.1
Spine 1.2.1
thold 1.0.6
monitor 2.3.5
php 7.2.11
mariadb 5.5.56
Own plugin:
ExtendDB 1.1.2
LinkDiscovery 1.2.4
Map 1.2.5


Top
 Profile  
 
 Post subject: Re: Change in API
PostPosted: Mon Oct 29, 2018 8:47 am 
Offline
Cacti Guru User

Joined: Sun Aug 27, 2017 12:05 am
Posts: 2414
Sorry, my bad, let me go check.

_________________
Official Cacti Developer

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation

My resources:
How to submit Pull Requests
Development Wiki and How To's
Updated NetSNMP Memory template for Cacti 1.x
Cisco SFP template for Cacti 0.8.8


Top
 Profile  
 
 Post subject: Re: Change in API
PostPosted: Mon Oct 29, 2018 8:50 am 
Offline
Cacti Guru User

Joined: Sun Aug 27, 2017 12:05 am
Posts: 2414
So that appears to be changed in commit 2c4b143c which was over a year ago in relation to:
https://github.com/cacti/cacti/issues/122

_________________
Official Cacti Developer

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation

My resources:
How to submit Pull Requests
Development Wiki and How To's
Updated NetSNMP Memory template for Cacti 1.x
Cisco SFP template for Cacti 0.8.8


Top
 Profile  
 
 Post subject: Re: Change in API
PostPosted: Mon Oct 29, 2018 9:09 am 
Offline
Cacti User

Joined: Wed Dec 07, 2011 9:19 am
Posts: 322
Ok
was not on release 1.1.38

_________________
CentOS
Production
Cacti 0.8.8h
Spine 0.8.8h
PIA 3.1
Aggregate 0.75
Monitor 1.3
Settings 0.71
Weathermap 0.98
Thold 0.5
rrdclean 0.41

Own plugin: LinkDiscovery 0.3, Map 0.4

Test
Cacti 1.2.1
Spine 1.2.1
thold 1.0.6
monitor 2.3.5
php 7.2.11
mariadb 5.5.56
Own plugin:
ExtendDB 1.1.2
LinkDiscovery 1.2.4
Map 1.2.5


Top
 Profile  
 
 Post subject: Re: Change in API
PostPosted: Mon Oct 29, 2018 9:19 am 
Offline
Cacti Guru User

Joined: Sun Aug 27, 2017 12:05 am
Posts: 2414
That's interesting, as I don't recall changing that in one of Howie's plugins that does tree manipulation. I'll have to have a look.

_________________
Official Cacti Developer

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation

My resources:
How to submit Pull Requests
Development Wiki and How To's
Updated NetSNMP Memory template for Cacti 1.x
Cisco SFP template for Cacti 0.8.8


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group