From 0e625db2b13c42aba04e8e9424f1a1aaeacd8886 Mon Sep 17 00:00:00 2001 From: lijunbo Date: Mon, 15 Jul 2019 23:08:29 -0400 Subject: [PATCH] Cleanup dead code in storage_backend.py The base code already provide storage_ceph, storage_lvm, storage_file..., and already returned by bellow code: 'return _patch(storage_backend_uuid, patch)' So, after the return code, there is no use and we don't need keep those code again. Closes-bug: #1836678 Change-Id: Ia83e674688b583a40205da5d26d26de150e326a7 Signed-off-by: junboli --- .../api/controllers/v1/storage_backend.py | 48 ------------------- 1 file changed, 48 deletions(-) diff --git a/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/storage_backend.py b/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/storage_backend.py index 06e741c6a2..771203aaea 100644 --- a/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/storage_backend.py +++ b/sysinv/sysinv/sysinv/sysinv/api/controllers/v1/storage_backend.py @@ -20,7 +20,6 @@ # -import jsonpatch import pecan from pecan import rest @@ -42,7 +41,6 @@ from sysinv import objects from sysinv.openstack.common import log from sysinv.openstack.common.gettextutils import _ from sysinv.openstack.common import uuidutils -from oslo_serialization import jsonutils from sysinv.api.controllers.v1 import storage_ceph # noqa from sysinv.api.controllers.v1 import storage_lvm # noqa @@ -280,52 +278,6 @@ class StorageBackendController(rest.RestController): # update return _patch(storage_backend_uuid, patch) - rpc_storage_backend = objects.storage_backend.get_by_uuid( - pecan.request.context, storage_backend_uuid) - # action = None - for p in patch: - # if '/action' in p['path']: - # value = p['value'] - # patch.remove(p) - # if value in (constants.APPLY_ACTION, - # constants.INSTALL_ACTION): - # action = value - # elif p['path'] == '/capabilities': - if p['path'] == '/capabilities': - p['value'] = jsonutils.loads(p['value']) - - # replace isystem_uuid and storage_backend_uuid with corresponding - patch_obj = jsonpatch.JsonPatch(patch) - state_rel_path = ['/uuid', '/forisystemid', '/isystem_uuid'] - if any(p['path'] in state_rel_path for p in patch_obj): - raise wsme.exc.ClientSideError(_("The following fields can not be " - "modified: %s" % - state_rel_path)) - for p in patch_obj: - if p['path'] == '/isystem_uuid': - isystem = objects.system.get_by_uuid(pecan.request.context, - p['value']) - p['path'] = '/forisystemid' - p['value'] = isystem.id - break - - try: - storage_backend = StorageBackend(**jsonpatch.apply_patch( - rpc_storage_backend.as_dict(), - patch_obj)) - - except utils.JSONPATCH_EXCEPTIONS as e: - raise exception.PatchError(patch=patch, reason=e) - - # Update only the fields that have changed - for field in objects.storage_backend.fields: - if rpc_storage_backend[field] != getattr(storage_backend, field): - rpc_storage_backend[field] = getattr(storage_backend, field) - - # Save storage_backend - rpc_storage_backend.save() - return StorageBackend.convert_with_links(rpc_storage_backend) - @wsme_pecan.wsexpose(None) def delete(self): """Retrieve a list of storage_backend with detail."""