hotfix: add networkinterface docs

This commit is contained in:
ioito
2019-08-02 16:36:43 +08:00
parent a772dc2194
commit a95070a3cd
12 changed files with 179 additions and 31 deletions

View File

@@ -0,0 +1,46 @@
// 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 shell
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modules"
)
func init() {
type NetworkinterfaceNetworkListOptions struct {
Networkinterface string `help:"ID or Name of Server"`
Network string `help:"Network ID or name"`
}
R(&NetworkinterfaceNetworkListOptions{}, "networkinterface-network-list", "List server network pairs", func(s *mcclient.ClientSession, args *NetworkinterfaceNetworkListOptions) error {
params := jsonutils.NewDict()
var result *modules.ListResult
var err error
if len(args.Networkinterface) > 0 {
result, err = modules.Networkinterfacenetworks.ListDescendent(s, args.Networkinterface, params)
} else if len(args.Network) > 0 {
result, err = modules.Networkinterfacenetworks.ListDescendent2(s, args.Network, params)
} else {
result, err = modules.Networkinterfacenetworks.List(s, params)
}
if err != nil {
return err
}
printList(result, modules.Networkinterfacenetworks.GetColumns(s))
return nil
})
}

View File

@@ -70,6 +70,8 @@ paths:
$ref: "./network/network.yaml#/reserve-ip"
/networks/{networkId}/release-reserve-ip:
$ref: "./network/network.yaml#/release-reserve-ip"
/networks/{networkId}/networkinterface:
$ref: "./network/networkinterface.yaml"
/servers:
$ref: "./instance/instances.yaml"
@@ -302,6 +304,9 @@ paths:
$ref: "./networkinterface/networkinterfaces.yaml"
/networkinterfaces/{networkinterfaceId}:
$ref: "./networkinterface/networkinterface.yaml"
/networkinterfaces/{networkinterfaceId}/networks:
$ref: "./networkinterface/networks.yaml"
/buckets:
$ref: "./bucket/buckets.yaml"

View File

@@ -0,0 +1,11 @@
get:
summary: 获取指定子网下弹性网卡IP列表信息
parameters:
- $ref: "../parameters/network.yaml#/networkId"
responses:
200:
description: 弹性网卡IP列表信息
schema:
$ref: "../schemas/networkinterfacenetwork.yaml#/NetworkinterfaceNetworkListResponse"
tags:
- networks

View File

@@ -1,11 +1,23 @@
get:
summary: 获取指定虚拟网卡详情信息
summary: 获取指定弹性网卡详情信息
parameters:
- $ref: "../parameters/networkinterface.yaml#/networkinterfaceId"
responses:
200:
description: 虚拟网卡详情信息
description: 弹性网卡详情信息
schema:
$ref: "../schemas/networkinterface.yaml#/NetworkinterfaceResponse"
tags:
- networkinterfaces
delete:
summary: 删除指定弹性网卡
parameters:
- $ref: "../parameters/networkinterface.yaml#/networkinterfaceId"
responses:
200:
description: 被删除弹性网卡的信息
schema:
$ref: "../schemas/networkinterface.yaml#/NetworkinterfaceResponse"
tags:
- networkinterfaces

View File

@@ -1,5 +1,5 @@
get:
summary: 按指定条件列出虚拟网卡列表
summary: 按指定条件列出弹性网卡列表
parameters:
- $ref: '../parameters/common.yaml#/limit'
- $ref: '../parameters/common.yaml#/offset'
@@ -7,7 +7,7 @@ get:
- $ref: '../parameters/common.yaml#/zone'
responses:
200:
description: 虚拟网卡列表信息
description: 弹性网卡列表信息
schema:
$ref: "../schemas/networkinterface.yaml#/NetworkinterfaceListResponse"
tags:

View File

@@ -0,0 +1,11 @@
get:
summary: 获取指定弹性网卡底下的IP列表
parameters:
- $ref: "../parameters/networkinterface.yaml#/networkinterfaceId"
responses:
200:
description: 弹性网卡IP列表信息
schema:
$ref: "../schemas/networkinterfacenetwork.yaml#/NetworkinterfaceNetworkListResponse"
tags:
- networkinterfaces

