enfcli 4.0.0 → 4.1.0.pre.alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/Dockerfile +2 -2
- data/.circleci/config.yml +5 -0
- data/Gemfile.lock +37 -25
- data/Makefile +7 -0
- data/README.md +52 -7
- data/enfcli.gemspec +28 -26
- data/format.sh +9 -0
- data/lib/enfapi.rb +86 -97
- data/lib/enfcli.rb +166 -94
- data/lib/enfcli/commands/captive.rb +149 -149
- data/lib/enfcli/commands/user.rb +23 -20
- data/lib/enfcli/commands/xcr.rb +95 -82
- data/lib/enfcli/commands/xdns.rb +53 -50
- data/lib/enfcli/commands/xfw.rb +37 -37
- data/lib/enfcli/commands/xiam.rb +87 -80
- data/lib/enfcli/version.rb +1 -1
- data/lib/enfthor.rb +38 -14
- metadata +62 -5
@@ -15,21 +15,22 @@
|
|
15
15
|
# See the License for the specific language governing permissions and
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
18
|
+
require "enfthor"
|
19
|
+
require "enfapi"
|
20
|
+
require "json"
|
21
|
+
require "erb"
|
22
22
|
|
23
23
|
module EnfCli
|
24
24
|
module Cmd
|
25
25
|
class Captive < EnfThor
|
26
|
-
desc
|
27
|
-
|
28
|
-
method_option :name, default: nil, type: :string, banner:
|
29
|
-
desc:
|
30
|
-
method_option :domain, default: nil, type: :string, banner:
|
31
|
-
aliases:
|
32
|
-
method_option :ssid, default: nil, type: :string, banner:
|
26
|
+
desc "list-wifi-configurations",
|
27
|
+
"List wifi configuration information for all or the matching records."
|
28
|
+
method_option :name, default: nil, type: :string, banner: "NAME",
|
29
|
+
desc: "where NAME will match the user-given name."
|
30
|
+
method_option :domain, default: nil, type: :string, banner: "DOMAIN",
|
31
|
+
aliases: "-d"
|
32
|
+
method_option :ssid, default: nil, type: :string, banner: "SSID"
|
33
|
+
|
33
34
|
def list_wifi_configurations
|
34
35
|
try_with_rescue_in_session do
|
35
36
|
## TODO: V1 is only listing all of the wifi configurations, it is not
|
@@ -40,15 +41,16 @@ module EnfCli
|
|
40
41
|
# display the data
|
41
42
|
display_wifi_configs wifi_configs
|
42
43
|
else
|
43
|
-
say
|
44
|
+
say "No WiFi configurations found."
|
44
45
|
end
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
48
|
-
desc
|
49
|
+
desc "create-wifi-configuration", "Create a new wifi configuration."
|
49
50
|
method_option :'wifi-config-file', type: :string, required: true,
|
50
|
-
banner:
|
51
|
-
desc:
|
51
|
+
banner: "<file>",
|
52
|
+
desc: "<file> is JSON file with parameters required for configuring the router card."
|
53
|
+
|
52
54
|
def create_wifi_configuration
|
53
55
|
try_with_rescue_in_session do
|
54
56
|
json_file_name = options[:'wifi-config-file']
|
@@ -65,20 +67,21 @@ module EnfCli
|
|
65
67
|
end
|
66
68
|
end
|
67
69
|
|
68
|
-
desc
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
method_option :'wifi-id', defaut: nil, type: :string, banner:
|
73
|
-
desc:
|
74
|
-
method_option :version, defaut: nil, type: :string, banner:
|
75
|
-
desc:
|
76
|
-
method_option :'profile-id', defaut: nil, type: :string, banner:
|
77
|
-
desc:
|
78
|
-
method_option :'device-id', defaut: nil, type: :string, banner:
|
79
|
-
desc:
|
80
|
-
method_option :'wifi-name', defaut: nil, type: :string, banner:
|
81
|
-
desc:
|
70
|
+
desc "get-wifi-configuration",
|
71
|
+
"Get details of the specified wifi configuration. Exactly one of: " \
|
72
|
+
"--wifi-id, --profile-id, --device-id, or --wifi-name must be " \
|
73
|
+
"specified."
|
74
|
+
method_option :'wifi-id', defaut: nil, type: :string, banner: "WIFI-ID",
|
75
|
+
desc: "WIFI-ID is the UUID of the wifi record"
|
76
|
+
method_option :version, defaut: nil, type: :string, banner: "VERSION",
|
77
|
+
desc: "Optionally used with --wifi-id"
|
78
|
+
method_option :'profile-id', defaut: nil, type: :string, banner: "PROFILE-ID",
|
79
|
+
desc: "PROFILE-ID is the UUID of the profile."
|
80
|
+
method_option :'device-id', defaut: nil, type: :string, banner: "DEVICE-ID",
|
81
|
+
desc: "DEVICE-ID is the UUID of the device."
|
82
|
+
method_option :'wifi-name', defaut: nil, type: :string, banner: "WIFI-NAME",
|
83
|
+
desc: "Result matches any wifi configuration that contains the substring WIFI-NAME"
|
84
|
+
|
82
85
|
def get_wifi_configuration
|
83
86
|
try_with_rescue_in_session do
|
84
87
|
## TODO - Currently, this only handles wifi-id, add the others to v2
|
@@ -95,31 +98,30 @@ module EnfCli
|
|
95
98
|
num_query_opts += 1 if device_id
|
96
99
|
num_query_opts += 1 if wifi_name
|
97
100
|
|
98
|
-
|
99
|
-
raise 'ERROR: Exactly one of: --wifi-id, --profile-id, --device-id, or --wifi-name must be specified.' if num_query_opts != 1
|
101
|
+
raise "ERROR: Exactly one of: --wifi-id, --profile-id, --device-id, or --wifi-name must be specified." if num_query_opts != 1
|
100
102
|
|
101
103
|
if wifi_id
|
102
104
|
wifi_config = EnfApi::Captive.instance.get_wifi_configuration wifi_id, version
|
103
105
|
|
104
106
|
# display the data
|
105
107
|
display_wifi_detail wifi_config
|
106
|
-
|
107
108
|
end
|
108
109
|
end
|
109
110
|
end
|
110
111
|
|
111
|
-
desc
|
112
|
-
|
112
|
+
desc "update-wifi-configuration",
|
113
|
+
"Update an existing wifi configuration."
|
113
114
|
method_option :'wifi-id', type: :string,
|
114
115
|
required: true,
|
115
|
-
banner:
|
116
|
-
desc:
|
116
|
+
banner: "WIFI-ID",
|
117
|
+
desc: "WIFI-ID is the UUID of the wifi profile"
|
117
118
|
method_option :'wifi-config-file', type: :string,
|
118
119
|
required: true,
|
119
|
-
banner:
|
120
|
-
desc:
|
121
|
-
|
122
|
-
|
120
|
+
banner: "<file>",
|
121
|
+
desc: "<file> is JSON file with " \
|
122
|
+
"parameters required for " \
|
123
|
+
"configuring the router card."
|
124
|
+
|
123
125
|
def update_wifi_configuration
|
124
126
|
try_with_rescue_in_session do
|
125
127
|
json_file_name = options[:'wifi-config-file']
|
@@ -133,29 +135,29 @@ module EnfCli
|
|
133
135
|
end
|
134
136
|
end
|
135
137
|
|
138
|
+
desc "create-device",
|
139
|
+
"Add a new device to the database. This is only available to Xaptum administrators"
|
140
|
+
method_option :'device-id', type: :string, required: true, banner: "SERIAL-NUM",
|
141
|
+
desc: "SERIAL-NUM is the serial number of the device."
|
142
|
+
method_option :'device-name', type: :string, default: nil, banner: "DEVICE-NAME",
|
143
|
+
desc: "User-defined name for the device."
|
144
|
+
method_option :'mac-addr1', type: :string, default: nil, banner: "MAC-ADDR1",
|
145
|
+
desc: "MAC address 1 (wifi address on a wifi-enabled device)"
|
146
|
+
method_option :'mac-addr2', type: :string, default: nil, banner: "MAC-ADDR2",
|
147
|
+
desc: "MAC address 2"
|
148
|
+
method_option :'mac-addr3', type: :string, default: nil, banner: "MAC-ADDR3",
|
149
|
+
desc: "MAC address 3"
|
150
|
+
method_option :'mac-addr4', type: :string, default: nil, banner: "MAC-ADDR4",
|
151
|
+
desc: "MAC address 4"
|
152
|
+
method_option :'profile-id', type: :string, default: nil, banner: "PROFILE_ID",
|
153
|
+
desc: "UUID of the profile that the device will use. The profile must already exist."
|
154
|
+
method_option :model, type: :string, default: nil, banner: "MODEL",
|
155
|
+
desc: "Model identifier of the device"
|
136
156
|
|
137
|
-
desc 'create-device',
|
138
|
-
'Add a new device to the database. This is only available to Xaptum administrators'
|
139
|
-
method_option :'device-id', type: :string, required: true, banner: 'SERIAL-NUM',
|
140
|
-
desc: 'SERIAL-NUM is the serial number of the device.'
|
141
|
-
method_option :'device-name', type: :string, default: nil, banner: 'DEVICE-NAME',
|
142
|
-
desc: 'User-defined name for the device.'
|
143
|
-
method_option :'mac-addr1', type: :string, default: nil, banner: 'MAC-ADDR1',
|
144
|
-
desc: 'MAC address 1 (wifi address on a wifi-enabled device)'
|
145
|
-
method_option :'mac-addr2', type: :string, default: nil, banner: 'MAC-ADDR2',
|
146
|
-
desc: 'MAC address 2'
|
147
|
-
method_option :'mac-addr3', type: :string, default: nil, banner: 'MAC-ADDR3',
|
148
|
-
desc: 'MAC address 3'
|
149
|
-
method_option :'mac-addr4', type: :string, default: nil, banner: 'MAC-ADDR4',
|
150
|
-
desc: 'MAC address 4'
|
151
|
-
method_option :'profile-id', type: :string, default: nil, banner: 'PROFILE_ID',
|
152
|
-
desc: 'UUID of the profile that the device will use. The profile must already exist.'
|
153
|
-
method_option :model, type: :string, default: nil, banner: 'MODEL',
|
154
|
-
desc: 'Model identifier of the device'
|
155
157
|
def create_device
|
156
158
|
try_with_rescue_in_session do
|
157
159
|
new_device_hash = {
|
158
|
-
serial_number: options[:'device-id']
|
160
|
+
serial_number: options[:'device-id'],
|
159
161
|
}
|
160
162
|
|
161
163
|
mac1 = options[:'mac-addr1']
|
@@ -192,10 +194,11 @@ module EnfCli
|
|
192
194
|
end
|
193
195
|
end
|
194
196
|
|
195
|
-
desc
|
196
|
-
|
197
|
-
method_option :network, default: nil, type: :string, banner:
|
198
|
-
desc:
|
197
|
+
desc "list-devices",
|
198
|
+
"List basic device information for all devices matching the option specified."
|
199
|
+
method_option :network, default: nil, type: :string, banner: "NETWORK",
|
200
|
+
desc: "NETWORK is the ipv6 subnet used by the device."
|
201
|
+
|
199
202
|
def list_devices
|
200
203
|
try_with_rescue_in_session do
|
201
204
|
network = options[:network]
|
@@ -205,11 +208,12 @@ module EnfCli
|
|
205
208
|
end
|
206
209
|
end
|
207
210
|
|
208
|
-
desc
|
209
|
-
|
211
|
+
desc "get-device",
|
212
|
+
"Get details of the specified device."
|
210
213
|
method_option :'device-id', required: true, type: :string,
|
211
|
-
banner:
|
212
|
-
desc:
|
214
|
+
banner: "DEVICE-ID",
|
215
|
+
desc: "DEVICE-ID is either the device serial number or its ipv6 address."
|
216
|
+
|
213
217
|
def get_device
|
214
218
|
try_with_rescue_in_session do
|
215
219
|
device_id = ERB::Util::url_encode(options[:'device-id'])
|
@@ -220,14 +224,15 @@ module EnfCli
|
|
220
224
|
end
|
221
225
|
end
|
222
226
|
|
223
|
-
desc
|
224
|
-
|
225
|
-
method_option :'device-id', type: :string, required: true, banner:
|
226
|
-
desc:
|
227
|
-
method_option :'device-name', type: :string, default: nil, banner:
|
228
|
-
|
229
|
-
method_option :'profile-id', type: :string, default: nil, banner:
|
230
|
-
|
227
|
+
desc "update-device",
|
228
|
+
"Update an existing device record with the values specified."
|
229
|
+
method_option :'device-id', type: :string, required: true, banner: "DEVICE-ID",
|
230
|
+
desc: "DEVICE-ID is either the device serial number or its ipv6 address."
|
231
|
+
method_option :'device-name', type: :string, default: nil, banner: "DEVICE-NAME",
|
232
|
+
desc: "User-defined name for the device."
|
233
|
+
method_option :'profile-id', type: :string, default: nil, banner: "PROFILE_ID",
|
234
|
+
desc: "UUID of the profile that the device will use. The profile must already exist."
|
235
|
+
|
231
236
|
def update_device
|
232
237
|
try_with_rescue_in_session do
|
233
238
|
id = ERB::Util::url_encode(options[:'device-id'])
|
@@ -248,11 +253,12 @@ module EnfCli
|
|
248
253
|
end
|
249
254
|
end
|
250
255
|
|
251
|
-
desc
|
252
|
-
|
256
|
+
desc "get-device-status",
|
257
|
+
"Get the latest status of the specified device."
|
253
258
|
method_option :'device-id', required: true, type: :string,
|
254
|
-
banner:
|
255
|
-
desc:
|
259
|
+
banner: "DEVICE-ID",
|
260
|
+
desc: "DEVICE-ID is either the device serial number or its ipv6 address."
|
261
|
+
|
256
262
|
def get_device_status
|
257
263
|
try_with_rescue_in_session do
|
258
264
|
device_id = ERB::Util::url_encode(options[:'device-id'])
|
@@ -262,22 +268,23 @@ module EnfCli
|
|
262
268
|
end
|
263
269
|
end
|
264
270
|
|
265
|
-
desc
|
266
|
-
|
271
|
+
desc "create-profile",
|
272
|
+
"Create a new profile."
|
267
273
|
method_option :'profile-name', type: :string, required: true,
|
268
|
-
banner:
|
269
|
-
desc:
|
274
|
+
banner: "PROFILE-NAME",
|
275
|
+
desc: "PROFILE-NAME is the user-given name."
|
270
276
|
method_option :'device-mode', type: :string, required: true,
|
271
|
-
banner:
|
272
|
-
desc:
|
273
|
-
method_option :'wifi-id', type: :string, default: nil, banner:
|
274
|
-
desc:
|
277
|
+
banner: "DEVICE-MODE",
|
278
|
+
desc: "secure-host or passthrough"
|
279
|
+
method_option :'wifi-id', type: :string, default: nil, banner: "WIFI-ID",
|
280
|
+
desc: "WIFI-ID is the UUID of the wifi record that the profile will use. wifi record must already exist"
|
281
|
+
|
275
282
|
def create_profile
|
276
283
|
try_with_rescue_in_session do
|
277
284
|
profile_name = options[:'profile-name']
|
278
285
|
new_profile_hash = {
|
279
286
|
name: profile_name,
|
280
|
-
config: { mode: options[:'device-mode'] }
|
287
|
+
config: { mode: options[:'device-mode'] },
|
281
288
|
}
|
282
289
|
|
283
290
|
wifi = options[:'wifi-id']
|
@@ -292,10 +299,11 @@ module EnfCli
|
|
292
299
|
end
|
293
300
|
end
|
294
301
|
|
295
|
-
desc
|
296
|
-
|
297
|
-
method_option :name, default: nil, type: :string, banner:
|
298
|
-
desc:
|
302
|
+
desc "list-profiles",
|
303
|
+
"List the existing profiles."
|
304
|
+
method_option :name, default: nil, type: :string, banner: "NAME",
|
305
|
+
desc: "where NAME will match all or part of the user-given profile name."
|
306
|
+
|
299
307
|
def list_profiles
|
300
308
|
try_with_rescue_in_session do
|
301
309
|
query_name = options[:name]
|
@@ -304,14 +312,14 @@ module EnfCli
|
|
304
312
|
end
|
305
313
|
end
|
306
314
|
|
307
|
-
desc
|
308
|
-
|
309
|
-
method_option :'profile-id', required: true, type: :string,
|
310
|
-
banner:
|
311
|
-
desc:
|
312
|
-
# TODO - server doesn't support version yet.
|
313
|
-
# method_option :version, default: nil, type: :integer, banner: 'VERSION',
|
314
|
-
# desc: 'Get a specific version.'
|
315
|
+
desc "get-profile",
|
316
|
+
"Get full detail listing of the profile."
|
317
|
+
method_option :'profile-id', required: true, type: :string,
|
318
|
+
banner: "PROFILE-ID",
|
319
|
+
desc: "PROFILE-ID is the UUID of the profile."
|
320
|
+
# TODO - server doesn't support version yet.
|
321
|
+
# method_option :version, default: nil, type: :integer, banner: 'VERSION',
|
322
|
+
# desc: 'Get a specific version.'
|
315
323
|
def get_profile
|
316
324
|
try_with_rescue_in_session do
|
317
325
|
profile = EnfApi::Captive.instance.get_profile options[:'profile-id']
|
@@ -319,20 +327,21 @@ module EnfCli
|
|
319
327
|
end
|
320
328
|
end
|
321
329
|
|
322
|
-
desc
|
323
|
-
|
324
|
-
|
325
|
-
method_option :'profile-id', required: true, type: :string,
|
326
|
-
banner:
|
327
|
-
desc:
|
330
|
+
desc "update-profile",
|
331
|
+
"Update a previously-created profile specified by PROFILE-ID. At " \
|
332
|
+
"least one property must be changed."
|
333
|
+
method_option :'profile-id', required: true, type: :string,
|
334
|
+
banner: "PROFILE-ID",
|
335
|
+
desc: "UUID of the device profile."
|
328
336
|
method_option :'profile-name', type: :string, default: nil,
|
329
|
-
banner:
|
330
|
-
desc:
|
337
|
+
banner: "PROFILE-NAME",
|
338
|
+
desc: "PROFILE-NAME is the user-given name."
|
331
339
|
method_option :'device-mode', type: :string, default: nil,
|
332
|
-
banner:
|
333
|
-
desc:
|
334
|
-
method_option :'wifi-id', type: :string, default: nil, banner:
|
335
|
-
desc:
|
340
|
+
banner: "DEVICE-MODE",
|
341
|
+
desc: "secure-host or passthrough"
|
342
|
+
method_option :'wifi-id', type: :string, default: nil, banner: "WIFI-ID",
|
343
|
+
desc: "WIFI-ID is the UUID of the wifi record that the profile will use. wifi record must already exist"
|
344
|
+
|
336
345
|
def update_profile
|
337
346
|
try_with_rescue_in_session do
|
338
347
|
id = options[:'profile-id']
|
@@ -353,11 +362,9 @@ module EnfCli
|
|
353
362
|
|
354
363
|
profile = EnfApi::Captive.instance.update_profile id, update_hash
|
355
364
|
display_profile profile
|
356
|
-
|
357
365
|
end
|
358
366
|
end
|
359
367
|
|
360
|
-
|
361
368
|
#########################################################################
|
362
369
|
#
|
363
370
|
# Helper functions
|
@@ -367,7 +374,7 @@ module EnfCli
|
|
367
374
|
# Displays the wifi configuration summary list.
|
368
375
|
# TODO - Does non-Xaptum-admin columns only - add option to do admin list
|
369
376
|
def display_wifi_configs(configs)
|
370
|
-
headings = [
|
377
|
+
headings = ["ID", "Wifi Name", "Config Vers."]
|
371
378
|
rows = configs.map do |hash|
|
372
379
|
[hash[:id], hash[:name], hash[:version]]
|
373
380
|
end
|
@@ -376,7 +383,7 @@ module EnfCli
|
|
376
383
|
end
|
377
384
|
|
378
385
|
# Display a single wifi configuration in detail
|
379
|
-
def display_wifi_detail(wifi_data, full_listing=true)
|
386
|
+
def display_wifi_detail(wifi_data, full_listing = true)
|
380
387
|
name = wifi_data[:name]
|
381
388
|
wifi_id = wifi_data[:id]
|
382
389
|
desc = wifi_data[:description]
|
@@ -392,9 +399,7 @@ module EnfCli
|
|
392
399
|
display_wifi_net(wifi_net, 1)
|
393
400
|
end
|
394
401
|
end
|
395
|
-
|
396
402
|
end
|
397
|
-
|
398
403
|
end
|
399
404
|
|
400
405
|
def display_wifi_net(wifi_net, tabs)
|
@@ -412,7 +417,7 @@ module EnfCli
|
|
412
417
|
display_ipv6_addr(wifi_net[:IPv6], tabs + 1)
|
413
418
|
end
|
414
419
|
|
415
|
-
def display_ipv4_addr
|
420
|
+
def display_ipv4_addr(ipv4, tabs)
|
416
421
|
indent = " " * tabs
|
417
422
|
if ipv4.instance_of? String
|
418
423
|
say indent + "IPv4 : #{ipv4}", nil, true
|
@@ -435,7 +440,7 @@ module EnfCli
|
|
435
440
|
end
|
436
441
|
end
|
437
442
|
|
438
|
-
def display_ipv6_addr
|
443
|
+
def display_ipv6_addr(ipv6, tabs)
|
439
444
|
indent = " " * tabs
|
440
445
|
if ipv6.instance_of? String
|
441
446
|
say indent + "IPv6 : #{ipv6}", nil, true
|
@@ -458,8 +463,6 @@ module EnfCli
|
|
458
463
|
end
|
459
464
|
end
|
460
465
|
|
461
|
-
|
462
|
-
|
463
466
|
#
|
464
467
|
# display the device info.
|
465
468
|
# device_data is a hash matching the json structure
|
@@ -469,8 +472,8 @@ module EnfCli
|
|
469
472
|
ctl_addr = device_data[:control_address]
|
470
473
|
dev_addr = device_data[:device_address] || "\n"
|
471
474
|
mac_addrs = device_data[:mac_address]
|
472
|
-
firmware = device_data[:firmware_version] ||
|
473
|
-
model = device_data[:model] ||
|
475
|
+
firmware = device_data[:firmware_version] || "< not available >"
|
476
|
+
model = device_data[:model] || "< not available >"
|
474
477
|
profile = device_data[:profile]
|
475
478
|
status = device_data[:status]
|
476
479
|
|
@@ -485,18 +488,18 @@ module EnfCli
|
|
485
488
|
mac4 = mac_addrs[:'4']
|
486
489
|
|
487
490
|
if !mac1
|
488
|
-
say
|
491
|
+
say "Mac Address : < not available >"
|
489
492
|
elsif !mac2 && !mac3 && !mac4
|
490
493
|
say "Mac Address : #{mac1}", nil, true
|
491
494
|
else
|
492
|
-
say
|
495
|
+
say "Mac Address :"
|
493
496
|
say " 1 : #{mac1}", nil, true
|
494
497
|
say " 2 : #{mac2}", nil, true if mac2
|
495
498
|
say " 3 : #{mac3}", nil, true if mac3
|
496
499
|
say " 4 : #{mac4}", nil, true if mac4
|
497
500
|
end
|
498
501
|
else
|
499
|
-
say
|
502
|
+
say "Mac Address : < not available >"
|
500
503
|
end
|
501
504
|
|
502
505
|
say "Firmware Version : #{firmware}", nil, true
|
@@ -508,19 +511,19 @@ module EnfCli
|
|
508
511
|
say "Profile : < not available >"
|
509
512
|
end
|
510
513
|
display_device_status_summary status
|
511
|
-
say
|
514
|
+
say " ", nil, true
|
512
515
|
end
|
513
516
|
|
514
|
-
#
|
517
|
+
#
|
515
518
|
# display the status summary
|
516
519
|
#
|
517
|
-
def display_device_status_summary
|
520
|
+
def display_device_status_summary(device_status)
|
518
521
|
if device_status
|
519
|
-
mode = device_status[:router_mode] || device_status[:mode] ||
|
522
|
+
mode = device_status[:router_mode] || device_status[:mode] || "< not available >"
|
520
523
|
|
521
524
|
wifi = device_status[:wifi]
|
522
525
|
|
523
|
-
say
|
526
|
+
say "Status :"
|
524
527
|
say " Router Mode : #{mode}", nil, true
|
525
528
|
|
526
529
|
if wifi
|
@@ -539,21 +542,21 @@ module EnfCli
|
|
539
542
|
# status is a hash matching the json structure
|
540
543
|
#
|
541
544
|
def display_device_status(device_status)
|
542
|
-
sn = device_status[:serial_number] ||
|
543
|
-
mode = device_status[:router_mode] || device_status[:mode] ||
|
545
|
+
sn = device_status[:serial_number] || "< not available >"
|
546
|
+
mode = device_status[:router_mode] || device_status[:mode] || "< not available >"
|
544
547
|
|
545
|
-
uptime = device_status[:uptime] ||
|
546
|
-
refresh = device_status[:refresh_time] ||
|
548
|
+
uptime = device_status[:uptime] || "< not available >"
|
549
|
+
refresh = device_status[:refresh_time] || "< not available >"
|
547
550
|
|
548
551
|
wifi = device_status[:wifi]
|
549
552
|
if wifi
|
550
|
-
connected = wifi[:connected] ||
|
553
|
+
connected = wifi[:connected] || "< not available >"
|
551
554
|
ssid = wifi[:SSID]
|
552
555
|
ipv4 = wifi[:IPv4_addresses]
|
553
556
|
ipv6 = wifi[:IPv6_addresses]
|
554
557
|
wifi_config = wifi[:config]
|
555
558
|
else
|
556
|
-
connected =
|
559
|
+
connected = "< not available >"
|
557
560
|
ssid = nil
|
558
561
|
ipv4 = nil
|
559
562
|
ipv6 = nil
|
@@ -583,15 +586,15 @@ module EnfCli
|
|
583
586
|
|
584
587
|
display_wifi_detail(wifi_config, false) if wifi_config
|
585
588
|
|
586
|
-
say
|
589
|
+
say " ", nil, true
|
587
590
|
end
|
588
591
|
|
589
592
|
#
|
590
593
|
# display the devices summary list
|
591
594
|
#
|
592
595
|
def display_device_list(devices)
|
593
|
-
headings = [
|
594
|
-
|
596
|
+
headings = ["Serial No", "Dev Name", "Dev Addr", "Router Mode",
|
597
|
+
"Connected", "SSID"]
|
595
598
|
rows = devices.map do |hash|
|
596
599
|
status = hash[:status]
|
597
600
|
if status
|
@@ -601,10 +604,10 @@ module EnfCli
|
|
601
604
|
mode = status[:router_mode] || status[:mode]
|
602
605
|
|
603
606
|
[hash[:serial_number], hash[:device_name], hash[:device_address],
|
604
|
-
|
607
|
+
mode, connected, ssid]
|
605
608
|
else
|
606
609
|
[hash[:serial_number], hash[:device_name], hash[:device_address],
|
607
|
-
|
610
|
+
nil, nil, nil]
|
608
611
|
end
|
609
612
|
end
|
610
613
|
# [hash[:serial_number], hash[:device_name], hash[:device_address],
|
@@ -618,7 +621,7 @@ module EnfCli
|
|
618
621
|
# Display profile detail
|
619
622
|
#
|
620
623
|
def display_profile(profile, summary = false)
|
621
|
-
indent = summary ?
|
624
|
+
indent = summary ? " " : ""
|
622
625
|
|
623
626
|
say indent + "Name : #{profile[:name]}", nil, true
|
624
627
|
say indent + "Profile ID : #{profile[:id]}", nil, true
|
@@ -632,7 +635,7 @@ module EnfCli
|
|
632
635
|
#
|
633
636
|
# Display summary of the WIFI configuration info
|
634
637
|
#
|
635
|
-
def display_wifi_summary
|
638
|
+
def display_wifi_summary(wifi)
|
636
639
|
if wifi
|
637
640
|
say "Wifi config :"
|
638
641
|
say " id : #{wifi[:id]}", nil, true
|
@@ -645,22 +648,19 @@ module EnfCli
|
|
645
648
|
else
|
646
649
|
say "Wifi config : < not configured >"
|
647
650
|
end
|
648
|
-
|
649
651
|
end
|
650
652
|
|
651
653
|
#
|
652
654
|
# display the profile summary list
|
653
655
|
#
|
654
656
|
def display_profile_list(profiles)
|
655
|
-
headings = [
|
657
|
+
headings = ["Profile Name", "Profile ID", "Version"]
|
656
658
|
rows = profiles.map do |hash|
|
657
659
|
[hash[:name], hash[:id], hash[:config][:version]]
|
658
660
|
end
|
659
661
|
|
660
662
|
render_table(headings, rows)
|
661
663
|
end
|
662
|
-
|
663
|
-
|
664
664
|
end
|
665
665
|
end
|
666
666
|
end
|