33from jsonschema import validate
44from .config import INSTANCES_PATH
55
6- INSTANCE_META_FILE = os .path .join (INSTANCES_PATH , "instance.json" )
7- BINDING_META_FILE = os .path .join (INSTANCES_PATH , "binding.yaml" )
86
97INSTANCE_META_SCHEMA = {
108 "type" : "object" ,
3028}
3129
3230
33- def load_instance_meta (file = INSTANCE_META_FILE ):
31+ def load_instance_meta (instance_id ):
32+ file = os .path .join (INSTANCES_PATH , instance_id , "instance.json" )
3433 with open (file ) as f :
3534 data = json .load (f )
3635 validate (instance = data , schema = INSTANCE_META_SCHEMA )
3736 return data
3837
3938
40- def dump_instance_meta (data , file = INSTANCE_META_FILE ):
39+ def dump_instance_meta (instance_id , data ):
40+ file = os .path .join (INSTANCES_PATH , instance_id , "instance.json" )
4141 validate (instance = data , schema = INSTANCE_META_SCHEMA )
4242 with open (file , "w" ) as f :
4343 json .dump (f , data )
@@ -61,14 +61,16 @@ def dump_instance_meta(data, file=INSTANCE_META_FILE):
6161}
6262
6363
64- def load_binding_meta (file = BINDING_META_FILE ):
64+ def load_binding_meta (instance_id ):
65+ file = os .path .join (INSTANCES_PATH , instance_id , "binding.yaml" )
6566 with open (file , 'r' ) as f :
6667 data = json .loads (f .read ())
6768 validate (instance = data , schema = INSTANCE_META_SCHEMA )
6869 return data
6970
7071
71- def dump_binding_meta (data , file = BINDING_META_FILE ):
72+ def dump_binding_meta (instance_id , data ):
73+ file = os .path .join (INSTANCES_PATH , instance_id , "binding.yaml" )
7274 validate (instance = data , schema = INSTANCE_META_SCHEMA )
7375 with open (file , "w" ) as f :
7476 f .write (json .dumps (data ))
0 commit comments