~dave-cheney/juju-core/153-fix-release-tools-script

« back to all changes in this revision

Viewing changes to instance/address.go

  • Committer: Tarmac
  • Author(s): Andrew Wilkins
  • Date: 2013-08-30 01:48:39 UTC
  • mfrom: (1628.11.22 juju-add-machine)
  • Revision ID: tarmac-20130830014839-infsllif52ywy6yq
[r=axwalk] Update add-machine for manual provisioning

juju add-machine is updated to use a new package,
environs/manual, to manually provision tools and
a machine agent to an existing machine.

When a manually provisioned machine is destroyed
via juju destroy-machine, the machine agent will
detect its termination and remove its upstart
configuration file. There is currently no cleanup
of the data or log directories; this will be done
in a follow-up pending discussion.

When the machine goes to Dead, a provisioner will
remove the machine from state just like any other
machine.

TODO: destroy-environment will currently leak
manually provisioned machines. A follow-up will
address this by requiring users to individually
destroy-machine before destroy-environment will
proceed. Alternatively (or perhaps additionally),
destroy-environment may take a flag to automatically
do this.

https://codereview.appspot.com/12831043/

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
        return Address{value, addresstype, "", NetworkUnknown}
60
60
}
61
61
 
 
62
// HostAddresses looks up the IP addresses of the specified
 
63
// host, and translates them into instance.Address values.
 
64
func HostAddresses(host string) ([]Address, error) {
 
65
        ipaddrs, err := net.LookupIP(host)
 
66
        if err != nil {
 
67
                return nil, err
 
68
        }
 
69
        addrs := make([]Address, len(ipaddrs))
 
70
        for i, ipaddr := range ipaddrs {
 
71
                switch len(ipaddr) {
 
72
                case 4:
 
73
                        addrs[i].Type = Ipv4Address
 
74
                        addrs[i].Value = ipaddr.String()
 
75
                case 16:
 
76
                        addrs[i].Type = Ipv6Address
 
77
                        addrs[i].Value = ipaddr.String()
 
78
                }
 
79
        }
 
80
        return addrs, err
 
81
}
 
82
 
62
83
// SelectPublicAddress picks one address from a slice that would
63
84
// be appropriate to display as a publicly accessible endpoint.
64
85
// If there are no suitable addresses, the empty string is returned.