execvp passes pep8
This commit is contained in:
@@ -134,9 +134,9 @@ class XVPConsoleProxy(object):
|
||||
logging.debug(_("Starting xvp"))
|
||||
try:
|
||||
utils.execute('xvp',
|
||||
'-p',FLAGS.console_xvp_pid,
|
||||
'-c',FLAGS.console_xvp_conf,
|
||||
'-l',FLAGS.console_xvp_log)
|
||||
'-p', FLAGS.console_xvp_pid,
|
||||
'-c', FLAGS.console_xvp_conf,
|
||||
'-l', FLAGS.console_xvp_log)
|
||||
except exception.ProcessExecutionError, err:
|
||||
logging.error(_("Error starting xvp: %s") % err)
|
||||
|
||||
|
||||
@@ -120,7 +120,8 @@ def generate_key_pair(bits=1024):
|
||||
# bio = M2Crypto.BIO.MemoryBuffer()
|
||||
# key.save_pub_key_bio(bio)
|
||||
# public_key = bio.read()
|
||||
# public_key, err = execute('ssh-keygen', '-y', '-f', '/dev/stdin', private_key)
|
||||
# public_key, err = execute('ssh-keygen', '-y', '-f',
|
||||
# '/dev/stdin', private_key)
|
||||
|
||||
return (private_key, public_key, fingerprint)
|
||||
|
||||
|
||||
@@ -68,7 +68,8 @@ def metadata_forward():
|
||||
_confirm_rule("PREROUTING", '-t', 'nat', '-s', '0.0.0.0/0',
|
||||
'-d', '169.254.169.254/32', '-p', 'tcp', '-m', 'tcp',
|
||||
'--dport', '80', '-j', 'DNAT',
|
||||
'--to-destination', '%s:%s' % (FLAGS.ec2_dmz_host, FLAGS.ec2_port))
|
||||
'--to-destination',
|
||||
'%s:%s' % (FLAGS.ec2_dmz_host, FLAGS.ec2_port))
|
||||
|
||||
|
||||
def init_host():
|
||||
@@ -86,7 +87,8 @@ def init_host():
|
||||
_execute('sudo', 'iptables', '-D', 'FORWARD', '-j', 'nova_forward',
|
||||
check_exit_code=False)
|
||||
_execute('sudo', 'iptables', '-A', 'FORWARD', '-j', 'nova_forward')
|
||||
_execute('sudo', 'iptables', '-N', 'nova_output', check_exit_code=False)
|
||||
_execute('sudo', 'iptables', '-N', 'nova_output',
|
||||
check_exit_code=False)
|
||||
_execute('sudo', 'iptables', '-D', 'OUTPUT', '-j', 'nova_output',
|
||||
check_exit_code=False)
|
||||
_execute('sudo', 'iptables', '-A', 'OUTPUT', '-j', 'nova_output')
|
||||
@@ -220,7 +222,7 @@ def ensure_bridge(bridge, interface, net_attrs=None):
|
||||
# bridge for it to respond to reqests properly
|
||||
suffix = net_attrs['cidr'].rpartition('/')[2]
|
||||
out, err = _execute('sudo', 'ip', 'addr', 'add',
|
||||
"%s/%s" %
|
||||
"%s/%s" %
|
||||
(net_attrs['gateway'], suffix),
|
||||
'brd',
|
||||
net_attrs['broadcast'],
|
||||
@@ -237,7 +239,8 @@ def ensure_bridge(bridge, interface, net_attrs=None):
|
||||
# bridge, then the bridge has to be in promiscuous
|
||||
# to forward packets properly.
|
||||
if(FLAGS.public_interface == bridge):
|
||||
_execute('sudo', 'ip', 'link', 'set', 'dev', bridge, 'promisc', 'on')
|
||||
_execute('sudo', 'ip', 'link', 'set',
|
||||
'dev', bridge, 'promisc', 'on')
|
||||
if interface:
|
||||
# NOTE(vish): This will break if there is already an ip on the
|
||||
# interface, so we move any ips to the bridge
|
||||
@@ -253,8 +256,10 @@ def ensure_bridge(bridge, interface, net_attrs=None):
|
||||
fields = line.split()
|
||||
if fields and fields[0] == "inet":
|
||||
params = ' '.join(fields[1:-1])
|
||||
_execute('sudo', 'ip', 'addr', 'del', params, 'dev', fields[-1])
|
||||
_execute('sudo', 'ip', 'addr', 'add', params, 'dev', bridge)
|
||||
_execute('sudo', 'ip', 'addr',
|
||||
'del', params, 'dev', fields[-1])
|
||||
_execute('sudo', 'ip', 'addr',
|
||||
'add', params, 'dev', bridge)
|
||||
if gateway:
|
||||
_execute('sudo', 'route', 'add', '0.0.0.0', 'gw', gateway)
|
||||
out, err = _execute('sudo', 'brctl', 'addif', bridge, interface,
|
||||
@@ -397,7 +402,7 @@ def _device_exists(device):
|
||||
|
||||
|
||||
def _confirm_rule(chain, *cmd, **kwargs):
|
||||
append=kwargs.get('append',False)
|
||||
append = kwargs.get('append', False)
|
||||
"""Delete and re-add iptables rule"""
|
||||
if FLAGS.use_nova_chains:
|
||||
chain = "nova_%s" % chain.lower()
|
||||
|
||||
@@ -316,7 +316,7 @@ class IptablesFirewallTestCase(test.TestCase):
|
||||
|
||||
# self.fw.add_instance(instance_ref)
|
||||
def fake_iptables_execute(*cmd, **kwargs):
|
||||
process_input=kwargs.get('process_input', None)
|
||||
process_input = kwargs.get('process_input', None)
|
||||
if cmd == ('sudo', 'ip6tables-save', '-t', 'filter'):
|
||||
return '\n'.join(self.in6_rules), None
|
||||
if cmd == ('sudo', 'iptables-save', '-t', 'filter'):
|
||||
|
||||
@@ -40,7 +40,7 @@ import netaddr
|
||||
from eventlet import event
|
||||
from eventlet import greenthread
|
||||
from eventlet.green import subprocess
|
||||
|
||||
None
|
||||
from nova import exception
|
||||
from nova.exception import ProcessExecutionError
|
||||
from nova import log as logging
|
||||
@@ -129,13 +129,13 @@ def fetchfile(url, target):
|
||||
|
||||
|
||||
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', 0)
|
||||
stdin=kwargs.get('stdin', subprocess.PIPE)
|
||||
stdout=kwargs.get('stdout', subprocess.PIPE)
|
||||
stderr=kwargs.get('stderr', subprocess.PIPE)
|
||||
cmd=map(str,cmd)
|
||||
process_input = kwargs.get('process_input', None)
|
||||
addl_env = kwargs.get('addl_env', None)
|
||||
check_exit_code = kwargs.get('check_exit_code', 0)
|
||||
stdin = kwargs.get('stdin', subprocess.PIPE)
|
||||
stdout = kwargs.get('stdout', subprocess.PIPE)
|
||||
stderr = kwargs.get('stderr', subprocess.PIPE)
|
||||
cmd = map(str, cmd)
|
||||
|
||||
LOG.debug(_("Running cmd (subprocess): %s"), ' '.join(cmd))
|
||||
env = os.environ.copy()
|
||||
@@ -151,7 +151,8 @@ def execute(*cmd, **kwargs):
|
||||
obj.stdin.close()
|
||||
if obj.returncode:
|
||||
LOG.debug(_("Result was %s") % obj.returncode)
|
||||
if check_exit_code is not None and obj.returncode != check_exit_code:
|
||||
if type(check_exit_code) == types.IntType \
|
||||
and obj.returncode != check_exit_code:
|
||||
(stdout, stderr) = result
|
||||
raise ProcessExecutionError(exit_code=obj.returncode,
|
||||
stdout=stdout,
|
||||
|
||||
@@ -112,7 +112,7 @@ class VolumeDriver(object):
|
||||
# If the volume isn't present, then don't attempt to delete
|
||||
return True
|
||||
|
||||
self._try_execute('sudo', 'lvremove', '-f',"%s/%s" %
|
||||
self._try_execute('sudo', 'lvremove', '-f', "%s/%s" %
|
||||
(FLAGS.volume_group,
|
||||
volume['name']))
|
||||
|
||||
@@ -256,7 +256,7 @@ class ISCSIDriver(VolumeDriver):
|
||||
self._sync_exec('sudo', 'ietadm', '--op', 'new',
|
||||
"--tid=%s" % iscsi_target,
|
||||
'--params',
|
||||
"Name=%s" % iscsi-name,
|
||||
"Name=%s" % iscsi_name,
|
||||
check_exit_code=False)
|
||||
self._sync_exec('sudo', 'ietadm', '--op', 'new',
|
||||
"--tid=%s" % iscsi_target,
|
||||
|
||||
Reference in New Issue
Block a user