summaryrefslogtreecommitdiff
path: root/src/services/api/graphql/recipes
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2021-12-01 13:14:07 -0600
committerJohn Estabrook <jestabro@vyos.io>2021-12-01 15:52:24 -0600
commita499776ec7dd39b50a6f78ecd4ae3daf87bbb006 (patch)
tree686ae93e34127d7782ad00d6a340663eeed3344b /src/services/api/graphql/recipes
parentefbb2930dcc78ea1f870b5ae5467f1a576bbf08c (diff)
downloadvyos-1x-a499776ec7dd39b50a6f78ecd4ae3daf87bbb006.tar.gz
vyos-1x-a499776ec7dd39b50a6f78ecd4ae3daf87bbb006.zip
graphql: T3993: define add/delete system image request
(cherry picked from commit 358831c18fcf2937f4bf85a55fa0c8bdc802d817)
Diffstat (limited to 'src/services/api/graphql/recipes')
-rw-r--r--src/services/api/graphql/recipes/session.py29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/services/api/graphql/recipes/session.py b/src/services/api/graphql/recipes/session.py
index f8c072b39..5ece78ee6 100644
--- a/src/services/api/graphql/recipes/session.py
+++ b/src/services/api/graphql/recipes/session.py
@@ -7,7 +7,12 @@ from vyos.config import Config
from vyos.configtree import ConfigTree
from vyos.template import render
-class Session(object):
+class Session:
+ """
+ Wrapper for calling configsession functions based on GraphQL requests.
+ Non-nullable fields in the respective schema allow avoiding a key check
+ in 'data'.
+ """
def __init__(self, session, data):
self._session = session
self._data = data
@@ -94,3 +99,25 @@ class Session(object):
raise error
return out
+
+ def add(self):
+ session = self._session
+ data = self._data
+
+ try:
+ res = session.install_image(data['location'])
+ except Exception as error:
+ raise error
+
+ return res
+
+ def delete(self):
+ session = self._session
+ data = self._data
+
+ try:
+ res = session.remove_image(data['name'])
+ except Exception as error:
+ raise error
+
+ return res