blob: 1ccb96ad4133694b346e10d9639138fdf16b2be3 (
plain)
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
|
# Copyright (c) 2016 Hochikong
def messenger(obj, config):
"""This method used for sending configuration to VyOS
:param obj: A connection object
:param config: A configuration string
:return: A message or an error
"""
try:
obj.sendline(config)
obj.prompt()
if len(obj.before) > obj.before.index('\r\n') + 2:
return obj.before
else:
return "Result : Configured successfully"
except Exception as e:
return e
def committer(obj, config):
"""This method used for sending commit task to VyOS
:param obj: A connection object
:param config: A configuration string
:return: A message or an error
"""
try:
obj.sendline(config)
obj.prompt()
if len(obj.before) > obj.before.index('\r\n') + 2:
return obj.before
else:
return "Result : Commit successfully"
except Exception as e:
return e
|