-
Notifications
You must be signed in to change notification settings - Fork 14
/
migrate.go
52 lines (48 loc) · 1.09 KB
/
migrate.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
44
45
46
47
48
49
50
51
52
package main
import (
"github.com/crosbymichael/boss/api/v1"
"github.com/urfave/cli"
)
var migrateCommand = cli.Command{
Name: "migrate",
Usage: "migrate a container from one agent to another",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "live",
Usage: "enable live checkpoint(criu must be installed)",
},
cli.BoolFlag{
Name: "stop",
Usage: "stop the container after a successful checkpoint",
},
cli.BoolFlag{
Name: "delete",
Usage: "delete the container on the local agent after a successful checkpoint",
},
cli.StringFlag{
Name: "ref",
Usage: "ref name of the created checkpoint",
},
cli.StringFlag{
Name: "to",
Usage: "destination agent",
},
},
Action: func(clix *cli.Context) error {
ctx := Context()
agent, err := Agent(clix)
if err != nil {
return err
}
defer agent.Close()
_, err = agent.Migrate(ctx, &v1.MigrateRequest{
ID: clix.Args().First(),
Ref: clix.String("ref"),
Stop: clix.Bool("stop"),
Delete: clix.Bool("delete"),
To: clix.String("to"),
Live: clix.Bool("live"),
})
return err
},
}