示例#1
0
 def destroy_base_image(self):
     LOG.debug("Virtman: destroy base_image = %s, peer_id = %s" %
               (self.image_name, self.peer_id))
     if self.is_local_has_image:
         return False
     self._logout_master()
     if self.has_target:
         if iscsi.is_connected(self.target_id):
             LOG.debug("Virtman: destroy base image Failed! base_image = "
                       "%s, peer_id = %s" % (self.image_name, self.peer_id))
             return False
         else:
             self._delete_target()
     if self.has_origin:
         self._delete_origin()
     time.sleep(1)
     if not self.has_origin and not self.has_target:
         self._delete_cache()
     if not self.has_cache:
         self._delete_multipath()
     if not self.has_multipath:
         for key in self.paths.keys():
             self.paths[key].disconnect()
             del self.paths[key]
         LOG.debug("Virtman: destroy base image SUCCESS! base_image = %s, "
                   "peer_id = %s" % (self.image_name, self.peer_id))
         return True
     return False
示例#2
0
    def destroy_base_image(self):
        LOG.debug("Virtman: destroy base_image = %s, peer_id = %s" %
                  (self.image_name, self.peer_id))
        # if base_image.is_local_has_image:
        #     return False
        if self.is_login:
            Volt.logout_master(self)

        if self.has_target:
            if iscsi.is_connected(self.target_id):
                LOG.debug("Virtman: destroy base image Failed! iscsi target "
                          "for this base image is connected.")
                return False
            try:
                Target.delete_target(self)
            except Exception as ex:
                LOG.debug("Virtman: delete target for base image %s fail, "
                          "due to %s" % (self.image_name, ex))
                return False

        if self.origin_path:
            try:
                Origin.delete_origin(self)
            except Exception as ex:
                LOG.debug("Virtman: delete origin for base image %s fail, "
                          "due to %s" % (self.image_name, ex))
                return False

        time.sleep(1)

        if self.cached_path:
            try:
                Cache.delete_cache(self)
            except Exception as ex:
                LOG.debug("Virtman: delete cache for base image %s fail, "
                          "due to %s" % (self.image_name, ex))
                return False

        if self.multipath_path:
            try:
                self.delete_multipath()
            except Exception as ex:
                LOG.debug("Virtman: delete multipath for base image %s fail, "
                          "due to %s" % (self.image_name, ex))
                return False
        try:
            for key in self.paths.keys():
                Path.disconnect(self.paths[key])
                del self.paths[key]
            LOG.debug("Virtman: destroy base image SUCCESS! base_image = %s, "
                      "peer_id = %s" % (self.image_name,
                                        self.peer_id))
            return True
        except Exception as ex:
            LOG.debug("Virtman: destroy base image %s fail, due to %s" %
                      (self.image_name, ex))
            return False