Created
May 21, 2014 14:40
-
-
Save arubdesu/065499d6697acb420ca5 to your computer and use it in GitHub Desktop.
Using a csv and a template to generate computer record in DeployStudio, specifically creates users with password 'password'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import os | |
import csv | |
from Foundation import NSMutableDictionary | |
top_dict = NSMutableDictionary.dictionary() | |
# f = open(sys.argv[1], 'rt') | |
f = open('tehCSV.csv', 'rt') | |
try: | |
reader = csv.reader(f) | |
for row in reader: | |
tehSerial = row[0] | |
compyName = row[1] | |
lowerName = row[2] | |
camelName = row[3] | |
inner_dict = {} | |
userDict = {} | |
userDict['dstudio-user-admin-status'] = 'YES' | |
userDict['dstudio-user-hidden-status'] = 'NO' | |
userDict['dstudio-user-name'] = compyName | |
userDict['dstudio-user-password'] = 'U1Boa2trZUhLR2FKeFp2cDB3R095Zz09' | |
userDict['dstudio-user-shortname'] = camelName | |
inner_array = [userDict] | |
inner_dict['architecture'] = 'i386' | |
inner_dict['cn'] = compyName | |
inner_dict['dstudio-auto-started-workflow'] = '9AF04D45-C3BF-4504-9966-B6DC8BBCE3AF' | |
inner_dict['dstudio-host-primary-key'] = 'dstudio-host-serial-number' | |
inner_dict['dstudio-host-serial-number'] = tehSerial | |
inner_dict['dstudio-host-type'] = 'Mac' | |
inner_dict['dstudio-host-name'] = lowerName | |
inner_dict['dstudio-hostname'] = lowerName | |
inner_dict['dstudio-users'] = inner_array | |
top_dict[tehSerial] = inner_dict | |
print "finished generating block for " + tehSerial | |
finally: | |
f.close() | |
success = top_dict.writeToFile_atomically_('dsImporterated.plist', 1) | |
if not success: | |
print "plist failed to write!" | |
sys.exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
serialnumber | longUserName | hostname | shortusername |
---|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment