Class: Mu::Command::Cmd_muapi
- Inherits:
-
Mu::Command
- Object
- Mu::Command
- Mu::Command::Cmd_muapi
- Defined in:
- lib/mu/command/cmd_muapi.rb
Constant Summary
Constants inherited from Mu::Command
Constants included from Helper
Instance Attribute Summary collapse
-
#api ⇒ Object
Returns the value of attribute api.
-
#docroot ⇒ Object
Returns the value of attribute docroot.
-
#host ⇒ Object
Returns the value of attribute host.
-
#password ⇒ Object
Returns the value of attribute password.
-
#username ⇒ Object
Returns the value of attribute username.
Attributes inherited from Mu::Command
Instance Method Summary collapse
-
#cmd_archive(argv) ⇒ Object
archive has a set of three commands that are used to generate and download an archive of all data produced by a particular test ex: * argv = command-line arguments, requires a command (-c) argument * command=run returns the job_id * command=status (called after ‘run’), requires the job_id (-u) argument * command=get (called when status returns “Finished”), requires the job_id (-u) argument.
-
#cmd_backup(argv) ⇒ Object
backup has a set of three commands that are used to generate, query and retrieve a backup ex: * argv = command-line arguments, requires a command (-c) argument * command=run returns the job_id * command=status (called after ‘run’) * command=get (called when status returns “Finished”), requires the name (-n) argument * name = backup file name (will be given a .dat extension).
-
#cmd_capture(argv) ⇒ Object
capture has a set of three commands that are used to generate packet captures, poll the status and return the resulting file ex: * argv = command-line arguments, requires a command (-c) argument * command=run returns the job_id * command=status (called after ‘run’), requires the job_id (-u) argument * command=get (called when status returns “Finished”), requires the job_id (-u) argument * port = the Mu interface on which to capture packets.
-
#cmd_delete(argv) ⇒ Object
delets an analysis or template of any type * argv = command-line arguments, requires a uuid (-u) argument specifying the test.
-
#cmd_export_by_type_and_name(argv) ⇒ Object
exports a template by type and name * argv = command-line arguments, requires a template type (-t) and template name (-n) argument.
-
#cmd_export_by_uuid(argv) ⇒ Object
exports a template by uuid * argv = command-line arguments, requires a template uuid (-u) argument.
-
#cmd_get_faults(argv) ⇒ Object
returns a list of faults (if any) for the analysis * argv = command-line arguments, requires a uuid (-u) argument specifying the test.
-
#cmd_get_name(argv) ⇒ Object
returns the name of a test referenced by uuid * argv = command-line arguments, requires a uuid (-u) argument specifying the test.
-
#cmd_help(argv) ⇒ Object
displays command-line help * argv = command-line arguments.
-
#cmd_import_templates(argv) ⇒ Object
imports xml templates, ex: import_templates(“/path/my_template_file.xml”) * argv = command-line arguments, requires a template file (-f).
-
#cmd_list(argv) ⇒ Object
lists all templates of the given type * argv = command-line arguments, requires a type (-t) argument, such as ‘scenario’.
-
#cmd_list_by_status(argv) ⇒ Object
for any of the possible status values, returns a list of analysis * argv = command-line arguments, requires the status (-s) argument, specifying the values to query, such as ‘running’ or ‘failed’.
-
#cmd_pause(argv) ⇒ Object
pauses a running analysis.
-
#cmd_resume(argv) ⇒ Object
resumes a paused analysis * argv = command-line arguments, requires a uuid (-u) argument specifying the test.
-
#cmd_run(argv) ⇒ Object
runs an analysis, reference is the posted uuid ex: run(1234-1234-1234-1234, “new_name”) * argv = command-line arguments, requires a uuid (-u) and an optional name such that each successive run of the same uuid yields a new name.
-
#cmd_run_template(argv) ⇒ Object
runs an analysis, reference is the posted uuid ex: cmd_run_template(“/path/my_template_file.xml”, “my_new_name_for_test”) * argv = command-line arguments, requires a template file (-f) and an optional name such that each successive run of the same uuid yields a new name.
-
#cmd_status(argv) ⇒ Object
returns the status of a particular analysis * argv = command-line argumentsm require a uuid (-u) argument, specifying a test on the Mu.
-
#cmd_stop(argv) ⇒ Object
aborts a running analysis.
-
#cmd_types(argv) ⇒ Object
returns the types of templates on the Mu * argv = command-line arguments.
Methods inherited from Mu::Command
Methods included from Helper
#ask, #bin2hex, #error, #escape, #format_float, #get_file_as_string_array, #make_xml, #msg, #shift, #to_boolean
Constructor Details
This class inherits a constructor from Mu::Command
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
8 9 10 |
# File 'lib/mu/command/cmd_muapi.rb', line 8 def api @api end |
#docroot ⇒ Object
Returns the value of attribute docroot.
8 9 10 |
# File 'lib/mu/command/cmd_muapi.rb', line 8 def docroot @docroot end |
#host ⇒ Object
Returns the value of attribute host.
8 9 10 |
# File 'lib/mu/command/cmd_muapi.rb', line 8 def host @host end |
#password ⇒ Object
Returns the value of attribute password.
8 9 10 |
# File 'lib/mu/command/cmd_muapi.rb', line 8 def password @password end |
#username ⇒ Object
Returns the value of attribute username.
8 9 10 |
# File 'lib/mu/command/cmd_muapi.rb', line 8 def username @username end |
Instance Method Details
#cmd_archive(argv) ⇒ Object
archive has a set of three commands that are used to generate and download an archive of all data produced by a particular test ex:
* argv = command-line arguments, requires a command (-c) argument
* command=run returns the job_id
* command=status (called after 'run'), requires the job_id (-u) argument
* command=get (called when status returns "Finished"), requires the job_id (-u) argument
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
# File 'lib/mu/command/cmd_muapi.rb', line 204 def cmd_archive argv setup argv command = @hash['command'] job_id = @hash['uuid'] includes = @hash['include'] filepath = @hash['filepath'] if filepath==nil filepath = "." end notes,title="" pcaps,evts = true sign,logo,samples,audit = false if includes!=nil pcaps,evts = false includes.split(",").each do | option | if option=="pcaps" pcaps=true elsif option=="evts" evts = true elsif option=="sign" sign = true elsif option=="logo" logo = true elsif option=="samples" samples = true elsif option=="audit" audit = true elsif option.match(/^notes=/) matches = option.match(/^notes=(.+)/) if matches!=nil notes = matches[1] end elsif option.match(/^title=/) matches = option.match(/^title=(.+)/) if matches!=nil title = matches[1] end end end end response = @api.archive(command, job_id, filepath, title, notes, evts, pcaps, samples, logo, audit, sign) msg response return response end |
#cmd_backup(argv) ⇒ Object
backup has a set of three commands that are used to generate, query and retrieve a backup ex:
* argv = command-line arguments, requires a command (-c) argument
* command=run returns the job_id
* command=status (called after 'run')
* command=get (called when status returns "Finished"), requires the name (-n) argument
* name = backup file name (will be given a .dat extension)
257 258 259 260 261 262 263 264 |
# File 'lib/mu/command/cmd_muapi.rb', line 257 def cmd_backup argv setup argv command = @hash['command'] name = @hash['name'] response = @api.backup(command, name) msg response return response end |
#cmd_capture(argv) ⇒ Object
capture has a set of three commands that are used to generate packet captures, poll the status and return the resulting file ex:
* argv = command-line arguments, requires a command (-c) argument
* command=run returns the job_id
* command=status (called after 'run'), requires the job_id (-u) argument
* command=get (called when status returns "Finished"), requires the job_id (-u) argument
* port = the Mu interface on which to capture packets
274 275 276 277 278 279 280 281 282 |
# File 'lib/mu/command/cmd_muapi.rb', line 274 def cmd_capture argv setup argv command = @hash['command'] port = @hash['port'] job_id = @hash['uuid'] response = @api.capture(command, port, job_id) msg response return response end |
#cmd_delete(argv) ⇒ Object
delets an analysis or template of any type
* argv = command-line arguments, requires a uuid (-u) argument specifying the test
116 117 118 119 120 121 122 |
# File 'lib/mu/command/cmd_muapi.rb', line 116 def cmd_delete argv setup argv uuid = @hash['uuid'] response = @api.delete(uuid) msg response return response end |
#cmd_export_by_type_and_name(argv) ⇒ Object
exports a template by type and name
* argv = command-line arguments, requires a template type (-t) and template name (-n) argument
177 178 179 180 181 182 183 184 |
# File 'lib/mu/command/cmd_muapi.rb', line 177 def cmd_export_by_type_and_name argv setup argv type = @hash['type'] name = @hash['name'] response = @api.export_by_type_and_name(type, name) msg response return response end |
#cmd_export_by_uuid(argv) ⇒ Object
exports a template by uuid
* argv = command-line arguments, requires a template uuid (-u) argument
188 189 190 191 192 193 194 |
# File 'lib/mu/command/cmd_muapi.rb', line 188 def cmd_export_by_uuid argv setup argv uuid = @hash['uuid'] response = @api.export_by_uuid(uuid) msg response return response end |
#cmd_get_faults(argv) ⇒ Object
returns a list of faults (if any) for the analysis
* argv = command-line arguments, requires a uuid (-u) argument specifying the test
126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/mu/command/cmd_muapi.rb', line 126 def cmd_get_faults argv setup argv uuid = @hash['uuid'] response = @api.get_faults(uuid) if response.is_a?(Array) response.each do | r | msg r end else msg response end return response end |
#cmd_get_name(argv) ⇒ Object
returns the name of a test referenced by uuid
* argv = command-line arguments, requires a uuid (-u) argument specifying the test
142 143 144 145 146 147 148 |
# File 'lib/mu/command/cmd_muapi.rb', line 142 def cmd_get_name argv setup argv uuid = @hash['uuid'] response = @api.get_name(uuid) msg response return response end |
#cmd_help(argv) ⇒ Object
displays command-line help
* argv = command-line arguments
12 13 14 |
# File 'lib/mu/command/cmd_muapi.rb', line 12 def cmd_help argv help end |
#cmd_import_templates(argv) ⇒ Object
imports xml templates, ex: import_templates(“/path/my_template_file.xml”)
* argv = command-line arguments, requires a template file (-f)
76 77 78 79 80 81 82 |
# File 'lib/mu/command/cmd_muapi.rb', line 76 def cmd_import_templates argv setup argv template_file = @hash['filepath'] response = @api.import_templates(template_file) msg response return response end |
#cmd_list(argv) ⇒ Object
lists all templates of the given type
* argv = command-line arguments, requires a type (-t) argument, such as 'scenario'
161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/mu/command/cmd_muapi.rb', line 161 def cmd_list argv setup argv type = @hash['type'] response = @api.list(type) if response.is_a?(Array) response.each do | r | msg r end else msg response end return response end |
#cmd_list_by_status(argv) ⇒ Object
for any of the possible status values, returns a list of analysis
* argv = command-line arguments, requires the status (-s) argument, specifying the values to query, such as 'running' or 'failed'
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/mu/command/cmd_muapi.rb', line 18 def cmd_list_by_status argv setup argv status = @hash['status'] response = @api.list_by_status(status) if response.is_a?(Array) response.each do | r | msg r end else msg response end end |
#cmd_pause(argv) ⇒ Object
pauses a running analysis. Note that any queued analysis will NOT begin
* argv = command-line arguments, requires a uuid (-u) argument specifying the test
96 97 98 99 100 101 102 |
# File 'lib/mu/command/cmd_muapi.rb', line 96 def cmd_pause argv setup argv uuid = @hash['uuid'] response = @api.pause(uuid) msg response return response end |
#cmd_resume(argv) ⇒ Object
resumes a paused analysis
* argv = command-line arguments, requires a uuid (-u) argument specifying the test
106 107 108 109 110 111 112 |
# File 'lib/mu/command/cmd_muapi.rb', line 106 def cmd_resume argv setup argv uuid = @hash['uuid'] response = @api.resume(uuid) msg response return response end |
#cmd_run(argv) ⇒ Object
runs an analysis, reference is the posted uuid ex: run(1234-1234-1234-1234, “new_name”)
* argv = command-line arguments, requires a uuid (-u) and an optional name such that each successive run of the same uuid yields a new name
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/mu/command/cmd_muapi.rb', line 44 def cmd_run argv setup argv uuid = @hash['uuid'] if @hash['boolean'].nil? rename = "" else rename = @hash['boolean'] end response = @api.run(uuid, rename) msg response return response end |
#cmd_run_template(argv) ⇒ Object
runs an analysis, reference is the posted uuid ex: cmd_run_template(“/path/my_template_file.xml”, “my_new_name_for_test”)
* argv = command-line arguments, requires a template file (-f) and an optional name such that each successive run of the same uuid yields a new name
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/mu/command/cmd_muapi.rb', line 60 def cmd_run_template argv setup argv filepath = @hash['filepath'] if @hash['boolean'].nil? rename = "" else rename = @hash['boolean'] end response = @api.run_from_template(filepath, rename) msg response return response end |
#cmd_status(argv) ⇒ Object
returns the status of a particular analysis
* argv = command-line argumentsm require a uuid (-u) argument, specifying a test on the Mu
33 34 35 36 37 38 39 |
# File 'lib/mu/command/cmd_muapi.rb', line 33 def cmd_status argv setup argv uuid = @hash['uuid'] response = @api.status(uuid) msg response return response end |
#cmd_stop(argv) ⇒ Object
aborts a running analysis. the next queued analysis will start
* argv = command-line arguments, requires a uuid (-u) argument specifying the test
86 87 88 89 90 91 92 |
# File 'lib/mu/command/cmd_muapi.rb', line 86 def cmd_stop argv setup argv uuid = @hash['uuid'] response = @api.stop(uuid) msg response return response end |
#cmd_types(argv) ⇒ Object
returns the types of templates on the Mu
* argv = command-line arguments
152 153 154 155 156 157 |
# File 'lib/mu/command/cmd_muapi.rb', line 152 def cmd_types argv setup argv response = @api.types msg response return response end |