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:
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')):
current_cros = 0
cros_count = len(users)
for cros in users:
current_cros += 1
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})
for l in range(0, len(users), 50):
move_body = {u'deviceIds': users[l:l+50]}
print u' moving %s devices to %s' % (len(move_body[u'deviceIds']), orgUnitPath)
callGAPI(cd.chromeosdevices(), u'moveDevicesToOu', customerId=GC_Values[GC_CUSTOMER_ID], orgUnitPath=orgUnitPath, body=move_body)
else:
if orgUnitPath != u'/' and orgUnitPath[0] != u'/': # we do want a / at the beginning for user updates
orgUnitPath = u'/%s' % orgUnitPath