paleoN
Wizard
- Joined
- Apr 22, 2012
- Messages
- 1,402
I give you my little side project I've been stupidly working on for far too many weeks, GUI Slave UPS Support. It was a mistake to ever start it. Still I'm happy it's finished or I'm finished with it at least. The backend is solid. I didn't see a way around the change to notifier.py, but perhaps there is a better way. The GUI is a bit ugly, but functions. Before you ask why I did that dumb thing with the GUI, it's because I have no idea what I am doing. I consider it a minor miracle with how long I was lost in the weeds that I ever made it back at all. Milhouse did a fair job identifying the backend issues in this [thread=3086]thread[/thread].
William, any & all questions, comments, critiques and/or criticisms from you would be most welcome. It has passed my testing and now I'm expecting someone from the community to test it. In particular someone with a slave setup, but I suppose an additional master setup test would be useful as well.
To Install:
Requirements: 8.3.1-RELEASE (r13452)
Details for those who are interested in the particulars or name begins with W.
I didn't see an intelligent way to avoid schema changes for the table services_ups. Two columns are added ups_monuser - varchar(30) default upsmon and ups_modemaster - boolean default 1.
Field ups_monuser: In a slave setup we need to fit in with what's existing which means we need to be able to set the user as well as the password.
Field ups_modemaster: specifies master setup, default, or slave setup.
We can simply reuse ups_identifier allowing '@' and ':' characters on the slave form to be able to specify the remote UPS hostname/IP & port.
A slave setup only needs upsmon configured & running and in our case upssched configured. Ideally, upslog service would be optional if we don't want the traffic.
Backend:
Notifier:
GUI:
I am planning on trying my hand at the migration for the db changes, but I haven't looked at any migrations yet. Other than that I intend to be done with this. This will also be my retirement from any future GUI work. I don't like it.
Like I said if you have a question just ask. I can likely explain it. I will submit patches to Ticket #807 after additional testing.


William, any & all questions, comments, critiques and/or criticisms from you would be most welcome. It has passed my testing and now I'm expecting someone from the community to test it. In particular someone with a slave setup, but I suppose an additional master setup test would be useful as well.
To Install:
Requirements: 8.3.1-RELEASE (r13452)
- Backup current settings and optionally use your alternate USB stick with a separate install.
- Download View attachment slaveUPS.zip : Extract slaveUPS.sh, slaveUPS.sql and slaveUPS.patch to NAS.
- chmod 700 slaveUPS.sh
- ./slaveUPS.sh
- Configure UPS Service.
Details for those who are interested in the particulars or name begins with W.
I didn't see an intelligent way to avoid schema changes for the table services_ups. Two columns are added ups_monuser - varchar(30) default upsmon and ups_modemaster - boolean default 1.
Field ups_monuser: In a slave setup we need to fit in with what's existing which means we need to be able to set the user as well as the password.
Field ups_modemaster: specifies master setup, default, or slave setup.
We can simply reuse ups_identifier allowing '@' and ':' characters on the slave form to be able to specify the remote UPS hostname/IP & port.
A slave setup only needs upsmon configured & running and in our case upssched configured. Ideally, upslog service would be optional if we don't want the traffic.
Backend:
ix-ups
Assorted changes to nut .conf files.
For slave mode we don't generate ups.conf, upsd.conf or upsd.users. The upsd daemon isn't even started in a slave setup.
rc.conf.local
Conditionally enable nut service based on ups_modemaster.
Assorted changes to nut .conf files.
For slave mode we don't generate ups.conf, upsd.conf or upsd.users. The upsd daemon isn't even started in a slave setup.
rc.conf.local
Conditionally enable nut service based on ups_modemaster.
Notifier:
notifier.py
Which leads to the somewhat ugly, yet functional, change to notifier.py. Updates __service2daemon["ups"] to ("upsmon", "/var/db/nut/upsmon.pid") for slave setup. I'm open to a better way to accomplish this. For the UPS service, in a master setup it should depend on upsd while a slave setup needs to depend on upsmon instead.
Which leads to the somewhat ugly, yet functional, change to notifier.py. Updates __service2daemon["ups"] to ("upsmon", "/var/db/nut/upsmon.pid") for slave setup. I'm open to a better way to accomplish this. For the UPS service, in a master setup it should depend on upsd while a slave setup needs to depend on upsmon instead.
GUI:
The GUI ... might be better to just toss all of it and do it more intelligently. Still what I have functions and I've spent nearly all the time on the GUI as it is. Wound up using a proxy UPS class for the slave setup. That's what can happen when you start flailing around.
ups_edit templates
Add Slave/Master button which takes you to the opposing form.
core.html
Launches appropriate form based on the db.
forms.py
Automatically save ups_modemaster based on which form you are on and added slave form.
models.py
Renamed master pass field and added UPSMON User field.
nav.py
Blacklisted UPS & UPSSlave. UPSnav launches appropriate form based on the value of notifier__service2daemon["ups"].
ups_edit templates
Add Slave/Master button which takes you to the opposing form.
core.html
Launches appropriate form based on the db.
forms.py
Automatically save ups_modemaster based on which form you are on and added slave form.
models.py
Renamed master pass field and added UPSMON User field.
nav.py
Blacklisted UPS & UPSSlave. UPSnav launches appropriate form based on the value of notifier__service2daemon["ups"].
I am planning on trying my hand at the migration for the db changes, but I haven't looked at any migrations yet. Other than that I intend to be done with this. This will also be my retirement from any future GUI work. I don't like it.
Like I said if you have a question just ask. I can likely explain it. I will submit patches to Ticket #807 after additional testing.