def rid_system(cls, system_id): if cls.get_system_list(): cls.log.debug("Delete '{system_id}' system by REST ...".format(system_id=system_id)) try: generic_delete('storage-system',array_id=system_id) except: pass return
def rid_all_BANANAs(cls): for i in cls.get_system_list(): if re.match(r'^BANANA[0-9]?_', i): cls.log.debug("Delete '{system_id}' system by REST ...".format(system_id=i)) generic_delete('storage-system', array_id=i) # TODO For each BANANA system rid BANANA objects :) return
def remove_BANANA_objects_by_REST(cls, system_id): try: for volume_copy in generic_get('volume_copies', array_id=system_id): s = (generic_get('volume', array_id=system_id, id=volume_copy['sourceVolume']))['label'] t = (generic_get('volume', array_id=system_id, id=volume_copy['targetVolume']))['label'] if re.search('BANANA_VOLUME', s) and re.search('BANANA_VOLUME', t): cls.log.debug("DELETE VOLUME COPY'{0}' BY REST!".format(volume_copy['id'])) generic_delete('volume_copy', array_id=system_id, id=volume_copy['id']) for snapshot_group in generic_get('snapshot_groups', array_id=system_id): if re.search('BANANA_SNAPSHOT', snapshot_group['label']): cls.log.debug("DELETE SNAPSHOT GROUP '{0}' BY REST!".format(snapshot_group['label'])) generic_delete('snapshot_group', id=snapshot_group['id'], array_id=system_id) for volume in generic_get('volumes', array_id=system_id): if re.search('BANANA_VOLUME', volume['label']): cls.log.debug("DELETE VOLUME '{0}' BY REST!".format(volume['label'])) generic_delete('volume', id=volume['id'], array_id=system_id) for thin_volume in generic_get('thin_volumes', array_id=system_id): if re.search('BANANA_VOLUME', thin_volume['label']): cls.log.debug("DELETE THIN VOLUME '{0}' BY REST!".format(thin_volume['label'])) generic_delete('thin_volume', id=thin_volume['id'], array_id=system_id) for pool in generic_get('pools', array_id=system_id): if re.search('BANANA_POOL', pool['label']): cls.log.debug("DELETE POOL '{0}' BY REST!".format(pool['label'])) generic_delete('pool', id=pool['id'], array_id=system_id) for hostgroup in generic_get('host_groups', array_id=system_id): if re.search('BANANA_HOSTGROUP', hostgroup['label']): cls.log.debug("DELETE HOSTGROUP '{0}' BY REST!".format(hostgroup['label'])) generic_delete('host_group', id=hostgroup['id'], array_id=system_id) for storage_system in cls.get_system_list(): if re.match(r'^BANANA[0-9]?_', storage_system): cls.log.debug("DELETE STORAGE SYSTEM '{system_id}' BY REST!".format(system_id=storage_system)) generic_delete('storage-system', array_id=storage_system) # TODO Delete host except: print sys.exc_info()[0] return