mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/yunionio/cloudpods.git
synced 2026-09-20 08:03:53 +08:00
101 lines
3.6 KiB
Go
101 lines
3.6 KiB
Go
// Copyright 2019 Yunion
|
|
//
|
|
// 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
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package glance
|
|
|
|
import (
|
|
"yunion.io/x/jsonutils"
|
|
|
|
"yunion.io/x/onecloud/pkg/mcclient/options"
|
|
)
|
|
|
|
type ImageListOptions struct {
|
|
_ struct{} `mcp-desc:"【创建流程中的中间步骤】用于查询 Glance/本地 KVM 可用镜像。公有云或非 KVM 请用 climc_cached_image_list。创建场景下查完镜像后继续查网络/规格并调用 climc_server_create。严禁只调用本工具后就停止"`
|
|
|
|
options.BaseListOptions
|
|
|
|
IsPublic string `help:"filter images public or not(True, False or None)" choices:"true|false" mcp:"true"`
|
|
IsStandard string `help:"filter images standard or non-standard" choices:"true|false" mcp:"true"`
|
|
Protected string `help:"filter images by protected" choices:"true|false"`
|
|
IsUefi bool `help:"list uefi image" mcp:"true"`
|
|
Format []string `help:"Disk formats" mcp:"true"`
|
|
SubFormats []string `help:"Sub formats"`
|
|
Name string `help:"Name filter" mcp:"true"`
|
|
OsType []string `help:"Type of OS filter e.g. 'Windows, Linux, Freebsd, Android, macOS, VMWare'" mcp:"true"`
|
|
OsTypePreciseMatch bool `help:"OS precise match"`
|
|
OsArch []string `help:"Type of OS arch filter e.g. 'x86, arm, arm64, x86_64'" mcp:"true"`
|
|
OsArchPreciseMatch bool `help:"OS arch precise match"`
|
|
Distribution []string `help:"Distribution filter, e.g. 'CentOS, Ubuntu, Debian, Windows'" mcp:"true"`
|
|
DistributionPreciseMatch bool `help:"Distribution precise match"`
|
|
}
|
|
|
|
func (o *ImageListOptions) Params() (jsonutils.JSONObject, error) {
|
|
params, err := o.BaseListOptions.Params()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if len(o.IsPublic) > 0 {
|
|
params.Add(jsonutils.NewString(o.IsPublic), "is_public")
|
|
}
|
|
if len(o.IsStandard) > 0 {
|
|
params.Add(jsonutils.NewString(o.IsStandard), "is_standard")
|
|
}
|
|
if len(o.Protected) > 0 {
|
|
params.Add(jsonutils.NewString(o.Protected), "protected")
|
|
}
|
|
if o.IsUefi {
|
|
params.Add(jsonutils.JSONTrue, "uefi")
|
|
}
|
|
if len(o.Tenant) > 0 {
|
|
params.Add(jsonutils.NewString(o.Tenant), "owner")
|
|
}
|
|
if len(o.Name) > 0 {
|
|
params.Add(jsonutils.NewString(o.Name), "name")
|
|
}
|
|
if len(o.Format) > 0 {
|
|
fs := jsonutils.NewArray()
|
|
for _, f := range o.Format {
|
|
fs.Add(jsonutils.NewString(f))
|
|
}
|
|
params.Add(fs, "disk_formats")
|
|
}
|
|
if len(o.SubFormats) > 0 {
|
|
params.Add(jsonutils.Marshal(o.SubFormats), "sub_formats")
|
|
}
|
|
if len(o.OsType) > 0 {
|
|
params.Add(jsonutils.NewStringArray(o.OsType), "os_types")
|
|
}
|
|
if o.OsTypePreciseMatch {
|
|
params.Add(jsonutils.JSONTrue, "os_type_precise_match")
|
|
}
|
|
if len(o.OsArch) > 0 {
|
|
params.Add(jsonutils.NewStringArray(o.OsArch), "os_archs")
|
|
}
|
|
if o.OsArchPreciseMatch {
|
|
params.Add(jsonutils.JSONTrue, "os_arch_precise_match")
|
|
}
|
|
if len(o.Distribution) > 0 {
|
|
params.Add(jsonutils.NewStringArray(o.Distribution), "distributions")
|
|
}
|
|
if o.DistributionPreciseMatch {
|
|
params.Add(jsonutils.JSONTrue, "distribution_precise_match")
|
|
}
|
|
return params, nil
|
|
}
|
|
|
|
type ImageStatusStatisticsOptions struct {
|
|
ImageListOptions
|
|
options.StatusStatisticsOptions
|
|
}
|