diff options
-rw-r--r-- | main.py | 31 | ||||
-rw-r--r-- | out/phase-2/dba-cluster/0.yaml | 2 | ||||
-rw-r--r-- | out/phase-2/dba-cluster/vimscore-production.yaml | 2 | ||||
-rw-r--r-- | out/phase-2/dba-container/vimscore-production_4tune-api.yaml (renamed from out/phase-2/dba-container/1.yaml) | 1 | ||||
-rw-r--r-- | out/phase-2/dba-container/vimscore-production_4tune-web.yaml (renamed from out/phase-2/dba-container/2.yaml) | 1 | ||||
-rw-r--r-- | out/phase-2/dba-container/vimscore-production_mdb.yaml (renamed from out/phase-2/dba-container/0.yaml) | 1 | ||||
-rw-r--r-- | out/phase-2/dba-container/vimscore-production_pdb.yaml (renamed from out/phase-2/dba-container/5.yaml) | 1 | ||||
-rw-r--r-- | out/phase-2/dba-container/vimscore-production_statera-console.yaml (renamed from out/phase-2/dba-container/3.yaml) | 1 | ||||
-rw-r--r-- | out/phase-2/dba-container/vimscore-production_statera.yaml (renamed from out/phase-2/dba-container/4.yaml) | 1 |
9 files changed, 27 insertions, 14 deletions
@@ -44,12 +44,18 @@ class VsOperations: class DockerBasedApplications: @staticmethod - def cluster(name: str): - return {"type": "dba-cluster", "name": name} + def cluster(key: str): + return {"type": "dba-cluster", "key": key} @staticmethod def container(cluster: str, machineRole: str, name: str, image: str, tag: str): - return {"type": "dba-container", "cluster": cluster, "machineRole": machineRole, "name": name, "image": image, "tag": tag} + return {"type": "dba-container", + "key": f"{cluster}/{name}", + "cluster": cluster, + "machineRole": machineRole, + "name": name, + "image": image, + "tag": tag} dba = DockerBasedApplications @@ -82,7 +88,7 @@ with ruleset("my-rules"): # The none() part doesn't work as is, but it is worked around with the try/except block. @when_all( (c.container << m.type == "dba-container"), - none((m.type == "dba-cluster") & (m.name == c.container.cluster)), + none((m.type == "dba-cluster") & (m.key == c.container.cluster)), ) def dbCluster(c): cluster = c.container.cluster @@ -94,7 +100,7 @@ with ruleset("my-rules"): # @when_all(pri(40), # (c.container << m.type == "dba-container"), -# (c.cluster << (m.type == "dba-cluster") & (m.name == c.container.cluster)), +# (c.cluster << (m.type == "dba-cluster") & (m.key == c.container.cluster)), # ) # def dbCluster(c): # print("dba-cluster: CATCH ALL") @@ -117,11 +123,11 @@ if True: print("dba-clusters:") for f in [f for f in get_facts("my-rules") if f["type"] == "dba-cluster"]: - cluster_name = f["name"] + cluster_name = f["key"] - del f["name"] + del f["key"] print(f" cluster:") - print(f" name: {cluster_name}") + print(f" key: {cluster_name}") print(f" json: {f}") print(" dba-containers:") @@ -156,7 +162,7 @@ with ruleset("phase-2"): @when_all(pri(50), c.cluster << (m.type == "dba-cluster"), -# c.container << ((m.type == "dba-container") & (m.cluster == c.cluster.name) & m.ports.anyItem(item > 0)) +# c.container << ((m.type == "dba-container") & (m.cluster == c.cluster.key) & m.ports.anyItem(item > 0)) c.container << ((m.type == "dba-container") & +m.ports_classified & (m.public_ports > 0)) ) def container(c): @@ -209,11 +215,12 @@ def write_facts(ruleset: set): fs.append(f) i = 0 - for fact in fs: - path = os.path.join(typedir, str(i) + ".yaml") + for fact in sorted(fs, key=lambda f: f["key"]): + key = fact["key"] + path = os.path.join(typedir, f"{key.replace('/', '_')}.yaml") with open(path, "w") as f: s = yaml.dump(fact) - f.write(s) + f.write(s) i = i + 1 write_facts("phase-2") diff --git a/out/phase-2/dba-cluster/0.yaml b/out/phase-2/dba-cluster/0.yaml deleted file mode 100644 index 1eedbaa..0000000 --- a/out/phase-2/dba-cluster/0.yaml +++ /dev/null @@ -1,2 +0,0 @@ -name: vimscore-production -type: dba-cluster diff --git a/out/phase-2/dba-cluster/vimscore-production.yaml b/out/phase-2/dba-cluster/vimscore-production.yaml new file mode 100644 index 0000000..4390af6 --- /dev/null +++ b/out/phase-2/dba-cluster/vimscore-production.yaml @@ -0,0 +1,2 @@ +key: vimscore-production +type: dba-cluster diff --git a/out/phase-2/dba-container/1.yaml b/out/phase-2/dba-container/vimscore-production_4tune-api.yaml index 5fa9794..5e9fd63 100644 --- a/out/phase-2/dba-container/1.yaml +++ b/out/phase-2/dba-container/vimscore-production_4tune-api.yaml @@ -1,5 +1,6 @@ cluster: vimscore-production image: 4tune-api +key: vimscore-production/4tune-api machineRole: app name: 4tune-api ports_classified: true diff --git a/out/phase-2/dba-container/2.yaml b/out/phase-2/dba-container/vimscore-production_4tune-web.yaml index 68c3906..c5b87c5 100644 --- a/out/phase-2/dba-container/2.yaml +++ b/out/phase-2/dba-container/vimscore-production_4tune-web.yaml @@ -1,5 +1,6 @@ cluster: vimscore-production image: 4tune-web +key: vimscore-production/4tune-web machineRole: app name: 4tune-web ports_classified: true diff --git a/out/phase-2/dba-container/0.yaml b/out/phase-2/dba-container/vimscore-production_mdb.yaml index 60dba7a..48a760b 100644 --- a/out/phase-2/dba-container/0.yaml +++ b/out/phase-2/dba-container/vimscore-production_mdb.yaml @@ -1,5 +1,6 @@ cluster: vimscore-production image: mongodb +key: vimscore-production/mdb machineRole: db name: mdb ports_classified: true diff --git a/out/phase-2/dba-container/5.yaml b/out/phase-2/dba-container/vimscore-production_pdb.yaml index 8f82989..4f7d732 100644 --- a/out/phase-2/dba-container/5.yaml +++ b/out/phase-2/dba-container/vimscore-production_pdb.yaml @@ -1,5 +1,6 @@ cluster: vimscore-production image: postgresql +key: vimscore-production/pdb machineRole: db name: pdb ports_classified: true diff --git a/out/phase-2/dba-container/3.yaml b/out/phase-2/dba-container/vimscore-production_statera-console.yaml index a883361..dda5ea6 100644 --- a/out/phase-2/dba-container/3.yaml +++ b/out/phase-2/dba-container/vimscore-production_statera-console.yaml @@ -1,5 +1,6 @@ cluster: vimscore-production image: statera-console +key: vimscore-production/statera-console machineRole: app name: statera-console ports: diff --git a/out/phase-2/dba-container/4.yaml b/out/phase-2/dba-container/vimscore-production_statera.yaml index d4555f9..dcee4fa 100644 --- a/out/phase-2/dba-container/4.yaml +++ b/out/phase-2/dba-container/vimscore-production_statera.yaml @@ -1,5 +1,6 @@ cluster: vimscore-production image: statera +key: vimscore-production/statera machineRole: app name: statera ports: |