⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 slpattrib.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//%2006//////////////////////////////////////////////////////////////////////////// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;// IBM Corp.; EMC Corporation, The Open Group.// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;// EMC Corporation; VERITAS Software Corporation; The Open Group.// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;// EMC Corporation; Symantec Corporation; The Open Group.//// Permission is hereby granted, free of charge, to any person obtaining a copy// of this software and associated documentation files (the "Software"), to// deal in the Software without restriction, including without limitation the// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or// sell copies of the Software, and to permit persons to whom the Software is// furnished to do so, subject to the following conditions://// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.////==============================================================================////%/////////////////////////////////////////////////////////////////////////////#include "SLPAttrib.h"#include <string.h>#include <Pegasus/Client/CIMClient.h>#include <Pegasus/Common/System.h>#include <Pegasus/Common/Constants.h>#include <Pegasus/Common/CIMType.h>#include <Pegasus/Common/InternalException.h>PEGASUS_NAMESPACE_BEGIN//property namesstatic const String PROP_ELEMENTNAME = "ElementName";static const String PROP_DESCRIPTION = "Description";static const String PROP_NAME = "Name";static const String PROP_CLASSINFO = "Classinfo";static const String PROP_COMMUNICATIONMECHANISM = "CommunicationMechanism";static const String PROP_OTHERCOMMUNICATIONMECHANISMDESCRIPTION =                                      "OtherCommunicationMechanismDescription";static const String PROP_INTEROPSCHEMANAMESPACE = "InteropSchemaNamespace";static const String PROP_VERSION = "Version";static const String PROP_FUNCTIONALPROFILESSUPPORTED = "FunctionalProfilesSupported";static const String PROP_FUNCTIONALPROFILEDESCRIPTIONS =                                                      "FunctionalProfileDescriptions";static const String PROP_MULTIPLEOPERATIONSSUPPORTED = "MultipleOperationsSupported";static const String PROP_AUTHENTICATIONMECHANISMSSUPPORTED =                                                     "AuthenticationMechanismsSupported";static const String PROP_AUTHENTICATIONMECHANISMDESCRIPTIONS =                                                 "AuthenticationMechanismDescriptions";static const String PROP_NAMESPACETYPE = "namespaceType";static const String PROP_IPADDRESS = "IPAddress";static const String CIM_CLASSNAME_REGISTEREDPROFILE = "CIM_RegisteredProfile";static const String PROP_OTHERREGISTEREDORGANIZATION = "OtherRegisteredOrganization";static const String PROP_REGISTEREDNAME = "RegisteredName";static const String PROP_ADVERTISETYPES = "AdvertiseTypes";//constructorSLPAttrib::SLPAttrib():serviceType(PEGASUS_SLP_SERVICE_TYPE){}SLPAttrib::~SLPAttrib(){}String SLPAttrib::getAttributes(void) const{    return attributes;}String SLPAttrib::getServiceType(void) const{    return serviceType;}String SLPAttrib::getServiceUrl(void) const{    return serviceUrl;}// fill all data required for SLP.// Returns true if specifieBoolean SLPAttrib::fillData(String protocol){    CIMClient client;    CIMClass cimClass;    //    // open connection to CIMOM    //    String hostStr = System::getHostName();    try    {        //        client.connectLocal();        //        Array <CIMInstance> instances;        CIMInstance saveInstance;        CIMValue val;        Uint32 pos;        Boolean foundProtocol=false;        Boolean localOnly=true;        Boolean includeQualifiers=true;        Boolean includeClassOrigin=false;        Boolean deepInheritance=true;        Uint32 len = 0;        // set to true if there is "Other" property value in FunctionsProfilesSupported value.        Boolean functionaProfileDescriptions = false;        instances = client.enumerateInstances            (PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_OBJECTMANAGER,               deepInheritance,localOnly,includeQualifiers,includeClassOrigin);        PEGASUS_ASSERT (instances.size () == 1);        pos = instances[0].findProperty(PROP_ELEMENTNAME);        PEGASUS_ASSERT (pos != PEG_NOT_FOUND);        val = instances[0].getProperty(pos).getValue ();        serviceHiName = val.toString();        pos = instances[0].findProperty (PROP_DESCRIPTION);        PEGASUS_ASSERT (pos != PEG_NOT_FOUND);        val = instances[0].getProperty(pos).getValue ();        serviceHiDescription = val.toString();        pos = instances[0].findProperty (PROP_NAME);        PEGASUS_ASSERT (pos != PEG_NOT_FOUND);        val = instances[0].getProperty(pos).getValue ();        serviceId = val.toString();        instances = client.enumerateInstances            (PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_PG_CIMXMLCOMMUNICATIONMECHANISM,              deepInheritance,localOnly,includeQualifiers,includeClassOrigin);        for (Uint32 n=instances.size(),i=0 ; i<n; i++)        {            pos = instances[i].findProperty (PROP_NAMESPACETYPE);            PEGASUS_ASSERT (pos != PEG_NOT_FOUND);            val = instances[i].getProperty(pos).getValue ();            if (val.toString() == protocol)            {                pos = instances[i].findProperty (PROP_IPADDRESS);                PEGASUS_ASSERT (pos != PEG_NOT_FOUND);                val = instances[i].getProperty(pos).getValue ();                // Save copy of instance of PG_CIMXMLCommunicationMechanism                // matching protocol for later reference.                saveInstance = instances[i];                serviceUrl= PEGASUS_SLP_SERVICE_TYPE;                serviceUrl.append(":");                serviceUrl.append(protocol);                serviceUrl.append("://");                serviceUrl.append(val.toString());                foundProtocol=true;                break;            }        }        if (!foundProtocol)        {            // reset information that was already set            serviceHiName.clear();            serviceHiDescription.clear();            serviceId.clear();            return false;        }        cimClass = client.getClass(PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_CIMNAMESPACE);        instances = client.enumerateInstances            (PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_CIMNAMESPACE,deepInheritance,             localOnly,includeQualifiers,includeClassOrigin);        for (Uint32 n=instances.size(),i=0 ; i<n; i++)        {            pos = instances[i].findProperty (PROP_NAME);            PEGASUS_ASSERT (pos != PEG_NOT_FOUND);            val = instances[i].getProperty(pos).getValue();            nameSpaces.append(val.toString());            nameSpaces.append(",");            pos = instances[i].findProperty (PROP_CLASSINFO);            PEGASUS_ASSERT (pos != PEG_NOT_FOUND);            val = instances[i].getProperty(pos).getValue();            pos = cimClass.findProperty(PROP_CLASSINFO);            classes.append(getMappedValue(cimClass.getProperty(pos),val));            classes.append(",");        }        len = nameSpaces.size();        if (len > 0)            nameSpaces.remove( len-1,1);        len = classes.size();        if (len > 0)            classes.remove( len-1,1);        cimClass = client.getClass           (PEGASUS_NAMESPACENAME_INTEROP,            PEGASUS_CLASSNAME_OBJECTMANAGERCOMMUNICATIONMECHANISM);        instances = client.enumerateInstances           (PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_OBJECTMANAGERCOMMUNICATIONMECHANISM,            deepInheritance,localOnly,includeQualifiers,includeClassOrigin);        pos = saveInstance.findProperty (PROP_COMMUNICATIONMECHANISM);        PEGASUS_ASSERT (pos != PEG_NOT_FOUND);        val = saveInstance.getProperty(pos).getValue();        pos = cimClass.findProperty(PROP_COMMUNICATIONMECHANISM);        communicationMechanism = getMappedValue(cimClass.getProperty(pos),val);        pos = saveInstance.findProperty (PROP_OTHERCOMMUNICATIONMECHANISMDESCRIPTION);        PEGASUS_ASSERT (pos != PEG_NOT_FOUND);        val = saveInstance.getProperty(pos).getValue ();        otherCommunicationMechanismDescription = val.toString();        interopSchemaNamespace = PEGASUS_NAMESPACENAME_INTEROP.getString();        pos = saveInstance.findProperty (PROP_VERSION);        PEGASUS_ASSERT (pos != PEG_NOT_FOUND);        val = saveInstance.getProperty(pos).getValue();        pos = cimClass.findProperty(PROP_VERSION);        protocolVersion = getMappedValue(cimClass.getProperty(pos),val);        pos = saveInstance.findProperty (PROP_FUNCTIONALPROFILESSUPPORTED);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -