summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2019-11-10 20:07:16 +0100
committerDaniil Baturin <daniil@baturin.org>2019-11-10 20:07:16 +0100
commitd2bf13a58879f173c3034f6e1c244e06131a303d (patch)
tree6784289d0a79b2aff7b284c7a984af3deed1aa4f /python
parentfc93243324fa99a3d56003a7dbdfab3bda8918c9 (diff)
downloadvyos-1x-d2bf13a58879f173c3034f6e1c244e06131a303d.tar.gz
vyos-1x-d2bf13a58879f173c3034f6e1c244e06131a303d.zip
[HTTP API] Backport config file and image management functions.
Diffstat (limited to 'python')
-rw-r--r--python/vyos/configsession.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/python/vyos/configsession.py b/python/vyos/configsession.py
index acbdd3d5f..9baf8940d 100644
--- a/python/vyos/configsession.py
+++ b/python/vyos/configsession.py
@@ -25,6 +25,9 @@ COMMIT = '/opt/vyatta/sbin/my_commit'
DISCARD = '/opt/vyatta/sbin/my_discard'
SHOW_CONFIG = ['/bin/cli-shell-api', 'showConfig']
LOAD_CONFIG = ['/bin/cli-shell-api', 'loadFile']
+SAVE_CONFIG = ['/opt/vyatta/sbin/vyatta-save-config.pl']
+INSTALL_IMAGE = ['/opt/vyatta/sbin/install-image']
+REMOVE_IMAGE = ['/opt/vyatta/bin/vyatta-boot-image.pl', '--del']
# Default "commit via" string
APP = "vyos-http-api"
@@ -36,6 +39,8 @@ APP = "vyos-http-api"
def inject_vyos_env(env):
env['VYATTA_CFG_GROUP_NAME'] = 'vyattacfg'
env['VYATTA_USER_LEVEL_DIR'] = '/opt/vyatta/etc/shell/level/admin'
+ env['VYATTA_PROCESS_CLIENT'] = 'gui2_rest'
+ env['VYOS_HEADLESS_CLIENT'] = 'vyos_http_api'
env['vyatta_bindir']= '/opt/vyatta/bin'
env['vyatta_cfg_templates'] = '/opt/vyatta/share/vyatta-cfg/templates'
env['vyatta_configdir'] = '/opt/vyatta/config'
@@ -158,3 +163,15 @@ class ConfigSession(object):
def load_config(self, file_path):
self.__run_command(LOAD_CONFIG + [file_path])
+
+ def save_config(self, file_path):
+ out = self.__run_command(SAVE_CONFIG + [file_path])
+ return out
+
+ def install_image(self, url):
+ out = self.__run_command(INSTALL_IMAGE + [url])
+ return out
+
+ def remove_image(self, name):
+ out = self.__run_command(REMOVE_IMAGE + [name])
+ return out