MCPcopy Create free account
hub / github.com/linuxkit/linuxkit / runVCenterCmd

Function runVCenterCmd

src/cmd/linuxkit/run_vcenter.go:39–173  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

37}
38
39func runVCenterCmd() *cobra.Command {
40 var (
41 vCenterURL string
42 dcName string
43 dsName string
44 networkName string
45 vSphereHost string
46 vmFolder string
47 vmPath string
48 persistent string
49 poweron bool
50 guestIP bool
51 )
52
53 cmd := &cobra.Command{
54 Use: "vcenter",
55 Short: "launch a VCenter instance using an existing image",
56 Long: `Launch a VCenter instance using an existing image.
57 'path' specifies the full path of an image to run.
58 `,
59 Args: cobra.ExactArgs(1),
60 Example: "linuxkit run vcenter [options] path",
61 RunE: func(cmd *cobra.Command, args []string) error {
62 imagePath := args[0]
63 if guestIP && !poweron {
64 return errors.New("the waitForIP flag can not be used without the powerOn flag")
65 }
66 // Ensure an iso has been passed to the vCenter run Command
67 if strings.HasSuffix(vmPath, ".iso") {
68 // Allow alternative names for new virtual machines being created in vCenter
69 if vmFolder == "" {
70 vmFolder = strings.TrimSuffix(path.Base(vmPath), ".iso")
71 }
72 } else {
73 return fmt.Errorf("please pass an \".iso\" file as the path")
74 }
75
76 ctx, cancel := context.WithCancel(context.Background())
77 defer cancel()
78 mem64 := int64(mem)
79 newVM := vmConfig{
80 vCenterURL: &vCenterURL,
81 dcName: &dcName,
82 dsName: &dsName,
83 networkName: &networkName,
84 vSphereHost: &vSphereHost,
85 vmFolder: &vmFolder,
86 path: &vmPath,
87 persistent: &persistent,
88 mem: &mem64,
89 vCpus: &cpus,
90 poweron: &poweron,
91 guestIP: &guestIP,
92 }
93 newVM.path = &imagePath
94
95 // Connect to VMware vCenter and return the default and found values needed for a new VM
96 c, dss, folders, hs, net, rp := vCenterConnect(ctx, newVM)

Callers 1

runCmdFunction · 0.85

Calls 7

vCenterConnectFunction · 0.85
addISOFunction · 0.85
getDiskSizeMBFunction · 0.85
addVMDKFunction · 0.85
addNICFunction · 0.85
powerOnVMFunction · 0.85
getVMToolsIPFunction · 0.85

Tested by

no test coverage detected