Пример #1
0
   static CMPIStatus mbDeliverIndication(const CMPIBroker* eMb, const CMPIContext* ctx,
               const char *ns, const CMPIInstance* ind) {
      DDD(cout<<"--- mbDeliverIndication()"<<endl);
      eMb=CM_BROKER;
      CMPI_Broker *mb=(CMPI_Broker*)eMb;
      CMPIProviderManager::indProvRecord *prec;
      OperationContext* context=CM_Context(ctx);

      if (CMPIProviderManager::provTab.lookup(mb->name,prec)) {
         if (prec->enabled) {
            try {
               context->get(SubscriptionInstanceNamesContainer::NAME);
            }
            catch (const Exception &) {
               Array<CIMObjectPath> subscriptionInstanceNames;
               context->insert(SubscriptionInstanceNamesContainer(subscriptionInstanceNames));
            }
            CIMIndication cimIndication(*CM_Instance(ind));
            AutoMutex mtx(((CMPI_Broker*)mb)->mtx);
            try {
               prec->handler->deliver(
                  *context,
   //               OperationContext(*CM_Context(ctx)),
                  cimIndication);
            CMReturn(CMPI_RC_OK);
      }
            catch (const CIMException &e) {
               DDD(cout<<"### exception: mbSetProperty - code: "<<e.getCode()<<" msg: "<<e.getMessage()<<endl);
               CMReturn((CMPIrc)e.getCode());
            }
         }
      }
      CMReturn(CMPI_RC_ERR_FAILED);
   }
