fix instance migration is_isolated() issue

* Older versions of Instance model code may not contain the
is_isolated() method. This change accounts for that fact.
This commit is contained in:
chris meyers 2020-02-05 09:16:31 -05:00
parent e54fd19bca
commit a36bf4af64

View File

@ -7,7 +7,10 @@ from django.db import migrations
def _generate_new_uuid_for_iso_nodes(apps, schema_editor):
Instance = apps.get_model('main', 'Instance')
for instance in Instance.objects.all():
if instance.is_isolated():
# The below code is a copy paste of instance.is_isolated()
# We can't call is_isolated because we are using the "old" version
# of the Instance definition.
if instance.rampart_groups.filter(controller__isnull=False).exists():
instance.uuid = str(uuid4())
instance.save()