Skip to content

Commit 1c58b27

Browse files
committed
fixup
1 parent 4cc656f commit 1c58b27

1 file changed

Lines changed: 39 additions & 19 deletions

File tree

rootfs/helmbroker/meta.py

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,47 @@
1-
from collections import namedtuple
1+
import os
2+
import yaml
3+
from .config import INSTANCES_PATH
24

5+
INSTANCE_META_FILE = os.path.join(INSTANCES_PATH, "instance.yaml")
36

7+
class InstanceMeta(object):
8+
"""
9+
{
10+
"id": "instance_id",
11+
"details": {
12+
"service_id": "service_id",
13+
"plan_id" : "plan_id",
14+
"context" : {
415
5-
"""
6-
{
7-
"id": "instance_id",
8-
"details": {
9-
"service_id": "service_id",
10-
"plan_id" : "plan_id",
11-
"context" : {
16+
},
17+
"parameters": {
1218
19+
}
1320
},
14-
"parameters": {
15-
21+
"last_operation": {
22+
"state": "Ready",
23+
"description": "everything is ok."
1624
}
17-
},
18-
"last_operation": {
19-
"state": "Ready",
20-
"description": "everything is ok."
2125
}
22-
}
23-
"""
26+
"""
27+
def __init__(self, id, details, last_operation):
28+
self.id = id
29+
self.details = details
30+
self.last_operation = last_operation
31+
32+
@classmethod
33+
def load(cls, file=INSTANCE_META_FILE):
34+
with open(file) as f:
35+
data = yaml.load(f, Loader=yaml.Loader)
36+
return cls(data["id"], data["details"], data["last_operation"])
2437

25-
26-
class InstanceMeta(object):
27-
pass
38+
def dump(self, file=INSTANCE_META_FILE):
39+
with open(file, "w") as f:
40+
yaml.dump(
41+
{
42+
"id": self.id,
43+
"details": self.details,
44+
"last_operation": self.last_operation
45+
},
46+
Loader=yaml.Loader
47+
)

0 commit comments

Comments
 (0)