Fixed lp:1397376 - api-endpoints behaves as expected

This fixes http://pad.lv/1397376/ by changing how API
server addresses are handled by the CLI/API clients.

Major changes:
 * cmd/juju: api-endpoints - added help text, added --all argument,
 vastly improved tests.
 * network.SortAddresses and network.SortHostPorts changed to apply
 consistent ordering with regards to scope and prefer-ipv6 flag);
 * network.ResolveOrDropHostnames introduced;
 * network package refactored to split relevent entities in their own files/suites;
 * dropped obsolete stuff like most of what's related to network.Port.
 * cmd/juju: bootstrap command - endpoints caching post-bootstrap fixed;
 * juju/api: changed the way API endpoints are cached in the .jenv file.
 * environs/configstore: added APIEndpoint.Hostnames - optional list
 of cached API hostnames/IPs (before resolving), so DNS resolution
 won't be needed if hostnames haven't changed.
 * Added *lots* of extra tests for all changes.

What's changed? Before caching the API endpoints for use by the CLI (either just
 after bootstrap or with api-endpoints --refresh):
 - All known endpoints are sorted in the following order:
 -- public addresses
 -- hostnames (only localhost as the others are resolved, see below)
 -- cloud-local addresses
 -- link-local addresses (which are then filtered out as unusable)
 -- machine-local addresses
 - Then any hostnames, except localhost (because of the local provider
 and also dummy provider to simplify testing), are resolved using the
 local resolver and (if successful) inserted in the same order in the
 list of endpoints. Unresolvable hostnames are dropped. This means the
 .jenv file won't contain any hostnames (except for maybe localhost), as
 this seems to be the expected behavior - scripts prefer IPs, not hosts.
 - Any duplicates are removed.
 - prefer-ipv6 flag is respected (i.e. when true IPv6 addresses of the
 same scope come before IPv4 ones).
 - The last endpoint used to successfully connect to the API server is
 inserted at the top of the list.

Minor changes:
 * network.Address, HostPort, Port, PortRange now all have String() and
 GoString() methods; tests improved.
 * envtesting.PatchAttemptStrategies() changed to include the (now exported)
 AddressesRefreshAttempt used while waiting for bootstrap instance addresses.
 * A few changes to log messages to fix typos or improve
 readability (easier to test/debug some deeply nested operations).

RB link: http://reviews.vapour.ws/r/611/