github.com/mhilton/juju-juju@v0.0.0-20150901100907-a94dd2c73455/provider/joyent/instance.go (about) 1 // Copyright 2013 Joyent Inc. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package joyent 5 6 import ( 7 "github.com/joyent/gosdc/cloudapi" 8 9 "github.com/juju/juju/instance" 10 "github.com/juju/juju/network" 11 ) 12 13 type joyentInstance struct { 14 machine *cloudapi.Machine 15 env *joyentEnviron 16 } 17 18 var _ instance.Instance = (*joyentInstance)(nil) 19 20 func (inst *joyentInstance) Id() instance.Id { 21 return instance.Id(inst.machine.Id) 22 } 23 24 func (inst *joyentInstance) Status() string { 25 return inst.machine.State 26 } 27 28 func (inst *joyentInstance) Refresh() error { 29 return nil 30 } 31 32 func (inst *joyentInstance) Addresses() ([]network.Address, error) { 33 addresses := make([]network.Address, 0, len(inst.machine.IPs)) 34 for _, ip := range inst.machine.IPs { 35 address := network.NewAddress(ip) 36 if ip == inst.machine.PrimaryIP { 37 address.Scope = network.ScopePublic 38 } else { 39 address.Scope = network.ScopeCloudLocal 40 } 41 addresses = append(addresses, address) 42 } 43 44 return addresses, nil 45 }