callum027 / ipam-migrator Goto Github PK
View Code? Open in Web Editor NEWData migration tool for between phpIPAM and NetBox
License: GNU General Public License v3.0
Data migration tool for between phpIPAM and NetBox
License: GNU General Public License v3.0
Any plans to fix this script?
Hi,
I tired to migrate phpipam to netbox but getting error below,
2020-08-20 13:38:18,567 ipam-migrator: [INFO] Searching for sections...
2020-08-20 13:38:18,740 ipam-migrator: [ERROR] Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/ipam_migrator-1.0.0-py3.6.egg/ipam_migrator/ipam_migrator.py", line 172, in main
input_database = input_backend.database_read()
File "/usr/local/lib/python3.6/site-packages/ipam_migrator-1.0.0-py3.6.egg/ipam_migrator/backend/phpipam.py", line 296, in database_read
sections = self.sections_read() if read_prefixes or read_ip_addresses else None
File "/usr/local/lib/python3.6/site-packages/ipam_migrator-1.0.0-py3.6.egg/ipam_migrator/backend/phpipam.py", line 331, in sections_read
for data in self.api_read("sections"):
File "/usr/local/lib/python3.6/site-packages/ipam_migrator-1.0.0-py3.6.egg/ipam_migrator/backend/phpipam.py", line 208, in api_read
self.api_authenticate()
File "/usr/local/lib/python3.6/site-packages/ipam_migrator-1.0.0-py3.6.egg/ipam_migrator/backend/phpipam.py", line 185, in api_authenticate
obj = response.json()
File "/usr/local/lib/python3.6/site-packages/requests-2.24.0-py3.6.egg/requests/models.py", line 898, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib64/python3.6/json/init.py", line 354, in loads
return _default_decoder.decode(s)
File "/usr/lib64/python3.6/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib64/python3.6/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2020-08-20 13:38:18,746 ipam-migrator: [DEBUG] stopping logger
I used the fork https://github.com/absynth47215/ipam-migrator
Thank you @Callum027 and @absynth47215 for sharing your work!
When I run this command:
$ ipam-migrator --log-level DEBUG -naisv https://localhost/api/netbox,phpipam,login,username,ipamadmin
It does it's thing for a while and then stops with this error:
2022-01-19 09:12:15,789 ipam-migrator: [INFO] Found 1420 prefixes.
2022-01-19 09:12:15,790 ipam-migrator: [INFO] Searching for IP addresses used in found prefixes...
2022-01-19 09:14:42,645 ipam-migrator: [DEBUG] found IP address 10.x.x.x with description 'Security loopback'
2022-01-19 09:14:42,647 ipam-migrator: [DEBUG] found IP address 10.x.x.x with description 'Security loopback'
2022-01-19 09:16:30,041 ipam-migrator: [INFO] Found 2 IP addresses.
2022-01-19 09:16:30,042 ipam-migrator: [INFO] Searching for VLANs...
2022-01-19 09:16:30,298 ipam-migrator: [ERROR] ('vlan',)
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/ipam_migrator-1.0.0-py3.9.egg/ipam_migrator/ipam_migrator.py", line 172, in main
input_database = input_backend.database_read()
File "/usr/local/lib/python3.9/dist-packages/ipam_migrator-1.0.0-py3.9.egg/ipam_migrator/backend/phpipam.py", line 310, in database_read
vlans = self.vlans_read() if read_vlans else None
File "/usr/local/lib/python3.9/dist-packages/ipam_migrator-1.0.0-py3.9.egg/ipam_migrator/backend/phpipam.py", line 421, in vlans_read
if "GET" in self.api_controller_methods("vlan")[("vlan",)]:
KeyError: ('vlan',)
2022-01-19 09:16:30,323 ipam-migrator: [DEBUG] stopping logger
Any ideas?
Hi,
thanks for your script :)
I test to migrate my phpipam to netbox
phpipam version 1.4
When I test the migration :
ipam-migrator "http://10.xxx.yyy.zzz/api/migrator,phpipam,login,admin,gremzoihvnzemo$" --log-level DEBUG
the connection is ok but, when listed the vlan i received the error :
2021-02-16 17:08:42,709 ipam-migrator: [INFO] Searching for VLANs...
2021-02-16 17:08:42,718 ipam-migrator: [INFO] NOTE: 'vlans' controller root 'GET' method not supported by API endpoint, using iterative path (consider upgrading to phpIPAM 1.3+)```
and
```2021-02-16 17:09:22,583 ipam-migrator: [ERROR]
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/ipam_migrator-1.0.0-py3.8.egg/ipam_migrator/ipam_migrator.py", line 172, in main
input_database = input_backend.database_read()
File "/usr/local/lib/python3.8/dist-packages/ipam_migrator-1.0.0-py3.8.egg/ipam_migrator/backend/phpipam.py", line 311, in database_read
vrfs = self.vrfs_read() if read_vrfs else None
File "/usr/local/lib/python3.8/dist-packages/ipam_migrator-1.0.0-py3.8.egg/ipam_migrator/backend/phpipam.py", line 453, in vrfs_read
raise NotImplementedError()
NotImplementedError```
do you have any idea of the problem ?
thank you for your help :)
I used the fork https://github.com/absynth47215/ipam-migrator
Thank you @Callum027 and @absynth47215 for sharing your work!
I have phpIPAM v1.4.5 and NetBox v3.1.5
When I do a migration with the following command:
$ ipam-migrator --log-level DEBUG -naisv -noasv https://localhost/api/netbox,phpipam,login,username,ipamadmin https://192.168.0.2/api,netbox,key,secretkey"
It connects fine to both servers but fails after a while when writing data to NetBox with the following message:
2022-01-19 14:45:58,484 ipam-migrator: [INFO] Wrote 785 VLANs.
2022-01-19 14:45:58,487 ipam-migrator: [INFO] Writing prefixes...
2022-01-19 14:45:58,734 ipam-migrator: [DEBUG] updated prefix 10.x.x.x/29 with description 'albatross_server'
2022-01-19 14:45:58,972 ipam-migrator: [DEBUG] updated prefix 10.x.x.x/28 with description 'albatross_server2'
2022-01-19 14:45:58,973 ipam-migrator: [ERROR] 34
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/ipam_migrator-1.0.0-py3.9.egg/ipam_migrator/ipam_migrator.py", line 183, in main
output_backend.database_write(input_database)
File "/usr/local/lib/python3.9/dist-packages/ipam_migrator-1.0.0-py3.9.egg/ipam_migrator/backend/netbox.py", line 388, in database_write
prefixes_new, prefixes_old_to_new = self.prefixes_write(
File "/usr/local/lib/python3.9/dist-packages/ipam_migrator-1.0.0-py3.9.egg/ipam_migrator/backend/netbox.py", line 511, in prefixes_write
"vrf": vrfs_old_to_new[prefix.vrf_id] if prefix.vrf_id else None,
KeyError: 34
2022-01-19 14:45:58,998 ipam-migrator: [DEBUG] stopping logger
Let me know if there is something I can do to help debugging this.
I believe the order of the parameters is wrong in netbox.py
super().init(name, logger)
should be
super().init(logger, name)
Hello,
First of all thanks for sharing the code with the rest of us. It's always good to find solution for the problem that you face.
When using your code I faced an issue as following
File "/usr/local/lib/python3.8/dist-packages/ipam_migrator-1.0.0-py3.8.egg/ipam_migrator/backend/netbox.py", line 455, in vlans_write
self.logger.info("Writing VLANs...")
AttributeError: 'str' object has no attribute 'info'
2021-06-18 13:31:10,194 ipam-migrator: [DEBUG] stopping logger
What I found in the code is that in NetBox API backend constructor the args are mixed.
It is super().__init__(name, logger)
while it should be super().__init__(logger, name)
Best,
hello, can you provide example of full command for migrating phpipam to netbox ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.