mu 5.7.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. data/Mu_Gem.html +1591 -0
  2. data/bin/mu +11 -0
  3. data/lib/mu.rb +65 -0
  4. data/lib/mu/api/ddt.rb +233 -0
  5. data/lib/mu/api/homepage.rb +54 -0
  6. data/lib/mu/api/muapi.rb +231 -0
  7. data/lib/mu/api/netconfig.rb +233 -0
  8. data/lib/mu/api/scale.rb +199 -0
  9. data/lib/mu/api/system.rb +40 -0
  10. data/lib/mu/client.rb +31 -0
  11. data/lib/mu/command.rb +28 -0
  12. data/lib/mu/command/api.rb +95 -0
  13. data/lib/mu/command/cmd_appid.rb +486 -0
  14. data/lib/mu/command/cmd_cli.rb +151 -0
  15. data/lib/mu/command/cmd_ddt.rb +449 -0
  16. data/lib/mu/command/cmd_homepage.rb +146 -0
  17. data/lib/mu/command/cmd_muapi.rb +361 -0
  18. data/lib/mu/command/cmd_netconfig.rb +262 -0
  19. data/lib/mu/command/cmd_runscale.rb +533 -0
  20. data/lib/mu/command/cmd_runscenario.rb +258 -0
  21. data/lib/mu/command/cmd_runverify.rb +336 -0
  22. data/lib/mu/command/cmd_scale.rb +333 -0
  23. data/lib/mu/command/cmd_system.rb +127 -0
  24. data/lib/mu/command/curl.rb +246 -0
  25. data/lib/mu/command/help.rb +29 -0
  26. data/lib/mu/curl/error.rb +54 -0
  27. data/lib/mu/curl/verify.rb +137 -0
  28. data/lib/mu/helper.rb +55 -0
  29. data/lib/mu/http_helper.rb +232 -0
  30. data/rdoc/classes/Mu.html +305 -0
  31. data/rdoc/classes/Mu/Client.html +265 -0
  32. data/rdoc/classes/Mu/Command.html +208 -0
  33. data/rdoc/classes/Mu/Command/API.html +524 -0
  34. data/rdoc/classes/Mu/Command/Cmd_appid.html +934 -0
  35. data/rdoc/classes/Mu/Command/Cmd_cli.html +515 -0
  36. data/rdoc/classes/Mu/Command/Cmd_ddt.html +1169 -0
  37. data/rdoc/classes/Mu/Command/Cmd_homepage.html +489 -0
  38. data/rdoc/classes/Mu/Command/Cmd_muapi.html +968 -0
  39. data/rdoc/classes/Mu/Command/Cmd_netconfig.html +743 -0
  40. data/rdoc/classes/Mu/Command/Cmd_runscale.html +970 -0
  41. data/rdoc/classes/Mu/Command/Cmd_runscenario.html +530 -0
  42. data/rdoc/classes/Mu/Command/Cmd_runverify.html +621 -0
  43. data/rdoc/classes/Mu/Command/Cmd_scale.html +939 -0
  44. data/rdoc/classes/Mu/Command/Cmd_system.html +426 -0
  45. data/rdoc/classes/Mu/Command/Curl.html +524 -0
  46. data/rdoc/classes/Mu/Command/Help.html +166 -0
  47. data/rdoc/classes/Mu/Curl.html +116 -0
  48. data/rdoc/classes/Mu/Curl/Error.html +157 -0
  49. data/rdoc/classes/Mu/Curl/Error/Authorize.html +178 -0
  50. data/rdoc/classes/Mu/Curl/Error/Connect.html +149 -0
  51. data/rdoc/classes/Mu/Curl/Error/DNS.html +113 -0
  52. data/rdoc/classes/Mu/Curl/Error/Region.html +160 -0
  53. data/rdoc/classes/Mu/Curl/Error/Status.html +149 -0
  54. data/rdoc/classes/Mu/Curl/Error/Timeout.html +149 -0
  55. data/rdoc/classes/Mu/Curl/Verify.html +282 -0
  56. data/rdoc/classes/Mu/Curl/Verify/Request.html +227 -0
  57. data/rdoc/classes/Mu/Curl/Verify/Response.html +187 -0
  58. data/rdoc/classes/Mu/Curl/Verify/Result.html +188 -0
  59. data/rdoc/classes/Mu/Ddt.html +914 -0
  60. data/rdoc/classes/Mu/Helper.html +308 -0
  61. data/rdoc/classes/Mu/Homepage.html +377 -0
  62. data/rdoc/classes/Mu/HttpHelper.html +639 -0
  63. data/rdoc/classes/Mu/Muapi.html +816 -0
  64. data/rdoc/classes/Mu/Netconfig.html +781 -0
  65. data/rdoc/classes/Mu/Scale.html +832 -0
  66. data/rdoc/classes/Mu/System.html +281 -0
  67. data/rdoc/classes/Object.html +148 -0
  68. data/rdoc/classes/TCTestMu.html +1793 -0
  69. data/rdoc/classes/Test.html +107 -0
  70. data/rdoc/classes/Test/Unit.html +107 -0
  71. data/rdoc/classes/Test/Unit/TestCase.html +113 -0
  72. data/rdoc/created.rid +1 -0
  73. data/rdoc/files/lib/mu/api/ddt_rb.html +101 -0
  74. data/rdoc/files/lib/mu/api/homepage_rb.html +101 -0
  75. data/rdoc/files/lib/mu/api/muapi_rb.html +101 -0
  76. data/rdoc/files/lib/mu/api/netconfig_rb.html +101 -0
  77. data/rdoc/files/lib/mu/api/scale_rb.html +101 -0
  78. data/rdoc/files/lib/mu/api/system_rb.html +101 -0
  79. data/rdoc/files/lib/mu/client_rb.html +101 -0
  80. data/rdoc/files/lib/mu/command/api_rb.html +101 -0
  81. data/rdoc/files/lib/mu/command/cmd_appid_rb.html +119 -0
  82. data/rdoc/files/lib/mu/command/cmd_cli_rb.html +108 -0
  83. data/rdoc/files/lib/mu/command/cmd_ddt_rb.html +117 -0
  84. data/rdoc/files/lib/mu/command/cmd_homepage_rb.html +115 -0
  85. data/rdoc/files/lib/mu/command/cmd_muapi_rb.html +116 -0
  86. data/rdoc/files/lib/mu/command/cmd_netconfig_rb.html +116 -0
  87. data/rdoc/files/lib/mu/command/cmd_runscale_rb.html +119 -0
  88. data/rdoc/files/lib/mu/command/cmd_runscenario_rb.html +115 -0
  89. data/rdoc/files/lib/mu/command/cmd_runverify_rb.html +117 -0
  90. data/rdoc/files/lib/mu/command/cmd_scale_rb.html +115 -0
  91. data/rdoc/files/lib/mu/command/cmd_system_rb.html +116 -0
  92. data/rdoc/files/lib/mu/command/curl_rb.html +101 -0
  93. data/rdoc/files/lib/mu/command/help_rb.html +101 -0
  94. data/rdoc/files/lib/mu/command_rb.html +107 -0
  95. data/rdoc/files/lib/mu/curl/error_rb.html +101 -0
  96. data/rdoc/files/lib/mu/curl/verify_rb.html +101 -0
  97. data/rdoc/files/lib/mu/helper_rb.html +101 -0
  98. data/rdoc/files/lib/mu/http_helper_rb.html +101 -0
  99. data/rdoc/files/lib/mu_rb.html +121 -0
  100. data/rdoc/files/test/helper_rb.html +112 -0
  101. data/rdoc/files/test/tc_test_mu_rb.html +111 -0
  102. data/rdoc/fr_class_index.html +68 -0
  103. data/rdoc/fr_file_index.html +55 -0
  104. data/rdoc/fr_method_index.html +374 -0
  105. data/rdoc/index.html +24 -0
  106. data/rdoc/rdoc-style.css +208 -0
  107. data/test/data/app_id_stats.csv +1 -0
  108. data/test/data/data_cgi.msl +94 -0
  109. data/test/data/data_cgi.xml +322 -0
  110. data/test/data/default_test.csv +3 -0
  111. data/test/data/ftp_with_channel.xml +1643 -0
  112. data/test/data/irc.xml +3837 -0
  113. data/test/data/scale_configuration.json +25 -0
  114. data/test/data/test_data_cgi_error.xml +35 -0
  115. data/test/helper.rb +18 -0
  116. data/test/tc_test_mu.rb +716 -0
  117. metadata +322 -0
