diff --git a/pkg/apis/compute/storage_const.go b/pkg/apis/compute/storage_const.go index 4d307a329c..df2281e33b 100644 --- a/pkg/apis/compute/storage_const.go +++ b/pkg/apis/compute/storage_const.go @@ -236,4 +236,7 @@ type StorageListInput struct { // filter storages which attached the specified host HostId string `json:"host_id"` + + // filter storages of baremetal host + IsBaremetal *bool `json:"is_baremetal"` } diff --git a/pkg/compute/models/storages.go b/pkg/compute/models/storages.go index 71e540bfe8..35525307c7 100644 --- a/pkg/compute/models/storages.go +++ b/pkg/compute/models/storages.go @@ -1532,6 +1532,14 @@ func (manager *SStorageManager) ListItemFilter( q = q.In("id", sq.SubQuery()) } + if query.IsBaremetal != nil { + qf := q.NotEquals + if *query.IsBaremetal { + qf = q.Equals + } + q = qf("storage_type", api.STORAGE_BAREMETAL) + } + return q, err } diff --git a/pkg/mcclient/options/compute/storage.go b/pkg/mcclient/options/compute/storage.go index a1fa86ceed..5925c61b01 100644 --- a/pkg/mcclient/options/compute/storage.go +++ b/pkg/mcclient/options/compute/storage.go @@ -35,6 +35,7 @@ type StorageListOptions struct { HostSchedtagId string `help:"filter storage by host schedtag"` ImageId string `help:"filter storage by image"` + IsBaremetal *bool `help:"Baremetal storage list"` } func (opts *StorageListOptions) Params() (jsonutils.JSONObject, error) {