paramiko/paramiko — pull request #201 by Kami (2013-08-18 00:49:22+00:00)
Title: Fix a bug with resolving a hostname in the LazyFqdn class

## Problem

(I originally spotted this bug while using fabric with `env.use_ssh_config` option)

Currently `LazyFqdn` class explodes if `AddressFamily` is specified because it references an in-existent `host` variable while trying to resolve a hostname.

## Traceback

```bash
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/fabric/main.py", line 743, in main
*args, **kwargs
File "/usr/local/lib/python2.7/dist-packages/fabric/tasks.py", line 368, in execute
multiprocessing
File "/usr/local/lib/python2.7/dist-packages/fabric/tasks.py", line 211, in _execute
local_env = to_dict(host)
File "/usr/local/lib/python2.7/dist-packages/fabric/network.py", line 282, in to_dict
user, host, port = normalize(host_string)
File "/usr/local/lib/python2.7/dist-packages/fabric/network.py", line 261, in normalize
conf = ssh_config(host_string)
File "/usr/local/lib/python2.7/dist-packages/fabric/network.py", line 162, in ssh_config
return env._ssh_config.lookup(host)
File "/usr/local/lib/python2.7/dist-packages/paramiko/config.py", line 175, in lookup
ret = self._expand_variables(ret, hostname)
File "/usr/local/lib/python2.7/dist-packages/paramiko/config.py", line 253, in _expand_variables
replace(find, str(replace))
File "/usr/local/lib/python2.7/dist-packages/paramiko/config.py", line 59, in __str__
results = socket.getaddrinfo(host,
NameError: global name 'host' is not defined
```
## Proposed Solution

This pull request fixes it to correctly use `hostname` entry from the `self.config` dictionary.

Here is an example config dictionary so you can see `hostname` entry is present:

```python
{'identityfile': ['/home/foobar/.ssh/id_rsa_foo1'], 'hostname': 'foo', 'forwardagent': 'yes', 'controlpath': '~/.ssh/master-%r@%h:%p', 'controlmaster': 'auto', 'addressfamily': 'inet'}
```

I couldn't find any existing tests for the `SSHConfig` class, but I'll work on adding some for this issue (and depending on how much time I have, also for other `SSHConfig` stuff) in the next couple of days.