From bb9d5b3cdceee5c5062d242ca3d00f6d88872389 Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Fri, 15 May 2026 16:51:40 -0700 Subject: [PATCH] Added option `max_to_deprov ` to `gam update cros action ` --- src/GamCommands.txt | 4 ++-- src/GamUpdate.txt | 15 ++++++++++++++- src/gam/__init__.py | 17 +++++++++++++---- src/gam/gamlib/glmsgs.py | 1 + 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/GamCommands.txt b/src/GamCommands.txt index 89487da6..db7fa345 100644 --- a/src/GamCommands.txt +++ b/src/GamCommands.txt @@ -2469,9 +2469,9 @@ gam print chromehistory releases [todrive *] pre_provisioned_reenable gam update cros action [acknowledge_device_touch_requirement] - [actionbatchsize ] + [actionbatchsize ] [maxtodeprov ] gam update action [acknowledge_device_touch_requirement] - [actionbatchsize ] + [actionbatchsize ] [maxtodeprov ] reboot| diff --git a/src/GamUpdate.txt b/src/GamUpdate.txt index 537d7b53..cc5ed625 100644 --- a/src/GamUpdate.txt +++ b/src/GamUpdate.txt @@ -4,6 +4,19 @@ Added option `matchfield attendeesorganizer ` to ` that is used in commands that process events. The match is true if all of the addresses in `` are present as attendees in the event and are an organizer or not based on ``. +Added option `max_to_deprov ` to `gam update cros action ` +that is used when `` is any of the following: +``` +deprovision_different_model_replace| +deprovision_different_model_replacement| +deprovision_retiring_device| +deprovision_same_model_replace| +deprovision_same_model_replacement| +deprovision_upgrade_transfer +``` +`max_to_deprov ` - No deprovisions are processed if the number of devices in `` exceeds ``; +the default value is one; set `` to 0 for no limit. + 7.43.04 Added option `include_suspended_zeros []` to `gam print vaultcounts` that causes @@ -22,7 +35,7 @@ gam print filelist ... filepath|fullpath 7.43.02 -Added option `maxactivities ` to `gam print driveactivity` to limit +Added option `maxactivities ` to `gam print driveactivity` to limit the number of activities displayed; the default is 0, no limit. 7.43.01 diff --git a/src/gam/__init__.py b/src/gam/__init__.py index ce31604c..0983cea5 100755 --- a/src/gam/__init__.py +++ b/src/gam/__init__.py @@ -24210,7 +24210,7 @@ CROS_ACTION_NAME_MAP = { # gam update + [quickcrosmove []] [nobatchupdate] # gam update action [acknowledge_device_touch_requirement] -# [actionbatchsize ] +# [actionbatchsize ] [maxtodeprov ] def updateCrOSDevices(entityList): cd = buildGAPIObject(API.DIRECTORY) noBatchUpdate = False @@ -24220,6 +24220,7 @@ def updateCrOSDevices(entityList): ackWipe = False quickCrOSMove = GC.Values[GC.QUICK_CROS_MOVE] actionBatchSize = 10 + maxToDeprovision = None while Cmd.ArgumentsRemaining(): myarg = getArgument() if myarg in UPDATE_CROS_ARGUMENT_TO_PROPERTY_MAP: @@ -24245,6 +24246,8 @@ def updateCrOSDevices(entityList): noBatchUpdate = getBoolean() elif myarg == 'actionbatchsize': actionBatchSize = getInteger(minVal=10, maxVal=250) + elif myarg == 'maxtodeprov': + maxToDeprovision = getInteger(minVal=0) else: unknownArgumentExit() if action_body and update_body: @@ -24258,9 +24261,15 @@ def updateCrOSDevices(entityList): i, count, entityList = getEntityArgument(entityList) # Action if action_body: - if action_body['changeChromeOsDeviceStatusAction'] == 'CHANGE_CHROME_OS_DEVICE_STATUS_ACTION_DEPROVISION' and not ackWipe: - stderrWarningMsg(Msg.REFUSING_TO_DEPROVISION_DEVICES.format(count)) - systemErrorExit(ACTION_NOT_PERFORMED_RC, None) + if action_body['changeChromeOsDeviceStatusAction'] == 'CHANGE_CHROME_OS_DEVICE_STATUS_ACTION_DEPROVISION': + if not ackWipe: + stderrWarningMsg(Msg.REFUSING_TO_DEPROVISION_DEVICES.format(count)) + systemErrorExit(ACTION_NOT_PERFORMED_RC, None) + if maxToDeprovision is None: + maxToDeprovision = 1 + if count > maxToDeprovision > 0: + stderrWarningMsg(Msg.REFUSING_TO_DEPROVISION_N_DEVICES.format(count, maxToDeprovision)) + systemErrorExit(ACTION_NOT_PERFORMED_RC, None) while i < count: bcount = min(count-i, actionBatchSize) action_body['deviceIds'] = entityList[i:i+bcount] diff --git a/src/gam/gamlib/glmsgs.py b/src/gam/gamlib/glmsgs.py index 86e01771..60d28e2d 100644 --- a/src/gam/gamlib/glmsgs.py +++ b/src/gam/gamlib/glmsgs.py @@ -474,6 +474,7 @@ REASON_ONLY_VALID_WITH_CONTENTRESTRICTIONS_READONLY_TRUE = 'reason only valid wi REAUTHENTICATION_IS_NEEDED = 'Reauthentication is needed, please run\n\ngam oauth create' RECOMMEND_RUNNING_GAM_ROTATE_SAKEY = 'Recommend running "gam rotate sakey" to get a new key\n' REFUSING_TO_DEPROVISION_DEVICES = 'Refusing to deprovision {0} devices because acknowledge_device_touch_requirement not specified.\nDeprovisioning a device means the device will have to be physically wiped and re-enrolled to be managed by your domain again.\nThis requires physical access to the device and is very time consuming to perform for each device.\nPlease add "acknowledge_device_touch_requirement" to the GAM command if you understand this and wish to proceed with the deprovision.\nPlease also be aware that deprovisioning can have an effect on your device license count.\nSee https://support.google.com/chrome/a/answer/3523633 for full details.' +REFUSING_TO_DEPROVISION_N_DEVICES = 'Refusing to deprovision {0} devices due to maxtodepov {1}.' REPLY_TO_CUSTOM_REQUIRES_EMAIL_ADDRESS = 'replyto REPLY_TO_CUSTOM requires customReplyTo ' REQUEST_COMPLETED_NO_FILES = 'Request completed but no results/files were returned, try requesting again' REQUEST_NOT_COMPLETE = 'Request needs to be completed before downloading, current status is: {0}'