void EnableIndicationsResponseHandler::deliver(const CIMIndication & cimIndication)
{
    OperationContext context;

    Array<CIMObjectPath> subscriptionInstanceNames;

    context.insert(SubscriptionInstanceNamesContainer(subscriptionInstanceNames));

    deliver(context, cimIndication);
}
Пример #3
0
void _generateIndication (
    IndicationResponseHandler * handler,
    const CIMName methodName)
{
    if (_enabled)
    {
        CIMInstance indicationInstance;

        if (methodName.equal ("SendTestIndicationSubclass"))
        {
            CIMInstance theIndication (CIMName ("RT_TestIndicationSubclass"));
            indicationInstance = theIndication;
        }
        else
        {
            CIMInstance theIndication (CIMName ("RT_TestIndication"));
            indicationInstance = theIndication;
        }

        CIMObjectPath path;
        if (methodName.equal ("SendTestIndicationUnmatchingNamespace"))
        {
            //
            //  For SendTestIndicationUnmatchingNamespace, generate an
            //  indication instance with namespace that does not match the
            //  subscription instance name included in the operation context
            //  (nor does it match the namespace for which provider has
            //  registered)
            //
            path.setNameSpace ("root/cimv2");
            path.setClassName ("RT_TestIndication");
        }
        else if (methodName.equal ("SendTestIndicationUnmatchingClassName"))
        {
            // the indication class name and object path class must match
            indicationInstance = CIMInstance("CIM_AlertIndication");

            //
            //  For SendTestIndicationUnmatchingClassName, generate an
            //  indication instance with classname that does not match the
            //  subscription instance name included in the operation context
            //  (nor does it match the classname for which provider has
            //  registered)
            //
            path.setNameSpace ("root/SampleProvider");
            path.setClassName ("CIM_AlertIndication");
        }
        else if (methodName.equal ("SendTestIndicationSubclass"))
        {
            //
            //  For SendTestIndicationSubclass, generate an indication instance
            //  of a the RT_TestIndicationSubclass subclass
            //
            path.setNameSpace ("root/SampleProvider");
            path.setClassName ("RT_TestIndicationSubclass");
        }
        else
        {
            path.setNameSpace("root/SampleProvider");
            path.setClassName("RT_TestIndication");
        }

        indicationInstance.setPath(path);

        char buffer[32];
        sprintf(buffer, "%d", _nextUID++);
        indicationInstance.addProperty
            (CIMProperty ("IndicationIdentifier",String(buffer)));

	CIMDateTime currentDateTime = CIMDateTime::getCurrentDateTime ();
	indicationInstance.addProperty
            (CIMProperty ("IndicationTime", currentDateTime));

        //
        //  For SendTestIndicationMissingProperty, leave out the
        //  CorrelatedIndications property
        //
        if (!methodName.equal ("SendTestIndicationMissingProperty"))
        {
	    Array <String> correlatedIndications;
	    indicationInstance.addProperty
                (CIMProperty ("CorrelatedIndications", correlatedIndications));
        }

        if ((methodName.equal ("SendTestIndicationNormal")) ||
            (methodName.equal ("SendTestIndicationSubclass")) ||
            (methodName.equal ("SendTestIndicationMissingProperty")) ||
            (methodName.equal ("SendTestIndicationExtraProperty")) ||
            (methodName.equal ("SendTestIndicationMatchingInstance")) ||
            (methodName.equal ("SendTestIndicationUnmatchingNamespace")) ||
            (methodName.equal ("SendTestIndicationUnmatchingClassName")))
        {
            indicationInstance.addProperty
                (CIMProperty ("MethodName", CIMValue (methodName.getString())));
        }
        else
        {
            indicationInstance.addProperty
                (CIMProperty ("MethodName",
                    CIMValue (String ("generateIndication"))));
        }

        //
        //  For SendTestIndicationExtraProperty, add an extra property,
        //  ExtraProperty, that is not a member of the indication class
        //
        if (methodName.equal ("SendTestIndicationExtraProperty"))
        {
            indicationInstance.addProperty
                (CIMProperty ("ExtraProperty",
                    CIMValue (String ("extraProperty"))));
        }

        CIMIndication cimIndication (indicationInstance);

        //
        //  For SendTestIndicationSubclass,
        //  SendTestIndicationMatchingInstance,
        //  SendTestIndicationUnmatchingNamespace or
        //  SendTestIndicationUnmatchingClassName, include
        //  SubscriptionInstanceNamesContainer in operation context
        //
        if ((methodName.equal ("SendTestIndicationSubclass")) ||
            (methodName.equal ("SendTestIndicationMatchingInstance")) ||
            (methodName.equal ("SendTestIndicationUnmatchingNamespace")) ||
            (methodName.equal ("SendTestIndicationUnmatchingClassName")))
        {
            Array <CIMObjectPath> subscriptionInstanceNames;
            Array <CIMKeyBinding> subscriptionKeyBindings;

            String filterString;
            filterString.append ("CIM_IndicationFilter.CreationClassName=\"CIM_IndicationFilter\",Name=\"PIFilter01\",SystemCreationClassName=\"");
            filterString.append (System::getSystemCreationClassName ());
            filterString.append ("\",SystemName=\"");
            filterString.append (System::getFullyQualifiedHostName ());
            filterString.append ("\"");
            subscriptionKeyBindings.append (CIMKeyBinding ("Filter",
                filterString, CIMKeyBinding::REFERENCE));

            String handlerString;
            handlerString.append ("CIM_IndicationHandlerCIMXML.CreationClassName=\"CIM_IndicationHandlerCIMXML\",Name=\"PIHandler01\",SystemCreationClassName=\"");
            handlerString.append (System::getSystemCreationClassName ());
            handlerString.append ("\",SystemName=\"");
            handlerString.append (System::getFullyQualifiedHostName ());
            handlerString.append ("\"");
            subscriptionKeyBindings.append (CIMKeyBinding ("Handler",
                handlerString, CIMKeyBinding::REFERENCE));

            CIMObjectPath subscriptionPath ("",
                CIMNamespaceName ("root/PG_InterOp"),
                CIMName ("CIM_IndicationSubscription"),
                subscriptionKeyBindings);
            subscriptionInstanceNames.append (subscriptionPath);

	    OperationContext context;
            context.insert (SubscriptionInstanceNamesContainer
                (subscriptionInstanceNames));

            handler->deliver (context, indicationInstance);
        }
        else
        {
	    // deliver an indication without trapOid
            handler->deliver (indicationInstance);
        }

        //
        //  Only deliver extra indication with trapOid for SendTestIndication
        //
        if ((!methodName.equal ("SendTestIndicationNormal")) &&
            (!methodName.equal ("SendTestIndicationSubclass")) &&
            (!methodName.equal ("SendTestIndicationMissingProperty")) &&
            (!methodName.equal ("SendTestIndicationExtraProperty")) &&
            (!methodName.equal ("SendTestIndicationMatchingInstance")) &&
            (!methodName.equal ("SendTestIndicationUnmatchingNamespace")) &&
            (!methodName.equal ("SendTestIndicationUnmatchingClassName")))
        {
	    // deliver another indication with a trapOid which contains in the
	    // operationContext container
	    OperationContext context;

 	    // add trap OID to the context
	    context.insert
                (SnmpTrapOidContainer("1.3.6.1.4.1.900.2.3.9002.9600"));
            handler->deliver (context, indicationInstance);
        }
    }
}
Пример #4
0
    static CMPIStatus mbDeliverIndication(
        const CMPIBroker* eMb,
        const CMPIContext* ctx,
        const char *ns,
        const CMPIInstance* ind)
    {
        PEG_METHOD_ENTER(
            TRC_CMPIPROVIDERINTERFACE,
            "CMPI_Broker:mbDeliverIndication()");
        eMb = CM_BROKER;
        CMPI_Broker *mb = (CMPI_Broker*)eMb;
        IndProvRecord *indProvRec;
        OperationContext* context = CM_Context(ctx);

        SCMOInstance* scmoInst = SCMO_Instance(ind);
        CIMInstance indInst;
        scmoInst->getCIMInstance(indInst);

        // When an indication to be delivered comes from Remote providers,
        // the CMPIBroker contains the name of the provider in the form
        // of physical-name:logical-name. Search using logical-name. -V 5884
        String provider_name;
        CMPIUint32 n;

        if ( (n = mb->name.find(':') ) != PEG_NOT_FOUND)
        {
            provider_name = mb->name.subString (n + 1);
        }
        else
        {
            provider_name = mb->name;
        }
        ReadLock readLock(CMPIProviderManager::rwSemProvTab);
        if (CMPIProviderManager::indProvTab.lookup(provider_name, indProvRec))
        {
            if (indProvRec->isEnabled())
            {
                try
                {
                    context->get(SubscriptionInstanceNamesContainer::NAME);
                }
                catch (const Exception &e)
                {
                    PEG_TRACE((TRC_CMPIPROVIDERINTERFACE,Tracer::LEVEL1,
                        "Exception: %s",
                        (const char*)e.getMessage().getCString()));
                    Array<CIMObjectPath> subscriptionInstanceNames;
                    context->insert(
                        SubscriptionInstanceNamesContainer(
                            subscriptionInstanceNames));
                }
                CIMIndication cimIndication(indInst);
                try
                {
                    indProvRec->getHandler()->deliver(
                        *context,
   //                   OperationContext(*CM_Context(ctx)),
                        cimIndication);
                    PEG_METHOD_EXIT();
                    CMReturn(CMPI_RC_OK);
                }
                HandlerCatchReturnStatus();
            }
        }
        PEG_METHOD_EXIT();
        CMReturn(CMPI_RC_ERR_FAILED);
    }