mu 5.7.12 → 5.7.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,28 +17,30 @@ require 'optparse'
17
17
  require 'ostruct'
18
18
 
19
19
  class Mu
20
- class Command
21
- #include Test::Unit::Assertions
22
- include Helper
20
+ class Command
21
+ #include Test::Unit::Assertions
22
+ include Helper
23
23
 
24
- attr_accessor :options, :opts
24
+ attr_accessor :options, :opts
25
25
 
26
- def initialize
27
- # Set defaults
28
- @options = OpenStruct.new
29
- @options.verbose = false
26
+ def initialize
27
+ # Set defaults
28
+ @options = OpenStruct.new
29
+ @options.verbose = false
30
+ @options.mu_string = false
30
31
 
31
- # TO DO - add additional defaults
32
- @opts = OptionParser.new
33
- @opts.on('-V', '--verbose') { @options.verbose = true }
32
+ # TO DO - add additional defaults
33
+ @opts = OptionParser.new
34
+ @opts.on('-V', '--verbose') { @options.verbose = true }
34
35
 
35
- end
36
-
37
- @@mu_ip = ENV['MU_IP']
38
- @@mu_admin_user = ENV['MU_ADMIN_USER']
39
- @@mu_admin_pass = ENV['MU_ADMIN_PASS']
36
+ end
37
+
38
+ @@mu_ip = ENV['MU_IP']
39
+ @@mu_admin_user = ENV['MU_ADMIN_USER']
40
+ @@mu_admin_pass = ENV['MU_ADMIN_PASS']
41
+
40
42
 
41
- end # Command
43
+ end # Command
42
44
  end # Mu
43
45
 
44
46
  Dir["#{File.dirname(__FILE__)}/command/*.rb"].each { |c| require c }
@@ -134,7 +134,18 @@ class Mu
134
134
  #@opts.on( '--endpoint', 'One way communication' ) do
135
135
  # @options.endpoint = true
136
136
  #end
137
- @opts.on( '-s', '--scenario [FILENAME]', 'Specify the msl filename to be created' ) do |scenario|
137
+ #@opts.on('-m', '--mu_string <string>','user, password, mu_ip in the form of admin:admin@10.9.8.7') do |mu_string|
138
+ # @options.mu_string = true
139
+ # @options.mu_string_valid = false
140
+ # if mu_string =~ /(.+?):(.+?)@(.*)/
141
+ # @@mu_admin_user = $1
142
+ # @@mu_admin_pass = $2
143
+ # @@mu_ip = $3
144
+ # @options.mu_string_valid = true
145
+ # end
146
+ # next
147
+ #end
148
+ @opts.on( '-s', '--scenario <FILENAME>', 'Specify the msl filename to be created' ) do |scenario|
138
149
  @options.scenario = scenario
139
150
  end
140
151
  # Remove all options just leaving the harfiles
@@ -299,6 +299,7 @@ class Mu
299
299
  File.open(filename, 'a'){|f| f.puts("#{msl_file},#{@verify_response}")}
300
300
  end
301
301
 
302
+ # TO DO - We need to fix the logic of our response verification, it isn't elegant right now
302
303
  def parse_verify_response(response)
303
304
  if response.nil? # || response.empty?
304
305
  msg "*** error = no response received from /verify ***", Logger::ERROR
@@ -307,6 +308,14 @@ class Mu
307
308
  end
308
309
  begin
309
310
  msg JSON.pretty_generate(response), Logger::DEBUG
311
+
312
+ if response.has_key?("error")
313
+ @error = "Player Error"
314
+ @reason = response["error"]
315
+ msg "*** Error = #{@error}, reason = #{@reason} ***", Logger::ERROR
316
+ @verify_response = "Error = #{@error}, reason = #{@reason}"
317
+ return @verify_response
318
+ end
310
319
  if !response["status"].nil?
311
320
  if response["status"]["error"] == true
312
321
  @error = response["status"]["error"]
@@ -320,6 +329,7 @@ class Mu
320
329
  @verify_response = "okay"
321
330
  return @verify_response
322
331
  rescue => e
332
+ puts "Broken Response: \n#{response}\n"
323
333
  msg e, Logger::ERROR
324
334
  raise
325
335
  return nil
@@ -6,7 +6,6 @@ class Help < Command
6
6
  puts "Usage: mu <command>:<option>"
