github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/api/client/action/run.go (about) 1 // Copyright 2014 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package action 5 6 import ( 7 "time" 8 9 "github.com/juju/errors" 10 11 "github.com/juju/juju/rpc/params" 12 ) 13 14 // RunOnAllMachines runs the command on all the machines with the specified 15 // timeout. 16 func (c *Client) RunOnAllMachines(commands string, timeout time.Duration) (EnqueuedActions, error) { 17 var results params.EnqueuedActions 18 args := params.RunParams{Commands: commands, Timeout: timeout} 19 err := c.facade.FacadeCall("RunOnAllMachines", args, &results) 20 if err != nil { 21 return EnqueuedActions{}, errors.Trace(err) 22 } 23 return unmarshallEnqueuedActions(results) 24 } 25 26 // Run the Commands specified on the machines identified through the ids 27 // provided in the machines, applications and units slices. 28 func (c *Client) Run(run RunParams) (EnqueuedActions, error) { 29 args := params.RunParams{ 30 Commands: run.Commands, 31 Timeout: run.Timeout, 32 Machines: run.Machines, 33 Applications: run.Applications, 34 Units: run.Units, 35 WorkloadContext: run.WorkloadContext, 36 } 37 var results params.EnqueuedActions 38 err := c.facade.FacadeCall("Run", args, &results) 39 if err != nil { 40 return EnqueuedActions{}, errors.Trace(err) 41 } 42 return unmarshallEnqueuedActions(results) 43 }