Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 9c7e7886 authored by JONGLEZ Baptiste's avatar JONGLEZ Baptiste
Browse files

fork hack: get rid of prod networks

parent e7150e44
No related branches found
No related tags found
No related merge requests found
Pipeline #639597 failed
......@@ -5,23 +5,22 @@ import logging
import enoslib as en
en.init_logging(level=logging.DEBUG)
# TODO: we should check that inner jobs can "fit" in the container job.
# Otherwise, they will indefinitely remain in the Waiting state.
def g5k_run_async(req_conf, control_node="grisou"):
# TODO: get the right site for the control node
control_net = en.G5kNetworkConf(id="control", type="prod",
roles=["#enoslib-internal-control"],
site="nancy")
# Build container jobs with requested resources + 1 control node
containers = (
en.G5kConf.from_settings(job_type=["container", "noop"],
job_name=req_conf.job_name + "-container",
networks=deepcopy(req_conf.networks),
machines=deepcopy(req_conf.machines))
.add_machine(roles=["#enoslib-internal-control"], cluster=control_node,
primary_network=control_net,
nodes=1)
en.G5kConf.from_settings(
job_type=["container", "noop"],
job_name=req_conf.job_name + "-container",
networks=deepcopy(req_conf.networks),
machines=deepcopy(req_conf.machines),
)
.add_machine(roles=["#enoslib-internal-control"], cluster=control_node, nodes=1)
.finalize()
)
p_containers = en.G5k(containers)
......@@ -40,44 +39,39 @@ def g5k_run_async(req_conf, control_node="grisou"):
# Filter request to only keep machines and networks for this site.
# TODO: this should be a method provided by Enoslib
site_dict = req_conf.to_dict()
site_dict["resources"]["networks"] = [net for net in site_dict["resources"]["networks"] if net["site"] == site]
site_dict["resources"]["networks"] = [
net for net in site_dict["resources"]["networks"] if net["site"] == site
]
# The dict representation for machines does not include the site,
# we need to hack a bit.
machines_dicts = [m_group.to_dict() for m_group in req_conf.machines if m_group.site == site]
machines_dicts = [
m_group.to_dict() for m_group in req_conf.machines if m_group.site == site
]
site_dict["resources"]["machines"] = machines_dicts
site_conf = en.G5kConf.from_dictionnary(site_dict)
# Add "inner=XXX" type to run inside the container job
site_conf.job_type.append("inner={}".format(container_id))
site_conf.job_type.append(f"inner={container_id}")
# Add control node
if site == "nancy": # TODO
site_conf.add_machine(roles=["#enoslib-internal-control"], cluster=control_node,
primary_network=control_net,
nodes=1)
if site == "nancy": # TODO
site_conf.add_machine(
roles=["#enoslib-internal-control"], cluster=control_node, nodes=1
)
site_conf.finalize()
print(site_conf)
p_site = en.G5k(site_conf)
p_site.async_init()
print("{!r}".format(p_site))
print(f"{p_site!r}")
# claim the resources
network1 = en.G5kNetworkConf(id="n1", type="prod", roles=["my_network"], site="grenoble")
network2 = en.G5kNetworkConf(id="n2", type="prod", roles=["my_network"], site="rennes")
conf = (
en.G5kConf.from_settings(job_type="allow_classic_ssh", job_name="fork")
.add_network_conf(network1)
.add_network_conf(network2)
.add_machine(
roles=["role1"], cluster="dahu", nodes=2, primary_network=network1
)
.add_machine(
roles=["role2"], cluster="paravance", nodes=1, primary_network=network2
)
.add_machine(roles=["role1"], cluster="dahu", nodes=2)
.add_machine(roles=["role2"], cluster="paravance", nodes=1)
.finalize()
)
g5k_run_async(conf)
# Get actual resources
#roles, networks = provider.init()
# roles, networks = provider.init()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment