You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by al...@apache.org on 2012/07/10 03:31:08 UTC

[12/18] [Defect / Enhancement / New Feature] CS-15281 : Removal of third party dependencies in Citrix code base

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/32fef61a/tools/migration/paramiko/file.py
----------------------------------------------------------------------
diff --git a/tools/migration/paramiko/file.py b/tools/migration/paramiko/file.py
deleted file mode 100644
index ac86437..0000000
--- a/tools/migration/paramiko/file.py
+++ /dev/null
@@ -1,453 +0,0 @@
-# Copyright (C) 2003-2007  Robey Pointer <ro...@gmail.com>
-# Copyright 2012 Citrix Systems, Inc. Licensed under the
-# Apache License, Version 2.0 (the "License"); you may not use this
-# file except in compliance with the License.  Citrix Systems, Inc.
-# reserves all rights not expressly granted by the License.
-# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# 
-# Automatically generated by addcopyright.py at 04/03/2012
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-
-"""
-BufferedFile.
-"""
-
-from cStringIO import StringIO
-
-
-class BufferedFile (object):
-    """
-    Reusable base class to implement python-style file buffering around a
-    simpler stream.
-    """
-
-    _DEFAULT_BUFSIZE = 8192
-
-    SEEK_SET = 0
-    SEEK_CUR = 1
-    SEEK_END = 2
-
-    FLAG_READ = 0x1
-    FLAG_WRITE = 0x2
-    FLAG_APPEND = 0x4
-    FLAG_BINARY = 0x10
-    FLAG_BUFFERED = 0x20
-    FLAG_LINE_BUFFERED = 0x40
-    FLAG_UNIVERSAL_NEWLINE = 0x80
-
-    def __init__(self):
-        self.newlines = None
-        self._flags = 0
-        self._bufsize = self._DEFAULT_BUFSIZE
-        self._wbuffer = StringIO()
-        self._rbuffer = ''
-        self._at_trailing_cr = False
-        self._closed = False
-        # pos - position within the file, according to the user
-        # realpos - position according the OS
-        # (these may be different because we buffer for line reading)
-        self._pos = self._realpos = 0
-        # size only matters for seekable files
-        self._size = 0
-
-    def __del__(self):
-        self.close()
-        
-    def __iter__(self):
-        """
-        Returns an iterator that can be used to iterate over the lines in this
-        file.  This iterator happens to return the file itself, since a file is
-        its own iterator.
-
-        @raise ValueError: if the file is closed.
-        
-        @return: an interator.
-        @rtype: iterator
-        """
-        if self._closed:
-            raise ValueError('I/O operation on closed file')
-        return self
-
-    def close(self):
-        """
-        Close the file.  Future read and write operations will fail.
-        """
-        self.flush()
-        self._closed = True
-
-    def flush(self):
-        """
-        Write out any data in the write buffer.  This may do nothing if write
-        buffering is not turned on.
-        """
-        self._write_all(self._wbuffer.getvalue())
-        self._wbuffer = StringIO()
-        return
-
-    def next(self):
-        """
-        Returns the next line from the input, or raises L{StopIteration} when
-        EOF is hit.  Unlike python file objects, it's okay to mix calls to
-        C{next} and L{readline}.
-
-        @raise StopIteration: when the end of the file is reached.
-
-        @return: a line read from the file.
-        @rtype: str
-        """
-        line = self.readline()
-        if not line:
-            raise StopIteration
-        return line
-
-    def read(self, size=None):
-        """
-        Read at most C{size} bytes from the file (less if we hit the end of the
-        file first).  If the C{size} argument is negative or omitted, read all
-        the remaining data in the file.
-
-        @param size: maximum number of bytes to read
-        @type size: int
-        @return: data read from the file, or an empty string if EOF was
-            encountered immediately
-        @rtype: str
-        """
-        if self._closed:
-            raise IOError('File is closed')
-        if not (self._flags & self.FLAG_READ):
-            raise IOError('File is not open for reading')
-        if (size is None) or (size < 0):
-            # go for broke
-            result = self._rbuffer
-            self._rbuffer = ''
-            self._pos += len(result)
-            while True:
-                try:
-                    new_data = self._read(self._DEFAULT_BUFSIZE)
-                except EOFError:
-                    new_data = None
-                if (new_data is None) or (len(new_data) == 0):
-                    break
-                result += new_data
-                self._realpos += len(new_data)
-                self._pos += len(new_data)
-            return result
-        if size <= len(self._rbuffer):
-            result = self._rbuffer[:size]
-            self._rbuffer = self._rbuffer[size:]
-            self._pos += len(result)
-            return result
-        while len(self._rbuffer) < size:
-            read_size = size - len(self._rbuffer)
-            if self._flags & self.FLAG_BUFFERED:
-                read_size = max(self._bufsize, read_size)
-            try:
-                new_data = self._read(read_size)
-            except EOFError:
-                new_data = None
-            if (new_data is None) or (len(new_data) == 0):
-                break
-            self._rbuffer += new_data
-            self._realpos += len(new_data)
-        result = self._rbuffer[:size]
-        self._rbuffer = self._rbuffer[size:]
-        self._pos += len(result)
-        return result
-
-    def readline(self, size=None):
-        """
-        Read one entire line from the file.  A trailing newline character is
-        kept in the string (but may be absent when a file ends with an
-        incomplete line).  If the size argument is present and non-negative, it
-        is a maximum byte count (including the trailing newline) and an
-        incomplete line may be returned.  An empty string is returned only when
-        EOF is encountered immediately.
-
-        @note: Unlike stdio's C{fgets()}, the returned string contains null
-        characters (C{'\\0'}) if they occurred in the input.
-
-        @param size: maximum length of returned string.
-        @type size: int
-        @return: next line of the file, or an empty string if the end of the
-            file has been reached.
-        @rtype: str
-        """
-        # it's almost silly how complex this function is.
-        if self._closed:
-            raise IOError('File is closed')
-        if not (self._flags & self.FLAG_READ):
-            raise IOError('File not open for reading')
-        line = self._rbuffer
-        while True:
-            if self._at_trailing_cr and (self._flags & self.FLAG_UNIVERSAL_NEWLINE) and (len(line) > 0):
-                # edge case: the newline may be '\r\n' and we may have read
-                # only the first '\r' last time.
-                if line[0] == '\n':
-                    line = line[1:]
-                    self._record_newline('\r\n')
-                else:
-                    self._record_newline('\r')
-                self._at_trailing_cr = False
-            # check size before looking for a linefeed, in case we already have
-            # enough.
-            if (size is not None) and (size >= 0):
-                if len(line) >= size:
-                    # truncate line and return
-                    self._rbuffer = line[size:]
-                    line = line[:size]
-                    self._pos += len(line)
-                    return line
-                n = size - len(line)
-            else:
-                n = self._bufsize
-            if ('\n' in line) or ((self._flags & self.FLAG_UNIVERSAL_NEWLINE) and ('\r' in line)):
-                break
-            try:
-                new_data = self._read(n)
-            except EOFError:
-                new_data = None
-            if (new_data is None) or (len(new_data) == 0):
-                self._rbuffer = ''
-                self._pos += len(line)
-                return line
-            line += new_data
-            self._realpos += len(new_data)
-        # find the newline
-        pos = line.find('\n')
-        if self._flags & self.FLAG_UNIVERSAL_NEWLINE:
-            rpos = line.find('\r')
-            if (rpos >= 0) and ((rpos < pos) or (pos < 0)):
-                pos = rpos
-        xpos = pos + 1
-        if (line[pos] == '\r') and (xpos < len(line)) and (line[xpos] == '\n'):
-            xpos += 1
-        self._rbuffer = line[xpos:]
-        lf = line[pos:xpos]
-        line = line[:pos] + '\n'
-        if (len(self._rbuffer) == 0) and (lf == '\r'):
-            # we could read the line up to a '\r' and there could still be a
-            # '\n' following that we read next time.  note that and eat it.
-            self._at_trailing_cr = True
-        else:
-            self._record_newline(lf)
-        self._pos += len(line)
-        return line
-
-    def readlines(self, sizehint=None):
-        """
-        Read all remaining lines using L{readline} and return them as a list.
-        If the optional C{sizehint} argument is present, instead of reading up
-        to EOF, whole lines totalling approximately sizehint bytes (possibly
-        after rounding up to an internal buffer size) are read.
-
-        @param sizehint: desired maximum number of bytes to read.
-        @type sizehint: int
-        @return: list of lines read from the file.
-        @rtype: list
-        """
-        lines = []
-        bytes = 0
-        while True:
-            line = self.readline()
-            if len(line) == 0:
-                break
-            lines.append(line)
-            bytes += len(line)
-            if (sizehint is not None) and (bytes >= sizehint):
-                break
-        return lines
-
-    def seek(self, offset, whence=0):
-        """
-        Set the file's current position, like stdio's C{fseek}.  Not all file
-        objects support seeking.
-
-        @note: If a file is opened in append mode (C{'a'} or C{'a+'}), any seek
-            operations will be undone at the next write (as the file position
-            will move back to the end of the file).
-        
-        @param offset: position to move to within the file, relative to
-            C{whence}.
-        @type offset: int
-        @param whence: type of movement: 0 = absolute; 1 = relative to the
-            current position; 2 = relative to the end of the file.
-        @type whence: int
-
-        @raise IOError: if the file doesn't support random access.
-        """
-        raise IOError('File does not support seeking.')
-
-    def tell(self):
-        """
-        Return the file's current position.  This may not be accurate or
-        useful if the underlying file doesn't support random access, or was
-        opened in append mode.
-
-        @return: file position (in bytes).
-        @rtype: int
-        """
-        return self._pos
-
-    def write(self, data):
-        """
-        Write data to the file.  If write buffering is on (C{bufsize} was
-        specified and non-zero), some or all of the data may not actually be
-        written yet.  (Use L{flush} or L{close} to force buffered data to be
-        written out.)
-
-        @param data: data to write.
-        @type data: str
-        """
-        if self._closed:
-            raise IOError('File is closed')
-        if not (self._flags & self.FLAG_WRITE):
-            raise IOError('File not open for writing')
-        if not (self._flags & self.FLAG_BUFFERED):
-            self._write_all(data)
-            return
-        self._wbuffer.write(data)
-        if self._flags & self.FLAG_LINE_BUFFERED:
-            # only scan the new data for linefeed, to avoid wasting time.
-            last_newline_pos = data.rfind('\n')
-            if last_newline_pos >= 0:
-                wbuf = self._wbuffer.getvalue()
-                last_newline_pos += len(wbuf) - len(data)
-                self._write_all(wbuf[:last_newline_pos + 1])
-                self._wbuffer = StringIO()
-                self._wbuffer.write(wbuf[last_newline_pos + 1:])
-            return
-        # even if we're line buffering, if the buffer has grown past the
-        # buffer size, force a flush.
-        if self._wbuffer.tell() >= self._bufsize:
-            self.flush()
-        return
-
-    def writelines(self, sequence):
-        """
-        Write a sequence of strings to the file.  The sequence can be any
-        iterable object producing strings, typically a list of strings.  (The
-        name is intended to match L{readlines}; C{writelines} does not add line
-        separators.)
-
-        @param sequence: an iterable sequence of strings.
-        @type sequence: sequence
-        """
-        for line in sequence:
-            self.write(line)
-        return
-
-    def xreadlines(self):
-        """
-        Identical to C{iter(f)}.  This is a deprecated file interface that
-        predates python iterator support.
-
-        @return: an iterator.
-        @rtype: iterator
-        """
-        return self
-
-
-    ###  overrides...
-
-
-    def _read(self, size):
-        """
-        I{(subclass override)}
-        Read data from the stream.  Return C{None} or raise C{EOFError} to
-        indicate EOF.
-        """
-        raise EOFError()
-
-    def _write(self, data):
-        """
-        I{(subclass override)}
-        Write data into the stream.
-        """
-        raise IOError('write not implemented')
-
-    def _get_size(self):
-        """
-        I{(subclass override)}
-        Return the size of the file.  This is called from within L{_set_mode}
-        if the file is opened in append mode, so the file position can be
-        tracked and L{seek} and L{tell} will work correctly.  If the file is
-        a stream that can't be randomly accessed, you don't need to override
-        this method,
-        """
-        return 0
-
-
-    ###  internals...
-
-
-    def _set_mode(self, mode='r', bufsize=-1):
-        """
-        Subclasses call this method to initialize the BufferedFile.
-        """
-        # set bufsize in any event, because it's used for readline().
-        self._bufsize = self._DEFAULT_BUFSIZE
-        if bufsize < 0:
-            # do no buffering by default, because otherwise writes will get
-            # buffered in a way that will probably confuse people.
-            bufsize = 0
-        if bufsize == 1:
-            # apparently, line buffering only affects writes.  reads are only
-            # buffered if you call readline (directly or indirectly: iterating
-            # over a file will indirectly call readline).
-            self._flags |= self.FLAG_BUFFERED | self.FLAG_LINE_BUFFERED
-        elif bufsize > 1:
-            self._bufsize = bufsize
-            self._flags |= self.FLAG_BUFFERED
-            self._flags &= ~self.FLAG_LINE_BUFFERED
-        elif bufsize == 0:
-            # unbuffered
-            self._flags &= ~(self.FLAG_BUFFERED | self.FLAG_LINE_BUFFERED)
-
-        if ('r' in mode) or ('+' in mode):
-            self._flags |= self.FLAG_READ
-        if ('w' in mode) or ('+' in mode):
-            self._flags |= self.FLAG_WRITE
-        if ('a' in mode):
-            self._flags |= self.FLAG_WRITE | self.FLAG_APPEND
-            self._size = self._get_size()
-            self._pos = self._realpos = self._size
-        if ('b' in mode):
-            self._flags |= self.FLAG_BINARY
-        if ('U' in mode):
-            self._flags |= self.FLAG_UNIVERSAL_NEWLINE
-            # built-in file objects have this attribute to store which kinds of
-            # line terminations they've seen:
-            # <http://www.python.org/doc/current/lib/built-in-funcs.html>
-            self.newlines = None
-
-    def _write_all(self, data):
-        # the underlying stream may be something that does partial writes (like
-        # a socket).
-        while len(data) > 0:
-            count = self._write(data)
-            data = data[count:]
-            if self._flags & self.FLAG_APPEND:
-                self._size += count
-                self._pos = self._realpos = self._size
-            else:
-                self._pos += count
-                self._realpos += count
-        return None
-
-    def _record_newline(self, newline):
-        # silliness about tracking what kinds of newlines we've seen.
-        # i don't understand why it can be None, a string, or a tuple, instead
-        # of just always being a tuple, but we'll emulate that behavior anyway.
-        if not (self._flags & self.FLAG_UNIVERSAL_NEWLINE):
-            return
-        if self.newlines is None:
-            self.newlines = newline
-        elif (type(self.newlines) is str) and (self.newlines != newline):
-            self.newlines = (self.newlines, newline)
-        elif newline not in self.newlines:
-            self.newlines += (newline,)

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/32fef61a/tools/migration/paramiko/hostkeys.py
----------------------------------------------------------------------
diff --git a/tools/migration/paramiko/hostkeys.py b/tools/migration/paramiko/hostkeys.py
deleted file mode 100644
index 0786cda..0000000
--- a/tools/migration/paramiko/hostkeys.py
+++ /dev/null
@@ -1,313 +0,0 @@
-# Copyright (C) 2006-2007  Robey Pointer <ro...@gmail.com>
-# Copyright 2012 Citrix Systems, Inc. Licensed under the
-# Apache License, Version 2.0 (the "License"); you may not use this
-# file except in compliance with the License.  Citrix Systems, Inc.
-# reserves all rights not expressly granted by the License.
-# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# 
-# Automatically generated by addcopyright.py at 04/03/2012
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-
-"""
-L{HostKeys}
-"""
-
-import base64
-from Crypto.Hash import SHA, HMAC
-import UserDict
-
-from paramiko.common import *
-from paramiko.dsskey import DSSKey
-from paramiko.rsakey import RSAKey
-
-
-class HostKeyEntry:
-    """
-    Representation of a line in an OpenSSH-style "known hosts" file.
-    """
-
-    def __init__(self, hostnames=None, key=None):
-        self.valid = (hostnames is not None) and (key is not None)
-        self.hostnames = hostnames
-        self.key = key
-
-    def from_line(cls, line):
-        """
-        Parses the given line of text to find the names for the host,
-        the type of key, and the key data. The line is expected to be in the
-        format used by the openssh known_hosts file.
-
-        Lines are expected to not have leading or trailing whitespace.
-        We don't bother to check for comments or empty lines.  All of
-        that should be taken care of before sending the line to us.
-
-        @param line: a line from an OpenSSH known_hosts file
-        @type line: str
-        """
-        fields = line.split(' ')
-        if len(fields) < 3:
-            # Bad number of fields
-            return None
-        fields = fields[:3]
-
-        names, keytype, key = fields
-        names = names.split(',')
-
-        # Decide what kind of key we're looking at and create an object
-        # to hold it accordingly.
-        if keytype == 'ssh-rsa':
-            key = RSAKey(data=base64.decodestring(key))
-        elif keytype == 'ssh-dss':
-            key = DSSKey(data=base64.decodestring(key))
-        else:
-            return None
-
-        return cls(names, key)
-    from_line = classmethod(from_line)
-
-    def to_line(self):
-        """
-        Returns a string in OpenSSH known_hosts file format, or None if
-        the object is not in a valid state.  A trailing newline is
-        included.
-        """
-        if self.valid:
-            return '%s %s %s\n' % (','.join(self.hostnames), self.key.get_name(),
-                   self.key.get_base64())
-        return None
-
-    def __repr__(self):
-        return '<HostKeyEntry %r: %r>' % (self.hostnames, self.key)
-
-
-class HostKeys (UserDict.DictMixin):
-    """
-    Representation of an openssh-style "known hosts" file.  Host keys can be
-    read from one or more files, and then individual hosts can be looked up to
-    verify server keys during SSH negotiation.
-
-    A HostKeys object can be treated like a dict; any dict lookup is equivalent
-    to calling L{lookup}.
-
-    @since: 1.5.3
-    """
-
-    def __init__(self, filename=None):
-        """
-        Create a new HostKeys object, optionally loading keys from an openssh
-        style host-key file.
-
-        @param filename: filename to load host keys from, or C{None}
-        @type filename: str
-        """
-        # emulate a dict of { hostname: { keytype: PKey } }
-        self._entries = []
-        if filename is not None:
-            self.load(filename)
-
-    def add(self, hostname, keytype, key):
-        """
-        Add a host key entry to the table.  Any existing entry for a
-        C{(hostname, keytype)} pair will be replaced.
-
-        @param hostname: the hostname (or IP) to add
-        @type hostname: str
-        @param keytype: key type (C{"ssh-rsa"} or C{"ssh-dss"})
-        @type keytype: str
-        @param key: the key to add
-        @type key: L{PKey}
-        """
-        for e in self._entries:
-            if (hostname in e.hostnames) and (e.key.get_name() == keytype):
-                e.key = key
-                return
-        self._entries.append(HostKeyEntry([hostname], key))
-
-    def load(self, filename):
-        """
-        Read a file of known SSH host keys, in the format used by openssh.
-        This type of file unfortunately doesn't exist on Windows, but on
-        posix, it will usually be stored in
-        C{os.path.expanduser("~/.ssh/known_hosts")}.
-
-        If this method is called multiple times, the host keys are merged,
-        not cleared.  So multiple calls to C{load} will just call L{add},
-        replacing any existing entries and adding new ones.
-
-        @param filename: name of the file to read host keys from
-        @type filename: str
-
-        @raise IOError: if there was an error reading the file
-        """
-        f = open(filename, 'r')
-        for line in f:
-            line = line.strip()
-            if (len(line) == 0) or (line[0] == '#'):
-                continue
-            e = HostKeyEntry.from_line(line)
-            if e is not None:
-                self._entries.append(e)
-        f.close()
-
-    def save(self, filename):
-        """
-        Save host keys into a file, in the format used by openssh.  The order of
-        keys in the file will be preserved when possible (if these keys were
-        loaded from a file originally).  The single exception is that combined
-        lines will be split into individual key lines, which is arguably a bug.
-
-        @param filename: name of the file to write
-        @type filename: str
-
-        @raise IOError: if there was an error writing the file
-
-        @since: 1.6.1
-        """
-        f = open(filename, 'w')
-        for e in self._entries:
-            line = e.to_line()
-            if line:
-                f.write(line)
-        f.close()
-
-    def lookup(self, hostname):
-        """
-        Find a hostkey entry for a given hostname or IP.  If no entry is found,
-        C{None} is returned.  Otherwise a dictionary of keytype to key is
-        returned.  The keytype will be either C{"ssh-rsa"} or C{"ssh-dss"}.
-
-        @param hostname: the hostname (or IP) to lookup
-        @type hostname: str
-        @return: keys associated with this host (or C{None})
-        @rtype: dict(str, L{PKey})
-        """
-        class SubDict (UserDict.DictMixin):
-            def __init__(self, hostname, entries, hostkeys):
-                self._hostname = hostname
-                self._entries = entries
-                self._hostkeys = hostkeys
-
-            def __getitem__(self, key):
-                for e in self._entries:
-                    if e.key.get_name() == key:
-                        return e.key
-                raise KeyError(key)
-
-            def __setitem__(self, key, val):
-                for e in self._entries:
-                    if e.key is None:
-                        continue
-                    if e.key.get_name() == key:
-                        # replace
-                        e.key = val
-                        break
-                else:
-                    # add a new one
-                    e = HostKeyEntry([hostname], val)
-                    self._entries.append(e)
-                    self._hostkeys._entries.append(e)
-
-            def keys(self):
-                return [e.key.get_name() for e in self._entries if e.key is not None]
-
-        entries = []
-        for e in self._entries:
-            for h in e.hostnames:
-                if (h.startswith('|1|') and (self.hash_host(hostname, h) == h)) or (h == hostname):
-                    entries.append(e)
-        if len(entries) == 0:
-            return None
-        return SubDict(hostname, entries, self)
-
-    def check(self, hostname, key):
-        """
-        Return True if the given key is associated with the given hostname
-        in this dictionary.
-
-        @param hostname: hostname (or IP) of the SSH server
-        @type hostname: str
-        @param key: the key to check
-        @type key: L{PKey}
-        @return: C{True} if the key is associated with the hostname; C{False}
-            if not
-        @rtype: bool
-        """
-        k = self.lookup(hostname)
-        if k is None:
-            return False
-        host_key = k.get(key.get_name(), None)
-        if host_key is None:
-            return False
-        return str(host_key) == str(key)
-
-    def clear(self):
-        """
-        Remove all host keys from the dictionary.
-        """
-        self._entries = []
-
-    def __getitem__(self, key):
-        ret = self.lookup(key)
-        if ret is None:
-            raise KeyError(key)
-        return ret
-
-    def __setitem__(self, hostname, entry):
-        # don't use this please.
-        if len(entry) == 0:
-            self._entries.append(HostKeyEntry([hostname], None))
-            return
-        for key_type in entry.keys():
-            found = False
-            for e in self._entries:
-                if (hostname in e.hostnames) and (e.key.get_name() == key_type):
-                    # replace
-                    e.key = entry[key_type]
-                    found = True
-            if not found:
-                self._entries.append(HostKeyEntry([hostname], entry[key_type]))
-
-    def keys(self):
-        # python 2.4 sets would be nice here.
-        ret = []
-        for e in self._entries:
-            for h in e.hostnames:
-                if h not in ret:
-                    ret.append(h)
-        return ret
-
-    def values(self):
-        ret = []
-        for k in self.keys():
-            ret.append(self.lookup(k))
-        return ret
-
-    def hash_host(hostname, salt=None):
-        """
-        Return a "hashed" form of the hostname, as used by openssh when storing
-        hashed hostnames in the known_hosts file.
-
-        @param hostname: the hostname to hash
-        @type hostname: str
-        @param salt: optional salt to use when hashing (must be 20 bytes long)
-        @type salt: str
-        @return: the hashed hostname
-        @rtype: str
-        """
-        if salt is None:
-            salt = randpool.get_bytes(SHA.digest_size)
-        else:
-            if salt.startswith('|1|'):
-                salt = salt.split('|')[2]
-            salt = base64.decodestring(salt)
-        assert len(salt) == SHA.digest_size
-        hmac = HMAC.HMAC(salt, hostname, SHA).digest()
-        hostkey = '|1|%s|%s' % (base64.encodestring(salt), base64.encodestring(hmac))
-        return hostkey.replace('\n', '')
-    hash_host = staticmethod(hash_host)
-

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/32fef61a/tools/migration/paramiko/kex_gex.py
----------------------------------------------------------------------
diff --git a/tools/migration/paramiko/kex_gex.py b/tools/migration/paramiko/kex_gex.py
deleted file mode 100644
index 2aebcd2..0000000
--- a/tools/migration/paramiko/kex_gex.py
+++ /dev/null
@@ -1,241 +0,0 @@
-# Copyright (C) 2003-2007  Robey Pointer <ro...@gmail.com>
-# Copyright 2012 Citrix Systems, Inc. Licensed under the
-# Apache License, Version 2.0 (the "License"); you may not use this
-# file except in compliance with the License.  Citrix Systems, Inc.
-# reserves all rights not expressly granted by the License.
-# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# 
-# Automatically generated by addcopyright.py at 04/03/2012
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-
-"""
-Variant on L{KexGroup1 <paramiko.kex_group1.KexGroup1>} where the prime "p" and
-generator "g" are provided by the server.  A bit more work is required on the
-client side, and a B{lot} more on the server side.
-"""
-
-from Crypto.Hash import SHA
-from Crypto.Util import number
-
-from paramiko.common import *
-from paramiko import util
-from paramiko.message import Message
-from paramiko.ssh_exception import SSHException
-
-
-_MSG_KEXDH_GEX_REQUEST_OLD, _MSG_KEXDH_GEX_GROUP, _MSG_KEXDH_GEX_INIT, \
-    _MSG_KEXDH_GEX_REPLY, _MSG_KEXDH_GEX_REQUEST = range(30, 35)
-
-
-class KexGex (object):
-
-    name = 'diffie-hellman-group-exchange-sha1'
-    min_bits = 1024
-    max_bits = 8192
-    preferred_bits = 2048
-
-    def __init__(self, transport):
-        self.transport = transport
-        self.p = None
-        self.q = None
-        self.g = None
-        self.x = None
-        self.e = None
-        self.f = None
-        self.old_style = False
-
-    def start_kex(self, _test_old_style=False):
-        if self.transport.server_mode:
-            self.transport._expect_packet(_MSG_KEXDH_GEX_REQUEST, _MSG_KEXDH_GEX_REQUEST_OLD)
-            return
-        # request a bit range: we accept (min_bits) to (max_bits), but prefer
-        # (preferred_bits).  according to the spec, we shouldn't pull the
-        # minimum up above 1024.
-        m = Message()
-        if _test_old_style:
-            # only used for unit tests: we shouldn't ever send this
-            m.add_byte(chr(_MSG_KEXDH_GEX_REQUEST_OLD))
-            m.add_int(self.preferred_bits)
-            self.old_style = True
-        else:
-            m.add_byte(chr(_MSG_KEXDH_GEX_REQUEST))
-            m.add_int(self.min_bits)
-            m.add_int(self.preferred_bits)
-            m.add_int(self.max_bits)
-        self.transport._send_message(m)
-        self.transport._expect_packet(_MSG_KEXDH_GEX_GROUP)
-
-    def parse_next(self, ptype, m):
-        if ptype == _MSG_KEXDH_GEX_REQUEST:
-            return self._parse_kexdh_gex_request(m)
-        elif ptype == _MSG_KEXDH_GEX_GROUP:
-            return self._parse_kexdh_gex_group(m)
-        elif ptype == _MSG_KEXDH_GEX_INIT:
-            return self._parse_kexdh_gex_init(m)
-        elif ptype == _MSG_KEXDH_GEX_REPLY:
-            return self._parse_kexdh_gex_reply(m)
-        elif ptype == _MSG_KEXDH_GEX_REQUEST_OLD:
-            return self._parse_kexdh_gex_request_old(m)
-        raise SSHException('KexGex asked to handle packet type %d' % ptype)
-
-
-    ###  internals...
-
-    
-    def _generate_x(self):
-        # generate an "x" (1 < x < (p-1)/2).
-        q = (self.p - 1) // 2
-        qnorm = util.deflate_long(q, 0)
-        qhbyte = ord(qnorm[0])
-        bytes = len(qnorm)
-        qmask = 0xff
-        while not (qhbyte & 0x80):
-            qhbyte <<= 1
-            qmask >>= 1
-        while True:
-            self.transport.randpool.stir()
-            x_bytes = self.transport.randpool.get_bytes(bytes)
-            x_bytes = chr(ord(x_bytes[0]) & qmask) + x_bytes[1:]
-            x = util.inflate_long(x_bytes, 1)
-            if (x > 1) and (x < q):
-                break
-        self.x = x
-
-    def _parse_kexdh_gex_request(self, m):
-        minbits = m.get_int()
-        preferredbits = m.get_int()
-        maxbits = m.get_int()
-        # smoosh the user's preferred size into our own limits
-        if preferredbits > self.max_bits:
-            preferredbits = self.max_bits
-        if preferredbits < self.min_bits:
-            preferredbits = self.min_bits
-        # fix min/max if they're inconsistent.  technically, we could just pout
-        # and hang up, but there's no harm in giving them the benefit of the
-        # doubt and just picking a bitsize for them.
-        if minbits > preferredbits:
-            minbits = preferredbits
-        if maxbits < preferredbits:
-            maxbits = preferredbits
-        # now save a copy
-        self.min_bits = minbits
-        self.preferred_bits = preferredbits
-        self.max_bits = maxbits
-        # generate prime
-        pack = self.transport._get_modulus_pack()
-        if pack is None:
-            raise SSHException('Can\'t do server-side gex with no modulus pack')
-        self.transport._log(DEBUG, 'Picking p (%d <= %d <= %d bits)' % (minbits, preferredbits, maxbits))
-        self.g, self.p = pack.get_modulus(minbits, preferredbits, maxbits)
-        m = Message()
-        m.add_byte(chr(_MSG_KEXDH_GEX_GROUP))
-        m.add_mpint(self.p)
-        m.add_mpint(self.g)
-        self.transport._send_message(m)
-        self.transport._expect_packet(_MSG_KEXDH_GEX_INIT)
-
-    def _parse_kexdh_gex_request_old(self, m):
-        # same as above, but without min_bits or max_bits (used by older clients like putty)
-        self.preferred_bits = m.get_int()
-        # smoosh the user's preferred size into our own limits
-        if self.preferred_bits > self.max_bits:
-            self.preferred_bits = self.max_bits
-        if self.preferred_bits < self.min_bits:
-            self.preferred_bits = self.min_bits
-        # generate prime
-        pack = self.transport._get_modulus_pack()
-        if pack is None:
-            raise SSHException('Can\'t do server-side gex with no modulus pack')
-        self.transport._log(DEBUG, 'Picking p (~ %d bits)' % (self.preferred_bits,))
-        self.g, self.p = pack.get_modulus(self.min_bits, self.preferred_bits, self.max_bits)
-        m = Message()
-        m.add_byte(chr(_MSG_KEXDH_GEX_GROUP))
-        m.add_mpint(self.p)
-        m.add_mpint(self.g)
-        self.transport._send_message(m)
-        self.transport._expect_packet(_MSG_KEXDH_GEX_INIT)
-        self.old_style = True
-
-    def _parse_kexdh_gex_group(self, m):
-        self.p = m.get_mpint()
-        self.g = m.get_mpint()
-        # reject if p's bit length < 1024 or > 8192
-        bitlen = util.bit_length(self.p)
-        if (bitlen < 1024) or (bitlen > 8192):
-            raise SSHException('Server-generated gex p (don\'t ask) is out of range (%d bits)' % bitlen)
-        self.transport._log(DEBUG, 'Got server p (%d bits)' % bitlen)
-        self._generate_x()
-        # now compute e = g^x mod p
-        self.e = pow(self.g, self.x, self.p)
-        m = Message()
-        m.add_byte(chr(_MSG_KEXDH_GEX_INIT))
-        m.add_mpint(self.e)
-        self.transport._send_message(m)
-        self.transport._expect_packet(_MSG_KEXDH_GEX_REPLY)
-
-    def _parse_kexdh_gex_init(self, m):
-        self.e = m.get_mpint()
-        if (self.e < 1) or (self.e > self.p - 1):
-            raise SSHException('Client kex "e" is out of range')
-        self._generate_x()
-        self.f = pow(self.g, self.x, self.p)
-        K = pow(self.e, self.x, self.p)
-        key = str(self.transport.get_server_key())
-        # okay, build up the hash H of (V_C || V_S || I_C || I_S || K_S || min || n || max || p || g || e || f || K)
-        hm = Message()
-        hm.add(self.transport.remote_version, self.transport.local_version,
-               self.transport.remote_kex_init, self.transport.local_kex_init,
-               key)
-        if not self.old_style:
-            hm.add_int(self.min_bits)
-        hm.add_int(self.preferred_bits)
-        if not self.old_style:
-            hm.add_int(self.max_bits)
-        hm.add_mpint(self.p)
-        hm.add_mpint(self.g)
-        hm.add_mpint(self.e)
-        hm.add_mpint(self.f)
-        hm.add_mpint(K)
-        H = SHA.new(str(hm)).digest()
-        self.transport._set_K_H(K, H)
-        # sign it
-        sig = self.transport.get_server_key().sign_ssh_data(self.transport.randpool, H)
-        # send reply
-        m = Message()
-        m.add_byte(chr(_MSG_KEXDH_GEX_REPLY))
-        m.add_string(key)
-        m.add_mpint(self.f)
-        m.add_string(str(sig))
-        self.transport._send_message(m)
-        self.transport._activate_outbound()
-        
-    def _parse_kexdh_gex_reply(self, m):
-        host_key = m.get_string()
-        self.f = m.get_mpint()
-        sig = m.get_string()
-        if (self.f < 1) or (self.f > self.p - 1):
-            raise SSHException('Server kex "f" is out of range')
-        K = pow(self.f, self.x, self.p)
-        # okay, build up the hash H of (V_C || V_S || I_C || I_S || K_S || min || n || max || p || g || e || f || K)
-        hm = Message()
-        hm.add(self.transport.local_version, self.transport.remote_version,
-               self.transport.local_kex_init, self.transport.remote_kex_init,
-               host_key)
-        if not self.old_style:
-            hm.add_int(self.min_bits)
-        hm.add_int(self.preferred_bits)
-        if not self.old_style:
-            hm.add_int(self.max_bits)
-        hm.add_mpint(self.p)
-        hm.add_mpint(self.g)
-        hm.add_mpint(self.e)
-        hm.add_mpint(self.f)
-        hm.add_mpint(K)
-        self.transport._set_K_H(K, SHA.new(str(hm)).digest())
-        self.transport._verify_key(host_key, sig)
-        self.transport._activate_outbound()

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/32fef61a/tools/migration/paramiko/kex_group1.py
----------------------------------------------------------------------
diff --git a/tools/migration/paramiko/kex_group1.py b/tools/migration/paramiko/kex_group1.py
deleted file mode 100644
index 5922939..0000000
--- a/tools/migration/paramiko/kex_group1.py
+++ /dev/null
@@ -1,133 +0,0 @@
-# Copyright (C) 2003-2007  Robey Pointer <ro...@gmail.com>
-# Copyright 2012 Citrix Systems, Inc. Licensed under the
-# Apache License, Version 2.0 (the "License"); you may not use this
-# file except in compliance with the License.  Citrix Systems, Inc.
-# reserves all rights not expressly granted by the License.
-# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# 
-# Automatically generated by addcopyright.py at 04/03/2012
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-
-"""
-Standard SSH key exchange ("kex" if you wanna sound cool).  Diffie-Hellman of
-1024 bit key halves, using a known "p" prime and "g" generator.
-"""
-
-from Crypto.Hash import SHA
-
-from paramiko.common import *
-from paramiko import util
-from paramiko.message import Message
-from paramiko.ssh_exception import SSHException
-
-
-_MSG_KEXDH_INIT, _MSG_KEXDH_REPLY = range(30, 32)
-
-# draft-ietf-secsh-transport-09.txt, page 17
-P = 0xFFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFFL
-G = 2
-
-
-class KexGroup1(object):
-
-    name = 'diffie-hellman-group1-sha1'
-
-    def __init__(self, transport):
-        self.transport = transport
-        self.x = 0L
-        self.e = 0L
-        self.f = 0L
-
-    def start_kex(self):
-        self._generate_x()
-        if self.transport.server_mode:
-            # compute f = g^x mod p, but don't send it yet
-            self.f = pow(G, self.x, P)
-            self.transport._expect_packet(_MSG_KEXDH_INIT)
-            return
-        # compute e = g^x mod p (where g=2), and send it
-        self.e = pow(G, self.x, P)
-        m = Message()
-        m.add_byte(chr(_MSG_KEXDH_INIT))
-        m.add_mpint(self.e)
-        self.transport._send_message(m)
-        self.transport._expect_packet(_MSG_KEXDH_REPLY)
-
-    def parse_next(self, ptype, m):
-        if self.transport.server_mode and (ptype == _MSG_KEXDH_INIT):
-            return self._parse_kexdh_init(m)
-        elif not self.transport.server_mode and (ptype == _MSG_KEXDH_REPLY):
-            return self._parse_kexdh_reply(m)
-        raise SSHException('KexGroup1 asked to handle packet type %d' % ptype)
-    
-
-    ###  internals...
-
-
-    def _generate_x(self):
-        # generate an "x" (1 < x < q), where q is (p-1)/2.
-        # p is a 128-byte (1024-bit) number, where the first 64 bits are 1. 
-        # therefore q can be approximated as a 2^1023.  we drop the subset of
-        # potential x where the first 63 bits are 1, because some of those will be
-        # larger than q (but this is a tiny tiny subset of potential x).
-        while 1:
-            self.transport.randpool.stir()
-            x_bytes = self.transport.randpool.get_bytes(128)
-            x_bytes = chr(ord(x_bytes[0]) & 0x7f) + x_bytes[1:]
-            if (x_bytes[:8] != '\x7F\xFF\xFF\xFF\xFF\xFF\xFF\xFF') and \
-                   (x_bytes[:8] != '\x00\x00\x00\x00\x00\x00\x00\x00'):
-                break
-        self.x = util.inflate_long(x_bytes)
-
-    def _parse_kexdh_reply(self, m):
-        # client mode
-        host_key = m.get_string()
-        self.f = m.get_mpint()
-        if (self.f < 1) or (self.f > P - 1):
-            raise SSHException('Server kex "f" is out of range')
-        sig = m.get_string()
-        K = pow(self.f, self.x, P)
-        # okay, build up the hash H of (V_C || V_S || I_C || I_S || K_S || e || f || K)
-        hm = Message()
-        hm.add(self.transport.local_version, self.transport.remote_version,
-               self.transport.local_kex_init, self.transport.remote_kex_init)
-        hm.add_string(host_key)
-        hm.add_mpint(self.e)
-        hm.add_mpint(self.f)
-        hm.add_mpint(K)
-        self.transport._set_K_H(K, SHA.new(str(hm)).digest())
-        self.transport._verify_key(host_key, sig)
-        self.transport._activate_outbound()
-
-    def _parse_kexdh_init(self, m):
-        # server mode
-        self.e = m.get_mpint()
-        if (self.e < 1) or (self.e > P - 1):
-            raise SSHException('Client kex "e" is out of range')
-        K = pow(self.e, self.x, P)
-        key = str(self.transport.get_server_key())
-        # okay, build up the hash H of (V_C || V_S || I_C || I_S || K_S || e || f || K)
-        hm = Message()
-        hm.add(self.transport.remote_version, self.transport.local_version,
-               self.transport.remote_kex_init, self.transport.local_kex_init)
-        hm.add_string(key)
-        hm.add_mpint(self.e)
-        hm.add_mpint(self.f)
-        hm.add_mpint(K)
-        H = SHA.new(str(hm)).digest()
-        self.transport._set_K_H(K, H)
-        # sign it
-        sig = self.transport.get_server_key().sign_ssh_data(self.transport.randpool, H)
-        # send reply
-        m = Message()
-        m.add_byte(chr(_MSG_KEXDH_REPLY))
-        m.add_string(key)
-        m.add_mpint(self.f)
-        m.add_string(str(sig))
-        self.transport._send_message(m)
-        self.transport._activate_outbound()

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/32fef61a/tools/migration/paramiko/logging22.py
----------------------------------------------------------------------
diff --git a/tools/migration/paramiko/logging22.py b/tools/migration/paramiko/logging22.py
deleted file mode 100644
index 9b9c142..0000000
--- a/tools/migration/paramiko/logging22.py
+++ /dev/null
@@ -1,63 +0,0 @@
-# Copyright (C) 2003-2007  Robey Pointer <ro...@gmail.com>
-# Copyright 2012 Citrix Systems, Inc. Licensed under the
-# Apache License, Version 2.0 (the "License"); you may not use this
-# file except in compliance with the License.  Citrix Systems, Inc.
-# reserves all rights not expressly granted by the License.
-# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# 
-# Automatically generated by addcopyright.py at 04/03/2012
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-
-"""
-Stub out logging on python < 2.3.
-"""
-
-
-DEBUG = 10
-INFO = 20
-WARNING = 30
-ERROR = 40
-CRITICAL = 50
-
-
-def getLogger(name):
-    return _logger
-
-
-class logger (object):
-    def __init__(self):
-        self.handlers = [ ]
-        self.level = ERROR
-
-    def setLevel(self, level):
-        self.level = level
-
-    def addHandler(self, h):
-        self.handlers.append(h)
-
-    def addFilter(self, filter):
-        pass
-        
-    def log(self, level, text):
-        if level >= self.level:
-            for h in self.handlers:
-                h.f.write(text + '\n')
-                h.f.flush()
-
-class StreamHandler (object):
-    def __init__(self, f):
-        self.f = f
-
-    def setFormatter(self, f):
-        pass
-
-class Formatter (object):
-    def __init__(self, x, y):
-        pass
-
-_logger = logger()

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/32fef61a/tools/migration/paramiko/message.py
----------------------------------------------------------------------
diff --git a/tools/migration/paramiko/message.py b/tools/migration/paramiko/message.py
deleted file mode 100644
index d6a8e57..0000000
--- a/tools/migration/paramiko/message.py
+++ /dev/null
@@ -1,298 +0,0 @@
-# Copyright (C) 2003-2007  Robey Pointer <ro...@gmail.com>
-# Copyright 2012 Citrix Systems, Inc. Licensed under the
-# Apache License, Version 2.0 (the "License"); you may not use this
-# file except in compliance with the License.  Citrix Systems, Inc.
-# reserves all rights not expressly granted by the License.
-# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# 
-# Automatically generated by addcopyright.py at 04/03/2012
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-
-"""
-Implementation of an SSH2 "message".
-"""
-
-import struct
-import cStringIO
-
-from paramiko import util
-
-
-class Message (object):
-    """
-    An SSH2 I{Message} is a stream of bytes that encodes some combination of
-    strings, integers, bools, and infinite-precision integers (known in python
-    as I{long}s).  This class builds or breaks down such a byte stream.
-    
-    Normally you don't need to deal with anything this low-level, but it's
-    exposed for people implementing custom extensions, or features that
-    paramiko doesn't support yet.
-    """
-
-    def __init__(self, content=None):
-        """
-        Create a new SSH2 Message.
-
-        @param content: the byte stream to use as the Message content (passed
-            in only when decomposing a Message).
-        @type content: string
-        """
-        if content != None:
-            self.packet = cStringIO.StringIO(content)
-        else:
-            self.packet = cStringIO.StringIO()
-
-    def __str__(self):
-        """
-        Return the byte stream content of this Message, as a string.
-
-        @return: the contents of this Message.
-        @rtype: string
-        """
-        return self.packet.getvalue()
-
-    def __repr__(self):
-        """
-        Returns a string representation of this object, for debugging.
-
-        @rtype: string
-        """
-        return 'paramiko.Message(' + repr(self.packet.getvalue()) + ')'
-
-    def rewind(self):
-        """
-        Rewind the message to the beginning as if no items had been parsed
-        out of it yet.
-        """
-        self.packet.seek(0)
-
-    def get_remainder(self):
-        """
-        Return the bytes of this Message that haven't already been parsed and
-        returned.
-
-        @return: a string of the bytes not parsed yet.
-        @rtype: string
-        """
-        position = self.packet.tell()
-        remainder = self.packet.read()
-        self.packet.seek(position)
-        return remainder
-
-    def get_so_far(self):
-        """
-        Returns the bytes of this Message that have been parsed and returned.
-        The string passed into a Message's constructor can be regenerated by
-        concatenating C{get_so_far} and L{get_remainder}.
-
-        @return: a string of the bytes parsed so far.
-        @rtype: string
-        """
-        position = self.packet.tell()
-        self.rewind()
-        return self.packet.read(position)
-
-    def get_bytes(self, n):
-        """
-        Return the next C{n} bytes of the Message, without decomposing into
-        an int, string, etc.  Just the raw bytes are returned.
-
-        @return: a string of the next C{n} bytes of the Message, or a string
-            of C{n} zero bytes, if there aren't C{n} bytes remaining.
-        @rtype: string
-        """
-        b = self.packet.read(n)
-        if len(b) < n:
-            return b + '\x00' * (n - len(b))
-        return b
-
-    def get_byte(self):
-        """
-        Return the next byte of the Message, without decomposing it.  This
-        is equivalent to L{get_bytes(1)<get_bytes>}.
-
-        @return: the next byte of the Message, or C{'\000'} if there aren't
-            any bytes remaining.
-        @rtype: string
-        """
-        return self.get_bytes(1)
-
-    def get_boolean(self):
-        """
-        Fetch a boolean from the stream.
-
-        @return: C{True} or C{False} (from the Message).
-        @rtype: bool
-        """
-        b = self.get_bytes(1)
-        return b != '\x00'
-
-    def get_int(self):
-        """
-        Fetch an int from the stream.
-
-        @return: a 32-bit unsigned integer.
-        @rtype: int
-        """
-        return struct.unpack('>I', self.get_bytes(4))[0]
-
-    def get_int64(self):
-        """
-        Fetch a 64-bit int from the stream.
-
-        @return: a 64-bit unsigned integer.
-        @rtype: long
-        """
-        return struct.unpack('>Q', self.get_bytes(8))[0]
-
-    def get_mpint(self):
-        """
-        Fetch a long int (mpint) from the stream.
-
-        @return: an arbitrary-length integer.
-        @rtype: long
-        """
-        return util.inflate_long(self.get_string())
-
-    def get_string(self):
-        """
-        Fetch a string from the stream.  This could be a byte string and may
-        contain unprintable characters.  (It's not unheard of for a string to
-        contain another byte-stream Message.)
-
-        @return: a string.
-        @rtype: string
-        """
-        return self.get_bytes(self.get_int())
-
-    def get_list(self):
-        """
-        Fetch a list of strings from the stream.  These are trivially encoded
-        as comma-separated values in a string.
-
-        @return: a list of strings.
-        @rtype: list of strings
-        """
-        return self.get_string().split(',')
-
-    def add_bytes(self, b):
-        """
-        Write bytes to the stream, without any formatting.
-        
-        @param b: bytes to add
-        @type b: str
-        """
-        self.packet.write(b)
-        return self
-
-    def add_byte(self, b):
-        """
-        Write a single byte to the stream, without any formatting.
-        
-        @param b: byte to add
-        @type b: str
-        """
-        self.packet.write(b)
-        return self
-
-    def add_boolean(self, b):
-        """
-        Add a boolean value to the stream.
-        
-        @param b: boolean value to add
-        @type b: bool
-        """
-        if b:
-            self.add_byte('\x01')
-        else:
-            self.add_byte('\x00')
-        return self
-            
-    def add_int(self, n):
-        """
-        Add an integer to the stream.
-        
-        @param n: integer to add
-        @type n: int
-        """
-        self.packet.write(struct.pack('>I', n))
-        return self
-
-    def add_int64(self, n):
-        """
-        Add a 64-bit int to the stream.
-
-        @param n: long int to add
-        @type n: long
-        """
-        self.packet.write(struct.pack('>Q', n))
-        return self
-
-    def add_mpint(self, z):
-        """
-        Add a long int to the stream, encoded as an infinite-precision
-        integer.  This method only works on positive numbers.
-        
-        @param z: long int to add
-        @type z: long
-        """
-        self.add_string(util.deflate_long(z))
-        return self
-
-    def add_string(self, s):
-        """
-        Add a string to the stream.
-        
-        @param s: string to add
-        @type s: str
-        """
-        self.add_int(len(s))
-        self.packet.write(s)
-        return self
-
-    def add_list(self, l):
-        """
-        Add a list of strings to the stream.  They are encoded identically to
-        a single string of values separated by commas.  (Yes, really, that's
-        how SSH2 does it.)
-        
-        @param l: list of strings to add
-        @type l: list(str)
-        """
-        self.add_string(','.join(l))
-        return self
-        
-    def _add(self, i):
-        if type(i) is str:
-            return self.add_string(i)
-        elif type(i) is int:
-            return self.add_int(i)
-        elif type(i) is long:
-            if i > 0xffffffffL:
-                return self.add_mpint(i)
-            else:
-                return self.add_int(i)
-        elif type(i) is bool:
-            return self.add_boolean(i)
-        elif type(i) is list:
-            return self.add_list(i)
-        else:
-            raise Exception('Unknown type')
-
-    def add(self, *seq):
-        """
-        Add a sequence of items to the stream.  The values are encoded based
-        on their type: str, int, bool, list, or long.
-        
-        @param seq: the sequence of items
-        @type seq: sequence
-        
-        @bug: longs are encoded non-deterministically.  Don't use this method.
-        """
-        for item in seq:
-            self._add(item)

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/32fef61a/tools/migration/paramiko/packet.py
----------------------------------------------------------------------
diff --git a/tools/migration/paramiko/packet.py b/tools/migration/paramiko/packet.py
deleted file mode 100644
index 899ba57..0000000
--- a/tools/migration/paramiko/packet.py
+++ /dev/null
@@ -1,485 +0,0 @@
-# Copyright (C) 2003-2007  Robey Pointer <ro...@gmail.com>
-# Copyright 2012 Citrix Systems, Inc. Licensed under the
-# Apache License, Version 2.0 (the "License"); you may not use this
-# file except in compliance with the License.  Citrix Systems, Inc.
-# reserves all rights not expressly granted by the License.
-# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# 
-# Automatically generated by addcopyright.py at 04/03/2012
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-
-"""
-Packetizer.
-"""
-
-import errno
-import select
-import socket
-import struct
-import threading
-import time
-
-from paramiko.common import *
-from paramiko import util
-from paramiko.ssh_exception import SSHException
-from paramiko.message import Message
-
-
-got_r_hmac = False
-try:
-    import r_hmac
-    got_r_hmac = True
-except ImportError:
-    pass
-def compute_hmac(key, message, digest_class):
-    if got_r_hmac:
-        return r_hmac.HMAC(key, message, digest_class).digest()
-    from Crypto.Hash import HMAC
-    return HMAC.HMAC(key, message, digest_class).digest()
-
-
-class NeedRekeyException (Exception):
-    pass
-
-
-class Packetizer (object):
-    """
-    Implementation of the base SSH packet protocol.
-    """
-
-    # READ the secsh RFC's before raising these values.  if anything,
-    # they should probably be lower.
-    REKEY_PACKETS = pow(2, 30)
-    REKEY_BYTES = pow(2, 30)
-    
-    def __init__(self, socket):
-        self.__socket = socket
-        self.__logger = None
-        self.__closed = False
-        self.__dump_packets = False
-        self.__need_rekey = False
-        self.__init_count = 0
-        self.__remainder = ''
-        
-        # used for noticing when to re-key:
-        self.__sent_bytes = 0
-        self.__sent_packets = 0
-        self.__received_bytes = 0
-        self.__received_packets = 0
-        self.__received_packets_overflow = 0
-        
-        # current inbound/outbound ciphering:
-        self.__block_size_out = 8
-        self.__block_size_in = 8
-        self.__mac_size_out = 0
-        self.__mac_size_in = 0
-        self.__block_engine_out = None
-        self.__block_engine_in = None
-        self.__mac_engine_out = None
-        self.__mac_engine_in = None
-        self.__mac_key_out = ''
-        self.__mac_key_in = ''
-        self.__compress_engine_out = None
-        self.__compress_engine_in = None
-        self.__sequence_number_out = 0L
-        self.__sequence_number_in = 0L
-
-        # lock around outbound writes (packet computation)
-        self.__write_lock = threading.RLock()
-
-        # keepalives:
-        self.__keepalive_interval = 0
-        self.__keepalive_last = time.time()
-        self.__keepalive_callback = None
-        
-    def set_log(self, log):
-        """
-        Set the python log object to use for logging.
-        """
-        self.__logger = log
-    
-    def set_outbound_cipher(self, block_engine, block_size, mac_engine, mac_size, mac_key):
-        """
-        Switch outbound data cipher.
-        """
-        self.__block_engine_out = block_engine
-        self.__block_size_out = block_size
-        self.__mac_engine_out = mac_engine
-        self.__mac_size_out = mac_size
-        self.__mac_key_out = mac_key
-        self.__sent_bytes = 0
-        self.__sent_packets = 0
-        # wait until the reset happens in both directions before clearing rekey flag
-        self.__init_count |= 1
-        if self.__init_count == 3:
-            self.__init_count = 0
-            self.__need_rekey = False
-    
-    def set_inbound_cipher(self, block_engine, block_size, mac_engine, mac_size, mac_key):
-        """
-        Switch inbound data cipher.
-        """
-        self.__block_engine_in = block_engine
-        self.__block_size_in = block_size
-        self.__mac_engine_in = mac_engine
-        self.__mac_size_in = mac_size
-        self.__mac_key_in = mac_key
-        self.__received_bytes = 0
-        self.__received_packets = 0
-        self.__received_packets_overflow = 0
-        # wait until the reset happens in both directions before clearing rekey flag
-        self.__init_count |= 2
-        if self.__init_count == 3:
-            self.__init_count = 0
-            self.__need_rekey = False
-    
-    def set_outbound_compressor(self, compressor):
-        self.__compress_engine_out = compressor
-    
-    def set_inbound_compressor(self, compressor):
-        self.__compress_engine_in = compressor
-        
-    def close(self):
-        self.__closed = True
-        self.__socket.close()
-
-    def set_hexdump(self, hexdump):
-        self.__dump_packets = hexdump
-        
-    def get_hexdump(self):
-        return self.__dump_packets
-    
-    def get_mac_size_in(self):
-        return self.__mac_size_in
-    
-    def get_mac_size_out(self):
-        return self.__mac_size_out
-
-    def need_rekey(self):
-        """
-        Returns C{True} if a new set of keys needs to be negotiated.  This
-        will be triggered during a packet read or write, so it should be
-        checked after every read or write, or at least after every few.
-        
-        @return: C{True} if a new set of keys needs to be negotiated
-        """
-        return self.__need_rekey
-    
-    def set_keepalive(self, interval, callback):
-        """
-        Turn on/off the callback keepalive.  If C{interval} seconds pass with
-        no data read from or written to the socket, the callback will be
-        executed and the timer will be reset.
-        """
-        self.__keepalive_interval = interval
-        self.__keepalive_callback = callback
-        self.__keepalive_last = time.time()
-    
-    def read_all(self, n, check_rekey=False):
-        """
-        Read as close to N bytes as possible, blocking as long as necessary.
-        
-        @param n: number of bytes to read
-        @type n: int
-        @return: the data read
-        @rtype: str
-        @raise EOFError: if the socket was closed before all the bytes could
-            be read
-        """
-        out = ''
-        # handle over-reading from reading the banner line
-        if len(self.__remainder) > 0:
-            out = self.__remainder[:n]
-            self.__remainder = self.__remainder[n:]
-            n -= len(out)
-        if PY22:
-            return self._py22_read_all(n, out)
-        while n > 0:
-            got_timeout = False
-            try:
-                x = self.__socket.recv(n)
-                if len(x) == 0:
-                    raise EOFError()
-                out += x
-                n -= len(x)
-            except socket.timeout:
-                got_timeout = True
-            except socket.error, e:
-                # on Linux, sometimes instead of socket.timeout, we get
-                # EAGAIN.  this is a bug in recent (> 2.6.9) kernels but
-                # we need to work around it.
-                if (type(e.args) is tuple) and (len(e.args) > 0) and (e.args[0] == errno.EAGAIN):
-                    got_timeout = True
-                elif (type(e.args) is tuple) and (len(e.args) > 0) and (e.args[0] == errno.EINTR):
-                    # syscall interrupted; try again
-                    pass
-                elif self.__closed:
-                    raise EOFError()
-                else:
-                    raise
-            if got_timeout:
-                if self.__closed:
-                    raise EOFError()
-                if check_rekey and (len(out) == 0) and self.__need_rekey:
-                    raise NeedRekeyException()
-                self._check_keepalive()
-        return out
-
-    def write_all(self, out):
-        self.__keepalive_last = time.time()
-        while len(out) > 0:
-            got_timeout = False
-            try:
-                n = self.__socket.send(out)
-            except socket.timeout:
-                got_timeout = True
-            except socket.error, e:
-                if (type(e.args) is tuple) and (len(e.args) > 0) and (e.args[0] == errno.EAGAIN):
-                    got_timeout = True
-                elif (type(e.args) is tuple) and (len(e.args) > 0) and (e.args[0] == errno.EINTR):
-                    # syscall interrupted; try again
-                    pass
-                else:
-                    n = -1
-            except Exception:
-                # could be: (32, 'Broken pipe')
-                n = -1
-            if got_timeout:
-                n = 0
-                if self.__closed:
-                    n = -1
-            if n < 0:
-                raise EOFError()
-            if n == len(out):
-                break
-            out = out[n:]
-        return
-        
-    def readline(self, timeout):
-        """
-        Read a line from the socket.  We assume no data is pending after the
-        line, so it's okay to attempt large reads.
-        """
-        buf = self.__remainder
-        while not '\n' in buf:
-            buf += self._read_timeout(timeout)
-        n = buf.index('\n')
-        self.__remainder = buf[n+1:]
-        buf = buf[:n]
-        if (len(buf) > 0) and (buf[-1] == '\r'):
-            buf = buf[:-1]
-        return buf
-        
-    def send_message(self, data):
-        """
-        Write a block of data using the current cipher, as an SSH block.
-        """
-        # encrypt this sucka
-        data = str(data)
-        cmd = ord(data[0])
-        if cmd in MSG_NAMES:
-            cmd_name = MSG_NAMES[cmd]
-        else:
-            cmd_name = '$%x' % cmd
-        orig_len = len(data)
-        self.__write_lock.acquire()
-        try:
-            if self.__compress_engine_out is not None:
-                data = self.__compress_engine_out(data)
-            packet = self._build_packet(data)
-            if self.__dump_packets:
-                self._log(DEBUG, 'Write packet <%s>, length %d' % (cmd_name, orig_len))
-                self._log(DEBUG, util.format_binary(packet, 'OUT: '))
-            if self.__block_engine_out != None:
-                out = self.__block_engine_out.encrypt(packet)
-            else:
-                out = packet
-            # + mac
-            if self.__block_engine_out != None:
-                payload = struct.pack('>I', self.__sequence_number_out) + packet
-                out += compute_hmac(self.__mac_key_out, payload, self.__mac_engine_out)[:self.__mac_size_out]
-            self.__sequence_number_out = (self.__sequence_number_out + 1) & 0xffffffffL
-            self.write_all(out)
-
-            self.__sent_bytes += len(out)
-            self.__sent_packets += 1
-            if (self.__sent_packets % 100) == 0:
-                # stirring the randpool takes 30ms on my ibook!!
-                randpool.stir()
-            if ((self.__sent_packets >= self.REKEY_PACKETS) or (self.__sent_bytes >= self.REKEY_BYTES)) \
-                   and not self.__need_rekey:
-                # only ask once for rekeying
-                self._log(DEBUG, 'Rekeying (hit %d packets, %d bytes sent)' %
-                          (self.__sent_packets, self.__sent_bytes))
-                self.__received_packets_overflow = 0
-                self._trigger_rekey()
-        finally:
-            self.__write_lock.release()
-
-    def read_message(self):
-        """
-        Only one thread should ever be in this function (no other locking is
-        done).
-        
-        @raise SSHException: if the packet is mangled
-        @raise NeedRekeyException: if the transport should rekey
-        """
-        header = self.read_all(self.__block_size_in, check_rekey=True)
-        if self.__block_engine_in != None:
-            header = self.__block_engine_in.decrypt(header)
-        if self.__dump_packets:
-            self._log(DEBUG, util.format_binary(header, 'IN: '));
-        packet_size = struct.unpack('>I', header[:4])[0]
-        # leftover contains decrypted bytes from the first block (after the length field)
-        leftover = header[4:]
-        if (packet_size - len(leftover)) % self.__block_size_in != 0:
-            raise SSHException('Invalid packet blocking')
-        buf = self.read_all(packet_size + self.__mac_size_in - len(leftover))
-        packet = buf[:packet_size - len(leftover)]
-        post_packet = buf[packet_size - len(leftover):]
-        if self.__block_engine_in != None:
-            packet = self.__block_engine_in.decrypt(packet)
-        if self.__dump_packets:
-            self._log(DEBUG, util.format_binary(packet, 'IN: '));
-        packet = leftover + packet
-
-        if self.__mac_size_in > 0:
-            mac = post_packet[:self.__mac_size_in]
-            mac_payload = struct.pack('>II', self.__sequence_number_in, packet_size) + packet
-            my_mac = compute_hmac(self.__mac_key_in, mac_payload, self.__mac_engine_in)[:self.__mac_size_in]
-            if my_mac != mac:
-                raise SSHException('Mismatched MAC')
-        padding = ord(packet[0])
-        payload = packet[1:packet_size - padding]
-        randpool.add_event()
-        if self.__dump_packets:
-            self._log(DEBUG, 'Got payload (%d bytes, %d padding)' % (packet_size, padding))
-
-        if self.__compress_engine_in is not None:
-            payload = self.__compress_engine_in(payload)
-
-        msg = Message(payload[1:])
-        msg.seqno = self.__sequence_number_in
-        self.__sequence_number_in = (self.__sequence_number_in + 1) & 0xffffffffL
-        
-        # check for rekey
-        self.__received_bytes += packet_size + self.__mac_size_in + 4
-        self.__received_packets += 1
-        if self.__need_rekey:
-            # we've asked to rekey -- give them 20 packets to comply before
-            # dropping the connection
-            self.__received_packets_overflow += 1
-            if self.__received_packets_overflow >= 20:
-                raise SSHException('Remote transport is ignoring rekey requests')
-        elif (self.__received_packets >= self.REKEY_PACKETS) or \
-             (self.__received_bytes >= self.REKEY_BYTES):
-            # only ask once for rekeying
-            self._log(DEBUG, 'Rekeying (hit %d packets, %d bytes received)' %
-                      (self.__received_packets, self.__received_bytes))
-            self.__received_packets_overflow = 0
-            self._trigger_rekey()
-
-        cmd = ord(payload[0])
-        if cmd in MSG_NAMES:
-            cmd_name = MSG_NAMES[cmd]
-        else:
-            cmd_name = '$%x' % cmd
-        if self.__dump_packets:
-            self._log(DEBUG, 'Read packet <%s>, length %d' % (cmd_name, len(payload)))
-        return cmd, msg
-
-
-    ##########  protected
-    
-    
-    def _log(self, level, msg):
-        if self.__logger is None:
-            return
-        if issubclass(type(msg), list):
-            for m in msg:
-                self.__logger.log(level, m)
-        else:
-            self.__logger.log(level, msg)
-
-    def _check_keepalive(self):
-        if (not self.__keepalive_interval) or (not self.__block_engine_out) or \
-            self.__need_rekey:
-            # wait till we're encrypting, and not in the middle of rekeying
-            return
-        now = time.time()
-        if now > self.__keepalive_last + self.__keepalive_interval:
-            self.__keepalive_callback()
-            self.__keepalive_last = now
-    
-    def _py22_read_all(self, n, out):
-        while n > 0:
-            r, w, e = select.select([self.__socket], [], [], 0.1)
-            if self.__socket not in r:
-                if self.__closed:
-                    raise EOFError()
-                self._check_keepalive()
-            else:
-                x = self.__socket.recv(n)
-                if len(x) == 0:
-                    raise EOFError()
-                out += x
-                n -= len(x)
-        return out
-
-    def _py22_read_timeout(self, timeout):
-        start = time.time()
-        while True:
-            r, w, e = select.select([self.__socket], [], [], 0.1)
-            if self.__socket in r:
-                x = self.__socket.recv(1)
-                if len(x) == 0:
-                    raise EOFError()
-                break
-            if self.__closed:
-                raise EOFError()
-            now = time.time()
-            if now - start >= timeout:
-                raise socket.timeout()
-        return x
-
-    def _read_timeout(self, timeout):
-        if PY22:
-            return self._py22_read_timeout(timeout)
-        start = time.time()
-        while True:
-            try:
-                x = self.__socket.recv(128)
-                if len(x) == 0:
-                    raise EOFError()
-                break
-            except socket.timeout:
-                pass
-            if self.__closed:
-                raise EOFError()
-            now = time.time()
-            if now - start >= timeout:
-                raise socket.timeout()
-        return x
-
-    def _build_packet(self, payload):
-        # pad up at least 4 bytes, to nearest block-size (usually 8)
-        bsize = self.__block_size_out
-        padding = 3 + bsize - ((len(payload) + 8) % bsize)
-        packet = struct.pack('>IB', len(payload) + padding + 1, padding)
-        packet += payload
-        if self.__block_engine_out is not None:
-            packet += randpool.get_bytes(padding)
-        else:
-            # cute trick i caught openssh doing: if we're not encrypting,
-            # don't waste random bytes for the padding
-            packet += (chr(0) * padding)
-        return packet
-
-    def _trigger_rekey(self):
-        # outside code should check for this flag
-        self.__need_rekey = True

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/32fef61a/tools/migration/paramiko/pipe.py
----------------------------------------------------------------------
diff --git a/tools/migration/paramiko/pipe.py b/tools/migration/paramiko/pipe.py
deleted file mode 100644
index 9be8ca9..0000000
--- a/tools/migration/paramiko/pipe.py
+++ /dev/null
@@ -1,144 +0,0 @@
-# Copyright (C) 2003-2007  Robey Pointer <ro...@gmail.com>
-# Copyright 2012 Citrix Systems, Inc. Licensed under the
-# Apache License, Version 2.0 (the "License"); you may not use this
-# file except in compliance with the License.  Citrix Systems, Inc.
-# reserves all rights not expressly granted by the License.
-# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# 
-# Automatically generated by addcopyright.py at 04/03/2012
-# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-
-"""
-Abstraction of a one-way pipe where the read end can be used in select().
-Normally this is trivial, but Windows makes it nearly impossible.
-
-The pipe acts like an Event, which can be set or cleared. When set, the pipe
-will trigger as readable in select().
-"""
-
-import sys
-import os
-import socket
-
-
-def make_pipe ():
-    if sys.platform[:3] != 'win':
-        p = PosixPipe()
-    else:
-        p = WindowsPipe()
-    return p
-
-
-class PosixPipe (object):
-    def __init__ (self):
-        self._rfd, self._wfd = os.pipe()
-        self._set = False
-        self._forever = False
-        self._closed = False
-    
-    def close (self):
-        os.close(self._rfd)
-        os.close(self._wfd)
-        # used for unit tests:
-        self._closed = True
-    
-    def fileno (self):
-        return self._rfd
-
-    def clear (self):
-        if not self._set or self._forever:
-            return
-        os.read(self._rfd, 1)
-        self._set = False
-    
-    def set (self):
-        if self._set or self._closed:
-            return
-        self._set = True
-        os.write(self._wfd, '*')
-    
-    def set_forever (self):
-        self._forever = True
-        self.set()
-
-
-class WindowsPipe (object):
-    """
-    On Windows, only an OS-level "WinSock" may be used in select(), but reads
-    and writes must be to the actual socket object.
-    """
-    def __init__ (self):
-        serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-        serv.bind(('127.0.0.1', 0))
-        serv.listen(1)
-    
-        # need to save sockets in _rsock/_wsock so they don't get closed
-        self._rsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-        self._rsock.connect(('127.0.0.1', serv.getsockname()[1]))
-    
-        self._wsock, addr = serv.accept()
-        serv.close()
-        self._set = False
-        self._forever = False
-        self._closed = False
-    
-    def close (self):
-        self._rsock.close()
-        self._wsock.close()
-        # used for unit tests:
-        self._closed = True
-    
-    def fileno (self):
-        return self._rsock.fileno()
-
-    def clear (self):
-        if not self._set or self._forever:
-            return
-        self._rsock.recv(1)
-        self._set = False
-    
-    def set (self):
-        if self._set or self._closed:
-            return
-        self._set = True
-        self._wsock.send('*')
-
-    def set_forever (self):
-        self._forever = True
-        self.set()
-
-
-class OrPipe (object):
-    def __init__(self, pipe):
-        self._set = False
-        self._partner = None
-        self._pipe = pipe
-    
-    def set(self):
-        self._set = True
-        if not self._partner._set:
-            self._pipe.set()
-    
-    def clear(self):
-        self._set = False
-        if not self._partner._set:
-            self._pipe.clear()
-
-
-def make_or_pipe(pipe):
-    """
-    wraps a pipe into two pipe-like objects which are "or"d together to
-    affect the real pipe. if either returned pipe is set, the wrapped pipe
-    is set. when both are cleared, the wrapped pipe is cleared.
-    """
-    p1 = OrPipe(pipe)
-    p2 = OrPipe(pipe)
-    p1._partner = p2
-    p2._partner = p1
-    return p1, p2
-