示例#1
0
    def main(self):
        CONF.register_cli_opts(_OPTS)
        _setup_logger(sys.argv[1:])

        if CONF.source_storage == CONF.target_storage:
            raise utils.Error(_('Source and destination can not be the same.'))

        introspection_data_manager = plugins_base.introspection_data_manager()
        self.ext_src = introspection_data_manager[CONF.source_storage].obj
        self.ext_tgt = introspection_data_manager[CONF.target_storage].obj

        nodes = node_cache.get_node_list()
        migration_list = [(n, p) for n in nodes for p in [True, False]]
        failed_records = []
        for node, processed in migration_list:
            result = self._migrate_one(node, processed)
            if result == RESULT_FAILED:
                failed_records.append((node.uuid, processed))

        msg = ('Finished introspection data migration, total records: %d. ' %
               len(migration_list))
        if failed_records:
            msg += 'Failed to migrate:\n' + '\n'.join([
                '%s(processed=%s)' % (record[0], record[1])
                for record in failed_records
            ])
        elif len(migration_list) > 0:
            msg += 'all records are migrated successfully.'
        print(msg)
示例#2
0
def store_introspection_data(node_uuid, data, processed=True):
    """Store introspection data to the storage backend.

    :param node_uuid: node UUID
    :param data: Introspection data to be saved
    :param processed: The type of introspection data, set to True means the
                      introspection data is processed, otherwise unprocessed.
    :raises: utils.Error
    """
    introspection_data_manager = plugins_base.introspection_data_manager()
    store = CONF.processing.store_data
    ext = introspection_data_manager[store].obj
    ext.save(node_uuid, data, processed)
示例#3
0
def get_introspection_data(uuid, processed=True, get_json=False):
    """Get introspection data from the storage backend.

    :param uuid: node UUID
    :param processed: Indicates the type of introspection data to be read,
                      set True to request processed introspection data.
    :param get_json: Specify whether return the introspection data in json
                     format, string value is returned if False.
    :raises: utils.Error
    """
    introspection_data_manager = plugins_base.introspection_data_manager()
    store = CONF.processing.store_data
    ext = introspection_data_manager[store].obj
    return ext.get(uuid, processed=processed, get_json=get_json)
示例#4
0
def get_introspection_data(uuid, processed=True, get_json=False):
    introspection_data_manager = plugins_base.introspection_data_manager()
    store = CONF.processing.store_data
    ext = introspection_data_manager[store].obj
    return ext.get(uuid, processed=processed, get_json=get_json)
示例#5
0
def _store_data(node_uuid, data, processed=True):
    introspection_data_manager = plugins_base.introspection_data_manager()
    store = CONF.processing.store_data
    ext = introspection_data_manager[store].obj
    ext.save(node_uuid, data, processed)