diff options
| author | Rob van der Linde <rob@catalyst.net.nz> | 2024-02-26 17:19:58 +1300 |
|---|---|---|
| committer | Andrew Bartlett <abartlet@samba.org> | 2024-03-01 04:45:36 +0000 |
| commit | 993b6da2db8cc107a42931b617f6d4aac4a9ed39 (patch) | |
| tree | 82d22311fd30e4d0139cc95e9454cf18cf58dda2 /python/samba | |
| parent | 9238afc16c6eeb79543f063b283f511929df67f0 (diff) | |
| download | samba-993b6da2db8cc107a42931b617f6d4aac4a9ed39.tar.gz samba-993b6da2db8cc107a42931b617f6d4aac4a9ed39.tar.bz2 samba-993b6da2db8cc107a42931b617f6d4aac4a9ed39.zip | |
netcmd: silos: silo and auth policy commands use Query class better
Since the introduction of the Query class these can be written to be a lot clearer using models.
Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Diffstat (limited to 'python/samba')
| -rw-r--r-- | python/samba/netcmd/domain/auth/policy.py | 10 | ||||
| -rw-r--r-- | python/samba/netcmd/domain/auth/silo.py | 10 | ||||
| -rw-r--r-- | python/samba/netcmd/domain/claim/claim_type.py | 11 | ||||
| -rw-r--r-- | python/samba/netcmd/domain/claim/value_type.py | 11 |
4 files changed, 18 insertions, 24 deletions
diff --git a/python/samba/netcmd/domain/auth/policy.py b/python/samba/netcmd/domain/auth/policy.py index f5347cdaa03..d7156510a1c 100644 --- a/python/samba/netcmd/domain/auth/policy.py +++ b/python/samba/netcmd/domain/auth/policy.py @@ -188,19 +188,17 @@ class cmd_domain_auth_policy_list(Command): ldb = self.ldb_connect(hostopts, sambaopts, credopts) - # Authentication policies grouped by cn. try: - policies = {policy.cn: policy.as_dict() - for policy in AuthenticationPolicy.query(ldb)} + policies = AuthenticationPolicy.query(ldb) except ModelError as e: raise CommandError(e) # Using json output format gives more detail. if output_format == "json": - self.print_json(policies) + self.print_json({policy.name: policy for policy in policies}) else: - for policy in policies.keys(): - print(policy, file=self.outf) + for policy in policies: + print(policy.name, file=self.outf) class cmd_domain_auth_policy_view(Command): diff --git a/python/samba/netcmd/domain/auth/silo.py b/python/samba/netcmd/domain/auth/silo.py index 410b04fc702..52a5523847c 100644 --- a/python/samba/netcmd/domain/auth/silo.py +++ b/python/samba/netcmd/domain/auth/silo.py @@ -49,19 +49,17 @@ class cmd_domain_auth_silo_list(Command): ldb = self.ldb_connect(hostopts, sambaopts, credopts) - # Authentication silos grouped by cn. try: - silos = {silo.cn: silo.as_dict() - for silo in AuthenticationSilo.query(ldb)} + silos = AuthenticationSilo.query(ldb) except ModelError as e: raise CommandError(e) # Using json output format gives more detail. if output_format == "json": - self.print_json(silos) + self.print_json({silo.name: silo for silo in silos}) else: - for silo in silos.keys(): - print(silo, file=self.outf) + for silo in silos: + print(silo.name, file=self.outf) class cmd_domain_auth_silo_view(Command): diff --git a/python/samba/netcmd/domain/claim/claim_type.py b/python/samba/netcmd/domain/claim/claim_type.py index 109f79c0a03..3b82b06405d 100644 --- a/python/samba/netcmd/domain/claim/claim_type.py +++ b/python/samba/netcmd/domain/claim/claim_type.py @@ -298,19 +298,18 @@ class cmd_domain_claim_claim_type_list(Command): ldb = self.ldb_connect(hostopts, sambaopts, credopts) - # Claim types grouped by displayName. try: - claim_types = {claim_type.display_name: claim_type.as_dict() - for claim_type in ClaimType.query(ldb)} + claim_types = ClaimType.query(ldb) except ModelError as e: raise CommandError(e) # Using json output format gives more detail. if output_format == "json": - self.print_json(claim_types) + self.print_json({claim_type.display_name: claim_type + for claim_type in claim_types}) else: - for claim_type in claim_types.keys(): - print(claim_type, file=self.outf) + for claim_type in claim_types: + print(claim_type.display_name, file=self.outf) class cmd_domain_claim_claim_type_view(Command): diff --git a/python/samba/netcmd/domain/claim/value_type.py b/python/samba/netcmd/domain/claim/value_type.py index a15f7c57570..ca30bd68904 100644 --- a/python/samba/netcmd/domain/claim/value_type.py +++ b/python/samba/netcmd/domain/claim/value_type.py @@ -47,19 +47,18 @@ class cmd_domain_claim_value_type_list(Command): ldb = self.ldb_connect(hostopts, sambaopts, credopts) - # Value types grouped by display name. try: - value_types = {value_type.display_name: value_type.as_dict() - for value_type in ValueType.query(ldb)} + value_types = ValueType.query(ldb) except ModelError as e: raise CommandError(e) # Using json output format gives more detail. if output_format == "json": - self.print_json(value_types) + self.print_json({value_type.display_name: value_type + for value_type in value_types}) else: - for value_type in value_types.keys(): - print(value_type, file=self.outf) + for value_type in value_types: + print(value_type.display_name, file=self.outf) class cmd_domain_claim_value_type_view(Command): |
