1
0
mirror of https://github.com/dkmstr/openuds.git synced 2024-12-22 13:34:04 +03:00

Fixed tree generation to include id and uuid on managed objects

This commit is contained in:
Adolfo Gómez García 2024-06-19 16:54:49 +02:00
parent 8bad7d576a
commit cd0827af07
No known key found for this signature in database
GPG Key ID: DD1ABF20724CDA23
2 changed files with 14 additions and 8 deletions

View File

@ -1713,17 +1713,21 @@ class UserInterface(metaclass=UserInterfaceType):
# Values can contain invalid characters, so we log every single char
# logger.info('Invalid serialization data on {0} {1}'.format(self, values.encode('hex')))
def gui_description(self) -> list[types.ui.GuiElement]:
def gui_description(self, *, skip_init_gui: bool = False) -> list[types.ui.GuiElement]:
"""
This simple method generates the theGui description needed by the
administration client, so it can
represent it at user interface and manage it.
Args:
obj: If any, object that will get its "initGui" invoked
This will only happen (not to be None) in Services.
skip_init_gui: If True, init_gui will not be called
Note:
skip_init_gui is used to avoid calling init_gui when we are not going to use the result
This is used, for example, when exporting data, generating the tree, etc...
"""
self.init_gui() # We give the "oportunity" to fill necesary theGui data before providing it to client
if not skip_init_gui:
self.init_gui() # We give the "oportunity" to fill necesary theGui data before providing it to client
res: list[types.ui.GuiElement] = []
for key, val in self._gui.items():

View File

@ -60,14 +60,14 @@ def get_serialized_from_managed_object(
) -> collections.abc.Mapping[str, typing.Any]:
try:
obj: 'Module' = mod.get_instance()
gui_types: dict[str, str] = {i['name']: str(i['gui']['type']) for i in obj.gui_description()}
gui_types: dict[str, str] = {i['name']: str(i['gui']['type']) for i in obj.gui_description(skip_init_gui=True)}
values = obj.get_fields_as_dict()
# Remove password fields
for fld, fld_type in gui_types.items():
if fld_type == 'password':
values[fld] = '********'
# Some names are know "secret data"
for i in ('serverCertificate', 'privateKey'):
for i in ('serverCertificate', 'privateKey', 'server_certificate', 'private_key'):
if i in values:
values[i] = '********'
# remove removable fields
@ -75,6 +75,8 @@ def get_serialized_from_managed_object(
if i in values:
del values[i]
# Append type_name to list
values['id'] = mod.id
values['uuid'] = mod.uuid
values['type_name'] = str(obj.type_name)
values['comments'] = mod.comments
@ -166,8 +168,8 @@ class Command(BaseCommand):
'id': item.uuid,
'unique_id': item.unique_id,
'friendly_name': item.friendly_name,
'state': types.states.State.from_str(item.state).localized,
'os_state': types.states.State.from_str(item.os_state).localized,
'state': str(types.states.State.from_str(item.state).localized),
'os_state': str(types.states.State.from_str(item.os_state).localized),
'state_date': item.state_date,
'creation_date': item.creation_date,
'revision': item.publication and item.publication.revision or '',