def setUpTestData(cls): Configuration.objects.bulk_create( [ Configuration(name="Configuration 1", template="Configuration 1"), Configuration(name="Configuration 2", template="Configuration 2"), ] )
def setUpTestData(cls): Configuration.objects.bulk_create([ Configuration(name="Configuration 1", template="Configuration 1"), Configuration(name="Configuration 2", template="Configuration 2"), Configuration(name="Configuration 3", template="Configuration 3"), ]) cls.form_data = { "name": "Configuration 4", "template": "Configuration 4", "comments": "", "tags": "", }
def handle(self, *args, **options): if options["verbosity"] >= 2: self.stdout.write("[*] Loading template") t = Configuration( name="tmp", template=options["input"].read(), jinja2_trim=options["trim"], jinja2_lstrip=options["lstrip"], ) routers = Router.objects.all() if options["limit"]: routers = routers.filter(hostname__in=options["limit"].split(",")) self.stdout.write("[*] Rendering configurations") for r in routers: if options["verbosity"] >= 2: self.stdout.write(f" - Rendering {r.hostname} configuration") r.configuration_template = t configuration = r.generate_configuration() self.stdout.write(configuration)
def setUpTestData(cls): Configuration.objects.bulk_create([ Configuration(name="Example 1", template="example_1"), Configuration(name="Example 2", template="example_2"), Configuration(name="Example 3", template="example_3"), ])