Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ip address's state definition has been changed since phpipam v1.2 #1

Open
ghost opened this issue Feb 11, 2016 · 4 comments
Open

ip address's state definition has been changed since phpipam v1.2 #1

ghost opened this issue Feb 11, 2016 · 4 comments

Comments

@ghost
Copy link

ghost commented Feb 11, 2016

Hello Maciej

I found you phpipam scripts very useful
but since version 1.2 phpipam has been completely rewriten
and your hardcoded statements of a state values don't fit it anymore

let me explain what have happened in python style
in previous versions of phpipam there were a dictionary {active:1, reserver:2, offline:0, dhcp:3}
now this dictionary has been trasformed to {active:2, reserver:3, offline:1, dhcp:4}

I would rewrite your code but I'am new to github so I don't know how to use it
can you rewrite you script to match new version?

Thx,
Nikolay

@drybjed
Copy link
Member

drybjed commented Feb 11, 2016

@IDQDD Hello, and thanks for the heads up.

The phpIPAM script here is kind of crude, because it directly scrapes the MySQL database for relevant data. I would gladly change that to use the phpIPAM API, if/when I learn to use it programatically - I'm a sysadmin, not a programmer. :-)

Sure, I can update the scripts when I find some time. Do you know if the phpIPAM database has a version field which could be checked? That way the script could support both versions at the same time.

@ghost
Copy link
Author

ghost commented Feb 11, 2016

Maciej

IPAM API sounds good
but do keep in mind they change their API as fast as MySQL structure :)

I did some greps and found out that the state values had been changed since version 1.1.5
this is an UPDATE-v1.15.sql (first line has an answer of your question about a version field)

/* Update version */
UPDATE settings set version = '1.15';

/* insert default values */
INSERT INTO ipTags (id, type, showtag, bgcolor, fgcolor, locked)
VALUES
(1, 'Offline', 1, '#f59c99', '#ffffff', 'Yes'),
(2, 'Used', 0, '#a9c9a4', '#ffffff', 'Yes'),
(3, 'Reserved', 1, '#9ac0cd', '#ffffff', 'Yes'),
(4, 'DHCP', 1, '#c9c9c9', '#ffffff', 'Yes');

/* update ipaddresses */
UPDATE ipaddresses SET state = 1 WHERE state > 3;
UPDATE ipaddresses SET state = 4 WHERE state = 3;
UPDATE ipaddresses SET state = 3 WHERE state = 2;
UPDATE ipaddresses SET state = 2 WHERE state = 1;
UPDATE ipaddresses SET state = 1 WHERE state = 0;

p.s. I'm not a programmer either but seems we sysadmins have to become programmers to keep up the good job

@drybjed
Copy link
Member

drybjed commented Feb 11, 2016

@IDQDD Indeed! Thanks for the research, I'll look into it when I have some time, perhaps on the weekend.

@esebille
Copy link

I have found a workaround to get IP addresses from the database.

If you use inet_ntoa(ip_addr) in the query it get the pointed decimal notation !

I'm trying to get the script to work, but we miss almost all hostnames in phpipam...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants