From e9f4cb7321798564aaad31a4cf75e87294b40cdb Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Mon, 24 Jun 2024 10:00:31 -0700 Subject: [PATCH 1/2] vcsim: add vSAN FileServiceConfig support Issue #3430 --- vsan/simulator/simulator.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/vsan/simulator/simulator.go b/vsan/simulator/simulator.go index ba671932f..f78bb2016 100644 --- a/vsan/simulator/simulator.go +++ b/vsan/simulator/simulator.go @@ -1,11 +1,11 @@ /* -Copyright (c) 2021 VMware, Inc. All Rights Reserved. +Copyright (c) 2021-2024 VMware, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -106,6 +106,9 @@ func (s *ClusterConfigSystem) VsanClusterReconfig(ctx *simulator.Context, req *t if req.VsanReconfigSpec.UnmapConfig != nil { info.UnmapConfig = req.VsanReconfigSpec.UnmapConfig } + if req.VsanReconfigSpec.FileServiceConfig != nil { + info.FileServiceConfig = req.VsanReconfigSpec.FileServiceConfig + } return nil, nil }) From c3c5ffbaf8e7b67a8ade463297ebcf127baa731f Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Mon, 24 Jun 2024 10:00:58 -0700 Subject: [PATCH 2/2] govc: add vsan.info -file-service-enabled flag --- govc/USAGE.md | 3 ++- govc/test/vsan.bats | 20 +++++++++++++++++--- govc/vsan/change.go | 14 ++++++++++---- govc/vsan/info.go | 10 +++++----- 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/govc/USAGE.md b/govc/USAGE.md index f8ad98cf9..57b075e1d 100644 --- a/govc/USAGE.md +++ b/govc/USAGE.md @@ -7190,7 +7190,8 @@ Examples: govc vsan.change -unmap-enabled=false ClusterA # disable unmap Options: - -unmap-enabled= Enable Unmap + -file-service-enabled= Enable FileService + -unmap-enabled= Enable Unmap ``` ## vsan.info diff --git a/govc/test/vsan.bats b/govc/test/vsan.bats index 1dbdcf0b0..7058cd86f 100755 --- a/govc/test/vsan.bats +++ b/govc/test/vsan.bats @@ -5,14 +5,14 @@ load test_helper @test "vsan.change" { vcsim_env -cluster 2 + run govc vsan.change DC0_C0 + assert_failure # no flags specified + run govc vsan.info -json DC0_C0 assert_success config=$(jq .clusters[].info.UnmapConfig <<<"$output") assert_equal null "$config" - run govc vsan.change DC0_C0 - assert_failure # no flags specified - run govc vsan.change -unmap-enabled DC0_C0 assert_success @@ -21,4 +21,18 @@ load test_helper config=$(jq .clusters[].info.UnmapConfig.Enable <<<"$output") assert_equal true "$config" + + run govc vsan.info -json DC0_C0 + assert_success + config=$(jq .clusters[].info.FileServiceConfig <<<"$output") + assert_equal null "$config" + + run govc vsan.change -file-service-enabled DC0_C0 + assert_success + + run govc vsan.info -json DC0_C0 + assert_success + + config=$(jq .clusters[].info.FileServiceConfig.Enabled <<<"$output") + assert_equal true "$config" } diff --git a/govc/vsan/change.go b/govc/vsan/change.go index 7e98033fd..838f5f3e7 100644 --- a/govc/vsan/change.go +++ b/govc/vsan/change.go @@ -1,11 +1,11 @@ /* -Copyright (c) 2021 VMware, Inc. All Rights Reserved. +Copyright (c) 2021-2024 VMware, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -30,6 +30,7 @@ type change struct { *flags.DatacenterFlag unmap *bool + fs *bool } func init() { @@ -41,6 +42,7 @@ func (cmd *change) Register(ctx context.Context, f *flag.FlagSet) { cmd.DatacenterFlag.Register(ctx, f) f.Var(flags.NewOptionalBool(&cmd.unmap), "unmap-enabled", "Enable Unmap") + f.Var(flags.NewOptionalBool(&cmd.fs), "file-service-enabled", "Enable FileService") } func (cmd *change) Usage() string { @@ -80,10 +82,14 @@ func (cmd *change) Run(ctx context.Context, f *flag.FlagSet) error { var spec types.VimVsanReconfigSpec + if cmd.unmap == nil && cmd.fs == nil { + return flag.ErrHelp + } if cmd.unmap != nil { spec.UnmapConfig = &types.VsanUnmapConfig{Enable: *cmd.unmap} - } else { - return flag.ErrHelp + } + if cmd.fs != nil { + spec.FileServiceConfig = &types.VsanFileServiceConfig{Enabled: *cmd.fs} } task, err := c.VsanClusterReconfig(ctx, cluster.Reference(), spec) diff --git a/govc/vsan/info.go b/govc/vsan/info.go index ae9781481..8636558fb 100644 --- a/govc/vsan/info.go +++ b/govc/vsan/info.go @@ -1,5 +1,5 @@ /* -Copyright (c) 2021-2023 VMware, Inc. All Rights Reserved. +Copyright (c) 2021-2024 VMware, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -112,12 +112,12 @@ func (r *infoResult) Write(w io.Writer) error { for _, cluster := range r.Clusters { fmt.Fprintf(tw, "Path:\t%s\n", cluster.Path) fmt.Fprintf(tw, " Enabled:\t%t\n", *cluster.Info.Enabled) - unmapEnabled := false if unmap := cluster.Info.UnmapConfig; unmap != nil { - unmapEnabled = unmap.Enable + fmt.Fprintf(tw, " Unmap Enabled:\t%t\n", unmap.Enable) + } + if fs := cluster.Info.FileServiceConfig; fs != nil { + fmt.Fprintf(tw, " FileService Enabled:\t%t\n", fs.Enabled) } - - fmt.Fprintf(tw, " Unmap Enabled:\t%t\n", unmapEnabled) } return tw.Flush()