From ffef020a09f002fd89fd6aec62d374cc2849f7ec Mon Sep 17 00:00:00 2001 From: Stefan Bourlon Date: Fri, 7 Jul 2017 14:32:14 -0700 Subject: [PATCH] Backend vCenter: add the datacenter parameter Signed-off-by: Stefan Bourlon --- src/cmd/linuxkit/push_vcenter.go | 1 + src/cmd/linuxkit/run_vcenter.go | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cmd/linuxkit/push_vcenter.go b/src/cmd/linuxkit/push_vcenter.go index 8c1e633b5..3b58598f8 100644 --- a/src/cmd/linuxkit/push_vcenter.go +++ b/src/cmd/linuxkit/push_vcenter.go @@ -32,6 +32,7 @@ func pushVCenter(args []string) { } newVM.vCenterURL = flags.String("url", os.Getenv("VCURL"), "URL of VMware vCenter in the format of https://username:password@VCaddress/sdk") + newVM.dcName = flags.String("datacenter", os.Getenv("VCDATACENTER"), "The name of the DataCenter to host the image") newVM.dsName = flags.String("datastore", os.Getenv("VCDATASTORE"), "The name of the DataStore to host the image") newVM.networkName = flags.String("network", os.Getenv("VCNETWORK"), "The network label the VM will use") newVM.vSphereHost = flags.String("hostname", os.Getenv("VCHOST"), "The server that will host the image") diff --git a/src/cmd/linuxkit/run_vcenter.go b/src/cmd/linuxkit/run_vcenter.go index 78051567b..c44a08362 100644 --- a/src/cmd/linuxkit/run_vcenter.go +++ b/src/cmd/linuxkit/run_vcenter.go @@ -20,6 +20,7 @@ import ( type vmConfig struct { vCenterURL *string + dcName *string dsName *string networkName *string vSphereHost *string @@ -44,6 +45,7 @@ func runVcenter(args []string) { invoked := filepath.Base(os.Args[0]) newVM.vCenterURL = flags.String("url", os.Getenv("VCURL"), "URL of VMware vCenter in the format of https://username:password@VCaddress/sdk") + newVM.dcName = flags.String("datacenter", os.Getenv("VCDATACENTER"), "The name of the Datacenter to host the VM") newVM.dsName = flags.String("datastore", os.Getenv("VCDATASTORE"), "The name of the DataStore to host the VM") newVM.networkName = flags.String("network", os.Getenv("VCNETWORK"), "The network label the VM will use") newVM.vSphereHost = flags.String("hostname", os.Getenv("VCHOST"), "The server that will run the VM") @@ -178,7 +180,7 @@ func vCenterConnect(ctx context.Context, newVM vmConfig) (*govmomi.Client, *obje f := find.NewFinder(c.Client, true) // Find one and only datacenter, not sure how VMware linked mode will work - dc, err := f.DefaultDatacenter(ctx) + dc, err := f.DatacenterOrDefault(ctx, *newVM.dcName) if err != nil { log.Fatalf("No Datacenter instance could be found inside of vCenter %v", err) }