diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-04-26 15:28:15 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-26 15:28:15 -0700 |
commit | fe3acddcbe02cfa258170707791bd096dc909022 (patch) | |
tree | 9a68b96d5f85adcc67189e97e1c788786c20b32c /cmd/podman/system_migrate.go | |
parent | b6e2cbad0a4581a8fe4954ff4a9202461a526781 (diff) | |
parent | f49e0c19ede56b1cc6b1d44ea9ba8b336cd22658 (diff) | |
download | podman-fe3acddcbe02cfa258170707791bd096dc909022.tar.gz podman-fe3acddcbe02cfa258170707791bd096dc909022.tar.bz2 podman-fe3acddcbe02cfa258170707791bd096dc909022.zip |
Merge pull request #2950 from giuseppe/podman-system-migrate
system: add new subcommand "migrate"
Diffstat (limited to 'cmd/podman/system_migrate.go')
-rw-r--r-- | cmd/podman/system_migrate.go | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/cmd/podman/system_migrate.go b/cmd/podman/system_migrate.go new file mode 100644 index 000000000..4a0afcfad --- /dev/null +++ b/cmd/podman/system_migrate.go @@ -0,0 +1,50 @@ +package main + +import ( + "github.com/containers/libpod/cmd/podman/cliconfig" + "github.com/containers/libpod/cmd/podman/libpodruntime" + "github.com/pkg/errors" + "github.com/spf13/cobra" +) + +var ( + migrateCommand cliconfig.SystemMigrateValues + migrateDescription = ` + podman system migrate + + Migrate existing containers to a new version of Podman. +` + + _migrateCommand = &cobra.Command{ + Use: "migrate", + Args: noSubArgs, + Short: "Migrate containers", + Long: migrateDescription, + RunE: func(cmd *cobra.Command, args []string) error { + migrateCommand.InputArgs = args + migrateCommand.GlobalFlags = MainGlobalOpts + return migrateCmd(&migrateCommand) + }, + } +) + +func init() { + migrateCommand.Command = _migrateCommand + migrateCommand.SetHelpTemplate(HelpTemplate()) + migrateCommand.SetUsageTemplate(UsageTemplate()) +} + +func migrateCmd(c *cliconfig.SystemMigrateValues) error { + // We need to pass one extra option to NewRuntime. + // This will inform the OCI runtime to start a migrate. + // That's controlled by the last argument to GetRuntime. + r, err := libpodruntime.GetRuntimeMigrate(getContext(), &c.PodmanCommand) + if err != nil { + return errors.Wrapf(err, "error migrating containers") + } + if err := r.Shutdown(false); err != nil { + return err + } + + return nil +} |