1616import os
1717import platform
1818import re
19- import time
2019
2120
2221class Instance :
@@ -174,13 +173,17 @@ def set_network(self, params):
174173 self .network [key ] = self .network .get (key , True )
175174
176175 def set_ports (self , params ):
177- """set ports from the recipe to be used"""
176+ """
177+ Set ports from the recipe to be used
178+ """
178179 self .ports = params .get ("ports" , [])
179180
180181 # Commands
181182
182183 def set_start (self , params ):
183- """set arguments to the startscript"""
184+ """
185+ Set arguments to the startscript
186+ """
184187 start = params .get ("start" , {})
185188 self .args = start .get ("args" , "" )
186189 self .start_opts = [
@@ -211,6 +214,13 @@ def _get_command_opts(self, group):
211214 """
212215 return ["--%s" % opt if len (opt ) > 1 else "-%s" % opt for opt in group ]
213216
217+ @property
218+ def network_args (self ):
219+ """
220+ Return a list of network args.
221+ """
222+ return self .params .get ("network" , {}).get ("args" , [])
223+
214224 def _get_network_commands (self , ip_address = None ):
215225 """
216226 Take a list of ports, return the list of --network-args to
@@ -221,8 +231,12 @@ def _get_network_commands(self, ip_address=None):
221231 # Fakeroot means not needing sudo
222232 fakeroot = "--fakeroot" in self .start_opts or "-f" in self .start_opts
223233
224- # If not sudo or fakeroot, we need --network none
225- if not self .sudo and not fakeroot :
234+ # Add all network args
235+ network_args = self .network_args
236+ for arg in network_args :
237+ ports += ["--network-args" , arg ]
238+
239+ if not network_args and (not self .sudo and not fakeroot ):
226240 ports += ["--network" , "none" ]
227241
228242 for pair in self .ports :
0 commit comments