Class: Mu::Command::Cmd_ddt

Inherits:
Mu::Command show all
Defined in:
lib/mu/command/cmd_ddt.rb

Constant Summary

Constants inherited from Mu::Command

Api

Constants included from Helper

Helper::ESCAPES

Instance Attribute Summary collapse

Attributes inherited from Mu::Command

#options, #opts

Instance Method Summary collapse

Methods inherited from Mu::Command

#initialize

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

#apiObject

Returns the value of attribute api.



9
10
11
# File 'lib/mu/command/cmd_ddt.rb', line 9

def api
  @api
end

#hashObject

Returns the value of attribute hash.



9
10
11
# File 'lib/mu/command/cmd_ddt.rb', line 9

def hash
  @hash
end

#hostObject

Returns the value of attribute host.



9
10
11
# File 'lib/mu/command/cmd_ddt.rb', line 9

def host
  @host
end

#passwordObject

Returns the value of attribute password.



9
10
11
# File 'lib/mu/command/cmd_ddt.rb', line 9

def password
  @password
end

#usernameObject

Returns the value of attribute username.



9
10
11
# File 'lib/mu/command/cmd_ddt.rb', line 9

def username
  @username
end

Instance Method Details

#cmd_close_all_sessions(argv) ⇒ Object

closes all existing Studio Verify sessions# * command-line args

* argv = command-line arguments


65
66
67
68
69
70
# File 'lib/mu/command/cmd_ddt.rb', line 65

def cmd_close_all_sessions argv
  setup argv
  response = @api.close_all_sessions
  msg response
  return response
end

#cmd_close_session(argv) ⇒ Object

closes the currently active Studio Verify session

* argv = command-line arguments


47
48
49
50
51
52
# File 'lib/mu/command/cmd_ddt.rb', line 47

def cmd_close_session argv
  setup argv
  response = @api.close_session
  msg response
  return response
end

#cmd_csv_export(argv) ⇒ Object

exports a testset from Mu Studio to a csv file

* argv = command-line arguments, requires a uuid (-u) argument that is the uuid of a testset on the Mu


257
258
259
260
261
262
263
264
265
# File 'lib/mu/command/cmd_ddt.rb', line 257

def cmd_csv_export argv
  setup argv
  msg @api.new_session
  uuid = @hash['uuid']
  response = @api.csv_export(uuid)
  @api.close_session
  msg response
  return response
end

#cmd_csv_import(argv) ⇒ Object

imports a csv-formatted testset to a Mu system

* argv = command-line arguments, requires the csv testset file (-t)


269
270
271
272
273
274
275
276
277
# File 'lib/mu/command/cmd_ddt.rb', line 269

def cmd_csv_import argv
  setup argv
  msg @api.new_session
  testset_file = @hash['testset']
  response = @api.csv_import(testset_file)
  @api.close_session
  msg response
  return response
end

#cmd_display_results(argv) ⇒ Object

displays testset results

* argv = command-line arguments


248
249
250
251
252
253
# File 'lib/mu/command/cmd_ddt.rb', line 248

def cmd_display_results argv
 setup argv
 response = @api.results
 msg response
  return response
end

#cmd_get_all_sessions(argv) ⇒ Object

returns all Studio Verify sessions

* argv = command-line arguments


74
75
76
77
78
79
# File 'lib/mu/command/cmd_ddt.rb', line 74

def cmd_get_all_sessions argv
  setup argv
  response = @api.get_all_sessions
  msg response
  return response
end

#cmd_get_channels(argv) ⇒ Object

returns the channel elements of a Mu Studio scenario

* argv = command-line arguments


156
157
158
159
160
161
# File 'lib/mu/command/cmd_ddt.rb', line 156

def cmd_get_channels argv
  setup argv
  response = @api.get_channels
  msg response
  return response
end

#cmd_get_hosts(argv) ⇒ Object

returns array of host hashmaps, e.g.

(A1.V4)”, “roleId”=>“host_0”, “layer”=>“v4”, (dell-eth1.V4)”, “roleId”=>“host_1”, “layer”=>“v4”

NOTE: the values of ‘roleId’ are what are passed to set_hosts as ‘roles’, not ‘role’

* argv = command-line arguments


113
114
115
116
117
118
# File 'lib/mu/command/cmd_ddt.rb', line 113

def cmd_get_hosts argv
  setup argv
  response = @api.get_hosts
  msg response
  return response
end

#cmd_get_options(argv) ⇒ Object

returns array of options hashmap, consisting of name and value keys, e.g.

“value”=>250, “value”=>0
  • argv = command-line arguments



193
194
195
196
197
198
# File 'lib/mu/command/cmd_ddt.rb', line 193

def cmd_get_options argv
  setup argv
  response = @api.get_options
  msg response
  return response
end

#cmd_get_sessions(argv) ⇒ Object

returns an array of current Studio Verify session id’s

* argv = command-line arguments


56
57
58
59
60
61
# File 'lib/mu/command/cmd_ddt.rb', line 56

def cmd_get_sessions argv
  setup argv
  response = @api.get_sessions
  msg response
  return response
end

#cmd_get_testset_results(argv) ⇒ Object

returns results from the current testset. can be called repeatedly during a test run. the end of a test is indicated by the presence of the word ‘END’ in the returned results array

