'Pipe output of cmd1 into cmd2.'

def _piped_execute(self, cmd1, cmd2):

    LOG.debug("Piping    cmd1='%s'    into...", '    '.join(cmd1))
    LOG.debug("cmd2='%s'", '    '.join(cmd2))
    try:
        p1 = subprocess.Popen(cmd1, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    except OSError as e:
        LOG.error('Pipe1    failed    -    %s    ', e)
        raise
    flags = (fcntl.fcntl(p1.stdout, fcntl.F_GETFL) & (~ os.O_NONBLOCK))
    fcntl.fcntl(p1.stdout, fcntl.F_SETFL, flags)
    try:
        p2 = subprocess.Popen(cmd2, stdin=p1.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    except OSError as e:
        LOG.error('Pipe2    failed    -    %s    ', e)
        raise
    p1.stdout.close()
    (stdout, stderr) = p2.communicate()
    return (p2.returncode, stderr)
