1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- from common.setting import Config
- import requests
- from common.utils import call_api
- class IpamApi:
- def apply_ip(self, segmentId, _openCLIENT="RIIL", mac=None, user=None, devIp=None, ifIdx=None, department=None):
- """
- 申请IP接口
- """
- endpoint = "/ipam/applyIpmacList"
- params = {
- "segmentId": segmentId,
- "mac": mac,
- "user": user,
- "devIp": devIp,
- "ifIdx": ifIdx,
- "department": department,
- "_openCLIENT": _openCLIENT
- }
- # Remove any None values
- params = {key: value for key, value in params.items() if value is not None}
- return call_api(endpoint, method="POST", params=params)
- def delete_by_ip(self, ip, _openCLIENT="RIIL"):
- """
- 根据IP删除基准表记录
- """
- endpoint = "/ipam/daleteByIp"
- params = {
- "ip": ip,
- "_openCLIENT": _openCLIENT
- }
- return call_api(endpoint, method="POST", params=params)
- def get_all_subnet_info(self, _openCLIENT="RIIL"):
- """
- 获取所有子网列表信息
- """
- endpoint = "/ipam/getIpmacAllSegmentList"
- params = {
- "_openCLIENT": _openCLIENT
- }
- return call_api(endpoint, method="POST", params=params)
- def get_ipmac_list(self, ip, _openCLIENT="RIIL", devIp=None, tableFlag=None):
- """
- 根据IP查询基准表IPMAC列表
- """
- endpoint = "/ipam/getIpmacList"
- params = {
- "ip": ip,
- "devIp": devIp,
- "tableFlag": tableFlag,
- "_openCLIENT": _openCLIENT
- }
- # Remove any None values
- params = {key: value for key, value in params.items() if value is not None}
- return call_api(endpoint, method="POST", params=params)
- def get_ipmac_location_list(self, _openCLIENT="RIIL"):
- """
- 获取网段列表信息
- """
- endpoint = "/ipam/getIpmacLocationList"
- params = {
- "_openCLIENT": _openCLIENT
- }
- return call_api(endpoint, method="POST", params=params)
- def get_ipmac_segment_list(self, locationId, _openCLIENT="RIIL"):
- """
- 根据网段获取可用子网列表信息
- """
- endpoint = "/ipam/getIpmacSegmentList"
- params = {
- "locationId": locationId,
- "_openCLIENT": _openCLIENT
- }
- return call_api(endpoint, method="POST", params=params)
- def modify_ipmac_info(self, ip, _openCLIENT="RIIL", mac=None, user=None, devIp=None, ifIdx=None, department=None):
- """
- 修改IP信息
- """
- endpoint = "/ipam/modifyIpmacInfo"
- params = {
- "ip": ip,
- "mac": mac,
- "user": user,
- "devIp": devIp,
- "ifIdx": ifIdx,
- "department": department,
- "_openCLIENT": _openCLIENT
- }
- # Remove any None values
- params = {key: value for key, value in params.items() if value is not None}
- return call_api(endpoint, method="POST", params=params)
|