I tested it without success. I run it like this:
sudo python3 generate_dhcp_config.py -u admin -p password -e http://192.168.0.31:8080 -a ipam
When i run above command i get error:
AttributeError: module 'datetime' has no attribute 'now'
To solve that i added line:
from datetime import datetime
Second problem, when i ran above command ( I have DHCP range defined in phpipam):
Backing up original config.
Original config backed up.
Getting subnet DHCP data.
{'id': '141', 'subnet': '192.168.10.0', 'mask': '25', 'sectionId': '1', 'description': ' testib', 'linked_subnet': None, 'firewallAddressObject': None, 'vrfId': '0', 'masterSubnetId': '0', 'allowRequests': '0', 'vlanId': '3', 'showName': '0', 'device': '0', 'permissions': [{'group_id': 3, 'permission': '1', 'name': 'Guests', 'desc': 'default Guest group (viewers)', 'members': False}, {'group_id': 2, 'permission': '2', 'name': 'Operators', 'desc': 'default Operator group', 'members': False}], 'pingSubnet': '0', 'discoverSubnet': '0', 'resolveDNS': '0', 'DNSrecursive': '0', 'DNSrecords': '0', 'nameserverId': '0', 'scanAgent': '0', 'customer_id': None, 'isFolder': '0', 'isFull': '0', 'tag': '2', 'threshold': '0', 'location': [], 'editDate': '2022-01-29 14:33:49', 'lastScan': None, 'lastDiscovery': None}
{'id': '141', 'subnet': '192.168.10.0', 'mask': '25', 'sectionId': '1', 'description': ' testib', 'linked_subnet': None, 'firewallAddressObject': None, 'vrfId': '0', 'masterSubnetId': '0', 'allowRequests': '0', 'vlanId': '3', 'showName': '0', 'device': '0', 'permissions': [{'group_id': 3, 'permission': '1', 'name': 'Guests', 'desc': 'default Guest group (viewers)', 'members': False}, {'group_id': 2, 'permission': '2', 'name': 'Operators', 'desc': 'default Operator group', 'members': False}], 'pingSubnet': '0', 'discoverSubnet': '0', 'resolveDNS': '0', 'DNSrecursive': '0', 'DNSrecords': '0', 'nameserverId': '0', 'scanAgent': '0', 'customer_id': None, 'isFolder': '0', 'isFull': '0', 'tag': '2', 'threshold': '0', 'location': [], 'editDate': '2022-01-29 14:33:49', 'lastScan': None, 'lastDiscovery': None}
{'id': '141', 'subnet': '192.168.10.0', 'mask': '25', 'sectionId': '1', 'description': ' testib', 'linked_subnet': None, 'firewallAddressObject': None, 'vrfId': '0', 'masterSubnetId': '0', 'allowRequests': '0', 'vlanId': '3', 'showName': '0', 'device': '0', 'permissions': [{'group_id': 3, 'permission': '1', 'name': 'Guests', 'desc': 'default Guest group (viewers)', 'members': False}, {'group_id': 2, 'permission': '2', 'name': 'Operators', 'desc': 'default Operator group', 'members': False}], 'pingSubnet': '0', 'discoverSubnet': '0', 'resolveDNS': '0', 'DNSrecursive': '0', 'DNSrecords': '0', 'nameserverId': '0', 'scanAgent': '0', 'customer_id': None, 'isFolder': '0', 'isFull': '0', 'tag': '2', 'threshold': '0', 'location': [], 'editDate': '2022-01-29 14:33:49', 'lastScan': None, 'lastDiscovery': None}
{'id': '141', 'subnet': '192.168.10.0', 'mask': '25', 'sectionId': '1', 'description': ' testib', 'linked_subnet': None, 'firewallAddressObject': None, 'vrfId': '0', 'masterSubnetId': '0', 'allowRequests': '0', 'vlanId': '3', 'showName': '0', 'device': '0', 'permissions': [{'group_id': 3, 'permission': '1', 'name': 'Guests', 'desc': 'default Guest group (viewers)', 'members': False}, {'group_id': 2, 'permission': '2', 'name': 'Operators', 'desc': 'default Operator group', 'members': False}], 'pingSubnet': '0', 'discoverSubnet': '0', 'resolveDNS': '0', 'DNSrecursive': '0', 'DNSrecords': '0', 'nameserverId': '0', 'scanAgent': '0', 'customer_id': None, 'isFolder': '0', 'isFull': '0', 'tag': '2', 'threshold': '0', 'location': [], 'editDate': '2022-01-29 14:33:49', 'lastScan': None, 'lastDiscovery': None}
Traceback (most recent call last):
File "generate_dhcp_config.py", line 136, in <module>
print(main())
File "generate_dhcp_config.py", line 128, in main
result = run.create_config()
File "generate_dhcp_config.py", line 96, in create_config
config = self._dhcp_config_generator()
File "generate_dhcp_config.py", line 53, in _dhcp_config_generator
ranges = self._get_subnet_dhcp_ranges()
File "generate_dhcp_config.py", line 44, in _get_subnet_dhcp_ranges
dhcp_range = subnet_info.dhcp_range
File "/home/imre/phpipam-dhcp-config-generator-main/classes.py", line 61, in __getattr__
raise AttributeError(f'{__class__.__name__} has no attribute "{key}"')
AttributeError: IPAMObject has no attribute "dhcp_range"