CIMQualifier::CIMQualifier( const bp::object &name, const bp::object &value, const bp::object &type, const bp::object &propagated, const bp::object &overridable, const bp::object &tosubclass, const bp::object &toinstance, const bp::object &translatable) : m_name() , m_type() , m_value() , m_is_propagated(false) , m_is_overridable(false) , m_is_tosubclass(false) , m_is_toinstance(false) , m_is_translatable(false) { m_name = StringConv::asString(name, "name"); if (!isnone(type)) m_type = StringConv::asString(type, "type"); m_value = value; m_is_propagated = Conv::as<bool>(propagated, "propagated"); m_is_overridable = Conv::as<bool>(overridable, "overridable"); m_is_tosubclass = Conv::as<bool>(tosubclass, "tosubclass"); m_is_toinstance = Conv::as<bool>(toinstance, "toinstance"); m_is_translatable = Conv::as<bool>(translatable, "translatable"); }
bp::object SLP::discover( const bp::object &srvtype, const bp::object &scopelist, const bp::object &filter, const bp::object &async) { String c_srvtype; String c_scopelist; String c_filter; if (!isnone(srvtype)) c_srvtype = StringConv::asString(srvtype, "srvtype"); if (!isnone(scopelist)) c_scopelist = StringConv::asString(scopelist, "scopelist"); if (!isnone(filter)) c_filter = StringConv::asString(filter, "filter"); bool c_async = Conv::as<bool>(async, "async"); // Open SLP handle. ScopedSLPHandle hslp(c_async); if (!hslp) throw_SLPError("Can't open SLP handle", static_cast<int>(hslp.error())); // Discover the services. SLPError err; bp::list py_srvs; if ((err = SLPFindSrvs( hslp, c_srvtype.c_str(), c_scopelist.c_str(), c_filter.c_str(), SLP::urlCallback, static_cast<void*>(&py_srvs))) != SLP_OK) { throw_SLPError("SLP discovery failed", static_cast<int>(err)); } return py_srvs; }
SLPResult::SLPResult( const bp::object &srvtype, const bp::object &host, const bp::object &port, const bp::object &family, const bp::object &srvpart) : m_srvtype() , m_host() , m_family() , m_srvpart() , m_port(0) { m_srvtype = StringConv::asString(srvtype, "srvtype"); m_host = StringConv::asString(host, "host"); m_port = Conv::as<int>(port, "port"); if (!isnone(family)) m_family = StringConv::asString(family, "family"); if (!isnone(srvpart)) m_srvpart = StringConv::asString(srvpart, "srvpart"); }
bp::object SLP::discoverAttrs( const bp::object &srvurl, const bp::object &scopelist, const bp::object &attrids, const bp::object &async) { String c_srvurl(StringConv::asString(srvurl, "srvurl")); String c_scopelist; String c_attrids; if (!isnone(scopelist)) c_scopelist = StringConv::asString(scopelist, "scopelist"); if (!isnone(attrids)) c_attrids = StringConv::asString(attrids, "attrids"); bool c_async = Conv::as<bool>(async, "async"); // Open SLP handle. ScopedSLPHandle hslp(c_async); if (!hslp) throw_SLPError("Can't open SLP handle", static_cast<int>(hslp.error())); // Discover the attrs. SLPError err; bp::dict py_attrs; if ((err = SLPFindAttrs( hslp, c_srvurl.c_str(), c_scopelist.c_str(), c_attrids.c_str(), SLP::attrCallback, static_cast<void*>(&py_attrs))) != SLP_OK) { throw_SLPError("SLP attrs discovery failed", static_cast<int>(err)); } return py_attrs; }
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; }
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; }
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; }
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; }