mu 5.7.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. data/Mu_Gem.html +1591 -0
  2. data/bin/mu +11 -0
  3. data/lib/mu.rb +65 -0
  4. data/lib/mu/api/ddt.rb +233 -0
  5. data/lib/mu/api/homepage.rb +54 -0
  6. data/lib/mu/api/muapi.rb +231 -0
  7. data/lib/mu/api/netconfig.rb +233 -0
  8. data/lib/mu/api/scale.rb +199 -0
  9. data/lib/mu/api/system.rb +40 -0
  10. data/lib/mu/client.rb +31 -0
  11. data/lib/mu/command.rb +28 -0
  12. data/lib/mu/command/api.rb +95 -0
  13. data/lib/mu/command/cmd_appid.rb +486 -0
  14. data/lib/mu/command/cmd_cli.rb +151 -0
  15. data/lib/mu/command/cmd_ddt.rb +449 -0
  16. data/lib/mu/command/cmd_homepage.rb +146 -0
  17. data/lib/mu/command/cmd_muapi.rb +361 -0
  18. data/lib/mu/command/cmd_netconfig.rb +262 -0
  19. data/lib/mu/command/cmd_runscale.rb +533 -0
  20. data/lib/mu/command/cmd_runscenario.rb +258 -0
  21. data/lib/mu/command/cmd_runverify.rb +336 -0
  22. data/lib/mu/command/cmd_scale.rb +333 -0
  23. data/lib/mu/command/cmd_system.rb +127 -0
  24. data/lib/mu/command/curl.rb +246 -0
  25. data/lib/mu/command/help.rb +29 -0
  26. data/lib/mu/curl/error.rb +54 -0
  27. data/lib/mu/curl/verify.rb +137 -0
  28. data/lib/mu/helper.rb +55 -0
  29. data/lib/mu/http_helper.rb +232 -0
  30. data/rdoc/classes/Mu.html +305 -0
  31. data/rdoc/classes/Mu/Client.html +265 -0
  32. data/rdoc/classes/Mu/Command.html +208 -0
  33. data/rdoc/classes/Mu/Command/API.html +524 -0
  34. data/rdoc/classes/Mu/Command/Cmd_appid.html +934 -0
  35. data/rdoc/classes/Mu/Command/Cmd_cli.html +515 -0
  36. data/rdoc/classes/Mu/Command/Cmd_ddt.html +1169 -0
  37. data/rdoc/classes/Mu/Command/Cmd_homepage.html +489 -0
  38. data/rdoc/classes/Mu/Command/Cmd_muapi.html +968 -0
  39. data/rdoc/classes/Mu/Command/Cmd_netconfig.html +743 -0
  40. data/rdoc/classes/Mu/Command/Cmd_runscale.html +970 -0
  41. data/rdoc/classes/Mu/Command/Cmd_runscenario.html +530 -0
  42. data/rdoc/classes/Mu/Command/Cmd_runverify.html +621 -0
  43. data/rdoc/classes/Mu/Command/Cmd_scale.html +939 -0
  44. data/rdoc/classes/Mu/Command/Cmd_system.html +426 -0
  45. data/rdoc/classes/Mu/Command/Curl.html +524 -0
  46. data/rdoc/classes/Mu/Command/Help.html +166 -0
  47. data/rdoc/classes/Mu/Curl.html +116 -0
  48. data/rdoc/classes/Mu/Curl/Error.html +157 -0
  49. data/rdoc/classes/Mu/Curl/Error/Authorize.html +178 -0
  50. data/rdoc/classes/Mu/Curl/Error/Connect.html +149 -0
  51. data/rdoc/classes/Mu/Curl/Error/DNS.html +113 -0
  52. data/rdoc/classes/Mu/Curl/Error/Region.html +160 -0
  53. data/rdoc/classes/Mu/Curl/Error/Status.html +149 -0
  54. data/rdoc/classes/Mu/Curl/Error/Timeout.html +149 -0
  55. data/rdoc/classes/Mu/Curl/Verify.html +282 -0
  56. data/rdoc/classes/Mu/Curl/Verify/Request.html +227 -0
  57. data/rdoc/classes/Mu/Curl/Verify/Response.html +187 -0
  58. data/rdoc/classes/Mu/Curl/Verify/Result.html +188 -0
  59. data/rdoc/classes/Mu/Ddt.html +914 -0
  60. data/rdoc/classes/Mu/Helper.html +308 -0
  61. data/rdoc/classes/Mu/Homepage.html +377 -0
  62. data/rdoc/classes/Mu/HttpHelper.html +639 -0
  63. data/rdoc/classes/Mu/Muapi.html +816 -0
  64. data/rdoc/classes/Mu/Netconfig.html +781 -0
  65. data/rdoc/classes/Mu/Scale.html +832 -0
  66. data/rdoc/classes/Mu/System.html +281 -0
  67. data/rdoc/classes/Object.html +148 -0
  68. data/rdoc/classes/TCTestMu.html +1793 -0
  69. data/rdoc/classes/Test.html +107 -0
  70. data/rdoc/classes/Test/Unit.html +107 -0
  71. data/rdoc/classes/Test/Unit/TestCase.html +113 -0
  72. data/rdoc/created.rid +1 -0
  73. data/rdoc/files/lib/mu/api/ddt_rb.html +101 -0
  74. data/rdoc/files/lib/mu/api/homepage_rb.html +101 -0
  75. data/rdoc/files/lib/mu/api/muapi_rb.html +101 -0
  76. data/rdoc/files/lib/mu/api/netconfig_rb.html +101 -0
  77. data/rdoc/files/lib/mu/api/scale_rb.html +101 -0
  78. data/rdoc/files/lib/mu/api/system_rb.html +101 -0
  79. data/rdoc/files/lib/mu/client_rb.html +101 -0
  80. data/rdoc/files/lib/mu/command/api_rb.html +101 -0
  81. data/rdoc/files/lib/mu/command/cmd_appid_rb.html +119 -0
  82. data/rdoc/files/lib/mu/command/cmd_cli_rb.html +108 -0
  83. data/rdoc/files/lib/mu/command/cmd_ddt_rb.html +117 -0
  84. data/rdoc/files/lib/mu/command/cmd_homepage_rb.html +115 -0
  85. data/rdoc/files/lib/mu/command/cmd_muapi_rb.html +116 -0
  86. data/rdoc/files/lib/mu/command/cmd_netconfig_rb.html +116 -0
  87. data/rdoc/files/lib/mu/command/cmd_runscale_rb.html +119 -0
  88. data/rdoc/files/lib/mu/command/cmd_runscenario_rb.html +115 -0
  89. data/rdoc/files/lib/mu/command/cmd_runverify_rb.html +117 -0
  90. data/rdoc/files/lib/mu/command/cmd_scale_rb.html +115 -0
  91. data/rdoc/files/lib/mu/command/cmd_system_rb.html +116 -0
  92. data/rdoc/files/lib/mu/command/curl_rb.html +101 -0
  93. data/rdoc/files/lib/mu/command/help_rb.html +101 -0
  94. data/rdoc/files/lib/mu/command_rb.html +107 -0
  95. data/rdoc/files/lib/mu/curl/error_rb.html +101 -0
  96. data/rdoc/files/lib/mu/curl/verify_rb.html +101 -0
  97. data/rdoc/files/lib/mu/helper_rb.html +101 -0
  98. data/rdoc/files/lib/mu/http_helper_rb.html +101 -0
  99. data/rdoc/files/lib/mu_rb.html +121 -0
  100. data/rdoc/files/test/helper_rb.html +112 -0
  101. data/rdoc/files/test/tc_test_mu_rb.html +111 -0
  102. data/rdoc/fr_class_index.html +68 -0
  103. data/rdoc/fr_file_index.html +55 -0
  104. data/rdoc/fr_method_index.html +374 -0
  105. data/rdoc/index.html +24 -0
  106. data/rdoc/rdoc-style.css +208 -0
  107. data/test/data/app_id_stats.csv +1 -0
  108. data/test/data/data_cgi.msl +94 -0
  109. data/test/data/data_cgi.xml +322 -0
  110. data/test/data/default_test.csv +3 -0
  111. data/test/data/ftp_with_channel.xml +1643 -0
  112. data/test/data/irc.xml +3837 -0
  113. data/test/data/scale_configuration.json +25 -0
  114. data/test/data/test_data_cgi_error.xml +35 -0
  115. data/test/helper.rb +18 -0
  116. data/test/tc_test_mu.rb +716 -0
  117. metadata +322 -0
