def delete(self, sr_uuid): if not self._checkpath(self.path): raise xs_errors.XenError('SRUnavailable', \ opterr='no such directory %s' % self.path) cleanup.gc_force(self.session, self.uuid) # check to make sure no VDIs are present; then remove old # files that are non VDI's try: if util.ioretry(lambda: util.pathexists(self.path)): #Load the VDI list self._loadvdis() for uuid in self.vdis: if not self.vdis[uuid].deleted: raise xs_errors.XenError('SRNotEmpty', \ opterr='VDIs still exist in SR') # remove everything else, there are no vdi's for name in util.ioretry(lambda: util.listdir(self.path)): fullpath = os.path.join(self.path, name) try: util.ioretry(lambda: os.unlink(fullpath)) except util.CommandException, inst: if inst.code != errno.ENOENT and \ inst.code != errno.EISDIR: raise xs_errors.XenError('FileSRDelete', \ opterr='failed to remove %s error %d' \ % (fullpath, inst.code)) except util.CommandException, inst: raise xs_errors.XenError('FileSRDelete', \ opterr='error %d' % inst.code)
def delete(self, sr_uuid): self.attach(sr_uuid) cleanup.gc_force(self.session, self.uuid) # check to make sure no VDIs are present; then remove old # files that are non VDI's try: if util.ioretry(lambda: util.pathexists(self.path)): #Load the VDI list self._loadvdis() for uuid in self.vdis: if not self.vdis[uuid].deleted: raise xs_errors.XenError('SRNotEmpty', \ opterr='VDIs still exist in SR') # remove everything else, there are no vdi's for name in util.ioretry(lambda: util.listdir(self.path)): fullpath = os.path.join(self.path,name) try: util.ioretry(lambda: os.unlink(fullpath)) except util.CommandException, inst: if inst.code != errno.ENOENT and \ inst.code != errno.EISDIR: raise xs_errors.XenError('FileSRDelete', \ opterr='failed to remove %s error %d' \ % (fullpath, inst.code)) self.detach(sr_uuid)
def delete(self, sr_uuid): if not self._checkpath(self.path): raise xs_errors.XenError("SRUnavailable", opterr="no such directory %s" % self.path) cleanup.gc_force(self.session, self.uuid) # check to make sure no VDIs are present; then remove old # files that are non VDI's try: if util.ioretry(lambda: util.pathexists(self.path)): # Load the VDI list self._loadvdis() for uuid in self.vdis: if not self.vdis[uuid].deleted: raise xs_errors.XenError("SRNotEmpty", opterr="VDIs still exist in SR") # remove everything else, there are no vdi's for name in util.ioretry(lambda: util.listdir(self.path)): fullpath = os.path.join(self.path, name) try: util.ioretry(lambda: os.unlink(fullpath)) except util.CommandException, inst: if inst.code != errno.ENOENT and inst.code != errno.EISDIR: raise xs_errors.XenError( "FileSRDelete", opterr="failed to remove %s error %d" % (fullpath, inst.code) ) except util.CommandException, inst: raise xs_errors.XenError("FileSRDelete", opterr="error %d" % inst.code)