Source code for pyds8k.resources.ds8k.v1.cs.pprcs

##############################################################################
# Copyright 2019 IBM Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##############################################################################

"""
advanced PPRC interface.
"""

from pyds8k.base import ManagerMeta, ResourceMeta
from pyds8k.resources.ds8k.v1.common.base import Base, ReadOnlyManager
from pyds8k.resources.ds8k.v1.common.types import DS8K_CS_PPRC
from pyds8k.resources.ds8k.v1.systems import System, SystemManager
from pyds8k.resources.ds8k.v1.volumes import Volume, VolumeManager


[docs]class PPRC(Base, metaclass=ResourceMeta): resource_type = DS8K_CS_PPRC _template = { 'id': '', 'type': '', 'state': '', 'source_system': '', 'target_system': '', 'source_volume': '', 'target_volume': '', } related_resource = { '_source_volume': (Volume, VolumeManager), '_source_system': (System, SystemManager), '_target_volume': (Volume, VolumeManager), '_target_system': (System, SystemManager), } def _update_volume_info(self, info): # Handle for bug in DS8000 RESTful API /api/v1/cs/pprcs: # When it responds, source_volume and target_volume use # "name" as the key of id field. for key in ['source_volume', 'target_volume']: if 'name' in info[key] and 'id' not in info[key]: info[key]['id'] = info[key].pop('name') return info def _add_details(self, info, force=False): self._start_updating() self._update_volume_info(info) self._stop_updating() super()._add_details(info, force=force)
[docs]class PPRCManager(ReadOnlyManager, metaclass=ManagerMeta): """ Manage advanced PPRC resources. """ resource_class = PPRC resource_type = DS8K_CS_PPRC