mu 5.7.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Mu_Gem.html +1591 -0
- data/bin/mu +11 -0
- data/lib/mu.rb +65 -0
- data/lib/mu/api/ddt.rb +233 -0
- data/lib/mu/api/homepage.rb +54 -0
- data/lib/mu/api/muapi.rb +231 -0
- data/lib/mu/api/netconfig.rb +233 -0
- data/lib/mu/api/scale.rb +199 -0
- data/lib/mu/api/system.rb +40 -0
- data/lib/mu/client.rb +31 -0
- data/lib/mu/command.rb +28 -0
- data/lib/mu/command/api.rb +95 -0
- data/lib/mu/command/cmd_appid.rb +486 -0
- data/lib/mu/command/cmd_cli.rb +151 -0
- data/lib/mu/command/cmd_ddt.rb +449 -0
- data/lib/mu/command/cmd_homepage.rb +146 -0
- data/lib/mu/command/cmd_muapi.rb +361 -0
- data/lib/mu/command/cmd_netconfig.rb +262 -0
- data/lib/mu/command/cmd_runscale.rb +533 -0
- data/lib/mu/command/cmd_runscenario.rb +258 -0
- data/lib/mu/command/cmd_runverify.rb +336 -0
- data/lib/mu/command/cmd_scale.rb +333 -0
- data/lib/mu/command/cmd_system.rb +127 -0
- data/lib/mu/command/curl.rb +246 -0
- data/lib/mu/command/help.rb +29 -0
- data/lib/mu/curl/error.rb +54 -0
- data/lib/mu/curl/verify.rb +137 -0
- data/lib/mu/helper.rb +55 -0
- data/lib/mu/http_helper.rb +232 -0
- data/rdoc/classes/Mu.html +305 -0
- data/rdoc/classes/Mu/Client.html +265 -0
- data/rdoc/classes/Mu/Command.html +208 -0
- data/rdoc/classes/Mu/Command/API.html +524 -0
- data/rdoc/classes/Mu/Command/Cmd_appid.html +934 -0
- data/rdoc/classes/Mu/Command/Cmd_cli.html +515 -0
- data/rdoc/classes/Mu/Command/Cmd_ddt.html +1169 -0
- data/rdoc/classes/Mu/Command/Cmd_homepage.html +489 -0
- data/rdoc/classes/Mu/Command/Cmd_muapi.html +968 -0
- data/rdoc/classes/Mu/Command/Cmd_netconfig.html +743 -0
- data/rdoc/classes/Mu/Command/Cmd_runscale.html +970 -0
- data/rdoc/classes/Mu/Command/Cmd_runscenario.html +530 -0
- data/rdoc/classes/Mu/Command/Cmd_runverify.html +621 -0
- data/rdoc/classes/Mu/Command/Cmd_scale.html +939 -0
- data/rdoc/classes/Mu/Command/Cmd_system.html +426 -0
- data/rdoc/classes/Mu/Command/Curl.html +524 -0
- data/rdoc/classes/Mu/Command/Help.html +166 -0
- data/rdoc/classes/Mu/Curl.html +116 -0
- data/rdoc/classes/Mu/Curl/Error.html +157 -0
- data/rdoc/classes/Mu/Curl/Error/Authorize.html +178 -0
- data/rdoc/classes/Mu/Curl/Error/Connect.html +149 -0
- data/rdoc/classes/Mu/Curl/Error/DNS.html +113 -0
- data/rdoc/classes/Mu/Curl/Error/Region.html +160 -0
- data/rdoc/classes/Mu/Curl/Error/Status.html +149 -0
- data/rdoc/classes/Mu/Curl/Error/Timeout.html +149 -0
- data/rdoc/classes/Mu/Curl/Verify.html +282 -0
- data/rdoc/classes/Mu/Curl/Verify/Request.html +227 -0
- data/rdoc/classes/Mu/Curl/Verify/Response.html +187 -0
- data/rdoc/classes/Mu/Curl/Verify/Result.html +188 -0
- data/rdoc/classes/Mu/Ddt.html +914 -0
- data/rdoc/classes/Mu/Helper.html +308 -0
- data/rdoc/classes/Mu/Homepage.html +377 -0
- data/rdoc/classes/Mu/HttpHelper.html +639 -0
- data/rdoc/classes/Mu/Muapi.html +816 -0
- data/rdoc/classes/Mu/Netconfig.html +781 -0
- data/rdoc/classes/Mu/Scale.html +832 -0
- data/rdoc/classes/Mu/System.html +281 -0
- data/rdoc/classes/Object.html +148 -0
- data/rdoc/classes/TCTestMu.html +1793 -0
- data/rdoc/classes/Test.html +107 -0
- data/rdoc/classes/Test/Unit.html +107 -0
- data/rdoc/classes/Test/Unit/TestCase.html +113 -0
- data/rdoc/created.rid +1 -0
- data/rdoc/files/lib/mu/api/ddt_rb.html +101 -0
- data/rdoc/files/lib/mu/api/homepage_rb.html +101 -0
- data/rdoc/files/lib/mu/api/muapi_rb.html +101 -0
- data/rdoc/files/lib/mu/api/netconfig_rb.html +101 -0
- data/rdoc/files/lib/mu/api/scale_rb.html +101 -0
- data/rdoc/files/lib/mu/api/system_rb.html +101 -0
- data/rdoc/files/lib/mu/client_rb.html +101 -0
- data/rdoc/files/lib/mu/command/api_rb.html +101 -0
- data/rdoc/files/lib/mu/command/cmd_appid_rb.html +119 -0
- data/rdoc/files/lib/mu/command/cmd_cli_rb.html +108 -0
- data/rdoc/files/lib/mu/command/cmd_ddt_rb.html +117 -0
- data/rdoc/files/lib/mu/command/cmd_homepage_rb.html +115 -0
- data/rdoc/files/lib/mu/command/cmd_muapi_rb.html +116 -0
- data/rdoc/files/lib/mu/command/cmd_netconfig_rb.html +116 -0
- data/rdoc/files/lib/mu/command/cmd_runscale_rb.html +119 -0
- data/rdoc/files/lib/mu/command/cmd_runscenario_rb.html +115 -0
- data/rdoc/files/lib/mu/command/cmd_runverify_rb.html +117 -0
- data/rdoc/files/lib/mu/command/cmd_scale_rb.html +115 -0
- data/rdoc/files/lib/mu/command/cmd_system_rb.html +116 -0
- data/rdoc/files/lib/mu/command/curl_rb.html +101 -0
- data/rdoc/files/lib/mu/command/help_rb.html +101 -0
- data/rdoc/files/lib/mu/command_rb.html +107 -0
- data/rdoc/files/lib/mu/curl/error_rb.html +101 -0
- data/rdoc/files/lib/mu/curl/verify_rb.html +101 -0
- data/rdoc/files/lib/mu/helper_rb.html +101 -0
- data/rdoc/files/lib/mu/http_helper_rb.html +101 -0
- data/rdoc/files/lib/mu_rb.html +121 -0
- data/rdoc/files/test/helper_rb.html +112 -0
- data/rdoc/files/test/tc_test_mu_rb.html +111 -0
- data/rdoc/fr_class_index.html +68 -0
- data/rdoc/fr_file_index.html +55 -0
- data/rdoc/fr_method_index.html +374 -0
- data/rdoc/index.html +24 -0
- data/rdoc/rdoc-style.css +208 -0
- data/test/data/app_id_stats.csv +1 -0
- data/test/data/data_cgi.msl +94 -0
- data/test/data/data_cgi.xml +322 -0
- data/test/data/default_test.csv +3 -0
- data/test/data/ftp_with_channel.xml +1643 -0
- data/test/data/irc.xml +3837 -0
- data/test/data/scale_configuration.json +25 -0
- data/test/data/test_data_cgi_error.xml +35 -0
- data/test/helper.rb +18 -0
- data/test/tc_test_mu.rb +716 -0
- metadata +322 -0
@@ -0,0 +1,233 @@
|
|
1
|
+
class Mu
|
2
|
+
class Netconfig
|
3
|
+
include Helper
|
4
|
+
|
5
|
+
attr_accessor :host, :username, :password, :docroot, :element, :response, :config
|
6
|
+
|
7
|
+
def initialize(host=ENV['MU_IP'], username=ENV['MU_ADMIN_USER'], password=ENV['MU_ADMIN_PASS'])
|
8
|
+
@host = host
|
9
|
+
@username = username
|
10
|
+
@password = password
|
11
|
+
@docroot = "/restlet/netconfig/"
|
12
|
+
@response = nil
|
13
|
+
@http = HttpHelper.new(@host, @username, @password, @docroot)
|
14
|
+
@element = "" # sticky variable will hold a default element, the last element specified
|
15
|
+
msg "Created Netconfig API object to :#{@host}", Logger::DEBUG
|
16
|
+
end
|
17
|
+
|
18
|
+
# get - with no params, returns the entire netconfig json object
|
19
|
+
# * e = the element to retrieve (interfaces|hosts|routes, interfaces/a1 ...)
|
20
|
+
def get(e)
|
21
|
+
response = @http.get_json(e)
|
22
|
+
msg response, Logger::DEBUG
|
23
|
+
return response
|
24
|
+
end
|
25
|
+
|
26
|
+
# PUT to modify netconfig element(s) to json values
|
27
|
+
# * json = the json string containing the modified values
|
28
|
+
# * e = the element to modify (interfaces|hosts|routes)
|
29
|
+
def modify(json, e)
|
30
|
+
response = do_modify(json, e)
|
31
|
+
msg response, Logger::DEBUG
|
32
|
+
return response
|
33
|
+
=begin
|
34
|
+
jstring = json
|
35
|
+
@element = e
|
36
|
+
unless json.is_a? String
|
37
|
+
jstring = JSON.generate json
|
38
|
+
end
|
39
|
+
response = @http.put_json(e, jstring)
|
40
|
+
msg response, Logger::DEBUG
|
41
|
+
return response
|
42
|
+
=end
|
43
|
+
end
|
44
|
+
|
45
|
+
# POST method to add a network element
|
46
|
+
# * json = the json string containing the element values
|
47
|
+
# * e = the element to create (interfaces|hosts|routes)
|
48
|
+
def create(json, e)
|
49
|
+
jstring = json
|
50
|
+
unless json.is_a? String
|
51
|
+
jstring = JSON.generate json
|
52
|
+
end
|
53
|
+
response = @http.post_json(e, jstring)
|
54
|
+
msg response, Logger::DEBUG
|
55
|
+
return response
|
56
|
+
end
|
57
|
+
|
58
|
+
# deletes the specified element
|
59
|
+
# * e = the element to delete
|
60
|
+
def delete(e)
|
61
|
+
response = @http.delete(e)
|
62
|
+
msg response, Logger::DEBUG
|
63
|
+
return response
|
64
|
+
end
|
65
|
+
|
66
|
+
# updates a network configuration from file
|
67
|
+
# * filepath = the path to the json file
|
68
|
+
# * clear_existing - boolean determining whether or not existing elements should be cleared
|
69
|
+
def restore(filepath=nil,clear_existing=false)
|
70
|
+
unless filepath.nil?
|
71
|
+
@config = JSON.parse(File.read(filepath))
|
72
|
+
end
|
73
|
+
@config.each do |c|
|
74
|
+
case c.keys[0]
|
75
|
+
when "hosts"
|
76
|
+
msg "RESTORE HOSTS", Logger::DEBUG
|
77
|
+
clear_existing and clear_hosts
|
78
|
+
restore_hosts c["hosts"]
|
79
|
+
when "routes"
|
80
|
+
msg "RESTORE ROUTES", Logger::DEBUG
|
81
|
+
clear_existing and clear_routes
|
82
|
+
restore_routes c["routes"]
|
83
|
+
when "interfaces"
|
84
|
+
clear_existing and clear_vlans
|
85
|
+
msg "RESTORE INTERFACES", Logger::DEBUG
|
86
|
+
restore_interfaces c["interfaces"]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# clears the network hosts
|
92
|
+
def clear_hosts
|
93
|
+
h = get("hosts")
|
94
|
+
h["hosts"].each do |h|
|
95
|
+
msg "Clear host: #{h['name']}", Logger::DEBUG
|
96
|
+
delete("hosts/#{h['name']}")
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# restores the network hosts to the initial system states
|
101
|
+
def restore_hosts(hosts)
|
102
|
+
hosts.each do |h|
|
103
|
+
msg "create host: #{h['name']}", Logger::DEBUG
|
104
|
+
delete "hosts/#{h['name']}" # harmlessly fails when host does not exist
|
105
|
+
create(h,"hosts")
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# use Dns to update host ip addresses.
|
110
|
+
# A new Host is added if not present when the name is provided as argument
|
111
|
+
# * name = the name of the host to resolve
|
112
|
+
def resolve_hosts(name=nil)
|
113
|
+
hosts = Array.new
|
114
|
+
if name.nil?
|
115
|
+
hst = get "hosts"
|
116
|
+
hst["hosts"].each {|h| hosts << h["name"]}
|
117
|
+
else
|
118
|
+
hosts << name
|
119
|
+
end
|
120
|
+
hosts.each do |h|
|
121
|
+
msg "resolve host: #{h}", Logger::DEBUG
|
122
|
+
v4_addr = Socket::gethostbyname(h)[3].unpack("CCCC").join(".") rescue nil
|
123
|
+
next if v4_addr.nil?
|
124
|
+
json = get "hosts/#{h}"
|
125
|
+
if json["name"].nil?
|
126
|
+
json = {"name" => h, "v4_addr" => v4_addr}
|
127
|
+
create json, "hosts"
|
128
|
+
else
|
129
|
+
json["v4_addr"] = v4_addr
|
130
|
+
modify json, "hosts/#{h}"
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
# clears a network interface
|
136
|
+
# * interface = the name of the interface to clear
|
137
|
+
def clear_interface(interface)
|
138
|
+
interface = interface
|
139
|
+
json = { "v4_addrs"=>[], "v4_mask"=>"", "v4_dhcp"=>false,
|
140
|
+
"v6_global_addrs"=>[], "v6_global_mask"=>""}
|
141
|
+
modify json,"interfaces/#{interface}"
|
142
|
+
end
|
143
|
+
|
144
|
+
# clears all network vlans
|
145
|
+
def clear_vlans
|
146
|
+
i = get "interfaces"
|
147
|
+
i["interfaces"].each do |i|
|
148
|
+
next if i['vlan'] == ""
|
149
|
+
msg "Clear vlan: #{i['name']}", Logger::DEBUG
|
150
|
+
delete "interfaces/#{i['name']}"
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
# restores network interfaces to system initial settings
|
155
|
+
# * interfaces - the names of the interfaces to restore
|
156
|
+
def restore_interfaces(interfaces)
|
157
|
+
interfaces.each do |i|
|
158
|
+
next if i['name'].include? "eth" # don't do eth0 or eth1
|
159
|
+
msg "configure interface: #{i['name']}", Logger::DEBUG
|
160
|
+
unless i['vlan'] == ""
|
161
|
+
interface,vlan = i['name'].split(".")
|
162
|
+
create [{"name"=>interface,"vlan"=>vlan},"interfaces"]
|
163
|
+
end
|
164
|
+
modify [i,"interfaces/#{i['name']}"]
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
# clears network routes
|
169
|
+
def clear_routes
|
170
|
+
routes = get "routes"
|
171
|
+
routes["routes"].each do |r|
|
172
|
+
next if r['readonly'] == true
|
173
|
+
msg "Clear route: #{r['dst']}-#{r['gateway']}-#{r['interface_display_name'].downcase}", Logger::DEBUG
|
174
|
+
delete "routes/#{r['dst']}-#{r['gateway']}-#{r['interface_display_name'].downcase}"
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
# restores network routes to system initial settings
|
179
|
+
def restore_routes(routes)
|
180
|
+
routes.each do |r|
|
181
|
+
next if r['readonly'] == true
|
182
|
+
msg "configure route: #{r['dst']}-#{r['gateway']}-#{r['interface_display_name'].downcase}", Logger::DEBUG
|
183
|
+
create r,"routes"
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
# writes the json config to filepath
|
188
|
+
# * e = the element to save, or 'all'
|
189
|
+
# * filepath - the fully qualified name of the file to save to
|
190
|
+
def save(e="all", filepath="config.json")
|
191
|
+
json = get e
|
192
|
+
File.open(filepath,'w'){|f| f.write(JSON.pretty_generate(json))}
|
193
|
+
end
|
194
|
+
|
195
|
+
private
|
196
|
+
|
197
|
+
# restclient put was not recgonized as json
|
198
|
+
# PUT to modify netconfig element(s) to json values
|
199
|
+
def do_modify(json, e)
|
200
|
+
jstring = json
|
201
|
+
unless json.is_a? String
|
202
|
+
jstring = JSON.generate json
|
203
|
+
end
|
204
|
+
msg jstring, Logger::DEBUG
|
205
|
+
uri = URI.parse("https://#{@host}")
|
206
|
+
escaped = URI.escape("#{@docroot}#{e}")
|
207
|
+
msg "Put: #{uri}#{escaped}", Logger::DEBUG
|
208
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
209
|
+
http.use_ssl = true
|
210
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
211
|
+
http.start do |http|
|
212
|
+
req = Net::HTTP::Put.new("#{escaped}",initheader = {"User-Agent" => @username, 'Content-Type' => 'application/json; charset=utf-8'})
|
213
|
+
req.body = jstring
|
214
|
+
response = http_request(http, req)
|
215
|
+
end
|
216
|
+
msg response, Logger::DEBUG
|
217
|
+
return response
|
218
|
+
end
|
219
|
+
|
220
|
+
def http_request(http, req)
|
221
|
+
req.basic_auth(@username, @password)
|
222
|
+
response = http.request(req)
|
223
|
+
if response.code != "200"
|
224
|
+
return "Error status code #{response.code}\n#{response.body}"
|
225
|
+
end
|
226
|
+
return response.body
|
227
|
+
end
|
228
|
+
|
229
|
+
|
230
|
+
end
|
231
|
+
end # Mu
|
232
|
+
|
233
|
+
|
data/lib/mu/api/scale.rb
ADDED
@@ -0,0 +1,199 @@
|
|
1
|
+
class Mu
|
2
|
+
class Scale
|
3
|
+
include Helper
|
4
|
+
|
5
|
+
attr_accessor :host, :username, :password, :docroot, :configuration, :config_file, :uuid
|
6
|
+
|
7
|
+
def initialize(host=ENV['MU_IP'], username=ENV['MU_ADMIN_USER'], password=ENV['MU_ADMIN_PASS'])
|
8
|
+
@host = host
|
9
|
+
@username = username
|
10
|
+
@password = password
|
11
|
+
@docroot = "/api/v5/scale/"
|
12
|
+
@uuid = nil
|
13
|
+
@http = HttpHelper.new(@host, @username, @password, @docroot)
|
14
|
+
@config_file = (ENV['SCALE_CONFIG_FILE'].nil?) ? "scale.json" : ENV['SCALE_CONFIG_FILE']
|
15
|
+
if File.readable? @config_file
|
16
|
+
msg "reading config file: #{@config_file}", Logger::DEBUG
|
17
|
+
@configuration = JSON.parse File.read(@config_file)
|
18
|
+
else
|
19
|
+
@configuration = {
|
20
|
+
"hosts"=> {
|
21
|
+
"host_0"=> "a1/*",
|
22
|
+
"host_1"=> "a2/*"
|
23
|
+
},
|
24
|
+
"timeout"=> 5000,
|
25
|
+
"delay"=> 0,
|
26
|
+
"volume"=> 1,
|
27
|
+
"holdConcurrency"=> true,
|
28
|
+
"limitConcurrency"=> false,
|
29
|
+
"vectorAddressPairing"=> false,
|
30
|
+
"musl" => "",
|
31
|
+
"csv" => "",
|
32
|
+
"pattern" => {}
|
33
|
+
}
|
34
|
+
end
|
35
|
+
@uuid = session
|
36
|
+
msg "Created Scale Api session [#{@uuid}] on :#{@host}", Logger::DEBUG
|
37
|
+
end
|
38
|
+
|
39
|
+
# creates a new Studio Scale session, returning the session id
|
40
|
+
def session
|
41
|
+
uuid = nil
|
42
|
+
list = get("list")
|
43
|
+
if !list.empty?
|
44
|
+
msg list
|
45
|
+
uuid = list[0] # return existing session identifier if there is one
|
46
|
+
return uuid
|
47
|
+
end
|
48
|
+
uuid = get "new" # return a new session identifier
|
49
|
+
msg "uuid from /new = #{uuid}"
|
50
|
+
return uuid
|
51
|
+
end
|
52
|
+
|
53
|
+
# configures a parameter in the class @configuration object
|
54
|
+
# * param = the parameter to configure (e.g. volume)
|
55
|
+
# * value = the parameter's value ( e.g. 100)
|
56
|
+
def configure(param, value)
|
57
|
+
if param == "pattern" and value.is_a?(String)
|
58
|
+
value = JSON.parse(value)
|
59
|
+
end
|
60
|
+
@configuration[param] = value
|
61
|
+
File.open("scale_configuration.json",'w'){|f| f.write(JSON.pretty_generate(@configuration))}
|
62
|
+
end
|
63
|
+
|
64
|
+
# starts a scale test with the class @configuration object
|
65
|
+
def start
|
66
|
+
response = post "start", {"request" => @configuration}
|
67
|
+
msg response, Logger::DEBUG
|
68
|
+
return response
|
69
|
+
end
|
70
|
+
|
71
|
+
# verifies the class @configuration object
|
72
|
+
def verify
|
73
|
+
response = post "verify", {"request" => @configuration}
|
74
|
+
msg response, Logger::DEBUG
|
75
|
+
return response
|
76
|
+
end
|
77
|
+
|
78
|
+
# updates a running scale test, as long as the test pattern is 'none'
|
79
|
+
# * params = a json object containing the information to update, such as { "volume" : 100 }
|
80
|
+
def update(params)
|
81
|
+
response = get "update", params
|
82
|
+
msg response, Logger::DEBUG
|
83
|
+
return response
|
84
|
+
end
|
85
|
+
|
86
|
+
# gets information about the currently running Scale test.
|
87
|
+
def status
|
88
|
+
response = get "status"
|
89
|
+
msg response, Logger::DEBUG
|
90
|
+
return response
|
91
|
+
end
|
92
|
+
|
93
|
+
# returns the current Scale Player's session id
|
94
|
+
def list
|
95
|
+
response = get "list"
|
96
|
+
msg response, Logger::DEBUG
|
97
|
+
return response
|
98
|
+
end
|
99
|
+
|
100
|
+
# lists information about the the Scale Player and all active and inactive Scale Engines
|
101
|
+
def about
|
102
|
+
response = get "about"
|
103
|
+
msg response, Logger::DEBUG
|
104
|
+
return response
|
105
|
+
end
|
106
|
+
|
107
|
+
# returns a packet capture file from scale verify
|
108
|
+
# * bot_id = the id of the scale engine
|
109
|
+
# * file = the name of the pcap file to retrieve
|
110
|
+
def pcap(bot_id, file)
|
111
|
+
response = get "pcap", "botId=#{bot_id}&file=#{file}"
|
112
|
+
msg response, Logger::DEBUG
|
113
|
+
return response
|
114
|
+
end
|
115
|
+
|
116
|
+
# gets the status of all active and inactive Scale engines
|
117
|
+
def statuses
|
118
|
+
response = get "statuses"
|
119
|
+
msg response, Logger::DEBUG
|
120
|
+
return response
|
121
|
+
end
|
122
|
+
|
123
|
+
# gets chart data for the Scale test
|
124
|
+
# * view = the TIMELINE or CALLGRAPH chart.
|
125
|
+
# * zoom = the zoom level (0 to 1). 1 returns data for 100% of the time range, 0.5 returns data for 50% of the time range, and 0 returns only the last minute of data
|
126
|
+
# * position = 0.
|
127
|
+
# * bot_id = the scale engine id
|
128
|
+
def data(view='TIMELINE', zoom="0", position="0", bot_id="")
|
129
|
+
response = get "data", "view=#{view.upcase}&zoom=#{zoom}&position=#{position}&bot_id=#{bot_id}"
|
130
|
+
msg response, Logger::DEBUG
|
131
|
+
return response
|
132
|
+
end
|
133
|
+
|
134
|
+
# returns scale test data for charting
|
135
|
+
# * command-line args require a zoom level and position(0)
|
136
|
+
# * zoom = the zoom level (0 to 1). 1 returns data for 100% of the time range, 0.5 returns data for 50% of the time range, and 0 returns only the last minute of data
|
137
|
+
# * position = 0.
|
138
|
+
def pattern(zoom="0", position="0")
|
139
|
+
response = get "pattern", "zoom=#{zoom}&position=#{position}"
|
140
|
+
msg response, Logger::DEBUG
|
141
|
+
return response
|
142
|
+
end
|
143
|
+
|
144
|
+
# stops a scale test
|
145
|
+
def stop
|
146
|
+
response = get "stop"
|
147
|
+
msg response, Logger::DEBUG
|
148
|
+
return response
|
149
|
+
end
|
150
|
+
|
151
|
+
# releases the scale player
|
152
|
+
def release
|
153
|
+
response = get "release"
|
154
|
+
msg response, Logger::DEBUG
|
155
|
+
return response
|
156
|
+
end
|
157
|
+
|
158
|
+
# marks the specified Scale Engine as active (will participate in a Scale test
|
159
|
+
# * bot_id = the scale engine id
|
160
|
+
def reserve_scale_engine(bot_id)
|
161
|
+
response = get "reserveScaleEngine", "botId=#{bot_id}"
|
162
|
+
msg response, Logger::DEBUG
|
163
|
+
return response
|
164
|
+
end
|
165
|
+
|
166
|
+
# marks the specified Scale Engine as inactive (will not participate in a Scale test)
|
167
|
+
# * bot_id = the scale engine id
|
168
|
+
def release_scale_engine(bot_id)
|
169
|
+
response = get "releaseScaleEngine", "botId=#{bot_id}"
|
170
|
+
msg response, Logger::DEBUG
|
171
|
+
return response
|
172
|
+
end
|
173
|
+
|
174
|
+
# removes a Scale engine from the list of available engines
|
175
|
+
# * bot_id = the scale engine id
|
176
|
+
def delete_scale_engine(bot_id)
|
177
|
+
response = get "deleteScaleEngine", "botId=#{bot_id}"
|
178
|
+
msg response, Logger::DEBUG
|
179
|
+
return response
|
180
|
+
end
|
181
|
+
|
182
|
+
private
|
183
|
+
|
184
|
+
def get(e=@element, params=nil)
|
185
|
+
element = e
|
186
|
+
element << "?uuid=#{@uuid}" unless @uuid.nil?
|
187
|
+
element << "&#{params}" unless params.nil?
|
188
|
+
return @http.get_json(element)
|
189
|
+
end
|
190
|
+
|
191
|
+
# POST method
|
192
|
+
def post(e, json='{}')
|
193
|
+
element = e
|
194
|
+
element << "?uuid=#{@uuid}"
|
195
|
+
@http.post_json(element, JSON.generate(json))
|
196
|
+
end
|
197
|
+
|
198
|
+
end
|
199
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
class Mu
|
2
|
+
class System
|
3
|
+
include Helper
|
4
|
+
|
5
|
+
attr_accessor :host, :docroot, :username, :password
|
6
|
+
|
7
|
+
def initialize(host=ENV['MU_IP'], username=ENV['MU_ADMIN_USER'], password=ENV['MU_ADMIN_PASS'])
|
8
|
+
@host = host
|
9
|
+
@username = username
|
10
|
+
@password = password
|
11
|
+
@docroot = "/api/v5/system/"
|
12
|
+
@cookie = ""
|
13
|
+
@response = nil
|
14
|
+
@http = HttpHelper.new(@host, @username, @password, @docroot)
|
15
|
+
msg "Created System Api object to :#{@host}", Logger::DEBUG
|
16
|
+
end
|
17
|
+
|
18
|
+
# restarts the Mu system
|
19
|
+
def restart
|
20
|
+
response = @http.get("restart/")
|
21
|
+
msg response, Logger::DEBUG
|
22
|
+
return response
|
23
|
+
end
|
24
|
+
|
25
|
+
# returns Mu System status
|
26
|
+
def status
|
27
|
+
response = @http.get("status/")
|
28
|
+
msg response, Logger::DEBUG
|
29
|
+
return response
|
30
|
+
end
|
31
|
+
|
32
|
+
# returns more Mu System status
|
33
|
+
def status2
|
34
|
+
response = @http.get("status2/")
|
35
|
+
msg response, Logger::DEBUG
|
36
|
+
return response
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end # Mu
|