Support setting the OpenStack region per appserver.
Created by: smarnach
This change allows launching appservers in other regions than the default region.
Testing instructions
Set openstack_region
to a different region on the instance, then spawn a new appserver. The region you choose needs to have the base image and SSH key needed for the instance.
Author concerns
- In line with the other OpenStack settings, I avoided storing the region on individual appservers. See my comment here.
- The OpenStack region is needed to create the Nova client, which is done in the
OpenStackServer
constructor. This only works if the region is stored on the server as well. TheOpenStackServer
is instantiated in the abstract base classAppServer
, so the region needs to be accessible there. This means I need to add the region toInstance
instead ofOpenEdXInstance
. - I had to remove the declaration of base classes from the migration that creates the
OpenEdXInstance
model. Django imports the current version of the base class and implicitly creates all fields in that current version, which defies the whole purpose of migrations as a record of historic versions of the model. thebases
parameter toCreateModel
can take a string of the formapp_name.model_name
to retrieve a historic version of a model. However, this only works for actual models, not for abstract models, so we can't do this in this case. Simply removing thebases
parameter seems to work fine though, so this is what I'm doing for now. (This was rather difficult to debug, by the way, since there was no indication what was wrong. The new migration applies fine to the current state of the database, but if you try to run all migrations on a pristine database, the last one fails with the error that theopenstack_region
field already exists. But none of the earlier migrations contains a reference to this field, so it was completely unclear how that happened.) - Even though all lines of code I added are tested, the total coverage had dropped for reasons I don't understand, so I had to add some tests for completely unrelated code (and I found a minor bug when doing so).
Reviewers
-
@pomegranited