acos_client 0.1.0.pre.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/README.md +39 -0
- data/Rakefile +1 -0
- data/acos_client.gemspec +29 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/acos_client/application.rb +91 -0
- data/lib/acos_client/client.rb +58 -0
- data/lib/acos_client/errors.rb +56 -0
- data/lib/acos_client/tools.rb +12 -0
- data/lib/acos_client/v21/action.rb +36 -0
- data/lib/acos_client/v21/axapi_http.rb +142 -0
- data/lib/acos_client/v21/base.rb +63 -0
- data/lib/acos_client/v21/config_file.rb +26 -0
- data/lib/acos_client/v21/device_info.rb +22 -0
- data/lib/acos_client/v21/ha.rb +29 -0
- data/lib/acos_client/v21/log.rb +117 -0
- data/lib/acos_client/v21/monkey_patch_ssl.rb +22 -0
- data/lib/acos_client/v21/nat.rb +53 -0
- data/lib/acos_client/v21/network.rb +167 -0
- data/lib/acos_client/v21/partition.rb +53 -0
- data/lib/acos_client/v21/responses.rb +170 -0
- data/lib/acos_client/v21/session.rb +61 -0
- data/lib/acos_client/v21/slb/aflex.rb +89 -0
- data/lib/acos_client/v21/slb/class_list.rb +67 -0
- data/lib/acos_client/v21/slb/hm.rb +122 -0
- data/lib/acos_client/v21/slb/init.rb +53 -0
- data/lib/acos_client/v21/slb/member.rb +36 -0
- data/lib/acos_client/v21/slb/port.rb +52 -0
- data/lib/acos_client/v21/slb/server.rb +65 -0
- data/lib/acos_client/v21/slb/service_group.rb +75 -0
- data/lib/acos_client/v21/slb/template/init.rb +28 -0
- data/lib/acos_client/v21/slb/template/persistence.rb +79 -0
- data/lib/acos_client/v21/slb/template/template_ssl.rb +56 -0
- data/lib/acos_client/v21/slb/virtual_port.rb +87 -0
- data/lib/acos_client/v21/slb/virtual_server.rb +62 -0
- data/lib/acos_client/v21/slb/virtual_service.rb +61 -0
- data/lib/acos_client/v21/system.rb +84 -0
- data/lib/acos_client/version.rb +3 -0
- data/lib/acos_client.rb +13 -0
- metadata +154 -0
@@ -0,0 +1,89 @@
|
|
1
|
+
#from acos_client import multipart
|
2
|
+
require 'acos_client/v21/base'
|
3
|
+
|
4
|
+
module AcosClient
|
5
|
+
module V21
|
6
|
+
#
|
7
|
+
# Todo: implement multipart upload
|
8
|
+
#
|
9
|
+
class Aflex < AcosClient::V21::BaseV21
|
10
|
+
|
11
|
+
|
12
|
+
def _set(action, name, aflex, **opts)
|
13
|
+
# m = multipart.Multipart
|
14
|
+
# m.file(name="upload_aflex", filename=name, value=aflex)
|
15
|
+
# ct, payload = m.get
|
16
|
+
# kwargs.update(payload=payload, headers={'Content-Type': ct})
|
17
|
+
# self._post(action, **opts)
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
def upload(name, aflex, **opts)
|
22
|
+
self._set('slb.aflex.upload', name, aflex, **opts)
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
def update(name, aflex, **opts)
|
27
|
+
self._set('slb.aflex.update', name, aflex, **opts)
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
def all(**opts)
|
32
|
+
self._get('slb.aflex.getAll')
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
def get(name, **opts)
|
37
|
+
self._post('slb.aflex.search', params: {:name => name}, **opts)
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
def download(name, **opts)
|
42
|
+
self._post('slb.aflex.download', params: {:name => name}, **opts)
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
def delete(name, **opts)
|
47
|
+
self._post('slb.aflex.delete', params: {:name => name}, **opts)
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
def stats(name, **opts)
|
52
|
+
self._post('slb.aflex.fetchStatistics', params: {:name => name}, **opts)
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
def all_stats(**opts)
|
57
|
+
self._get('slb.aflex.fetchAllstatistics', **opts)
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
def clear_stats(name, **opts)
|
62
|
+
self._post('slb.aflex.slb.aflex.clearStatistics', params: {:name => name}, **opts)
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
def clear_all_stats(**opts)
|
67
|
+
self._post('slb.aflex.clearAllStatistics', **opts)
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
def clear_events(name, event_name, **opts)
|
72
|
+
params = {
|
73
|
+
:aflex_event => {
|
74
|
+
:name => name,
|
75
|
+
:event_name => event_name
|
76
|
+
}
|
77
|
+
}
|
78
|
+
self._post('slb.aflex.clearEvents', params: params, **opts)
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
def clear_all_events(**opts)
|
83
|
+
self._post('slb.aflax.clearAllEvents', **opts)
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'json'
|
2
|
+
#require 'regexp'
|
3
|
+
require 'acos_client/v21/base'
|
4
|
+
|
5
|
+
|
6
|
+
module AcosClient
|
7
|
+
module V21
|
8
|
+
#
|
9
|
+
# ToDo: add more types
|
10
|
+
# ToDo: implement multipart upload
|
11
|
+
#
|
12
|
+
|
13
|
+
class ClassList < AcosClient::V21::BaseV21
|
14
|
+
|
15
|
+
IPV4 = 2
|
16
|
+
|
17
|
+
def _fix_json(data)
|
18
|
+
# p = re.compile(r '(?<=[^:{\[,])"(?![:,}\]])')
|
19
|
+
# json.loads(re.sub(p, '\\"', data))
|
20
|
+
end
|
21
|
+
|
22
|
+
def all(**opts)
|
23
|
+
#self._fix_json(self._get('slb.class_list.getAll', **opts))
|
24
|
+
self._get('slb.class_list.getAll', **opts)
|
25
|
+
end
|
26
|
+
|
27
|
+
def get(name, **opts)
|
28
|
+
self._fix_json(self._post('slb.class_list.search', params: {:name => name}, **opts))
|
29
|
+
end
|
30
|
+
|
31
|
+
def download(name, **opts)
|
32
|
+
self._post('slb.class_list.download', params: {:file_name => name}, **opts)
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
def upload(name, class_list, **opts)
|
37
|
+
#m = multipart.Multipart()
|
38
|
+
#m.file(name=name, filename=name, value=class_list)
|
39
|
+
#ct, payload = m.get()
|
40
|
+
#kwargs.update(payload=payload, headers={'Content-Type' : ct})
|
41
|
+
# self._post('slb.class_list.upload', **opts)
|
42
|
+
end
|
43
|
+
|
44
|
+
def _set(action, class_list, **opts)
|
45
|
+
self._post(action, params: {:name => class_list}, **opts)
|
46
|
+
end
|
47
|
+
|
48
|
+
def create(class_list, type=IPV4, **opts)
|
49
|
+
params = {
|
50
|
+
:name => class_list,
|
51
|
+
:type => type
|
52
|
+
}
|
53
|
+
self._post('slb.class_list.create', params: params, **opts)
|
54
|
+
end
|
55
|
+
|
56
|
+
def update(class_list, **opts)
|
57
|
+
self._set('slb.class_list.update', class_list, **opts)
|
58
|
+
end
|
59
|
+
|
60
|
+
def delete(name, **opts)
|
61
|
+
self._post('slb.class_list.delete', params: {:name => name}, **opts)
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'acos_client/errors'
|
2
|
+
require 'acos_client/v21/base'
|
3
|
+
|
4
|
+
|
5
|
+
module AcosClient
|
6
|
+
module V21
|
7
|
+
class HealthMonitor < AcosClient::V21::BaseV21
|
8
|
+
|
9
|
+
# Valid types
|
10
|
+
ICMP = 0
|
11
|
+
TCP = 1
|
12
|
+
HTTP = 3
|
13
|
+
HTTPS = 4
|
14
|
+
|
15
|
+
def get(name, **opts)
|
16
|
+
self._post('slb.hm.search', params: {:name => name}, **opts)
|
17
|
+
end
|
18
|
+
|
19
|
+
def _set(action, name, mon_type, interval, timeout, max_retries, method: nil, url: nil, expect_code: nil,
|
20
|
+
port: nil, **opts)
|
21
|
+
defs = {
|
22
|
+
:HTTP => {
|
23
|
+
:protocol => 'http',
|
24
|
+
:port => 80
|
25
|
+
},
|
26
|
+
:HTTPS => {
|
27
|
+
:protocol => 'https',
|
28
|
+
:port => 443
|
29
|
+
},
|
30
|
+
:ICMP => {
|
31
|
+
:protocol => 'icmp',
|
32
|
+
},
|
33
|
+
:TCP => {
|
34
|
+
:protocol => 'tcp',
|
35
|
+
:port => 80
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
|
40
|
+
params = {
|
41
|
+
:retry => max_retries,
|
42
|
+
:name => name,
|
43
|
+
:consec_pass_reqd => max_retries,
|
44
|
+
:interval => interval,
|
45
|
+
:timeout => timeout,
|
46
|
+
:disable_after_down => 0,
|
47
|
+
:type => mon_type
|
48
|
+
}
|
49
|
+
|
50
|
+
if defs.key?(mon_type)
|
51
|
+
|
52
|
+
params[defs[mon_type][:protocol]] = {
|
53
|
+
:url => "#{method} #{url}",
|
54
|
+
:expect_code => expect_code
|
55
|
+
}
|
56
|
+
|
57
|
+
#n = port or n = defs[mon_type].fetch(:port, nil)
|
58
|
+
if !port.nil?
|
59
|
+
n = port
|
60
|
+
else
|
61
|
+
n = defs[mon_type].fetch(:port, nil)
|
62
|
+
end
|
63
|
+
|
64
|
+
if n
|
65
|
+
params[defs[mon_type][:protocol]]['port'] = n
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
begin
|
70
|
+
self._post(action, params: params, **opts)
|
71
|
+
rescue AcosClient::Error::HMMissingHttpPassive
|
72
|
+
# Some version of AxAPI 2.1 require this arg
|
73
|
+
params[defs[mon_type][:protocol]][:passive] = 0
|
74
|
+
self._post(action, params: params, **opts)
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
def create(name, mon_type, interval, timeout, max_retries,
|
80
|
+
method: nil,
|
81
|
+
url: nil,
|
82
|
+
expect_code: nil,
|
83
|
+
port: nil, **opts)
|
84
|
+
|
85
|
+
self._set('slb.hm.create', name, mon_type, interval, timeout, max_retries,
|
86
|
+
method: method,
|
87
|
+
url: url,
|
88
|
+
expect_code: expect_code,
|
89
|
+
port: port, **opts)
|
90
|
+
end
|
91
|
+
|
92
|
+
# Example call
|
93
|
+
# ._set('slb.hm.create',
|
94
|
+
# 'testHM',
|
95
|
+
# :HTTP,
|
96
|
+
# 60,
|
97
|
+
# 60,
|
98
|
+
# 5,
|
99
|
+
# method: "method",
|
100
|
+
# url: "url",
|
101
|
+
# expect_code: "expect_code",
|
102
|
+
# port: 99999)
|
103
|
+
|
104
|
+
def update(name, mon_type, interval, timeout, max_retries,
|
105
|
+
method: nil,
|
106
|
+
url: nil,
|
107
|
+
expect_code: nil,
|
108
|
+
port: nil, **opts)
|
109
|
+
|
110
|
+
self._set('slb.hm.update', name, mon_type, interval, timeout, max_retries,
|
111
|
+
method: method,
|
112
|
+
url: url,
|
113
|
+
expect_code: expect_code,
|
114
|
+
port: port, **opts)
|
115
|
+
end
|
116
|
+
|
117
|
+
def delete(name, **opts)
|
118
|
+
self._post('slb.hm.delete', params: {:name => name}, **opts)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'acos_client/v21/base'
|
2
|
+
require 'acos_client/v21/slb/server'
|
3
|
+
require 'acos_client/v21/slb/hm'
|
4
|
+
require 'acos_client/v21/slb/service_group'
|
5
|
+
require 'acos_client/v21/slb/virtual_service'
|
6
|
+
require 'acos_client/v21/slb/virtual_server'
|
7
|
+
require 'acos_client/v21/slb/class_list'
|
8
|
+
require 'acos_client/v21/slb/aflex'
|
9
|
+
require 'acos_client/v21/slb/template/init'
|
10
|
+
|
11
|
+
|
12
|
+
module AcosClient
|
13
|
+
module V21
|
14
|
+
class SLB < AcosClient::V21::BaseV21
|
15
|
+
|
16
|
+
DOWN = 0
|
17
|
+
UP = 1
|
18
|
+
|
19
|
+
def hm
|
20
|
+
HealthMonitor.new(@client)
|
21
|
+
end
|
22
|
+
|
23
|
+
def server
|
24
|
+
Server.new(@client)
|
25
|
+
end
|
26
|
+
|
27
|
+
def service_group
|
28
|
+
ServiceGroup.new(@client)
|
29
|
+
end
|
30
|
+
|
31
|
+
def template
|
32
|
+
Template.new(@client)
|
33
|
+
end
|
34
|
+
|
35
|
+
def virtual_server
|
36
|
+
VirtualServer.new(@client)
|
37
|
+
end
|
38
|
+
|
39
|
+
def aflex
|
40
|
+
Aflex.new(@client)
|
41
|
+
end
|
42
|
+
|
43
|
+
def class_list
|
44
|
+
ClassList.new(@client)
|
45
|
+
end
|
46
|
+
|
47
|
+
def virtual_service
|
48
|
+
VirtualService.new(@client)
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'acos_client/errors'
|
2
|
+
require 'acos_client/v21/base'
|
3
|
+
|
4
|
+
|
5
|
+
module AcosClient
|
6
|
+
module V21
|
7
|
+
|
8
|
+
class Member < AcosClient::V21::BaseV21
|
9
|
+
|
10
|
+
def _write(action, service_group_name, server_name, server_port, status=nil, **opts)
|
11
|
+
params = {
|
12
|
+
:name => service_group_name,
|
13
|
+
:member => {
|
14
|
+
:server => server_name,
|
15
|
+
:port => server_port.to_i,
|
16
|
+
:status => status
|
17
|
+
}.compact!
|
18
|
+
}
|
19
|
+
self._post(action, params: params, **opts)
|
20
|
+
end
|
21
|
+
|
22
|
+
def create(service_group_name, server_name, server_port, status=1, **opts)
|
23
|
+
self._write('slb.service_group.member.create', service_group_name, server_name, server_port, status, **opts)
|
24
|
+
end
|
25
|
+
|
26
|
+
def update(service_group_name, server_name, server_port, status=1, **opts)
|
27
|
+
self._write('slb.service_group.member.update', service_group_name, server_name, server_port, status, **opts)
|
28
|
+
end
|
29
|
+
|
30
|
+
def delete(service_group_name, server_name, server_port, **opts)
|
31
|
+
self._write('slb.service_group.member.delete', service_group_name, server_name, server_port, **opts)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'acos_client/v21/base'
|
2
|
+
|
3
|
+
module AcosClient
|
4
|
+
module V21
|
5
|
+
|
6
|
+
class Port < AcosClient::V21::BaseV21
|
7
|
+
|
8
|
+
# Protocols
|
9
|
+
TCP = 2
|
10
|
+
UDP = 3
|
11
|
+
|
12
|
+
def _set(action, name, port_num, protocol, **opts)
|
13
|
+
|
14
|
+
params = {
|
15
|
+
:name => name,
|
16
|
+
:port => {
|
17
|
+
:port_num => port_num,
|
18
|
+
:protocol => protocol,
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
self._post(action, params: params, **opts)
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
def create(name, port_num, protocol, **opts)
|
27
|
+
self._set('slb.server.port.create', name, port_num, protocol, **opts)
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
def update(name, port_num, protocol, **opts)
|
32
|
+
self._set('slb.server.port.update', name, port_num, protocol, **opts)
|
33
|
+
end
|
34
|
+
|
35
|
+
def all_update(name, port_num, protocol, **opts)
|
36
|
+
self._set('slb.server.port.updateAll', name, port_num, protocol, **opts)
|
37
|
+
end
|
38
|
+
|
39
|
+
def delete(name, port_num, protocol, **opts)
|
40
|
+
self._set('slb.server.port.delete', name, port_num, protocol, **opts)
|
41
|
+
end
|
42
|
+
|
43
|
+
def all_delete(name, **opts)
|
44
|
+
self._get('slb.server.port.deleteAll', params: {:name => name}, **opts)
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'acos_client/v21/base'
|
2
|
+
require 'acos_client/v21/slb/port'
|
3
|
+
|
4
|
+
module AcosClient
|
5
|
+
module V21
|
6
|
+
class Server < AcosClient::V21::BaseV21
|
7
|
+
|
8
|
+
def get(name, **opts)
|
9
|
+
self._post('slb.server.search', params: {:name => name}, **opts)
|
10
|
+
end
|
11
|
+
|
12
|
+
def create(name, ip_address, **opts)
|
13
|
+
params = {
|
14
|
+
:server => {
|
15
|
+
:name => name,
|
16
|
+
:host => ip_address,
|
17
|
+
}
|
18
|
+
}
|
19
|
+
self._post('slb.server.create', params: params, **opts)
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
def update(name, ip_address, **opts)
|
24
|
+
params = {
|
25
|
+
:server => {
|
26
|
+
:name => name,
|
27
|
+
:host => ip_address,
|
28
|
+
:status => opts.fetch(:status, 1) # Use update(name, ip_address, {:status => 0})
|
29
|
+
}
|
30
|
+
}
|
31
|
+
self._post('slb.server.update', params: params, **opts)
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
def fetch_statistics(name, **opts)
|
36
|
+
self._post('slb.server.fetchStatistics', params: {:name => name}, **opts)
|
37
|
+
end
|
38
|
+
|
39
|
+
def delete(name, **opts)
|
40
|
+
self._post('slb.server.delete', params: {:server => {:name => name}}, **opts)
|
41
|
+
end
|
42
|
+
|
43
|
+
def all
|
44
|
+
self._get('slb.server.getAll')
|
45
|
+
end
|
46
|
+
|
47
|
+
def all_delete(**opts)
|
48
|
+
self._get('slb.server.deleteAll', **opts)
|
49
|
+
end
|
50
|
+
|
51
|
+
def stats(name, **opts)
|
52
|
+
self._post('slb.server.fetchStatistics', params: {:server => {:name => name}}, **opts)
|
53
|
+
end
|
54
|
+
|
55
|
+
def all_stats(**opts)
|
56
|
+
self._get('slb.server.fetchAllStatistics', **opts)
|
57
|
+
end
|
58
|
+
|
59
|
+
def port
|
60
|
+
Port.new(self.client)
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
#from member import Member
|
2
|
+
|
3
|
+
require 'acos_client/errors'
|
4
|
+
require 'acos_client/v21/base'
|
5
|
+
require 'acos_client/v21/slb/member'
|
6
|
+
|
7
|
+
module AcosClient
|
8
|
+
module V21
|
9
|
+
class ServiceGroup < AcosClient::V21::BaseV21
|
10
|
+
|
11
|
+
def member
|
12
|
+
Member.new(self.client)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Valid LB methods
|
16
|
+
ROUND_ROBIN = 0
|
17
|
+
WEIGHTED_ROUND_ROBIN = 1
|
18
|
+
LEAST_CONNECTION = 2
|
19
|
+
WEIGHTED_LEAST_CONNECTION = 3
|
20
|
+
LEAST_CONNECTION_ON_SERVICE_PORT = 4
|
21
|
+
WEIGHTED_LEAST_CONNECTION_ON_SERVICE_PORT = 5
|
22
|
+
FAST_RESPONSE_TIME = 6
|
23
|
+
LEAST_REQUEST = 7
|
24
|
+
STRICT_ROUND_ROBIN = 8
|
25
|
+
STATELESS_SOURCE_IP_HASH = 9
|
26
|
+
STATELESS_SOURCE_IP_HASH_ONLY = 10
|
27
|
+
STATELESS_DESTINATION_IP_HASH = 11
|
28
|
+
STATELESS_SOURCE_DESTINATION_IP_HASH = 12
|
29
|
+
STATELESS_PER_PACKET_ROUND_ROBIN = 13
|
30
|
+
|
31
|
+
# Valid protocols
|
32
|
+
TCP = 2
|
33
|
+
UDP = 3
|
34
|
+
|
35
|
+
def get(name, **opts)
|
36
|
+
self._post('slb.service_group.search', params: {:name => name}, **opts)
|
37
|
+
end
|
38
|
+
|
39
|
+
def _set(action, name, protocol: nil, lb_method: nil, health_monitor: nil, **opts)
|
40
|
+
puts opts
|
41
|
+
params = {
|
42
|
+
:service_group => {
|
43
|
+
:name => name,
|
44
|
+
:protocol => protocol,
|
45
|
+
:lb_method => lb_method,
|
46
|
+
:health_monitor => health_monitor
|
47
|
+
}.compact!
|
48
|
+
}
|
49
|
+
puts params
|
50
|
+
self._post(action, params: params, **opts)
|
51
|
+
end
|
52
|
+
|
53
|
+
def create(name, protocol: TCP, lb_method: ROUND_ROBIN, **opts)
|
54
|
+
self._set('slb.service_group.create', name, protocol: protocol, lb_method: lb_method, **opts)
|
55
|
+
end
|
56
|
+
|
57
|
+
def update(name, protocol: nil, lb_method: nil, health_monitor: nil, **opts)
|
58
|
+
self._set('slb.service_group.update', name, protocol: protocol, lb_method: lb_method, health_monitor: health_monitor, **opts)
|
59
|
+
end
|
60
|
+
|
61
|
+
def delete(name, **opts)
|
62
|
+
self._post('slb.service_group.delete', params: {:name => name}, **opts)
|
63
|
+
end
|
64
|
+
|
65
|
+
def all(**opts)
|
66
|
+
self._get('slb.service_group.getAll', **opts)
|
67
|
+
end
|
68
|
+
|
69
|
+
def delete_all(**opts)
|
70
|
+
self._get('slb.service_group.deleteAll', **opts)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'acos_client/v21/base'
|
2
|
+
require 'acos_client/v21/slb/template/persistence'
|
3
|
+
require 'acos_client/v21/slb/template/template_ssl'
|
4
|
+
|
5
|
+
module AcosClient
|
6
|
+
module V21
|
7
|
+
class Template < AcosClient::V21::BaseV21
|
8
|
+
|
9
|
+
def client_ssl
|
10
|
+
ClientSSL.new(self.client)
|
11
|
+
end
|
12
|
+
|
13
|
+
def server_ssl
|
14
|
+
ServerSSL.new(self.client)
|
15
|
+
end
|
16
|
+
|
17
|
+
def cookie_persistence
|
18
|
+
CookiePersistence.new(self.client)
|
19
|
+
end
|
20
|
+
|
21
|
+
def src_ip_persistence
|
22
|
+
SourceIpPersistence.new(self.client)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'acos_client/errors'
|
2
|
+
require 'acos_client/v21/base'
|
3
|
+
|
4
|
+
module AcosClient
|
5
|
+
module V21
|
6
|
+
|
7
|
+
class BasePersistence < AcosClient::V21::BaseV21
|
8
|
+
|
9
|
+
# def initialize(client)
|
10
|
+
# super(client)
|
11
|
+
# @prefix = "slb.template.#{@pers_type}_persistence"
|
12
|
+
# end
|
13
|
+
|
14
|
+
def all(**opts)
|
15
|
+
self._get("#{@prefix}.getAll", **opts)
|
16
|
+
end
|
17
|
+
|
18
|
+
def get(name, **opts)
|
19
|
+
self._post("#{@prefix}.search", params: {:name => name}, **opts)
|
20
|
+
end
|
21
|
+
|
22
|
+
def exists(name, **opts)
|
23
|
+
begin
|
24
|
+
self.get(name, **opts)
|
25
|
+
return true
|
26
|
+
rescue AcosClient::Error::NotFound
|
27
|
+
return false
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
def create(name, **opts)
|
33
|
+
self._post("#{@prefix}.create", params: self.get_params(name), **opts)
|
34
|
+
end
|
35
|
+
|
36
|
+
def delete(name, **opts)
|
37
|
+
self._post("#{@prefix}.delete", params: {:name => name}, **opts)
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
class CookiePersistence < BasePersistence
|
44
|
+
|
45
|
+
def initialize(client)
|
46
|
+
super(client)
|
47
|
+
@pers_type = 'cookie'
|
48
|
+
@prefix = "slb.template.#{@pers_type}_persistence"
|
49
|
+
end
|
50
|
+
|
51
|
+
def get_params(name)
|
52
|
+
{
|
53
|
+
:cookie_persistence_template => {
|
54
|
+
:name => name
|
55
|
+
}
|
56
|
+
}
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
class SourceIpPersistence < BasePersistence
|
62
|
+
|
63
|
+
def initialize(client)
|
64
|
+
super(client)
|
65
|
+
@pers_type = 'src_ip'
|
66
|
+
@prefix = "slb.template.#{@pers_type}_persistence"
|
67
|
+
end
|
68
|
+
|
69
|
+
def get_params(name)
|
70
|
+
{
|
71
|
+
:src_ip_persistence_template => {
|
72
|
+
:name => name
|
73
|
+
}
|
74
|
+
}
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
end
|