def ctl_synchronize(self, image_name, start_index=0, end_index=-1, verbose=False): metadata = None if image_name in self._metadata_dict: # the image is in use on this node. metadata = self._metadata_dict[image_name] data = self._data_dict[image_name] else: # XXX need to check if no one is using this image. metadata_raw = self._get_metadata(image_name) if metadata_raw is None: return errno.ENOENT metadata = UKAIMetadata(image_name, self._config, metadata_raw) data = UKAIData(metadata, self._node_error_state_set, self._config) if end_index == -1: end_index = (metadata.size / metadata.block_size) - 1 for block_index in range(start_index, end_index + 1): if verbose is True: print 'Syncing block %d (from %d to %d)' % (block_index, start_index, end_index) if data.synchronize_block(block_index) is True: metadata.flush() return 0