7
7
  helps = [
8
8
  { :cmd => 'mu help', :help => "Display this help" },
9
- { :cmd => 'mu cmd_cli:help', :help => 'Show help on using the Mu CLI Api through the command-line' },
10
9
  { :cmd => 'mu cmd_ddt:help', :help => 'Show help on using the Studio Verify Api through the command-line' },
11
10
  { :cmd => 'mu cmd_homepage:help', :help => 'Show help on using the Homepage Api through the command-line' },
12
11
  { :cmd => 'mu cmd_muapi:help', :help => 'Show help on using the Mu Api for fuzzing, templates, backup and archive' },
@@ -452,8 +452,13 @@ class Har
452
452
  else ; ('\x%02x' % i).freeze
453
453
  end
454
454
  end
455
- ESCAPES['"'.ord] = %q{\"}
456
- ESCAPES["'".ord] = %q{\'}
455
+
456
+ # Only works for 1.9
457
+ #ESCAPES["'".ord] = %q{\'}
458
+ #ESCAPES['"'.ord] = %q{\"}
459
+ # Works for 1.8 and 1.9
460
+ ESCAPES['"'.unpack('c*')[0]] = %q{\"}
461
+ ESCAPES["'".unpack('c*')[0]] = %q{\'}
457
462
  ESCAPES.freeze
458
463
 
459
464
  # Takes input and a table that maps ascii codes to their representation
@@ -3,10 +3,16 @@ class HttpHelper
3
3
  include Helper
4
4
 
5
5
  def initialize(host, username, password, docroot)
6
- @host = host
6
+ # This check is to see if the user has set ENV variables or used the -m command line option
7
+ if(host.nil? || username.nil? || password.nil? || docroot.nil?)
8
+ raise "The host, username and/or password aren't defined. Please use the -m command line option '-m user:password@1.2.3.4' or set your MU environment variables MU_IP,MU_ADMIN_USER,MU_ADMIN_PASS"
9
+ end
10
+
11
+ @host = host
7
12
  @username = username
8
13
  @password = password
9
- @docroot = docroot
14
+ @docroot = docroot
15
+
10
16
  $cookie = "" if $cookie.nil?
11
17
  end
12
18
 
data/version.rb CHANGED
@@ -1 +1 @@
1
- VERSION='5.7.12'
1
+ VERSION='5.7.13'
metadata CHANGED
@@ -1,116 +1,110 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: mu
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 5.7.13
4
5
  prerelease:
5
- version: 5.7.12
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - MuEng
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-04-12 00:00:00 -07:00
12
+ date: 2011-04-13 00:00:00.000000000 -07:00
14
13
  default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
17
16
  name: nokogiri
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &20647040 !ruby/object:Gem::Requirement
20
18
  none: false
21
- requirements:
22
- - - ">="
23
- - !ruby/object:Gem::Version
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
24
22
  version: 1.4.4
25
23
  type: :runtime
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: rest-client
29
24
  prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: *20647040
26
+ - !ruby/object:Gem::Dependency
27
+ name: rest-client
28
+ requirement: &20646460 !ruby/object:Gem::Requirement
31
29
  none: false
32
- requirements:
33
- - - ">="
34
- - !ruby/object:Gem::Version
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
35
33
  version: 1.6.1
36
34
  type: :runtime
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: mime-types
40
35
  prerelease: false
41
- requirement: &id003 !ruby/object:Gem::Requirement
36
+ version_requirements: *20646460
37
+ - !ruby/object:Gem::Dependency
38
+ name: mime-types
39
+ requirement: &20645880 !ruby/object:Gem::Requirement
42
40
  none: false
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: "1.16"
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '1.16'
47
45
  type: :runtime
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
50
- name: json_pure
51
46
  prerelease: false
52
- requirement: &id004 !ruby/object:Gem::Requirement
47
+ version_requirements: *20645880
48
+ - !ruby/object:Gem::Dependency
49
+ name: json_pure
50
+ requirement: &20645300 !ruby/object:Gem::Requirement
53
51
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
57
55
  version: 1.4.6
58
56
  type: :runtime
59
- version_requirements: *id004
60
- - !ruby/object:Gem::Dependency
61
- name: hexy
62
57
  prerelease: false
63
- requirement: &id005 !ruby/object:Gem::Requirement
58
+ version_requirements: *20645300
59
+ - !ruby/object:Gem::Dependency
60
+ name: hexy
61
+ requirement: &20644720 !ruby/object:Gem::Requirement
64
62
  none: false
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
68
66
  version: 0.1.1
69
67
  type: :runtime
70
- version_requirements: *id005
71
- description: |-
72
- The Mu gem allows users to include mu libraries within scripts
73
- that interact with mu appliance software. The gem also supplies command line interfaces
74
- to many of these same libraries
75
- email:
68
+ prerelease: false
69
+ version_requirements: *20644720
70
+ description: ! "The Mu gem allows users to include mu libraries within scripts\n that
71
+ interact with mu appliance software. The gem also supplies command line interfaces\n
72
+ \ to many of these same libraries"
73
+ email:
76
74
  - info@mudynamics.com
77
- executables:
75
+ executables:
78
76
  - mu
79
77
  extensions: []
80
-
81
78
  extra_rdoc_files: []
82
-
83
- files:
84
- - lib/mu/api/ddt.rb
85
- - lib/mu/api/homepage.rb
86
- - lib/mu/api/muapi.rb
79
+ files:
80
+ - lib/mu.rb
81
+ - lib/mu/har.rb
82
+ - lib/mu/http_helper.rb
83
+ - lib/mu/client.rb
87
84
  - lib/mu/api/netconfig.rb
88
- - lib/mu/api/scale.rb
85
+ - lib/mu/api/muapi.rb
86
+ - lib/mu/api/homepage.rb
89
87
  - lib/mu/api/system.rb
90
- - lib/mu/cli/muclish.tcl
91
- - lib/mu/client.rb
88
+ - lib/mu/api/scale.rb
89
+ - lib/mu/api/ddt.rb
90
+ - lib/mu/helper.rb
91
+ - lib/mu/maker.rb
92
+ - lib/mu/command/cmd_homepage.rb
92
93
  - lib/mu/command/api.rb
93
- - lib/mu/command/cmd_cli.rb
94
94
  - lib/mu/command/cmd_ddt.rb
95
- - lib/mu/command/cmd_homepage.rb
95
+ - lib/mu/command/cmd_scale.rb
96
+ - lib/mu/command/curl.rb
96
97
  - lib/mu/command/cmd_muapi.rb
98
+ - lib/mu/command/help.rb
97
99
  - lib/mu/command/cmd_musl.rb
98
- - lib/mu/command/cmd_netconfig.rb
100
+ - lib/mu/command/cmd_system.rb
99
101
  - lib/mu/command/cmd_runscale.rb
100
102
  - lib/mu/command/cmd_runscenario.rb
103
+ - lib/mu/command/cmd_netconfig.rb
101
104
  - lib/mu/command/cmd_runverify.rb
102
- - lib/mu/command/cmd_scale.rb
103
- - lib/mu/command/cmd_system.rb
104
- - lib/mu/command/curl.rb
105
- - lib/mu/command/help.rb
106
105
  - lib/mu/command.rb
107
106
  - lib/mu/curl/error.rb
108
107
  - lib/mu/curl/verify.rb
109
- - lib/mu/har.rb
110
- - lib/mu/helper.rb
111
- - lib/mu/http_helper.rb
112
- - lib/mu/maker.rb
113
- - lib/mu.rb
114
108
  - bin/mu
115
109
  - Mu_Gem.html
116
110
  - version.rb
@@ -119,30 +113,26 @@ files:
119
113
  has_rdoc: true
120
114
  homepage: http://www.mudynamics.com
121
115
  licenses: []
122
-
123
116
  post_install_message:
124
117
  rdoc_options: []
125
-
126
- require_paths:
118
+ require_paths:
127
119
  - lib
128
- required_ruby_version: !ruby/object:Gem::Requirement
120
+ required_ruby_version: !ruby/object:Gem::Requirement
129
121
  none: false
130
- requirements:
131
- - - ">="
132
- - !ruby/object:Gem::Version
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
133
125
  version: 1.8.7
134
- required_rubygems_version: !ruby/object:Gem::Requirement
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
127
  none: false
136
- requirements:
137
- - - ">="
138
- - !ruby/object:Gem::Version
139
- version: "0"
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
140
132
  requirements: []
141
-
142
133
  rubyforge_project:
143
134
  rubygems_version: 1.6.2
144
135
  signing_key:
145
136
  specification_version: 3
146
137
  summary: Mu Dynamics General Purpose Library and Command Line Tool
147
138
  test_files: []
148
-
@@ -1,20 +0,0 @@
1
- #!/usr/bin/expect --
2
- set prompt "MU>" ;# default prompt
3
- set host [lindex $argv 0]
4
- set password [lindex $argv 1]
5
- set prompt [lindex $argv 2]
6
-
7
- # aux port? use mrtwig
8
- if {$host == "192.168.2.1"} {
9
- eval spawn ssh root@10.10.3.60
10
- expect "password:"
11
- send "happy1\r"
12
- expect "#"
13
- send "ssh admin@192.168.2.1\r"
14
- } else {
15
- eval spawn ssh admin@$host
16
- }
17
- expect "password:"
18
- send "$password\r"
19
- expect $prompt
20
- interact
@@ -1,151 +0,0 @@
1
- # Api methods to access the Mu CLI calls
2
- class Mu
3
- class Command
4
- class Cmd_cli < Command
5
-
6
- attr_accessor :host, :username, :password, :api
7
-
8
- # displays command-line help
9
- def cmd_help argv
10
- help
11
- end
12
-
13
- # runs the cli help command
14
- # * argv = command-line arguments
15
- def cmd_cli_help argv
16
- setup argv
17
- msg run_cmd("help")
18
- end
19
-
20
- # runs the cli command '?"
21
- # * argv = command-line arguments
22
- def cmd_question argv
23
- setup argv
24
- msg run_cmd("?")
25
- end
26
-
27
- # displays the command line history for the current session
28
- # * argv = command-line arguments
29
- def cmd_history argv
30
- setup argv
31
- msg run_cmd("history")
32
- end
33
-
34
- # pings an ip address
35
- # * argv = command-line arguments, requires an ip address (-a) argument
36
- def cmd_ping argv
37
- setup argv
38
- addr = @hash["address"]
39
- msg run_cmd("ping #{addr}")
40
- end
41
-
42
- # runs traceroute on an ip address
43
- # * argv = command-line arguments, requires an ip address (-a) argument
44
- def cmd_traceroute argv
45
- setup argv
46
- addr = @hash["address"]
47
- msg run_cmd("traceroute #{addr}")
48
- end
49
-
50
- private
51
-
52
- # runs the cli command
53
- def run_cmd(command, prompt=@prompt)
54
- msg "run command #{command}"
55
- @pipe.write("#{command}\r")
56
- response = @pipe.readline(prompt)
57
- @pipe.close
58
- return response
59
- end
60
-
61
- def setup argv
62
- parse_cli argv
63
- @host = (@@mu_ip.nil?) ? "127.0.0.1" : @@mu_ip
64
- @username = (@@mu_admin_user.nil?) ? "admin" : @@mu_admin_user
65
- @password = (@@mu_admin_pass.nil?) ? "admin" : @@mu_admin_pass
66
- @prompt = "MU>"
67
- @pipe = IO.popen("./lib/mu/cli/muclish.tcl #{@host} #{@password} '#{@prompt}'", 'w+')
68
- @pipe.sync = true
69
- @banner = @pipe.readline(@prompt)
70
- end
71
-
72
- def parse_cli argv
73
- @hash = {}
74
- args = Array.new
75
- while not argv.empty?
76
- args << argv.shift if argv.first[0,1] != '-'
77
-
78
- k = argv.shift
79
-
80
- if [ '-a', '--address' ].member? k
81
- @hash['address'] = shift(k, argv)
82
- next
83
- end
84
-
85
- if [ '-h', '--help' ].member? k
86
- help
87
- exit
88
- end
89
-
90
- if [ '-m', '--mu_string' ].member? k
91
- mu_string = shift(k, argv)
92
- if mu_string =~ /(.+?):(.+?)@(.*)/
93
- @@mu_admin_user = $1
94
- @@mu_admin_pass = $2
95
- @@mu_ip = $3
96
- end
97
- next
98
- end
99
-
100
- if [ '-o', '--output' ].member? k
101
- $stdout.reopen(shift(k, argv), "w")
102
- next
103
- end
104
-
105
- if [ '-v', '--verbose' ].member? k
106
- $log.level = Logger::DEBUG
107
- next
108
- end
109
-
110
- end
111
-
112
- args
113
- end
114
-
115
- def help
116
- helps = [
117
- { :short => '-a', :long => '--address', :value => '<string', :help => 'ip address to for ping or traceroute' },
118
- { :short => '-h', :long => '--help', :value => '', :help => 'Help on command line options' },
119
- { :short => '-o', :long => '--output', :value => '<string>', :help => 'output logging to this file' },
120
- { :short => '-m', :long => '--mu_string', :value => '<string>', :help => 'user, password, mu_ip in the form of admin:admin@10.9.8.7' },
121
- { :short => '-v', :long => '--verbose', :value => '', :help => 'set Logger::DEBUG level' }
122
- ]
123
-
124
- cmds = [
125
- "mu cmd_cli:cli_help",
126
- "mu cmd_cli:history",
127
- "mu cmd_cli:ping -a <address>",
128
- "mu cmd_cli:question",
129
- "mu cmd_cli:traceroute -a <address>",
130
- ]
131
-
132
- max_long_size = helps.inject(0) { |memo, obj| [ obj[:long].size, memo ].max }
133
- max_value_size = helps.inject(0) { |memo, obj| [ obj[:value].size, memo ].max }
134
- puts
135
- puts "Usage: mu cmd_cli:<command> <options>"
136
- puts
137
- helps.each do |h|
138
- puts "%-*s %*s %-*s %s" % [max_long_size, h[:long], 2, h[:short], max_value_size, h[:value], h[:help]]
139
- end
140
- puts
141
- puts "Available Commands"
142
- puts
143
- cmds.each do | c |
144
- puts c
145
- end
146
- puts
147
- end
148
-
149
- end
150
- end # Command
151
- end # Mu