首頁>技術>

Radware提供了Alteon的python API,開發人員不再需要去呼叫Alteon 的restful API,只需要呼叫已經封裝好的API模組就可以。

安裝python SDK

pip3 install alteon-sdk

python版本要求 >3.6

Alteon版本支援:31.0.10.0, 32.2.2.0

SDK提供了三種方式來配置和管理Alteon:

1、透過Alteon client模組來提供直接配置和管理裝置的介面

from radware.alteon.client import AlteonClientfrom radware.alteon.beans.SlbNewCfgEnhRealServerTable import *server_configurator = ServerConfigurator(connection)alteon_client_params = dict(        validate_certs=False,        user='admin',        password='radware',        https_port=443,        server='192.168.199.151',        timeout=15,)client = AlteonClient(**alteon_client_params)# read bean from device:bean = SlbNewCfgEnhRealServerTable()bean.Index = 'real1'print(client.api.device.read(bean))# work with Configurators:client.api.mgmt.config.commit()print(client.api.mgmt.info.software)print(client.api.conf.type.dns_responders.read_all())server_params = ServerParameters()server_params.index = 'real1'server_params.ip_address = '3.3.3.3'client.api.conf.execute('deploy', server_params, dry_run=False, write_on_change=True, get_diff=True)

這種模式裡面有個Bean的概念和透過vDirect來進行配置的有點類似。

執行結果如下

/c/slb/real real1

dis

ipver v4

rip 3.3.3.3

2、透過特定的 Configurator來進行配置和管理

from radware.alteon.sdk.configurators.server import *from radware.alteon.client import AlteonClient,AlteonDeviceConnectionalteon_client_params = dict(       validate_certs=False,        user='admin',        password='radware',        https_port=443,        server='192.168.199.151',        timeout=15,)client = AlteonClient(**alteon_client_params)connection = AlteonDeviceConnection(**alteon_client_params)server_configurator = ServerConfigurator(connection)server_params = ServerParameters()server_params.index = 'real1'server_params.ip_address = '3.3.3.3'server_params.availability = 5server_params.server_ports = [56, 78]server_params.weight = 5server_params.server_type = EnumSlbRealServerType.remote_serverserver_params.state = EnumSlbRealServerState.enabledserver_configurator.deploy(server_params)

執行結果如下

/c/slb/real real2

ena

ipver v4

rip 3.3.3.3

type remote

weight 5

addport 56

addport 78

/c/slb/real real2/adv

avail 5

3、透過配置管理器來

from radware.sdk.configurator import DeviceConfigurator, DeviceConfigurationManagerfrom radware.alteon.sdk.configurators.ssl_key import SSLKeyConfiguratorfrom radware.alteon.client import AlteonClient,AlteonDeviceConnectionalteon_client_params = dict(        validate_certs=False,        user='admin',        password='admin',        https_port=443,        server='172.16.1.1',        timeout=15,)passphrase = "radware"connection = AlteonDeviceConnection(**alteon_client_params)ssl_key_configurator = SSLKeyConfigurator(connection)cfg_mng = DeviceConfigurationManager()result = cfg_mng.execute(ssl_key_configurator, DeviceConfigurator.READ_ALL, None, passphrase=passphrase)print(result.content_translate)

取得管理證書如下

