Skip to content

Commit

Permalink
govc: add storage.policy.info flag to query IO filters
Browse files Browse the repository at this point in the history
  • Loading branch information
dougm committed Oct 3, 2024
1 parent da340f5 commit 2613278
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
19 changes: 16 additions & 3 deletions govc/storage/policy/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type info struct {

compliance bool
storage bool
iofilters bool
}

func init() {
Expand All @@ -53,6 +54,10 @@ func (cmd *info) Register(ctx context.Context, f *flag.FlagSet) {

f.BoolVar(&cmd.storage, "s", false, "Check Storage Compatibility")
f.BoolVar(&cmd.compliance, "c", false, "Check VM Compliance")

if cli.ShowUnreleased() {
f.BoolVar(&cmd.iofilters, "i", false, "Query IO Filters")
}
}

func (cmd *info) Process(ctx context.Context) error {
Expand All @@ -79,9 +84,10 @@ Examples:
}

type Policy struct {
Profile types.BasePbmProfile `json:"profile"`
CompliantVM []string `json:"compliantVM"`
CompatibleDatastores []string `json:"compatibleDatastores"`
Profile types.BasePbmProfile `json:"profile"`
CompliantVM []string `json:"compliantVM"`
CompatibleDatastores []string `json:"compatibleDatastores"`
FilterMap []types.PbmProfileToIofilterMap `json:"filterMap,omitempty"`
}

type infoResult struct {
Expand Down Expand Up @@ -190,6 +196,13 @@ func (cmd *info) Run(ctx context.Context, f *flag.FlagSet) error {
}
}

if cmd.iofilters {
policy.FilterMap, err = c.QueryIOFiltersFromProfileId(ctx, p.ProfileId.UniqueId)
if err != nil {
return err
}
}

policies = append(policies, policy)
}

Expand Down
6 changes: 6 additions & 0 deletions govc/test/storage.bats
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ load test_helper

run govc storage.policy.info "vSAN Default Storage Policy"
assert_success

run env GOVC_SHOW_UNRELEASED=true govc storage.policy.info -json -i "VM Encryption Policy"
assert_success

kind="$(jq -r .policies[].filterMap[].iofilters[].filterType <<<"$output")"
assert_equal "ENCRYPTION" "$kind"
}

@test "storage.policy.create" {
Expand Down

0 comments on commit 2613278

Please sign in to comment.