Skip to content

Commit 60d40ff

Browse files
committed
xml is now a string
1 parent 66fb633 commit 60d40ff

15 files changed

+65
-45
lines changed

examples/compound_job_simulator/simulator.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
simulation = wrench.Simulation()
2424

2525
# Starting the simulation, with this simulated process running on the host ControllerHost
26-
simulation.start(platform_file_path, "ControllerHost")
26+
with open(platform_file_path, "r") as platform_file:
27+
xml_string = platform_file.read()
28+
simulation.start(xml_string, "ControllerHost")
2729

2830
hosts = simulation.get_all_hostnames()
2931
print(f"Hosts in the platform are: {hosts}")
@@ -142,12 +144,12 @@
142144

143145
print("Synchronously waiting for the next simulation event...")
144146
event = simulation.wait_for_next_event()
145-
print(f" - Event: {event}")
147+
print(f"\t- Event: {event}")
146148
print(f"Time is {simulation.get_simulated_time()}")
147149

148150
print("Synchronously waiting for the next simulation event...")
149151
event = simulation.wait_for_next_event()
150-
print(f" - Event: {event}")
152+
print(f"\t- Event: {event}")
151153
print(f"Time is {simulation.get_simulated_time()}")
152154

153155
# print("Synchronously waiting for the next simulation event...")

examples/json_workflow_simulator/simulator.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,15 @@ def main():
116116
print(f"Starting the simulation using the XML platform file...")
117117
current_dir = pathlib.Path(__file__).parent.resolve()
118118
platform_file_path = pathlib.Path(current_dir / "one_host_and_several_clusters.xml")
119-
simulation.start(platform_file_path, user_host)
119+
with open(platform_file_path, "r") as platform_file:
120+
xml_string = platform_file.read()
121+
simulation.start(xml_string, user_host)
120122

121123
# Get the list of all hostnames in the platform
122124
print(f"Getting the list of all hostnames...")
123125
list_of_hostnames = simulation.get_all_hostnames()
124126

125-
if not "UserHost" in list_of_hostnames:
127+
if "UserHost" not in list_of_hostnames:
126128
raise Exception("This simulator assumes that the XML platform files has a host with hostname UserHost that"
127129
" has a disk mounted at '/'")
128130
list_of_hostnames.remove("UserHost")
@@ -183,7 +185,7 @@ def main():
183185
# Wait for next event
184186
event = simulation.wait_for_next_event()
185187
if event["event_type"] != "standard_job_completion":
186-
print(f" - Event: {event}") # Should make sure it's a job completion
188+
print(f"\t- Event: {event}") # Should make sure it's a job completion
187189
raise wrench.WRENCHException("Received an unexpected event")
188190
else:
189191
completed_job = event["standard_job"]

examples/simple_simulator/simulator.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
simulation = wrench.Simulation()
2323

2424
# Starting the simulation, with this simulated process running on the host ControllerHost
25-
simulation.start(platform_file_path, "ControllerHost")
25+
with open(platform_file_path, "r") as platform_file:
26+
xml_string = platform_file.read()
27+
simulation.start(xml_string, "ControllerHost")
2628

2729
print(f"Simulation, time is {simulation.get_simulated_time()}")
2830

@@ -121,7 +123,7 @@
121123
print("Getting simulation events that have occurred while I slept...")
122124
events = simulation.get_events()
123125
for event in events:
124-
print(f" - Event: {event}")
126+
print(f"\t- Event: {event}")
125127

126128
print("Creating another task")
127129
task2 = workflow.add_task("task2", 100.0, 1, 1, 0)
@@ -131,7 +133,7 @@
131133

132134
print("Creating a VM on the cloud compute service...")
133135
my_vm = ccs.create_vm(1, 100,
134-
{"CloudComputeServiceProperty::VM_BOOT_OVERHEAD": "5s"},{})
136+
{"CloudComputeServiceProperty::VM_BOOT_OVERHEAD": "5s"}, {})
135137

136138
print("Starting the VM...")
137139
vm_cs = my_vm.start()
@@ -141,7 +143,7 @@
141143

