Ejemplo n.º 1
0
    void insertObjects(const char *ns, const vector<BSONObj> &objs, bool keepGoing, uint64_t flags, bool logop ) {
        StringData _ns(ns);
        if (NamespaceString::isSystem(_ns)) {
            massert(16748, "need transaction to run insertObjects", cc().txnStackSize() > 0);
            uassert(10095, "attempt to insert in reserved database name 'system'", nsToDatabaseSubstring(_ns) != "system");
            massert(16750, "attempted to insert multiple objects into a system namspace at once", objs.size() == 1);

            // Trying to insert into a system collection.  Fancy side-effects go here:
            if (nsToCollectionSubstring(ns) == "system.indexes") {
                BSONObj obj = stripDropDups(objs[0]);
                NamespaceDetails *d = getAndMaybeCreateNS(obj["ns"].Stringdata(), logop);
                bool ok = d->ensureIndex(obj);
                if (!ok) {
                    // Already had that index
                    return;
                }

                // Now we have to actually insert that document into system.indexes, we may have
                // modified it with stripDropDups.
                vector<BSONObj> newObjs;
                newObjs.push_back(obj);
                _insertObjects(ns, newObjs, keepGoing, flags, logop);
                return;
            } else if (!legalClientSystemNS(ns, true)) {
                uasserted(16459, str::stream() << "attempt to insert in system namespace '" << ns << "'");
            }
        }
        _insertObjects(ns, objs, keepGoing, flags, logop);
    }
