-
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We introduce a new Django management command: `provision`. For each app, some resources can be created and updated automatically, based on their configuration in the Zentral config. We start with the MDM `SCEPConfig` resources.
- Loading branch information
Showing
18 changed files
with
740 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import inspect | ||
import logging | ||
from django.apps import apps | ||
from django.core.management.base import BaseCommand | ||
from django.db import transaction | ||
from zentral.conf import settings | ||
from zentral.utils.apps import ZentralAppConfig | ||
from zentral.utils.provisioning import Provisioner | ||
|
||
|
||
logger = logging.getLogger("zentral.server.base.management.commands.provision") | ||
|
||
|
||
class Command(BaseCommand): | ||
help = 'Provision Zentral' | ||
|
||
@staticmethod | ||
def add_arguments(parser): | ||
pass | ||
|
||
def iter_provisiners(self): | ||
for app_config in apps.app_configs.values(): | ||
if not isinstance(app_config, ZentralAppConfig): | ||
continue | ||
if not app_config.provisioning_module: | ||
continue | ||
for _, provisioner_cls in inspect.getmembers( | ||
app_config.provisioning_module, | ||
lambda m: inspect.isclass(m) and m != Provisioner and issubclass(m, Provisioner) | ||
): | ||
yield provisioner_cls(app_config, settings) | ||
|
||
def handle(self, *args, **options): | ||
with transaction.atomic(): | ||
for provisioner in self.iter_provisiners(): | ||
provisioner.apply() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.