Add header to gam show chromepolicy to display OU and printerid/appid (#1341)

This commit is contained in:
Ross Scroggs
2021-03-23 13:16:58 -07:00
committed by GitHub
parent b7d052a6b3
commit 2199fb2828
2 changed files with 11 additions and 2 deletions

View File

@@ -76,6 +76,13 @@ def printshow_policies():
# 'chrome.devices.kiosk',
]
throw_reasons = [gapi_errors.ErrorReason.FOUR_O_O,]
orgunitPath = gapi_directory_orgunits.orgunit_from_orgunitid(orgunit[9:], None)
header = f'Organizational Unit: {orgunitPath}'
if printer_id:
header += f', printerid: {printer_id}'
elif app_id:
header += f', appid: {app_id}'
print(header)
for namespace in namespaces:
body['policySchemaFilter'] = f'{namespace}.*'
try:
@@ -87,6 +94,7 @@ def printshow_policies():
except googleapiclient.errors.HttpError:
policies = []
for policy in sorted(policies, key=lambda k: k.get('value', {}).get('policySchema', '')):
print()
name = policy.get('value', {}).get('policySchema', '')
print(name)
values = policy.get('value', {}).get('value', {})
@@ -94,7 +102,6 @@ def printshow_policies():
if isinstance(value, str) and value.find('_ENUM_') != -1:
value = value.split('_ENUM_')[-1]
print(f' {setting}: {value}')
print()
def build_schemas(svc=None, sfilter=None):

View File

@@ -402,7 +402,9 @@ def getOrgUnitId(orgUnit, cd=None):
return (orgUnit, result['orgUnitId'])
def orgunit_from_orgunitid(orgunitid, cd):
def orgunit_from_orgunitid(orgunitid, cd=None):
if cd is None:
cd = gapi_directory.build()
orgunitpath = GM_Globals[GM_MAP_ORGUNIT_ID_TO_NAME].get(orgunitid)
if not orgunitpath:
try: