@@ -195,6 +195,10 @@ def create_hosts(self, name, depends_on):
195195
196196 def shell (self , name ):
197197 '''if an instance exists, shell into it.
198+
199+ Parameters
200+ ==========
201+ name: the name of the instance to shell into
198202 '''
199203 if self .instances :
200204 if name in self .instances :
@@ -203,6 +207,25 @@ def shell(self, name):
203207 self .client .shell (instance .instance .get_uri (), sudo = self .sudo )
204208
205209
210+ def execute (self , name , commands ):
211+ '''if an instance exists, execute a command to it.
212+
213+ Parameters
214+ ==========
215+ name: the name of the instance to exec to
216+ commands: a list of commands to issue
217+ '''
218+ if self .instances :
219+ if name in self .instances :
220+ instance = self .instances [name ]
221+ if instance .exists ():
222+ for line in self .client .execute (instance .instance .get_uri (),
223+ command = commands ,
224+ stream = True ,
225+ sudo = self .sudo ):
226+ print (line , end = '' )
227+
228+
206229 def logs (self , names , tail = 0 ):
207230 '''logs will print logs to the screen.
208231 '''
@@ -275,19 +298,24 @@ def _create(self, names, command="create", writable_tmpfs=False):
275298
276299 for instance in self .iter_instances (names ):
277300
301+ # Flag to indicated create
302+ do_create = True
303+
278304 # Ensure created, skip over if not
279305 for depends_on in instance .params .get ('depends_on' , []):
280306 if depends_on not in created :
281307 count += 1
282- continue
308+ do_create = False
309+
310+ if do_create :
283311
284- # Create a hosts file for the instance based on depends
285- self .create_hosts (instance .name , created )
312+ # Create a hosts file for the instance based on depends
313+ self .create_hosts (instance .name , created )
286314
287- # If we get here, execute command and add to list
288- getattr (instance , command )(self .working_dir , writable_tmpfs )
289- created .append (instance .name )
290- names .remove (instance .name )
315+ # If we get here, execute command and add to list
316+ getattr (instance , command )(self .working_dir , writable_tmpfs )
317+ created .append (instance .name )
318+ names .remove (instance .name )
291319
292320 # Possibly circular dependencies
293321 if count >= 100 :
0 commit comments