def save(self, **kwargs): """ Set default values before saving the instance. """ # Set default field values from settings - using the `default` field attribute confuses # automatically generated migrations, generating a new one when settings don't match if not self.edx_platform_commit: self.edx_platform_commit = self.openedx_release if self.storage_type is None: self.storage_type = settings.INSTANCE_STORAGE_TYPE # If left blank, the base playbook name will be automatically selected # based on the openedx release if not self.configuration_playbook_name: self.configuration_playbook_name = get_base_playbook_name( self.openedx_release) if self.random_prefix is not None: self.mysql_user = self.random_prefix # The instance is newly created if not self.pk: self.logger.info('successful_instance_create: %s', str(self)) super().save(**kwargs) self.update_consul_metadata()
def base_playbook_name(self): """ Get the correct base playbook name for the openedx_release Automatically fills the field if left empty """ if not self.configuration_playbook_name: self.configuration_playbook_name = get_base_playbook_name(self.openedx_release) self.save() return self.configuration_playbook_name
def save(self, **kwargs): """ Set default values before saving the instance. """ # Set default field values from settings - using the `default` field attribute confuses # automatically generated migrations, generating a new one when settings don't match if not self.edx_platform_commit: self.edx_platform_commit = self.openedx_release if self.storage_type is None: self.storage_type = settings.INSTANCE_STORAGE_TYPE # If left blank, the base playbook name will be automatically selected # based on the openedx release if not self.configuration_playbook_name: self.configuration_playbook_name = get_base_playbook_name( self.openedx_release) super().save(**kwargs) self.update_consul_metadata()
def test_get_base_playbook_name(self, openedx_release, playbook_name): """ Test the overloaded comparison operators """ self.assertEqual(get_base_playbook_name(openedx_release), playbook_name)