From 750cd9d4dc6fd14508cdaf2f4c3bdeffaed02f0b Mon Sep 17 00:00:00 2001 From: Qiu Jian Date: Sat, 11 Jan 2020 00:34:30 +0800 Subject: [PATCH] fix: ServerCreateInput add deprecated sku field for backward compatibility --- pkg/apis/compute/api.go | 18 ++++++++++++------ pkg/cloudcommon/db/adminsharablevirtual.go | 4 ++-- pkg/compute/models/baremetalagents.go | 2 +- pkg/compute/models/dynamicschedtags.go | 2 +- pkg/compute/models/loadbalanceracls.go | 2 +- pkg/keystone/models/regions.go | 2 +- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/pkg/apis/compute/api.go b/pkg/apis/compute/api.go index a655bbe14c..64fa468c11 100644 --- a/pkg/apis/compute/api.go +++ b/pkg/apis/compute/api.go @@ -424,9 +424,6 @@ type ServerCreateInput struct { // swagger:ignore AutoPrepaidRecycle bool `json:"auto_prepaid_recycle,omitfalse"` - // 安全组Id, 此参数会和secgroups参数合并 - SecgroupId string `json:"secgrp_id"` - // 弹性公网IP带宽 // 指定此参数后会创建新的弹性公网IP并绑定到新建的虚拟机 // 私有云不支持此参数 @@ -445,6 +442,8 @@ type ServerCreateInput struct { // required: false InstanceSnapshotId string `json:"instance_snapshot_id,omitempty"` + // 安全组Id, 此参数会和secgroups参数合并 + SecgroupId string `json:"secgrp_id"` // 安全组Id列表 Secgroups []string `json:"secgroups"` @@ -458,7 +457,8 @@ type ServerCreateInput struct { // swagger:ignore BillingCycle string `json:"billing_cycle"` - // DEPRECATE + // swagger:ignore + // Deprecated // 此参数等同于 hypervisor=baremetal Baremetal bool `json:"baremetal"` @@ -469,8 +469,14 @@ type ServerCreateInput struct { // swagger:ignore DefaultStorageType string `json:"default_storage_type,omitempty"` - // Guest Image ID - GuestImageID string + // 指定用于新建主机的主机镜像ID + GuestImageID string `json:"guest_image_id"` +} + +func (input *ServerCreateInput) AfterUnmarshal() { + if input.Baremetal { + input.Hypervisor = HYPERVISOR_BAREMETAL + } } type ServerCloneInput struct { diff --git a/pkg/cloudcommon/db/adminsharablevirtual.go b/pkg/cloudcommon/db/adminsharablevirtual.go index 87b3fb1d4b..f3f9667a26 100644 --- a/pkg/cloudcommon/db/adminsharablevirtual.go +++ b/pkg/cloudcommon/db/adminsharablevirtual.go @@ -19,13 +19,13 @@ import ( "strings" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/errors" "yunion.io/x/pkg/utils" + "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/pkg/errors" - "yunion.io/x/sqlchemy" ) type SAdminSharableVirtualResourceBase struct { diff --git a/pkg/compute/models/baremetalagents.go b/pkg/compute/models/baremetalagents.go index 0a271f2b1d..dc5a8e0ed1 100644 --- a/pkg/compute/models/baremetalagents.go +++ b/pkg/compute/models/baremetalagents.go @@ -22,13 +22,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/util/regutils" + "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/sqlchemy" ) type SBaremetalagentManager struct { diff --git a/pkg/compute/models/dynamicschedtags.go b/pkg/compute/models/dynamicschedtags.go index 9bad62592e..d845afd50a 100644 --- a/pkg/compute/models/dynamicschedtags.go +++ b/pkg/compute/models/dynamicschedtags.go @@ -21,6 +21,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" "yunion.io/x/sqlchemy" @@ -30,7 +31,6 @@ import ( "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/util/conditionparser" - "yunion.io/x/pkg/errors" ) type IDynamicResourceManager interface { diff --git a/pkg/compute/models/loadbalanceracls.go b/pkg/compute/models/loadbalanceracls.go index c5b96d0f23..97aff73337 100644 --- a/pkg/compute/models/loadbalanceracls.go +++ b/pkg/compute/models/loadbalanceracls.go @@ -26,6 +26,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/errors" "yunion.io/x/pkg/gotypes" "yunion.io/x/pkg/util/compare" "yunion.io/x/sqlchemy" @@ -38,7 +39,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudprovider" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/pkg/errors" ) type SLoadbalancerAclEntry struct { diff --git a/pkg/keystone/models/regions.go b/pkg/keystone/models/regions.go index 9933f8ab0e..1ba3973a01 100644 --- a/pkg/keystone/models/regions.go +++ b/pkg/keystone/models/regions.go @@ -18,6 +18,7 @@ import ( "context" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/errors" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" @@ -25,7 +26,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/pkg/errors" ) type SRegionManager struct {