-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmain.py
More file actions
executable file
·130 lines (97 loc) · 3.35 KB
/
main.py
File metadata and controls
executable file
·130 lines (97 loc) · 3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import method_call
from base import AxError, AxAPI
import urllib2
from slb import ServiceGroup, ServiceGroupStats
from slb import RealServer, RealServerStats
from slb import VirtualServer, VirtualServerStats
from slb_template import *
from system import *
from gslb import *
from network import *
axapi_239 = method_call.AxApiContext("192.168.210.239", "user1", "aa&bb").authentication()
print axapi_239
#status = method_call.axapi_authentication()
#print method_call.AXAPI_SESSION_ID
intf = Interface()
intf.get(2)
#ints = Interface.getAll()
#for e in ints:
# print e
caches = TemplateCache.getAll()
for e in caches:
print e
print e.dump()
cache1 = TemplateCache(name="my_cache_templ1")
cache1.policy_list = [{"uri": "abc", "action": 1}, {"uri": "123", "action": 1}]
cache1.create()
ntp1 = SystemNtp(server="2.2.2.2", status=0)
ntp1.add()
ntp = SystemNtp(server="myntp_srv", status=1)
ntp.add()
ntp.status = 1
ntp.update()
ntp.delete()
templates = TemplateSmtp.getAll()
for e in templates:
print e
smtp = TemplateSmtp(name="my_smpt_temp3")
smtp.client_domain_switching_list = [{"client_domain": "domain1", "service_group": "sg1", "match_type": 0}]
smtp.create()
smtp.delete()
vip2 = VirtualServer.searchByName("vip2")
print vip2
vip_list = VirtualServer.getAll()
for e in vip_list:
print e
vip1 = VirtualServer(name="test_vip1", address="100.10.10.1")
vip1.vport_list = [{"port" : 80, "protocol": AxAPI.SVC_HTTP, "http_template": ""}]
vip1.create()
vip1.vport_list = [{"port" : 80, "protocol": AxAPI.SVC_HTTP, "status": AxAPI.STATUS_DISABLED}]
vip1.update()
vip1.delete()
print vip1
#axapi_241 = method_call.AxApiContext("192.168.210.241", "admin", "a10$pass").authentication()
rs_list = RealServer.getAll()
for e in rs_list:
print e
#axapi_239.switchContext()
s1 = RealServer(host="13.12.12.1", name="test1")
s1.port_list = [{"port_num" : 80, "protocol" : AxAPI.PROTO_TCP, "weight" : 2}, {"port_num" : 81, "protocol" : AxAPI.PROTO_TCP, "weight" : 3}]
s1.create()
print s1
s1.status = AxAPI.STATUS_DISABLED
s1.update()
s1.delete()
svc_s4 = ServiceGroupStats.getAll()
for e in svc_s4:
print e
svc_s1 = ServiceGroupStats.searchByName(name='g1')
print svc_s1
svc_s2 = ServiceGroupStats(name="abc")
print svc_s2
#svc_s2.status = 1
svc_group_list = ServiceGroup.getAll()
for svc in svc_group_list:
print svc
svc = ServiceGroup.searchByName("g1")
#print svc.name
#print svc.health_monitor
#print svc.member_list
svc2 = ServiceGroup()
svc2.name = "g3" #svc.name
svc2.protocol = svc.protocol
svc2.lb_method = AxAPI.LB_LEAST_CONNECTED_ON_SERVICE_PORT
svc2.member_list = [{"server":"1.1.1.2", "port": 80, "status": AxAPI.STATUS_ENABLED}, {"server":"1.1.1.3", "port": 80}]
svc2.create()
svc2.delete()
print svc2
svc3 = ServiceGroup(name='g5', protocol=AxAPI.PROTO_TCP, lb_method=AxAPI.LB_LEAST_REQ)
svc3.member_list = [{"server":"1.1.11.2", "port": 80}, {"server":"1.1.11.3", "port": 80}]
svc3.create()
svc4 = ServiceGroup(name='g5')
svc4.member_list = [{"server":"1.1.1.2", "port": 80, "status": AxAPI.STATUS_DISABLED}, {"server":"1.1.1.3", "port": 80, "status": AxAPI.STATUS_ENABLED}]
svc4.update()
svc4.delete()
print svc3
svc_s1 = ServiceGroupStats.searchByName(name='g1')
print svc_s1