@@ -65,6 +65,25 @@ def start_lab(lab, provision=False):
65
65
time .sleep (1 )
66
66
67
67
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
+
68
87
@click .command ()
69
88
@click .argument ("repo" , default = "default" )
70
89
@click .option (
@@ -157,10 +176,17 @@ def up(repo=None, provision=False, start=True, **kwargs):
157
176
lab = client .import_lab_from_path (fname , title = lname )
158
177
elif not lab :
159
178
# 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 )
162
185
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 ))
164
190
165
191
if lab :
166
192
if lab .is_active ():
0 commit comments