内聚网络SDK

cohesivenet的Python项目详细描述


Python内聚网络SDK

contactcontact

内聚网络SDK是Python工具,提供从用Python编写的应用程序访问VNS3和VNS3:msapi。它还包括用于构建网络拓扑的通用管道和宏函数。在

支持的API版本

SDK将尽最大努力始终保持向后兼容。所有SDK版本都将支持从VNS3 v4.8.4开始的VNS3版本,以及从v2.1.1开始的VNS3:ms版本。在

cohesivenet==XVNS3 APIMS API
0.3.X4.8.4-4.11.12.1.1-2.3.5
0.1.35-0.2.X4.8.4-4.10.12.1.1-2.3.5
0.1.344.8.4-4.10.1N/A
0.1.334.8.4-4.9.2N/A
0.1.324.8.4-4.9.1N/A
0.1.0-314.8.4N/A

安装

你可以用PIP安装

pip install cohesivenet

(您可能需要使用根权限运行pipsudo pip install cohesivenet

或通过Setuptools安装。在

^{pr2}$

(或sudo python setup.py install为所有用户安装软件包)

使用

配置客户端

importcohesivenetfrompprintimportpprintconfiguration=cohesivenet.Configuration(host='https://[vns3-host]:8000',username='api',password='YOUR_PASSWORD',verify_ssl=False)# Local cert is used by default. Can add your own cert.# Configure HTTP basic authorization: basicAuthconfiguration.username='api'configuration.password='YOUR_PASSWORD'configuration.host="https://[vns3-host]:8000"# Create an instance of the API classvns3_controller=cohesivenet.VNS3Client(configuration)try:api_response=vns3_controller.config.get_config()pprint(api_response)exceptcohesivenet.ApiExceptionase:print("Exception fetching VNS3 Configuration get_config(): %s\n"%e)# ORfromcohesivenet.macrosimportconnectasvns3_connectvns3_host="55.55.55.55:8000"api_user="api"api_ps="test1234"vns3=vns3_connect.get_client(vns3_host,api_user,api_ps)config=vns3.config.get_config()print(config.response)

方法

每个子api可从VNS3Client实例获得,如下所示:

# VNS3vns3_client.access# Manage access urls and api tokensvns3_client.bgp# BGPApi for Border Gateway Protocol methodsvns3_client.config# ConfigurationApi provides VNS3 config methodsvns3_client.firewall# FirewallApi for configuring VNS3 policiesvns3_client.ipsec# IPsecApi for IPsec tunnel methodsvns3_client.interfaces# InterfacesApi for viewing VNS3 interfacesvns3_client.monitoring# MonitoringAlertingApivns3_client.network_edge_plugins# NetworkEdgePluginsApivns3_client.overlay_network# OverlayNetworkApi for managing the overlay networkvns3_client.peering# PeeringApi for peering VNS3 controllersvns3_client.routing# RoutingApi for configuring routingvns3_client.snapshots# SnapshotsApi for managing backupsvns3_client.sys_admin# SystemAdministrationApi for access and sys admin tasksvns3_client.licensing# LicensingApi for controller licensing # VNS3:msms_client.access# Provision short-lived access URLs or API keys for any VNS3 controller in your topologyms_client.admin# Configure VNS3:ms administration settings such as LDAP integrationms_client.vns3_management# Manage VNS3 controllers in your network topology, automating snapshots, HA and morems_client.cloud_monitoring# Configure and monitor your cloud by tracking cloud VPCs, virtual networks and VNS3 topologiesms_client.system# System configuration such as SSL, NTP hosts and remote supportms_client.backups# Configure backups for VNS3:ms and your controller snapshotsms_client.user# User management endpoints for configuring credentials

常见API模式:cohesivenet.macros

许多API调用被一起调用以配置拓扑或更新网络配置。更多宏将添加到 越来越简化VNS3拓扑的创建和配置。更多的文档即将发布。在

macros.admin# Admin operations typically applied to multiple controllers at oncemacros.config# configuring multiple clientsmacros.connect# connecting to clientsmacros.firewall# firewall operations like idempotently creating full firewallmacros.ipsec# ipsec operations like creating a tunnel and then a routemacros.network_edge_plugins# Manage container system network, images and running containersmacros.overlay_network# overlay network functions like calculating network segments of the overlaymacros.peering# topology peering operations like creating a peering mesh between controllersmacros.routing# Operations for updating routing in your topologymacros.state# Methods for fetching the state of your controller(s)

日志

可以将SDK配置为发出日志,以便更好地了解它在做什么。SDK支持信息、调试和错误日志记录。在

有两种方法可以启用它:

  1. 将环境变量COHESIVE_LOG_LEVEL设置为值debuginfo或{}

    $ exportCOHESIVE_LOG_LEVEL=debug
    
  2. 通过Python的日志模块启用它:

    importlogginglogging.basicConfig()logging.getLogger('cohesivenet').setLevel(logging.DEBUG)

作者

solutions@cohesive.net

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
JavaSpringMVC控制器测试打印结果JSON字符串   若catch语句返回,那个么为什么它最终会阻塞呢?   java Grails中servletContext在哪里可用?   java Jhipster:如何为现有项目启用多种语言   java异常评估SpringEL表达式:“#fields.hasErrors('something')”   java如何验证SeleniumWebDriver中的文本颜色?   java在绘图时使用JPanel坐标   java如何初始化spring启动到project?   java如何通过JDBC的PreparedStatement将UUID数组插入HyperSQL数据库   java修改JVM以跨线程序列化文件访问   Javascript到Java正则表达式   使用Java运行时调用aspell程序时出现字符集问题。getRuntime()。执行官   执行RDP时的java Sukuli按钮识别   java如何使用okhttp更改connect请求的标头   java无法创建Maven Eclipse项目