[{'index': 'WebManagementCert', 'description': '', 'passphrase': None, 'content': '-----BEGIN RSA PRIVATE KEY-----\nProc-Type: 4,ENCRYPTED\nDEK-Info: DES-EDE3-CBC,267E73F27EEBA0F4\n\nNNl2qsIgpLREYJa4G2fRAf4fqspYOT7+m1LfrASuHy21ivaZNpH19uc7zWXZi21g\n6ja+cblXUznWaACpI7WmoiBl3424dBqGoQUw6AW7qZO+QupeFbtXudDniM6A71Al\nypDMABmdWBbBB8yEWS0gB6bXk+5ZcuTf4fnkYKyUDkvIZ7K+7BrVYvnrx6FRt7CZ\nv5CPNv3rxdG8qfOzi1tQfTDMQE79Ps0ommXfDyInwgNPu82cemYhqUYHvIndtql2\n1AtlOSLdJmbLmUgd0qwOWET6om1ZrjIK4Ec1/71EMkyesqcNbFT63CjPa03PxRu5\nL9ICk5CsrKETOw9bRHNvt29T1bZBw4XkQ1XowwtYCh8Eg/BfRd/k/W9OyjkI8/oH\nIQ0fMYzw4wXJTtNYeZ/bdAqKTk4sVrNuWnUFZah9ocBCopdWTtOTOwxQxNyIyQmO\nL0JJuBjKuOQTCFJkTb6XdfPtBaq7mUGQKVp1RKapQGi7LXJxSKUA3tYV/38PZVZ1\nQu7mDW3/Lk51h++VUrhU6+H4TABCSDPXNjWId4A5vpQD23i4PuYqwPnYg2y6D4t5\nijmXsq+Ylw/GxMmZcGNxByfoOdkhz3PJaSRdI6vF25HZJ+vwXC1/F8kqD41wVPxa\nhjR3POwabWW1HPCWiVYqShBgoB9DzvCR8gKwxtHU+bfgEGCl4JkURsbhX0LGhcw/\nq/+qXe5qhtLjTejX/X41WovpMqydAj++OTKvNV78TqsAqVdv4ZqYzU7xrfTC4Oqe\nu2Zm48rj2FKglXqyXkNeCKe7RpmvPWBJVZSHlGutFJBN6Mr6ieWsuHQaCo8VQZKY\nWNFcNc01rFCUCq56Ob2rwB9rZyngcVGNAxOxdOQ69Szei98wbUuhR2nBvWrju0d/\nY9+iHBMzNVZ3qlTyJ9dI9sO7UN6YnCZNls8yvo2C+eNFzNVwbN9KrA1UzMcoTC9Z\nMXEt8fAgkw84+78tDNQt5jz/UbVwyqEnHRY+HRrbDA3q/UPU93ggOLNM9zkMyRQc\n354dpg0PTG8tMucQ3q5HG0cdaHodpZJf0zfrscqpkyogaY+GJRsz3lIkTaUq8wAL\nU5g8Q5fodLDaWyFdIzxHrl4ZUgNFl/76ZdMNRMdbV83ZE6zJL1pW/0ikfQp5tpLQ\nYR7MepoVDF2N/ZcqdfN8k/Ed72KcDeABTncPT/vWdk66HYe0C0zK/mGwgiRc+OxS\ngnxfPqOsoFLFrl88LGdKr1AGfn9l9G6PpwR6gG3xO9N/cnapZimYGR/y8F02q9h8\nbVz/YthlwRXywEZV/jTMWsh5KsdN3pjCcNAFs7ZK2GM6zeJyREA7k2fx1X1x6z9G\nDv7MChzovAIuQDogeUefexOwG/AH1qDEMVJRoAJt1kmI8Hv4cjPkRAnXIZXaTpda\nNcRACfq57dYQHiZoWhQs8AUHQNVZRYv10FU7F1zQoQOUaafU1Dt2EtMpo9XNx3fG\nEHGRjJFp2iYHCiUFwyxE0W9oM4zHEKMBygUurYIwHCeLLgk2OMQmicc1zEzsohI9\nHYpeGcdbedpcCp7kImh1Uk9yBxYDoCuUhoZi7ugpHh+Cz2ta/jf9BQ==\n-----END RSA PRIVATE KEY-----\n'}]

(文章轉自“勤勞的存鋒”)

5
最新評論
  • BSA-TRITC(10mg/ml) TRITC-BSA 牛血清白蛋白改性標記羅丹明
  • 從“訊息佇列”到“服務匯流排”和“流處理平臺”