diff options
author | John Estabrook <jestabro@vyos.io> | 2021-11-14 19:03:25 -0600 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2021-11-15 15:36:42 -0600 |
commit | 419f81a0c39740de0ff61ce25325ebea76c4a395 (patch) | |
tree | bd19031423992efff8151bcc034e57467944f0fd /src/services/api/graphql/recipes | |
parent | 8e8d3d8e6dfec86c210a1b5874e839ad8adaef4b (diff) | |
download | vyos-1x-419f81a0c39740de0ff61ce25325ebea76c4a395.tar.gz vyos-1x-419f81a0c39740de0ff61ce25325ebea76c4a395.zip |
graphql: T3993: add config file save/load
(cherry picked from commit 8915a19f7761253b7bdf6ca847069539ee33851d)
Diffstat (limited to 'src/services/api/graphql/recipes')
-rw-r--r-- | src/services/api/graphql/recipes/config_file.py | 16 | ||||
-rw-r--r-- | src/services/api/graphql/recipes/recipe.py | 19 |
2 files changed, 35 insertions, 0 deletions
diff --git a/src/services/api/graphql/recipes/config_file.py b/src/services/api/graphql/recipes/config_file.py new file mode 100644 index 000000000..850e5326e --- /dev/null +++ b/src/services/api/graphql/recipes/config_file.py @@ -0,0 +1,16 @@ + +from . recipe import Recipe + +class ConfigFile(Recipe): + def __init__(self, session, command_file): + super().__init__(session, command_file) + + # Define any custom processing of parameters here by overriding + # save/load: + # + # def save(self): + # self.data = transform_data(self.data) + # super().save() + # def load(self): + # self.data = transform_data(self.data) + # super().load() diff --git a/src/services/api/graphql/recipes/recipe.py b/src/services/api/graphql/recipes/recipe.py index 8fbb9e0bf..91d8bd67a 100644 --- a/src/services/api/graphql/recipes/recipe.py +++ b/src/services/api/graphql/recipes/recipe.py @@ -46,4 +46,23 @@ class Recipe(object): except Exception as error: raise error + def save(self): + session = self._session + data = self.data + if 'file_name' not in data or not data['file_name']: + data['file_name'] = '/config/config.boot' + try: + session.save_config(data['file_name']) + except Exception as error: + raise error + + def load(self): + session = self._session + data = self.data + + try: + session.load_config(data['file_name']) + session.commit() + except Exception as error: + raise error |