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,146 @@
|
|
1
|
+
# Api methods to access the Mu System homepage
|
2
|
+
require 'mu/api/homepage'
|
3
|
+
class Mu
|
4
|
+
class Command
|
5
|
+
class Cmd_homepage < Command
|
6
|
+
|
7
|
+
attr_accessor :host, :username, :password, :api
|
8
|
+
|
9
|
+
# displays command-line help
|
10
|
+
# * argv = command-line arguments
|
11
|
+
def cmd_help argv
|
12
|
+
help
|
13
|
+
end
|
14
|
+
|
15
|
+
# returns all homepage information
|
16
|
+
# * argv = command-line arguments
|
17
|
+
def cmd_all argv
|
18
|
+
setup argv
|
19
|
+
response = @api.all
|
20
|
+
msg response
|
21
|
+
return response
|
22
|
+
end
|
23
|
+
|
24
|
+
# returns recent homepage information
|
25
|
+
# * argv = command-line arguments
|
26
|
+
def cmd_recent argv
|
27
|
+
setup argv
|
28
|
+
response = @api.recent
|
29
|
+
msg response
|
30
|
+
return response
|
31
|
+
end
|
32
|
+
|
33
|
+
# returns homepage status information
|
34
|
+
# * argv = command-line arguments
|
35
|
+
def cmd_status argv
|
36
|
+
setup argv
|
37
|
+
response = @api.status
|
38
|
+
msg response
|
39
|
+
return response
|
40
|
+
end
|
41
|
+
|
42
|
+
# returns the latest test
|
43
|
+
# * argv = command-line arguments
|
44
|
+
def cmd_latest_test argv
|
45
|
+
setup argv
|
46
|
+
response = @api.latest_test
|
47
|
+
msg response
|
48
|
+
return response
|
49
|
+
end
|
50
|
+
|
51
|
+
# returns the queued tests
|
52
|
+
# * argv = command-line arguments
|
53
|
+
def cmd_queue_test argv
|
54
|
+
setup argv
|
55
|
+
response = @api.queue_test
|
56
|
+
msg response
|
57
|
+
return response
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def setup argv
|
63
|
+
parse_cli argv
|
64
|
+
@host = (@@mu_ip.nil?) ? "127.0.0.1" : @@mu_ip
|
65
|
+
@username = (@@mu_admin_user.nil?) ? "admin" : @@mu_admin_user
|
66
|
+
@password = (@@mu_admin_pass.nil?) ? "admin" : @@mu_admin_pass
|
67
|
+
@cookie = ""
|
68
|
+
@response = nil
|
69
|
+
@api = Homepage.new(@host, @username, @password)
|
70
|
+
msg "Created Homepage object to :#{@host}", Logger::DEBUG
|
71
|
+
end
|
72
|
+
|
73
|
+
def parse_cli argv
|
74
|
+
@hash = {}
|
75
|
+
args = Array.new
|
76
|
+
while not argv.empty?
|
77
|
+
args << argv.shift if argv.first[0,1] != '-'
|
78
|
+
|
79
|
+
k = argv.shift
|
80
|
+
|
81
|
+
if [ '-h', '--help' ].member? k
|
82
|
+
help
|
83
|
+
exit
|
84
|
+
end
|
85
|
+
|
86
|
+
if [ '-m', '--mu_string' ].member? k
|
87
|
+
mu_string = shift(k, argv)
|
88
|
+
if mu_string =~ /(.+?):(.+?)@(.*)/
|
89
|
+
@@mu_admin_user = $1
|
90
|
+
@@mu_admin_pass = $2
|
91
|
+
@@mu_ip = $3
|
92
|
+
end
|
93
|
+
next
|
94
|
+
end
|
95
|
+
|
96
|
+
if [ '-o', '--output' ].member? k
|
97
|
+
$stdout.reopen(shift(k, argv), "w")
|
98
|
+
next
|
99
|
+
end
|
100
|
+
|
101
|
+
if [ '-v', '--verbose' ].member? k
|
102
|
+
$log.level = Logger::DEBUG
|
103
|
+
next
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
args
|
108
|
+
end
|
109
|
+
|
110
|
+
def help
|
111
|
+
helps = [
|
112
|
+
{ :short => '-h', :long => '--help', :value => '', :help => 'help on command line options' },
|
113
|
+
{ :short => '-m', :long => '--mu_string', :value => '<string>', :help => 'user, password, mu_ip in the form of admin:admin@10.9.8.7' },
|
114
|
+
{ :short => '-o', :long => '--output', :value => '<string>', :help => 'output logging to this file' },
|
115
|
+
{ :short => '-v', :long => '--verbose', :value => '', :help => 'set Logger::DEBUG level' }
|
116
|
+
]
|
117
|
+
|
118
|
+
cmds = [
|
119
|
+
"mu cmd_homepage:all",
|
120
|
+
"mu cmd_homepage:help",
|
121
|
+
"mu cmd_homepage:latest_test",
|
122
|
+
"mu cmd_homepage:queue_test",
|
123
|
+
"mu cmd_homepage:recent",
|
124
|
+
"mu cmd_homepage:status",
|
125
|
+
]
|
126
|
+
|
127
|
+
max_long_size = helps.inject(0) { |memo, obj| [ obj[:long].size, memo ].max }
|
128
|
+
max_value_size = helps.inject(0) { |memo, obj| [ obj[:value].size, memo ].max }
|
129
|
+
puts
|
130
|
+
puts "Usage: mu cmd_homepage:<command> <options>"
|
131
|
+
puts
|
132
|
+
helps.each do |h|
|
133
|
+
puts "%-*s %*s %-*s %s" % [max_long_size, h[:long], 2, h[:short], max_value_size, h[:value], h[:help]]
|
134
|
+
end
|
135
|
+
puts
|
136
|
+
puts "Available Commands"
|
137
|
+
puts
|
138
|
+
cmds.each do | c |
|
139
|
+
puts c
|
140
|
+
end
|
141
|
+
puts
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|
145
|
+
end # Command
|
146
|
+
end # Mu
|
@@ -0,0 +1,361 @@
|
|
1
|
+
# Use these commands to access the legacy REST API for Test Runs (Protocol Mutation, Scenario Mutation, DoS, and PV tests).
|
2
|
+
|
3
|
+
require 'mu/api/muapi'
|
4
|
+
class Mu
|
5
|
+
class Command
|
6
|
+
class Cmd_muapi < Command
|
7
|
+
|
8
|
+
attr_accessor :host, :username, :password, :api, :docroot
|
9
|
+
|
10
|
+
# displays command-line help
|
11
|
+
# * argv = command-line arguments
|
12
|
+
def cmd_help argv
|
13
|
+
help
|
14
|
+
end
|
15
|
+
|
16
|
+
# for any of the possible status values, returns a list of analysis
|
17
|
+
# * argv = command-line arguments, requires the status (-s) argument, specifying the values to query, such as 'running' or 'failed'
|
18
|
+
def cmd_list_by_status argv
|
19
|
+
setup argv
|
20
|
+
status = @hash['status']
|
21
|
+
response = @api.list_by_status(status)
|
22
|
+
if response.is_a?(Array)
|
23
|
+
response.each do | r |
|
24
|
+
msg r
|
25
|
+
end
|
26
|
+
else
|
27
|
+
msg response
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# returns the status of a particular analysis
|
32
|
+
# * argv = command-line argumentsm require a uuid (-u) argument, specifying a test on the Mu
|
33
|
+
def cmd_status argv
|
34
|
+
setup argv
|
35
|
+
uuid = @hash['uuid']
|
36
|
+
response = @api.status(uuid)
|
37
|
+
msg response
|
38
|
+
return response
|
39
|
+
end
|
40
|
+
|
41
|
+
# runs an analysis, reference is the posted uuid
|
42
|
+
# ex: run(1234-1234-1234-1234, "new_name")
|
43
|
+
# * 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
|
+
def cmd_run argv
|
45
|
+
setup argv
|
46
|
+
uuid = @hash['uuid']
|
47
|
+
if @hash['boolean'].nil?
|
48
|
+
rename = ""
|
49
|
+
else
|
50
|
+
rename = @hash['boolean']
|
51
|
+
end
|
52
|
+
response = @api.run(uuid, rename)
|
53
|
+
msg response
|
54
|
+
return response
|
55
|
+
end
|
56
|
+
|
57
|
+
# aborts a running analysis. the next queued analysis will start
|
58
|
+
# * argv = command-line arguments, requires a uuid (-u) argument specifying the test
|
59
|
+
def cmd_stop argv
|
60
|
+
setup argv
|
61
|
+
uuid = @hash['uuid']
|
62
|
+
response = @api.stop(uuid)
|
63
|
+
msg response
|
64
|
+
return response
|
65
|
+
end
|
66
|
+
|
67
|
+
# pauses a running analysis. Note that any queued analysis will NOT begin
|
68
|
+
# * argv = command-line arguments, requires a uuid (-u) argument specifying the test
|
69
|
+
def cmd_pause argv
|
70
|
+
setup argv
|
71
|
+
uuid = @hash['uuid']
|
72
|
+
response = @api.pause(uuid)
|
73
|
+
msg response
|
74
|
+
return response
|
75
|
+
end
|
76
|
+
|
77
|
+
# resumes a paused analysis
|
78
|
+
# * argv = command-line arguments, requires a uuid (-u) argument specifying the test
|
79
|
+
def cmd_resume argv
|
80
|
+
setup argv
|
81
|
+
uuid = @hash['uuid']
|
82
|
+
response = @api.resume(uuid)
|
83
|
+
msg response
|
84
|
+
return response
|
85
|
+
end
|
86
|
+
|
87
|
+
# delets an analysis or template of any type
|
88
|
+
# * argv = command-line arguments, requires a uuid (-u) argument specifying the test
|
89
|
+
def cmd_delete argv
|
90
|
+
setup argv
|
91
|
+
uuid = @hash['uuid']
|
92
|
+
response = @api.delete(uuid)
|
93
|
+
msg response
|
94
|
+
return response
|
95
|
+
end
|
96
|
+
|
97
|
+
# returns a list of faults (if any) for the analysis
|
98
|
+
# * argv = command-line arguments, requires a uuid (-u) argument specifying the test
|
99
|
+
def cmd_get_faults argv
|
100
|
+
setup argv
|
101
|
+
uuid = @hash['uuid']
|
102
|
+
response = @api.get_faults(uuid)
|
103
|
+
if response.is_a?(Array)
|
104
|
+
response.each do | r |
|
105
|
+
msg r
|
106
|
+
end
|
107
|
+
else
|
108
|
+
msg response
|
109
|
+
end
|
110
|
+
return response
|
111
|
+
end
|
112
|
+
|
113
|
+
# returns the name of a test referenced by uuid
|
114
|
+
# * argv = command-line arguments, requires a uuid (-u) argument specifying the test
|
115
|
+
def cmd_get_name argv
|
116
|
+
setup argv
|
117
|
+
uuid = @hash['uuid']
|
118
|
+
response = @api.get_name(uuid)
|
119
|
+
msg response
|
120
|
+
return response
|
121
|
+
end
|
122
|
+
|
123
|
+
# returns the types of templates on the Mu
|
124
|
+
# * argv = command-line arguments
|
125
|
+
def cmd_types argv
|
126
|
+
setup argv
|
127
|
+
response = @api.types
|
128
|
+
msg response
|
129
|
+
return response
|
130
|
+
end
|
131
|
+
|
132
|
+
# lists all templates of the given type
|
133
|
+
# * argv = command-line arguments, requires a type (-t) argument, such as 'scenario'
|
134
|
+
def cmd_list argv
|
135
|
+
setup argv
|
136
|
+
type = @hash['type']
|
137
|
+
response = @api.list(type)
|
138
|
+
if response.is_a?(Array)
|
139
|
+
response.each do | r |
|
140
|
+
msg r
|
141
|
+
end
|
142
|
+
else
|
143
|
+
msg response
|
144
|
+
end
|
145
|
+
return response
|
146
|
+
end
|
147
|
+
|
148
|
+
# exports a template by type and name
|
149
|
+
# * argv = command-line arguments, requires a template type (-t) and template name (-n) argument
|
150
|
+
def cmd_export_by_type_and_name argv
|
151
|
+
setup argv
|
152
|
+
type = @hash['type']
|
153
|
+
name = @hash['name']
|
154
|
+
response = @api.export_by_type_and_name(type, name)
|
155
|
+
msg response
|
156
|
+
return response
|
157
|
+
end
|
158
|
+
|
159
|
+
# exports a template by uuid
|
160
|
+
# * argv = command-line arguments, requires a template uuid (-u) argument
|
161
|
+
def cmd_export_by_uuid argv
|
162
|
+
setup argv
|
163
|
+
uuid = @hash['uuid']
|
164
|
+
response = @api.export_by_uuid(uuid)
|
165
|
+
msg response
|
166
|
+
return response
|
167
|
+
end
|
168
|
+
|
169
|
+
# archive has a set of three commands that are used to
|
170
|
+
# generate and download an archive of all data produced by
|
171
|
+
# a particular test
|
172
|
+
# ex:
|
173
|
+
# * argv = command-line arguments, requires a command (-c) argument
|
174
|
+
# * command=run returns the job_id
|
175
|
+
# * command=status (called after 'run'), requires the job_id (-u) argument
|
176
|
+
# * command=get (called when status returns "Finished"), requires the job_id (-u) argument
|
177
|
+
def cmd_archive argv
|
178
|
+
setup argv
|
179
|
+
command = @hash['command']
|
180
|
+
job_id = @hash['uuid']
|
181
|
+
response = @api.archive(command, job_id)
|
182
|
+
msg response
|
183
|
+
return response
|
184
|
+
end
|
185
|
+
|
186
|
+
# backup has a set of three commands that are used to generate,
|
187
|
+
# query and retrieve a backup
|
188
|
+
# ex:
|
189
|
+
# * argv = command-line arguments, requires a command (-c) argument
|
190
|
+
# * command=run returns the job_id
|
191
|
+
# * command=status (called after 'run')
|
192
|
+
# * command=get (called when status returns "Finished"), requires the name (-n) argument
|
193
|
+
# * name = backup file name (will be given a .dat extension)
|
194
|
+
def cmd_backup argv
|
195
|
+
setup argv
|
196
|
+
command = @hash['command']
|
197
|
+
name = @hash['name']
|
198
|
+
response = @api.backup(command, name)
|
199
|
+
msg response
|
200
|
+
return response
|
201
|
+
end
|
202
|
+
|
203
|
+
# capture has a set of three commands that are used to generate
|
204
|
+
# packet captures, poll the status and return the resulting file
|
205
|
+
# ex:
|
206
|
+
# * argv = command-line arguments, requires a command (-c) argument
|
207
|
+
# * command=run returns the job_id
|
208
|
+
# * command=status (called after 'run'), requires the job_id (-u) argument
|
209
|
+
# * command=get (called when status returns "Finished"), requires the job_id (-u) argument
|
210
|
+
# * port = the Mu interface on which to capture packets
|
211
|
+
def cmd_capture argv
|
212
|
+
setup argv
|
213
|
+
command = @hash['command']
|
214
|
+
port = @hash['port']
|
215
|
+
job_id = @hash['uuid']
|
216
|
+
response = @api.capture(command, port, job_id)
|
217
|
+
msg response
|
218
|
+
return response
|
219
|
+
end
|
220
|
+
|
221
|
+
private
|
222
|
+
|
223
|
+
def setup argv
|
224
|
+
parse_cli argv
|
225
|
+
@host = (@@mu_ip.nil?) ? "127.0.0.1" : @@mu_ip
|
226
|
+
@username = (@@mu_admin_user.nil?) ? "admin" : @@mu_admin_user
|
227
|
+
@password = (@@mu_admin_pass.nil?) ? "admin" : @@mu_admin_pass
|
228
|
+
@docroot = "/api/v3"
|
229
|
+
@params = nil
|
230
|
+
@expected_error = nil
|
231
|
+
@api = Muapi.new(@host, @username, @password)
|
232
|
+
msg "Created API object to :#{@host}", Logger::DEBUG
|
233
|
+
end
|
234
|
+
|
235
|
+
def parse_cli argv
|
236
|
+
args = Array.new
|
237
|
+
@hash = Hash.new
|
238
|
+
while not argv.empty?
|
239
|
+
args << argv.shift if argv.first[0,1] != '-'
|
240
|
+
|
241
|
+
k = argv.shift
|
242
|
+
|
243
|
+
if [ '-b', '--boolean' ].member? k
|
244
|
+
@hash['boolean'] = shift(k, argv)
|
245
|
+
next
|
246
|
+
end
|
247
|
+
|
248
|
+
if [ '-c', '--command' ].member? k
|
249
|
+
@hash['command'] = shift(k, argv)
|
250
|
+
next
|
251
|
+
end
|
252
|
+
|
253
|
+
if [ '-h', '--help' ].member? k
|
254
|
+
help
|
255
|
+
exit
|
256
|
+
end
|
257
|
+
|
258
|
+
if [ '-m', '--mu_string' ].member? k
|
259
|
+
mu_string = shift(k, argv)
|
260
|
+
if mu_string =~ /(.+?):(.+?)@(.*)/
|
261
|
+
@@mu_admin_user = $1
|
262
|
+
@@mu_admin_pass = $2
|
263
|
+
@@mu_ip = $3
|
264
|
+
end
|
265
|
+
next
|
266
|
+
end
|
267
|
+
|
268
|
+
if [ '-n', '--name' ].member? k
|
269
|
+
@hash['name'] = shift(k, argv)
|
270
|
+
next
|
271
|
+
end
|
272
|
+
|
273
|
+
if [ '-o', '--output' ].member? k
|
274
|
+
$stdout.reopen(shift(k, argv), "w")
|
275
|
+
next
|
276
|
+
end
|
277
|
+
|
278
|
+
if [ '-p', '--port' ].member? k
|
279
|
+
@hash['port'] = shift(k, argv)
|
280
|
+
next
|
281
|
+
end
|
282
|
+
|
283
|
+
if [ '-s', '--status' ].member? k
|
284
|
+
@hash['status'] = shift(k, argv)
|
285
|
+
next
|
286
|
+
end
|
287
|
+
|
288
|
+
if [ '-t', '--type' ].member? k
|
289
|
+
@hash['type'] = shift(k, argv)
|
290
|
+
next
|
291
|
+
end
|
292
|
+
|
293
|
+
if [ '-u', '--uuid' ].member? k
|
294
|
+
@hash['uuid'] = shift(k, argv)
|
295
|
+
next
|
296
|
+
end
|
297
|
+
|
298
|
+
if [ '-v', '--verbose' ].member? k
|
299
|
+
$log.level = Logger::DEBUG
|
300
|
+
next
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
args
|
305
|
+
end
|
306
|
+
|
307
|
+
def help
|
308
|
+
helps = [
|
309
|
+
{ :short => '-b', :long => '--boolean', :value => '<string>', :help => 'boolean arg' },
|
310
|
+
{ :short => '-c', :long => '--command', :value => '<string>', :help => 'e.g. run|get|status' },
|
311
|
+
{ :short => '-h', :long => '--help', :value => '', :help => 'help on command line options' },
|
312
|
+
{ :short => '-m', :long => '--mu_string', :value => '<string>', :help => 'user, password, mu_ip in the form of admin:admin@10.9.8.7' },
|
313
|
+
{ :short => '-n', :long => '--name', :value => '<string>', :help => 'name for filtering' },
|
314
|
+
{ :short => '-o', :long => '--output', :value => '<string>', :help => 'output logging to this file' },
|
315
|
+
{ :short => '-p', :long => '--port', :value => '<string>', :help => 'port name' },
|
316
|
+
{ :short => '-s', :long => '--status', :value => '<string>', :help => 'status, running|finished|aborted|queued|failed' },
|
317
|
+
{ :short => '-t', :long => '--type', :value => '<string>', :help => 'template type' },
|
318
|
+
{ :short => '-u', :long => '--uuid', :value => '<string>', :help => 'template uuid' },
|
319
|
+
{ :short => '-v', :long => '--verbose', :value => '', :help => 'set Logger::DEBUG level' }
|
320
|
+
]
|
321
|
+
|
322
|
+
cmds = [
|
323
|
+
"mu cmd_muapi:archive -c <command> -u <uuid>",
|
324
|
+
"mu cmd_muapi:backup -c <command> [-n <name>]",
|
325
|
+
"mu cmd_muapi:capture -c <command> -p <port> [-u <uuid>]",
|
326
|
+
"mu cmd_muapi:delete -u <uuid>",
|
327
|
+
"mu cmd_muapi:export_by_type_and_name -t <type> -n <name>",
|
328
|
+
"mu cmd_muapi:export_by_uuid -u <uuid>",
|
329
|
+
"mu cmd_muapi:get_faults -u <uuid>",
|
330
|
+
"mu cmd_muapi:get_name -u <uuid>",
|
331
|
+
"mu cmd_muapi:help",
|
332
|
+
"mu cmd_muapi:list -t <type>",
|
333
|
+
"mu cmd_muapi:list_by_status -s <status>",
|
334
|
+
"mu cmd_muapi:pause -u <uuid>",
|
335
|
+
"mu cmd_muapi:resume -u <uuid>",
|
336
|
+
"mu cmd_muapi:run -u <uuid> [-b rename]",
|
337
|
+
"mu cmd_muapi:status -u <uuid>",
|
338
|
+
"mu cmd_muapi:stop -u <uuid>",
|
339
|
+
"mu cmd_muapi:types",
|
340
|
+
]
|
341
|
+
|
342
|
+
max_long_size = helps.inject(0) { |memo, obj| [ obj[:long].size, memo ].max }
|
343
|
+
max_value_size = helps.inject(0) { |memo, obj| [ obj[:value].size, memo ].max }
|
344
|
+
puts
|
345
|
+
puts "Usage: mu cmd_muapi <options>"
|
346
|
+
puts
|
347
|
+
helps.each do |h|
|
348
|
+
puts "%-*s %*s %-*s %s" % [max_long_size, h[:long], 2, h[:short], max_value_size, h[:value], h[:help]]
|
349
|
+
end
|
350
|
+
puts
|
351
|
+
puts "Available Commands"
|
352
|
+
puts
|
353
|
+
cmds.each do | c |
|
354
|
+
puts c
|
355
|
+
end
|
356
|
+
puts
|
357
|
+
end
|
358
|
+
|
359
|
+
end
|
360
|
+
end # Command
|
361
|
+
end # Mu
|