radware vdirect服务器python rest客户端

vdirect_client的Python项目详细描述


http://www.radappliances.com/images/Software/vDirect/vdirect.jpg

基于rest的用于radware vdirect的python客户端

Radware vDirect

自动生成的基于rest的客户端

客户端功能:

  • 支持异步模式客户端的默认行为是等待请求的操作完成。这种行为可能是过分的。有关详细信息,请参阅本文件末尾的“常见问题解答”部分。
  • 支持vdirect服务器ha。当使用辅助VDirect IP地址配置时,当主VDirect服务器不可用时,客户端会自动尝试切换到辅助VDirect服务器实例。
  • API调用结果是一个包含四个条目的元组:
    • 条目1是一个HTTP响应代码例如:404(整数)
    • 条目2是一个http响应原因。例如:未找到。(字符串)
    • 条目3是作为字符串的响应。
    • 条目4通常是作为dict或dict列表的响应。

要了解要发送哪些有效负载及其预期的响应,开发人员应参考位于https://<;vdirect server ip address>;:2189/docs/api docs/的vdirect rest api文档。

基本客户端使用:

fromvdirect_clientimportrest_clientfromvdirect_client.rest_clientimportRestClientdefshow(result):printresult[rest_client.RESP_STATUS]printresult[rest_client.RESP_REASON]printresult[rest_client.RESP_STR]printresult[rest_client.RESP_DATA]ip=<vDirectserverIPaddress>user=<vDirectserverusername>password=<vDirectserverpassword>client=RestClient(ip,user,password)data={"tenants":[],"parameters":{"vipAddress":"1.1.1.1","ServerIps":["1.2.3.4","1.2.3.5"]},"devices":{"adc":{"deviceId":{"name":"Site1.vx2"}}}}show(client.runnable.run(data,'ConfigurationTemplate','caching_enh','run'))show(client.ha.get_ha_config())show(client.ha.get_ha_status())show(client.template.list())show(client.defensePro.list())

常见问题解答:

Q:What do RestClient init parameters mean?
A:RestClient init parameters description:
  • VDirect_IP:主/独立VDirect服务器IP地址(字符串)
  • vdirect_user:vdirect服务器用户名(字符串)
  • vdirect_password:vdirect服务器用户密码(字符串)
  • 等待:等待异步操作完成(布尔值)。默认值为true
  • secondary_vdirect_ip:辅助vdirect服务器IP地址(字符串)。与vDirect服务器HA对相关
  • https_端口:https vdirect服务器端口。默认值为2189(整数)
  • http_端口:http vdirect服务器端口。默认值为2188(整数)
  • 超时:等待异步操作完成的时间段(秒)(整数)。与“wait”参数设置为true的情况相关。默认值为60秒
  • https:使用https连接(布尔值),默认值为true
  • strict_http_results:如果设置为true,则仅接受成功的http状态代码,并引发4xx和5xx状态代码的异常。默认值为false
  • 验证:验证https连接上的ssl证书(布尔值)。默认值为true
  • < >:如果响应中存在布尔值,则自动获取结果(布尔值)。默认值为false
Q:How can I use vdirect_client in several places without passing init paramters each time?
A:You can use environment variables instead of any RestClient init parameter. Following is a map of init parameters and their respective environment variable names:
  • v直接ip-v直接ip
  • vdirect_用户-vdirect_用户
  • v直接密码-v直接密码
  • wait=v直接等待
  • 二级直接IP—二级直接IP
  • https_端口-VDIRECT_https_端口
  • http_端口-VDIRECT_http_端口
  • 超时-v直接超时
  • https-VDIRECT_https
  • strict_http_results-VDIRECT_strict_http_results
  • verify-vdirect_verify
  • 获取结果-vdirect获取结果
Q:How do I disable SSL certificates verification on HTTPS connection?
A:To disable SSL certificates verification, do one of the following: either set the RestClient init “verify” parameter to False, or set environment variable VDIRECT_VERIFY to False.
Q:Why do I see method names ending with numbers, e.g. “create0”, “list2”, “acquire0”, and others?
A:vdirect_client code is a generated code and those method names are the result of technical constraints.
Q:How do I know if my asynchronous operation has completed and succeeded?
A:See the vDirect REST API documentation at https://<vdirect server IP address>:2189/docs/api-docs/async.html.
Q:What is the difference between synchronous and asynchronous modes?
A:See the vDirect REST API documentation at https://<vdirect server IP address>:2189/docs/api-docs/async.html. Following is a python code sample demonstrating how to get the URI token from the operation response, and to periodically verify whether the operation has completed, and if completion was successful.
importjsonimportrequestsimporttimefromvdirect_clientimportrest_clientfromvdirect_client.rest_clientimportRestClientip=<vDirectserverIPaddress>user=<vDirectserverusername>password=<vDirectserverpassword># creating rest client with wait parameter set to Falseclient=RestClient(ip,user,password,wait=False)data={"tenants":[],"parameters":{"vipAddress":"1.1.1.1","ServerIps":["1.2.3.4","1.2.3.5"]},"devices":{"adc":{"deviceId":{"name":"Site1.vx2"}}}}# Requesting operation and getting the operation URI token for completion samplingret=client.runnable.run(data,'WorkflowTemplate','caching_enh','createWorkflow')token_uri=ret[rest_client.RESP_DATA]['uri']# Getting the URI and periodically check for completion and successcntr=0timeout=10whilecntr<timeout:time.sleep(1)cntr+=1ret=requests.get(token_uri,auth=(user,password),verify=False)content=json.loads(ret.content)ifcontent['complete']:breakifcontent['complete']:print("Operation completed")if(content['success']):print("Operation succeeded")else:print("Operation failed")else:print("Operation not completed")
Q:What is vDirect HA and how does it work?
A:vdirect_client supports vDirect server HA mode. For further information, see the vDirect documentation at https://<vdirect server IP address>:2189/docs/api-docs/examples/haServer/index.html.

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

推荐PyPI第三方库


热门话题
用于读取OBS写入的java打开文件   java使用XFire通过ssl使用Web服务   java如何查看幸存者空间中的对象   不使用ActionListener从按钮执行java代码   java仅当用户执行某个操作时,如何清除应用程序的历史记录?   json无法反序列化'java'的实例。lang.Long`out-of-START\u对象标记;在弹簧靴柱上   JavaPOJO到OpenApi定义   java时间戳格式不显示不同的值   java Android:如何从片段切换到主要活动?   用于步进计数器/健身应用程序的java循环进度条   java Log4j更改特定记录器实例的记录器级别   JAVA中实现连接的数据结构   java Mockito静态函数mock   未找到java辅助技术:org。侏儒。可访问性。阿特克拉珀   java仅当列表中没有类似项时才向ArrayList添加项   java如何使用docx4j在word中添加合并字段?