mirror of
https://github.com/dkmstr/openuds.git
synced 2025-03-20 06:50:23 +03:00
Fixed comands type checking and added a few samples to sample provider
This commit is contained in:
parent
018ba4a3f8
commit
7c1b4ab61e
@ -109,7 +109,8 @@ def authenticator_exporter(
|
||||
a = managed_object_exporter(authenticator)
|
||||
a['priority'] = authenticator.priority
|
||||
a['provider'] = authenticator.small_name
|
||||
a['visible'] = authenticator.visible
|
||||
a['visible'] = authenticator.state == models.Authenticator.VISIBLE
|
||||
a['enabled'] = authenticator.state != models.Authenticator.DISABLED
|
||||
return a
|
||||
|
||||
|
||||
@ -165,7 +166,7 @@ def transport_exporter(transport: models.Transport) -> typing.Dict[str, typing.A
|
||||
t.update(
|
||||
{
|
||||
'priority': transport.priority,
|
||||
'nets_positive': transport.nets_positive,
|
||||
'net_filtering': transport.net_filtering,
|
||||
'allowed_oss': transport.allowed_oss,
|
||||
'label': transport.label,
|
||||
'networks': [n.uuid for n in transport.networks.all()],
|
||||
@ -266,7 +267,7 @@ class Command(BaseCommand):
|
||||
'--output',
|
||||
action='store',
|
||||
dest='output',
|
||||
default='/tmp/export.yaml',
|
||||
default='/tmp/export.yaml', # nosec: This is a default value
|
||||
help='Output file name. Defaults to /tmp/export.yaml',
|
||||
)
|
||||
|
||||
|
@ -44,7 +44,7 @@ logger = logging.getLogger(__name__)
|
||||
class Command(BaseCommand):
|
||||
help = "Show current PUBLIC configuration of UDS broker (passwords are not shown)"
|
||||
|
||||
def add_arguments(self, parser):
|
||||
def add_arguments(self, parser) -> None:
|
||||
parser.add_argument(
|
||||
'--csv',
|
||||
action='store_true',
|
||||
@ -60,7 +60,7 @@ class Command(BaseCommand):
|
||||
help='Shows configuration in YAML format',
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
def handle(self, *args, **options) -> None:
|
||||
logger.debug("Show settings")
|
||||
config.GlobalConfig.initialize()
|
||||
try:
|
||||
@ -87,5 +87,6 @@ class Command(BaseCommand):
|
||||
if options['yaml']:
|
||||
self.stdout.write(yaml.safe_dump(writer, default_flow_style=False))
|
||||
except Exception as e:
|
||||
print('The command could not be processed: {}'.format(e))
|
||||
self.stdout.write('The command could not be processed: {}'.format(e))
|
||||
self.stdout.flush()
|
||||
logger.exception('Exception processing %s', args)
|
||||
|
@ -93,7 +93,7 @@ class Command(BaseCommand):
|
||||
args = "None"
|
||||
help = "Executes the task manager as a daemon. No parameter show current status of task manager"
|
||||
|
||||
def add_arguments(self, parser):
|
||||
def add_arguments(self, parser) -> None:
|
||||
parser.add_argument(
|
||||
'--start',
|
||||
action='store_true',
|
||||
|
@ -118,7 +118,7 @@ class Command(BaseCommand):
|
||||
help='Maximum elements exported for groups and user services',
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
def handle(self, *args, **options) -> None:
|
||||
logger.debug("Show Tree")
|
||||
# firt, genertate Provider-service-servicepool tree
|
||||
cntr = 0
|
||||
@ -184,7 +184,7 @@ class Command(BaseCommand):
|
||||
totalUserServices += numberOfUserServices
|
||||
|
||||
# get publications
|
||||
publications = {}
|
||||
publications: typing.Dict[str, typing.Any] = {}
|
||||
for publication in servicePool.publications.all():
|
||||
# Get all changelogs for this publication
|
||||
try:
|
||||
@ -197,10 +197,10 @@ class Command(BaseCommand):
|
||||
except Exception:
|
||||
changelogs = []
|
||||
|
||||
publications[publication.revision] = getSerializedFromModel(
|
||||
publications[str(publication.revision)] = getSerializedFromModel(
|
||||
publication, ['data']
|
||||
)
|
||||
publications[publication.revision][
|
||||
publications[str(publication.revision)][
|
||||
'changelogs'
|
||||
] = changelogs
|
||||
|
||||
@ -258,21 +258,21 @@ class Command(BaseCommand):
|
||||
tree[counter('PROVIDERS')] = providers
|
||||
|
||||
# authenticators
|
||||
authenticators = {}
|
||||
authenticators: typing.Dict[str, typing.Any] = {}
|
||||
for authenticator in models.Authenticator.objects.all():
|
||||
# Groups
|
||||
groups = {}
|
||||
grps: typing.Dict[str, typing.Any] = {}
|
||||
for group in authenticator.groups.all()[:max_items]: # at most max_items items
|
||||
groups[group.name] = getSerializedFromModel(group, ['manager_id', 'name'])
|
||||
grps[group.name] = getSerializedFromModel(group, ['manager_id', 'name'])
|
||||
authenticators[authenticator.name] = {
|
||||
'_': getSerializedFromManagedObject(authenticator),
|
||||
'groups': groups,
|
||||
'groups': grps,
|
||||
}
|
||||
|
||||
tree[counter('AUTHENTICATORS')] = authenticators
|
||||
|
||||
# transports
|
||||
transports = {}
|
||||
transports: typing.Dict[str, typing.Any] = {}
|
||||
for transport in models.Transport.objects.all():
|
||||
transports[transport.name] = getSerializedFromManagedObject(transport)
|
||||
|
||||
@ -289,14 +289,14 @@ class Command(BaseCommand):
|
||||
tree[counter('NETWORKS')] = networks
|
||||
|
||||
# os managers
|
||||
osManagers = {}
|
||||
osManagers: typing.Dict[str, typing.Any] = {}
|
||||
for osManager in models.OSManager.objects.all():
|
||||
osManagers[osManager.name] = getSerializedFromManagedObject(osManager)
|
||||
|
||||
tree[counter('OSMANAGERS')] = osManagers
|
||||
|
||||
# calendars
|
||||
calendars = {}
|
||||
calendars: typing.Dict[str, typing.Any] = {}
|
||||
for calendar in models.Calendar.objects.all():
|
||||
# calendar rules
|
||||
rules = {}
|
||||
@ -313,14 +313,14 @@ class Command(BaseCommand):
|
||||
tree[counter('CALENDARS')] = calendars
|
||||
|
||||
# Metapools
|
||||
metapools = {}
|
||||
metapools: typing.Dict[str, typing.Any] = {}
|
||||
for metapool in models.MetaPool.objects.all():
|
||||
metapools[metapool.name] = getSerializedFromModel(metapool)
|
||||
|
||||
tree[counter('METAPOOLS')] = metapools
|
||||
|
||||
# accounts
|
||||
accounts = {}
|
||||
accounts: typing.Dict[str, typing.Any] = {}
|
||||
for account in models.Account.objects.all():
|
||||
accounts[account.name] = {
|
||||
'_': getSerializedFromModel(account),
|
||||
@ -355,7 +355,7 @@ class Command(BaseCommand):
|
||||
tree[counter('GALLERY')] = gallery
|
||||
|
||||
# Actor tokens
|
||||
actorTokens = {}
|
||||
actorTokens: typing.Dict[str, typing.Any] = {}
|
||||
for actorToken in models.ActorToken.objects.all():
|
||||
actorTokens[actorToken.hostname] = getSerializedFromModel(
|
||||
actorToken, passwordFields=['token']
|
||||
@ -364,7 +364,7 @@ class Command(BaseCommand):
|
||||
tree[counter('ACTORTOKENS')] = actorTokens
|
||||
|
||||
# Tunnel tokens
|
||||
tunnelTokens = {}
|
||||
tunnelTokens: typing.Dict[str, typing.Any] = {}
|
||||
for tunnelToken in models.TunnelToken.objects.all():
|
||||
tunnelTokens[tunnelToken.hostname] = getSerializedFromModel(
|
||||
tunnelToken, passwordFields=['token']
|
||||
@ -375,5 +375,6 @@ class Command(BaseCommand):
|
||||
self.stdout.write(yaml.safe_dump(tree, default_flow_style=False))
|
||||
|
||||
except Exception as e:
|
||||
print('The command could not be processed: {}'.format(e))
|
||||
self.stdout.write('The command could not be processed: {}'.format(e))
|
||||
self.stdout.flush()
|
||||
logger.exception('Exception processing %s', args)
|
||||
|
@ -101,9 +101,19 @@ class Provider(services.ServiceProvider):
|
||||
tooltip=_('This fields contains a remote host'),
|
||||
required=True,
|
||||
)
|
||||
|
||||
# simple password field
|
||||
passwdField = gui.PasswordField(
|
||||
order=2,
|
||||
length=32,
|
||||
label=_('Password'),
|
||||
tooltip=_('This is a password field'),
|
||||
required=True,
|
||||
)
|
||||
|
||||
# : Name of your pet (sample, not really needed :-) )
|
||||
petName = gui.TextField(
|
||||
order=2,
|
||||
order=3,
|
||||
length=32,
|
||||
label=_('Your pet\'s name'),
|
||||
tooltip=_('If you like, write the name of your pet'),
|
||||
@ -114,7 +124,7 @@ class Provider(services.ServiceProvider):
|
||||
# : in Spain there is a well-known to say that something is very old,
|
||||
# : "Tiene mas años que matusalén"(is older than Methuselah)
|
||||
methAge = gui.NumericField(
|
||||
order=3,
|
||||
order=4,
|
||||
length=4, # That is, max allowed value is 9999
|
||||
label=_('Age of Methuselah'),
|
||||
tooltip=_('If you know it, please, tell me!!!'),
|
||||
@ -124,14 +134,30 @@ class Provider(services.ServiceProvider):
|
||||
|
||||
# : Is Methuselah istill alive?
|
||||
methAlive = gui.CheckBoxField(
|
||||
order=4,
|
||||
order=5,
|
||||
label=_('Is Methuselah still alive?'),
|
||||
tooltip=_('If you fail, this will not get saved :-)'),
|
||||
defvalue=gui.TRUE, # : By default, at new item, check this
|
||||
)
|
||||
|
||||
methText = gui.TextField(
|
||||
# : Is Methuselah istill alive?
|
||||
methAlive2 = gui.CheckBoxField(
|
||||
order=5,
|
||||
label=_('Is Methuselah still alive BBBB?'),
|
||||
tooltip=_('If you fail, this will not get saved BBBB'),
|
||||
defvalue=gui.TRUE, # : By default, at new item, check this
|
||||
)
|
||||
|
||||
# : Is Methuselah istill alive?
|
||||
methAlive3 = gui.CheckBoxField(
|
||||
order=5,
|
||||
label=_('Is Methuselah still alive CCCC?'),
|
||||
tooltip=_('If you fail, this will not get saved CCCC'),
|
||||
defvalue=gui.TRUE, # : By default, at new item, check this
|
||||
)
|
||||
|
||||
methText = gui.TextField(
|
||||
order=6,
|
||||
length=512,
|
||||
multiline=5,
|
||||
label=_('Text area'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user