aboutsummaryrefslogtreecommitdiffstats
path: root/src/onapsdk/sdc/vsp.py
diff options
context:
space:
mode:
authorMichal Jagiello <michal.jagiello@t-mobile.pl>2023-03-03 08:11:10 +0000
committerMichal Jagiello <michal.jagiello@t-mobile.pl>2023-03-03 08:24:25 +0000
commit70c6a75709b0001e9ffe26987563e14e3e6c6b3d (patch)
tree0a439f2fa76985e45c42925c1c78504e1ff9b4a9 /src/onapsdk/sdc/vsp.py
parent04d216408b1fe94337775a6e528175733d055f25 (diff)
Archive Vendor Software Product
Add a method to archive SDC VSP resource Issue-ID: INT-2193 Signed-off-by: Michal Jagiello <michal.jagiello@t-mobile.pl> Change-Id: If643ff47e6b7385eff5d745a5896bf4cb76c5c67
Diffstat (limited to 'src/onapsdk/sdc/vsp.py')
-rw-r--r--src/onapsdk/sdc/vsp.py44
1 files changed, 42 insertions, 2 deletions
diff --git a/src/onapsdk/sdc/vsp.py b/src/onapsdk/sdc/vsp.py
index a6c4c24..a04b3c0 100644
--- a/src/onapsdk/sdc/vsp.py
+++ b/src/onapsdk/sdc/vsp.py
@@ -139,6 +139,13 @@ class Vsp(SdcElement): # pylint: disable=too-many-instance-attributes
self._generic_action,
action=const.SUBMIT)
+ def archive(self) -> None:
+ """Archive VSP."""
+ self._action("archive",
+ const.CERTIFIED,
+ self._generic_action,
+ action=const.ARCHIVE)
+
def create_csar(self) -> None:
"""Create the CSAR package in the SDC Vsp."""
self._action("create CSAR package", const.CERTIFIED,
@@ -226,7 +233,10 @@ class Vsp(SdcElement): # pylint: disable=too-many-instance-attributes
def _generic_action(self, action=None):
"""Do a generic action for real."""
if action:
- self._action_to_sdc(action, action_type="lifecycleState")
+ if action == const.ARCHIVE:
+ self._action_to_sdc(action, action_type=const.ARCHIVE)
+ else:
+ self._action_to_sdc(action, action_type="lifecycleState")
def _create_csar_action(self):
"""Create CSAR package for real."""
@@ -320,6 +330,36 @@ class Vsp(SdcElement): # pylint: disable=too-many-instance-attributes
return {}
@classmethod
+ def _get_all_url(cls) -> str:
+ """
+ Get URL for all elements in SDC.
+
+ Returns:
+ str: the url
+
+ """
+ return f"{cls._base_url()}/items?itemType=vsp"
+
+ def _action_url(self, base: str, subpath: str, version_path: str,
+ action_type: str = None) -> str:
+ """Generate action URL for VSP to send to SDC.
+
+ Args:
+ base (str): base part of vsp action url
+ subpath (str): subpath of vsp action url
+ version_path (str): version path. If action is equal to ARCHIVE
+ it's going to be edited
+ action_type (str, optional): the type of action.
+
+ Returns:
+ str: the URL to use
+
+ """
+ if action_type == const.ARCHIVE:
+ version_path = version_path.split("/")[0]
+ return super()._action_url(base, subpath, version_path, action_type)
+
+ @classmethod
def import_from_sdc(cls, values: Dict[str, Any]) -> 'Vsp':
"""
Import Vsp from SDC.
@@ -334,7 +374,7 @@ class Vsp(SdcElement): # pylint: disable=too-many-instance-attributes
cls._logger.debug("importing VSP %s from SDC", values['name'])
vsp = Vsp(values['name'])
vsp.identifier = values['id']
- vsp.vendor = Vendor(name=values['vendorName'])
+ vsp.vendor = Vendor(name=values['properties']['vendorName'])
return vsp
def _really_submit(self) -> None: