587adfe010
This change added a parameter called 'inactive' to load-import workflow on cgts-client to allow import a previous release (ISO). Test Plan: PASS: (AIO-SX) failed to import the current version PASS: (AIO-SX) failed to import the current version with active param PASS: (AIO-SX) import the new version PASS: (AIO-SX) import new version with local param PASS: (AIO-SX) failed to import the previous release PASS: (AIO-SX) import the previous release with inactive param PASS: DC (--os-region-name SystemController) success to import currently version with active param PASS: DC (--os-region-name SystemController) failed to import currently version PASS: DC (--os-region-name SystemController) import new version PASS: DC (--os-region-name SystemController) import new version with local param PASS: DC (--os-region-name SystemController) import previous release with inactive param PASS: DC (--os-region-name SystemController) failed to import previous release PASS: DC (--os-region-name SystemController) extracted ISO files to the controller (/var/www/pages/feed/rel-version) Story: 2010611 Task: 47509 Depends-On: https://review.opendev.org/c/starlingx/config/+/875186 Signed-off-by: Guilherme Schons <guilherme.dossantosschons@windriver.com> Change-Id: I053b0f29ffb347e109143181c6f60988706e6d29
88 lines
2.2 KiB
Python
88 lines
2.2 KiB
Python
# Copyright (c) 2015-2023 Wind River Systems, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
|
|
from cgtsclient.common import base
|
|
from cgtsclient import exc
|
|
|
|
|
|
CREATION_ATTRIBUTES = ['software_version', 'compatible_version',
|
|
'required_patches']
|
|
|
|
IMPORT_ATTRIBUTES = ['path_to_iso', 'path_to_sig', 'active', 'local',
|
|
'inactive']
|
|
|
|
|
|
class Load(base.Resource):
|
|
def __repr__(self):
|
|
return "<loads %s>" % self._info
|
|
|
|
|
|
class LoadManager(base.Manager):
|
|
resource_class = Load
|
|
|
|
def list(self):
|
|
return self._list('/v1/loads/', "loads")
|
|
|
|
def get(self, load_id):
|
|
path = '/v1/loads/%s' % load_id
|
|
try:
|
|
return self._list(path)[0]
|
|
except IndexError:
|
|
return None
|
|
|
|
def _create_load(self, load, path):
|
|
if set(list(load.keys())) != set(CREATION_ATTRIBUTES):
|
|
raise exc.InvalidAttribute()
|
|
|
|
return self._create(path, load)
|
|
|
|
def create(self, load):
|
|
path = '/v1/loads/'
|
|
self._create_load(load, path)
|
|
|
|
def import_load_metadata(self, load):
|
|
path = '/v1/loads/import_load_metadata'
|
|
return self._create_load(load, path)
|
|
|
|
def import_load(self, **kwargs):
|
|
path = '/v1/loads/import_load'
|
|
local = kwargs.pop('local')
|
|
load_info = {}
|
|
|
|
for key, value in kwargs.items():
|
|
if key in IMPORT_ATTRIBUTES:
|
|
if isinstance(value, bool):
|
|
load_info[key] = str(value).lower()
|
|
else:
|
|
load_info[key] = value
|
|
else:
|
|
raise exc.InvalidAttribute(key)
|
|
|
|
if local:
|
|
return self._create(path, body=load_info)
|
|
|
|
data = {
|
|
'active': load_info.pop('active', 'false'),
|
|
'inactive': load_info.pop('inactive', 'false'),
|
|
}
|
|
|
|
json_data = self._upload_multipart(
|
|
path,
|
|
body=load_info,
|
|
data=data,
|
|
check_exceptions=True,
|
|
)
|
|
|
|
return self.resource_class(self, json_data)
|
|
|
|
def delete(self, load_id):
|
|
path = '/v1/loads/%s' % load_id
|
|
return self._delete(path)
|
|
|
|
def update(self, load_id, patch):
|
|
path = '/v1/loads/%s' % load_id
|
|
return self._update(path, patch)
|