コード例 #1
0
bp::object WBEMConnection::pullInstanceNames(
    bp::object &ctx,
    bp::object &max_object_cnt) try
{
    CIMEnumerationContext &ctx_ = CIMEnumerationContext::asNative(ctx, "Context");
    Pegasus::Uint32 peg_max_object_cnt = Conv::as<Pegasus::Uint32>(
        max_object_cnt, "MaxObjectCnt");

    Pegasus::Array<Pegasus::CIMObjectPath> peg_instance_names;
    Pegasus::Boolean peg_end_of_sequence;

    ScopedTransactionBegin();
    peg_instance_names = client()->pullInstancePaths(
        ctx_.getPegasusContext(),
        peg_end_of_sequence,
        peg_max_object_cnt);
    ScopedTransactionEnd();

    return bp::make_tuple(
        ListConv::asPyCIMInstanceNameList(peg_instance_names),
        ctx,
        bp::object(peg_end_of_sequence));
} catch (...) {
    std::stringstream ss;
    if (Config::isVerbose())
        ss << "PullInstanceNames()";
    handle_all_exceptions(ss);
    return None;
}
コード例 #2
0
void WBEMConnection::closeEnumeration(const bp::object &ctx) try
{
    CIMEnumerationContext &ctx_ = CIMEnumerationContext::asNative(ctx, "Context");
    ScopedTransactionBegin();
    client()->closeEnumeration(ctx_.getPegasusContext());
    ScopedTransactionEnd();
} catch (...) {
    std::stringstream ss;
    if (Config::isVerbose()) {
        ss << "CloseEnumeration()";
    }
    handle_all_exceptions(ss);
}
コード例 #3
0
bp::object WBEMConnection::openExecQuery(
    const bp::object &query_lang,
    const bp::object &query,
    const bp::object &ns,
    const bp::object &operation_timeout,
    const bp::object &continue_on_error,
    const bp::object &max_object_cnt) try
{
    String c_query_lang(
        StringConv::asString(query_lang, "QueryLanguage"));
    String c_query(
        StringConv::asString(query, "Query"));
    Pegasus::CIMClass c_query_cls;

    Pegasus::CIMNamespaceName peg_ns(m_default_namespace);
    if (!isnone(ns))
        peg_ns = StringConv::asString(ns, "namespace");

    Pegasus::Uint32Arg peg_operation_timeout;
    if (!isnone(operation_timeout)) {
        peg_operation_timeout.setValue(Conv::as<Pegasus::Uint32>(
            operation_timeout, "OperationTimeout"));
    }

    Pegasus::Boolean peg_continue_on_error = Conv::as<Pegasus::Boolean>(
        continue_on_error, "ContinueOnError");
    Pegasus::Uint32 peg_max_object_cnt = Conv::as<Pegasus::Uint32>(
        max_object_cnt, "MaxObjectCount");

    Pegasus::Array<Pegasus::CIMInstance> peg_instances;
    boost::shared_ptr<Pegasus::CIMEnumerationContext> ctx_ptr(
        make_enumeration_ctx());
    Pegasus::Boolean peg_end_of_sequence;

    ScopedTransactionBegin();
    peg_instances = client()->openQueryInstances(
        *ctx_ptr,
        peg_end_of_sequence,
        peg_ns,
        c_query_lang,
        c_query,
        c_query_cls, // Unused: queryResultClass
        false,         // Unused: returnQueryResultClass
        peg_operation_timeout,
        peg_continue_on_error,
        peg_max_object_cnt);
    ScopedTransactionEnd();

    return bp::make_tuple(
        ListConv::asPyCIMInstanceList(
            peg_instances,
            peg_ns.getString(),
            client()->getHostname()),
        CIMEnumerationContext::create(
            ctx_ptr,
            false, /* with_paths */
            peg_ns.getString()),
        bp::object(peg_end_of_sequence));
} catch (...) {
    std::stringstream ss;
    if (Config::isVerbose()) {
        ss << "OpenExecQuery(";
        if (Config::isVerboseMore()) {
            ss << "lang=u'"  << StringConv::asString(query_lang) << "', "
               << "query=u'" << StringConv::asString(query) << '\'';
        }
        ss << ')';
    }
    handle_all_exceptions(ss);
    return None;
}
コード例 #4
0
bp::object WBEMConnection::openReferenceNames(
    const bp::object &object_path,
    const bp::object &ns,
    const bp::object &result_class,
    const bp::object &role,
    const bp::object &query_lang,
    const bp::object &query,
    const bp::object &operation_timeout,
    const bp::object &continue_on_error,
    const bp::object &max_object_cnt) try
{
    const CIMInstanceName &inst_name = CIMInstanceName::asNative(
        object_path, "ObjectName");
    Pegasus::CIMObjectPath peg_path = inst_name.asPegasusCIMObjectPath();

    Pegasus::CIMNamespaceName peg_ns(m_default_namespace);
    if (!peg_path.getNameSpace().isNull())
        peg_ns = peg_path.getNameSpace().getString();

    Pegasus::CIMName peg_result_class;
    if (!isnone(result_class))
        peg_result_class = StringConv::asString(result_class, "ResultClass");

    String c_role;
    if (!isnone(role))
        c_role = StringConv::asString(role, "Role");

    String c_query_lang;
    String c_query;
    if (!isnone(query_lang))
        c_query_lang = StringConv::asString(query_lang);
    if (!isnone(query))
        c_query = StringConv::asString(query);

    Pegasus::Boolean peg_continue_on_error = Conv::as<Pegasus::Boolean>(
        continue_on_error, "ContinueOnError");
    Pegasus::Uint32 peg_max_object_cnt = Conv::as<Pegasus::Uint32>(
        max_object_cnt, "MaxObjectCount");

    Pegasus::Uint32Arg peg_operation_timeout;
    if (!isnone(operation_timeout)) {
        peg_operation_timeout.setValue(Conv::as<Pegasus::Uint32>(
            operation_timeout, "OperationTimeout"));
    }

    Pegasus::Array<Pegasus::CIMObjectPath> peg_reference_names;
    boost::shared_ptr<Pegasus::CIMEnumerationContext> ctx_ptr(
        make_enumeration_ctx());
    Pegasus::Boolean peg_end_of_sequence;

    ScopedTransactionBegin();
    peg_reference_names = client()->openReferenceInstancePaths(
        *ctx_ptr,
        peg_end_of_sequence,
        peg_ns,
        peg_path,
        peg_result_class,
        c_role,
        c_query_lang,
        c_query,
        peg_operation_timeout,
        peg_continue_on_error,
        peg_max_object_cnt);
    ScopedTransactionEnd();

    return bp::make_tuple(
        ListConv::asPyCIMInstanceNameList(peg_reference_names),
        CIMEnumerationContext::create(ctx_ptr),
        bp::object(peg_end_of_sequence));
} catch (...) {
    std::stringstream ss;
    if (Config::isVerbose()) {
        ss << "OpenReferenceNames(";
        if (Config::isVerboseMore())
            ss << '\'' << ObjectConv::asString(object_path) << '\'';
        ss << ')';
    }
    handle_all_exceptions(ss);
    return None;
}
コード例 #5
0
bp::object WBEMConnection::openEnumerateInstanceNames(
    const bp::object &cls,
    const bp::object &ns,
    const bp::object &query_lang,
    const bp::object &query,
    const bp::object &operation_timeout,
    const bp::object &continue_on_error,
    const bp::object &max_object_cnt) try
{
    String c_cls(StringConv::asString(cls, "ClassName"));
    String c_ns(m_default_namespace);
    if (!isnone(ns))
        c_ns = StringConv::asString(ns, "namespace");
    Pegasus::CIMName peg_cls(c_cls);
    Pegasus::CIMNamespaceName peg_ns(c_ns);

    String c_query_lang;
    String c_query;
    if (!isnone(query_lang))
        c_query_lang = StringConv::asString(query_lang);
    if (!isnone(query))
        c_query = StringConv::asString(query);

    Pegasus::Boolean peg_continue_on_error = Conv::as<Pegasus::Boolean>(
        continue_on_error, "ContinueOnError");
    Pegasus::Uint32 peg_max_object_cnt = Conv::as<Pegasus::Uint32>(
        max_object_cnt, "MaxObjectCount");

    Pegasus::Uint32Arg peg_operation_timeout;
    if (!isnone(operation_timeout)) {
        peg_operation_timeout.setValue(Conv::as<Pegasus::Uint32>(
            operation_timeout, "OperationTimeout"));
    }

    Pegasus::Array<Pegasus::CIMObjectPath> peg_instance_names;
    boost::shared_ptr<Pegasus::CIMEnumerationContext> ctx_ptr(
        make_enumeration_ctx());
    Pegasus::Boolean peg_end_of_sequence;

    ScopedTransactionBegin();
    peg_instance_names = client()->openEnumerateInstancePaths(
        *ctx_ptr,
        peg_end_of_sequence,
        peg_ns,
        peg_cls,
        c_query_lang,
        c_query,
        peg_operation_timeout,
        peg_continue_on_error,
        peg_max_object_cnt);
    ScopedTransactionEnd();

    return bp::make_tuple(
        ListConv::asPyCIMInstanceNameList(peg_instance_names),
        CIMEnumerationContext::create(ctx_ptr),
        bp::object(peg_end_of_sequence));
} catch (...) {
    std::stringstream ss;
    if (Config::isVerbose()) {
        ss << "OpenEnumerateInstanceNames(";
        if (Config::isVerboseMore()) {
            String c_ns(m_default_namespace);
            if (!isnone(ns))
                c_ns = StringConv::asString(ns);
            ss << "classname=u" << StringConv::asString(cls) << ", "
               << "namespace=u" << c_ns;
        }
        ss << ')';
    }
    handle_all_exceptions(ss);
    return None;
}
コード例 #6
0
bp::object WBEMConnection::openEnumerateInstances(
    const bp::object &cls,
    const bp::object &ns,
    const bp::object &deep_inheritance,
    const bp::object &include_class_origin,
    const bp::object &property_list,
    const bp::object &query_lang,
    const bp::object &query,
    const bp::object &operation_timeout,
    const bp::object &continue_on_error,
    const bp::object &max_object_cnt) try
{
    Pegasus::CIMName peg_cls(StringConv::asPegasusString(cls, "ClassName"));
    Pegasus::CIMNamespaceName peg_ns(m_default_namespace.c_str());
    if (!isnone(ns))
        peg_ns = StringConv::asPegasusString(ns, "namespace");

    Pegasus::String peg_query_lang;
    Pegasus::String peg_query;
    if (!isnone(query_lang))
        peg_query_lang = StringConv::asPegasusString(query_lang);
    if (!isnone(query))
        peg_query = StringConv::asPegasusString(query);

    Pegasus::Boolean peg_deep_inheritance = Conv::as<Pegasus::Boolean>(
        deep_inheritance, "DeepInheritance");
    Pegasus::Boolean peg_include_class_origin = Conv::as<Pegasus::Boolean>(
        include_class_origin, "IncludeClassOrigin");
    Pegasus::Boolean peg_continue_on_error = Conv::as<Pegasus::Boolean>(
        continue_on_error, "ContinueOnError");
    Pegasus::CIMPropertyList peg_property_list(
        ListConv::asPegasusPropertyList(property_list,
        "PropertyList"));
    Pegasus::Uint32Arg peg_operation_timeout;
    Pegasus::Uint32 peg_max_object_cnt = Conv::as<Pegasus::Uint32>(
        max_object_cnt, "MaxObjectCount");

    if (!isnone(operation_timeout)) {
        peg_operation_timeout.setValue(Conv::as<Pegasus::Uint32>(
            operation_timeout, "OperationTimeout"));
    }

    boost::shared_ptr<Pegasus::CIMEnumerationContext> ctx_ptr(
        make_enumeration_ctx());
    Pegasus::Array<Pegasus::CIMInstance> peg_instances;
    Pegasus::Boolean peg_end_of_sequence;

    ScopedTransactionBegin();
    peg_instances = m_client.openEnumerateInstances(
        *ctx_ptr,
        peg_end_of_sequence,
        peg_ns,
        peg_cls,
        peg_deep_inheritance,
        peg_include_class_origin,
        peg_property_list,
        peg_query_lang,
        peg_query,
        peg_operation_timeout,
        peg_continue_on_error,
        peg_max_object_cnt);
    ScopedTransactionEnd();

    return bp::make_tuple(
        ListConv::asPyCIMInstanceList(peg_instances),
        CIMEnumerationContext::create(ctx_ptr),
        bp::object(peg_end_of_sequence));
} catch (...) {
    std::stringstream ss;
    if (Config::isVerbose()) {
        ss << "OpenEnumerateInstances(";
        if (Config::isVerboseMore()) {
            std::string std_ns(m_default_namespace);
            if (!isnone(ns))
                std_ns = StringConv::asStdString(ns);
            ss << "classname=" << StringConv::asStdString(cls) << ", "
               << "namespace=" << std_ns;
        }
        ss << ')';
    }
    handle_all_exceptions(ss);
    return None;
}