Skip to content

Commit 9edfd6d

Browse files
committed
vsphere - allow network selection on cluster name
Prior to the capi implementation for vSphere there was no selector of network path based on resource pools. This addition has changed the requirement of the resource pool existing prior to installation. To maintain backward compat add a selector base on the cluster name.
1 parent 469d617 commit 9edfd6d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pkg/asset/machines/vsphere/capimachines.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"strings"
99

10+
"github.com/sirupsen/logrus"
1011
v1 "k8s.io/api/core/v1"
1112
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1213
"k8s.io/apimachinery/pkg/runtime"
@@ -51,11 +52,20 @@ func getNetworkInventoryPath(vcenterContext vsphere.VCenterContext, networkName
5152
if _, networkInContext := clusterNetworkMap.NetworkNames[networkName]; !networkInContext {
5253
continue
5354
}
55+
5456
for _, resourcePool := range clusterNetworkMap.ResourcePools {
5557
if resourcePool.InventoryPath == providerSpec.Workspace.ResourcePool {
5658
return clusterNetworkMap.NetworkNames[networkName], nil
5759
}
5860
}
61+
62+
// This is a case for UPI (terraform or powercli) the resource pool will not exist
63+
// prior to running openshift-install create manifests.
64+
// This also will keep backward compatibility as this was not required to CAPI implementation.
65+
if strings.Contains(providerSpec.Workspace.ResourcePool, clusterNetworkMap.Cluster) {
66+
logrus.Debugf("using cluster %s as selector for network device path %s", clusterNetworkMap.Cluster, networkName)
67+
return clusterNetworkMap.NetworkNames[networkName], nil
68+
}
5969
}
6070
return "", fmt.Errorf("unable to find network %s in resource pool %s", networkName, providerSpec.Workspace.ResourcePool)
6171
}

0 commit comments

Comments
 (0)