Last active
March 12, 2019 05:11
-
-
Save mrlesmithjr/cabe850409f806a0e56b52e4afcb1fd9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/env python | |
import json | |
VMS = { | |
'db01': { | |
'profile': 'Linux_DB', | |
'vm_size': 'medium' | |
}, | |
'web01': { | |
'profile': 'Linux_Web', | |
'vm_size': 'small' | |
} | |
} | |
with open('profiles.json', 'r') as stream: | |
MAPPINGS = json.load(stream) | |
VM_MAPPINGS = [] | |
for key, value in VMS.items(): | |
profile = MAPPINGS.get(value['profile']) | |
specs = profile['vm_sizes'].get(value['vm_size']) | |
template = profile.get('template') | |
vm_size = value.get('vm_size') | |
vm_config = { | |
key: { | |
'specs': specs, | |
'template': template, | |
'vm_size': vm_size | |
} | |
} | |
VM_MAPPINGS.append(vm_config) | |
print json.dumps(VM_MAPPINGS, indent=4) |
This file contains hidden or 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
{ | |
"Linux_DB": { | |
"template": "ubuntu1804_x64", | |
"vm_sizes": { | |
"small": { | |
"cpus": 1, | |
"cores": 1, | |
"memory_mb": 1024 | |
}, | |
"medium": { | |
"cpus": 1, | |
"cores": 2, | |
"memory_mb": 2048 | |
} | |
} | |
}, | |
"Linux_Web": { | |
"template": "ubuntu1804_x64", | |
"vm_sizes": { | |
"small": { | |
"cpus": 1, | |
"cores": 1, | |
"memory_mb": 1024 | |
}, | |
"medium": { | |
"cpus": 1, | |
"cores": 2, | |
"memory_mb": 2048 | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.