Skip to content

Commit 7ac274b

Browse files
committed
Support new flexibility for pull.
1 parent 316e47a commit 7ac274b

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

virl/cli/up/commands.py

+29-3
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,25 @@ def start_lab(lab, provision=False):
6565
time.sleep(1)
6666

6767

68+
def _build_command(cmd, provision, start, **kwargs):
69+
if kwargs["f"]:
70+
cmd += ["-f", kwargs["f"]]
71+
if provision:
72+
cmd.append("--provision")
73+
else:
74+
cmd.append("--noprovision")
75+
if start:
76+
cmd.append("--start")
77+
else:
78+
cmd.append("--no-start")
79+
if kwargs["id"]:
80+
cmd += ["--id", kwargs["id"]]
81+
if kwargs["lab_name"]:
82+
cmd += ["--lab-name", kwargs["lab_name"]]
83+
84+
return cmd
85+
86+
6887
@click.command()
6988
@click.argument("repo", default="default")
7089
@click.option(
@@ -157,10 +176,17 @@ def up(repo=None, provision=False, start=True, **kwargs):
157176
lab = client.import_lab_from_path(fname, title=lname)
158177
elif not lab:
159178
# try to pull from virlfiles
160-
if repo and (os.path.basename(fname) == "topology.yaml" or os.path.basename(fname) == "topology.virl"):
161-
rc = call([get_command(), "pull", repo])
179+
if repo:
180+
cmd = [get_command(), "pull", repo]
181+
if kwargs["f"]:
182+
cmd += ["--file", kwargs["f"]]
183+
184+
rc = call(cmd)
162185
if rc == 0:
163-
exit(call([get_command(), "up"]))
186+
cmd = [get_command(), "up"]
187+
cmd = _build_command(provision, start, kwargs)
188+
189+
exit(call(cmd))
164190

165191
if lab:
166192
if lab.is_active():

0 commit comments

Comments
 (0)