📄 disableenable.cpp
字号:
//%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.////==============================================================================//// Author: Carol Ann Krug Graves, Hewlett-Packard Company// (carolann_graves@hp.com)////%/////////////////////////////////////////////////////////////////////////////#include <Pegasus/Common/Config.h>#include <Pegasus/Common/Constants.h>#include <Pegasus/Common/System.h>#include <Pegasus/Client/CIMClient.h>PEGASUS_USING_PEGASUS;PEGASUS_USING_STD;// This test uses the Interop namespace definition from Constants.hconst CIMNamespaceName NAMESPACE1 = CIMNamespaceName ("root/SampleProvider");const CIMNamespaceName NAMESPACE2 = CIMNamespaceName ("root/cimv2");const CIMNamespaceName NAMESPACE3 = CIMNamespaceName ("test/TestProvider");const CIMNamespaceName SOURCENAMESPACE = CIMNamespaceName ("root/SampleProvider");void _createModuleInstance (CIMClient & client, const String & name, const String & location){ CIMInstance moduleInstance (PEGASUS_CLASSNAME_PROVIDERMODULE); moduleInstance.addProperty (CIMProperty (CIMName ("Name"), name)); moduleInstance.addProperty (CIMProperty (CIMName ("Vendor"), String ("Hewlett-Packard Company"))); moduleInstance.addProperty (CIMProperty (CIMName ("Version"), String ("2.0"))); moduleInstance.addProperty (CIMProperty (CIMName ("InterfaceType"), String ("C++Default"))); moduleInstance.addProperty (CIMProperty (CIMName ("InterfaceVersion"), String ("2.2.0"))); moduleInstance.addProperty (CIMProperty (CIMName ("Location"), location)); CIMObjectPath path = client.createInstance (PEGASUS_NAMESPACENAME_INTEROP, moduleInstance);}void _createProviderInstance (CIMClient & client, const String & name, const String & providerModuleName){ CIMInstance providerInstance (PEGASUS_CLASSNAME_PROVIDER); providerInstance.addProperty (CIMProperty (CIMName ("Name"), name)); providerInstance.addProperty (CIMProperty (CIMName ("ProviderModuleName"), providerModuleName)); CIMObjectPath path = client.createInstance (PEGASUS_NAMESPACENAME_INTEROP, providerInstance);}void _createCapabilityInstance (CIMClient & client, const String & providerModuleName, const String & providerName, const String & capabilityID, const String & className, const CIMPropertyList & supportedProperties){ Array <String> namespaces; Array <Uint16> providerType; namespaces.append (SOURCENAMESPACE.getString ()); providerType.append (4); CIMInstance capabilityInstance (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES); capabilityInstance.addProperty (CIMProperty (CIMName ("ProviderModuleName"), providerModuleName)); capabilityInstance.addProperty (CIMProperty (CIMName ("ProviderName"), providerName)); capabilityInstance.addProperty (CIMProperty (CIMName ("CapabilityID"), capabilityID)); capabilityInstance.addProperty (CIMProperty (CIMName ("ClassName"), className)); capabilityInstance.addProperty (CIMProperty (CIMName ("Namespaces"), namespaces)); capabilityInstance.addProperty (CIMProperty (CIMName ("ProviderType"), CIMValue (providerType))); if (!supportedProperties.isNull ()) { Array <String> propertyNameStrings; for (Uint32 i = 0; i < supportedProperties.size (); i++) { propertyNameStrings.append (supportedProperties [i].getString ()); } capabilityInstance.addProperty (CIMProperty (CIMName ("supportedProperties"), CIMValue (propertyNameStrings))); } CIMObjectPath path = client.createInstance (PEGASUS_NAMESPACENAME_INTEROP, capabilityInstance);}void _createHandlerInstance (CIMClient & client, const String & name, const String & destination, const CIMNamespaceName & handlerNS){ CIMInstance handlerInstance (PEGASUS_CLASSNAME_INDHANDLER_CIMXML); handlerInstance.addProperty (CIMProperty (CIMName ("SystemCreationClassName"), System::getSystemCreationClassName ())); handlerInstance.addProperty (CIMProperty (CIMName ("SystemName"), System::getFullyQualifiedHostName ())); handlerInstance.addProperty (CIMProperty (CIMName ("CreationClassName"), PEGASUS_CLASSNAME_INDHANDLER_CIMXML.getString ())); handlerInstance.addProperty (CIMProperty (CIMName ("Name"), name)); handlerInstance.addProperty (CIMProperty (CIMName ("Destination"), destination)); CIMObjectPath path = client.createInstance (handlerNS, handlerInstance);}void _createFilterInstance (CIMClient & client, const String & name, const String & query, const String & qlang, const CIMNamespaceName & filterNS){ CIMInstance filterInstance (PEGASUS_CLASSNAME_INDFILTER); filterInstance.addProperty (CIMProperty (CIMName ("SystemCreationClassName"), System::getSystemCreationClassName ())); filterInstance.addProperty (CIMProperty (CIMName ("SystemName"), System::getFullyQualifiedHostName ())); filterInstance.addProperty (CIMProperty (CIMName ("CreationClassName"), PEGASUS_CLASSNAME_INDFILTER.getString ())); filterInstance.addProperty (CIMProperty (CIMName ("Name"), name)); filterInstance.addProperty (CIMProperty (CIMName ("Query"), query)); filterInstance.addProperty (CIMProperty (CIMName ("QueryLanguage"), String (qlang))); filterInstance.addProperty (CIMProperty (CIMName ("SourceNamespace"), SOURCENAMESPACE.getString ())); CIMObjectPath path = client.createInstance (filterNS, filterInstance);}void _createSubscriptionInstance (CIMClient & client, const CIMObjectPath & filterPath, const CIMObjectPath & handlerPath, const CIMNamespaceName & subscriptionNS){ CIMInstance subscriptionInstance (PEGASUS_CLASSNAME_INDSUBSCRIPTION); subscriptionInstance.addProperty (CIMProperty (CIMName ("Filter"), filterPath, 0, PEGASUS_CLASSNAME_INDFILTER)); subscriptionInstance.addProperty (CIMProperty (CIMName ("Handler"), handlerPath, 0, PEGASUS_CLASSNAME_INDHANDLER_CIMXML)); subscriptionInstance.addProperty (CIMProperty (CIMName ("SubscriptionState"), CIMValue ((Uint16) 2))); CIMObjectPath path = client.createInstance (subscriptionNS, subscriptionInstance);}void _modifyCapabilityInstance (CIMClient & client, const String & providerModuleName, const String & providerName, const String & capabilityID, const CIMPropertyList & supportedProperties){ CIMInstance modifiedInstance (PEGASUS_CLASSNAME_PROVIDERCAPABILITIES); modifiedInstance.addProperty (CIMProperty (CIMName ("ProviderModuleName"), providerModuleName)); modifiedInstance.addProperty (CIMProperty (CIMName ("ProviderName"), providerName)); modifiedInstance.addProperty (CIMProperty (CIMName ("CapabilityID"), capabilityID)); Array<CIMKeyBinding> keyBindings; keyBindings.append (CIMKeyBinding ("ProviderModuleName", providerModuleName, CIMKeyBinding::STRING)); keyBindings.append (CIMKeyBinding ("ProviderName", providerName, CIMKeyBinding::STRING)); keyBindings.append (CIMKeyBinding ("CapabilityID", capabilityID, CIMKeyBinding::STRING)); CIMObjectPath path ("", CIMNamespaceName (), CIMName ("PG_ProviderCapabilities"), keyBindings); modifiedInstance.setPath (path); if (!supportedProperties.isNull ()) { Array <String> propertyNameStrings; for (Uint32 i = 0; i < supportedProperties.size (); i++) { propertyNameStrings.append (supportedProperties [i].getString ()); } modifiedInstance.addProperty (CIMProperty (CIMName ("supportedProperties"), CIMValue (propertyNameStrings))); } Array <CIMName> propertyNames; propertyNames.append (CIMName ("SupportedProperties")); client.modifyInstance (PEGASUS_NAMESPACENAME_INTEROP, modifiedInstance, false, CIMPropertyList (propertyNames));}void _deleteSubscriptionInstance (CIMClient & client, const String & filterName, const String & handlerName, const CIMNamespaceName & filterNS, const CIMNamespaceName & handlerNS, const CIMNamespaceName & subscriptionNS){ Array<CIMKeyBinding> filterKeyBindings; filterKeyBindings.append (CIMKeyBinding ("SystemCreationClassName", System::getSystemCreationClassName (), CIMKeyBinding::STRING)); filterKeyBindings.append (CIMKeyBinding ("SystemName", System::getFullyQualifiedHostName (), CIMKeyBinding::STRING)); filterKeyBindings.append (CIMKeyBinding ("CreationClassName", PEGASUS_CLASSNAME_INDFILTER.getString (), CIMKeyBinding::STRING)); filterKeyBindings.append (CIMKeyBinding ("Name", filterName, CIMKeyBinding::STRING)); CIMObjectPath filterPath ("", filterNS, PEGASUS_CLASSNAME_INDFILTER, filterKeyBindings); Array<CIMKeyBinding> handlerKeyBindings; handlerKeyBindings.append (CIMKeyBinding ("SystemCreationClassName", System::getSystemCreationClassName (), CIMKeyBinding::STRING)); handlerKeyBindings.append (CIMKeyBinding ("SystemName", System::getFullyQualifiedHostName (), CIMKeyBinding::STRING)); handlerKeyBindings.append (CIMKeyBinding ("CreationClassName", PEGASUS_CLASSNAME_INDHANDLER_CIMXML.getString (), CIMKeyBinding::STRING)); handlerKeyBindings.append (CIMKeyBinding ("Name", handlerName, CIMKeyBinding::STRING)); CIMObjectPath handlerPath ("", handlerNS, PEGASUS_CLASSNAME_INDHANDLER_CIMXML, handlerKeyBindings); Array<CIMKeyBinding> subscriptionKeyBindings; subscriptionKeyBindings.append (CIMKeyBinding ("Filter", filterPath.toString (), CIMKeyBinding::REFERENCE)); subscriptionKeyBindings.append (CIMKeyBinding ("Handler", handlerPath.toString (), CIMKeyBinding::REFERENCE)); CIMObjectPath subscriptionPath ("", CIMNamespaceName (), PEGASUS_CLASSNAME_INDSUBSCRIPTION, subscriptionKeyBindings); client.deleteInstance (subscriptionNS, subscriptionPath);}void _deleteSubscriptionInstance (CIMClient & client, const String & filterName, const String & handlerName){ _deleteSubscriptionInstance (client, filterName, handlerName, CIMNamespaceName (), CIMNamespaceName (), PEGASUS_NAMESPACENAME_INTEROP);}void _deleteHandlerInstance (CIMClient & client, const String & name, const CIMNamespaceName & handlerNS){ Array<CIMKeyBinding> keyBindings; keyBindings.append (CIMKeyBinding ("SystemCreationClassName", System::getSystemCreationClassName (), CIMKeyBinding::STRING)); keyBindings.append (CIMKeyBinding ("SystemName", System::getFullyQualifiedHostName (), CIMKeyBinding::STRING)); keyBindings.append (CIMKeyBinding ("CreationClassName", PEGASUS_CLASSNAME_INDHANDLER_CIMXML.getString (), CIMKeyBinding::STRING)); keyBindings.append (CIMKeyBinding ("Name", name, CIMKeyBinding::STRING)); CIMObjectPath path ("", CIMNamespaceName (), PEGASUS_CLASSNAME_INDHANDLER_CIMXML, keyBindings); client.deleteInstance (handlerNS, path);}void _deleteFilterInstance (CIMClient & client, const String & name, const CIMNamespaceName & filterNS){ Array<CIMKeyBinding> keyBindings; keyBindings.append (CIMKeyBinding ("SystemCreationClassName", System::getSystemCreationClassName (), CIMKeyBinding::STRING)); keyBindings.append (CIMKeyBinding ("SystemName", System::getFullyQualifiedHostName (), CIMKeyBinding::STRING)); keyBindings.append (CIMKeyBinding ("CreationClassName", PEGASUS_CLASSNAME_INDFILTER.getString (), CIMKeyBinding::STRING)); keyBindings.append (CIMKeyBinding ("Name", name, CIMKeyBinding::STRING)); CIMObjectPath path ("", CIMNamespaceName (), PEGASUS_CLASSNAME_INDFILTER, keyBindings); client.deleteInstance (filterNS, path);}void _deleteCapabilityInstance (CIMClient & client, const String & providerModuleName, const String & providerName, const String & capabilityID){ Array<CIMKeyBinding> keyBindings; keyBindings.append (CIMKeyBinding ("ProviderModuleName", providerModuleName, CIMKeyBinding::STRING)); keyBindings.append (CIMKeyBinding ("ProviderName", providerName, CIMKeyBinding::STRING)); keyBindings.append (CIMKeyBinding ("CapabilityID", capabilityID, CIMKeyBinding::STRING)); CIMObjectPath path ("", CIMNamespaceName (), CIMName ("PG_ProviderCapabilities"), keyBindings); client.deleteInstance (PEGASUS_NAMESPACENAME_INTEROP, path);}void _deleteProviderInstance (CIMClient & client, const String & name, const String & providerModuleName){ Array<CIMKeyBinding> keyBindings; keyBindings.append (CIMKeyBinding ("Name", name, CIMKeyBinding::STRING)); keyBindings.append (CIMKeyBinding ("ProviderModuleName", providerModuleName, CIMKeyBinding::STRING)); CIMObjectPath path ("", CIMNamespaceName (), CIMName ("PG_Provider"), keyBindings); client.deleteInstance (PEGASUS_NAMESPACENAME_INTEROP, path);}void _deleteModuleInstance (CIMClient & client, const String & name){ Array<CIMKeyBinding> keyBindings; keyBindings.append (CIMKeyBinding ("Name", name, CIMKeyBinding::STRING)); CIMObjectPath path ("", CIMNamespaceName (), CIMName ("PG_ProviderModule"), keyBindings); client.deleteInstance (PEGASUS_NAMESPACENAME_INTEROP, path);}CIMObjectPath _buildFilterOrHandlerPath (const CIMName & className, const String & name, const CIMNamespaceName & namespaceName = CIMNamespaceName ()){ CIMObjectPath path;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -