ranger/orm/orm_client/flavorgen/make_flav.py
raigax9 2bc511c69f Added orm_client codebase
Initial commit for orm_client by adding the codebase.

Change-Id: I24f17561e6a426e6af9dbbe04e4a66599344d265
2017-08-28 14:17:28 +00:00

37 lines
714 B
Python

#!/usr/bin/env python
import json
import sys
if sys.argv[1].isdigit():
vcpus = sys.argv[1]
else:
vcpus = "1"
if sys.argv[1].isdigit():
ram = sys.argv[1]
else:
ram = "1"
if sys.argv[1].isdigit():
disk = sys.argv[1]
else:
disk = "1"
def calculate_name(flavor):
return "{0}.c{1}r{2}d{3}".format(flavor['series'], flavor['vcpus'],
flavor['ram'], flavor['disk'])
data = {
"series": "gv",
"vcpus": "10",
"ram": "20",
"disk": "30",
"ephemeral": "0",
"swap": "0",
"visibility": "public"
}
flavor_name = calculate_name(data)
series = flavor_name.split('.')[0]
open(flavor_name, "w").write(json.dumps(data, indent=4) + '\n')