与Arista CloudVision交互的模块
rcvpapi的Python项目详细描述
CloudVision API(RCVP API)
这是一个自定义的cvp api包装器。
支持
注意在处理生产环境之前,始终测试实验室部署。尤其是在不同版本的cvp和rcvp api之间。
这已经在CVP版本上测试过:
- 2018.2.2
- 2018.2.3
- 2018.2.4
- 2018.2.5
使用量
注释 以下文件不完整,正在进行中。此模块比文档中的功能更多。有了正确的补充数据和步骤,它可以配置cvp从零到功能。
使用python包索引安装
pip install rcvpapi
初始设置和使用
from rcvpapi.rcvpapi import *
# Create connection to CloudVision
cvp_cnt = CVPCON(cvp_ip,cvp_user,cvp_user_pwd)
# Check current CloudVision session ID
cvp_cnt.SID
# Get the current CVP Version
cvp_ver = cvp_cnt.checkVersion()
# Logout/End session
cvp_cnt.execLogout()
# Save topology
cvp_cnt.saveTopology()
设备/库存
# Get all provisioned devices
cur_inv = cvp_cnt.getDeviceInventory()
# Adds new devices to inventory/provisioning
cvp_cnt.addDeviceInventory(['10.0.0.1','10.0.0.2'])
任务
# Get a list of any Task type
cur_tasks = cvp_cnt.getAllTasks("Pending")
# Execute all tasks
cvp_cnt.execAllTasks("Pending")
# Get status of a task
tsk_stat = cvp_cnt.getTaskStatus(task_id)
配置
# Import static configlet
cvp_cnt.impConfiglet("static",configlet_name,configlet_data)
# Import configlet builder
cvp_cnt.impCofniglet("builder",configlet_name,configlet_data,configlet_form_data)
# Get all Configlets
exist_configlets = cvp_cnt.getConfiglets()
# Get a Configlet by Name
ex_cfg = cvp_cnt.getConfigletByName("Base_Authentication")
快照
# Get all configured snapshots
cvp_cnt.snapshots
# Add a new snapshot
# Parameters:
# snap_name = Name of the snapshot (required)
# snap_cmds = Array of all commands to be included in snapshot (required)
# snap_devices = Array of any devices to be included on the snapshot (optional)
cvp_cnt.createSnapshot(snap_name,snap_cmds,snap_devices)
容器
# Get all containers
ex_cont = cvp_cnt.getAllContainers()
# Add a new container
cvp_cnt.addContainer(new_cont_name,parent_cont_name)
from rcvpapi.rcvpapi import *
# Create connection to CloudVision
cvp_cnt = CVPCON(cvp_ip,cvp_user,cvp_user_pwd)
# Check current CloudVision session ID
cvp_cnt.SID
# Get the current CVP Version
cvp_ver = cvp_cnt.checkVersion()
# Logout/End session
cvp_cnt.execLogout()
# Save topology
cvp_cnt.saveTopology()
# Get all provisioned devices
cur_inv = cvp_cnt.getDeviceInventory()
# Adds new devices to inventory/provisioning
cvp_cnt.addDeviceInventory(['10.0.0.1','10.0.0.2'])
任务
# Get a list of any Task type
cur_tasks = cvp_cnt.getAllTasks("Pending")
# Execute all tasks
cvp_cnt.execAllTasks("Pending")
# Get status of a task
tsk_stat = cvp_cnt.getTaskStatus(task_id)
配置
# Import static configlet
cvp_cnt.impConfiglet("static",configlet_name,configlet_data)
# Import configlet builder
cvp_cnt.impCofniglet("builder",configlet_name,configlet_data,configlet_form_data)
# Get all Configlets
exist_configlets = cvp_cnt.getConfiglets()
# Get a Configlet by Name
ex_cfg = cvp_cnt.getConfigletByName("Base_Authentication")
快照
# Get all configured snapshots
cvp_cnt.snapshots
# Add a new snapshot
# Parameters:
# snap_name = Name of the snapshot (required)
# snap_cmds = Array of all commands to be included in snapshot (required)
# snap_devices = Array of any devices to be included on the snapshot (optional)
cvp_cnt.createSnapshot(snap_name,snap_cmds,snap_devices)
容器
# Get all containers
ex_cont = cvp_cnt.getAllContainers()
# Add a new container
cvp_cnt.addContainer(new_cont_name,parent_cont_name)
# Import static configlet
cvp_cnt.impConfiglet("static",configlet_name,configlet_data)
# Import configlet builder
cvp_cnt.impCofniglet("builder",configlet_name,configlet_data,configlet_form_data)
# Get all Configlets
exist_configlets = cvp_cnt.getConfiglets()
# Get a Configlet by Name
ex_cfg = cvp_cnt.getConfigletByName("Base_Authentication")
# Get all configured snapshots
cvp_cnt.snapshots
# Add a new snapshot
# Parameters:
# snap_name = Name of the snapshot (required)
# snap_cmds = Array of all commands to be included in snapshot (required)
# snap_devices = Array of any devices to be included on the snapshot (optional)
cvp_cnt.createSnapshot(snap_name,snap_cmds,snap_devices)
# Get all containers
ex_cont = cvp_cnt.getAllContainers()
# Add a new container
cvp_cnt.addContainer(new_cont_name,parent_cont_name)