summaryrefslogtreecommitdiff
path: root/vymgmt/mgmt_common.py
blob: 0ed4bf0b4a93df368aa8c61a0774f78c29ef90d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 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