142144
print("Synchronously waiting for the next simulation event...")
143145
event = simulation.wait_for_next_event()
144-
print(f" - Event: {event}")
146+
print(f"\t- Event: {event}")
145147

146148
print(f"Time is {simulation.get_simulated_time()}")
147149

@@ -158,7 +160,6 @@
158160
# if (my_sleep_action_1.get_state_as_string() == "RUNNING"):
159161
# print("Action is still running!")
160162

161-
162163
print("Terminating simulation")
163164

164165
simulation.terminate()

tests/bare_metal_compute_service_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121

2222
simulation = wrench.Simulation()
2323

24+
with open(platform_file_path, "r") as platform_file:
25+
xml_string = platform_file.read()
2426
try:
25-
simulation.start(platform_file_path, "ControllerHost")
27+
simulation.start(xml_string, "ControllerHost")
2628
except wrench.WRENCHException as e:
2729
sys.stderr.write(f"Error: {e}\n")
2830
exit(1)

tests/batch_compute_service_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@
2020
platform_file_path = pathlib.Path(current_dir / "sample_platform.xml")
2121

2222
simulation = wrench.Simulation()
23+
with open(platform_file_path, "r") as platform_file:
24+
xml_string = platform_file.read()
2325
try:
24-
simulation.start(platform_file_path, "ControllerHost")
26+
simulation.start(xml_string, "ControllerHost")
2527
except wrench.WRENCHException as e:
2628
sys.stderr.write(f"Error: {e}\n")
2729
exit(1)

tests/cloud_compute_service_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
platform_file_path = pathlib.Path(current_dir / "sample_platform.xml")
2020

2121
simulation = wrench.Simulation()
22+
with open(platform_file_path, "r") as platform_file:
23+
xml_string = platform_file.read()
2224
try:
23-
simulation.start(platform_file_path, "ControllerHost")
25+
simulation.start(xml_string, "ControllerHost")
2426
except wrench.WRENCHException as e:
2527
sys.stderr.write(f"Error: {e}\n")
2628
exit(1)

tests/compound_job_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
simulation = wrench.Simulation()
2424

2525
# Starting the simulation, with this simulated process running on the host ControllerHost
26-
simulation.start(platform_file_path, "ControllerHost")
26+
with open(platform_file_path, "r") as platform_file:
27+
xml_string = platform_file.read()
28+
simulation.start(xml_string, "ControllerHost")
2729

2830
# Creating a compute services
2931
bmcs = simulation.create_bare_metal_compute_service(

tests/file_registry_service_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121

2222
simulation = wrench.Simulation()
2323

24+
with open(platform_file_path, "r") as platform_file:
25+
xml_string = platform_file.read()
2426
try:
25-
simulation.start(platform_file_path, "ControllerHost")
27+
simulation.start(xml_string, "ControllerHost")
2628
except wrench.WRENCHException as e:
2729
sys.stderr.write(f"Error: {e}\n")
2830
exit(1)

tests/simulation_events_test.py_DISABLED

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ if __name__ == "__main__":
1919
platform_file_path = pathlib.Path(current_dir / "sample_platform.xml")
2020

2121
simulation = wrench.Simulation()
22+
with open(platform_file_path, "r") as platform_file:
23+
xml_string = platform_file.read()
2224

2325
try:
24-
simulation.start(platform_file_path, "ControllerHost")
26+
simulation.start(xml_string, "ControllerHost")
2527
except wrench.WRENCHException as e:
2628
sys.stderr.write(f"Error: {e}\n")
2729
exit(1)

tests/storage_service_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222

2323
simulation = wrench.Simulation()
2424

25-
simulation.start(platform_file_path, "ControllerHost")
25+
with open(platform_file_path, "r") as platform_file:
26+
xml_string = platform_file.read()
27+
simulation.start(xml_string, "ControllerHost")
2628

2729
ss = simulation.create_simple_storage_service("StorageHost", ["/"])
2830
# Coverage

0 commit comments

Comments
 (0)