-
Notifications
You must be signed in to change notification settings - Fork 10
/
seash_dictionary.py
2109 lines (1683 loc) · 77 KB
/
seash_dictionary.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
Author: Alan Loh
Module: A data structure of all the available commands of seash held in a
dictionary of dictionaries format. Also holds the methods for
parsing user command input and executing functions corresponding
to the command.
User input is parsed according to whether or not it follows the structure
of a command's dictionary and its children. When parsing a command word,
it simply checks to see if the user's input string list contains the command word
at the appropriate index respective to the level of command dictionary currently
being iterated. If it is an user argument, however, it will
simply assign the user's inputted string as the key of the respective
argument's dictionary.
Command input is split by white spaces, so except for the case of arguments
located at the end of the command string series, the parser will not taken
into account file names or arguments that are multiple words long. Also,
because of the way the command callback functions pull out user arguments,
arguments of similar type need different 'name' field in its command dictionary
to help distinguish one from the other.
"""
# repyportability destroys the built-in type variable, so we need to
# restore the python built-in type function in order for python
# libraries to work.
# The unit tests often import seash_dictionary directly instead of going
# through seash, so let's re-insert here so that we cover as much ground
# as possible..
originaltype = type
#import repyportability # XXX Why is this needed?
import abc
import warnings
abc.type = originaltype
warnings.type = originaltype
# for access to list of targets
import seash_global_variables
import seash_exceptions
import command_callbacks
# Used for module preprocessing of user input
import seash_modules
# Prints the help text of the last command node that has one
# Also lists all sub-commands that follow the command node.
def print_help(input_dict, environment_dict):
# Iterate through the user command dictionary
dict_mark = input_dict
command_string = ""
cmdgroup = ''
while dict_mark.keys():
# Pulls out the current command key word
command_key = dict_mark.keys()[0]
if dict_mark[command_key]['name'] == 'display_group':
cmdgroup = command_key
else:
command_string += command_key + ' '
# If the command's help text isn't an empty string, sets it as the help_text
# that will be printed out
if dict_mark[command_key]['help_text'] is not '':
current_help_text = dict_mark[command_key]['help_text']
# Iterates into the next dictionary of children commands
dict_mark = dict_mark[command_key]['children']
# Remove the 'help' token.
command_string = command_string.split('help ', 1)[1]
command_summaries = get_command_summaries(input_dict)
# summary_strings[module] = formatted string for command summary text for all
# commands under that module
summary_strings = {}
if command_summaries:
# cmdgroup can either be a command or a display group.
# However, if we get to this point, then cmdgroup can never be a command
# because the command dispatcher will correctly identify it as such.
# Therefore, if this is not a display group, we should flag it as an error.
if cmdgroup and not cmdgroup in command_summaries:
raise seash_exceptions.UserError("'"+cmdgroup+"' is not an enabled command nor a display group.")
for module in command_summaries[cmdgroup]:
summary_strings[module] = get_string_from_command_summarylist(command_summaries[cmdgroup][module], command_string)
# What should be displayed:
# -- Help text --
# (help_text that is defined at the command)
# A target can be either a host:port:vesselname, %ID, or a group name.
# -- Subcommand list --
# (Lists the summaries of all subcommands that fall under the display group)
# add -- Adds a target (a vessel name or group) to a group.
# get -- Acquires vessels from the clearinghouse.
# release -- Release vessels from your control
# show -- Displays shell state (see 'help show')
# -- Additional subcommand modifiers --
# (Lists all additional display groups, if the user did not specify a display group)
# For more commands, try:
# help extended
print
print current_help_text.strip()
print
summary_modules = summary_strings.keys()
summary_modules.sort()
for module in summary_modules:
if not module is None:
print "Commands from the", module, "module:"
print summary_strings[module]
# Display additional cmdgroups if the user did not enter one
if not cmdgroup:
# Are there additional keywords?
additional_cmdgroups = command_summaries.keys()
# Ignore the default '' keyword.
if '' in additional_cmdgroups:
additional_cmdgroups.remove('')
if None in additional_cmdgroups:
additional_cmdgroups.remove(None)
if additional_cmdgroups:
# List them alphabetically
additional_cmdgroups.sort()
print "For more commands, try:"
command_string = 'help ' + command_string
for alt_cmdgroup in additional_cmdgroups:
print " " + command_string.rstrip(), alt_cmdgroup
print
"""
Command dictionary entry format:
'(command key)':{'name':'', 'callback':, 'priority':, 'summary':'', 'example':'', 'help_text':'', 'children':[
'(command key)' - The expected command word the user is suppose to input to
call the command's function. If a certain type of argument is expected, a general
word in all caps should be enclosed within square brackets that signify the type
of argument needed. For example, '[TARGET]' if a target ID is expected, or
'[FILENAME]' if the name of a file is needed. Frequently used type includes
'[TARGET]' for targets, '[KEYNAME]' for loaded keynames, '[FILENAME]' for files,
and '[ARGUMENT]' for everything else, so unless another category of arguments is
needed, only use those four strings for command keys of arguments in order for
the parser to work correctly.
For general commands like 'browse', however, the key would simply be the same
command word, 'browse'.
In general, the command key should only be a single word from the whole command
string being implemented, and with the exception of arguments that occur at the
end of the command string, no user-inputted arguments should ever contain spaces.
'name': - The name of the command word. For general commands, it should be
the same as the command key. For arguments, however, the name should be
distinguishable from other potential arguments of the same command key to avoid
conflicts when pulling the user's argument from the input dictionary during
command execution.
'callback': - Reference to the command callback function associated with the
command string up to this point. Only command dictionaries that mark a complete
command string should contain a reference to a callback method. Otherwise, it
should be set to none. Default location of command callback functions is
command_callbacks.py.
'priority' - Gives the command callback function of the dictionary
containing the key 'priority' the priority of being executed first before
executing the main function of the command string. It should be implemented and
assigned True if needed. Otherwise, it should not be added into any other command
dictionary.
An example of how it should work is in the case of 'as [KEYNAME] browse':
A keyname needs to be set before executing 'browse', so the command dictionary of
'[KEYNAME]' has 'priority' in being executed first to set the user's keyname
before executing 'browse's command function.
'summary' - A short summary text that should be shown next to the command.
This should be no longer than a sentence if possible. All commands should have a
summary text.
'cmdgroup'- The keyword that should be passed to 'help' to show the summary
text for this command. Commonly used commands that should be shown by default
should have the empty string, or omit this key.
For example, some of the lesser used root commands (join, loadstate, etc.) should
only be shown when the user types 'help extended'. For these commands, the
'cmdgroup' should be set to 'extended'.
'help_text' - The text that will be outputted whenever a user accesses the
help function for that command. Not every command dictionary needs a help text
associated with it, so it defaults as a blank string, and if none of the command
dictionaries in the help call holds a help text, it will default at the last
command dictionary that holds one, namely the dictionary associated with 'help'.
'children' - The list of command dictionaries that follows the current one.
This will determine the validity of an command input when parsing. Each user
inputted string is verified that it follows one of the potential chains of
command strings through the series of command dictionaries. Limit only one
argument dictionary per children list to avoid confusion when parsing user
argument input.
For example, in the command 'show resources', the children of the command
dictionary for 'show' will contain the command dictionary 'resources' along with
any other potential command words that can follow 'show'.
"""
seashcommanddict = {
'on':{
'name':'on', 'callback':None, 'example': 'target [command]',
'summary':'Run a command on a target (or changes the default)', 'help_text':"""
on group
on group [command]
Sets the default group for future commands. Most other commands will only
operate on the vessels specified in the default group. The default group is
listed in the seash command prompt 'identity@group !>'. The 'on' command can
also be prepended to another command to set the group for only this command.
Example:
exampleuser@browsegood !> on WAN
exampleuser@WAN !>
exampleuser@browsegood !> on WAN show ip
1.2.3.4
5.6.7.8
exampleuser@browsegood !>
""", 'children':{
'[TARGET]':{'name':'ontarget', 'callback':command_callbacks.on_target, 'priority':True, 'help_text':'', 'children':{
}}
}},
'as':{
'name':'as', 'callback':None, 'example':'keyname [command]',
'summary':'Run a command using an identity (or changes the default)', 'help_text':"""
Sets the default identity for an operation. The credentials (i.e. public
and private key) for this user are used for the following commands.
The default identity is listed in the seash command prompt 'identity@group !>'.
The 'as' command can also be prepended to another command to set the identity
for just this command.
Example:
exampleuser@%all !> as tom
tom@%all !>
exampleuser@browsegood !> as tom browse
(browse output here)
exampleuser@browsegood !>
""", 'children':{
'[KEYNAME]':{
'name':'askeyname', 'callback':command_callbacks.as_keyname, 'priority':True,
'example': '(command)', 'summary': 'Sets the default identity globally or for an operation.',
'help_text':'', 'children':{
}},
}},
'help':{
'name':'help', 'callback':print_help, 'priority':True,
'cmdgroup':None, 'help_text':"""
A target can be either a host:port:vesselname, %ID, or a group name.
See https://seattle.poly.edu/wiki/RepyTutorial for more info!""",
'children':{}},
'show':{
'name':'show', 'callback':command_callbacks.show,
'summary': "Displays the shell state (see 'help show')", 'help_text':"""
Displays information regarding the current state of Seattle, depending on
the additional keywords that are passed in.
(*) No need to update prior, the command contacts the nodes anew
""", 'children':{
'info':{
'name':'info', 'callback':command_callbacks.show_info,
'summary':'Display general information about the vessels','help_text':"""
show info
This command prints general information about vessels in the default group
including the version, nodeID, etc.
Example:
exampleuser@%1 !> show info
192.x.x.178:1224:v3 has no information (try 'update' or 'list')
exampleuser@%1 !> update
exampleuser@%1 !> show info
192.x.x.178:1224:v3 {'nodekey': {'e': 65537L, 'n': 929411623458072017781884599109L}, 'version': '0.1r', 'nodename': '192.x.x.175'}
""", 'children':{}},
'users':{
'pattern':'users', 'name':'users', 'callback':command_callbacks.show_users,
'summary':'Display the user keys for the vessels','help_text':"""
show users
This command lists the set of user keys for vessels in the default group.
If the key has been loaded into seash as an identity, this name will be used.
Example:
exampleuser@browsegood !> show users
192.x.x.178:1224:v3 has no information (try 'update' or 'list')
192.x.x.2:1224:v12 has no information (try 'update' or 'list')
192.x.x.2:1224:v3 has no information (try 'update' or 'list')
exampleuser@browsegood !> update
exampleuser@browsegood !> show users
192.x.x.178:1224:v3 (no keys)
192.x.x.2:1224:v12 65537 136475...
192.x.x.2:1224:v3 exampleuser
""", 'children':{}},
'ownerinfo':{
'name':'ownerinfo', 'callback':command_callbacks.show_ownerinfo,
'summary':'Display owner information for the vessels','help_text':"""
show ownerinfo
This lists the ownerinfo strings for vessels in the default group. See
'set ownerinfo' for more details
""", 'children':{}},
'advertise':{
'name':'advertise', 'callback':command_callbacks.show_advertise,
'summary':"Shows whether the node manager will advertise the vessel's keys in the advertise services.", 'help_text':"""
show advertise
This indicates whether the node manager will advertise the vessel's keys in
the advertise services. See 'set advertise' for more details.
""", 'children':{}},
'ip':{
'name':'ip', 'callback':command_callbacks.show_ip, 'example': '[to file]',
'summary':'Display the ip addresses of the nodes', 'help_text':"""
show ip
show ip [to file]
This lists the ip addresses of the vessels in the default group. These IP
addresses may be optionally written to a file.
Note that machines behind a NAT, mobile devices, or other systems with
atypical network connectivity may list a host name instead.
Example:
exampleuser@ !> show targets
browsegood ['192.x.x.2:1224:v12', '192.x.x.2:1224:v3', '193.x.x.42:1224:v18', '219.x.x.62:1224:v4']
%4 ['219.x.x.62:1224:v4']
%all ['192.x.x.2:1224:v12', '192.x.x.2:1224:v3', '193.x.x.42:1224:v18', '219.x.x.62:1224:v4']
%1 ['192.x.x.2:1224:v12']
%3 ['193.x.x.42:1224:v18']
%2 ['192.x.x.2:1224:v3']
exampleuser@ !> on browsegood
exampleuser@browsegood !> show ip
192.x.x.2
193.x.x.42
219.x.x.62
""", 'children':{
'to':{
'name':'to', 'callback':None, 'example': '[filename]',
'summary': 'Outputs the list of ip addresses of the vessels in the default group to [filename]',
'help_text':'', 'children':{
'[FILENAME]':{'name':'filename', 'callback':command_callbacks.show_ip_to_file, 'help_text':'', 'children':{}},
}},
'>':{
'name':'>', 'callback':None, 'example': '[filename]',
'summary': 'Outputs the list of ip addresses of the vessels in the default group to [filename]',
'help_text':'', 'children':{
'[FILENAME]':{'name':'filename', 'callback':command_callbacks.show_ip_to_file, 'help_text':'', 'children':{}},
}},
}},
'hostname':{
'name':'hostname', 'callback':command_callbacks.show_hostname,
'summary':'Display the hostnames of the nodes','help_text':"""
show hostname
This lists the DNS host names for the vessels in the default group. If this
information is not available, this will be listed.
Example:
exampleuser@browsegood !> show ip
192.x.x.2
193.x.x.42
219.x.x.62
exampleuser@browsegood !> show hostname
192.x.x.2 is known as Guest-Laptop.home
193.x.x.42 is known as pl2.maskep.aerop.fr
219.x.x.62 has unknown host information
""", 'children':{}},
'owner':{'name':'owner', 'callback':command_callbacks.show_owner, 'help_text':"""
show owner
Displays the owner key (or identity if known) for the vessels in the default
group.
Example:
exampleuser@ !> show targets
browsegood ['192.x.x.2:1224:v12', '192.x.x.2:1224:v3', '193.x.x.42:1224:v18', '219.x.x.62:1224:v4']
%4 ['219.x.x.62:1224:v4']
%all ['192.x.x.2:1224:v12', '192.x.x.2:1224:v3', '193.x.x.42:1224:v18', '219.x.x.62:1224:v4']
%1 ['192.x.x.2:1224:v12']
%3 ['193.x.x.42:1224:v18']
%2 ['192.x.x.2:1224:v3']
exampleuser@ !> on browsegood
exampleuser@browsegood !> show owner
192.x.x2:1224:v12 exampleuser pubkey
192.x.x.2:1224:v3 65537 127603...
193.x.x.42:1224:v18 65537 163967...
219.x.x.62:1224:v4 65537 952875...
""", 'children':{}},
'targets':{
'name':'targets', 'callback':command_callbacks.show_targets,
'summary':'Display a list of targets','help_text':"""
show targets
Lists the known targets (groups and individual nodes) that commands may be
run on.
Example:
exampleuser@ !> show targets
%all (empty)
exampleuser@ !> browse
['192.x.x.2:1224', '219.x.x.62:1224', '193.x.x.42:1224']
Added targets: %3(193.x.x.42:1224:v18), %4(219.x.x.62:1224:v4), %1(192.x.x.2:1224:v12), %2(192.x.x.2:1224:v3)
Added group 'browsegood' with 4 targets
yaluen@ !> show targets
browsegood ['192.x.x.2:1224:v12', '192.x.x.2:1224:v3', '193.x.x.42:1224:v18', '219.x.x.62:1224:v4']
%4 ['219.x.x.62:1224:v4']
%all ['192.x.x.2:1224:v12', '192.x.x.2:1224:v3', '193.x.x.42:1224:v18', '219.x.x.62:1224:v4']
%1 ['192.x.x.2:1224:v12']
%3 ['193.x.x.42:1224:v18']
%2 ['192.x.x.2:1224:v3']
""", 'children':{}},
'groups':{
'name':'groups', 'callback':command_callbacks.show_groups,
'summery':'Display a list of groups','help_text':"""
show groups
Lists available groups.
Example:
exampleuser@ !> show groups
%all []
exampleuser@ !> browse
['192.x.x.2:1224', '219.x.x.62:1224', '193.x.x.42:1224']
Added targets: %3(193.x.x.42:1224:v18), %4(219.x.x.62:1224:v4), %1(192.x.x.2:1224:v12), %2(192.x.x.2:1224:v3)
Added group 'browsegood' with 4 targets
exampleuser@ !> show groups
browsegood ['192.x.x.2:1224:v12', '192.x.x.2:1224:v3', '193.x.x.42:1224:v18', '219.x.x.62:1224:v4']
%all ['192.x.x.2:1224:v12', '192.x.x.2:1224:v3', '193.x.x.42:1224:v18', '219.x.x.62:1224:v4']
""", 'children':{}},
'identities':{
'name':'identities', 'callback':command_callbacks.show_identities,
'summary':'Display the known identities', 'help_text':"""
show identities
Lists the identities loaded into the shell and whether the public or private
keys are loaded. This does not display the keys themselves (see 'show keys').
Example:
!> show identities
!> loadkeys exampleuser
!> loadkeys guest0
!> loadkeys guest1
!> show identities
guest2 PRIV
exampleuser PUB PRIV
guest0 PUB PRIV
guest1 PUB PRIV
""", 'children':{}},
'keys':{
'name':'keys', 'callback':command_callbacks.show_keys,
'summary':'Display the known keys', 'help_text':"""
show keys
List the actual keys loaded by the shell. To see identity information, see
'show identities'.
Example:
!> show keys
!> loadkeys yaluen
!> loadpub guest0
!> loadpriv guest1
!> show keys
exampleuser {'e': 65537L, 'n': 967699203053798948061567293973111925102424779L} {'q': 130841985099129780748709L, 'p': 739593793918579524787167931524344434698161314501292256851220768397231L, 'd': 9466433905223884723074560052831388470409993L}
guest0 {'e': 65537L, 'n': 9148459067481753275566379538357634516166379961L} None
guest1 None {'q': 121028014346935113507847L, 'p': 107361553689073802754887L, 'd': 127298628609806695961451784003754746302524139001L}
""", 'children':{}},
'log':{
'name':'log', 'callback':command_callbacks.show_log,
'example': '[to file]', 'summary':'Display the log from the vessel (*)', 'help_text':"""
Lists the log of operations from the vessel. This log is populated by print
statements and exceptions from the program running in the vessel.
""", 'children':{
'to':{
'name':'to', 'callback':None, 'example': '[filename]',
'summary': 'Writes the log to a file.', 'help_text':'', 'children':{
'[FILENAME]':{'name':'filename', 'callback':command_callbacks.show_log_to_file, 'help_text':'', 'children':{}},
}},
}},
'files':{
'name':'files', 'callback':command_callbacks.show_files,
'summary':'Display a list of files in the vessel (*)', 'help_text':"""
show files
Lists the names of the files loaded into vessels in the default groups.
This is similar to dir or ls.
Example:
exampleuser@browsegood !> show files
Files on '192.x.x.2:1224:v3': ''
Files on '193.x.x.42:1224:v18': ''
Files on '219.x.x.62:1224:v4': ''
exampleuser@browsegood !> upload example.1.1.r2py
exampleuser@browsegood !> show files
Files on '192.x.x.2:1224:v3': 'example.1.1.r2py'
Files on '193.x.x.42:1224:v18': 'example.1.1.r2py'
Files on '219.x.x.62:1224:v4': 'example.1.1.r2py'
""", 'children':{}},
'resources':{
'name':'resources', 'callback':command_callbacks.show_resources,
'summary':'Display the resources / restrictions for the vessel (*)', 'help_text':"""
show resources
Lists the resources allotted to vessels in the default group.
""", 'children':{}},
'offcut':{
'name':'offcut', 'callback':command_callbacks.show_offcut,
'summary':'Display the offcut resource for the node (*)', 'help_text':"""
show offcut
This lists the amount of resources that will be lost by splitting a vessel or
gained by joining two vessels. This is shown on a per-node basis amongst
all vessels in the default group
""", 'children':{}},
'timeout':{
'name':'timeout', 'callback':command_callbacks.show_timeout,
'summary':'Display the timeout for nodes', 'help_text':"""
show timeout
This shows the amount of time the shell will wait for a command to timeout.
Note that commands like 'run' and 'upload' will use both this value and the
uploadrate setting
Example:
!> show timeout
10
""", 'children':{}},
'uploadrate':{
'name':'uploadrate', 'callback':command_callbacks.show_uploadrate,
'summary':'Display the upload rate which seash uses to estimate the required time for a file upload', 'help_text':"""
show uploadrate
This lists the minimum rate at which the shell should allow uploads to occur.
Uploads to vessels that go slower than this will be aborted. Note that this
is used in combination with the timeout setting.
Example:
!> show uploadrate
102400
""", 'children':{}},
}},
'run':{
'name':'run', 'callback':None, 'example':'file [args ...]',
'summary':'Upload a file and start executing it', 'help_text':"""
Uploads a program to a vessel and starts it running. (This command is
actually just a short-cut for the 'upload' and 'start' commands). The
arguments listed will be passed to the command when it is started.
This command will make an educated guess as to what platform your
program is written for (i.e. repyV1 or repyV2). You can override this
by using 'runv1' or 'runv2', respectively.
Example:
exampleuser@browsegood !> show log
Log from '192.x.x.2:1224:v3':
Log from '193.x.x.42:1224:v18':
Log from '219.x.x.62:1224:v4':
Log from '192.x.x.2:1224:v12':
exampleuser@browsegood !> run example.1.1.r2py
exampleuser@browsegood !> show log
Log from '192.x.x.2:1224:v3':
Hello World
Log from '193.x.x.42:1224:v18':
Hello World
Log from '219.x.x.62:1224:v4':
Hello World
Log from '192.x.x.2:1224:v12':
Hello World
""", 'children':{
'[FILENAME]':{
'name':'filename', 'callback':command_callbacks.run_localfn, 'example':'[arg1, arg2, ...]',
'summary': 'Uploads the file to the vessels and starts running them, passing arguments if specified.',
'help_text':'','children':{
'[ARGUMENT]':{'name':'args', 'callback':command_callbacks.run_localfn_arg, 'help_text':'', 'children':{}},
}},
}},
'runv1':{
'name':'run', 'callback':None, 'example':'file [args ...]',
'summary':'Upload a file and start executing it as repyV1', 'help_text':"""
Uploads a program to a vessel and starts it running. (This command is
actually just a short-cut for the 'upload' and 'startv1' commands).
The arguments listed will be passed to the command when it is started.
Example:
exampleuser@browsegood !> show log
Log from '192.x.x.2:1224:v3':
Log from '193.x.x.42:1224:v18':
Log from '219.x.x.62:1224:v4':
Log from '192.x.x.2:1224:v12':
exampleuser@browsegood !> run example.1.1.r2py
exampleuser@browsegood !> show log
Log from '192.x.x.2:1224:v3':
Hello World
Log from '193.x.x.42:1224:v18':
Hello World
Log from '219.x.x.62:1224:v4':
Hello World
Log from '192.x.x.2:1224:v12':
Hello World
""", 'children':{
'[FILENAME]':{
'name':'filename', 'callback':command_callbacks.run_localfn, 'example':'[arg1, arg2, ...]',
'summary': 'Uploads the file to the vessels and starts running them, passing arguments if specified.',
'help_text':'','children':{
'[ARGUMENT]':{'name':'args', 'callback':command_callbacks.run_localfn_arg, 'help_text':'', 'children':{}},
}},
}},
'runv2':{
'name':'run', 'callback':None, 'example':'file [args ...]',
'summary':'Upload a file and start executing it as repyV2', 'help_text':"""
Uploads a program to a vessel and starts it running. (This command is
actually just a short-cut for the 'upload' and 'startv2' commands).
The arguments listed will be passed to the command when it is started.
Example:
exampleuser@browsegood !> show log
Log from '192.x.x.2:1224:v3':
Log from '193.x.x.42:1224:v18':
Log from '219.x.x.62:1224:v4':
Log from '192.x.x.2:1224:v12':
exampleuser@browsegood !> run example.1.1.r2py
exampleuser@browsegood !> show log
Log from '192.x.x.2:1224:v3':
Hello World
Log from '193.x.x.42:1224:v18':
Hello World
Log from '219.x.x.62:1224:v4':
Hello World
Log from '192.x.x.2:1224:v12':
Hello World
""", 'children':{
'[FILENAME]':{
'name':'filename', 'callback':command_callbacks.run_localfn, 'example':'[arg1, arg2, ...]',
'summary': 'Uploads the file to the vessels and starts running them, passing arguments if specified.',
'help_text':'','children':{
'[ARGUMENT]':{'name':'args', 'callback':command_callbacks.run_localfn_arg, 'help_text':'', 'children':{}},
}},
}},
'runv1':{
'name':'run', 'callback':None, 'example':'file [args ...]',
'summary':'Upload a file and start executing it as repyV1', 'help_text':"""
Uploads a program to a vessel and starts it running. (This command is
actually just a short-cut for the 'upload' and 'startv1' commands).
The arguments listed will be passed to the command when it is started.
Example:
exampleuser@browsegood !> show log
Log from '192.x.x.2:1224:v3':
Log from '193.x.x.42:1224:v18':
Log from '219.x.x.62:1224:v4':
Log from '192.x.x.2:1224:v12':
exampleuser@browsegood !> run example.1.1.r2py
exampleuser@browsegood !> show log
Log from '192.x.x.2:1224:v3':
Hello World
Log from '193.x.x.42:1224:v18':
Hello World
Log from '219.x.x.62:1224:v4':
Hello World
Log from '192.x.x.2:1224:v12':
Hello World
""", 'children':{
'[FILENAME]':{
'name':'filename', 'callback':command_callbacks.run_localfn, 'example':'[arg1, arg2, ...]',
'summary': 'Uploads the file to the vessels and starts running them, passing arguments if specified.',
'help_text':'','children':{
'[ARGUMENT]':{'name':'args', 'callback':command_callbacks.run_localfn_arg, 'help_text':'', 'children':{}},
}},
}},
'runv2':{
'name':'run', 'callback':None, 'example':'file [args ...]',
'summary':'Upload a file and start executing it as repyV2', 'help_text':"""
Uploads a program to a vessel and starts it running. (This command is
actually just a short-cut for the 'upload' and 'startv2' commands).
The arguments listed will be passed to the command when it is started.
Example:
exampleuser@browsegood !> show log
Log from '192.x.x.2:1224:v3':
Log from '193.x.x.42:1224:v18':
Log from '219.x.x.62:1224:v4':
Log from '192.x.x.2:1224:v12':
exampleuser@browsegood !> run example.1.1.r2py
exampleuser@browsegood !> show log
Log from '192.x.x.2:1224:v3':
Hello World
Log from '193.x.x.42:1224:v18':
Hello World
Log from '219.x.x.62:1224:v4':
Hello World
Log from '192.x.x.2:1224:v12':
Hello World
""", 'children':{
'[FILENAME]':{
'name':'filename', 'callback':command_callbacks.run_localfn, 'example':'[arg1, arg2, ...]',
'summary': 'Uploads the file to the vessels and starts running them, passing arguments if specified.',
'help_text':'','children':{
'[ARGUMENT]':{'name':'args', 'callback':command_callbacks.run_localfn_arg, 'help_text':'', 'children':{}},
}},
}},
'add':{
'name':'add', 'callback':None, 'example': '[target] [to group]',
'summary':'Adds a target (a vessel name or group) to a group', 'help_text':"""
add target [to group]
add to group
Adds a target (a vessel name or group) a group. If the group does not exist,
it is created. This can be used to control which vessels are manipulated by
different commands. The short form 'add target' adds the target to the
default group. The short form 'add to group' adds the default group to
the target.
If the target is already in the group, an error message will be printed.
Example:
exampleuser@%1 !> on new_group
Invalid command input: Target does not exist
exampleuser@%1 !> add to new_group
exampleuser@%1 !> add %2 to new_group
exampleuser@%1 !> on new_group
exampleuser@new_group !> list
ID Own Name Status Owner Information
%1 * 192.x.x.178:1224:v3 Fresh
%2 * 192.x.x.2:1224:v12 Fresh
""", 'children':{
'[TARGET]':{
'name':'target', 'callback':command_callbacks.add_target,
'example': 'to group', 'summary': 'Adds a target to a group.', 'help_text':'', 'children':{
'to':{'name':'to', 'callback':None, 'help_text':'', 'children':{
'[ARGUMENT]':{'name':'args', 'callback':command_callbacks.add_target_to_group, 'help_text':'', 'children':{}},
}},
}},
'to':{
'name':'to', 'callback':None, 'example': 'group',
'summary':'Adds the default target to a group.', 'help_text':'', 'children':{
'[ARGUMENT]':{'name':'args', 'callback':command_callbacks.add_to_group, 'help_text':'', 'children':{}},
}},
}},
'move':{
'name':'move', 'callback':None, 'example': 'target to group',
'summary': 'Add target to group, remove target from default', 'cmdgroup': 'extended', 'help_text':"""
This is essentially a shortcut for removing the target from the default group
and adding it to group. See 'add' and 'remove' for more information.
""", 'children':{
'[TARGET]':{
'name':'target', 'callback':None, 'example': 'to group',
'summary': 'Moves the target to the group', 'help_text':'', 'children':{
'to':{'name':'to', 'callback':None, 'help_text':'', 'children':{
'[GROUP]':{'name':'group', 'callback':command_callbacks.move_target_to_group, 'help_text':'', 'children':{}},
}},
}},
}},
'remove':{
'name':'remove', 'callback':None, 'example':'[target] [from group]',
'summary':'Removes a target from a group', 'help_text':"""
remove [target] from group
This command removes a target (vesselname or group) from a group. This means
that future group operations will not include the listed vesselname or group.
The short form 'remove target' removes the target from the default group.
The short form 'remove from group' removes the default group from group.
If the target is not in the group, an error message will be printed.
Example:
exampleuser@new_group !> list
ID Own Name Status Owner Information
%1 * 192.x.x.178:1224:v3 Fresh
%2 * 192.x.x.2:1224:v12 Fresh
%3 192.x.x.2:1224:v3 Fresh
exampleuser@new_group !> on %1
exampleuser@%1 !> remove from new_group
exampleuser@%1 !> remove %2 from new_group
exampleuser@%1 !> on new_group
exampleuser@new_group !> list
ID Own Name Status Owner Information
%3 192.x.x.2:1224:v3 Fresh
""", 'children':{
'[TARGET]':{
'name':'target', 'callback':command_callbacks.remove_target, 'example':'from group',
'summary': 'Removes the target from the default group', 'help_text':'', 'children':{
'from':{'name':'from', 'callback':None, 'help_text':'', 'children':{
'[GROUP]':{
'name':'group', 'callback':command_callbacks.remove_target_from_group,
'summary': 'Removes the target from the group', 'help_text':'',
'children':{}},
}},
}},
'from':{
'name':'from', 'callback':None, 'example': 'group',
'summary': 'Removes the default group from group', 'help_text':'', 'children':{
'[GROUP]':{'name':'group', 'callback':command_callbacks.remove_from_group, 'help_text':'', 'children':{}},
}},
}},
'set':{
'name':'set', 'callback':command_callbacks.set,
'summary': "Changes the shell or vessels (see 'help set')", 'help_text':"""
Changes the shell or vessels.
""", 'children':{
'users':{
'name':'users', 'callback':None, 'example':'[identity ...]',
'summary':"Change a vessel's users", 'help_text':"""
set users [identity1, identity2, ...]
Sets the user keys for vessels in the default group. The current identity
must own the vessels.
Example:
exampleuser@%1 !> show owner
192.x.x.2:1224:v12 exampleuser pubkey
exampleuser@%1 !> show users
192.x.x.2:1224:v12 65537 136475...
exampleuser@%1 !> set users guest0 guest1 guest2
exampleuser@%1 !> update
exampleuser@%1 !> show users
192.x.x.2:1224:v12 guest0 guest1 guest2
exampleuser@%1 !> on %2
exampleuser@%2 !> show owner
192.x.x.2:1224:v3 65537 127603...
exampleuser@%2 !> set users guest0 guest1
Failure 'Node Manager error 'Insufficient Permissions'' on 192.x.x.2:1224:v3
""", 'children':{
'[ARGUMENT]':{'name':'args', 'callback':command_callbacks.set_users_arg, 'help_text':'', 'children':{}},
}},
'ownerinfo':{
'name':'ownerinfo', 'callback':None, 'example': '[ data ... ]',
'summary': 'Change owner information for the vessels', 'help_text':"""
set ownerinfo 'string'
This command sets the owner information for each vessel in the default group.
The default identity must own the vessels.
Example:
exampleuser@browsegood !> show owner
192.x.x.2:1224:v12 exampleuser pubkey
192.x.x.2:1224:v3 65537 127603...
exampleuser@browsegood !> show ownerinfo
192.x.x.2:1224:v12 ''
192.x.x.2:1224:v3 ''
exampleuser@browsegood !> set ownerinfo Example owner info
Failure 'Node Manager error 'Insufficient Permissions'' on 192.x.x.2:1224:v3
Added group 'ownerinfogood' with 1 targets and 'ownerinfofail' with 1 targets
exampleuser@browsegood !> update
exampleuser@browsegood !> show ownerinfo
192.x.x.2:1224:v12 'Example owner info'
192.x.x.2:1224:v3 ''
""", 'children':{
'[ARGUMENT]':{'name':'args', 'callback':command_callbacks.set_ownerinfo_arg, 'help_text':'', 'children':{}},
}},
'advertise':{
'name':'advertise', 'callback':None,
'summary':'Change advertisement information about the vessels','help_text':"""
set advertise [on/off]
This setting is changable only by the vessel owner and indicates whether or
not the node's IP / port should be advertised under the owner and user keys.
The default value is on. With this turned off, the 'browse' command will
be unable to discover the vessel.
exampleuser@%1 !> show owner
192.x.x.2:1224:v12 exampleuser pubkey
exampleuser@%1 !> show advertise
192.x.x.2:1224:v12 on
exampleuser@%1 !> set advertise off
exampleuser@%1 !> update
exampleuser@%1 !> show advertise
192.x.x.2:1224:v12 off
exampleuser@%1 !> on %2
exampleuser@%2 !> show owner
192.x.x.2:1224:v3 65537 127603...
exampleuser@%2 !> show advertise
192.x.x.2:1224:v3 on
exampleuser@%2 !> set advertise off
Failure 'Node Manager error 'Insufficient Permissions'' on 192.x.x.2:1224:v3
""", 'children':{
'[ARGUMENT]':{'name':'args', 'callback':command_callbacks.set_advertise_arg, 'help_text':'', 'children':{}},
}},
'owner':{
'name':'owner', 'callback':None, 'example': 'identity',
'summary': "Changes a vessel's owner.", 'help_text':"""
set owner identity
This changes the owner key for all vessels in the default group to the
identity specified. This command may only be issued by the vessels' current
owner.
Example:
exampleuser@%1 !> show identities
exampleuser PUB PRIV
guest0 PUB PRIV
guest1 PUB PRIV
exampleuser@%1 !> show owner
192.x.x.2:1224:v12 exampleuser pubkey
exampleuser@%1 !> set owner guest0
exampleuser@%1 !> update