示例#1
0
static rc_t vdi_report_repository( const KRepository * repo, const char * prefix, int idx, bool full )
{
    KRepCategory cat = KRepositoryCategory( repo );
    KRepSubCategory subcat = KRepositorySubCategory( repo );

    rc_t rc = KOutMsg( "  repo.%s #%d:\n", prefix, idx );
    if ( rc == 0 )
        rc = KOutMsg( "     - category : %s.%s\n", KRepCategory_to_str( cat ), KRepSubCategory_to_str( subcat ) );
    if ( rc == 0 )
        rc = vdi_report_repo_str( repo, "name", KRepositoryName );
    if ( rc == 0 )
        rc = KOutMsg( "     - disabled : %s\n", yes_or_no( KRepositoryDisabled( repo ) ) );

    if ( full )
    {
        if ( rc == 0 ) rc = vdi_report_repo_str( repo, "displayname", KRepositoryDisplayName );
        if ( rc == 0 ) rc = vdi_report_repo_str( repo, "root", KRepositoryRoot );
        if ( rc == 0 ) rc = vdi_report_repo_str( repo, "resolver", KRepositoryResolver );

        if ( rc == 0 )
            rc = KOutMsg( "     - cached : %s\n", yes_or_no( KRepositoryCacheEnabled( repo ) ) );

        if ( rc == 0 ) rc = vdi_report_repo_str( repo, "ticket", KRepositoryDownloadTicket );
        if ( rc == 0 ) rc = vdi_report_repo_str( repo, "key", KRepositoryEncryptionKey );
        if ( rc == 0 ) rc = vdi_report_repo_str( repo, "keyfile", KRepositoryEncryptionKeyFile );
        if ( rc == 0 ) rc = vdi_report_repo_str( repo, "desc", KRepositoryDescription );

        if ( rc == 0 )
        {
            uint32_t prj_id;
            rc_t rc1 = KRepositoryProjectId( repo, &prj_id );
            if ( rc1 == 0 ) rc = KOutMsg( "     - prj-id : %d\n", prj_id );
        }
    }

    if ( rc == 0 ) rc = KOutMsg( "\n" );
    return rc;
}
示例#2
0
static rc_t report_repo( visit_ctx * octx, KRepCategory category )
{
    rc_t rc, rc1;
    KRepositoryVector repos;
    const char * hint;

    VectorInit ( &repos, 0, 5 );

    switch ( category )
    {
        case krepUserCategory   : hint = MAIN_CAT_USER;
                                   rc = KRepositoryMgrUserRepositories( octx->repo_mgr, &repos );
                                   break;

        case krepSiteCategory   : hint = MAIN_CAT_SITE;
                                   rc = KRepositoryMgrSiteRepositories( octx->repo_mgr, &repos );
                                   break;

        case krepRemoteCategory : hint = MAIN_CAT_REMOTE;
                                   rc = KRepositoryMgrRemoteRepositories( octx->repo_mgr, &repos );
                                   break;
    }

    if ( rc != 0 )
    {
        if ( rc == SILENT_RC( rcKFG, rcNode, rcOpening, rcPath, rcNotFound ) )
        {
            KOutMsg("\n%s:\n", hint);
            KOutMsg("\tnot found in configuration\n");
            rc = 0;
        }
        else
        {
            PLOGERR( klogErr, ( klogErr, rc,
                 "KRepositoryMgr<$(hint)>repositories() failed in $(func)",
                 "hint=%s,func=%s", hint, __func__ ) );
        }
    }
    else
    {
        uint32_t idx;
        bool disabled = KRepositoryMgrCategoryDisabled ( octx->repo_mgr, category );

        rc = KOutMsg( "\n%s:\n", hint );
        if ( rc == 0 && disabled )
            rc = KOutMsg( "\tglobally disabled\n" );

        for ( idx = 0; idx < VectorLength( &repos ) && rc == 0; ++idx )
        {
            const KRepository *repo = VectorGet( &repos, idx );
            if ( repo != NULL )
            {
                char repo_name[ 1024 ];
                rc = KRepositoryDisplayName ( repo, repo_name, sizeof repo_name, NULL );
                if ( rc != 0 )
                {
                    PLOGERR( klogErr, ( klogErr, rc,
                             "KRepositoryName() for $(hint) failed in $(func)", "hint=%s,func=%s", hint, __func__ ) );
                }
                else
                {
                    KRepSubCategory sub_cat = KRepositorySubCategory ( repo );
                    bool disabled = KRepositoryDisabled ( repo );
                    bool cache_enabled = KRepositoryCacheEnabled ( repo );
                    const char * sub_cat_ptr = SUB_CAT_UNKNOWN;
                    switch( sub_cat )
                    {
                        case krepMainSubCategory        : sub_cat_ptr = SUB_CAT_MAIN; break;
                        case krepAuxSubCategory         : sub_cat_ptr = SUB_CAT_AUX; break;
                        case krepProtectedSubCategory   : sub_cat_ptr = SUB_CAT_PROT; break;
                        default                         : sub_cat_ptr = SUB_CAT_UNKNOWN; break;
                    }

                    rc = KOutMsg( "\t%s.%s: %s, cache-%s",
                            sub_cat_ptr, repo_name,
                            ( disabled ? "disabled" : "enabled" ),
                            ( cache_enabled ? "enabled" : "disabled" ) );
                    if ( rc == 0 )
                    {
                        if ( octx->options->detailed )
                        {
                            /* it is OK if we cannot find the root of a repository... */
                            char where[ 4096 ];
                            rc1 = KRepositoryRoot ( repo, where, sizeof where, NULL );
                            if ( rc1 == 0 )
                                rc = KOutMsg( ", at %s", where );
                            else
                            {
                                rc1 = KRepositoryResolver ( repo, where, sizeof where, NULL );
                                if ( rc1 == 0 )
                                    rc = KOutMsg( ", at %s", where );
                            }
                        }
                                            }
                    if ( rc == 0 )
                        rc = KOutMsg( "\n" );
                }
            }
        }
    }
    {
        rc1 = KRepositoryVectorWhack ( &repos );
        if ( rc1 != 0 )
        {
            PLOGERR( klogErr, ( klogErr, rc1,
                     "KRepositoryVectorWhack() for $(hint) failed in $(func)", "hint=%s,func=%s", hint, __func__ ) );
        }
    }
    return rc;
}