void drive_RepositoryQueryContext()
{
    // get the configuration variable PEGASUS_HOME
    const char* peg_home = getenv("PEGASUS_HOME");
    if (peg_home == NULL)
    {
        cout << "PEGASUS_HOME needs to be set to run this test." << endl;
        exit(-1);
    }
    String repositoryDir(peg_home);
    repositoryDir.append("/");

    // get the makefile build config variable REPOSITORY_NAME
    const char* repo_name = getenv("REPOSITORY_NAME");
    if (repo_name == NULL)
        repositoryDir.append("repository");
    else
        repositoryDir.append(repo_name);

    CIMNamespaceName _ns("root/SampleProvider");
    CIMRepository _rep(repositoryDir);
    RepositoryQueryContext _queryOrig(_ns, &_rep);

    RepositoryQueryContext _query = _queryOrig;

    PEGASUS_TEST_ASSERT(_query.getNamespace() == _ns);

    drive_FromList(_query);
    drive_WhereIds(_query);
    drive_Schema(_query);
}
void drive_CIMOMHandleQueryContext()
{
    CIMNamespaceName _ns("root/SampleProvider");
    CIMOMHandle _ch;
    CIMOMHandleQueryContext _queryOrig(_ns,_ch);

    CIMOMHandleQueryContext _query = _queryOrig;

    PEGASUS_TEST_ASSERT(_query.getNamespace() == _ns);

    drive_FromList(_query);
    drive_WhereIds(_query);
    drive_Schema(_query);
}
Ejemplo n.º 4
0
void drive_resolve_specialChars()
{


    const char* env = getenv("PEGASUS_HOME");
    String repositoryDir(env);
    repositoryDir.append("/repository");
    //String repositoryDir("c:/pegasus-cvs/pegasus/repository");
    CIMNamespaceName _ns("root/cimv2");
    CIMRepository *_rep = new CIMRepository(repositoryDir);
    RepositoryQueryContext _query(_ns, _rep);
    RepositoryQueryContext _query1(_ns, _rep);
    try {
        const CQLIdentifier _Id1(String("CIM_OperatingSystem"));

        _query.insertClassPath(_Id1);

        const CIMName _cimName(String("CIM_OperatingSystem"));

        CIMInstance _i1(_cimName);
        CIMProperty _p1(CIMName("OSType"),CIMValue(Uint16(11)));
        CIMProperty _p2(CIMName("Status"),CIMValue(String("Degraded")));
        Array<Uint16> array16;
        array16.append(Uint16(0));
        array16.append(Uint16(1));
        array16.append(Uint16(2));
        array16.append(Uint16(3));
        CIMProperty _p3(CIMName("OperationalStatus"),CIMValue(array16));

        _i1.addProperty(_p1);
        _i1.addProperty(_p2);
        _i1.addProperty(_p3);

        CQLChainedIdentifier ci1(String("CIM_OperatingSystem.OSType#OS400"));
        CQLChainedIdentifier ci2(String("CIM_OperatingSystem.OSType#LINUX"));
        CQLChainedIdentifier ci3(String("CIM_OperatingSystem.Status#Degraded"));

        CQLChainedIdentifier ci5(String("CIM_OperatingSystem.Status#BOGUS"));

        CQLChainedIdentifier ci6(
            String("CIM_OperatingSystem.CIM_OperatingSystem::"
                   "OperationalStatus[2]"));
        CQLValue a1(ci1);
        CQLValue a2(ci2);
        CQLValue a3(ci3);

        CQLValue a5(ci5);
        CQLValue a6(ci6);


        a1.resolve(_i1, _query);
        a2.resolve(_i1, _query);

        a6.resolve(_i1, _query);

        try
        {
            a3.resolve(_i1, _query);
            PEGASUS_TEST_ASSERT(0);
        }
        catch(...)
        {
            PEGASUS_TEST_ASSERT(1);
        }

        try
        {
            a5.resolve(_i1, _query);
            PEGASUS_TEST_ASSERT(0);
        }
        catch(...)
        {
            PEGASUS_TEST_ASSERT(1);
        }

        PEGASUS_TEST_ASSERT(a1 == CQLValue(Uint64(11)));
        PEGASUS_TEST_ASSERT(a2 == CQLValue(Uint64(36)));


        PEGASUS_TEST_ASSERT(a6 == CQLValue(Uint64(2)));


    }
    catch(Exception & e)
    {
        cout << e.getMessage() << endl;
        PEGASUS_TEST_ASSERT(0);
    }
    delete _rep;
    return;
}
Ejemplo n.º 5
0
void drive_resolve_primitive()
{


    const char* env = getenv("PEGASUS_HOME");
    String repositoryDir(env);
    repositoryDir.append("/repository");
    //String repositoryDir("c:/pegasus-cvs/pegasus/repository");
    CIMNamespaceName _ns("root/cimv2");
    CIMRepository *_rep = new CIMRepository(repositoryDir);
    RepositoryQueryContext _query(_ns, _rep);
    RepositoryQueryContext _query1(_ns, _rep);
    try {
        const CQLIdentifier _Id1(String("CIM_OperatingSystem"));

        _query.insertClassPath(_Id1);

        const CIMName _cimName(String("CIM_OperatingSystem"));

        CIMInstance _i1(_cimName);
        CIMProperty _p1(CIMName("Description"),CIMValue(String("Dave Rules")));
        CIMProperty _p2(CIMName("EnabledState"),CIMValue(Uint16(2)));
        CIMProperty _p3(CIMName("CurrentTimeZone"),CIMValue(Sint16(-600)));
        CIMProperty _p4(CIMName("TimeOfLastStateChange"),
                        CIMValue(CIMDateTime(String("20040811105625.000000-360"))));

        _i1.addProperty(_p1);
        _i1.addProperty(_p2);
        _i1.addProperty(_p3);
        _i1.addProperty(_p4);

        CQLChainedIdentifier ci1(
            String("CIM_OperatingSystem.CIM_OperatingSystem::Description"));
        CQLChainedIdentifier
        ci2(String("CIM_OperatingSystem.CIM_OperatingSystem::EnabledState"));
        CQLChainedIdentifier ci3(
            String("CIM_OperatingSystem.CIM_OperatingSystem::CurrentTimeZone"));
        CQLChainedIdentifier ci4(
            String("CIM_OperatingSystem.CIM_OperatingSystem::TimeOfLastStateChange"));

        CQLChainedIdentifier
        ci5(String(
                "CIM_OperatingSystem.CIM_EnabledLogicalElement::TimeOfLastStateChange"));

        CQLChainedIdentifier
        ci7(String("CIM_OperatingSystem"));

        CQLChainedIdentifier
        ci9(String(
                "CIM_EnabledLogicalElement.CIM_OperatingSystem::CSCreationClassName"));

        CQLChainedIdentifier
        ci10(String("CIM_OperatingSystem.CIM_OperatingSystem::Bubba"));

        CQLValue a1(ci1);
        CQLValue a2(ci2);
        CQLValue a3(ci3);
        CQLValue a4(ci4);
        CQLValue a5(ci5);

        CQLValue a7(ci7);

        CQLValue a9(ci9);
        CQLValue a10(ci10);

        CQLValue a11(_query.getClass(CIMName("CIM_OperatingSystem")));

        a1.resolve(_i1, _query);
        a2.resolve(_i1, _query);
        a3.resolve(_i1, _query);
        a4.resolve(_i1, _query);
        a5.resolve(_i1, _query);
        a7.resolve(_i1, _query);
        a10.resolve(_i1, _query1);

        a9.resolve(_i1, _query);

        PEGASUS_TEST_ASSERT(a1 == CQLValue(String("Dave Rules")));
        PEGASUS_TEST_ASSERT(a2 == CQLValue(Uint64(2)));
        PEGASUS_TEST_ASSERT(a3 == CQLValue(Sint64(-600)));
        PEGASUS_TEST_ASSERT(a4 == CQLValue(
                                CIMDateTime(String("20040811105625.000000-360"))));
        PEGASUS_TEST_ASSERT(a5 == CQLValue(
                                CIMDateTime(String("20040811105625.000000-360"))));
        //PEGASUS_TEST_ASSERT(a7 == CQLValue(_i1));
        PEGASUS_TEST_ASSERT(a9.isNull());
        PEGASUS_TEST_ASSERT(a10.isNull());

    }
    catch(Exception & e)
    {
        cout << e.getMessage() << endl;
        PEGASUS_TEST_ASSERT(0);
    }
    delete _rep;
    return;
}