def get_cs_flashcopies(self, fcid=None): """ Get Copy Service Flash Copies for the Caller Object. Args: fcid (str): id of the flash copy. Get all if None. Returns: list: A list of :py:class:`pyds8k.resources.ds8k.v1.cs.flashcopies.FlashCopy`. """ if not self.id: raise IDMissingError() if fcid: return self.one('{}.{}'.format( types.DS8K_COPY_SERVICE_PREFIX, types.DS8K_CS_FLASHCOPY), fcid).get() flashcopies = self.all('{}.{}'.format( types.DS8K_COPY_SERVICE_PREFIX, types.DS8K_CS_FLASHCOPY)).list() self._start_updating() setattr(self, types.DS8K_CS_FLASHCOPY, flashcopies) self._stop_updating() return flashcopies
def get_eserep(self): if not self.id: raise IDMissingError() eserep = self.all(DS8K_ESEREP).list() self._start_updating() setattr(self, DS8K_ESEREP, eserep) self._stop_updating() return eserep
def create_mappings(self, volumes=[], mappings=[]): if not self.id: raise IDMissingError() if volumes: _, res = self.all(types.DS8K_VOLMAP).posta({'volumes': volumes}) else: _, res = self.all(types.DS8K_VOLMAP).posta({'mappings': mappings}) return res
def get_resource_id_from_url(self, url, resource_type): if url.endswith('/'): url = url[:-1] url_frag = url.split('/') if len(url_frag) > 1 and url_frag[-2] == resource_type: return url_frag[-1] logger.debug("Failed to get resource id from url {}".format(url)) raise IDMissingError()
def get_host_ports(self, port_id=None): if port_id: return self.get_host_port(port_id) if not self.id: raise IDMissingError() host_ports = self.all(types.DS8K_HOST_PORT).list() self._start_updating() setattr(self, types.DS8K_HOST_PORT, host_ports) self._stop_updating() return host_ports
def get_flashcopy(self, fcid=None): if not self.id: raise IDMissingError() if fcid: return self.one(types.DS8K_FLASHCOPY, fcid).get() flashcopies = self.all(types.DS8K_FLASHCOPY).list() self._start_updating() setattr(self, types.DS8K_FLASHCOPY, flashcopies) self._stop_updating() return flashcopies
def get_pprc(self, pprc_id=None): if not self.id: raise IDMissingError() if pprc_id: return self.one(types.DS8K_PPRC, pprc_id).get() pprc = self.all(types.DS8K_PPRC).list() self._start_updating() setattr(self, types.DS8K_PPRC, pprc) self._stop_updating() return pprc
def get_mappings(self, lunid=None): if lunid: return self.get_mapping(lunid) if not self.id: raise IDMissingError() mappings = self.all(types.DS8K_VOLMAP).list() self._start_updating() setattr(self, types.DS8K_VOLMAP, mappings) self._stop_updating() return mappings
def get_volumes(self, volume_id=None): if volume_id: return self.get_volume(volume_id) if not self.id: raise IDMissingError() volumes = self.all(types.DS8K_VOLUME).list() self._start_updating() setattr(self, types.DS8K_VOLUME, volumes) self._stop_updating() return volumes
def get_mapping(self, lunid): """ Get the Mapping of the Volume by Volume id for the Caller Object. Args: lunid (str): Require. id of the volume. Returns: object: :py:class:`pyds8k.resources.ds8k.v1.mappings.Volmap`. """ if not self.id: raise IDMissingError() return self.one(types.DS8K_VOLMAP, lunid).get()
def get_host_port(self, port_id): """ Get An Host Ports for the Caller Object. Args: port_id (str): id of the Host Port. Get all if None. Returns: object: :py:class:`pyds8k.resources.ds8k.v1.host_ports.HostPort`. """ if not self.id: raise IDMissingError() return self.one(types.DS8K_HOST_PORT, port_id).get()
def get_ioport(self, port_id): """ Get An IO Port for the Caller Object. Args: port_id (str): Required. id of the IO Port. Returns: object: :py:class:`pyds8k.resources.ds8k.v1.ioports.IOPort`. """ if not self.id: raise IDMissingError() return self.one(types.DS8K_IOPORT, port_id).get()
def delete_mapping(self, lunid): """ Delete the Mapping of the Volume by Volume id for the Caller Object. Args: lunid (str): Require. id of the volume. Returns: tuple: tuple of DS8000 RESTAPI Server Response. """ if not self.id: raise IDMissingError() _, res = self.one(types.DS8K_VOLMAP, lunid).delete() return res
def get_volume(self, volume_id): """ Get A Volume for the Caller Object. Args: volume_id (str): Required. id of the volume. Returns: object: list: A list of :py:class:`pyds8k.resources.ds8k.v1.volumes.Volume`. """ if not self.id: raise IDMissingError() return self.one(types.DS8K_VOLUME, volume_id).get()
def get_pprc(self, pprc_id=None): """ Get PPRC for the Caller Object. Args: pprc_id (str): id of the PPRC. Get all if None. Returns: list: A list of :py:class:`pyds8k.resources.ds8k.v1.pprc.PPRC`. """ if not self.id: raise IDMissingError() if pprc_id: return self.one(types.DS8K_PPRC, pprc_id).get() pprc = self.all(types.DS8K_PPRC).list() self._start_updating() setattr(self, types.DS8K_PPRC, pprc) self._stop_updating() return pprc
def create_mappings(self, volumes=[], mappings=[]): """ Create the Mapping of the Volume by Volume id for the Caller Object. Args: volumes (list): Require. volume ids. mappings (list): Required. mappings. Returns: list: A list of :py:class:`pyds8k.resources.ds8k.v1.mappings.Volmap`. """ if not self.id: raise IDMissingError() if volumes: _, res = self.all(types.DS8K_VOLMAP).posta({'volumes': volumes}) else: _, res = self.all(types.DS8K_VOLMAP).posta({'mappings': mappings}) return res
def get_flashcopies(self, fcid=None): """ Get Flash Copies for the Caller Object. Args: fcid (str): id of the flash copy. Get all if None. Returns: list: A list of :py:class:`pyds8k.resources.ds8k.v1.flashcopy.FlashCopy`. """ if not self.id: raise IDMissingError() if fcid: return self.one(types.DS8K_FLASHCOPY, fcid).get() flashcopies = self.all(types.DS8K_FLASHCOPY).list() self._start_updating() setattr(self, types.DS8K_FLASHCOPY, flashcopies) self._stop_updating() return flashcopies
def get_mappings(self, lunid=None): """ Get Mappings of the Volume by Volume id for the Caller Object. Args: lunid (str): id of the volume. Get all if None. Returns: list: A list of :py:class:`pyds8k.resources.ds8k.v1.mappings.Volmap`. """ if lunid: return self.get_mapping(lunid) if not self.id: raise IDMissingError() mappings = self.all(types.DS8K_VOLMAP).list() self._start_updating() setattr(self, types.DS8K_VOLMAP, mappings) self._stop_updating() return mappings
def get_host_ports(self, port_id=None): """ Get Host Ports for the Caller Object. Args: port_id (str): id of the Host Port. Get all if None. Returns: list: A list of :py:class:`pyds8k.resources.ds8k.v1.host_ports.HostPort`. """ if port_id: return self.get_host_port(port_id) if not self.id: raise IDMissingError() host_ports = self.all(types.DS8K_HOST_PORT).list() self._start_updating() setattr(self, types.DS8K_HOST_PORT, host_ports) self._stop_updating() return host_ports
def get_volumes(self, volume_id=None): """ Get Volumes for the Caller Object. Args: volume_id (str): id of the volume. Get all if None. Returns: list: A list of :py:class:`pyds8k.resources.ds8k.v1.volumes.Volume`. """ if volume_id: return self.get_volume(volume_id) if not self.id: raise IDMissingError() volumes = self.all(types.DS8K_VOLUME).list() self._start_updating() setattr(self, types.DS8K_VOLUME, volumes) self._stop_updating() return volumes
def update_eserep_cap(self, cap, captype=''): if not self.id: raise IDMissingError() return self.all(DS8K_ESEREP).update({'cap': cap, 'captype': captype})
def delete_mapping(self, lunid): if not self.id: raise IDMissingError() _, res = self.one(types.DS8K_VOLMAP, lunid).delete() return res
def get_mapping(self, lunid): if not self.id: raise IDMissingError() return self.one(types.DS8K_VOLMAP, lunid).get()
def get_host_port(self, port_id): if not self.id: raise IDMissingError() return self.one(types.DS8K_HOST_PORT, port_id).get()
def get_volume(self, volume_id): if not self.id: raise IDMissingError() return self.one(types.DS8K_VOLUME, volume_id).get()
def update_tserep_threshold(self, threshold): if not self.id: raise IDMissingError() return self.all(DS8K_TSEREP).update({'threshold': threshold})
def delete_eserep(self): if not self.id: raise IDMissingError() return self.all(DS8K_ESEREP).delete()