From d54fdf6e710e87190c0bb0673c0753ca6cac8c04 Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Mon, 1 Mar 2021 18:35:25 +0800 Subject: [PATCH] networks: server_type: do not allow update Transition between guest, baremetal, ipmi, eip, etc. all requires sanity checks on relevant types allocated from the network --- pkg/apis/compute/network.go | 4 ---- pkg/compute/models/networks.go | 2 +- pkg/mcclient/options/network.go | 4 ---- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/pkg/apis/compute/network.go b/pkg/apis/compute/network.go index e9ea804787..ff2b0c579e 100644 --- a/pkg/apis/compute/network.go +++ b/pkg/apis/compute/network.go @@ -316,10 +316,6 @@ type NetworkUpdateInput struct { VlanId *int `json:"vlan_id"` - // 服务器类型 - // example: server - ServerType string `json:"server_type"` - // 分配策略 AllocPolicy string `json:"alloc_policy"` diff --git a/pkg/compute/models/networks.go b/pkg/compute/models/networks.go index 4904e10ca7..9acce986b6 100644 --- a/pkg/compute/models/networks.go +++ b/pkg/compute/models/networks.go @@ -109,7 +109,7 @@ type SNetwork struct { // 服务器类型 // example: server - ServerType string `width:"16" charset:"ascii" default:"guest" nullable:"true" list:"user" update:"user" create:"optional"` + ServerType string `width:"16" charset:"ascii" default:"guest" nullable:"true" list:"user" create:"optional"` // 分配策略 AllocPolicy string `width:"16" charset:"ascii" nullable:"true" get:"user" update:"user" create:"optional"` diff --git a/pkg/mcclient/options/network.go b/pkg/mcclient/options/network.go index 87d77fef78..5894358fe3 100644 --- a/pkg/mcclient/options/network.go +++ b/pkg/mcclient/options/network.go @@ -58,7 +58,6 @@ func (opts *NetworkListOptions) Params() (jsonutils.JSONObject, error) { type NetworkUpdateOptions struct { BaseUpdateOptions - ServerType string `help:"server type," choices:"baremetal|container|eip|guest|ipmi|pxe"` StartIp string `help:"Start ip"` EndIp string `help:"end ip"` NetMask int64 `help:"Netmask"` @@ -80,9 +79,6 @@ func (opts *NetworkUpdateOptions) Params() (jsonutils.JSONObject, error) { if len(opts.Desc) > 0 { params.Add(jsonutils.NewString(opts.Desc), "description") } - if len(opts.ServerType) > 0 { - params.Add(jsonutils.NewString(opts.ServerType), "server_type") - } if len(opts.StartIp) > 0 { params.Add(jsonutils.NewString(opts.StartIp), "guest_ip_start") }