Skip to content

Instantly share code, notes, and snippets.

@chelnak
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chelnak/fe26487661b91a8b8c30 to your computer and use it in GitHub Desktop.
Save chelnak/fe26487661b91a8b8c30 to your computer and use it in GitHub Desktop.
#!/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