1- /*
2- Copyright (c) 2018-2024 VMware, Inc. All Rights Reserved.
3-
4- Licensed under the Apache License, Version 2.0 (the "License");
5- you may not use this file except in compliance with the License.
6- You may obtain a copy of the License at
7-
8- http://www.apache.org/licenses/LICENSE-2.0
9-
10- Unless required by applicable law or agreed to in writing, software
11- distributed under the License is distributed on an "AS IS" BASIS,
12- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13- See the License for the specific language governing permissions and
14- limitations under the License.
15- */
1+ // © Broadcom. All Rights Reserved.
2+ // The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
3+ // SPDX-License-Identifier: Apache-2.0
164
175package disk
186
@@ -30,7 +18,6 @@ import (
3018 "github.com/vmware/govmomi/fault"
3119 "github.com/vmware/govmomi/units"
3220 "github.com/vmware/govmomi/vim25/types"
33- "github.com/vmware/govmomi/vslm"
3421)
3522
3623type ls struct {
@@ -123,23 +110,13 @@ func (r *lsResult) Dump() interface{} {
123110}
124111
125112func (cmd * ls ) Run (ctx context.Context , f * flag.FlagSet ) error {
126- c , err := cmd .Client ()
127- if err != nil {
128- return err
129- }
130-
131- ds , err := cmd .Datastore ()
113+ m , err := NewManagerFromFlag (ctx , cmd .DatastoreFlag )
132114 if err != nil {
133115 return err
134116 }
135117
136- m := vslm .NewObjectManager (c )
137118 if cmd .r {
138- task , err := m .ReconcileDatastoreInventory (ctx , ds )
139- if err != nil {
140- return err
141- }
142- if err = task .Wait (ctx ); err != nil {
119+ if err = m .ReconcileDatastoreInventory (ctx ); err != nil {
143120 return err
144121 }
145122 }
@@ -151,7 +128,7 @@ func (cmd *ls) Run(ctx context.Context, f *flag.FlagSet) error {
151128 filterNotFound = true
152129 var oids []types.ID
153130 if cmd .category == "" {
154- oids , err = m .List (ctx , ds )
131+ oids , err = m .List (ctx )
155132 } else {
156133 oids , err = m .ListAttachedObjects (ctx , cmd .category , cmd .tag )
157134 }
@@ -165,7 +142,7 @@ func (cmd *ls) Run(ctx context.Context, f *flag.FlagSet) error {
165142 }
166143
167144 for _ , id := range ids {
168- o , err := m .Retrieve (ctx , ds , id )
145+ o , err := m .Retrieve (ctx , id )
169146 if err != nil {
170147 if filterNotFound && fault .Is (err , & types.NotFound {}) {
171148 // The case when an FCD is deleted by something other than DeleteVStorageObject_Task, such as VM destroy
0 commit comments