Last active
August 29, 2015 14:26
-
-
Save chelnak/fe26487661b91a8b8c30 to your computer and use it in GitHub Desktop.
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 json | |
#full path to cloudclient | |
cloudClientPath = '/PATH_TO_CLOUD_CLIENT/bin/cloudclient.sh' | |
#Path to your prefix json file. If just the filename, it will look in the script directory | |
prefixJSONFile = 'vra-machineprefixes.json' | |
#Path to the resulting script file. If just the filename, it will look in the script directory | |
prefixScriptFile = 'machineprefix-cloudclient-commands.sh' | |
#Open up the file we exported earlier and parse it with json.load | |
with open(prefixJSONFile, 'r') as json_data: | |
machinePrefixes = json.load(json_data) | |
#Open a new file and write out each command | |
with open(prefixScriptFile, 'w') as f: | |
f.write('export CLOUDCLIENTPATH={path}\n'.format(path=cloudClientPath)) | |
for i in machinePrefixes['Items']: | |
f.write( | |
'$CLOUDCLIENTPATH vra machineprefix add --prefix {prefix} --numberOfDigits {numberOfDigits} --nextNumber {nextNumber}\n'.format( | |
prefix=i['Prefix'], | |
numberOfDigits=i['NumberOfDigits'], | |
nextNumber=i['NextNumber'])) | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment