- Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathexec_cmd.py
More file actions
Latest commit
53 lines (48 loc) · 1.67 KB
/
Copy pathexec_cmd.py
File metadata and controls
53 lines (48 loc) · 1.67 KB
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
"""
This module executes user requested commands to devices.
"""
importinitialize
fromlib.objects.basenodeimportBaseNode
fromprocessdbimportprocess_nodes
fromsearchimportsearch_node
fromsearchimportnode_element
fromnode_createimportnode_create
frommultithreadimportmultithread_engine
defexec_cmd(args):
argument_command=args.command
argument_node=args.node
redirect= []
authentication=True
"""
:param argument_command: Referenced to global variable commands which keeps track of all commands per node.
:type commands: list
:param argument_node: Argument accepted as regular expression.
:type augument_node: str
:param redirect: A list of which method superloop will access. This variable is sent to the multithread_engine. Each element is a redirect per node.
:type alt_key_file: list
"""
redirect.append('exec_cmd')
try:
ifargument_command=='reload'orargument_command=='reboot':
print("superloopError: command not supported")
returnFalse
else:
node_object=process_nodes()
match_node=search_node(argument_node,node_object)
"""
:param node_object: All node(s) in the database with all attributes.
:type node_object: list
:param match_node: Nodes that matches the arguements passed in by user.
:type match_node: list
"""
iflen(match_node) ==0:
print('+ No matching node(s) found in database.')
print()
else:
node_element(match_node,node_object)
node_create(match_node,node_object)
multithread_engine(initialize.ntw_device,redirect,argument_command,authentication)
exceptExceptionaserror:
print("ExceptionError: an exception occured")
print(error)
returnNone