data/bin/mu ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
4
+ $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
5
+
6
+ require 'mu'
7
+
8
+ argv = ARGV.dup
9
+ ARGV.clear
10
+ cmd = argv.shift.strip rescue 'help'
11
+ Mu.run cmd, argv
@@ -0,0 +1,65 @@
1
+ require 'rubygems'
2
+ require 'hexy'
3
+ require 'json/pure'
4
+ require 'logger'
5
+ require 'net/https'
6
+ require 'nokogiri'
7
+ require 'restclient'
8
+ require 'uri'
9
+
10
+ # Command-line tools and applications for using the Mu Dynamics REST Api's
11
+ class Mu
12
+ require 'mu/helper'
13
+ @version = "5.7.2"
14
+ Version = @version.freeze
15
+ $log = Logger.new(STDOUT)
16
+ $cookie = nil # http_helper
17
+
18
+ extend Mu::Helper
19
+
20
+ def self.run cmd, argv
21
+ $log.datetime_format = "%Y-%m-%d %H:%M:%S"
22
+ $log.level = Logger::INFO
23
+ $log.formatter = proc { |severity, datetime, progname, msg|
24
+ "[#{datetime} #{severity}]: #{msg}\n"
25
+ }
26
+
27
+ check_version
28
+
29
+ kname, mname = cmd.split(':', 2)
30
+ klass = Mu::Command.const_get kname.capitalize rescue nil
31
+ mname ||= 'default'
32
+ mname = "cmd_#{mname}".to_sym
33
+ if klass and klass < Mu::Command and klass.method_defined? mname
34
+ command = klass.new
35
+ begin
36
+ command.send mname, argv
37
+ rescue => e
38
+ error e.message.chomp('.')
39
+ end
40
+ else
41
+ error "Unknown command #{cmd}"
42
+ end
43
+ end
44
+
45
+ def self.check_version
46
+ begin
47
+ api = Mu::System.new(ENV['MU_IP'], ENV['MU_ADMIN_USER'], ENV['MU_ADMIN_PASS'])
48
+ resp = Nokogiri::XML(api.status)
49
+ version_string = resp.xpath("//versions/platform")[0].content
50
+ version = version_string[0...version_string.rindex(".")]
51
+ if @version > version
52
+ puts "Warning. Version mismatch. Mu Gem version (#{@version}) is higher than Mu Platform version (#{version})"
53
+ end
54
+ rescue => e
55
+ puts "#{e}. Check Mu env settings: $MU_IP (#{ENV['MU_IP']}), $MU_ADMIN_USER (#{ENV['MU_ADMIN_USER']}), $MU_ADMIN_PASS (#{ENV['MU_ADMIN_PASS']}) "
56
+ end
57
+
58
+ end
59
+ end
60
+
61
+ require 'mu/client'
62
+ require 'mu/curl/error'
63
+ require 'mu/curl/verify'
64
+ require 'mu/command'
65
+ require 'mu/http_helper'
@@ -0,0 +1,233 @@
1
+ class Mu
2
+ class Ddt
3
+ include Helper
4
+
5
+ attr_accessor :host, :docroot, :username, :password, :session_id
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/ddt/"
12
+ @session_id = nil
13
+ @http = HttpHelper.new(@host, @username, @password, @docroot)
14
+ msg "Created Ddt Api object to :#{@host}", Logger::DEBUG
15
+ end
16
+
17
+ # verifies the loaded scenario
18
+ def run
19
+ response = @http.post("session/test/run")
20
+ msg response, Logger::DEBUG
21
+ return response
22
+ end
23
+
24
+ # sets and executes test suite
25
+ # * uuid = the uuid of a testset loaded on the Mu
26
+ def run_testset(uuid)
27
+ response = @http.post("session/test/runSuite/#{uuid}")
28
+ msg response, Logger::DEBUG
29
+ return response
30
+ end
31
+
32
+ # must be called first to establish a new Studio Verify session
33
+ def new_session
34
+ reply = @http.post("newSession") # with no args
35
+ response = reply["response"]
36
+ msg response, Logger::DEBUG
37
+ @session_id = response["sessionId"]
38
+ msg @session_id, Logger::DEBUG
39
+ return @session_id
40
+ end
41
+
42
+ # closes the existing Studio Verify session
43
+ def close_session
44
+ response = @http.get("session/closeSession")
45
+ msg response, Logger::DEBUG
46
+ return response
47
+ end
48
+
49
+ # returns array of session_ids
50
+ def get_sessions
51
+ all_sessions = Array.new
52
+ response = @http.get("") # with no args
53
+ sessions = response["sessions"]
54
+ if !sessions["session"].nil?
55
+ num = sessions["session"].size
56
+ if num > 1
57
+ sessions["session"].each do | s |
58
+ all_sessions << s["id"]
59
+ end
60
+ else # special case if there is only one (there is no array)
61
+ all_sessions << sessions["session"]["id"]
62
+ end
63
+ return all_sessions
64
+ end
65
+ return nil
66
+ end
67
+
68
+ # closes all Studio Verify sessions
69
+ def close_all_sessions
70
+ response = @http.post("closeAllSessions")
71
+ msg response, Logger::DEBUG
72
+ return response
73
+ end
74
+
75
+ # returns the session id's of all existing Studio Verify sessions
76
+ def get_all_sessions
77
+ response = @http.get("getAllSessions")
78
+ msg response, Logger::DEBUG
79
+ return response
80
+ end
81
+
82
+ # sets up a test for run
83
+ def setup_test
84
+ response = @http.post("session/setupTest")
85
+ msg response, Logger::DEBUG
86
+ return response
87
+ end
88
+
89
+ # tears down a test
90
+ def teardown_test
91
+ response = @http.post("session/test/tearDownTest")
92
+ msg response, Logger::DEBUG
93
+ return response
94
+ end
95
+
96
+ # loads a scenario
97
+ # * the uuid of a scenario present on the Mu
98
+ def load_scenario(uuid)
99
+ response = @http.post("session/loadScenario/#{uuid}")
100
+ msg response, Logger::DEBUG
101
+ return response
102
+ end
103
+
104
+ # returns the hosts in the loaded scenario
105
+ def get_hosts
106
+ response = @http.get("session/scenario/hosts")
107
+ msg response, Logger::DEBUG
108
+ return response
109
+ end
110
+
111
+ # sets the hosts in the loaded scenario
112
+ # * roles = an array of the host roles defined in the scenario
113
+ # * names = an array of host names to be mapped to the roles
114
+ # * type = network layer type (v4, v6 or l2) matching the defined hosts
115
+ def set_hosts(roles=[], names=[], type="v4")
116
+ responses = Array.new
117
+ hosts = roles.length.to_i
118
+ hosts.times do | i |
119
+ response = @http.post("session/scenario/hosts/#{roles[i]}/#{names[i]}/#{type}")
120
+ responses << response
121
+ end
122
+ msg responses, Logger::DEBUG
123
+ return responses
124
+ end
125
+
126
+ # returns the channel elements of the loaded scenario
127
+ def get_channels
128
+ response = @http.get("session/scenario/channels")
129
+ msg response, Logger::DEBUG
130
+ return response
131
+ end
132
+
133
+ # sets the channel elements of the loaded scenario
134
+ # * roles = an array of the roles defined for the channels in the scenario ('channel')
135
+ # * names = an array of host names to be mapped to the roles
136
+ def set_channels(roles=[], names=[])
137
+ responses = Array.new
138
+ roles.length.times do | i |
139
+ response = @http.post("session/scenario/channels/#{roles[i]}/#{names[i]}")
140
+ responses << response
141
+ end
142
+ msg responses, Logger::DEBUG
143
+ return responses
144
+ end
145
+
146
+ # returns the options from the loaded scenario
147
+ def get_options
148
+ response = @http.get("session/scenario/options")
149
+ msg response, Logger::DEBUG
150
+ return response
151
+ end
152
+
153
+ # sets the options for the loaded scenario
154
+ # * an array of option names
155
+ # * an array of option values
156
+ def set_options(names=[], values=[])
157
+ responses = Array.new
158
+ names.length.times do | i |
159
+ response = @http.post("session/scenario/options/#{names[i]}/#{values[i]}")
160
+ responses << response
161
+ end
162
+ msg responses, Logger::DEBUG
163
+ return responses
164
+ end
165
+
166
+ # collects results until the test is done or the timeout expires
167
+ # * timeout = time in seconds to wait for the test to complete
168
+ def collect_results(timeout=120)
169
+ wait_until_done(timeout)
170
+ results = get_testset_results
171
+ return results
172
+ end
173
+
174
+ # waits until the test is done or the timeout expires
175
+ # * timeout = the time in seconds to wait for the test to complete
176
+ def wait_until_done(timeout=120)
177
+ finished = false
178
+ interval = timeout / 10
179
+ 10.times do
180
+ begin
181
+ response = get_testset_status
182
+ #msg "wait_until_done, response = #{response}", Logger::DEBUG
183
+ if !response.nil?
184
+ if response.to_s.include?("Done")
185
+ finished = true
186
+ return finished
187
+ end
188
+ end
189
+ rescue Exception => e
190
+ puts e, Logger::DEBUG # status may not be ready right away. may return a 500
191
+ end
192
+ sleep interval
193
+ end
194
+ return finished
195
+ end
196
+
197
+ # returns the status of a running test set
198
+ def get_testset_status
199
+ response = @http.get("session/test/runSuite/status")
200
+ msg response, Logger::DEBUG
201
+ return response
202
+ end
203
+
204
+ # returns the results of a running test set. can be called repeatedly.
205
+ # the test is done when the results include the 'END' keyword
206
+ def get_testset_results
207
+ response = @http.get("session/test/runSuite/results")
208
+ msg response, Logger::DEBUG
209
+ return response
210
+ end
211
+
212
+ # exports a testset to a csv file
213
+ # * uuid = the uuid of the testset to export
214
+ def csv_export(uuid=@testset)
215
+ response = @http.post("session/test/export/csv/#{uuid}")
216
+ msg response, Logger::DEBUG
217
+ return response
218
+ end
219
+
220
+
221
+ # imports a csv file to the Mu
222
+ # * filepath = the path to the csv file
223
+ def csv_import(filepath)
224
+ return "new_session required" if $cookie.nil? or $cookie["testSessionId"].nil?
225
+ testSessionId = $cookie["testSessionId"]
226
+ response = @http.post_form("session/test/import/csv?testSessionId=#{testSessionId}", filepath)
227
+ msg response, Logger::DEBUG
228
+ return response
229
+ end
230
+
231
+ end
232
+ end
233
+
@@ -0,0 +1,54 @@
1
+ class Mu
2
+ class Homepage
3
+ include Helper
4
+
5
+ attr_accessor :host, :docroot, :cookie, :username, :password, :session_id, :results, :posted_uuid, :testsuite, :results, :failed, :errors
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/homepage/"
12
+ @cookie = ""
13
+ @response = nil
14
+ @http = HttpHelper.new(@host, @username, @password, @docroot)
15
+ msg "Created Homepage object to :#{@host}", Logger::DEBUG
16
+ end
17
+
18
+ # returns all homepage elements
19
+ def all
20
+ response = @http.get("all/")
21
+ msg response, Logger::DEBUG
22
+ return response
23
+ end
24
+
25
+ # returns recent homepage activity
26
+ def recent
27
+ response = @http.get("recent/")
28
+ msg response, Logger::DEBUG
29
+ return response
30
+ end
31
+
32
+ # returns homepage status
33
+ def status
34
+ response = @http.get("status/")
35
+ msg response, Logger::DEBUG
36
+ return response
37
+ end
38
+
39
+ # returns the latest test
40
+ def latest_test
41
+ response = @http.get("test/latest/")
42
+ msg response, Logger::DEBUG
43
+ return response
44
+ end
45
+
46
+ # returns queued tests
47
+ def queue_test
48
+ response = @http.get("test/queue/")
49
+ msg response, Logger::DEBUG
50
+ return response
51
+ end
52
+
53
+ end
54
+ end # Mu
@@ -0,0 +1,231 @@
1
+ class Mu
2
+ class Muapi
3
+ include Helper
4
+
5
+ attr_accessor :host, :docroot, :posted_uuid, :run_uuid, :job_id, :username, :password, :params, :expected_error
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/v3/"
12
+ @params = nil
13
+ @expected_error = nil
14
+ @http = HttpHelper.new(@host, @username, @password, @docroot)
15
+ msg "Created Mu Api object to :#{@host}", Logger::DEBUG
16
+ end
17
+
18
+ # lists the statuses of tests
19
+ # * status = the status type, such as 'running' or 'failed'
20
+ def list_by_status(status="")
21
+ uuid_list = Array.new()
22
+ if !status.empty?
23
+ doc = @http.get_xml("analysis/list?status=#{status}")
24
+ else
25
+ doc = @http.get_xml("analysis/list")
26
+ end
27
+ unless doc.xpath("//analysis").empty?
28
+ doc.xpath('//analysis').each { |e| uuid_list << e.attribute('uuid') }
29
+ end
30
+ return uuid_list
31
+ end
32
+
33
+ # returns the status of a test
34
+ # * uuid = the uuid of the test
35
+ def status(uuid=@run_uuid)
36
+ doc = @http.get_xml("analysis/status?uuid=#{uuid}")
37
+ return nil if doc.nil?
38
+ unless doc.xpath("//analysis").empty?
39
+ status = doc.xpath("//status")[0].text
40
+ return status
41
+ end
42
+ return doc
43
+ end
44
+
45
+ # starts a test
46
+ # * uuid = the uuid of the test
47
+ def run(uuid, rename="")
48
+ req = "analysis/run?uuid=#{uuid}"
49
+ unless rename.empty?
50
+ req = "#{req}&rename=#{rename}"
51
+ end
52
+ doc = @http.get_xml(req)
53
+ unless doc.xpath("//analysis").empty?
54
+ @run_uuid = doc.xpath("//analysis")[0].attribute('uuid')
55
+ return @run_uuid
56
+ end
57
+ return @run_uuid
58
+ end
59
+
60
+ # stops a running test
61
+ # * uuid = the uuid of the test
62
+ def stop(uuid=@run_uuid)
63
+ doc = @http.get_xml("analysis/stop?uuid=#{uuid}")
64
+ unless doc.xpath("//analysis").empty?
65
+ status = doc.xpath("//analysis")[0].attribute('status')
66
+ return status
67
+ end
68
+ return false
69
+ end
70
+
71
+ # pauses a running test
72
+ # * uuid = the uuid of the test
73
+ def pause(uuid=@run_uuid)
74
+ doc = @http.get_xml("analysis/pause?uuid=#{uuid}")
75
+ unless doc.xpath("//analysis").empty?
76
+ status = doc.xpath("//analysis")[0].attribute('status')
77
+ return status
78
+ end
79
+ return false
80
+ end
81
+
82
+ # resumes a suspended test
83
+ # * uuid = the uuid of the test
84
+ def resume(uuid=@run_uuid)
85
+ doc = @http.get_xml("analysis/resume?uuid=#{uuid}")
86
+ unless doc.xpath("//analysis").empty?
87
+ status = doc.xpath("//analysis")[0].attribute('status')
88
+ return status
89
+ end
90
+ return false
91
+ end
92
+
93
+ # deletes the specified test
94
+ # * uuid = the uuid of the test
95
+ def delete(uuid=@run_uuid)
96
+ doc = @http.get_xml("analysis/delete?uuid=#{uuid}")
97
+ unless doc.xpath("//analysis").empty?
98
+ status = doc.xpath("//analysis")[0].attribute('status')
99
+ return status
100
+ end
101
+ return true
102
+ end
103
+
104
+ # returns a list of faults from the specified test
105
+ # * uuid = the uuid of the test
106
+ def get_faults(uuid=@run_uuid)
107
+ doc = @http.get_xml("templates/export?uuid=#{uuid}")
108
+ unless doc.xpath("//analysis").empty?
109
+ faults = get_xml("analysis/getFaultList?uuid=#{uuid}",true)
110
+ return faults
111
+ end
112
+ return "error: no analysis with uuid: #{uuid} found"
113
+ end
114
+
115
+ # returns the name of an test
116
+ # * uuid = the uuid of the test
117
+ def get_name(uuid=@run_uuid)
118
+ doc = @http.get_xml("templates/export?uuid=#{uuid}")
119
+ unless doc.xpath("//analysis").empty?
120
+ return doc.xpath("//analysis")[0].attribute('name')
121
+ end
122
+ return
123
+ end
124
+
125
+ # lists the templates on the Mu system using the template type and template name:
126
+ # * type = the template type, such as 'scenario' or 'monitor'
127
+ def list(type)
128
+ names = Array.new
129
+ doc = @http.get_xml("templates/list?type=#{type}")
130
+ doc.xpath("//templates/*").each {|a| names << a.attribute('name') }
131
+ return names
132
+ end
133
+
134
+ # lists the types of templates on the Mu system
135
+ def types
136
+ doc = @http.get("templates/types?")
137
+ return doc
138
+ end
139
+
140
+ # exports a template from the Mu system using the template type and template name
141
+ # * name = the template name
142
+ def export_by_type_and_name(type, name)
143
+ return @http.get_xml("templates/export?type=#{type}&name=#{name}")
144
+ end
145
+
146
+ # exports a template from the Mu system using the template uuid
147
+ # * uuid = the template uuid
148
+ def export_by_uuid(uuid)
149
+ return @http.get_xml("templates/export?uuid=#{uuid}")
150
+ end
151
+
152
+ # performs archive operations
153
+ # * command=run to create a test archive
154
+ # * command=status to view the status of a test archive job
155
+ # * command=get to download a test archive job
156
+ # * uuid = the uuid of the test
157
+ def archive(command="run", id=@run_uuid)
158
+ case command
159
+ when 'run'
160
+ request_string = "archive/run?uuid=#{id}"
161
+ request_string += @params unless @params.nil?
162
+ doc = @http.get_xml(request_string)
163
+ unless doc.xpath("//job").empty?
164
+ @job_id = doc.xpath("//job")[0].attribute('id')
165
+ msg "job_id = #{@job_id}"
166
+ return @job_id
167
+ end
168
+ return doc
169
+ when 'status'
170
+ doc = @http.get("archive/status?jobId=#{id}")
171
+ return doc
172
+ when 'get'
173
+ file_size = @http.download_file("archive/get?jobId=#{id}","#{id}.zip")
174
+ return "#{id}.zip file size = #{file_size}"
175
+ end
176
+ return false
177
+ end
178
+
179
+ # performs backup operations
180
+ # * command=run to create a system backup file.
181
+ # * command=status to view the status of a backup job. If no backup job is running, gets the date of the most recent backup.
182
+ # * command=get to retrieve the backup file
183
+ # * name = backup file name
184
+ def backup(command="run", name="")
185
+ case command
186
+ when 'run'
187
+ doc = @http.get_xml("backup/run")
188
+ unless doc.xpath("//job").empty?
189
+ @job_id = doc.xpath("//job")[0].attribute('id')
190
+ msg "job_id = #{@job_id}"
191
+ return @job_id
192
+ end
193
+ return doc
194
+ when 'status'
195
+ doc = @http.get("backup/status")
196
+ return doc
197
+ when 'get'
198
+ file_size = @http.download_file("backup/get","#{name}.dat")
199
+ return "#{name}.dat file size = #{file_size}"
200
+ end
201
+ return false
202
+ end
203
+
204
+ # packet capture operations
205
+ # * command=run to start capturing packets on the specified Mu appliance port
206
+ # * command=status tp view the status of packet capture activity
207
+ # * command=get to download the pcap file generated during packet capture
208
+ # * port = the Mu appliance port
209
+ # * id = job_id for status and get commands
210
+ def capture(command='run', port='a1', id=@job_id)
211
+ case command
212
+ when 'run'
213
+ doc = @http.get_xml("capture/run?port=#{port}")
214
+ unless doc.xpath("//job").empty?
215
+ @job_id = doc.xpath("//job")[0].attribute('id')
216
+ msg "job_id = #{@job_id}"
217
+ return @job_id
218
+ end
219
+ return doc
220
+ when 'status'
221
+ doc = @http.get("capture/status?jobId=#{id}")
222
+ return doc
223
+ when 'get'
224
+ file_size = @http.download_file("capture/get?jobId=#{id}","#{id}.pcap")
225
+ return "#{id}.pcap file size = #{file_size}"
226
+ end
227
+ return false
228
+ end
229
+
230
+ end
231
+ end # Mu