summaryrefslogtreecommitdiff
path: root/vymgmt/mgmt_common.py
diff options
context:
space:
mode:
Diffstat (limited to 'vymgmt/mgmt_common.py')
-rw-r--r--vymgmt/mgmt_common.py62
1 files changed, 0 insertions, 62 deletions
diff --git a/vymgmt/mgmt_common.py b/vymgmt/mgmt_common.py
deleted file mode 100644
index 1153c54..0000000
--- a/vymgmt/mgmt_common.py
+++ /dev/null
@@ -1,62 +0,0 @@
-# Copyright (c) 2016 Hochikong
-
-CODEC = 'utf8'
-
-
-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()
- result = decodetool(obj.before, CODEC)
- if len(result) > result.index('\r\n') + 2:
- return result
- 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
- """
- exception_string = "enhanced syslogd: rsyslogd"
- try:
- obj.sendline(config)
- obj.prompt()
- result = decodetool(obj.before, CODEC)
- if len(result) > result.index('\r\n') + 2:
- if exception_string in result:
- return "Result : Commit successfully"
- else:
- return result
- else:
- return "Result : Commit successfully"
- except Exception as e:
- return e
-
-
-def decodetool(target, codec):
- """This method is used for decoding obj.before to string when run this
- library under python3
-
- :param target: The obj.before
- :param codec: The codec use to decode
- :return:
- """
- try:
- if type(target) == str:
- return target
- if type(target) == bytes:
- return target.decode(codec)
- except Exception as e:
- return e