Class: Mu::Command::Cmd_scale

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

Constant Summary

Constants inherited from Mu::Command

Api

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper

#ask, #error, #format_float, #get_file_as_string_array, #msg, #shift, #to_boolean

Instance Attribute Details

#apiObject

Returns the value of attribute api.



7
8
9
# File 'lib/mu/command/cmd_scale.rb', line 7

def api
  @api
end

#hostObject

Returns the value of attribute host.



7
8
9
# File 'lib/mu/command/cmd_scale.rb', line 7

def host
  @host
end

#passwordObject

Returns the value of attribute password.



7
8
9
# File 'lib/mu/command/cmd_scale.rb', line 7

def password
  @password
end

#usernameObject

Returns the value of attribute username.



7
8
9
# File 'lib/mu/command/cmd_scale.rb', line 7

def username
  @username
end

Instance Method Details

#cmd_about(argv) ⇒ Object

returns scale engine configuration information

* argv = command-line arguments


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

def cmd_about argv
  setup argv
  response = @api.about
  msg response
  return response
end

#cmd_configure(argv) ⇒ Object

configures the scale json object

* argv = command-line arguments, requires a params (-p) and params value (-pv) argument, such as -p volume -pv 100


16
17
18
19
20
21
22
23
# File 'lib/mu/command/cmd_scale.rb', line 16

def cmd_configure argv   
  setup argv
  param = @hash['params']
  value = @hash['param_value']
  response = @api.configure(param, value)
  msg response
  return response
end

#cmd_data(argv) ⇒ Object

returns scale test data for charting

* argv = command-line arguments, requires:
* view (-w), which specifies the TIMELINE or CALLGRAPH chart.
* zoom (-z), which  specifies the zoom level (0 to 1). 1 returns data for 100% of the time range, 0.5 returns data for 50% of the time range, and 0 returns only the last minute of data
* position (-p), which must be 0.
* scale engine id (-b)


106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/mu/command/cmd_scale.rb', line 106

def cmd_data argv
  setup argv
  begin
    view = @hash['view']
    zoom = @hash['zoom']
    position = @hash['view_position']
    bot_id = @hash['bot_id']
    response = @api.data(view, zoom, position, bot_id)
  rescue => e
    msg e
  end
  msg response
  return response
end

#cmd_delete_scale_engine(argv) ⇒ Object

deletes a scale engine

* argv = command-line arguments, require a scale engine id (-b) argument


178
179
180
181
182
183
184
# File 'lib/mu/command/cmd_scale.rb', line 178

def cmd_delete_scale_engine argv
  setup argv
  bot_id = @hash['bot_id']
  response = @api.delete_scale_engine(bot_id)
  msg response
  return response
end

#cmd_help(argv) ⇒ Object

outputs help for this command



10
11
12
# File 'lib/mu/command/cmd_scale.rb', line 10

def cmd_help argv
  help
end

#cmd_list(argv) ⇒ Object

returns an array of currently reserved scale engines

* argv = command-line arguments


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

def cmd_list argv
  setup argv
  response = @api.list
  msg response
  return response
end

#cmd_pattern(argv) ⇒ Object

returns scale test data for charting

* argv = command-line arguments, requires:
* zoom (z) level
* position(-p 0)


125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/mu/command/cmd_scale.rb', line 125

def cmd_pattern argv
  setup argv
  begin
    zoom = @hash['zoom']
    position = @hash['view_position']
    response = @api.pattern(zoom, position)
  rescue => e
    msg e
  end
  msg response
  return response
end

#cmd_pcap(argv) ⇒ Object

returns a packet capture file from scale verify

* argv = command-line arguments, requires a scale engine id (-b) and the pcap filename (-f) argument


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

def cmd_pcap argv
  setup argv
  bot_id = @hash['bot_id']
  file = @hash['filename']
  response = @api.pcap(bot_id, file)
  msg response
  return response
end

#cmd_release(argv) ⇒ Object

releases the currently reserved scale engine

* argv = command-line arguments


149
150
151
152
153
154
# File 'lib/mu/command/cmd_scale.rb', line 149

def cmd_release argv
  setup argv
  response = @api.release
  msg response
  return response
end

#cmd_release_scale_engine(argv) ⇒ Object

releases a scale engine

* argv = command-line arguments, require a scale engine id (-b) argument


168
169
170
171
172
173
174
# File 'lib/mu/command/cmd_scale.rb', line 168

def cmd_release_scale_engine argv
 setup argv
  bot_id = @hash['bot_id']
  response = @api.release_scale_engine(bot_id)
  msg response
  return response
end

#cmd_reserve_scale_engine(argv) ⇒ Object

reserves a scale engine

* argv = command-line arguments, require a scale engine id (-b) argument


158
159
160
161
162
163
164
# File 'lib/mu/command/cmd_scale.rb', line 158

def cmd_reserve_scale_engine argv
  setup argv
  bot_id = @hash['bot_id']
  response = @api.reserve_scale_engine(bot_id)
  msg response
  return response
end

#cmd_start(argv) ⇒ Object

starts a scale test

* argv = command-line arguments, requires a scale json object to have been configured


27
28
29
30
31
32
# File 'lib/mu/command/cmd_scale.rb', line 27

def cmd_start argv
  setup argv
  response = @api.start
  msg response
  return response
end

#cmd_status(argv) ⇒ Object

returns status from a scale test

* argv = command-line arguments


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

def cmd_status argv
  setup argv
  response = @api.status
  msg response
  return response
end

#cmd_statuses(argv) ⇒ Object

returns the status of all reserved scale engines

* argv = command-line arguments


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

def cmd_statuses argv
  setup argv
  response = @api.statuses
  msg response
  return response
end

#cmd_stop(argv) ⇒ Object

stops a scale test

* argv = command-line arguments


140
141
142
143
144
145
# File 'lib/mu/command/cmd_scale.rb', line 140

def cmd_stop argv
  setup argv
  response = @api.stop
  msg response
  return response
end

#cmd_update(argv) ⇒ Object

updates a running scale test (valid only if the test is running with no pattern)

* argv = command-line arguments, requires a json params object (-p) such as '{ "volume": 100 }'


45
46
47
48
49
50
51
# File 'lib/mu/command/cmd_scale.rb', line 45

def cmd_update argv
  setup argv
  params = @hash['params']
  response = @api.update(params)
  msg response
  return response
end

#cmd_verify(argv) ⇒ Object

verifies a scale test

* argv = command-line arguments, requires a scale json object to have been configured


36
37
38
39
40
41
# File 'lib/mu/command/cmd_scale.rb', line 36

def cmd_verify argv
  setup argv
  response = @api.verify
  msg response
  return response
end