mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
feat: add 'vlan_id' param when creating network
This commit is contained in:
@@ -187,6 +187,12 @@ type NetworkCreateInput struct {
|
||||
|
||||
// 是否加入自动分配地址池
|
||||
IsAutoAlloc *bool `json:"is_auto_alloc"`
|
||||
|
||||
// VlanId
|
||||
VlanId *int `json:"vlan_id"`
|
||||
|
||||
// deprecated
|
||||
Vlan *int `json:"vlan" yunion-deprecated-by:"vlan_id"`
|
||||
}
|
||||
|
||||
type NetworkDetails struct {
|
||||
|
||||
@@ -1333,6 +1333,20 @@ func (manager *SNetworkManager) ValidateCreateData(ctx context.Context, userCred
|
||||
return input, httperrors.NewInputParameterError("Invalid server_type: %s", input.ServerType)
|
||||
}
|
||||
|
||||
{
|
||||
defaultVlanId := 1
|
||||
|
||||
if input.VlanId == nil {
|
||||
input.VlanId = &defaultVlanId
|
||||
} else if *input.VlanId < 1 {
|
||||
input.VlanId = &defaultVlanId
|
||||
}
|
||||
|
||||
if *input.VlanId > 4095 {
|
||||
return input, httperrors.NewInputParameterError("valid vlan id")
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
if len(input.IfnameHint) == 0 {
|
||||
input.IfnameHint = input.Name
|
||||
|
||||
Reference in New Issue
Block a user