@@ -0,0 +1,55 @@
1
+ class Mu
2
+ module Helper
3
+
4
+ def error msg
5
+ $stderr.puts "!! #{msg}"
6
+ end
7
+
8
+ def msg msg, level=Logger::INFO
9
+ caller[0] =~ /`([^']*)'/ and method = $1
10
+ if caller[0].include?("mu")
11
+ clz = caller[0][caller[0].index("mu")..caller[0].length]
12
+ else
13
+ clz = caller[0]
14
+ end
15
+
16
+ $log.add(level, "#{method} | #{msg}")
17
+ # $log.add(level, "(#{clz}) | #{msg}")
18
+ end
19
+
20
+ def ask
21
+ gets.strip
22
+ end
23
+
24
+ def shift key, argv
25
+ val = argv.shift
26
+ raise "missing value for #{key}" if val.nil?
27
+ val
28
+ end
29
+
30
+ def format_float(spaces=2,arg=0.0)
31
+ if !arg.nil?
32
+ return sprintf("%.#{spaces}f", arg)
33
+ else
34
+ return ""
35
+ end
36
+ end
37
+
38
+ def to_boolean(value="false")
39
+ return false if value.nil?
40
+ return true if value.downcase == "true"
41
+ return false
42
+ end
43
+
44
+ # IO.readlines
45
+ def get_file_as_string_array(filename)
46
+ arr = []
47
+ f = File.open(filename, "r")
48
+ f.each_line do |line|
49
+ arr.push line
50
+ end
51
+ return arr
52
+ end
53
+
54
+ end
55
+ end # Mu
@@ -0,0 +1,232 @@
1
+ class Mu
2
+ class HttpHelper
3
+ include Helper
4
+
5
+ def initialize(host, username, password, docroot)
6
+ @host = host
7
+ @username = username
8
+ @password = password
9
+ @docroot = docroot
10
+ $cookie = "" if $cookie.nil?
11
+ end
12
+
13
+ #--------------- RestClient methods ---------------------
14
+
15
+ # basic get call
16
+ # * e = the url suffix
17
+ # * p = hash of parameters, such as headers
18
+ def get(e, p={})
19
+ url = "https://#{@username}:#{@password}@#{@host}#{@docroot}#{e}"
20
+ msg url, Logger::DEBUG
21
+ params = {}.merge! p
22
+ params[:cookies] = $cookie if !$cookie.empty?
23
+ resp = RestClient.get(url, params)
24
+ $cookie = resp.cookies unless resp.cookies.empty?
25
+ msg "got cookie #{$cookie}", Logger::DEBUG unless resp.cookies.empty?
26
+ return resp
27
+ end
28
+
29
+ # get call for json, converts the response to json if applicable
30
+ # * e = the url suffix
31
+ # * p = hash of parameters, such as headers
32
+ def get_json(e, p={})
33
+ url = "https://#{@username}:#{@password}@#{@host}#{@docroot}#{e}"
34
+ msg url, Logger::DEBUG
35
+ params = {}.merge! p
36
+ params[:cookies] = $cookie if !$cookie.empty?
37
+ resp = RestClient.get(url, params)
38
+ $cookie = resp.cookies unless resp.cookies.empty?
39
+ msg "got cookie #{$cookie}", Logger::DEBUG unless resp.cookies.empty?
40
+ begin
41
+ msg resp, Logger::DEBUG
42
+ jresp = JSON resp
43
+ if jresp
44
+ return jresp
45
+ end
46
+ rescue JSON::ParserError => e
47
+ # nothing to do
48
+ end
49
+ return resp
50
+ end
51
+
52
+ # get call for xml, converts the response to xml if applicable
53
+ # * e = the url suffix
54
+ # * p = hash of parameters, such as headers
55
+ def get_xml(e, p={})
56
+ url = "https://#{@username}:#{@password}@#{@host}#{@docroot}#{e}"
57
+ msg url, Logger::DEBUG
58
+ params = {}.merge! p
59
+ params[:cookies] = $cookie if !$cookie.empty?
60
+ resp = RestClient.get(url, params)
61
+ $cookie = resp.cookies unless resp.cookies.empty?
62
+ msg "got cookie #{$cookie}", Logger::DEBUG unless resp.cookies.empty?
63
+ msg resp, Logger::DEBUG
64
+ begin
65
+ if (/<.+>/).match(resp)
66
+ xmldoc = Nokogiri::XML(resp)
67
+ else
68
+ err_node = Nokogiri::XML::Node.new('err_node', xmldoc)
69
+ err_node.content = resp
70
+ xmldoc.root << err_node
71
+ end
72
+ rescue => e
73
+ msg "Error parsing XML " + e.to_s, Logger::DEBUG
74
+ ensure
75
+ msg xmldoc, Logger::DEBUG
76
+ return xmldoc
77
+ end
78
+ end
79
+
80
+ # basic post call
81
+ # * e = the url suffix
82
+ # * body = the data to post
83
+ # * p = hash of parameters, such as headers
84
+ def post(e, body="", p = {})
85
+ url = "https://#{@username}:#{@password}@#{@host}#{@docroot}#{e}"
86
+ msg "#{url} #{body}", Logger::DEBUG
87
+ params = {}.merge! p
88
+ params[:cookies] = $cookie if !$cookie.empty?
89
+ msg("using cookie #{$cookie}", Logger::DEBUG) if !$cookie.empty?
90
+ resp = RestClient.post(url, body, params)
91
+ # msg resp.headers
92
+ $cookie = resp.cookies unless resp.cookies.empty?
93
+ msg "got cookie #{$cookie}", Logger::DEBUG unless resp.cookies.empty?
94
+ begin
95
+ msg resp, Logger::DEBUG
96
+ jresp = JSON resp
97
+ if jresp
98
+ return jresp
99
+ end
100
+ rescue JSON::ParserError => e
101
+ # do nothing
102
+ end
103
+ return resp
104
+ end
105
+
106
+ # post call for uploading json
107
+ # * e = the url suffix
108
+ # * body = the json object to post
109
+ # * p = hash of parameters, such as headers
110
+ def post_json(e, json, p = {})
111
+ url = "https://#{@username}:#{@password}@#{@host}#{@docroot}#{e}"
112
+ msg "#{url} #{json}", Logger::DEBUG
113
+ params = { :content_type => "application/json" }.merge! p
114
+ params[:cookies] = $cookie if !$cookie.empty?
115
+ resp = RestClient.post(url, json, params )
116
+ begin
117
+ msg resp, Logger::DEBUG
118
+ $cookie = resp.cookies unless resp.cookies.empty?
119
+ msg "got cookie #{$cookie}", Logger::DEBUG unless resp.cookies.empty?
120
+ jresp = JSON resp
121
+ if jresp
122
+ return jresp
123
+ end
124
+ rescue JSON::ParserError => e
125
+ # msg e, Logger::DEBUG
126
+ end
127
+ return resp
128
+ end
129
+
130
+ # post call for uploading xml
131
+ # * e = the url suffix
132
+ # * body = the xml object to post
133
+ # * p = hash of parameters, such as headers
134
+ def post_xml(e, doc, p = {})
135
+ begin
136
+ url = "https://#{@username}:#{@password}@#{@host}#{@docroot}#{e}"
137
+ msg "post to #{url}", Logger::DEBUG
138
+ params = { :content_type => "application/xml" }.merge! p
139
+ params[:cookies] = $cookie if !$cookie.empty?
140
+ resp = RestClient.post(url, doc.to_s, params )
141
+ msg resp, Logger::DEBUG
142
+ $cookie = resp.cookies unless resp.cookies.empty?
143
+ msg "got cookie #{$cookie}", Logger::DEBUG unless resp.cookies.empty?
144
+ # XML Document
145
+ if (/<.+>/).match(resp)
146
+ xmldoc = Nokogiri::XML(resp)
147
+ else
148
+ err_node = Nokogiri::XML::Node.new('err_node', xmldoc)
149
+ err_node.content = resp
150
+ xmldoc.root << err_node
151
+ end
152
+ rescue SocketError
153
+ raise "Host " + @host + " nicht erreichbar"
154
+ rescue Exception => e
155
+ msg "error parsing XML " + e.to_s, Logger::DEBUG
156
+ end
157
+ if (xmldoc.nil? || !xmldoc.xpath("//err_node").empty?)
158
+ @posted_uuid = nil
159
+ end
160
+ if !xmldoc.nil?
161
+ @posted_uuid = xmldoc.xpath("//uuid")[0].text if !xmldoc.xpath("//uuid").empty?
162
+ end
163
+ return xmldoc
164
+ end
165
+
166
+ # post call for uploading form data
167
+ # * e = the url suffix
168
+ # * filepath = the file to post
169
+ # * p = hash of parameters, such as headers
170
+ def post_form(e, filepath, p = {})
171
+ url = "https://#{@username}:#{@password}@#{@host}#{@docroot}#{e}"
172
+ params = {}.merge! p
173
+ params = { :content_type => "application/x-www-form-urlencoded", :file => File.new(filepath, 'rb') }
174
+ resp = RestClient.post(url, params)
175
+ $cookie = resp.cookies unless resp.cookies.empty?
176
+ msg "got cookie #{$cookie}", Logger::DEBUG unless resp.cookies.empty?
177
+ return resp
178
+ end
179
+
180
+ #------- other ---------
181
+
182
+ # basic delete call
183
+ # * e = the url suffix
184
+ def delete(e)
185
+ url = "https://#{@username}:#{@password}@#{@host}#{@docroot}#{e}"
186
+ return RestClient.delete(url)
187
+ end
188
+
189
+ # put call for json
190
+ # * e = the url suffix
191
+ # * body = the json object to put
192
+ # * p = hash of parameters, such as headers
193
+ def put_json(e, json, p={})
194
+ url = "https://#{@username}:#{@password}@#{@host}#{@docroot}#{e}"
195
+ params = {}.merge! p
196
+ params[:cookies] = $cookie if !$cookie.empty?
197
+ resp = RestClient.put(url, json, { :content_type => "application/json" } )
198
+ begin
199
+ msg resp, Logger::DEBUG
200
+ $cookie = resp.cookies unless resp.cookies.empty?
201
+ msg "got cookie #{$cookie}", Logger::DEBUG unless resp.cookies.empty?
202
+ jresp = JSON resp
203
+ if jresp
204
+ return jresp
205
+ end
206
+ rescue JSON::ParserError => e
207
+ # msg e, Logger::DEBUG
208
+ end
209
+ return resp
210
+ end
211
+
212
+ # fetches a file and stores it locally
213
+ # * e = the url suffix
214
+ # * filename = the name to store the file locally
215
+ # * p = hash of parameters, such as headers
216
+ def download_file(e, filename, p={})
217
+ url = "https://#{@username}:#{@password}@#{@host}#{@docroot}#{e}"
218
+ params = {}.merge! p
219
+ params[:cookies] = $cookie if !$cookie.empty?
220
+ resp = RestClient.get(url)
221
+ $cookie = resp.cookies unless resp.cookies.empty?
222
+ msg "got cookie #{$cookie}", Logger::DEBUG unless resp.cookies.empty?
223
+ if resp.body.include?("Could not download")
224
+ msg "==> Could not download the file"
225
+ return -1
226
+ end
227
+ open(filename, "wb") { |f| f.write(resp.body) }
228
+ return File.size(filename)
229
+ end
230
+
231
+ end
232
+ end # Mu
@@ -0,0 +1,305 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: Mu</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">Mu</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../files/lib/mu/api/ddt_rb.html">
59
+ lib/mu/api/ddt.rb
60
+ </a>
61
+ <br />
62
+ <a href="../files/lib/mu/api/homepage_rb.html">
63
+ lib/mu/api/homepage.rb
64
+ </a>
65
+ <br />
66
+ <a href="../files/lib/mu/api/muapi_rb.html">
67
+ lib/mu/api/muapi.rb
68
+ </a>
69
+ <br />
70
+ <a href="../files/lib/mu/api/netconfig_rb.html">
71
+ lib/mu/api/netconfig.rb
72
+ </a>
73
+ <br />
74
+ <a href="../files/lib/mu/api/scale_rb.html">
75
+ lib/mu/api/scale.rb
76
+ </a>
77
+ <br />
78
+ <a href="../files/lib/mu/api/system_rb.html">
79
+ lib/mu/api/system.rb
80
+ </a>
81
+ <br />
82
+ <a href="../files/lib/mu/client_rb.html">
83
+ lib/mu/client.rb
84
+ </a>
85
+ <br />
86
+ <a href="../files/lib/mu/command/api_rb.html">
87
+ lib/mu/command/api.rb
88
+ </a>
89
+ <br />
90
+ <a href="../files/lib/mu/command/cmd_appid_rb.html">
91
+ lib/mu/command/cmd_appid.rb
92
+ </a>
93
+ <br />
94
+ <a href="../files/lib/mu/command/cmd_cli_rb.html">
95
+ lib/mu/command/cmd_cli.rb
96
+ </a>
97
+ <br />
98
+ <a href="../files/lib/mu/command/cmd_ddt_rb.html">
99
+ lib/mu/command/cmd_ddt.rb
100
+ </a>
101
+ <br />
102
+ <a href="../files/lib/mu/command/cmd_homepage_rb.html">
103
+ lib/mu/command/cmd_homepage.rb
104
+ </a>
105
+ <br />
106
+ <a href="../files/lib/mu/command/cmd_muapi_rb.html">
107
+ lib/mu/command/cmd_muapi.rb
108
+ </a>
109
+ <br />
110
+ <a href="../files/lib/mu/command/cmd_netconfig_rb.html">
111
+ lib/mu/command/cmd_netconfig.rb
112
+ </a>
113
+ <br />
114
+ <a href="../files/lib/mu/command/cmd_runscale_rb.html">
115
+ lib/mu/command/cmd_runscale.rb
116
+ </a>
117
+ <br />
118
+ <a href="../files/lib/mu/command/cmd_runscenario_rb.html">
119
+ lib/mu/command/cmd_runscenario.rb
120
+ </a>
121
+ <br />
122
+ <a href="../files/lib/mu/command/cmd_runverify_rb.html">
123
+ lib/mu/command/cmd_runverify.rb
124
+ </a>
125
+ <br />
126
+ <a href="../files/lib/mu/command/cmd_scale_rb.html">
127
+ lib/mu/command/cmd_scale.rb
128
+ </a>
129
+ <br />
130
+ <a href="../files/lib/mu/command/cmd_system_rb.html">
131
+ lib/mu/command/cmd_system.rb
132
+ </a>
133
+ <br />
134
+ <a href="../files/lib/mu/command/curl_rb.html">
135
+ lib/mu/command/curl.rb
136
+ </a>
137
+ <br />
138
+ <a href="../files/lib/mu/command/help_rb.html">
139
+ lib/mu/command/help.rb
140
+ </a>
141
+ <br />
142
+ <a href="../files/lib/mu/command_rb.html">
143
+ lib/mu/command.rb
144
+ </a>
145
+ <br />
146
+ <a href="../files/lib/mu/curl/error_rb.html">
147
+ lib/mu/curl/error.rb
148
+ </a>
149
+ <br />
150
+ <a href="../files/lib/mu/curl/verify_rb.html">
151
+ lib/mu/curl/verify.rb
152
+ </a>
153
+ <br />
154
+ <a href="../files/lib/mu/helper_rb.html">
155
+ lib/mu/helper.rb
156
+ </a>
157
+ <br />
158
+ <a href="../files/lib/mu/http_helper_rb.html">
159
+ lib/mu/http_helper.rb
160
+ </a>
161
+ <br />
162
+ <a href="../files/lib/mu_rb.html">
163
+ lib/mu.rb
164
+ </a>
165
+ <br />
166
+ </td>
167
+ </tr>
168
+
169
+ <tr class="top-aligned-row">
170
+ <td><strong>Parent:</strong></td>
171
+ <td>
172
+ <a href="Object.html">
173
+ Object
174
+ </a>
175
+ </td>
176
+ </tr>
177
+ </table>
178
+ </div>
179
+ <!-- banner header -->
180
+
181
+ <div id="bodyContent">
182
+
183
+
184
+
185
+ <div id="contextContent">
186
+
187
+ <div id="description">
188
+ <p>
189
+ Api methods to access the <a href="Mu.html">Mu</a> CLI calls
190
+ </p>
191
+
192
+ </div>
193
+
194
+
195
+ </div>
196
+
197
+ <div id="method-list">
198
+ <h3 class="section-bar">Methods</h3>
199
+
200
+ <div class="name-list">
201
+ <a href="#M000051">run</a>&nbsp;&nbsp;
202
+ </div>
203
+ </div>
204
+
205
+ </div>
206
+
207
+
208
+ <!-- if includes -->
209
+
210
+ <div id="section">
211
+
212
+ <div id="class-list">
213
+ <h3 class="section-bar">Classes and Modules</h3>
214
+
215
+ Module <a href="Mu/Curl.html" class="link">Mu::Curl</a><br />
216
+ Module <a href="Mu/Helper.html" class="link">Mu::Helper</a><br />
217
+ Class <a href="Mu/Client.html" class="link">Mu::Client</a><br />
218
+ Class <a href="Mu/Command.html" class="link">Mu::Command</a><br />
219
+ Class <a href="Mu/Ddt.html" class="link">Mu::Ddt</a><br />
220
+ Class <a href="Mu/Homepage.html" class="link">Mu::Homepage</a><br />
221
+ Class <a href="Mu/HttpHelper.html" class="link">Mu::HttpHelper</a><br />
222
+ Class <a href="Mu/Muapi.html" class="link">Mu::Muapi</a><br />
223
+ Class <a href="Mu/Netconfig.html" class="link">Mu::Netconfig</a><br />
224
+ Class <a href="Mu/Scale.html" class="link">Mu::Scale</a><br />
225
+ Class <a href="Mu/System.html" class="link">Mu::System</a><br />
226
+
227
+ </div>
228
+
229
+ <div id="constants-list">
230
+ <h3 class="section-bar">Constants</h3>
231
+
232
+ <div class="name-list">
233
+ <table summary="Constants">
234
+ <tr class="top-aligned-row context-row">
235
+ <td class="context-item-name">Version</td>
236
+ <td>=</td>
237
+ <td class="context-item-value">&quot;0.1.0&quot;.freeze</td>
238
+ </tr>
239
+ </table>
240
+ </div>
241
+ </div>
242
+
243
+
244
+
245
+
246
+
247
+
248
+ <!-- if method_list -->
249
+ <div id="methods">
250
+ <h3 class="section-bar">Public Class methods</h3>
251
+
252
+ <div id="method-M000051" class="method-detail">
253
+ <a name="M000051"></a>
254
+
255
+ <div class="method-heading">
256
+ <a href="#M000051" class="method-signature">
257
+ <span class="method-name">run</span><span class="method-args">(cmd, argv)</span>
258
+ </a>
259
+ </div>
260
+
261
+ <div class="method-description">
262
+ <p><a class="source-toggle" href="#"
263
+ onclick="toggleCode('M000051-source');return false;">[Source]</a></p>
264
+ <div class="method-source-code" id="M000051-source">
265
+ <pre>
266
+ <span class="ruby-comment cmt"># File lib/mu.rb, line 18</span>
267
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">run</span> <span class="ruby-identifier">cmd</span>, <span class="ruby-identifier">argv</span>
268
+ <span class="ruby-identifier">$log</span>.<span class="ruby-identifier">datetime_format</span> = <span class="ruby-value str">&quot;%Y-%m-%d %H:%M:%S&quot;</span>
269
+ <span class="ruby-identifier">$log</span>.<span class="ruby-identifier">level</span> = <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">INFO</span>
270
+ <span class="ruby-identifier">$log</span>.<span class="ruby-identifier">formatter</span> = <span class="ruby-identifier">proc</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">severity</span>, <span class="ruby-identifier">datetime</span>, <span class="ruby-identifier">progname</span>, <span class="ruby-identifier">msg</span><span class="ruby-operator">|</span>
271
+ <span class="ruby-node">&quot;[#{datetime} #{severity}]: #{msg}\n&quot;</span>
272
+ }
273
+ <span class="ruby-identifier">kname</span>, <span class="ruby-identifier">mname</span> = <span class="ruby-identifier">cmd</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">':'</span>, <span class="ruby-value">2</span>)
274
+ <span class="ruby-identifier">klass</span> = <span class="ruby-constant">Mu</span><span class="ruby-operator">::</span><span class="ruby-constant">Command</span>.<span class="ruby-identifier">const_get</span> <span class="ruby-identifier">kname</span>.<span class="ruby-identifier">capitalize</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
275
+ <span class="ruby-identifier">mname</span> <span class="ruby-operator">||=</span> <span class="ruby-value str">'default'</span>
276
+ <span class="ruby-identifier">mname</span> = <span class="ruby-node">&quot;cmd_#{mname}&quot;</span>.<span class="ruby-identifier">to_sym</span>
277
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">klass</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">klass</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">Mu</span><span class="ruby-operator">::</span><span class="ruby-constant">Command</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">method_defined?</span> <span class="ruby-identifier">mname</span>
278
+ <span class="ruby-identifier">command</span> = <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">new</span>
279
+ <span class="ruby-keyword kw">begin</span>
280
+ <span class="ruby-identifier">command</span>.<span class="ruby-identifier">send</span> <span class="ruby-identifier">mname</span>, <span class="ruby-identifier">argv</span>
281
+ <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
282
+ <span class="ruby-identifier">error</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>.<span class="ruby-identifier">chomp</span>(<span class="ruby-value str">'.'</span>)
283
+ <span class="ruby-keyword kw">end</span>
284
+ <span class="ruby-keyword kw">else</span>
285
+ <span class="ruby-identifier">error</span> <span class="ruby-node">&quot;Unknown command #{cmd}&quot;</span>
286
+ <span class="ruby-keyword kw">end</span>
287
+ <span class="ruby-keyword kw">end</span>
288
+ </pre>
289
+ </div>
290
+ </div>
291
+ </div>
292
+
293
+
294
+ </div>
295
+
296
+
297
+ </div>
298
+
299
+
300
+ <div id="validator-badges">
301
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
302
+ </div>
303
+
304
+ </body>
305
+ </html>