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,743 @@
|
|
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::Command::Cmd_netconfig</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::Command::Cmd_netconfig</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../../files/lib/mu/command/cmd_netconfig_rb.html">
|
59
|
+
lib/mu/command/cmd_netconfig.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
Command
|
69
|
+
</td>
|
70
|
+
</tr>
|
71
|
+
</table>
|
72
|
+
</div>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<div id="contextContent">
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
</div>
|
84
|
+
|
85
|
+
<div id="method-list">
|
86
|
+
<h3 class="section-bar">Methods</h3>
|
87
|
+
|
88
|
+
<div class="name-list">
|
89
|
+
<a href="#M000199">cmd_clear_hosts</a>
|
90
|
+
<a href="#M000201">cmd_clear_interface</a>
|
91
|
+
<a href="#M000203">cmd_clear_routes</a>
|
92
|
+
<a href="#M000202">cmd_clear_vlans</a>
|
93
|
+
<a href="#M000196">cmd_create</a>
|
94
|
+
<a href="#M000197">cmd_delete</a>
|
95
|
+
<a href="#M000194">cmd_get</a>
|
96
|
+
<a href="#M000193">cmd_help</a>
|
97
|
+
<a href="#M000195">cmd_modify</a>
|
98
|
+
<a href="#M000200">cmd_resolve_hosts</a>
|
99
|
+
<a href="#M000198">cmd_restore</a>
|
100
|
+
<a href="#M000204">cmd_save</a>
|
101
|
+
<a href="#M000207">help</a>
|
102
|
+
<a href="#M000206">parse_cli</a>
|
103
|
+
<a href="#M000205">setup</a>
|
104
|
+
</div>
|
105
|
+
</div>
|
106
|
+
|
107
|
+
</div>
|
108
|
+
|
109
|
+
|
110
|
+
<!-- if includes -->
|
111
|
+
|
112
|
+
<div id="section">
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
<div id="attribute-list">
|
119
|
+
<h3 class="section-bar">Attributes</h3>
|
120
|
+
|
121
|
+
<div class="name-list">
|
122
|
+
<table>
|
123
|
+
<tr class="top-aligned-row context-row">
|
124
|
+
<td class="context-item-name">api</td>
|
125
|
+
<td class="context-item-value"> [RW] </td>
|
126
|
+
<td class="context-item-desc"></td>
|
127
|
+
</tr>
|
128
|
+
<tr class="top-aligned-row context-row">
|
129
|
+
<td class="context-item-name">host</td>
|
130
|
+
<td class="context-item-value"> [RW] </td>
|
131
|
+
<td class="context-item-desc"></td>
|
132
|
+
</tr>
|
133
|
+
<tr class="top-aligned-row context-row">
|
134
|
+
<td class="context-item-name">password</td>
|
135
|
+
<td class="context-item-value"> [RW] </td>
|
136
|
+
<td class="context-item-desc"></td>
|
137
|
+
</tr>
|
138
|
+
<tr class="top-aligned-row context-row">
|
139
|
+
<td class="context-item-name">username</td>
|
140
|
+
<td class="context-item-value"> [RW] </td>
|
141
|
+
<td class="context-item-desc"></td>
|
142
|
+
</tr>
|
143
|
+
</table>
|
144
|
+
</div>
|
145
|
+
</div>
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
<!-- if method_list -->
|
150
|
+
<div id="methods">
|
151
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
152
|
+
|
153
|
+
<div id="method-M000199" class="method-detail">
|
154
|
+
<a name="M000199"></a>
|
155
|
+
|
156
|
+
<div class="method-heading">
|
157
|
+
<a href="#M000199" class="method-signature">
|
158
|
+
<span class="method-name">cmd_clear_hosts</span><span class="method-args">(argv)</span>
|
159
|
+
</a>
|
160
|
+
</div>
|
161
|
+
|
162
|
+
<div class="method-description">
|
163
|
+
<p>
|
164
|
+
clears existing network configuration hosts
|
165
|
+
</p>
|
166
|
+
<pre>
|
167
|
+
* argv = command-line arguments
|
168
|
+
</pre>
|
169
|
+
<p><a class="source-toggle" href="#"
|
170
|
+
onclick="toggleCode('M000199-source');return false;">[Source]</a></p>
|
171
|
+
<div class="method-source-code" id="M000199-source">
|
172
|
+
<pre>
|
173
|
+
<span class="ruby-comment cmt"># File lib/mu/command/cmd_netconfig.rb, line 70</span>
|
174
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cmd_clear_hosts</span> <span class="ruby-identifier">argv</span>
|
175
|
+
<span class="ruby-identifier">setup</span> <span class="ruby-identifier">argv</span>
|
176
|
+
<span class="ruby-identifier">response</span> = <span class="ruby-ivar">@api</span>.<span class="ruby-identifier">clear_hosts</span>
|
177
|
+
<span class="ruby-identifier">msg</span> <span class="ruby-constant">JSON</span>.<span class="ruby-identifier">pretty_generate</span>(<span class="ruby-identifier">response</span>)
|
178
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">response</span>
|
179
|
+
<span class="ruby-keyword kw">end</span>
|
180
|
+
</pre>
|
181
|
+
</div>
|
182
|
+
</div>
|
183
|
+
</div>
|
184
|
+
|
185
|
+
<div id="method-M000201" class="method-detail">
|
186
|
+
<a name="M000201"></a>
|
187
|
+
|
188
|
+
<div class="method-heading">
|
189
|
+
<a href="#M000201" class="method-signature">
|
190
|
+
<span class="method-name">cmd_clear_interface</span><span class="method-args">(argv)</span>
|
191
|
+
</a>
|
192
|
+
</div>
|
193
|
+
|
194
|
+
<div class="method-description">
|
195
|
+
<p>
|
196
|
+
clears existing network interfaces
|
197
|
+
</p>
|
198
|
+
<pre>
|
199
|
+
* argv = command-line arguments, require the names of the interfaces to clear (-i name)
|
200
|
+
</pre>
|
201
|
+
<p><a class="source-toggle" href="#"
|
202
|
+
onclick="toggleCode('M000201-source');return false;">[Source]</a></p>
|
203
|
+
<div class="method-source-code" id="M000201-source">
|
204
|
+
<pre>
|
205
|
+
<span class="ruby-comment cmt"># File lib/mu/command/cmd_netconfig.rb, line 89</span>
|
206
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cmd_clear_interface</span> <span class="ruby-identifier">argv</span>
|
207
|
+
<span class="ruby-identifier">setup</span> <span class="ruby-identifier">argv</span>
|
208
|
+
<span class="ruby-identifier">interface</span> = <span class="ruby-ivar">@hash</span>[<span class="ruby-value str">'interfaces'</span>]
|
209
|
+
<span class="ruby-identifier">response</span> = <span class="ruby-ivar">@api</span>.<span class="ruby-identifier">clear_interface</span>(<span class="ruby-identifier">interface</span>)
|
210
|
+
<span class="ruby-identifier">msg</span> <span class="ruby-identifier">response</span>
|
211
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">response</span>
|
212
|
+
<span class="ruby-keyword kw">end</span>
|
213
|
+
</pre>
|
214
|
+
</div>
|
215
|
+
</div>
|
216
|
+
</div>
|
217
|
+
|
218
|
+
<div id="method-M000203" class="method-detail">
|
219
|
+
<a name="M000203"></a>
|
220
|
+
|
221
|
+
<div class="method-heading">
|
222
|
+
<a href="#M000203" class="method-signature">
|
223
|
+
<span class="method-name">cmd_clear_routes</span><span class="method-args">(argv)</span>
|
224
|
+
</a>
|
225
|
+
</div>
|
226
|
+
|
227
|
+
<div class="method-description">
|
228
|
+
<p>
|
229
|
+
clears existing network routes
|
230
|
+
</p>
|
231
|
+
<pre>
|
232
|
+
* argv = command-line arguments
|
233
|
+
</pre>
|
234
|
+
<p><a class="source-toggle" href="#"
|
235
|
+
onclick="toggleCode('M000203-source');return false;">[Source]</a></p>
|
236
|
+
<div class="method-source-code" id="M000203-source">
|
237
|
+
<pre>
|
238
|
+
<span class="ruby-comment cmt"># File lib/mu/command/cmd_netconfig.rb, line 108</span>
|
239
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cmd_clear_routes</span> <span class="ruby-identifier">argv</span>
|
240
|
+
<span class="ruby-identifier">setup</span> <span class="ruby-identifier">argv</span>
|
241
|
+
<span class="ruby-identifier">response</span> = <span class="ruby-ivar">@api</span>.<span class="ruby-identifier">clear_routes</span>
|
242
|
+
<span class="ruby-identifier">msg</span> <span class="ruby-identifier">response</span>
|
243
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">response</span>
|
244
|
+
<span class="ruby-keyword kw">end</span>
|
245
|
+
</pre>
|
246
|
+
</div>
|
247
|
+
</div>
|
248
|
+
</div>
|
249
|
+
|
250
|
+
<div id="method-M000202" class="method-detail">
|
251
|
+
<a name="M000202"></a>
|
252
|
+
|
253
|
+
<div class="method-heading">
|
254
|
+
<a href="#M000202" class="method-signature">
|
255
|
+
<span class="method-name">cmd_clear_vlans</span><span class="method-args">(argv)</span>
|
256
|
+
</a>
|
257
|
+
</div>
|
258
|
+
|
259
|
+
<div class="method-description">
|
260
|
+
<p>
|
261
|
+
clears existing vlan configurations
|
262
|
+
</p>
|
263
|
+
<pre>
|
264
|
+
* argv = command-line arguments
|
265
|
+
</pre>
|
266
|
+
<p><a class="source-toggle" href="#"
|
267
|
+
onclick="toggleCode('M000202-source');return false;">[Source]</a></p>
|
268
|
+
<div class="method-source-code" id="M000202-source">
|
269
|
+
<pre>
|
270
|
+
<span class="ruby-comment cmt"># File lib/mu/command/cmd_netconfig.rb, line 99</span>
|
271
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cmd_clear_vlans</span> <span class="ruby-identifier">argv</span>
|
272
|
+
<span class="ruby-identifier">setup</span> <span class="ruby-identifier">argv</span>
|
273
|
+
<span class="ruby-identifier">response</span> = <span class="ruby-ivar">@api</span>.<span class="ruby-identifier">clear_vlans</span>
|
274
|
+
<span class="ruby-identifier">msg</span> <span class="ruby-identifier">response</span>
|
275
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">response</span>
|
276
|
+
<span class="ruby-keyword kw">end</span>
|
277
|
+
</pre>
|
278
|
+
</div>
|
279
|
+
</div>
|
280
|
+
</div>
|
281
|
+
|
282
|
+
<div id="method-M000196" class="method-detail">
|
283
|
+
<a name="M000196"></a>
|
284
|
+
|
285
|
+
<div class="method-heading">
|
286
|
+
<a href="#M000196" class="method-signature">
|
287
|
+
<span class="method-name">cmd_create</span><span class="method-args">(argv)</span>
|
288
|
+
</a>
|
289
|
+
</div>
|
290
|
+
|
291
|
+
<div class="method-description">
|
292
|
+
<p>
|
293
|
+
creates a new network element
|
294
|
+
</p>
|
295
|
+
<pre>
|
296
|
+
* argv = command-line arguments, requires a json configuration (-j) and the element (-e) to modify, such as 'interfaces', 'hosts' or 'routes'
|
297
|
+
</pre>
|
298
|
+
<p><a class="source-toggle" href="#"
|
299
|
+
onclick="toggleCode('M000196-source');return false;">[Source]</a></p>
|
300
|
+
<div class="method-source-code" id="M000196-source">
|
301
|
+
<pre>
|
302
|
+
<span class="ruby-comment cmt"># File lib/mu/command/cmd_netconfig.rb, line 38</span>
|
303
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cmd_create</span> <span class="ruby-identifier">argv</span>
|
304
|
+
<span class="ruby-identifier">setup</span> <span class="ruby-identifier">argv</span>
|
305
|
+
<span class="ruby-identifier">json</span> = <span class="ruby-ivar">@hash</span>[<span class="ruby-value str">'json'</span>]
|
306
|
+
<span class="ruby-identifier">e</span> = <span class="ruby-ivar">@hash</span>[<span class="ruby-value str">'element'</span>]
|
307
|
+
<span class="ruby-identifier">response</span> = <span class="ruby-ivar">@api</span>.<span class="ruby-identifier">create</span>(<span class="ruby-identifier">json</span>, <span class="ruby-identifier">e</span>)
|
308
|
+
<span class="ruby-identifier">msg</span> <span class="ruby-identifier">response</span>
|
309
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">response</span>
|
310
|
+
<span class="ruby-keyword kw">end</span>
|
311
|
+
</pre>
|
312
|
+
</div>
|
313
|
+
</div>
|
314
|
+
</div>
|
315
|
+
|
316
|
+
<div id="method-M000197" class="method-detail">
|
317
|
+
<a name="M000197"></a>
|
318
|
+
|
319
|
+
<div class="method-heading">
|
320
|
+
<a href="#M000197" class="method-signature">
|
321
|
+
<span class="method-name">cmd_delete</span><span class="method-args">(argv)</span>
|
322
|
+
</a>
|
323
|
+
</div>
|
324
|
+
|
325
|
+
<div class="method-description">
|
326
|
+
<p>
|
327
|
+
deletes an existing network element
|
328
|
+
</p>
|
329
|
+
<pre>
|
330
|
+
* argv = command-line arguments, requires a json configuration (-j) and the element (-e) to modify, such as 'interfaces', 'hosts' or 'routes' or 'interfaces/a1' or 'hosts/dell-9'
|
331
|
+
</pre>
|
332
|
+
<p><a class="source-toggle" href="#"
|
333
|
+
onclick="toggleCode('M000197-source');return false;">[Source]</a></p>
|
334
|
+
<div class="method-source-code" id="M000197-source">
|
335
|
+
<pre>
|
336
|
+
<span class="ruby-comment cmt"># File lib/mu/command/cmd_netconfig.rb, line 49</span>
|
337
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cmd_delete</span> <span class="ruby-identifier">argv</span>
|
338
|
+
<span class="ruby-identifier">setup</span> <span class="ruby-identifier">argv</span>
|
339
|
+
<span class="ruby-identifier">e</span> = <span class="ruby-ivar">@hash</span>[<span class="ruby-value str">'element'</span>]
|
340
|
+
<span class="ruby-identifier">response</span> = <span class="ruby-ivar">@api</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">e</span>)
|
341
|
+
<span class="ruby-identifier">msg</span> <span class="ruby-identifier">response</span>
|
342
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">response</span>
|
343
|
+
<span class="ruby-keyword kw">end</span>
|
344
|
+
</pre>
|
345
|
+
</div>
|
346
|
+
</div>
|
347
|
+
</div>
|
348
|
+
|
349
|
+
<div id="method-M000194" class="method-detail">
|
350
|
+
<a name="M000194"></a>
|
351
|
+
|
352
|
+
<div class="method-heading">
|
353
|
+
<a href="#M000194" class="method-signature">
|
354
|
+
<span class="method-name">cmd_get</span><span class="method-args">(argv)</span>
|
355
|
+
</a>
|
356
|
+
</div>
|
357
|
+
|
358
|
+
<div class="method-description">
|
359
|
+
<p>
|
360
|
+
returns a json representation of the specified element
|
361
|
+
</p>
|
362
|
+
<pre>
|
363
|
+
* argv = command-line arguments, requires an element (-e) argument, such as 'interfaces', 'hosts' or 'routes' or 'interfaces/a1' or 'hosts/dell-9'
|
364
|
+
</pre>
|
365
|
+
<p><a class="source-toggle" href="#"
|
366
|
+
onclick="toggleCode('M000194-source');return false;">[Source]</a></p>
|
367
|
+
<div class="method-source-code" id="M000194-source">
|
368
|
+
<pre>
|
369
|
+
<span class="ruby-comment cmt"># File lib/mu/command/cmd_netconfig.rb, line 16</span>
|
370
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cmd_get</span> <span class="ruby-identifier">argv</span>
|
371
|
+
<span class="ruby-identifier">setup</span> <span class="ruby-identifier">argv</span>
|
372
|
+
<span class="ruby-identifier">e</span> = <span class="ruby-ivar">@hash</span>[<span class="ruby-value str">'element'</span>]
|
373
|
+
<span class="ruby-identifier">response</span> = <span class="ruby-ivar">@api</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">e</span>)
|
374
|
+
<span class="ruby-identifier">msg</span> <span class="ruby-constant">JSON</span>.<span class="ruby-identifier">pretty_generate</span>(<span class="ruby-identifier">response</span>)
|
375
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">response</span>
|
376
|
+
<span class="ruby-keyword kw">end</span>
|
377
|
+
</pre>
|
378
|
+
</div>
|
379
|
+
</div>
|
380
|
+
</div>
|
381
|
+
|
382
|
+
<div id="method-M000193" class="method-detail">
|
383
|
+
<a name="M000193"></a>
|
384
|
+
|
385
|
+
<div class="method-heading">
|
386
|
+
<a href="#M000193" class="method-signature">
|
387
|
+
<span class="method-name">cmd_help</span><span class="method-args">(argv)</span>
|
388
|
+
</a>
|
389
|
+
</div>
|
390
|
+
|
391
|
+
<div class="method-description">
|
392
|
+
<p>
|
393
|
+
displays command-line <a href="Cmd_netconfig.html#M000207">help</a>
|
394
|
+
</p>
|
395
|
+
<p><a class="source-toggle" href="#"
|
396
|
+
onclick="toggleCode('M000193-source');return false;">[Source]</a></p>
|
397
|
+
<div class="method-source-code" id="M000193-source">
|
398
|
+
<pre>
|
399
|
+
<span class="ruby-comment cmt"># File lib/mu/command/cmd_netconfig.rb, line 10</span>
|
400
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cmd_help</span> <span class="ruby-identifier">argv</span>
|
401
|
+
<span class="ruby-identifier">help</span>
|
402
|
+
<span class="ruby-keyword kw">end</span>
|
403
|
+
</pre>
|
404
|
+
</div>
|
405
|
+
</div>
|
406
|
+
</div>
|
407
|
+
|
408
|
+
<div id="method-M000195" class="method-detail">
|
409
|
+
<a name="M000195"></a>
|
410
|
+
|
411
|
+
<div class="method-heading">
|
412
|
+
<a href="#M000195" class="method-signature">
|
413
|
+
<span class="method-name">cmd_modify</span><span class="method-args">(argv)</span>
|
414
|
+
</a>
|
415
|
+
</div>
|
416
|
+
|
417
|
+
<div class="method-description">
|
418
|
+
<p>
|
419
|
+
modifies a network element
|
420
|
+
</p>
|
421
|
+
<pre>
|
422
|
+
* argv = command-line arguments, requires a json configuration (-j) and the element (-e) to modify, such as 'interfaces', 'hosts' or 'routes' or 'interfaces/a1' or 'hosts/dell-9'
|
423
|
+
</pre>
|
424
|
+
<p><a class="source-toggle" href="#"
|
425
|
+
onclick="toggleCode('M000195-source');return false;">[Source]</a></p>
|
426
|
+
<div class="method-source-code" id="M000195-source">
|
427
|
+
<pre>
|
428
|
+
<span class="ruby-comment cmt"># File lib/mu/command/cmd_netconfig.rb, line 26</span>
|
429
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cmd_modify</span> <span class="ruby-identifier">argv</span>
|
430
|
+
<span class="ruby-identifier">setup</span> <span class="ruby-identifier">argv</span>
|
431
|
+
<span class="ruby-identifier">json</span> = <span class="ruby-ivar">@hash</span>[<span class="ruby-value str">'json'</span>]
|
432
|
+
<span class="ruby-identifier">e</span> = <span class="ruby-ivar">@hash</span>[<span class="ruby-value str">'element'</span>]
|
433
|
+
<span class="ruby-identifier">response</span> = <span class="ruby-ivar">@api</span>.<span class="ruby-identifier">modify</span>(<span class="ruby-identifier">json</span>, <span class="ruby-identifier">e</span>)
|
434
|
+
<span class="ruby-identifier">msg</span> <span class="ruby-identifier">response</span>
|
435
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">response</span>
|
436
|
+
<span class="ruby-keyword kw">end</span>
|
437
|
+
</pre>
|
438
|
+
</div>
|
439
|
+
</div>
|
440
|
+
</div>
|
441
|
+
|
442
|
+
<div id="method-M000200" class="method-detail">
|
443
|
+
<a name="M000200"></a>
|
444
|
+
|
445
|
+
<div class="method-heading">
|
446
|
+
<a href="#M000200" class="method-signature">
|
447
|
+
<span class="method-name">cmd_resolve_hosts</span><span class="method-args">(argv)</span>
|
448
|
+
</a>
|
449
|
+
</div>
|
450
|
+
|
451
|
+
<div class="method-description">
|
452
|
+
<p>
|
453
|
+
resolves network configuration hosts
|
454
|
+
</p>
|
455
|
+
<pre>
|
456
|
+
* argv = command-line arguments, requires the name (-n) of the host to resolve (determines its ip address and adds it to the network configuration)
|
457
|
+
</pre>
|
458
|
+
<p><a class="source-toggle" href="#"
|
459
|
+
onclick="toggleCode('M000200-source');return false;">[Source]</a></p>
|
460
|
+
<div class="method-source-code" id="M000200-source">
|
461
|
+
<pre>
|
462
|
+
<span class="ruby-comment cmt"># File lib/mu/command/cmd_netconfig.rb, line 79</span>
|
463
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cmd_resolve_hosts</span> <span class="ruby-identifier">argv</span>
|
464
|
+
<span class="ruby-identifier">setup</span> <span class="ruby-identifier">argv</span>
|
465
|
+
<span class="ruby-identifier">name</span> = <span class="ruby-ivar">@hash</span>[<span class="ruby-value str">'name'</span>]
|
466
|
+
<span class="ruby-identifier">response</span> = <span class="ruby-ivar">@api</span>.<span class="ruby-identifier">resolve_hosts</span>(<span class="ruby-identifier">name</span>)
|
467
|
+
<span class="ruby-identifier">msg</span> <span class="ruby-identifier">response</span>
|
468
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">response</span>
|
469
|
+
<span class="ruby-keyword kw">end</span>
|
470
|
+
</pre>
|
471
|
+
</div>
|
472
|
+
</div>
|
473
|
+
</div>
|
474
|
+
|
475
|
+
<div id="method-M000198" class="method-detail">
|
476
|
+
<a name="M000198"></a>
|
477
|
+
|
478
|
+
<div class="method-heading">
|
479
|
+
<a href="#M000198" class="method-signature">
|
480
|
+
<span class="method-name">cmd_restore</span><span class="method-args">(argv)</span>
|
481
|
+
</a>
|
482
|
+
</div>
|
483
|
+
|
484
|
+
<div class="method-description">
|
485
|
+
<p>
|
486
|
+
restores the network configuration from a file
|
487
|
+
</p>
|
488
|
+
<pre>
|
489
|
+
* argv = command-line arguments, requires a path to a json configuration file (-f) , and a boolean (-b true|false) argument indicating whether or not existing elements should be cleared
|
490
|
+
</pre>
|
491
|
+
<p><a class="source-toggle" href="#"
|
492
|
+
onclick="toggleCode('M000198-source');return false;">[Source]</a></p>
|
493
|
+
<div class="method-source-code" id="M000198-source">
|
494
|
+
<pre>
|
495
|
+
<span class="ruby-comment cmt"># File lib/mu/command/cmd_netconfig.rb, line 59</span>
|
496
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cmd_restore</span> <span class="ruby-identifier">argv</span>
|
497
|
+
<span class="ruby-identifier">setup</span> <span class="ruby-identifier">argv</span>
|
498
|
+
<span class="ruby-identifier">filepath</span> = <span class="ruby-ivar">@hash</span>[<span class="ruby-value str">'filepath'</span>]
|
499
|
+
<span class="ruby-identifier">clear_existing</span> = <span class="ruby-identifier">to_boolean</span>(<span class="ruby-ivar">@hash</span>[<span class="ruby-value str">'boolean'</span>])
|
500
|
+
<span class="ruby-identifier">response</span> = <span class="ruby-ivar">@api</span>.<span class="ruby-identifier">restore</span>(<span class="ruby-identifier">filepath</span>, <span class="ruby-identifier">clear_existing</span>)
|
501
|
+
<span class="ruby-identifier">msg</span> <span class="ruby-identifier">response</span>
|
502
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">response</span>
|
503
|
+
<span class="ruby-keyword kw">end</span>
|
504
|
+
</pre>
|
505
|
+
</div>
|
506
|
+
</div>
|
507
|
+
</div>
|
508
|
+
|
509
|
+
<div id="method-M000204" class="method-detail">
|
510
|
+
<a name="M000204"></a>
|
511
|
+
|
512
|
+
<div class="method-heading">
|
513
|
+
<a href="#M000204" class="method-signature">
|
514
|
+
<span class="method-name">cmd_save</span><span class="method-args">(argv)</span>
|
515
|
+
</a>
|
516
|
+
</div>
|
517
|
+
|
518
|
+
<div class="method-description">
|
519
|
+
<p>
|
520
|
+
saves the network configuration to a file
|
521
|
+
</p>
|
522
|
+
<pre>
|
523
|
+
* argv = command-line arguments, requires the element (-e element, such as 'interfaces', or -e all) to save, and a file name (-f) to save the settings to
|
524
|
+
</pre>
|
525
|
+
<p><a class="source-toggle" href="#"
|
526
|
+
onclick="toggleCode('M000204-source');return false;">[Source]</a></p>
|
527
|
+
<div class="method-source-code" id="M000204-source">
|
528
|
+
<pre>
|
529
|
+
<span class="ruby-comment cmt"># File lib/mu/command/cmd_netconfig.rb, line 118</span>
|
530
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cmd_save</span> <span class="ruby-identifier">argv</span>
|
531
|
+
<span class="ruby-identifier">setup</span> <span class="ruby-identifier">argv</span>
|
532
|
+
<span class="ruby-identifier">e</span> = <span class="ruby-ivar">@hash</span>[<span class="ruby-value str">'elements'</span>]
|
533
|
+
<span class="ruby-identifier">filepath</span> = <span class="ruby-ivar">@hash</span>[<span class="ruby-value str">'filepath'</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">"config.json"</span>
|
534
|
+
<span class="ruby-identifier">response</span> = <span class="ruby-ivar">@api</span>.<span class="ruby-identifier">save</span>(<span class="ruby-identifier">e</span>, <span class="ruby-identifier">filepath</span>)
|
535
|
+
<span class="ruby-identifier">msg</span> <span class="ruby-identifier">response</span>
|
536
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">response</span>
|
537
|
+
<span class="ruby-keyword kw">end</span>
|
538
|
+
</pre>
|
539
|
+
</div>
|
540
|
+
</div>
|
541
|
+
</div>
|
542
|
+
|
543
|
+
<h3 class="section-bar">Private Instance methods</h3>
|
544
|
+
|
545
|
+
<div id="method-M000207" class="method-detail">
|
546
|
+
<a name="M000207"></a>
|
547
|
+
|
548
|
+
<div class="method-heading">
|
549
|
+
<a href="#M000207" class="method-signature">
|
550
|
+
<span class="method-name">help</span><span class="method-args">()</span>
|
551
|
+
</a>
|
552
|
+
</div>
|
553
|
+
|
554
|
+
<div class="method-description">
|
555
|
+
<p><a class="source-toggle" href="#"
|
556
|
+
onclick="toggleCode('M000207-source');return false;">[Source]</a></p>
|
557
|
+
<div class="method-source-code" id="M000207-source">
|
558
|
+
<pre>
|
559
|
+
<span class="ruby-comment cmt"># File lib/mu/command/cmd_netconfig.rb, line 212</span>
|
560
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">help</span>
|
561
|
+
<span class="ruby-identifier">helps</span> = [
|
562
|
+
{ <span class="ruby-identifier">:short</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'-b'</span>, <span class="ruby-identifier">:long</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'--boolean'</span>, <span class="ruby-identifier">:value</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'<string>'</span>, <span class="ruby-identifier">:help</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'boolean arg'</span> },
|
563
|
+
{ <span class="ruby-identifier">:short</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'-e'</span>, <span class="ruby-identifier">:long</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'--element'</span>, <span class="ruby-identifier">:value</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'<string>'</span>, <span class="ruby-identifier">:help</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'http string'</span> },
|
564
|
+
{ <span class="ruby-identifier">:short</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'-f'</span>, <span class="ruby-identifier">:long</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'--filepath'</span>, <span class="ruby-identifier">:value</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'<string>'</span>, <span class="ruby-identifier">:help</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'filepath'</span> },
|
565
|
+
{ <span class="ruby-identifier">:short</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'-h'</span>, <span class="ruby-identifier">:long</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'--help'</span>, <span class="ruby-identifier">:value</span> =<span class="ruby-operator">></span> <span class="ruby-value str">''</span>, <span class="ruby-identifier">:help</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'help on command line options'</span> },
|
566
|
+
{ <span class="ruby-identifier">:short</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'-i'</span>, <span class="ruby-identifier">:long</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'--interfaces'</span>, <span class="ruby-identifier">:value</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'<string>'</span>, <span class="ruby-identifier">:help</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'interfaces/hosts'</span> },
|
567
|
+
{ <span class="ruby-identifier">:short</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'-j'</span>, <span class="ruby-identifier">:long</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'--json'</span>, <span class="ruby-identifier">:value</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'<string>'</span>, <span class="ruby-identifier">:help</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'json object'</span> },
|
568
|
+
{ <span class="ruby-identifier">:short</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'-m'</span>, <span class="ruby-identifier">:long</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'--mu_string'</span>, <span class="ruby-identifier">:value</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'<string>'</span>, <span class="ruby-identifier">:help</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'user, password, mu_ip in the form of admin:admin@10.9.8.7'</span> },
|
569
|
+
{ <span class="ruby-identifier">:short</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'-n'</span>, <span class="ruby-identifier">:long</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'--name'</span>, <span class="ruby-identifier">:value</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'<string>'</span>, <span class="ruby-identifier">:help</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'host name'</span> },
|
570
|
+
{ <span class="ruby-identifier">:short</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'-o'</span>, <span class="ruby-identifier">:long</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'--output'</span>, <span class="ruby-identifier">:value</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'<string>'</span>, <span class="ruby-identifier">:help</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'output logging to this file'</span> },
|
571
|
+
{ <span class="ruby-identifier">:short</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'-v'</span>, <span class="ruby-identifier">:long</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'--verbose'</span>, <span class="ruby-identifier">:value</span> =<span class="ruby-operator">></span> <span class="ruby-value str">''</span>, <span class="ruby-identifier">:help</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'set Logger::DEBUG level'</span> }
|
572
|
+
]
|
573
|
+
|
574
|
+
<span class="ruby-identifier">cmds</span> = [
|
575
|
+
<span class="ruby-value str">"mu cmd_netconfig:clear_hosts"</span>,
|
576
|
+
<span class="ruby-value str">"mu cmd_netconfig:clear_interfaces -i <interfaces>"</span>,
|
577
|
+
<span class="ruby-value str">"mu cmd_netconfig:clear_routes"</span>,
|
578
|
+
<span class="ruby-value str">"mu cmd_netconfig:clear_vlans"</span>,
|
579
|
+
<span class="ruby-value str">"mu cmd_netconfig:create -j <json> -e <element>"</span>,
|
580
|
+
<span class="ruby-value str">"mu cmd_netconfig:delete -e <element>"</span>,
|
581
|
+
<span class="ruby-value str">"mu cmd_netconfig:get -e <element>"</span>,
|
582
|
+
<span class="ruby-value str">"mu cmd_netconfig:help"</span>,
|
583
|
+
<span class="ruby-value str">"mu cmd_netconfig:modify -j <json> -e <element>"</span>,
|
584
|
+
<span class="ruby-value str">"mu cmd_netconfig:resolve_hosts -n <name>"</span>,
|
585
|
+
<span class="ruby-value str">"mu cmd_netconfig:restore -f <filepath> [-b <clear_existing>]"</span>,
|
586
|
+
<span class="ruby-value str">"mu cmd_netconfig:save -e <element> -f <filepath>"</span>,
|
587
|
+
]
|
588
|
+
|
589
|
+
<span class="ruby-identifier">max_long_size</span> = <span class="ruby-identifier">helps</span>.<span class="ruby-identifier">inject</span>(<span class="ruby-value">0</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">memo</span>, <span class="ruby-identifier">obj</span><span class="ruby-operator">|</span> [ <span class="ruby-identifier">obj</span>[<span class="ruby-identifier">:long</span>].<span class="ruby-identifier">size</span>, <span class="ruby-identifier">memo</span> ].<span class="ruby-identifier">max</span> }
|
590
|
+
<span class="ruby-identifier">max_value_size</span> = <span class="ruby-identifier">helps</span>.<span class="ruby-identifier">inject</span>(<span class="ruby-value">0</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">memo</span>, <span class="ruby-identifier">obj</span><span class="ruby-operator">|</span> [ <span class="ruby-identifier">obj</span>[<span class="ruby-identifier">:value</span>].<span class="ruby-identifier">size</span>, <span class="ruby-identifier">memo</span> ].<span class="ruby-identifier">max</span> }
|
591
|
+
<span class="ruby-identifier">puts</span>
|
592
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-value str">"Usage: mu cmd_netconfig <options>"</span>
|
593
|
+
<span class="ruby-identifier">puts</span>
|
594
|
+
<span class="ruby-identifier">helps</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">h</span><span class="ruby-operator">|</span>
|
595
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-value str">"%-*s %*s %-*s %s"</span> <span class="ruby-operator">%</span> [<span class="ruby-identifier">max_long_size</span>, <span class="ruby-identifier">h</span>[<span class="ruby-identifier">:long</span>], <span class="ruby-value">2</span>, <span class="ruby-identifier">h</span>[<span class="ruby-identifier">:short</span>], <span class="ruby-identifier">max_value_size</span>, <span class="ruby-identifier">h</span>[<span class="ruby-identifier">:value</span>], <span class="ruby-identifier">h</span>[<span class="ruby-identifier">:help</span>]]
|
596
|
+
<span class="ruby-keyword kw">end</span>
|
597
|
+
<span class="ruby-identifier">puts</span>
|
598
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-value str">"Available Commands"</span>
|
599
|
+
<span class="ruby-identifier">puts</span>
|
600
|
+
<span class="ruby-identifier">cmds</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">c</span> <span class="ruby-operator">|</span>
|
601
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">c</span>
|
602
|
+
<span class="ruby-keyword kw">end</span>
|
603
|
+
<span class="ruby-identifier">puts</span>
|
604
|
+
<span class="ruby-keyword kw">end</span>
|
605
|
+
</pre>
|
606
|
+
</div>
|
607
|
+
</div>
|
608
|
+
</div>
|
609
|
+
|
610
|
+
<div id="method-M000206" class="method-detail">
|
611
|
+
<a name="M000206"></a>
|
612
|
+
|
613
|
+
<div class="method-heading">
|
614
|
+
<a href="#M000206" class="method-signature">
|
615
|
+
<span class="method-name">parse_cli</span><span class="method-args">(argv)</span>
|
616
|
+
</a>
|
617
|
+
</div>
|
618
|
+
|
619
|
+
<div class="method-description">
|
620
|
+
<p><a class="source-toggle" href="#"
|
621
|
+
onclick="toggleCode('M000206-source');return false;">[Source]</a></p>
|
622
|
+
<div class="method-source-code" id="M000206-source">
|
623
|
+
<pre>
|
624
|
+
<span class="ruby-comment cmt"># File lib/mu/command/cmd_netconfig.rb, line 140</span>
|
625
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_cli</span> <span class="ruby-identifier">argv</span>
|
626
|
+
<span class="ruby-identifier">args</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
|
627
|
+
<span class="ruby-ivar">@hash</span> = {}
|
628
|
+
<span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">argv</span>.<span class="ruby-identifier">empty?</span>
|
629
|
+
<span class="ruby-identifier">args</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">argv</span>.<span class="ruby-identifier">shift</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">argv</span>.<span class="ruby-identifier">first</span>[<span class="ruby-value">0</span>,<span class="ruby-value">1</span>] <span class="ruby-operator">!=</span> <span class="ruby-value str">'-'</span>
|
630
|
+
|
631
|
+
<span class="ruby-identifier">k</span> = <span class="ruby-identifier">argv</span>.<span class="ruby-identifier">shift</span>
|
632
|
+
|
633
|
+
<span class="ruby-keyword kw">if</span> [ <span class="ruby-value str">'-b'</span>, <span class="ruby-value str">'--boolean'</span> ].<span class="ruby-identifier">member?</span> <span class="ruby-identifier">k</span>
|
634
|
+
<span class="ruby-ivar">@hash</span>[<span class="ruby-value str">'boolean'</span>] = <span class="ruby-identifier">shift</span>(<span class="ruby-identifier">k</span>, <span class="ruby-identifier">argv</span>)
|
635
|
+
<span class="ruby-keyword kw">next</span>
|
636
|
+
<span class="ruby-keyword kw">end</span>
|
637
|
+
|
638
|
+
<span class="ruby-keyword kw">if</span> [ <span class="ruby-value str">'-e'</span>, <span class="ruby-value str">'--element'</span> ].<span class="ruby-identifier">member?</span> <span class="ruby-identifier">k</span>
|
639
|
+
<span class="ruby-ivar">@hash</span>[<span class="ruby-value str">'element'</span>] = <span class="ruby-identifier">shift</span>(<span class="ruby-identifier">k</span>, <span class="ruby-identifier">argv</span>)
|
640
|
+
<span class="ruby-keyword kw">next</span>
|
641
|
+
<span class="ruby-keyword kw">end</span>
|
642
|
+
|
643
|
+
<span class="ruby-keyword kw">if</span> [ <span class="ruby-value str">'-f'</span>, <span class="ruby-value str">'--filepath'</span> ].<span class="ruby-identifier">member?</span> <span class="ruby-identifier">k</span>
|
644
|
+
<span class="ruby-ivar">@hash</span>[<span class="ruby-value str">'filepath'</span>] = <span class="ruby-identifier">shift</span>(<span class="ruby-identifier">k</span>, <span class="ruby-identifier">argv</span>)
|
645
|
+
<span class="ruby-keyword kw">next</span>
|
646
|
+
<span class="ruby-keyword kw">end</span>
|
647
|
+
|
648
|
+
<span class="ruby-keyword kw">if</span> [ <span class="ruby-value str">'-h'</span>, <span class="ruby-value str">'--help'</span> ].<span class="ruby-identifier">member?</span> <span class="ruby-identifier">k</span>
|
649
|
+
<span class="ruby-identifier">help</span>
|
650
|
+
<span class="ruby-identifier">exit</span>
|
651
|
+
<span class="ruby-keyword kw">end</span>
|
652
|
+
|
653
|
+
<span class="ruby-keyword kw">if</span> [ <span class="ruby-value str">'-i'</span>, <span class="ruby-value str">'--interfaces'</span> ].<span class="ruby-identifier">member?</span> <span class="ruby-identifier">k</span>
|
654
|
+
<span class="ruby-ivar">@hash</span>[<span class="ruby-value str">'interfaces'</span>] = <span class="ruby-identifier">shift</span>(<span class="ruby-identifier">k</span>, <span class="ruby-identifier">argv</span>)
|
655
|
+
<span class="ruby-keyword kw">next</span>
|
656
|
+
<span class="ruby-keyword kw">end</span>
|
657
|
+
|
658
|
+
<span class="ruby-keyword kw">if</span> [ <span class="ruby-value str">'-j'</span>, <span class="ruby-value str">'--json'</span> ].<span class="ruby-identifier">member?</span> <span class="ruby-identifier">k</span>
|
659
|
+
<span class="ruby-ivar">@hash</span>[<span class="ruby-value str">'json'</span>] = <span class="ruby-identifier">shift</span>(<span class="ruby-identifier">k</span>, <span class="ruby-identifier">argv</span>)
|
660
|
+
<span class="ruby-keyword kw">next</span>
|
661
|
+
<span class="ruby-keyword kw">end</span>
|
662
|
+
|
663
|
+
<span class="ruby-keyword kw">if</span> [ <span class="ruby-value str">'-m'</span>, <span class="ruby-value str">'--mu_string'</span> ].<span class="ruby-identifier">member?</span> <span class="ruby-identifier">k</span>
|
664
|
+
<span class="ruby-identifier">mu_string</span> = <span class="ruby-identifier">shift</span>(<span class="ruby-identifier">k</span>, <span class="ruby-identifier">argv</span>)
|
665
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">mu_string</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/(.+?):(.+?)@(.*)/</span>
|
666
|
+
<span class="ruby-ivar">@@mu_admin_user</span> = <span class="ruby-identifier">$1</span>
|
667
|
+
<span class="ruby-ivar">@@mu_admin_pass</span> = <span class="ruby-identifier">$2</span>
|
668
|
+
<span class="ruby-ivar">@@mu_ip</span> = <span class="ruby-identifier">$3</span>
|
669
|
+
<span class="ruby-keyword kw">end</span>
|
670
|
+
<span class="ruby-keyword kw">next</span>
|
671
|
+
<span class="ruby-keyword kw">end</span>
|
672
|
+
|
673
|
+
<span class="ruby-keyword kw">if</span> [ <span class="ruby-value str">'-n'</span>, <span class="ruby-value str">'--name'</span> ].<span class="ruby-identifier">member?</span> <span class="ruby-identifier">k</span>
|
674
|
+
<span class="ruby-ivar">@hash</span>[<span class="ruby-value str">'name'</span>] = <span class="ruby-identifier">shift</span>(<span class="ruby-identifier">k</span>, <span class="ruby-identifier">argv</span>)
|
675
|
+
<span class="ruby-keyword kw">next</span>
|
676
|
+
<span class="ruby-keyword kw">end</span>
|
677
|
+
|
678
|
+
<span class="ruby-keyword kw">if</span> [ <span class="ruby-value str">'-o'</span>, <span class="ruby-value str">'--output'</span> ].<span class="ruby-identifier">member?</span> <span class="ruby-identifier">k</span>
|
679
|
+
<span class="ruby-identifier">$stdout</span>.<span class="ruby-identifier">reopen</span>(<span class="ruby-identifier">shift</span>(<span class="ruby-identifier">k</span>, <span class="ruby-identifier">argv</span>), <span class="ruby-value str">"w"</span>)
|
680
|
+
<span class="ruby-keyword kw">next</span>
|
681
|
+
<span class="ruby-keyword kw">end</span>
|
682
|
+
|
683
|
+
<span class="ruby-keyword kw">if</span> [ <span class="ruby-value str">'-r'</span>, <span class="ruby-value str">'--routes'</span> ].<span class="ruby-identifier">member?</span> <span class="ruby-identifier">k</span>
|
684
|
+
<span class="ruby-ivar">@hash</span>[<span class="ruby-value str">'routes'</span>] = <span class="ruby-identifier">shift</span>(<span class="ruby-identifier">k</span>, <span class="ruby-identifier">argv</span>)
|
685
|
+
<span class="ruby-keyword kw">next</span>
|
686
|
+
<span class="ruby-keyword kw">end</span>
|
687
|
+
|
688
|
+
<span class="ruby-keyword kw">if</span> [ <span class="ruby-value str">'-v'</span>, <span class="ruby-value str">'--verbose'</span> ].<span class="ruby-identifier">member?</span> <span class="ruby-identifier">k</span>
|
689
|
+
<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">DEBUG</span>
|
690
|
+
<span class="ruby-keyword kw">next</span>
|
691
|
+
<span class="ruby-keyword kw">end</span>
|
692
|
+
<span class="ruby-keyword kw">end</span>
|
693
|
+
|
694
|
+
<span class="ruby-identifier">args</span>
|
695
|
+
<span class="ruby-keyword kw">end</span>
|
696
|
+
</pre>
|
697
|
+
</div>
|
698
|
+
</div>
|
699
|
+
</div>
|
700
|
+
|
701
|
+
<div id="method-M000205" class="method-detail">
|
702
|
+
<a name="M000205"></a>
|
703
|
+
|
704
|
+
<div class="method-heading">
|
705
|
+
<a href="#M000205" class="method-signature">
|
706
|
+
<span class="method-name">setup</span><span class="method-args">(argv)</span>
|
707
|
+
</a>
|
708
|
+
</div>
|
709
|
+
|
710
|
+
<div class="method-description">
|
711
|
+
<p><a class="source-toggle" href="#"
|
712
|
+
onclick="toggleCode('M000205-source');return false;">[Source]</a></p>
|
713
|
+
<div class="method-source-code" id="M000205-source">
|
714
|
+
<pre>
|
715
|
+
<span class="ruby-comment cmt"># File lib/mu/command/cmd_netconfig.rb, line 129</span>
|
716
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">setup</span> <span class="ruby-identifier">argv</span>
|
717
|
+
<span class="ruby-identifier">parse_cli</span> <span class="ruby-identifier">argv</span>
|
718
|
+
<span class="ruby-ivar">@host</span> = (<span class="ruby-ivar">@@mu_ip</span>.<span class="ruby-identifier">nil?</span>) <span class="ruby-operator">?</span> <span class="ruby-value str">"127.0.0.1"</span> <span class="ruby-operator">:</span> <span class="ruby-ivar">@@mu_ip</span>
|
719
|
+
<span class="ruby-ivar">@username</span> = (<span class="ruby-ivar">@@mu_admin_user</span>.<span class="ruby-identifier">nil?</span>) <span class="ruby-operator">?</span> <span class="ruby-value str">"admin"</span> <span class="ruby-operator">:</span> <span class="ruby-ivar">@@mu_admin_user</span>
|
720
|
+
<span class="ruby-ivar">@password</span> = (<span class="ruby-ivar">@@mu_admin_pass</span>.<span class="ruby-identifier">nil?</span>) <span class="ruby-operator">?</span> <span class="ruby-value str">"admin"</span> <span class="ruby-operator">:</span> <span class="ruby-ivar">@@mu_admin_pass</span>
|
721
|
+
<span class="ruby-ivar">@response</span> = <span class="ruby-keyword kw">nil</span>
|
722
|
+
<span class="ruby-ivar">@element</span> = <span class="ruby-value str">""</span> <span class="ruby-comment cmt"># sticky variable will hold a default element, the last element specified</span>
|
723
|
+
<span class="ruby-ivar">@api</span> = <span class="ruby-constant">Netconfig</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@host</span>, <span class="ruby-ivar">@username</span>, <span class="ruby-ivar">@password</span>)
|
724
|
+
<span class="ruby-identifier">msg</span> <span class="ruby-node">"Created Netconfig API object to :#{@host}"</span>, <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">DEBUG</span>
|
725
|
+
<span class="ruby-keyword kw">end</span>
|
726
|
+
</pre>
|
727
|
+
</div>
|
728
|
+
</div>
|
729
|
+
</div>
|
730
|
+
|
731
|
+
|
732
|
+
</div>
|
733
|
+
|
734
|
+
|
735
|
+
</div>
|
736
|
+
|
737
|
+
|
738
|
+
<div id="validator-badges">
|
739
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
740
|
+
</div>
|
741
|
+
|
742
|
+
</body>
|
743
|
+
</html>
|