switch wcs to django management commands (#83567)
gitea/publik-imio-industrialisation/pipeline/head This commit looks good Details

This commit is contained in:
Frédéric Péters 2023-11-21 12:15:43 +01:00
parent 75f4301241
commit 6e55599667
4 changed files with 23 additions and 36 deletions

View File

@ -31,8 +31,8 @@ install:
cp hobo/*.py $(DESTDIR)$(prefix)/lib/python3/dist-packages/hobo/environment/management/commands/
mkdir -p $(DESTDIR)$(prefix)/lib/python3/dist-packages/passerelle/base/management/commands/
-cp passerelle/*.py $(DESTDIR)$(prefix)/lib/python3/dist-packages/passerelle/base/management/commands/
mkdir -p $(DESTDIR)$(prefix)/lib/python3/dist-packages/wcs/ctl/
cp wcs/*.py $(DESTDIR)$(prefix)/lib/python3/dist-packages/wcs/ctl/
mkdir -p $(DESTDIR)$(prefix)/lib/python3/dist-packages/wcs/ctl/management/commands/
cp wcs/*.py $(DESTDIR)$(prefix)/lib/python3/dist-packages/wcs/ctl/management/commands/
dist-bzip2: dist
-mkdir sdist

View File

@ -1,4 +1,3 @@
hobo ALL=(wcs)NOPASSWD:/usr/bin/wcsctl
hobo ALL=(wcs)NOPASSWD:/usr/bin/wcs-manage
hobo ALL=(authentic-multitenant)NOPASSWD:/usr/bin/authentic2-multitenant-manage
hobo ALL=(combo)NOPASSWD:/usr/bin/combo-manage

View File

@ -1,25 +1,22 @@
import os
import argparse
import sys
from ..qommon.ctl import Command, make_option
from quixote import get_publisher
from wcs.ctl.management.commands import TenantCommand
class Cmd(Command):
name = 'has_role'
class Command(TenantCommand):
def __init__(self):
super().__init__([make_option('-d', '--domain', action='store', dest='domain')])
def add_arguments(self, parser):
parser.add_argument('-d', '--domain', '--vhost', required=True, metavar='DOMAIN')
parser.add_argument('args', nargs=argparse.REMAINDER)
def execute(self, base_options, sub_options, args):
from .. import publisher
def handle(self, *args, **options):
domain = options.pop('domain')
self.init_tenant_publisher(domain)
publisher.WcsPublisher.configure(self.config)
publisher = publisher.WcsPublisher.create_publisher(register_tld_names=False)
publisher.set_tenant_by_hostname(sub_options.domain)
for role in publisher.role_class.select():
for role in get_publisher().role_class.select():
if role.name == args[0]:
sys.exit(0)
sys.exit(1)
Cmd.register()

View File

@ -1,3 +1,4 @@
import argparse
import logging
import os
import xml.etree.ElementTree as ET
@ -18,28 +19,21 @@ from wcs.mail_templates import MailTemplate
from wcs.workflows import Workflow
from wcs.wscalls import NamedWsCall
from ..qommon.ctl import Command, make_option
from wcs.ctl.management.commands import TenantCommand
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
class Cmd(Command):
name = 'imio_import_directory'
class Command(TenantCommand):
def __init__(self):
super().__init__(
[
make_option('-d', '--domain', action='store', dest='domain'),
]
)
def add_arguments(self, parser):
parser.add_argument('-d', '--domain', '--vhost', required=True, metavar='DOMAIN')
parser.add_argument('args', nargs=argparse.REMAINDER)
def execute(self, base_options, sub_options, args):
from .. import publisher
def handle(self, *args, **options):
domain = options.pop('domain')
self.init_tenant_publisher(domain)
publisher.WcsPublisher.configure(self.config)
publisher = publisher.WcsPublisher.create_publisher(register_tld_names=False)
publisher.set_tenant_by_hostname(sub_options.domain)
publisher.substitutions.feed(publisher)
self.directory = args[0]
self.import_categories()
self.import_datasources()
@ -232,6 +226,3 @@ class Cmd(Command):
if hasattr(formdef, attribute):
setattr(existing_formdef, attribute, getattr(formdef, attribute))
existing_formdef.store(comment='Indus Update')
Cmd.register()