From 6e96a1b8b058ffbfd5f6ca9e43ba3104439d3f8d Mon Sep 17 00:00:00 2001 From: Miao Luo Date: Thu, 23 Feb 2017 15:58:49 -0800 Subject: [PATCH] Remove VCenterPort from vsphere cloud provider. The url which is used for communicating with govmomi should not include port number. A port number other than 443 will result in 404 error. VCenterPort stays in VSphereConfig structure for backward compatibility. --- pkg/cloudprovider/providers/vsphere/vsphere.go | 5 ++++- pkg/cloudprovider/providers/vsphere/vsphere_test.go | 5 ----- pkg/cloudprovider/providers/vsphere/vsphere_util.go | 1 - 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/pkg/cloudprovider/providers/vsphere/vsphere.go b/pkg/cloudprovider/providers/vsphere/vsphere.go index 84ae9e8b79..7822f754fa 100644 --- a/pkg/cloudprovider/providers/vsphere/vsphere.go +++ b/pkg/cloudprovider/providers/vsphere/vsphere.go @@ -272,6 +272,9 @@ func newVSphere(cfg VSphereConfig) (*VSphere, error) { if cfg.Global.RoundTripperCount == 0 { cfg.Global.RoundTripperCount = RoundTripperDefaultCount } + if cfg.Global.VCenterPort != "" { + glog.Warningf("port is a deprecated field in vsphere.conf and will be removed in future release.") + } c, err := newClient(context.TODO(), &cfg) if err != nil { @@ -309,7 +312,7 @@ func logout(vs *VSphere) { func newClient(ctx context.Context, cfg *VSphereConfig) (*govmomi.Client, error) { // Parse URL from string - u, err := url.Parse(fmt.Sprintf("https://%s:%s/sdk", cfg.Global.VCenterIP, cfg.Global.VCenterPort)) + u, err := url.Parse(fmt.Sprintf("https://%s/sdk", cfg.Global.VCenterIP)) if err != nil { return nil, err } diff --git a/pkg/cloudprovider/providers/vsphere/vsphere_test.go b/pkg/cloudprovider/providers/vsphere/vsphere_test.go index 89903b639c..02fdb5006a 100644 --- a/pkg/cloudprovider/providers/vsphere/vsphere_test.go +++ b/pkg/cloudprovider/providers/vsphere/vsphere_test.go @@ -33,7 +33,6 @@ func configFromEnv() (cfg VSphereConfig, ok bool) { var InsecureFlag bool var err error cfg.Global.VCenterIP = os.Getenv("VSPHERE_VCENTER") - cfg.Global.VCenterPort = os.Getenv("VSPHERE_VCENTER_PORT") cfg.Global.User = os.Getenv("VSPHERE_USER") cfg.Global.Password = os.Getenv("VSPHERE_PASSWORD") cfg.Global.Datacenter = os.Getenv("VSPHERE_DATACENTER") @@ -81,10 +80,6 @@ vm-uuid = 1234 t.Errorf("incorrect vcenter ip: %s", cfg.Global.VCenterIP) } - if cfg.Global.VCenterPort != "443" { - t.Errorf("incorrect vcenter port: %s", cfg.Global.VCenterPort) - } - if cfg.Global.Datacenter != "us-west" { t.Errorf("incorrect datacenter: %s", cfg.Global.Datacenter) } diff --git a/pkg/cloudprovider/providers/vsphere/vsphere_util.go b/pkg/cloudprovider/providers/vsphere/vsphere_util.go index c11c9d310c..111349d7e6 100644 --- a/pkg/cloudprovider/providers/vsphere/vsphere_util.go +++ b/pkg/cloudprovider/providers/vsphere/vsphere_util.go @@ -43,7 +43,6 @@ func GetVSphere() (*VSphere, error) { func getVSphereConfig() *VSphereConfig { var cfg VSphereConfig cfg.Global.VCenterIP = os.Getenv("VSPHERE_VCENTER") - cfg.Global.VCenterPort = os.Getenv("VSPHERE_VCENTER_PORT") cfg.Global.User = os.Getenv("VSPHERE_USER") cfg.Global.Password = os.Getenv("VSPHERE_PASSWORD") cfg.Global.Datacenter = os.Getenv("VSPHERE_DATACENTER")