From d36c8831a33f0c91d5eec8817ba835393406d6bd Mon Sep 17 00:00:00 2001 From: SerenaFeng Date: Mon, 21 Aug 2017 17:27:52 +0800 Subject: change scenario owner 1 bugfix owner must be explicit in ScenarioVersion model 2 change owner of scenario 3. usage: PUT /api/v1/scenarios//owner? \ installer=& \ version= body: new owner Change-Id: I261468cd8445030b61e37e0f804b699d6205bdb0 Signed-off-by: SerenaFeng --- .../opnfv_testapi/resources/scenario_handlers.py | 36 ++++++++++++++++++++++ .../opnfv_testapi/resources/scenario_models.py | 7 +++-- 2 files changed, 41 insertions(+), 2 deletions(-) (limited to 'utils/test/testapi/opnfv_testapi/resources') diff --git a/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py b/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py index 09cce7bc5..bd06400b4 100644 --- a/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py +++ b/utils/test/testapi/opnfv_testapi/resources/scenario_handlers.py @@ -146,6 +146,7 @@ class ScenarioUpdater(object): ('projects', 'post'): self._update_requests_add_projects, ('projects', 'put'): self._update_requests_update_projects, ('projects', 'delete'): self._update_requests_delete_projects, + ('owner', 'put'): self._update_requests_change_owner, } updates[(item, action)](self.data) @@ -251,6 +252,11 @@ class ScenarioUpdater(object): def _update_requests_delete_projects(self, version): version.projects = self._remove_projects(version.projects) + @iter_installers + @iter_versions + def _update_requests_change_owner(self, version): + version.owner = self.body + def _filter_installers(self, installers): return self._filter('installer', installers) @@ -566,3 +572,33 @@ class ScenarioProjectsHandler(GenericScenarioUpdateHandler): locators={'scenario': scenario, 'installer': None, 'version': None}) + + +class ScenarioOwnerHandler(GenericScenarioUpdateHandler): + @swagger.operation(nickname="changeScenarioOwner") + def put(self, scenario): + """ + @description: change scenario owner + @notes: substitute all projects, delete existed ones with new provides + PUT /api/v1/scenarios//owner? \ + installer=& \ + version= + @param body: new owner + @type body: L{string} + @in body: body + @param installer: installer type + @type installer: L{string} + @in installer: query + @required installer: True + @param version: version + @type version: L{string} + @in version: query + @required version: True + @return 200: change owner success. + @raise 404: scenario/installer/version not existed + """ + self.do_update('owner', + 'put', + locators={'scenario': scenario, + 'installer': None, + 'version': None}) diff --git a/utils/test/testapi/opnfv_testapi/resources/scenario_models.py b/utils/test/testapi/opnfv_testapi/resources/scenario_models.py index 9f5a07434..7d0770759 100644 --- a/utils/test/testapi/opnfv_testapi/resources/scenario_models.py +++ b/utils/test/testapi/opnfv_testapi/resources/scenario_models.py @@ -74,7 +74,8 @@ class ScenarioVersion(models.ModelBase): @property projects: @ptype projects: C{list} of L{ScenarioProject} """ - def __init__(self, version=None, projects=None): + def __init__(self, owner=None, version=None, projects=None): + self.owner = owner self.version = version self.projects = list_default(projects) @@ -83,7 +84,9 @@ class ScenarioVersion(models.ModelBase): return {'projects': ScenarioProject} def __eq__(self, other): - return [self.version == other.version and self._projects_eq(other)] + return [self.version == other.version and + self.owner == other.owner and + self._projects_eq(other)] def __ne__(self, other): return not self.__eq__(other) -- cgit 1.2.3-korg