mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
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>
This commit is contained in:
parent
9238afc16c
commit
993b6da2db
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user