ztpgenerator icon indicating copy to clipboard operation
ztpgenerator copied to clipboard

`dhcpd_restart_command` subprocess results in errors

Open wdennis opened this issue 6 years ago • 4 comments

When I run ztpgenerator.py device_data.csv, it is now giving me the following errors:

cp: cannot stat '/etc/dhcp/hosts.conf': No such file or directory
rm: cannot remove '/etc/dhcp/hosts.conf': No such file or directory

Generating device and dhcpd config files...

Job for isc-dhcp-server.service failed.
See "systemctl status isc-dhcp-server.service" and "journalctl -xe" for details.
Job for isc-dhcp-server.service failed.
See "systemctl status isc-dhcp-server.service" and "journalctl -xe" for details.
Done generating config files...

Running HTTP Server...
Press "Ctrl+C" in console to close HTTP server.
^C

I do not understand the cp and rm outputs, as the /etc/dhcp/hosts.conf file does exist...

root@junos-ztp:~/ztpgenerator# ls -l /etc/dhcp/hosts.conf
-rw-r--r-- 1 root root 3129 Jan 16 20:16 /etc/dhcp/hosts.conf

Also, as for the restart of the isc-dhcp-server service, journalctl shows the service restart failing with "Start request repeated too quickly":

root@junos-ztp:~/ztpgenerator# journalctl -xe -u isc-dhcp-server
-- Unit isc-dhcp-server.service has finished shutting down.
Jan 16 20:16:04 junos-ztp systemd[1]: isc-dhcp-server.service: Start request repeated too quickly.
Jan 16 20:16:04 junos-ztp systemd[1]: isc-dhcp-server.service: Failed with result 'start-limit-hit'.
Jan 16 20:16:04 junos-ztp systemd[1]: Failed to start ISC DHCP IPv4 server.
-- Subject: Unit isc-dhcp-server.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit isc-dhcp-server.service has failed.
--
-- The result is RESULT.

However, if I start the service by hand (systemctl start isc-dhcp-service) it starts correctly and then is running.

Ever see anything like this?

wdennis avatar Jan 17 '20 13:01 wdennis

I haven't seen this before.

Two items come to mind:

  1. Are you running this as root/sudo? I'm sure you are, but you never know.
  2. I'm thinking likely it's erring out because of the host file issue, so I'm wondering if perhaps something is changing for the python script with the context it's running the os module in. This doesn't really make sense though, especially if it's running as sudo/root.

Not sure to be honest. Perhaps if you copy pasta the entire output from beginning to end, that may reveal something.

consentfactory avatar Jan 17 '20 22:01 consentfactory

Am running the script as user 'root'. My output copy above has the stdout/err from the invocation of the script until I killed the web server with Ctrl-C.

wdennis avatar Jan 20 '20 02:01 wdennis

Can you post a redacted copy of your ztpgenerator.py, dhcpd.cfg, and device_data.csv?

consentfactory avatar Jan 25 '20 17:01 consentfactory

Sorry for the delay - here you go: for-github-issue.tar.gz

wdennis avatar Feb 04 '20 03:02 wdennis