Beispiel #1
0
    def ready(self):
        import nautobot.extras.signals  # noqa
        from nautobot.extras.plugins.validators import wrap_model_clean_methods

        try:
            # Wrap plugin model validator registered clean methods
            wrap_model_clean_methods()
        except ProgrammingError:
            # The ContentType table might not exist yet (if migrations have not been run)
            logger.warning(
                "Wrapping model clean methods for custom validators failed because "
                "the ContentType table was not available or populated. This is normal "
                "during the execution of the migration command for the first time."
            )
Beispiel #2
0
    def ready(self):
        super().ready()
        import nautobot.extras.signals  # noqa
        from nautobot.extras.signals import refresh_job_models

        nautobot_database_ready.connect(refresh_job_models, sender=self)

        from graphene_django.converter import convert_django_field
        from taggit.managers import TaggableManager
        from nautobot.extras.graphql.types import TagType

        @convert_django_field.register(TaggableManager)
        def convert_field_to_list_tags(field, registry=None):
            """Convert TaggableManager to List of Tags."""
            return graphene.List(TagType)

        from nautobot.extras.plugins.validators import wrap_model_clean_methods

        try:
            # Wrap plugin model validator registered clean methods
            wrap_model_clean_methods()
        except ProgrammingError:
            # The ContentType table might not exist yet (if migrations have not been run)
            logger.warning(
                "Wrapping model clean methods for custom validators failed because "
                "the ContentType table was not available or populated. This is normal "
                "during the execution of the migration command for the first time."
            )

        # Register the DatabaseBackend health check
        from nautobot.extras.health_checks import DatabaseBackend, RedisBackend

        plugin_dir.register(DatabaseBackend)
        plugin_dir.register(RedisBackend)

        # Register built-in SecretsProvider classes
        from nautobot.extras.secrets.providers import EnvironmentVariableSecretsProvider, TextFileSecretsProvider
        from nautobot.extras.secrets import register_secrets_provider

        register_secrets_provider(EnvironmentVariableSecretsProvider)
        register_secrets_provider(TextFileSecretsProvider)
Beispiel #3
0
 def setUp(self):
     # When creating a fresh test DB, wrapping model clean methods fails, which is normal.
     # This always occurs during the first run of migrations, however, During testing we
     # must manually call the method again to actually perform the action, now that the
     # ContentType table has been created.
     wrap_model_clean_methods()