* argv = command-line arguments


239
240
241
242
243
244
# File 'lib/mu/command/cmd_ddt.rb', line 239

def cmd_get_testset_results argv
  setup argv
  response = @api.get_testset_results
  msg response
  return response
end

#cmd_get_testset_status(argv) ⇒ Object

returns the status of the current testset

* argv = command-line arguments


229
230
231
232
233
234
# File 'lib/mu/command/cmd_ddt.rb', line 229

def cmd_get_testset_status argv
  setup argv
  response = @api.get_testset_status
  msg response
  return response
end

#cmd_help(argv) ⇒ Object

displays command-line help

* argv = command-line arguments


13
14
15
# File 'lib/mu/command/cmd_ddt.rb', line 13

def cmd_help argv
  help
end

#cmd_load_scenario(argv) ⇒ Object

loads a Mu Studio scenario

* argv = command-line arguments, requires the uuid (-u) argument, the uuid of a scenario that is already loaded on the Mu


101
102
103
104
105
106
107
# File 'lib/mu/command/cmd_ddt.rb', line 101

def cmd_load_scenario argv
  setup argv
  uuid = @hash['uuid']
  response = @api.load_scenario(uuid)
  msg response
  return response
end

#cmd_new_session(argv) ⇒ Object

creates a new Studio Verify session

* argv = command-line arguments


38
39
40
41
42
43
# File 'lib/mu/command/cmd_ddt.rb', line 38

def cmd_new_session argv
  setup argv
  response = @api.new_session
  msg response
  return response
end

#cmd_run(argv) ⇒ Object

verifies the loaded scenario

  • argv = command-line arguments



19
20
21
22
23
24
# File 'lib/mu/command/cmd_ddt.rb', line 19

def cmd_run argv  
  setup argv
  response = @api.run
  msg response
  return response
end

#cmd_run_testset(argv) ⇒ Object

runs the loaded scenario and testset

* argv = command-line arguments, requires a uuid (-u) argument


28
29
30
31
32
33
34
# File 'lib/mu/command/cmd_ddt.rb', line 28

def cmd_run_testset argv
  setup argv
  uuid = @hash['uuid']
  response = @api.run_testset(uuid)
  msg response
  return response
end

#cmd_set_channels(argv) ⇒ Object

sets the channel elements of a loaded scenario

* argv = command-line arguments, requires arrays of roles and names. The roles must all be 'channel' and the names are names of valid hosts
* roles and names can be single-values or comma-separated lists.


166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/mu/command/cmd_ddt.rb', line 166

def cmd_set_channels argv
  setup argv
  roles = @hash['roles']
  names = @hash['names']

  if names.include?(",")
    names_array = names.split(",")
  else
    names_array = Array.new
    names_array << names
  end

  if roles.include?(",")
    roles_array = roles.split(",")
  else
    roles_array = Array.new
    roles_array << roles
  end

  response = @api.set_channels(roles_array, names_array)
  msg response
  return response
end

#cmd_set_hosts(argv) ⇒ Object

sets a Mu Studio scenario’s host. takes an arrays of roles and names, e.g. [“h1”, “h2”], [“a1”, dell-9“] optional types array [”v4“, ”v4“]

* argv = command-line arguments, requires an array of roles and names (and optionally, type). The roles must match those defined within the scenario
* roles and names can be single-values or comma-separated lists.
* type is a single value (v4, v6 or l2)


125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/mu/command/cmd_ddt.rb', line 125

def cmd_set_hosts argv
  setup argv
  roles = @hash['roles']
  names = @hash['names']
  if @hash['type'].nil?
    type = "v4"
  else
    type = @hash['type']
  end

  if names.include?(",")
    names_array = names.split(",")
  else
    names_array = Array.new
    names_array << names
  end

  if roles.include?(",")
    roles_array = roles.split(",")
  else
    roles_array = Array.new
    roles_array << roles
  end

  response = @api.set_hosts(roles_array, names_array, type)
  msg response
  return response
end

#cmd_set_options(argv) ⇒ Object

sets the options of the loaded scenario

* argv = command-line arguments, requires arrays of valid options names and values
* names and values can be single-values or comma-separated lists.


203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# File 'lib/mu/command/cmd_ddt.rb', line 203

def cmd_set_options argv
  setup argv
  names = @hash['names']
  values = @hash['option_values']

  if names.include?(",")
    names_array = names.split(",")
  else
    names_array = Array.new
    names_array << names
  end

  if values.include?(",")
    values_array = values.split(",")
  else
    values_array = Array.new
    values_array << values
  end

  response = @api.set_options(names_array, values_array)
  msg response
  return response
end

#cmd_setup_test(argv) ⇒ Object

sets up a test session

* argv = command-line arguments


83
84
85
86
87
88
# File 'lib/mu/command/cmd_ddt.rb', line 83

def cmd_setup_test argv
  setup argv
  response = @api.setup_test
  msg response
  return response
end

#cmd_teardown_test(argv) ⇒ Object

tears down a test session

* argv = command-line arguments


92
93
94
95
96
97
# File 'lib/mu/command/cmd_ddt.rb', line 92

def cmd_teardown_test argv
  setup argv
  response = @api.teardown_test
  msg response
  return response
end