feat:(设备管理服务接口)设备管理服务接口相关关键字提交
This commit is contained in:
142
01-TestCase/tsg_bfapi/device/DeviceTest.robot
Normal file
142
01-TestCase/tsg_bfapi/device/DeviceTest.robot
Normal file
@@ -0,0 +1,142 @@
|
||||
*** Settings ***
|
||||
Resource ../../../02-Keyword/tsg_bfapi/device/Device.robot
|
||||
Resource ../../../02-Keyword/tsg_bfapi/Common.robot
|
||||
Library json
|
||||
Library DateTime
|
||||
*** Test Cases ***
|
||||
Device-SN-Get-v1-00001
|
||||
Comment 查询SN列表
|
||||
${list} GetSNList
|
||||
log ${list}
|
||||
Device-SN-Info-Get-v1-00002
|
||||
Comment 查询SN信息
|
||||
${list} GetSNInfo CBT2201925000001
|
||||
log ${list}
|
||||
Device-Traffics-Get-v1-00003
|
||||
Comment 查询设备流量信息
|
||||
${data} GetDeviceDatas CBT2201925000001 2020-07-01 00:00:00 2020-07-08 00:00:00 traffics
|
||||
log ${data}
|
||||
|
||||
Device-CPU-Get-v1-00004
|
||||
Comment 查询设备CPU信息
|
||||
${data} GetDeviceDatas CBT2201925000001 2020-07-01 00:00:00 2020-07-08 00:00:00 cpu
|
||||
log ${data}
|
||||
|
||||
Device-Mem-Get-v1-00005
|
||||
Comment 查询设备内存信息
|
||||
${data} GetDeviceDatas CBT2201925000001 2020-07-01 00:00:00 2020-07-08 00:00:00 mem
|
||||
log ${data}
|
||||
|
||||
Device-Ports-Get-v1-00006
|
||||
Comment 查询设备端口信息
|
||||
${data} GetDeviceDatas CBT2201925000001 2020-07-01 00:00:00 2020-07-08 00:00:00 port
|
||||
|
||||
Device-Alarms-Get-v1-00007
|
||||
Comment 查询设备告警信息
|
||||
${data} GetDeviceDatas CBT2201925000001 2020-07-01 00:00:00 2020-07-08 00:00:00 alarm
|
||||
log ${data}
|
||||
|
||||
Device-Alarms-Delte-v1-00008
|
||||
Comment 清除设备告警信息
|
||||
${list} Create List CBT22019250000010000000003711305|192.168.40.175|wx|test
|
||||
${data} ClearAlarm ${list}
|
||||
log ${data}
|
||||
|
||||
Device-Alarms-Delte-v1-00009
|
||||
Comment 清除设备告警信息
|
||||
${list} Create List ${100}|192.168.40.175||
|
||||
${data} ClearAlarm ${list}
|
||||
log ${data}
|
||||
|
||||
Device-Alarms-Delte-v1-00010
|
||||
Comment 清除设备告警信息
|
||||
${list} Create List CBT22019250000010000000003711309|192.168.40.175|${EMPTY}|${EMPTY}
|
||||
${data} ClearAlarm ${list}
|
||||
log ${data}
|
||||
|
||||
Device-Chassis-Get-v1-00011
|
||||
Comment 获取设备板卡信息
|
||||
${data} GetDeviceChassis CBT2201925000001
|
||||
log ${data}
|
||||
|
||||
Device-ClusterStatus-Get-v1-00012
|
||||
Comment 获取集群设备状态
|
||||
${data} GetClusterStatus
|
||||
log ${data}
|
||||
|
||||
Device-Tag-Get-v1-00013
|
||||
Comment 获取设备标签
|
||||
${data} GetDeviceTag ${EMPTY} ${EMPTY} ${EMPTY} ${EMPTY} ${EMPTY} ${EMPTY}
|
||||
log ${data}
|
||||
|
||||
Device-Tag-Post-v1-00014
|
||||
Comment 新增设备标签
|
||||
${data} AddDeviceTag 4|wx-test001,|wx-test-002
|
||||
log ${data}
|
||||
|
||||
Device-Tag-Refer-Get-v1-00015
|
||||
Comment 获取设备标签引用
|
||||
${data} GetDeviceTagRefer
|
||||
log ${data}
|
||||
|
||||
Device-Ntp-Get-v1-00016
|
||||
Comment ntp查询
|
||||
${data} GetNtpInfo
|
||||
log ${data}
|
||||
|
||||
Device-Ntp-Edit-v1-00017
|
||||
Comment ntp修改
|
||||
${data} EditNtpInfo 192.168.10.108
|
||||
log ${data}
|
||||
|
||||
Tsg-Oam-Get-v1-00018
|
||||
Comment 查询oam硬件板卡配置信息
|
||||
${data} TsgOamRedirect /cm/chassis/192.168.40.175 GET application/x-www-form-urlencoded ${EMPTY}
|
||||
log ${data}
|
||||
|
||||
Tsg-Oam-Get-v1-00019
|
||||
Comment 查询oam硬件FRU信息
|
||||
${data} TsgOamRedirect /cm/FRU/192.168.40.175/0 GET application/x-www-form-urlencoded ${EMPTY}
|
||||
log ${data}
|
||||
|
||||
Tsg-Oam-Post-v1-00019
|
||||
Comment 设置oam硬件hostname
|
||||
${dict} Create Dictionary chassis_ip=192.168.40.175 sled_id=0 hostname=test
|
||||
${data} TsgOamRedirect /cm/hostname POST application/x-www-form-urlencoded ${dict}
|
||||
log ${data}
|
||||
|
||||
Tsg-Oam-Post-v1-00020
|
||||
Comment 更新ntp server设置
|
||||
${dict} Create Dictionary chassis_ip=192.168.40.175 sled_id=0
|
||||
${list} Create List ${dict}
|
||||
${data} TsgOamRedirect /cm/softreboot POST application/x-www-form-urlencoded ${dict}
|
||||
log ${data}
|
||||
Tsg-Oam-Snmp-Update-00021
|
||||
Comment 更新SNMP配置
|
||||
${dict} Create Dictionary chassis_ip=192.168.40.175 snmp_version=v2
|
||||
${response} UpdateSnmp ${dict}
|
||||
log ${response}
|
||||
|
||||
Tsg-Oam-Snmp-Update-00022
|
||||
Comment 更新SNMP配置
|
||||
${dict} Create Dictionary chassis_ip=192.168.40.175 snmp_version=v3 users=wangxin|wangxin123|add,wangxin1|wangxin123|add
|
||||
${response} UpdateSnmp ${dict}
|
||||
log ${response}
|
||||
|
||||
Tsg-Oam-Snmp-Update-00023
|
||||
Comment 更新SNMP配置
|
||||
${dict} Create Dictionary chassis_ip=192.168.40.175 snmp_version=v3 users=wangxin|wangxin123|add
|
||||
${response} UpdateSnmp ${dict}
|
||||
log ${response}
|
||||
Tsg-Oam-Snmp-Update-00024
|
||||
Comment 更新SNMP配置
|
||||
${dict} Create Dictionary chassis_ip=192.168.40.175 snmp_version=v2
|
||||
${dict1} Create Dictionary chassis_ip=192.168.40.175 snmp_version=v3 users=wangxin|wangxin123|add
|
||||
${list} Create List ${dict} ${dict1}
|
||||
${response} UpdateSnmp ${list}
|
||||
log ${response}
|
||||
|
||||
Tsg-Oam-Snmp-Update-00025
|
||||
Comment 更新SNMP配置
|
||||
${response} UpdateSnmpBatch v3 wangxin wangxin123
|
||||
log ${response}
|
||||
@@ -124,7 +124,8 @@ Dictionary-To-QueryParams
|
||||
[Documentation]
|
||||
... 接收get参数字典,转换为请求字符串
|
||||
[Arguments] ${params}
|
||||
${paramsString} = Set Variable ${EMPTY}
|
||||
${paramsString} = Set Variable ${EMPTY}
|
||||
Run Keyword And Return If "${params}" == "${EMPTY}" Set Variable ${EMPTY}
|
||||
FOR ${key} IN @{params}
|
||||
${value} = Get From Dictionary ${params} ${key}
|
||||
${paramStr} = Catenate SEPARATOR=\= ${key} ${value}
|
||||
@@ -195,4 +196,36 @@ BaseGetRequestReturnBinary
|
||||
${response} Get Request api ${requestUri}?${dataString}
|
||||
log return data =${response}
|
||||
Should Be Equal As Strings ${response.status_code} 200
|
||||
[Return] ${response.content}
|
||||
[Return] ${response.content}
|
||||
|
||||
BaseFormEditRequest
|
||||
[Arguments] ${requestUri} ${data} ${apiVersion}
|
||||
${headers} set variable {"Authorization":"${token}","Content-Type":"application/x-www-form-urlencoded"}
|
||||
create session api http://${host}:${port}/${apiVersion} ${headers}
|
||||
${response}= Put Request api ${requestUri} data=${data}
|
||||
log return data =${response}
|
||||
Should Be Equal As Strings ${response.status_code} 200
|
||||
${response} to json ${response.content}
|
||||
[Return] ${response}
|
||||
BaseFormPostRequest
|
||||
[Arguments] ${requestUri} ${data} ${apiVersion}
|
||||
${headers} set variable {"Authorization":"${token}","Content-Type":"application/x-www-form-urlencoded"}
|
||||
create session api http://${host}:${port}/${apiVersion} ${headers}
|
||||
${response}= Post Request api ${requestUri} data=${data}
|
||||
log return data =${response}
|
||||
Should Be Equal As Strings ${response.status_code} 200
|
||||
${response} to json ${response.content}
|
||||
[Return] ${response}
|
||||
|
||||
OamRequest
|
||||
[Arguments] ${requestUri} ${path} ${method} ${contentType} ${data}
|
||||
${headers} set variable {"Authorization":"${token}","Content-Type":"${contentType}","path":"${path}"}
|
||||
create session api http://${host}:${port} ${headers}
|
||||
${response} Run Keyword If "${method}" == "GET" Get Request api ${requestUri}?${data}
|
||||
... ELSE IF "${method}" == "POST" Post Request api ${requestUri} data=${data}
|
||||
... ELSE IF "${method}" == "PUT" Put Request api ${requestUri} data=${data}
|
||||
... ELSE IF "${method}" == "DELETE" Delete Request api ${requestUri} data=${data}
|
||||
... ELSE Set Variable ${EMPTY}
|
||||
Should Be Equal As Strings ${response.status_code} 200
|
||||
${response} to json ${response.content}
|
||||
[Return] ${response}
|
||||
252
02-Keyword/tsg_bfapi/device/Device.robot
Normal file
252
02-Keyword/tsg_bfapi/device/Device.robot
Normal file
@@ -0,0 +1,252 @@
|
||||
*** Settings ***
|
||||
Library Collections
|
||||
Library RequestsLibrary
|
||||
Library json
|
||||
Resource ../../../03-Variable/BifangApiVariable.txt
|
||||
Resource ../../../02-Keyword/tsg_bfapi/policy_file_interface/FunctionalKeywords.robot
|
||||
Library Collections
|
||||
Resource ../Common.robot
|
||||
*** Variables ***
|
||||
${deviceUrl} /device
|
||||
${listSplitor} ,
|
||||
${itemSplitor} |
|
||||
*** Keywords ***
|
||||
GetSNList
|
||||
[Documentation]
|
||||
... 设备SN列表查询
|
||||
[Arguments]
|
||||
${response} BaseFormRequest ${deviceUrl}/sn ${EMPTY} ${version}
|
||||
${rescode} Set Variable ${response['code']}
|
||||
Should Be Equal As Strings ${rescode} 200
|
||||
[Return] ${response['data']['list']}
|
||||
|
||||
GetSNInfo
|
||||
[Documentation]
|
||||
... 设备SN信息查询
|
||||
[Arguments] ${sn}
|
||||
${response} BaseFormRequest ${deviceUrl} sn=${sn} ${version}
|
||||
${rescode} Set Variable ${response['code']}
|
||||
Should Be Equal As Strings ${rescode} 200
|
||||
[Return] ${response['data']['list']}
|
||||
|
||||
GetDeviceDatas
|
||||
[Documentation]
|
||||
... 设备信息数据查询
|
||||
... SN=${SN}
|
||||
... startTime YYYY-MM-DD HH:mm:ss
|
||||
... endTime YYYY-MM-DD HH:mm:ss
|
||||
... dataType,数据类型,可为:traffics,cpu,mem,port,alarm
|
||||
[Arguments] ${SN} ${startTime} ${endTime} ${dataType}
|
||||
Should Not Be Empty ${SN}
|
||||
Should Not Be Empty ${startTime}
|
||||
Should Not Be Empty ${endTime}
|
||||
Should Not Be Empty ${dataType}
|
||||
${dict} Create Dictionary SN=${SN} startTime=${startTime} endTime=${endTime}
|
||||
${queryParams} Dictionary-To-QueryParams ${dict}
|
||||
${response} BaseGetRequestForV2 ${deviceUrl}/${dataType} ${queryParams} ${version}
|
||||
${rescode} Set Variable ${response['code']}
|
||||
Should Be Equal As Strings ${rescode} 200
|
||||
[Return] ${response['data']}
|
||||
|
||||
ClearAlarm
|
||||
[Documentation]
|
||||
... 清除设备告警数据
|
||||
... params为一个list
|
||||
... list中一个单元的结构如下:
|
||||
... ${alarm_id}|${chassis_ip}|${operated_by}|${notes}
|
||||
... alarm_id,chassis_ip不能为空
|
||||
[Arguments] ${params}
|
||||
${list} Create List
|
||||
FOR ${param} IN @{params}
|
||||
${param} Evaluate re.split('[${itemSplitor}]', '${param}') re
|
||||
Should Not Be Empty ${param[0]}
|
||||
Should Not Be Empty ${param[1]}
|
||||
#${alarm_id} Evaluate int(${param[0]})
|
||||
${dict} Create Dictionary alarm_id=${param[0]} chassis_ip=${param[1]}
|
||||
Run Keyword If "${param[2]}" != "${EMPTY}" Set To Dictionary ${dict} operated_by=${param[2]}
|
||||
Run Keyword If "${param[3]}" != "${EMPTY}" Set To Dictionary ${dict} notes=${param[3]}
|
||||
Append To List ${list} ${dict}
|
||||
END
|
||||
${json} json.Dumps ${list}
|
||||
${response} BaseDeleteRequest /${version}${deviceUrl}/alarm ${json}
|
||||
${rescode} Set Variable ${response['code']}
|
||||
Should Be Equal As Strings ${rescode} 200
|
||||
[Return] ${rescode}
|
||||
|
||||
GetDeviceChassis
|
||||
[Documentation]
|
||||
... 获取设备板卡信息
|
||||
... sn sn号
|
||||
[Arguments] ${sn}
|
||||
Should Not Be Empty ${sn}
|
||||
${response} BaseGetRequestForV2 ${deviceUrl}/chassis sn=${sn} ${version}
|
||||
${rescode} Set Variable ${response['code']}
|
||||
Should Be Equal As Strings ${rescode} 200
|
||||
[Return] ${response['data']}
|
||||
|
||||
GetClusterStatus
|
||||
[Documentation]
|
||||
... 获取集群设备状态
|
||||
[Arguments]
|
||||
${response} BaseGetRequestForV2 ${deviceUrl}/clusterStatus ${EMPTY} ${version}
|
||||
${rescode} Set Variable ${response['code']}
|
||||
Should Be Equal As Strings ${rescode} 200
|
||||
[Return] ${response['data']}
|
||||
|
||||
GetDeviceTag
|
||||
[Documentation]
|
||||
... 查询设备标签信息
|
||||
[Arguments] ${pageSize} ${pageNo} ${id} ${tagType} ${tagName} ${pid}
|
||||
${dict} Create Dictionary
|
||||
Run Keyword If "${pageSize}" != "${EMPTY}" Set To Dictionary ${dict} pageSize=${pageSize}
|
||||
Run Keyword If "${pageNo}" != "${EMPTY}" Set To Dictionary ${dict} pageNo=${pageNo}
|
||||
Run Keyword If "${id}" != "${EMPTY}" Set To Dictionary ${dict} id=${id}
|
||||
Run Keyword If "${tagType}" != "${EMPTY}" Set To Dictionary ${dict} tagType=${tagType}
|
||||
Run Keyword If "${tagName}" != "${EMPTY}" Set To Dictionary ${dict} tagName=${tagName}
|
||||
Run Keyword If "${pid}" != "${EMPTY}" Set To Dictionary ${dict} pid=${pid}
|
||||
${queryParams} Dictionary-To-QueryParams ${dict}
|
||||
${response} BaseGetRequestForV2 /deviceTag ${queryParams} ${version}
|
||||
${rescode} Set Variable ${response['code']}
|
||||
Should Be Equal As Strings ${rescode} 200
|
||||
[Return] ${response['data']['list']}
|
||||
|
||||
AddDeviceTag
|
||||
[Documentation]
|
||||
... 新增设备标签
|
||||
... params结构如下:
|
||||
... pid1|tagName1,pid2|tagName2
|
||||
[Arguments] ${params}
|
||||
Should Not Be Empty ${params}
|
||||
${list} Evaluate re.split('[${listSplitor}]', '${params}') re
|
||||
${dataList} Create List
|
||||
FOR ${param} IN @{list}
|
||||
${paramList} Evaluate re.split('[${itemSplitor}]', '${param}') re
|
||||
${dict} Create Dictionary tagName=${paramList[1]}
|
||||
${pid} Run Keyword If "${paramList[0]}" != "${EMPTY}" Evaluate int(${paramList[0]})
|
||||
... ELSE Set Variable ${EMPTY}
|
||||
Run Keyword If "${pid}" != "${EMPTY}" Set To Dictionary ${dict} pid=${pid}
|
||||
Append To List ${dataList} ${dict}
|
||||
END
|
||||
${dict} Create Dictionary list=${dataList}
|
||||
${json} json.Dumps ${dict}
|
||||
${response} BasePostRequestForV2 /deviceTag ${json} ${version}
|
||||
${rescode} Set Variable ${response['code']}
|
||||
Should Be Equal As Strings ${rescode} 200
|
||||
[Return] ${rescode}
|
||||
|
||||
GetDeviceTagRefer
|
||||
[Documentation]
|
||||
... 获取设备标签引用
|
||||
[Arguments]
|
||||
${response} BaseGetRequestForV2 /deviceTag/refer ${EMPTY} ${version}
|
||||
${rescode} Set Variable ${response['code']}
|
||||
Should Be Equal As Strings ${rescode} 200
|
||||
[Return] ${response['data']}
|
||||
|
||||
GetNtpInfo
|
||||
[Documentation]
|
||||
... ntp信息查询
|
||||
[Arguments]
|
||||
${response} BaseFormRequest /ntp ${EMPTY} ${version}
|
||||
${rescode} Set Variable ${response['code']}
|
||||
Should Be Equal As Strings ${rescode} 200
|
||||
[Return] ${response['data']}
|
||||
|
||||
EditNtpInfo
|
||||
[Documentation]
|
||||
... ntp信息修改
|
||||
[Arguments] ${serverIP}
|
||||
${dict} Create Dictionary serverIP=${serverIP}
|
||||
${response} BaseFormEditRequest /ntp ${dict} ${version}
|
||||
${rescode} Set Variable ${response['code']}
|
||||
Should Be Equal As Strings ${rescode} 200
|
||||
[Return] ${response['data']}
|
||||
|
||||
TsgOamRedirect
|
||||
[Documentation]
|
||||
... oam转发调用
|
||||
... path:请求转发oam的路径
|
||||
... method:http请求方式,大写
|
||||
... params: 请求参数
|
||||
[Arguments] ${path} ${method} ${contentType} ${params}
|
||||
${params} Run Keyword If "${method}" == "GET" Dictionary-To-QueryParams ${params}
|
||||
... ELSE IF "${contentType}"=="application/json" json.Dumps ${params}
|
||||
... ELSE Set Variable ${params}
|
||||
${response} OamRequest /${version}/tsgoam ${path} ${method} ${contentType} ${params}
|
||||
${rescode} Set Variable ${response['code']}
|
||||
Should Be Equal As Strings ${rescode} 200
|
||||
[Return] ${response['data']}
|
||||
UpdateSnmp
|
||||
[Documentation]
|
||||
... 更新SNMP配置
|
||||
... params 支持list或者dict
|
||||
... params参数
|
||||
... chassis_ip 必填
|
||||
... snmp_version 必填
|
||||
... users: user1|pwd1|operation1,user2|pwd2|operation2
|
||||
[Arguments] ${params}
|
||||
${type} Evaluate type(${params})
|
||||
${dictOrList} Run Keyword If "${type}"=="<class 'dict'>" ProcessUpdateSnmpBody ${params}
|
||||
... ELSE UpdateSnmpList ${params}
|
||||
${data} TsgOamRedirect /cm/snmp/ POST application/json ${dictOrList}
|
||||
[Return] ${data}
|
||||
UpdateSnmpBatch
|
||||
[Documentation]
|
||||
... 批量更新SNMP配置
|
||||
[Arguments] ${snmp_version} ${user} ${pwd}
|
||||
${dict} Create Dictionary snmp_version=${snmp_version} user=${user} pwd=${pwd}
|
||||
${response} BaseFormPostRequest /tsgoam/snmpBatch ${dict} ${version}
|
||||
${rescode} Set Variable ${response['code']}
|
||||
Should Be Equal As Strings ${rescode} 200
|
||||
[Return] ${response['data']}
|
||||
UpdateSnmpList
|
||||
[Documentation]
|
||||
... 更新SNMP配置
|
||||
... params参数list
|
||||
[Arguments] ${params}
|
||||
${list} Create List
|
||||
FOR ${param} IN @{params}
|
||||
${dict} ProcessUpdateSnmpBody ${param}
|
||||
Append To List ${list} ${dict}
|
||||
END
|
||||
[Return] ${list}
|
||||
ProcessUpdateSnmpBody
|
||||
[Documentation]
|
||||
... 更新SNMP配置
|
||||
... params参数
|
||||
... chassis_ip 必填
|
||||
... snmp_version 必填
|
||||
... users: user1|pwd1|operation1,user2|pwd2|operation2
|
||||
[Arguments] ${params}
|
||||
${return} ${chassis_ip} Run Keyword And Ignore Error Get From Dictionary ${params} chassis_ip
|
||||
${chassis_ip} Run Keyword If "${return}" == "FAIL" Set Variable ${EMPTY}
|
||||
... ELSE Set Variable ${chassis_ip}
|
||||
${return} ${snmp_version} Run Keyword And Ignore Error Get From Dictionary ${params} snmp_version
|
||||
${snmp_version} Run Keyword If "${return}" == "FAIL" Set Variable ${EMPTY}
|
||||
... ELSE Set Variable ${snmp_version}
|
||||
${return} ${users} Run Keyword And Ignore Error Get From Dictionary ${params} users
|
||||
${users} Run Keyword If "${return}" == "FAIL" Set Variable ${EMPTY}
|
||||
... ELSE Set Variable ${users}
|
||||
|
||||
Should Not Be Empty ${chassis_ip}
|
||||
Should Not Be Empty ${snmp_version}
|
||||
|
||||
${users} Run Keyword If "${snmp_version}" == "v2" Create List
|
||||
... ELSE ProcessUserList ${users}
|
||||
${dict} Create Dictionary chassis_ip=${chassis_ip} snmp_version=${snmp_version} users=${users}
|
||||
[Return] ${dict}
|
||||
ProcessUserList
|
||||
[Documentation]
|
||||
... 处理用户
|
||||
[Arguments] ${userList}
|
||||
${users} Create List
|
||||
${userList} Evaluate re.split('[${listSplitor}]', '${userList}') re
|
||||
FOR ${user} IN @{userList}
|
||||
${user} Evaluate re.split('[${itemSplitor}]', '${user}') re
|
||||
Should Not Be Empty ${user[2]}
|
||||
${dict} Create Dictionary operation=${user[2]}
|
||||
Run Keyword If "${user[0]}" != "${EMPTY}" Set To Dictionary ${dict} user=${user[0]}
|
||||
Run Keyword If "${user[1]}" != "${EMPTY}" Set To Dictionary ${dict} pwd=${user[1]}
|
||||
Append To List ${users} ${dict}
|
||||
END
|
||||
[Return] ${users}
|
||||
Reference in New Issue
Block a user