View File

@@ -0,0 +1,12 @@
get:
summary: 按指定条件列出弹性网卡IP列表
parameters:
- $ref: '../parameters/common.yaml#/limit'
- $ref: '../parameters/common.yaml#/offset'
responses:
200:
description: 弹性网卡IP列表信息
schema:
$ref: "../schemas/networkinterfacenetwork.yaml#/NetworkinterfaceNetworkListResponse"
tags:
- networkinterfaces

View File

@@ -3,4 +3,4 @@ networkinterfaceId:
required: true
in: path
type: string
description: 虚拟网卡名称或ID,建议使用ID
description: 弹性网卡名称或ID,建议使用ID

View File

@@ -7,40 +7,19 @@ Networkinterface:
mac:
type: string
example: fa:16:3e:f4:51:76
description: 虚拟网卡MAC地址
description: 弹性网卡MAC地址
associate_id:
type: string
example: 1d18dea0-14a4-4d94-8f18-3a827a0cb124
description: 虚拟网卡绑定设备ID
description: 弹性网卡绑定设备ID
associate_type:
type: string
example: vip
description: 虚拟网卡绑定设备类型
description: 弹性网卡绑定设备类型
networks:
type: array
items:
$ref: '#/NetworkinterfaceNetwork'
NetworkinterfaceNetwork:
type: object
properties:
ip_addr:
type: string
example: "192.168.0.240"
description: 虚拟网卡IP地址
network_id:
type: string
example: 19b09a31-1884-4b3f-84cd-ac03827c567d
description: 虚拟网卡所在子网ID
networkinterface_id:
type: string
example: 231aab7c-9106-471a-822c-6dfa605915f7
description: 虚拟网卡ID
primary:
type: boolean
example: true
description: 是否是主IP
$ref: './networkinterfacenetwork.yaml#/NetworkinterfaceNetwork'
NetworkinterfaceListResponse:
type: object

View File

@@ -0,0 +1,41 @@
NetworkinterfaceNetwork:
type: object
properties:
ip_addr:
type: string
example: "192.168.0.240"
description: 弹性网卡IP地址
network_id:
type: string
example: 19b09a31-1884-4b3f-84cd-ac03827c567d
description: 弹性网卡所在子网ID
networkinterface_id:
type: string
example: 231aab7c-9106-471a-822c-6dfa605915f7
description: 弹性网卡ID
primary:
type: boolean
example: true
description: 是否是主IP
NetworkinterfaceNetworkListResponse:
type: object
properties:
limit:
type: integer
example: 20
networkinterfacenetworks:
type: array
items:
$ref: '#/NetworkinterfaceNetwork'
total:
type: integer
example: 124
NetworkinterfaceResponse:
type: object
properties:
networkinterfacenetwork:
type: object
$ref: '#/NetworkinterfaceNetwork'

View File

@@ -118,7 +118,6 @@ func InitHandlers(app *appsrv.Application) {
models.ServerSkuManager,
models.ExternalProjectManager,
models.NetworkInterfaceManager,
models.NetworkinterfacenetworkManager,
models.DBInstanceManager,
models.DBInstanceBackupManager,
models.DBInstanceParameterManager,
@@ -147,6 +146,7 @@ func InitHandlers(app *appsrv.Application) {
models.StoragecachedimageManager,
models.CloudproviderRegionManager,
models.DBInstanceNetworkManager,
models.NetworkinterfacenetworkManager,
} {
db.RegisterModelManager(manager)
handler := db.NewJointModelHandler(manager)

View File

@@ -0,0 +1,31 @@
// 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 modules
var (
Networkinterfacenetworks JointResourceManager
)
func init() {
Networkinterfacenetworks = NewJointComputeManager(
"networkinterfacenetwork",
"networkinterfacenetworks",
[]string{"Networkinterface_ID", "Networkinterface",
"Network_ID", "Network", "IP_Addr", "Primary"},
[]string{},
&Networkinterfaces,
&Networks)
registerCompute(&Networkinterfacenetworks)
}