github.com/cloud-green/juju@v0.0.0-20151002100041-a00291338d3d/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) Addresses() ([]network.Address, error) { 29 addresses := make([]network.Address, 0, len(inst.machine.IPs)) 30 for _, ip := range inst.machine.IPs { 31 address := network.NewAddress(ip) 32 if ip == inst.machine.PrimaryIP { 33 address.Scope = network.ScopePublic 34 } else { 35 address.Scope = network.ScopeCloudLocal 36 } 37 addresses = append(addresses, address) 38 } 39 40 return addresses, nil 41 }