def rebuild_multipath(self, parent_connections): """ :param parent_connections: list """ LOG.debug("Virtman: begin to rebuild multipath...") # If it has image on the local node or no path to connect, connect to # root if self.is_local_has_image or len(parent_connections) == 0: parent_connections = self.image_connections LOG.debug("Virtman: the parents were modified! now parents = %s" % parent_connections) # Get keys of paths to remove, and add new paths paths_to_remove = [] for key in self.paths.keys(): found = False for connection in parent_connections: if key == Path.connection_to_str(connection): found = True break if not found: paths_to_remove.append(key) for connection in parent_connections: if not isinstance(connection, dict): raise (Exception("Unknown %s type of %s " % (type(connection), connection))) key = Path.connection_to_str(connection) if key not in self.paths: self.paths[key] = Path(connection) # Connect new paths for key in self.paths.keys(): if key not in paths_to_remove and not self.paths[key].connected: self.paths[key].connect() # Rebuild multipath device disks = [self.paths[key].device_path for key in self.paths.keys() if key not in paths_to_remove and self.paths[key].connected] if len(disks) > 0: if not self.has_multipath: self._create_multipath(disks) else: self._reload_multipath(disks) # TODO:fix here, wait for multipath device ready time.sleep(2) # Disconnect paths to remove for key in paths_to_remove: if self.paths[key].connected: self.paths[key].disconnect() del self.paths[key] LOG.debug("Virtman: rebuild multipath completed, multipath = %s" % self.multipath_path)
def __str__(self): return Path.connection_to_str(self.connection)