MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / newGuestsCreateLXCCmd

Function newGuestsCreateLXCCmd

internal/cli/guests.go:927–969  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

925}
926
927func newGuestsCreateLXCCmd() *cobra.Command {
928 cmd := &cobra.Command{
929 Use: "lxc",
930 Short: "Create a new LXC container",
931 Long: "Create a new LXC container on a Proxmox node.",
932 Example: ` # Basic container
933 pvetui guests create lxc --node pve --hostname myct --rootfs-storage local-zfs \
934 --template local:vztmpl/debian-12-standard_12.7-1_amd64.tar.zst
935
936 # Using package name (auto-resolves to latest version)
937 pvetui guests create lxc --node pve --hostname myct --rootfs-storage local-zfs \
938 --template debian-12-standard
939
940 # Custom resources, privileged, start after create
941 pvetui guests create lxc --node pve --hostname myct --rootfs-storage local-zfs \
942 --template debian-12-standard --memory 2048 --cores 2 --unprivileged=false --start`,
943 RunE: runGuestsCreateLXC,
944 }
945
946 cmd.Flags().String("node", "", "Target node name (required)")
947 cmd.Flags().String("hostname", "", "Container hostname (required)")
948 cmd.Flags().Int("vmid", 0, "Container ID (auto-assigned if omitted)")
949 cmd.Flags().Int("memory", 512, "Memory in MB")
950 cmd.Flags().Int("swap", 512, "Swap in MB (0 to disable)")
951 cmd.Flags().Int("cores", 1, "Number of CPU cores")
952 cmd.Flags().String("rootfs-storage", "", "Storage for root filesystem (required)")
953 cmd.Flags().Int("rootfs-size", 8, "Root filesystem size in GB")
954 cmd.Flags().String("template", "", "OS template volid or package name (required)")
955 cmd.Flags().String("bridge", "vmbr0", "Network bridge")
956 cmd.Flags().Bool("unprivileged", true, "Run as unprivileged container")
957 cmd.Flags().Bool("nesting", true, "Enable nesting (allows Docker inside container)")
958 cmd.Flags().Bool("start", false, "Start container after creation")
959 addNoWaitFlag(cmd)
960
961 _ = cmd.MarkFlagRequired("node")
962 _ = cmd.MarkFlagRequired("hostname")
963 _ = cmd.MarkFlagRequired("rootfs-storage")
964 _ = cmd.MarkFlagRequired("template")
965
966 cmd.ValidArgsFunction = cobra.NoFileCompletions
967
968 return cmd
969}
970
971func runGuestsCreateLXC(cmd *cobra.Command, _ []string) error {
972 session, err := initCLISession(cmd)

Callers 1

newGuestsCreateCmdFunction · 0.85

Calls 2

addNoWaitFlagFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected