-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21175 from baude/consolidateIgnitionReadySocket
consolidate ignition ready socket unit
- Loading branch information
Showing
4 changed files
with
43 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package ignition | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
|
||
"github.com/containers/podman/v4/pkg/machine/define" | ||
) | ||
|
||
// ReadyUnitOpts are options for creating the ready unit that reports back to podman | ||
// when the system is booted | ||
type ReadyUnitOpts struct { | ||
Port uint64 | ||
} | ||
|
||
// CreateReadyUnitFile makes a the ready unit to report back to the host that the system is running | ||
func CreateReadyUnitFile(provider define.VMType, opts *ReadyUnitOpts) (string, error) { | ||
readyUnit := DefaultReadyUnitFile() | ||
switch provider { | ||
case define.QemuVirt: | ||
readyUnit.Add("Unit", "Requires", "dev-virtio\\x2dports-vport1p1.device") | ||
readyUnit.Add("Unit", "After", "systemd-user-sessions.service") | ||
readyUnit.Add("Service", "ExecStart", "/bin/sh -c '/usr/bin/echo Ready >/dev/vport1p1'") | ||
case define.AppleHvVirt: | ||
readyUnit.Add("Unit", "Requires", "dev-virtio\\x2dports-vsock.device") | ||
readyUnit.Add("Service", "ExecStart", "/bin/sh -c '/usr/bin/echo Ready | socat - VSOCK-CONNECT:2:1025'") | ||
case define.HyperVVirt: | ||
if opts == nil || opts.Port == 0 { | ||
return "", errors.New("no port provided for hyperv ready unit") | ||
} | ||
readyUnit.Add("Unit", "After", "systemd-user-sessions.service") | ||
readyUnit.Add("Service", "ExecStart", fmt.Sprintf("/bin/sh -c '/usr/bin/echo Ready | socat - VSOCK-CONNECT:2:%d'", opts.Port)) | ||
case define.WSLVirt: // WSL does not use ignition | ||
return "", nil | ||
default: | ||
return "", fmt.Errorf("unable to generate ready unit for provider %q", provider.String()) | ||
} | ||
return readyUnit.ToString() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters