SoftwareDefinedBuildings / smap

smap - Simple Measurement and Actuation Profile
Other
30 stars 36 forks source link

Dependencies on PowerDB2 #1

Open immesys opened 10 years ago

immesys commented 10 years ago

The sMAP archiver needs some infrastructure in postgres for handling subscription keys. Unfortunately, the tables for that are made when you install powerdb2.

Ideally the archiver should be separate from whichever frontend you choose to use.

stevedh commented 10 years ago

True enough -- there is a sql script in there to add the tables but there's still no UI for managing those keys. I've yet to come up with a great solution to this, although maybe we could have a little script. Bake it into smap-tool or smap-query?

immesys commented 10 years ago

So I was busy whipping the functionality into smap-tool, and testing it when I noticed that somewhere along the line a foreign key constraint is added so that the owner_id column in subscription references a legit user in auth_user. It doesn't seem to be in the scripts in sMAP so it must be part of powerdb's installation.

My understanding is that auth_user is django specific (it certainly seems to have a django specific password hash). So while I could sometimes directly inject a subscription key into the database for archiver deployments sans powerdb, things might get ugly if I later install powerdb2. I can't remember what happens if you try create a foreign key constraint when there are records that currently violate it, but I think it results in an error, so the powerdb2 installation would probably bail.

A workaround I can think of is perhaps relaxing the foreign key constraint on owner_id and allowing it to be null in the case where it doesn't have an owner?