From 28f8dd886d54015182674d1935effe855b838281 Mon Sep 17 00:00:00 2001 From: Zexi Li Date: Mon, 26 Sep 2022 15:02:33 +0800 Subject: [PATCH] feat(region): is_baremetal option for storage list --- pkg/apis/compute/storage_const.go | 3 +++ pkg/compute/models/storages.go | 8 ++++++++ pkg/mcclient/options/compute/storage.go | 1 + 3 files changed, 12 insertions(+) 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) {