Exemple #1
0
 def _volume_delete(self, uuid):
     pdisk = PersistentDisk(self.slConfigHolder)
     wait_time = 30
     time_stop = time.time() + wait_time
     while 0 != int(pdisk.getValue('count', uuid)):
         if time.time() >= time_stop:
             self._print_detail(
                 'Disk %s is still in use after waiting for %s sec.' %
                 (uuid, wait_time))
         time.sleep(3)
     return pdisk.deleteVolume(uuid)
Exemple #2
0
 def _get_volatile_disk_ids_to_delete(self, vm_info):
     """Return list of volatile disks uuids for the provided VM.
     vm_info : <ElementTree> object
     """
     # Collect disk sources starting with 'pdisk'.
     sources = []
     for disk in vm_info.findall('TEMPLATE/DISK'):
         if disk.find('SOURCE') is not None:
             disk_source = disk.find('SOURCE').text
             if disk_source.startswith('pdisk'):
                 sources.append(disk_source)
     if not sources:
         return []
     pdisk = PersistentDisk(self.slConfigHolder.copy())
     # Collect uuids of the disks sources only if they have special (volatile) tag in PDisk.
     # TOOD: This can be parallelized.
     uuids = []
     for source in sources:
         source = source.replace('/', ':')
         uuid = source.split(':')[-1]
         tag = pdisk.getValue('tag', uuid)
         if tag.startswith(self.VOLATILE_DISK_PREFIX):
             uuids.append(uuid)
     return uuids
Exemple #3
0
 def _volume_exists(self, uuid):
     pd = PersistentDisk(self.slConfigHolder)
     return pd.volumeExists(uuid)
Exemple #4
0
 def _volume_create(self, size, tag):
     pdisk = PersistentDisk(self.slConfigHolder)
     public = False
     return pdisk.createVolume(str(size), tag, public)