Skip to content

Commit

Permalink
if network not defined, use default network
Browse files Browse the repository at this point in the history
  • Loading branch information
rvanderp3 committed Aug 16, 2021
1 parent e36cb28 commit 34eb13d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/vsphere-priv-check/vsphere-priv-check.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func runRootCmd(cmd *cobra.Command, args []string) {
}

func main() {
fmt.Printf("OpenShift vSphere Pre-Flight Permissions Validator v1.1\n\n")
fmt.Printf("OpenShift vSphere Pre-Flight Permissions Validator v1.2\n\n")
rootCmd := newRootCmd()
rootCmd.Execute()
}
19 changes: 16 additions & 3 deletions pkg/util/privileges.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/vmware/govmomi/find"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/vim25/types"
"log"
"strings"
)

Expand Down Expand Up @@ -121,10 +122,22 @@ func ValidatePrivileges(ssn *Session, p *pctypes.Platform, folder string) error
}

if val, ok := permissions.RequiredPermissions["Port group"]; ok {
network, err := finder.Network(ctx, p.Network)
if err != nil {
return err
var network object.NetworkReference
if p.Network == "" {
log.Println("'network' not defined in install-config.yaml. attempting to use default network.")
_network, err := finder.DefaultNetwork(ctx)
if err != nil {
return err
}
network = _network
} else {
_network, err := finder.Network(ctx, p.Network)
if err != nil {
return err
}
network = _network
}

res, err := authManager.FetchUserPrivilegeOnEntities(ctx, []types.ManagedObjectReference{network.Reference()}, p.Username)
if err != nil {
return err
Expand Down

0 comments on commit 34eb13d

Please sign in to comment.