mirror of
https://github.com/containers/podman.git
synced 2025-11-29 09:37:38 +08:00
For Podman 6, we still have providers and will continue to have a default provider for each platform. But where a platform has multiple providers, we want users to be able to cross provider boudnaries imposed in Podman 4/5. The key change is to look up virtual machines by name, as before, but to then also iterate all possible providers. As of this PR, init will still only create with the default provider, but a subsequent PR will introdouce an provider override. I also removed the "--all-providers" command line option on `podman machine ls` because it no longer makes sense. And I marked the all provider list test to be skipped. Signed-off-by: Brent Baude <bbaude@redhat.com>
41 lines
1.0 KiB
Go
41 lines
1.0 KiB
Go
//go:build amd64 || arm64
|
|
|
|
package os
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/containers/podman/v6/pkg/machine"
|
|
"github.com/containers/podman/v6/pkg/machine/shim"
|
|
"github.com/containers/podman/v6/pkg/machine/vmconfigs"
|
|
)
|
|
|
|
// MachineOS manages machine OS's from outside the machine.
|
|
type MachineOS struct {
|
|
Args []string
|
|
VM *vmconfigs.MachineConfig
|
|
Provider vmconfigs.VMProvider
|
|
VMName string
|
|
Restart bool
|
|
}
|
|
|
|
// Apply applies the image by sshing into the machine and running apply from inside the VM.
|
|
func (m *MachineOS) Apply(image string, _ ApplyOptions) error {
|
|
args := []string{"podman", "machine", "os", "apply", image}
|
|
|
|
if err := machine.LocalhostSSH(m.VM.SSH.RemoteUsername, m.VM.SSH.IdentityPath, m.VMName, m.VM.SSH.Port, args); err != nil {
|
|
return err
|
|
}
|
|
|
|
if m.Restart {
|
|
if err := shim.Stop(m.VM, m.Provider, false); err != nil {
|
|
return err
|
|
}
|
|
if err := shim.Start(m.VM, m.Provider, machine.StartOptions{NoInfo: true}); err != nil {
|
|
return err
|
|
}
|
|
fmt.Printf("Machine %q restarted successfully\n", m.VMName)
|
|
}
|
|
return nil
|
|
}
|