Use moveDEvicesToOu in doUpdateOrg (#578)

This commit is contained in:
Ross Scroggs
2017-09-16 13:48:36 -07:00
committed by Jay Lee
parent cdbf740d38
commit e78dbeb056

View File

@ -8230,13 +8230,10 @@ def doUpdateOrg():
else: else:
users = getUsersToModify(entity_type=u'user', entity=sys.argv[5]) users = getUsersToModify(entity_type=u'user', entity=sys.argv[5])
if (sys.argv[5].lower() == u'cros') or ((sys.argv[5].lower() == u'all') and (sys.argv[6].lower() == u'cros')): if (sys.argv[5].lower() == u'cros') or ((sys.argv[5].lower() == u'all') and (sys.argv[6].lower() == u'cros')):
current_cros = 0 for l in range(0, len(users), 50):
cros_count = len(users) move_body = {u'deviceIds': users[l:l+50]}
for cros in users: print u' moving %s devices to %s' % (len(move_body[u'deviceIds']), orgUnitPath)
current_cros += 1 callGAPI(cd.chromeosdevices(), u'moveDevicesToOu', customerId=GC_Values[GC_CUSTOMER_ID], orgUnitPath=orgUnitPath, body=move_body)
sys.stderr.write(u' moving %s to %s (%s/%s)\n' % (cros, orgUnitPath, current_cros, cros_count))
callGAPI(cd.chromeosdevices(), u'update', soft_errors=True,
customerId=GC_Values[GC_CUSTOMER_ID], deviceId=cros, body={u'orgUnitPath': u'//%s' % orgUnitPath})
else: else:
if orgUnitPath != u'/' and orgUnitPath[0] != u'/': # we do want a / at the beginning for user updates if orgUnitPath != u'/' and orgUnitPath[0] != u'/': # we do want a / at the beginning for user updates
orgUnitPath = u'/%s' % orgUnitPath orgUnitPath = u'/%s' % orgUnitPath