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
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.
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_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_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 included from Helper
#ask, #error, #format_float, #get_file_as_string_array, #msg, #shift, #to_boolean
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
177 178 179 180 181 182 183 184 |
# File 'lib/mu/command/cmd_muapi.rb', line 177 def cmd_archive argv setup argv command = @hash['command'] job_id = @hash['uuid'] response = @api.archive(command, job_id) 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)
194 195 196 197 198 199 200 201 |
# File 'lib/mu/command/cmd_muapi.rb', line 194 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
211 212 213 214 215 216 217 218 219 |
# File 'lib/mu/command/cmd_muapi.rb', line 211 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
89 90 91 92 93 94 95 |
# File 'lib/mu/command/cmd_muapi.rb', line 89 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
150 151 152 153 154 155 156 157 |
# File 'lib/mu/command/cmd_muapi.rb', line 150 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
161 162 163 164 165 166 167 |
# File 'lib/mu/command/cmd_muapi.rb', line 161 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
99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/mu/command/cmd_muapi.rb', line 99 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
115 116 117 118 119 120 121 |
# File 'lib/mu/command/cmd_muapi.rb', line 115 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_list(argv) ⇒ Object
lists all templates of the given type
* argv = command-line arguments, requires a type (-t) argument, such as 'scenario'
134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/mu/command/cmd_muapi.rb', line 134 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
69 70 71 72 73 74 75 |
# File 'lib/mu/command/cmd_muapi.rb', line 69 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
79 80 81 82 83 84 85 |
# File 'lib/mu/command/cmd_muapi.rb', line 79 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_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
59 60 61 62 63 64 65 |
# File 'lib/mu/command/cmd_muapi.rb', line 59 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
125 126 127 128 129 130 |
# File 'lib/mu/command/cmd_muapi.rb', line 125 def cmd_types argv setup argv response = @api.types msg response return response end |