execvp: almost passes tests
This commit is contained in:
@@ -343,7 +343,7 @@ def lease_ip(private_ip):
|
|||||||
private_ip)
|
private_ip)
|
||||||
instance_ref = db.fixed_ip_get_instance(context.get_admin_context(),
|
instance_ref = db.fixed_ip_get_instance(context.get_admin_context(),
|
||||||
private_ip)
|
private_ip)
|
||||||
cmd = (binpath('nova-dhcpbridge'), 'add'
|
cmd = (binpath('nova-dhcpbridge'), 'add',
|
||||||
instance_ref['mac_address'],
|
instance_ref['mac_address'],
|
||||||
private_ip, 'fake')
|
private_ip, 'fake')
|
||||||
env = {'DNSMASQ_INTERFACE': network_ref['bridge'],
|
env = {'DNSMASQ_INTERFACE': network_ref['bridge'],
|
||||||
|
|||||||
@@ -315,15 +315,16 @@ class IptablesFirewallTestCase(test.TestCase):
|
|||||||
instance_ref = db.instance_get(admin_ctxt, instance_ref['id'])
|
instance_ref = db.instance_get(admin_ctxt, instance_ref['id'])
|
||||||
|
|
||||||
# self.fw.add_instance(instance_ref)
|
# self.fw.add_instance(instance_ref)
|
||||||
def fake_iptables_execute(cmd, process_input=None):
|
def fake_iptables_execute(*cmd, **kwargs):
|
||||||
if cmd == 'sudo ip6tables-save -t filter':
|
process_input=kwargs.get('process_input', None)
|
||||||
|
if cmd == ('sudo', 'ip6tables-save', '-t', 'filter'):
|
||||||
return '\n'.join(self.in6_rules), None
|
return '\n'.join(self.in6_rules), None
|
||||||
if cmd == 'sudo iptables-save -t filter':
|
if cmd == ('sudo', 'iptables-save', '-t', 'filter'):
|
||||||
return '\n'.join(self.in_rules), None
|
return '\n'.join(self.in_rules), None
|
||||||
if cmd == 'sudo iptables-restore':
|
if cmd == ('sudo', 'iptables-restore'):
|
||||||
self.out_rules = process_input.split('\n')
|
self.out_rules = process_input.split('\n')
|
||||||
return '', ''
|
return '', ''
|
||||||
if cmd == 'sudo ip6tables-restore':
|
if cmd == ('sudo', 'ip6tables-restore'):
|
||||||
self.out6_rules = process_input.split('\n')
|
self.out6_rules = process_input.split('\n')
|
||||||
return '', ''
|
return '', ''
|
||||||
self.fw.execute = fake_iptables_execute
|
self.fw.execute = fake_iptables_execute
|
||||||
|
|||||||
@@ -128,13 +128,20 @@ def fetchfile(url, target):
|
|||||||
execute("curl", "--fail", url, "-o", target)
|
execute("curl", "--fail", url, "-o", target)
|
||||||
|
|
||||||
|
|
||||||
def execute(*cmd, process_input=None, addl_env=None, check_exit_code=True):
|
def execute(*cmd, **kwargs):
|
||||||
|
process_input=kwargs.get('process_input', None)
|
||||||
|
addl_env=kwargs.get('addl_env', None)
|
||||||
|
check_exit_code=kwargs.get('check_exit_code', True)
|
||||||
|
stdin=kwargs.get('stdin', subprocess.PIPE)
|
||||||
|
stdout=kwargs.get('stdout', subprocess.PIPE)
|
||||||
|
stderr=kwargs.get('stderr', subprocess.PIPE)
|
||||||
|
|
||||||
LOG.debug(_("Running cmd (subprocess): %s"), ' '.join(cmd))
|
LOG.debug(_("Running cmd (subprocess): %s"), ' '.join(cmd))
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
if addl_env:
|
if addl_env:
|
||||||
env.update(addl_env)
|
env.update(addl_env)
|
||||||
obj = subprocess.Popen(*cmd, stdin=subprocess.PIPE,
|
obj = subprocess.Popen(cmd, stdin=stdin,
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)
|
stdout=stdout, stderr=stderr, env=env)
|
||||||
result = None
|
result = None
|
||||||
if process_input != None:
|
if process_input != None:
|
||||||
result = obj.communicate(process_input)
|
result = obj.communicate(process_input)
|
||||||
@@ -220,9 +227,9 @@ def debug(arg):
|
|||||||
return arg
|
return arg
|
||||||
|
|
||||||
|
|
||||||
def runthis(prompt, cmd, check_exit_code=True):
|
def runthis(prompt, *cmd, **kwargs):
|
||||||
LOG.debug(_("Running %s"), (cmd))
|
LOG.debug(_("Running %s"), (" ".join(cmd)))
|
||||||
rv, err = execute(cmd, check_exit_code=check_exit_code)
|
rv, err = execute(*cmd, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def generate_uid(topic, size=8):
|
def generate_uid(topic, size=8):
|
||||||
|
|||||||
Reference in New Issue
Block a user