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,781 @@
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::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::Netconfig</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/mu/api/netconfig_rb.html">
59
+ lib/mu/api/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
+ <a href="../Object.html">
69
+ Object
70
+ </a>
71
+ </td>
72
+ </tr>
73
+ </table>
74
+ </div>
75
+ <!-- banner header -->
76
+
77
+ <div id="bodyContent">
78
+
79
+
80
+
81
+ <div id="contextContent">
82
+
83
+
84
+
85
+ </div>
86
+
87
+ <div id="method-list">
88
+ <h3 class="section-bar">Methods</h3>
89
+
90
+ <div class="name-list">
91
+ <a href="#M000285">clear_hosts</a>&nbsp;&nbsp;
92
+ <a href="#M000288">clear_interface</a>&nbsp;&nbsp;
93
+ <a href="#M000291">clear_routes</a>&nbsp;&nbsp;
94
+ <a href="#M000289">clear_vlans</a>&nbsp;&nbsp;
95
+ <a href="#M000282">create</a>&nbsp;&nbsp;
96
+ <a href="#M000283">delete</a>&nbsp;&nbsp;
97
+ <a href="#M000294">do_modify</a>&nbsp;&nbsp;
98
+ <a href="#M000280">get</a>&nbsp;&nbsp;
99
+ <a href="#M000295">http_request</a>&nbsp;&nbsp;
100
+ <a href="#M000281">modify</a>&nbsp;&nbsp;
101
+ <a href="#M000279">new</a>&nbsp;&nbsp;
102
+ <a href="#M000287">resolve_hosts</a>&nbsp;&nbsp;
103
+ <a href="#M000284">restore</a>&nbsp;&nbsp;
104
+ <a href="#M000286">restore_hosts</a>&nbsp;&nbsp;
105
+ <a href="#M000290">restore_interfaces</a>&nbsp;&nbsp;
106
+ <a href="#M000292">restore_routes</a>&nbsp;&nbsp;
107
+ <a href="#M000293">save</a>&nbsp;&nbsp;
108
+ </div>
109
+ </div>
110
+
111
+ </div>
112
+
113
+
114
+ <!-- if includes -->
115
+ <div id="includes">
116
+ <h3 class="section-bar">Included Modules</h3>
117
+
118
+ <div id="includes-list">
119
+ <span class="include-name"><a href="Helper.html">Helper</a></span>
120
+ </div>
121
+ </div>
122
+
123
+ <div id="section">
124
+
125
+
126
+
127
+
128
+
129
+ <div id="attribute-list">
130
+ <h3 class="section-bar">Attributes</h3>
131
+
132
+ <div class="name-list">
133
+ <table>
134
+ <tr class="top-aligned-row context-row">
135
+ <td class="context-item-name">config</td>
136
+ <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
137
+ <td class="context-item-desc"></td>
138
+ </tr>
139
+ <tr class="top-aligned-row context-row">
140
+ <td class="context-item-name">docroot</td>
141
+ <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
142
+ <td class="context-item-desc"></td>
143
+ </tr>
144
+ <tr class="top-aligned-row context-row">
145
+ <td class="context-item-name">element</td>
146
+ <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
147
+ <td class="context-item-desc"></td>
148
+ </tr>
149
+ <tr class="top-aligned-row context-row">
150
+ <td class="context-item-name">host</td>
151
+ <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
152
+ <td class="context-item-desc"></td>
153
+ </tr>
154
+ <tr class="top-aligned-row context-row">
155
+ <td class="context-item-name">password</td>
156
+ <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
157
+ <td class="context-item-desc"></td>
158
+ </tr>
159
+ <tr class="top-aligned-row context-row">
160
+ <td class="context-item-name">response</td>
161
+ <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
162
+ <td class="context-item-desc"></td>
163
+ </tr>
164
+ <tr class="top-aligned-row context-row">
165
+ <td class="context-item-name">username</td>
166
+ <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
167
+ <td class="context-item-desc"></td>
168
+ </tr>
169
+ </table>
170
+ </div>
171
+ </div>
172
+
173
+
174
+
175
+ <!-- if method_list -->
176
+ <div id="methods">
177
+ <h3 class="section-bar">Public Class methods</h3>
178
+
179
+ <div id="method-M000279" class="method-detail">
180
+ <a name="M000279"></a>
181
+
182
+ <div class="method-heading">
183
+ <a href="#M000279" class="method-signature">
184
+ <span class="method-name">new</span><span class="method-args">(host=ENV['MU_IP'], username=ENV['MU_ADMIN_USER'], password=ENV['MU_ADMIN_PASS'])</span>
185
+ </a>
186
+ </div>
187
+
188
+ <div class="method-description">
189
+ <p><a class="source-toggle" href="#"
190
+ onclick="toggleCode('M000279-source');return false;">[Source]</a></p>
191
+ <div class="method-source-code" id="M000279-source">
192
+ <pre>
193
+ <span class="ruby-comment cmt"># File lib/mu/api/netconfig.rb, line 7</span>
194
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">host</span>=<span class="ruby-constant">ENV</span>[<span class="ruby-value str">'MU_IP'</span>], <span class="ruby-identifier">username</span>=<span class="ruby-constant">ENV</span>[<span class="ruby-value str">'MU_ADMIN_USER'</span>], <span class="ruby-identifier">password</span>=<span class="ruby-constant">ENV</span>[<span class="ruby-value str">'MU_ADMIN_PASS'</span>])
195
+ <span class="ruby-ivar">@host</span> = <span class="ruby-identifier">host</span>
196
+ <span class="ruby-ivar">@username</span> = <span class="ruby-identifier">username</span>
197
+ <span class="ruby-ivar">@password</span> = <span class="ruby-identifier">password</span>
198
+ <span class="ruby-ivar">@docroot</span> = <span class="ruby-value str">&quot;/restlet/netconfig/&quot;</span>
199
+ <span class="ruby-ivar">@response</span> = <span class="ruby-keyword kw">nil</span>
200
+ <span class="ruby-ivar">@http</span> = <span class="ruby-constant">HttpHelper</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>, <span class="ruby-ivar">@docroot</span>)
201
+ <span class="ruby-ivar">@element</span> = <span class="ruby-value str">&quot;&quot;</span> <span class="ruby-comment cmt"># sticky variable will hold a default element, the last element specified</span>
202
+ <span class="ruby-identifier">msg</span> <span class="ruby-node">&quot;Created Netconfig API object to :#{@host}&quot;</span>, <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">DEBUG</span>
203
+ <span class="ruby-keyword kw">end</span>
204
+ </pre>
205
+ </div>
206
+ </div>
207
+ </div>
208
+
209
+ <h3 class="section-bar">Public Instance methods</h3>
210
+
211
+ <div id="method-M000285" class="method-detail">
212
+ <a name="M000285"></a>
213
+
214
+ <div class="method-heading">
215
+ <a href="#M000285" class="method-signature">
216
+ <span class="method-name">clear_hosts</span><span class="method-args">()</span>
217
+ </a>
218
+ </div>
219
+
220
+ <div class="method-description">
221
+ <p>
222
+ clears the network hosts
223
+ </p>
224
+ <p><a class="source-toggle" href="#"
225
+ onclick="toggleCode('M000285-source');return false;">[Source]</a></p>
226
+ <div class="method-source-code" id="M000285-source">
227
+ <pre>
228
+ <span class="ruby-comment cmt"># File lib/mu/api/netconfig.rb, line 92</span>
229
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">clear_hosts</span>
230
+ <span class="ruby-identifier">h</span> = <span class="ruby-identifier">get</span>(<span class="ruby-value str">&quot;hosts&quot;</span>)
231
+ <span class="ruby-identifier">h</span>[<span class="ruby-value str">&quot;hosts&quot;</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>
232
+ <span class="ruby-identifier">msg</span> <span class="ruby-node">&quot;Clear host: #{h['name']}&quot;</span>, <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">DEBUG</span>
233
+ <span class="ruby-identifier">delete</span>(<span class="ruby-node">&quot;hosts/#{h['name']}&quot;</span>)
234
+ <span class="ruby-keyword kw">end</span>
235
+ <span class="ruby-keyword kw">end</span>
236
+ </pre>
237
+ </div>
238
+ </div>
239
+ </div>
240
+
241
+ <div id="method-M000288" class="method-detail">
242
+ <a name="M000288"></a>
243
+
244
+ <div class="method-heading">
245
+ <a href="#M000288" class="method-signature">
246
+ <span class="method-name">clear_interface</span><span class="method-args">(interface)</span>
247
+ </a>
248
+ </div>
249
+
250
+ <div class="method-description">
251
+ <p>
252
+ clears a network interface
253
+ </p>
254
+ <pre>
255
+ * interface = the name of the interface to clear
256
+ </pre>
257
+ <p><a class="source-toggle" href="#"
258
+ onclick="toggleCode('M000288-source');return false;">[Source]</a></p>
259
+ <div class="method-source-code" id="M000288-source">
260
+ <pre>
261
+ <span class="ruby-comment cmt"># File lib/mu/api/netconfig.rb, line 137</span>
262
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">clear_interface</span>(<span class="ruby-identifier">interface</span>)
263
+ <span class="ruby-identifier">interface</span> = <span class="ruby-identifier">interface</span>
264
+ <span class="ruby-identifier">json</span> = { <span class="ruby-value str">&quot;v4_addrs&quot;</span>=<span class="ruby-operator">&gt;</span>[], <span class="ruby-value str">&quot;v4_mask&quot;</span>=<span class="ruby-operator">&gt;</span><span class="ruby-value str">&quot;&quot;</span>, <span class="ruby-value str">&quot;v4_dhcp&quot;</span>=<span class="ruby-operator">&gt;</span><span class="ruby-keyword kw">false</span>,
265
+ <span class="ruby-value str">&quot;v6_global_addrs&quot;</span>=<span class="ruby-operator">&gt;</span>[], <span class="ruby-value str">&quot;v6_global_mask&quot;</span>=<span class="ruby-operator">&gt;</span><span class="ruby-value str">&quot;&quot;</span>}
266
+ <span class="ruby-identifier">modify</span> <span class="ruby-identifier">json</span>,<span class="ruby-node">&quot;interfaces/#{interface}&quot;</span>
267
+ <span class="ruby-keyword kw">end</span>
268
+ </pre>
269
+ </div>
270
+ </div>
271
+ </div>
272
+
273
+ <div id="method-M000291" class="method-detail">
274
+ <a name="M000291"></a>
275
+
276
+ <div class="method-heading">
277
+ <a href="#M000291" class="method-signature">
278
+ <span class="method-name">clear_routes</span><span class="method-args">()</span>
279
+ </a>
280
+ </div>
281
+
282
+ <div class="method-description">
283
+ <p>
284
+ clears network routes
285
+ </p>
286
+ <p><a class="source-toggle" href="#"
287
+ onclick="toggleCode('M000291-source');return false;">[Source]</a></p>
288
+ <div class="method-source-code" id="M000291-source">
289
+ <pre>
290
+ <span class="ruby-comment cmt"># File lib/mu/api/netconfig.rb, line 169</span>
291
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">clear_routes</span>
292
+ <span class="ruby-identifier">routes</span> = <span class="ruby-identifier">get</span> <span class="ruby-value str">&quot;routes&quot;</span>
293
+ <span class="ruby-identifier">routes</span>[<span class="ruby-value str">&quot;routes&quot;</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
294
+ <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">r</span>[<span class="ruby-value str">'readonly'</span>] <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span>
295
+ <span class="ruby-identifier">msg</span> <span class="ruby-node">&quot;Clear route: #{r['dst']}-#{r['gateway']}-#{r['interface_display_name'].downcase}&quot;</span>, <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">DEBUG</span>
296
+ <span class="ruby-identifier">delete</span> <span class="ruby-node">&quot;routes/#{r['dst']}-#{r['gateway']}-#{r['interface_display_name'].downcase}&quot;</span>
297
+ <span class="ruby-keyword kw">end</span>
298
+ <span class="ruby-keyword kw">end</span>
299
+ </pre>
300
+ </div>
301
+ </div>
302
+ </div>
303
+
304
+ <div id="method-M000289" class="method-detail">
305
+ <a name="M000289"></a>
306
+
307
+ <div class="method-heading">
308
+ <a href="#M000289" class="method-signature">
309
+ <span class="method-name">clear_vlans</span><span class="method-args">()</span>
310
+ </a>
311
+ </div>
312
+
313
+ <div class="method-description">
314
+ <p>
315
+ clears all network vlans
316
+ </p>
317
+ <p><a class="source-toggle" href="#"
318
+ onclick="toggleCode('M000289-source');return false;">[Source]</a></p>
319
+ <div class="method-source-code" id="M000289-source">
320
+ <pre>
321
+ <span class="ruby-comment cmt"># File lib/mu/api/netconfig.rb, line 145</span>
322
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">clear_vlans</span>
323
+ <span class="ruby-identifier">i</span> = <span class="ruby-identifier">get</span> <span class="ruby-value str">&quot;interfaces&quot;</span>
324
+ <span class="ruby-identifier">i</span>[<span class="ruby-value str">&quot;interfaces&quot;</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
325
+ <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">i</span>[<span class="ruby-value str">'vlan'</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;&quot;</span>
326
+ <span class="ruby-identifier">msg</span> <span class="ruby-node">&quot;Clear vlan: #{i['name']}&quot;</span>, <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">DEBUG</span>
327
+ <span class="ruby-identifier">delete</span> <span class="ruby-node">&quot;interfaces/#{i['name']}&quot;</span>
328
+ <span class="ruby-keyword kw">end</span>
329
+ <span class="ruby-keyword kw">end</span>
330
+ </pre>
331
+ </div>
332
+ </div>
333
+ </div>
334
+
335
+ <div id="method-M000282" class="method-detail">
336
+ <a name="M000282"></a>
337
+
338
+ <div class="method-heading">
339
+ <a href="#M000282" class="method-signature">
340
+ <span class="method-name">create</span><span class="method-args">(json, e)</span>
341
+ </a>
342
+ </div>
343
+
344
+ <div class="method-description">
345
+ <p>
346
+ POST method to add a network element
347
+ </p>
348
+ <pre>
349
+ * json = the json string containing the element values
350
+ * e = the element to create (interfaces|hosts|routes)
351
+ </pre>
352
+ <p><a class="source-toggle" href="#"
353
+ onclick="toggleCode('M000282-source');return false;">[Source]</a></p>
354
+ <div class="method-source-code" id="M000282-source">
355
+ <pre>
356
+ <span class="ruby-comment cmt"># File lib/mu/api/netconfig.rb, line 48</span>
357
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create</span>(<span class="ruby-identifier">json</span>, <span class="ruby-identifier">e</span>)
358
+ <span class="ruby-identifier">jstring</span> = <span class="ruby-identifier">json</span>
359
+ <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">json</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">String</span>
360
+ <span class="ruby-identifier">jstring</span> = <span class="ruby-constant">JSON</span>.<span class="ruby-identifier">generate</span> <span class="ruby-identifier">json</span>
361
+ <span class="ruby-keyword kw">end</span>
362
+ <span class="ruby-identifier">response</span> = <span class="ruby-ivar">@http</span>.<span class="ruby-identifier">post_json</span>(<span class="ruby-identifier">e</span>, <span class="ruby-identifier">jstring</span>)
363
+ <span class="ruby-identifier">msg</span> <span class="ruby-identifier">response</span>, <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">DEBUG</span>
364
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">response</span>
365
+ <span class="ruby-keyword kw">end</span>
366
+ </pre>
367
+ </div>
368
+ </div>
369
+ </div>
370
+
371
+ <div id="method-M000283" class="method-detail">
372
+ <a name="M000283"></a>
373
+
374
+ <div class="method-heading">
375
+ <a href="#M000283" class="method-signature">
376
+ <span class="method-name">delete</span><span class="method-args">(e)</span>
377
+ </a>
378
+ </div>
379
+
380
+ <div class="method-description">
381
+ <p>
382
+ deletes the specified element
383
+ </p>
384
+ <pre>
385
+ * e = the element to delete
386
+ </pre>
387
+ <p><a class="source-toggle" href="#"
388
+ onclick="toggleCode('M000283-source');return false;">[Source]</a></p>
389
+ <div class="method-source-code" id="M000283-source">
390
+ <pre>
391
+ <span class="ruby-comment cmt"># File lib/mu/api/netconfig.rb, line 60</span>
392
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete</span>(<span class="ruby-identifier">e</span>)
393
+ <span class="ruby-identifier">response</span> = <span class="ruby-ivar">@http</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">e</span>)
394
+ <span class="ruby-identifier">msg</span> <span class="ruby-identifier">response</span>, <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">DEBUG</span>
395
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">response</span>
396
+ <span class="ruby-keyword kw">end</span>
397
+ </pre>
398
+ </div>
399
+ </div>
400
+ </div>
401
+
402
+ <div id="method-M000280" class="method-detail">
403
+ <a name="M000280"></a>
404
+
405
+ <div class="method-heading">
406
+ <a href="#M000280" class="method-signature">
407
+ <span class="method-name">get</span><span class="method-args">(e)</span>
408
+ </a>
409
+ </div>
410
+
411
+ <div class="method-description">
412
+ <p>
413
+ <a href="Netconfig.html#M000280">get</a> - with no params, returns the
414
+ entire netconfig json object
415
+ </p>
416
+ <pre>
417
+ * e = the element to retrieve (interfaces|hosts|routes, interfaces/a1 ...)
418
+ </pre>
419
+ <p><a class="source-toggle" href="#"
420
+ onclick="toggleCode('M000280-source');return false;">[Source]</a></p>
421
+ <div class="method-source-code" id="M000280-source">
422
+ <pre>
423
+ <span class="ruby-comment cmt"># File lib/mu/api/netconfig.rb, line 20</span>
424
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get</span>(<span class="ruby-identifier">e</span>)
425
+ <span class="ruby-identifier">response</span> = <span class="ruby-ivar">@http</span>.<span class="ruby-identifier">get_json</span>(<span class="ruby-identifier">e</span>)
426
+ <span class="ruby-identifier">msg</span> <span class="ruby-identifier">response</span>, <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">DEBUG</span>
427
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">response</span>
428
+ <span class="ruby-keyword kw">end</span>
429
+ </pre>
430
+ </div>
431
+ </div>
432
+ </div>
433
+
434
+ <div id="method-M000281" class="method-detail">
435
+ <a name="M000281"></a>
436
+
437
+ <div class="method-heading">
438
+ <a href="#M000281" class="method-signature">
439
+ <span class="method-name">modify</span><span class="method-args">(json, e)</span>
440
+ </a>
441
+ </div>
442
+
443
+ <div class="method-description">
444
+ <p>
445
+ PUT to <a href="Netconfig.html#M000281">modify</a> netconfig element(s) to
446
+ json values
447
+ </p>
448
+ <pre>
449
+ * json = the json string containing the modified values
450
+ * e = the element to modify (interfaces|hosts|routes)
451
+ </pre>
452
+ <p><a class="source-toggle" href="#"
453
+ onclick="toggleCode('M000281-source');return false;">[Source]</a></p>
454
+ <div class="method-source-code" id="M000281-source">
455
+ <pre>
456
+ <span class="ruby-comment cmt"># File lib/mu/api/netconfig.rb, line 29</span>
457
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">modify</span>(<span class="ruby-identifier">json</span>, <span class="ruby-identifier">e</span>)
458
+ <span class="ruby-identifier">response</span> = <span class="ruby-identifier">do_modify</span>(<span class="ruby-identifier">json</span>, <span class="ruby-identifier">e</span>)
459
+ <span class="ruby-identifier">msg</span> <span class="ruby-identifier">response</span>, <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">DEBUG</span>
460
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">response</span>
461
+ ??
462
+ <span class="ruby-keyword kw">end</span>
463
+ </pre>
464
+ </div>
465
+ </div>
466
+ </div>
467
+
468
+ <div id="method-M000287" class="method-detail">
469
+ <a name="M000287"></a>
470
+
471
+ <div class="method-heading">
472
+ <a href="#M000287" class="method-signature">
473
+ <span class="method-name">resolve_hosts</span><span class="method-args">(name=nil)</span>
474
+ </a>
475
+ </div>
476
+
477
+ <div class="method-description">
478
+ <p>
479
+ use Dns to update host ip addresses. A <a
480
+ href="Netconfig.html#M000279">new</a> Host is added if not present when the
481
+ name is provided as argument
482
+ </p>
483
+ <pre>
484
+ * name = the name of the host to resolve
485
+ </pre>
486
+ <p><a class="source-toggle" href="#"
487
+ onclick="toggleCode('M000287-source');return false;">[Source]</a></p>
488
+ <div class="method-source-code" id="M000287-source">
489
+ <pre>
490
+ <span class="ruby-comment cmt"># File lib/mu/api/netconfig.rb, line 112</span>
491
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">resolve_hosts</span>(<span class="ruby-identifier">name</span>=<span class="ruby-keyword kw">nil</span>)
492
+ <span class="ruby-identifier">hosts</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
493
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">nil?</span>
494
+ <span class="ruby-identifier">hst</span> = <span class="ruby-identifier">get</span> <span class="ruby-value str">&quot;hosts&quot;</span>
495
+ <span class="ruby-identifier">hst</span>[<span class="ruby-value str">&quot;hosts&quot;</span>].<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">h</span><span class="ruby-operator">|</span> <span class="ruby-identifier">hosts</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">h</span>[<span class="ruby-value str">&quot;name&quot;</span>]}
496
+ <span class="ruby-keyword kw">else</span>
497
+ <span class="ruby-identifier">hosts</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">name</span>
498
+ <span class="ruby-keyword kw">end</span>
499
+ <span class="ruby-identifier">hosts</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>
500
+ <span class="ruby-identifier">msg</span> <span class="ruby-node">&quot;resolve host: #{h}&quot;</span>, <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">DEBUG</span>
501
+ <span class="ruby-identifier">v4_addr</span> = <span class="ruby-constant">Socket</span><span class="ruby-operator">::</span><span class="ruby-identifier">gethostbyname</span>(<span class="ruby-identifier">h</span>)[<span class="ruby-value">3</span>].<span class="ruby-identifier">unpack</span>(<span class="ruby-value str">&quot;CCCC&quot;</span>).<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;.&quot;</span>) <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
502
+ <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">v4_addr</span>.<span class="ruby-identifier">nil?</span>
503
+ <span class="ruby-identifier">json</span> = <span class="ruby-identifier">get</span> <span class="ruby-node">&quot;hosts/#{h}&quot;</span>
504
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">json</span>[<span class="ruby-value str">&quot;name&quot;</span>].<span class="ruby-identifier">nil?</span>
505
+ <span class="ruby-identifier">json</span> = {<span class="ruby-value str">&quot;name&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">h</span>, <span class="ruby-value str">&quot;v4_addr&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">v4_addr</span>}
506
+ <span class="ruby-identifier">create</span> <span class="ruby-identifier">json</span>, <span class="ruby-value str">&quot;hosts&quot;</span>
507
+ <span class="ruby-keyword kw">else</span>
508
+ <span class="ruby-identifier">json</span>[<span class="ruby-value str">&quot;v4_addr&quot;</span>] = <span class="ruby-identifier">v4_addr</span>
509
+ <span class="ruby-identifier">modify</span> <span class="ruby-identifier">json</span>, <span class="ruby-node">&quot;hosts/#{h}&quot;</span>
510
+ <span class="ruby-keyword kw">end</span>
511
+ <span class="ruby-keyword kw">end</span>
512
+ <span class="ruby-keyword kw">end</span>
513
+ </pre>
514
+ </div>
515
+ </div>
516
+ </div>
517
+
518
+ <div id="method-M000284" class="method-detail">
519
+ <a name="M000284"></a>
520
+
521
+ <div class="method-heading">
522
+ <a href="#M000284" class="method-signature">
523
+ <span class="method-name">restore</span><span class="method-args">(filepath=nil,clear_existing=false)</span>
524
+ </a>
525
+ </div>
526
+
527
+ <div class="method-description">
528
+ <p>
529
+ updates a network configuration from file
530
+ </p>
531
+ <pre>
532
+ * filepath = the path to the json file
533
+ * clear_existing - boolean determining whether or not existing elements should be cleared
534
+ </pre>
535
+ <p><a class="source-toggle" href="#"
536
+ onclick="toggleCode('M000284-source');return false;">[Source]</a></p>
537
+ <div class="method-source-code" id="M000284-source">
538
+ <pre>
539
+ <span class="ruby-comment cmt"># File lib/mu/api/netconfig.rb, line 69</span>
540
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">restore</span>(<span class="ruby-identifier">filepath</span>=<span class="ruby-keyword kw">nil</span>,<span class="ruby-identifier">clear_existing</span>=<span class="ruby-keyword kw">false</span>)
541
+ <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">filepath</span>.<span class="ruby-identifier">nil?</span>
542
+ <span class="ruby-ivar">@config</span> = <span class="ruby-constant">JSON</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">filepath</span>))
543
+ <span class="ruby-keyword kw">end</span>
544
+ <span class="ruby-ivar">@config</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>
545
+ <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">keys</span>[<span class="ruby-value">0</span>]
546
+ <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;hosts&quot;</span>
547
+ <span class="ruby-identifier">msg</span> <span class="ruby-value str">&quot;RESTORE HOSTS&quot;</span>, <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">DEBUG</span>
548
+ <span class="ruby-identifier">clear_existing</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">clear_hosts</span>
549
+ <span class="ruby-identifier">restore_hosts</span> <span class="ruby-identifier">c</span>[<span class="ruby-value str">&quot;hosts&quot;</span>]
550
+ <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;routes&quot;</span>
551
+ <span class="ruby-identifier">msg</span> <span class="ruby-value str">&quot;RESTORE ROUTES&quot;</span>, <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">DEBUG</span>
552
+ <span class="ruby-identifier">clear_existing</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">clear_routes</span>
553
+ <span class="ruby-identifier">restore_routes</span> <span class="ruby-identifier">c</span>[<span class="ruby-value str">&quot;routes&quot;</span>]
554
+ <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;interfaces&quot;</span>
555
+ <span class="ruby-identifier">clear_existing</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">clear_vlans</span>
556
+ <span class="ruby-identifier">msg</span> <span class="ruby-value str">&quot;RESTORE INTERFACES&quot;</span>, <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">DEBUG</span>
557
+ <span class="ruby-identifier">restore_interfaces</span> <span class="ruby-identifier">c</span>[<span class="ruby-value str">&quot;interfaces&quot;</span>]
558
+ <span class="ruby-keyword kw">end</span>
559
+ <span class="ruby-keyword kw">end</span>
560
+ <span class="ruby-keyword kw">end</span>
561
+ </pre>
562
+ </div>
563
+ </div>
564
+ </div>
565
+
566
+ <div id="method-M000286" class="method-detail">
567
+ <a name="M000286"></a>
568
+
569
+ <div class="method-heading">
570
+ <a href="#M000286" class="method-signature">
571
+ <span class="method-name">restore_hosts</span><span class="method-args">(hosts)</span>
572
+ </a>
573
+ </div>
574
+
575
+ <div class="method-description">
576
+ <p>
577
+ restores the network hosts to the initial system states
578
+ </p>
579
+ <p><a class="source-toggle" href="#"
580
+ onclick="toggleCode('M000286-source');return false;">[Source]</a></p>
581
+ <div class="method-source-code" id="M000286-source">
582
+ <pre>
583
+ <span class="ruby-comment cmt"># File lib/mu/api/netconfig.rb, line 101</span>
584
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">restore_hosts</span>(<span class="ruby-identifier">hosts</span>)
585
+ <span class="ruby-identifier">hosts</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>
586
+ <span class="ruby-identifier">msg</span> <span class="ruby-node">&quot;create host: #{h['name']}&quot;</span>, <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">DEBUG</span>
587
+ <span class="ruby-identifier">delete</span> <span class="ruby-node">&quot;hosts/#{h['name']}&quot;</span> <span class="ruby-comment cmt"># harmlessly fails when host does not exist</span>
588
+ <span class="ruby-identifier">create</span>(<span class="ruby-identifier">h</span>,<span class="ruby-value str">&quot;hosts&quot;</span>)
589
+ <span class="ruby-keyword kw">end</span>
590
+ <span class="ruby-keyword kw">end</span>
591
+ </pre>
592
+ </div>
593
+ </div>
594
+ </div>
595
+
596
+ <div id="method-M000290" class="method-detail">
597
+ <a name="M000290"></a>
598
+
599
+ <div class="method-heading">
600
+ <a href="#M000290" class="method-signature">
601
+ <span class="method-name">restore_interfaces</span><span class="method-args">(interfaces)</span>
602
+ </a>
603
+ </div>
604
+
605
+ <div class="method-description">
606
+ <p>
607
+ restores network interfaces to system initial settings
608
+ </p>
609
+ <pre>
610
+ * interfaces - the names of the interfaces to restore
611
+ </pre>
612
+ <p><a class="source-toggle" href="#"
613
+ onclick="toggleCode('M000290-source');return false;">[Source]</a></p>
614
+ <div class="method-source-code" id="M000290-source">
615
+ <pre>
616
+ <span class="ruby-comment cmt"># File lib/mu/api/netconfig.rb, line 156</span>
617
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">restore_interfaces</span>(<span class="ruby-identifier">interfaces</span>)
618
+ <span class="ruby-identifier">interfaces</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
619
+ <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">i</span>[<span class="ruby-value str">'name'</span>].<span class="ruby-identifier">include?</span> <span class="ruby-value str">&quot;eth&quot;</span> <span class="ruby-comment cmt"># don't do eth0 or eth1</span>
620
+ <span class="ruby-identifier">msg</span> <span class="ruby-node">&quot;configure interface: #{i['name']}&quot;</span>, <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">DEBUG</span>
621
+ <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">i</span>[<span class="ruby-value str">'vlan'</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;&quot;</span>
622
+ <span class="ruby-identifier">interface</span>,<span class="ruby-identifier">vlan</span> = <span class="ruby-identifier">i</span>[<span class="ruby-value str">'name'</span>].<span class="ruby-identifier">split</span>(<span class="ruby-value str">&quot;.&quot;</span>)
623
+ <span class="ruby-identifier">create</span> [{<span class="ruby-value str">&quot;name&quot;</span>=<span class="ruby-operator">&gt;</span><span class="ruby-identifier">interface</span>,<span class="ruby-value str">&quot;vlan&quot;</span>=<span class="ruby-operator">&gt;</span><span class="ruby-identifier">vlan</span>},<span class="ruby-value str">&quot;interfaces&quot;</span>]
624
+ <span class="ruby-keyword kw">end</span>
625
+ <span class="ruby-identifier">modify</span> [<span class="ruby-identifier">i</span>,<span class="ruby-node">&quot;interfaces/#{i['name']}&quot;</span>]
626
+ <span class="ruby-keyword kw">end</span>
627
+ <span class="ruby-keyword kw">end</span>
628
+ </pre>
629
+ </div>
630
+ </div>
631
+ </div>
632
+
633
+ <div id="method-M000292" class="method-detail">
634
+ <a name="M000292"></a>
635
+
636
+ <div class="method-heading">
637
+ <a href="#M000292" class="method-signature">
638
+ <span class="method-name">restore_routes</span><span class="method-args">(routes)</span>
639
+ </a>
640
+ </div>
641
+
642
+ <div class="method-description">
643
+ <p>
644
+ restores network routes to system initial settings
645
+ </p>
646
+ <p><a class="source-toggle" href="#"
647
+ onclick="toggleCode('M000292-source');return false;">[Source]</a></p>
648
+ <div class="method-source-code" id="M000292-source">
649
+ <pre>
650
+ <span class="ruby-comment cmt"># File lib/mu/api/netconfig.rb, line 179</span>
651
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">restore_routes</span>(<span class="ruby-identifier">routes</span>)
652
+ <span class="ruby-identifier">routes</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
653
+ <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">r</span>[<span class="ruby-value str">'readonly'</span>] <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span>
654
+ <span class="ruby-identifier">msg</span> <span class="ruby-node">&quot;configure route: #{r['dst']}-#{r['gateway']}-#{r['interface_display_name'].downcase}&quot;</span>, <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">DEBUG</span>
655
+ <span class="ruby-identifier">create</span> <span class="ruby-identifier">r</span>,<span class="ruby-value str">&quot;routes&quot;</span>
656
+ <span class="ruby-keyword kw">end</span>
657
+ <span class="ruby-keyword kw">end</span>
658
+ </pre>
659
+ </div>
660
+ </div>
661
+ </div>
662
+
663
+ <div id="method-M000293" class="method-detail">
664
+ <a name="M000293"></a>
665
+
666
+ <div class="method-heading">
667
+ <a href="#M000293" class="method-signature">
668
+ <span class="method-name">save</span><span class="method-args">(e=&quot;all&quot;, filepath=&quot;config.json&quot;)</span>
669
+ </a>
670
+ </div>
671
+
672
+ <div class="method-description">
673
+ <p>
674
+ writes the json config to filepath
675
+ </p>
676
+ <pre>
677
+ * e = the element to save, or 'all'
678
+ * filepath - the fully qualified name of the file to save to
679
+ </pre>
680
+ <p><a class="source-toggle" href="#"
681
+ onclick="toggleCode('M000293-source');return false;">[Source]</a></p>
682
+ <div class="method-source-code" id="M000293-source">
683
+ <pre>
684
+ <span class="ruby-comment cmt"># File lib/mu/api/netconfig.rb, line 190</span>
685
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">save</span>(<span class="ruby-identifier">e</span>=<span class="ruby-value str">&quot;all&quot;</span>, <span class="ruby-identifier">filepath</span>=<span class="ruby-value str">&quot;config.json&quot;</span>)
686
+ <span class="ruby-identifier">json</span> = <span class="ruby-identifier">get</span> <span class="ruby-identifier">e</span>
687
+ <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">filepath</span>,<span class="ruby-value str">'w'</span>){<span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">write</span>(<span class="ruby-constant">JSON</span>.<span class="ruby-identifier">pretty_generate</span>(<span class="ruby-identifier">json</span>))}
688
+ <span class="ruby-keyword kw">end</span>
689
+ </pre>
690
+ </div>
691
+ </div>
692
+ </div>
693
+
694
+ <h3 class="section-bar">Private Instance methods</h3>
695
+
696
+ <div id="method-M000294" class="method-detail">
697
+ <a name="M000294"></a>
698
+
699
+ <div class="method-heading">
700
+ <a href="#M000294" class="method-signature">
701
+ <span class="method-name">do_modify</span><span class="method-args">(json, e)</span>
702
+ </a>
703
+ </div>
704
+
705
+ <div class="method-description">
706
+ <p>
707
+ restclient put was not recgonized as json PUT to <a
708
+ href="Netconfig.html#M000281">modify</a> netconfig element(s) to json
709
+ values
710
+ </p>
711
+ <p><a class="source-toggle" href="#"
712
+ onclick="toggleCode('M000294-source');return false;">[Source]</a></p>
713
+ <div class="method-source-code" id="M000294-source">
714
+ <pre>
715
+ <span class="ruby-comment cmt"># File lib/mu/api/netconfig.rb, line 199</span>
716
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">do_modify</span>(<span class="ruby-identifier">json</span>, <span class="ruby-identifier">e</span>)
717
+ <span class="ruby-identifier">jstring</span> = <span class="ruby-identifier">json</span>
718
+ <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">json</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">String</span>
719
+ <span class="ruby-identifier">jstring</span> = <span class="ruby-constant">JSON</span>.<span class="ruby-identifier">generate</span> <span class="ruby-identifier">json</span>
720
+ <span class="ruby-keyword kw">end</span>
721
+ <span class="ruby-identifier">msg</span> <span class="ruby-identifier">jstring</span>, <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">DEBUG</span>
722
+ <span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-node">&quot;https://#{@host}&quot;</span>)
723
+ <span class="ruby-identifier">escaped</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">escape</span>(<span class="ruby-node">&quot;#{@docroot}#{e}&quot;</span>)
724
+ <span class="ruby-identifier">msg</span> <span class="ruby-node">&quot;Put: #{uri}#{escaped}&quot;</span>, <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">DEBUG</span>
725
+ <span class="ruby-identifier">http</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">host</span>, <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">port</span>)
726
+ <span class="ruby-identifier">http</span>.<span class="ruby-identifier">use_ssl</span> = <span class="ruby-keyword kw">true</span>
727
+ <span class="ruby-identifier">http</span>.<span class="ruby-identifier">verify_mode</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSL</span><span class="ruby-operator">::</span><span class="ruby-constant">VERIFY_NONE</span>
728
+ <span class="ruby-identifier">http</span>.<span class="ruby-identifier">start</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">http</span><span class="ruby-operator">|</span>
729
+ <span class="ruby-identifier">req</span> = <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span><span class="ruby-operator">::</span><span class="ruby-constant">Put</span>.<span class="ruby-identifier">new</span>(<span class="ruby-node">&quot;#{escaped}&quot;</span>,<span class="ruby-identifier">initheader</span> = {<span class="ruby-value str">&quot;User-Agent&quot;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@username</span>, <span class="ruby-value str">'Content-Type'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'application/json; charset=utf-8'</span>})
730
+ <span class="ruby-identifier">req</span>.<span class="ruby-identifier">body</span> = <span class="ruby-identifier">jstring</span>
731
+ <span class="ruby-identifier">response</span> = <span class="ruby-identifier">http_request</span>(<span class="ruby-identifier">http</span>, <span class="ruby-identifier">req</span>)
732
+ <span class="ruby-keyword kw">end</span>
733
+ <span class="ruby-identifier">msg</span> <span class="ruby-identifier">response</span>, <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">DEBUG</span>
734
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">response</span>
735
+ <span class="ruby-keyword kw">end</span>
736
+ </pre>
737
+ </div>
738
+ </div>
739
+ </div>
740
+
741
+ <div id="method-M000295" class="method-detail">
742
+ <a name="M000295"></a>
743
+
744
+ <div class="method-heading">
745
+ <a href="#M000295" class="method-signature">
746
+ <span class="method-name">http_request</span><span class="method-args">(http, req)</span>
747
+ </a>
748
+ </div>
749
+
750
+ <div class="method-description">
751
+ <p><a class="source-toggle" href="#"
752
+ onclick="toggleCode('M000295-source');return false;">[Source]</a></p>
753
+ <div class="method-source-code" id="M000295-source">
754
+ <pre>
755
+ <span class="ruby-comment cmt"># File lib/mu/api/netconfig.rb, line 220</span>
756
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">http_request</span>(<span class="ruby-identifier">http</span>, <span class="ruby-identifier">req</span>)
757
+ <span class="ruby-identifier">req</span>.<span class="ruby-identifier">basic_auth</span>(<span class="ruby-ivar">@username</span>, <span class="ruby-ivar">@password</span>)
758
+ <span class="ruby-identifier">response</span> = <span class="ruby-identifier">http</span>.<span class="ruby-identifier">request</span>(<span class="ruby-identifier">req</span>)
759
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">response</span>.<span class="ruby-identifier">code</span> <span class="ruby-operator">!=</span> <span class="ruby-value str">&quot;200&quot;</span>
760
+ <span class="ruby-keyword kw">return</span> <span class="ruby-node">&quot;Error status code #{response.code}\n#{response.body}&quot;</span>
761
+ <span class="ruby-keyword kw">end</span>
762
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">response</span>.<span class="ruby-identifier">body</span>
763
+ <span class="ruby-keyword kw">end</span>
764
+ </pre>
765
+ </div>
766
+ </div>
767
+ </div>
768
+
769
+
770
+ </div>
771
+
772
+
773
+ </div>
774
+
775
+
776
+ <div id="validator-badges">
777
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
778
+ </div>
779
+
780
+ </body>
781
+ </html>