"os"
"git.arvados.org/arvados.git/lib/cloud"
+ "git.arvados.org/arvados.git/lib/cmd"
"git.arvados.org/arvados.git/lib/config"
"git.arvados.org/arvados.git/lib/dispatchcloud"
"git.arvados.org/arvados.git/sdk/go/arvados"
"git.arvados.org/arvados.git/sdk/go/ctxlog"
- "golang.org/x/crypto/ssh"
)
var Command command
destroyExisting := flags.Bool("destroy-existing", false, "Destroy any existing instances tagged with our InstanceSetID, instead of erroring out")
shellCommand := flags.String("command", "", "Run an interactive shell command on the test instance when it boots")
pauseBeforeDestroy := flags.Bool("pause-before-destroy", false, "Prompt and wait before destroying the test instance")
- err = flags.Parse(args)
- if err == flag.ErrHelp {
- err = nil
- return 0
- } else if err != nil {
- return 2
- }
-
- if len(flags.Args()) != 0 {
- flags.Usage()
- return 2
+ if ok, code := cmd.ParseFlags(flags, prog, args, "", stderr); !ok {
+ return code
}
logger := ctxlog.New(stderr, "text", "info")
defer func() {
if err != nil {
return 1
}
- key, err := ssh.ParsePrivateKey([]byte(cluster.Containers.DispatchPrivateKey))
+ key, err := config.LoadSSHKey(cluster.Containers.DispatchPrivateKey)
if err != nil {
- err = fmt.Errorf("error parsing configured Containers.DispatchPrivateKey: %s", err)
+ err = fmt.Errorf("error loading Containers.DispatchPrivateKey: %s", err)
return 1
}
driver, ok := dispatchcloud.Drivers[cluster.Containers.CloudVMs.Driver]
tagKeyPrefix := cluster.Containers.CloudVMs.TagKeyPrefix
tags[tagKeyPrefix+"CloudTestPID"] = fmt.Sprintf("%d", os.Getpid())
if !(&tester{
- Logger: logger,
- Tags: tags,
- TagKeyPrefix: tagKeyPrefix,
- SetID: cloud.InstanceSetID(*instanceSetID),
- DestroyExisting: *destroyExisting,
- ProbeInterval: cluster.Containers.CloudVMs.ProbeInterval.Duration(),
- SyncInterval: cluster.Containers.CloudVMs.SyncInterval.Duration(),
- TimeoutBooting: cluster.Containers.CloudVMs.TimeoutBooting.Duration(),
- Driver: driver,
- DriverParameters: cluster.Containers.CloudVMs.DriverParameters,
- ImageID: cloud.ImageID(*imageID),
- InstanceType: it,
- SSHKey: key,
- SSHPort: cluster.Containers.CloudVMs.SSHPort,
- BootProbeCommand: cluster.Containers.CloudVMs.BootProbeCommand,
- ShellCommand: *shellCommand,
+ Logger: logger,
+ Tags: tags,
+ TagKeyPrefix: tagKeyPrefix,
+ SetID: cloud.InstanceSetID(*instanceSetID),
+ DestroyExisting: *destroyExisting,
+ ProbeInterval: cluster.Containers.CloudVMs.ProbeInterval.Duration(),
+ SyncInterval: cluster.Containers.CloudVMs.SyncInterval.Duration(),
+ TimeoutBooting: cluster.Containers.CloudVMs.TimeoutBooting.Duration(),
+ Driver: driver,
+ DriverParameters: cluster.Containers.CloudVMs.DriverParameters,
+ ImageID: cloud.ImageID(*imageID),
+ InstanceType: it,
+ SSHKey: key,
+ SSHPort: cluster.Containers.CloudVMs.SSHPort,
+ BootProbeCommand: cluster.Containers.CloudVMs.BootProbeCommand,
+ InstanceInitCommand: cloud.InitCommand(cluster.Containers.CloudVMs.InstanceInitCommand),
+ ShellCommand: *shellCommand,
PauseBeforeDestroy: func() {
if *pauseBeforeDestroy {
logger.Info("waiting for operator to press Enter")