github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/api/diskmanager/diskmanager.go (about) 1 // Copyright 2014 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package diskmanager 5 6 import ( 7 "gopkg.in/juju/names.v2" 8 9 "github.com/juju/juju/api/base" 10 "github.com/juju/juju/apiserver/params" 11 "github.com/juju/juju/storage" 12 ) 13 14 const diskManagerFacade = "DiskManager" 15 16 // State provides access to a diskmanager worker's view of the state. 17 type State struct { 18 facade base.FacadeCaller 19 tag names.MachineTag 20 } 21 22 // NewState creates a new client-side DiskManager facade. 23 func NewState(caller base.APICaller, authTag names.MachineTag) *State { 24 return &State{ 25 base.NewFacadeCaller(caller, diskManagerFacade), 26 authTag, 27 } 28 } 29 30 // SetMachineBlockDevices sets the block devices attached to the machine 31 // identified by the authenticated machine tag. 32 func (st *State) SetMachineBlockDevices(devices []storage.BlockDevice) error { 33 args := params.SetMachineBlockDevices{ 34 MachineBlockDevices: []params.MachineBlockDevices{{ 35 Machine: st.tag.String(), 36 BlockDevices: devices, 37 }}, 38 } 39 var results params.ErrorResults 40 err := st.facade.FacadeCall("SetMachineBlockDevices", args, &results) 41 if err != nil { 42 return err 43 } 44 return results.OneError() 45 }