Skip to content

Commit c3c5ffb

Browse files
committed
govc: add vsan.info -file-service-enabled flag
1 parent e9f4cb7 commit c3c5ffb

File tree

4 files changed

+34
-13
lines changed

4 files changed

+34
-13
lines changed

govc/USAGE.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -7190,7 +7190,8 @@ Examples:
71907190
govc vsan.change -unmap-enabled=false ClusterA # disable unmap
71917191
71927192
Options:
7193-
-unmap-enabled=<nil> Enable Unmap
7193+
-file-service-enabled=<nil> Enable FileService
7194+
-unmap-enabled=<nil> Enable Unmap
71947195
```
71957196

71967197
## vsan.info

govc/test/vsan.bats

+17-3
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ load test_helper
55
@test "vsan.change" {
66
vcsim_env -cluster 2
77

8+
run govc vsan.change DC0_C0
9+
assert_failure # no flags specified
10+
811
run govc vsan.info -json DC0_C0
912
assert_success
1013
config=$(jq .clusters[].info.UnmapConfig <<<"$output")
1114
assert_equal null "$config"
1215

13-
run govc vsan.change DC0_C0
14-
assert_failure # no flags specified
15-
1616
run govc vsan.change -unmap-enabled DC0_C0
1717
assert_success
1818

@@ -21,4 +21,18 @@ load test_helper
2121

2222
config=$(jq .clusters[].info.UnmapConfig.Enable <<<"$output")
2323
assert_equal true "$config"
24+
25+
run govc vsan.info -json DC0_C0
26+
assert_success
27+
config=$(jq .clusters[].info.FileServiceConfig <<<"$output")
28+
assert_equal null "$config"
29+
30+
run govc vsan.change -file-service-enabled DC0_C0
31+
assert_success
32+
33+
run govc vsan.info -json DC0_C0
34+
assert_success
35+
36+
config=$(jq .clusters[].info.FileServiceConfig.Enabled <<<"$output")
37+
assert_equal true "$config"
2438
}

govc/vsan/change.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
Copyright (c) 2021 VMware, Inc. All Rights Reserved.
2+
Copyright (c) 2021-2024 VMware, Inc. All Rights Reserved.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
66
You may obtain a copy of the License at
77
8-
http://www.apache.org/licenses/LICENSE-2.0
8+
http://www.apache.org/licenses/LICENSE-2.0
99
1010
Unless required by applicable law or agreed to in writing, software
1111
distributed under the License is distributed on an "AS IS" BASIS,
@@ -30,6 +30,7 @@ type change struct {
3030
*flags.DatacenterFlag
3131

3232
unmap *bool
33+
fs *bool
3334
}
3435

3536
func init() {
@@ -41,6 +42,7 @@ func (cmd *change) Register(ctx context.Context, f *flag.FlagSet) {
4142
cmd.DatacenterFlag.Register(ctx, f)
4243

4344
f.Var(flags.NewOptionalBool(&cmd.unmap), "unmap-enabled", "Enable Unmap")
45+
f.Var(flags.NewOptionalBool(&cmd.fs), "file-service-enabled", "Enable FileService")
4446
}
4547

4648
func (cmd *change) Usage() string {
@@ -80,10 +82,14 @@ func (cmd *change) Run(ctx context.Context, f *flag.FlagSet) error {
8082

8183
var spec types.VimVsanReconfigSpec
8284

85+
if cmd.unmap == nil && cmd.fs == nil {
86+
return flag.ErrHelp
87+
}
8388
if cmd.unmap != nil {
8489
spec.UnmapConfig = &types.VsanUnmapConfig{Enable: *cmd.unmap}
85-
} else {
86-
return flag.ErrHelp
90+
}
91+
if cmd.fs != nil {
92+
spec.FileServiceConfig = &types.VsanFileServiceConfig{Enabled: *cmd.fs}
8793
}
8894

8995
task, err := c.VsanClusterReconfig(ctx, cluster.Reference(), spec)

govc/vsan/info.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2021-2023 VMware, Inc. All Rights Reserved.
2+
Copyright (c) 2021-2024 VMware, Inc. All Rights Reserved.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -112,12 +112,12 @@ func (r *infoResult) Write(w io.Writer) error {
112112
for _, cluster := range r.Clusters {
113113
fmt.Fprintf(tw, "Path:\t%s\n", cluster.Path)
114114
fmt.Fprintf(tw, " Enabled:\t%t\n", *cluster.Info.Enabled)
115-
unmapEnabled := false
116115
if unmap := cluster.Info.UnmapConfig; unmap != nil {
117-
unmapEnabled = unmap.Enable
116+
fmt.Fprintf(tw, " Unmap Enabled:\t%t\n", unmap.Enable)
117+
}
118+
if fs := cluster.Info.FileServiceConfig; fs != nil {
119+
fmt.Fprintf(tw, " FileService Enabled:\t%t\n", fs.Enabled)
118120
}
119-
120-
fmt.Fprintf(tw, " Unmap Enabled:\t%t\n", unmapEnabled)
121121
}
122122

123123
return tw.Flush()

0 commit comments

Comments
 (0)