Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
karina-ranadive committed Feb 7, 2025
1 parent 748b92a commit c3c3f0b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ steps:
tuningSet: Sequence
runScript:
name: "Run Python Script"
command: "python modules/python/clusterloader2/slo/randomNs.py"
command: "python modules/python/clusterloader2/slo/randomNs.py && python modules/python/clusterloader2/slo/config/process_template.py"
objectBundle:
- basename: cnp
objectTemplatePath: cnp_template.yaml
18 changes: 18 additions & 0 deletions modules/python/clusterloader2/slo/process_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import os

# Read the random namespace from the file
with open("random_namespace.txt", "r") as file:
random_namespace = file.read().strip()

# Read the template file
with open("cnp_template.yaml", "r") as file:
template = file.read()

# Replace the placeholder with the random namespace
template = template.replace("{{$randomNamespace}}", random_namespace)

# Write the processed template back to the same file
with open("cnp_template.yaml", "w") as file:
file.write(template)

print("Processed template written to cnp_template.yaml")
9 changes: 7 additions & 2 deletions modules/python/clusterloader2/slo/randomNs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import random

namespaces = ["slo-1", "slo-2"]
namespace = {{.Namespace}}
namespace = "{{.Namespace}}"
randomNamespace = ""

while randomNamespace == "":
Expand All @@ -10,4 +10,9 @@
randomNamespace = namespaces[randomIndex]
break

print(f"Selected random namespace: {randomNamespace}")
def get_random_namespace():
return randomNamespace

# Write the random namespace to a file
with open("random_namespace.txt", "w") as file:
file.write(get_random_namespace())

0 comments on commit c3c3f0b

Please sign in to comment.