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