github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/apiserver/facades/controller/instancepoller/state.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package instancepoller 5 6 import ( 7 "github.com/juju/juju/core/instance" 8 "github.com/juju/juju/core/status" 9 "github.com/juju/juju/network" 10 "github.com/juju/juju/state" 11 ) 12 13 // StateMachine represents a machine from state package. 14 type StateMachine interface { 15 state.Entity 16 17 Id() string 18 InstanceId() (instance.Id, error) 19 ProviderAddresses() []network.Address 20 SetProviderAddresses(...network.Address) error 21 InstanceStatus() (status.StatusInfo, error) 22 SetInstanceStatus(status.StatusInfo) error 23 SetStatus(status.StatusInfo) error 24 String() string 25 Refresh() error 26 Life() state.Life 27 Status() (status.StatusInfo, error) 28 IsManual() (bool, error) 29 } 30 31 type StateInterface interface { 32 state.ModelAccessor 33 state.ModelMachinesWatcher 34 state.EntityFinder 35 36 Machine(id string) (StateMachine, error) 37 } 38 39 // TODO - CAAS(ericclaudejones): This should contain state alone, model will be 40 // removed once all relevant methods are moved from state to model. 41 type stateShim struct { 42 *state.State 43 *state.Model 44 } 45 46 func (s stateShim) Machine(id string) (StateMachine, error) { 47 return s.State.Machine(id) 48 } 49 50 var getState = func(st *state.State, m *state.Model) StateInterface { 51 return stateShim{st, m} 52 }