ClRcT
clCompAppAMFPrintCSI(
    ClAmsCSIDescriptorT csiDescriptor,
    ClAmsHAStateT haState)
{
    clprintf ("   CSI                     : %s\n", 
            csiDescriptor.csiName.value);
    clprintf ("   HA State                : %s\n",
            STRING_HA_STATE(haState));
    clprintf ("   CSI Flags               : 0x%x\n",
            csiDescriptor.csiFlags);
    clprintf ("   Active Descriptor       : \n");
    clprintf ("       Active Component    : %s\n",
        csiDescriptor.csiStateDescriptor.activeDescriptor.activeCompName.value);
    clprintf ("   Standby Descriptor      : \n");
    clprintf ("       Standby Rank        : %d\n",
        csiDescriptor.csiStateDescriptor.standbyDescriptor.standbyRank);
    clprintf ("       Active Component    : %s\n",
        csiDescriptor.csiStateDescriptor.standbyDescriptor.activeCompName.value);

    clprintf ("   Name Value Pairs        : \n");
    for (ClUint32T i = 0; i < csiDescriptor.csiAttributeList.numAttributes; i++)
    {
        clprintf ("       Name            : %s\n",
                csiDescriptor.csiAttributeList.attribute[i].attributeName);
        clprintf ("       Value           : %s\n",
                csiDescriptor.csiAttributeList.attribute[i].attributeValue);
    }

    return CL_OK;
}
void clCompAppAMFPrintCSI(SaAmfCSIDescriptorT csiDescriptor,
                          SaAmfHAStateT haState)
{
    clprintf (CL_LOG_SEV_INFO,
              "CSI Flags : [%s]",
              STRING_CSI_FLAGS(csiDescriptor.csiFlags));

    if (SA_AMF_CSI_TARGET_ALL != csiDescriptor.csiFlags)
    {
        clprintf (CL_LOG_SEV_INFO, "CSI Name : [%s]",
                  csiDescriptor.csiName.value);
    }

    if (SA_AMF_CSI_ADD_ONE == csiDescriptor.csiFlags)
    {
        ClUint32T i = 0;

        clprintf (CL_LOG_SEV_INFO, "   Name Value Pairs        : \n");
        for (i = 0; i < csiDescriptor.csiAttr.number; i++)
        {
            clprintf (CL_LOG_SEV_INFO, "Name : [%s]",
                      csiDescriptor.csiAttr.
                      attr[i].attrName);
            clprintf (CL_LOG_SEV_INFO, "Value : [%s]",
                      csiDescriptor.csiAttr.
                      attr[i].attrValue);
        }
    }

    clprintf (CL_LOG_SEV_INFO, "HA state : [%s]",
              STRING_HA_STATE(haState));

    if (SA_AMF_HA_ACTIVE == haState)
    {
        clprintf (CL_LOG_SEV_INFO, "Active Descriptor :");
        clprintf (CL_LOG_SEV_INFO,
                  "Transition Descriptor : [%d]",
                  csiDescriptor.csiStateDescriptor.
                  activeDescriptor.transitionDescriptor);
        clprintf (CL_LOG_SEV_INFO,
                  "Active Component : [%s]",
                  csiDescriptor.csiStateDescriptor.
                  activeDescriptor.activeCompName.value);
    }
    else if (SA_AMF_HA_STANDBY == haState)
    {
        clprintf (CL_LOG_SEV_INFO, "Standby Descriptor :");
        clprintf (CL_LOG_SEV_INFO,
                  "Standby Rank : [%d]",
                  csiDescriptor.csiStateDescriptor.
                  standbyDescriptor.standbyRank);
        clprintf (CL_LOG_SEV_INFO, "Active Component : [%s]",
                  csiDescriptor.csiStateDescriptor.
                  standbyDescriptor.activeCompName.value);
    }

}
ClRcT clCompAppAMFPrintCSI(ClAmsCSIDescriptorT csiDescriptor,
                           ClAmsHAStateT haState)
{
    clprintf ("   CSI Flags               : [%s]\n",
              STRING_CSI_FLAGS(csiDescriptor.csiFlags));

    if (CL_AMS_CSI_FLAG_TARGET_ALL != csiDescriptor.csiFlags)
    {
        clprintf ("   CSI Name                : [%s]\n", 
                  csiDescriptor.csiName.value);
    }

    if (CL_AMS_CSI_FLAG_ADD_ONE & csiDescriptor.csiFlags)
    {
        ClUint32T i = 0;
        
        clprintf ("   Name Value Pairs        : \n");
        for (i = 0; i < csiDescriptor.csiAttributeList.numAttributes; i++)
        {
            clprintf ("       Name            : [%s]\n",
                      csiDescriptor.csiAttributeList.
                      attribute[i].attributeName);
            clprintf ("       Value           : [%s]\n",
                      csiDescriptor.csiAttributeList.
                      attribute[i].attributeValue);
        }
    }
    
    clprintf ("   HA State                : [%s]\n",
              STRING_HA_STATE(haState));

    if (CL_AMS_HA_STATE_ACTIVE == haState)
    {
        clprintf ("   Active Descriptor       : \n");
        clprintf ("     Transition Descriptor : [%d]\n",
                  csiDescriptor.csiStateDescriptor.
                  activeDescriptor.transitionDescriptor);
        clprintf ("       Active Component    : [%s]\n",
                  csiDescriptor.csiStateDescriptor.
                  activeDescriptor.activeCompName.value);
    }
    else if (CL_AMS_HA_STATE_STANDBY == haState)
    {
        clprintf ("   Standby Descriptor      : \n");
        clprintf ("       Standby Rank        : [%d]\n",
                  csiDescriptor.csiStateDescriptor.
                  standbyDescriptor.standbyRank);
        clprintf ("       Active Component    : [%s]\n",
                  csiDescriptor.csiStateDescriptor.
                  standbyDescriptor.activeCompName.value);
    }

    return CL_OK;
}
static PyObject* GetWorkOnNode(PyObject *self, PyObject *args)
{
  char buf[32*1024];
  const int bufLen = sizeof(buf);
  int curLen = 0;
  ClRcT rc;
  ClAmsEntityBufferT suList,csiList;
  const char* arg0=NULL;
  ClAmsMgmtHandleT hdl = amsHandle;
  unsigned int suit;
  unsigned int siit;
  unsigned int csiit;
  unsigned int nvpit;
  
  DbgLog("GetWorkOnNode");

  if (!hdl)
    {
      PyErr_SetString(PyExc_SystemError,"AMF Handle not initialized");
      return NULL;
    }
  DbgLog("GetWorkOnNode handle ok");

  if (!PyArg_ParseTuple(args, "s", &arg0))
        return NULL;
  DbgLog("GetWorkOnNode arg is: %s",arg0);

  ClAmsEntityT node;
  node.type = CL_AMS_ENTITY_TYPE_NODE;
  clNameSet(&node.name, arg0);
  node.name.length+=1;

  curLen += snprintf(buf+curLen, bufLen-curLen, "{");
  DbgLog("GetWorkOnNode 0");

  suList.entity = NULL;
  rc = clAmsMgmtGetNodeSUList(hdl, &node, &suList);
  if (CL_GET_ERROR_CODE(rc) == CL_ERR_NOT_EXIST)
    {
      sprintf(buf,"Node %s does not exist",arg0);
      PyObject* errData = Py_BuildValue("is",rc,buf);
      PyErr_SetObject(PyExc_KeyError,errData);
      //PyErr_SetString(PyExc_KeyError,buf);
      return NULL;
    }
  else if (rc != CL_OK)
    {
      sprintf(buf,"clAmsMgmtGetNode error 0x%x",rc);
      //PyErr_SetString(PyExc_SystemError,buf);
      PyObject* errData = Py_BuildValue("is",rc,buf);
      PyErr_SetObject(PyExc_SystemError,errData);
      return NULL;
    }
  DbgLog("1");
  for (suit = 0; suit< suList.count; suit++)
  {
      curLen += snprintf(buf+curLen, bufLen-curLen, "%s'%.*s':{",(suit==0) ? "":",", suList.entity[suit].name.length,suList.entity[suit].name.value);
      DbgLog("2: %s", buf);

      ClAmsSUSIRefBufferT siList;
      siList.entityRef = NULL;
      rc =  clAmsMgmtGetSUAssignedSIsList(hdl, &suList.entity[suit],&siList); 
      DbgLog("3: %s", buf);
      if (rc == CL_OK)
      {
          
          for (siit = 0; siit < siList.count; siit++)
          {
              ClAmsSUSIRefT* si = &siList.entityRef[siit];
              ClAmsEntityT*  siEnt = &si->entityRef.entity;

              csiList.entity = NULL;
              rc = clAmsMgmtGetSICSIList(hdl, siEnt, &csiList);
              DbgLog("4: %s", buf);

              curLen += snprintf(buf+curLen, bufLen-curLen, "%s'%.*s':{",(siit==0) ? "":",", siEnt->name.length,siEnt->name.value);
              curLen += snprintf(buf+curLen, bufLen-curLen, "'csiHaState':'%s'", STRING_HA_STATE(si->haState));
          
              if (rc == CL_OK)
              {
                  for (csiit = 0; csiit < csiList.count; csiit++)
                  {
                      ClAmsCSINVPBufferT  nvpList;
                      nvpList.nvp = NULL;
                      rc = clAmsMgmtGetCSINVPList(hdl, &csiList.entity[csiit],&nvpList);
                      if (rc==CL_OK)
                      {                  
                          DbgLog("5: %s", buf);
                          for (nvpit = 0; nvpit < nvpList.count; nvpit++)
                          {
                              ClAmsCSINameValuePairT* nvp = &nvpList.nvp[nvpit];
                              curLen += snprintf(buf+curLen, bufLen-curLen, "%s '%.*s':'%.*s'",(0) ? "":",",nvp->paramName.length,nvp->paramName.value,nvp->paramValue.length,nvp->paramValue.value);
                              DbgLog("6: %s", buf);

                          }
                          //curLen += snprintf(buf+curLen, bufLen-curLen, "}");
                          if (nvpList.nvp) clHeapFree(nvpList.nvp);
                      }              
                  }
                  if (csiList.entity) clHeapFree(csiList.entity);
              }
              curLen += snprintf(buf+curLen, bufLen-curLen, "}");
          
          }
          if (siList.entityRef) clHeapFree(siList.entityRef);
      }      
      curLen += snprintf(buf+curLen, bufLen-curLen, "}");
  }

  curLen += snprintf(buf+curLen, bufLen-curLen, "}");
  if (suList.entity) clHeapFree(suList.entity);

  clAppLog(CL_LOG_HANDLE_APP, CL_LOG_SEV_INFO, 10, CL_LOG_AREA_UNSPECIFIED, CL_LOG_CONTEXT_UNSPECIFIED,
           "AmfDump: %s", buf);
  PyObject* ret = PyRun_String(buf,Py_eval_input,emptyDict,emptyDict);
  return ret;
}
void safAssignWork(SaInvocationT       invocation,
                   const SaNameT       *compName,
                   SaAmfHAStateT       haState,
                   SaAmfCSIDescriptorT csiDescriptor)
{
    /* Print information about the CSI Set */

    clprintf (CL_LOG_SEV_INFO, "Component [%.*s] : PID [%d]. CSI Set Received\n", 
              compName->length, compName->value, mypid);

    printCSI(csiDescriptor, haState);

    /*
     * Take appropriate action based on state
     */

    switch ( haState )
    {
        /* AMF asks this process to take the standby HA state for the work
           described in the csiDescriptor variable */
        case SA_AMF_HA_ACTIVE:
        {
            /* Typically you would spawn a thread here to initiate active 
               processing of the work. */
            if (csiDescriptor.csiFlags == SA_AMF_CSI_TARGET_ALL)
            {
                ClRcT rc;
                ClCpmCompCSIRefT csiRef = { 0 };
                ClInt32T i;
                rc = clCpmCompCSIList((SaNameT *)compName, &csiRef);
                if(rc != CL_OK)
                {
                    clLogError("APP", "CSISET", "Comp CSI get returned [%#x]", rc);
                }
                 else
                 {
                      for(i = 0; i < csiRef.numCSIs; ++i)
                      {
                         VirtualIpAddress temp;
                         ClCpmCompCSIT *pCSI = &csiRef.pCSIList[i];

                         clprintf(CL_LOG_SEV_INFO,"Comp [%s], CSI [%s], HA state [%s]",
                             (const char*)compName->value,
                             (const char*)pCSI->csiDescriptor.csiName.value,
                             STRING_HA_STATE((ClUint32T)pCSI->haState));

                         GetVirtualAddressInfoAsp(&pCSI->csiDescriptor, &temp);
                         AddRemVirtualAddress("up",&temp);

                     }
                     if(csiRef.pCSIList)
                       clHeapFree(csiRef.pCSIList);
                }
            }
            else /* SA_AMF_CSI_ADD_ONE */
            {
                 GetVirtualAddressInfo(&csiDescriptor, &gVirtualIp);
                 AddRemVirtualAddress("up",&gVirtualIp);
            }

            /* The AMF times the interval between the assignment and acceptance
               of the work (the time interval is configurable).
               So it is important to call this saAmfResponse function ASAP.
             */
            saAmfResponse(amfHandle, invocation, SA_AIS_OK);
            break;
        }

        /* AMF asks this process to take the standby HA state for the work
           described in the csiDescriptor variable */
        case SA_AMF_HA_STANDBY:
        {
            /* If your standby has ongoing maintenance, you would spawn a thread
               here to do it. */

            /* The AMF times the interval between the assignment and acceptance
               of the work (the time interval is configurable).
               So it is important to call this saAmfResponse function ASAP.
             */
            GetVirtualAddressInfo(&csiDescriptor, &gVirtualIp);
            AddRemVirtualAddress("down",&gVirtualIp);  /* Bring it down just in case it is up from a prior run */
            saAmfResponse(amfHandle, invocation, SA_AIS_OK);  
            break;
        }

        case SA_AMF_HA_QUIESCED:
        {
            /*
             * AMF has requested application to quiesce the CSI currently
             * assigned the active or quiescing HA state. The application 
             * must stop work associated with the CSI immediately.
             */
            if (csiDescriptor.csiFlags == SA_AMF_CSI_TARGET_ONE)
            {
                AddRemVirtualAddress("down",&gVirtualIp);
            }           
            else if (csiDescriptor.csiFlags == SA_AMF_CSI_TARGET_ALL)
            {                
                ClRcT rc;
                ClCpmCompCSIRefT csiRef = { 0 };
                ClInt32T i;
                rc = clCpmCompCSIList((SaNameT *)compName, &csiRef);
                if(rc != CL_OK)
                {
                    clLogError("APP", "CSISET", "Comp CSI get returned [%#x]", rc);
                }
                else
                {
                    for(i = 0; i < csiRef.numCSIs; ++i)
                    {
                        VirtualIpAddress temp;
                        ClCpmCompCSIT *pCSI = &csiRef.pCSIList[i];

                        clprintf(CL_LOG_SEV_INFO,"Comp [%s ], CSI [%s], HA state [%s]",
                                compName->value, 
                                pCSI->csiDescriptor.csiName.value,
                                STRING_HA_STATE((ClUint32T)pCSI->haState));

                        GetVirtualAddressInfoAsp(&pCSI->csiDescriptor, &temp);
                        AddRemVirtualAddress("down",&temp);

                    }
                    if(csiRef.pCSIList)
                    clHeapFree(csiRef.pCSIList);
                }
            }
            else /* SA_AMF_CSI_ADD_ONE */
            {
                VirtualIpAddress temp;
                GetVirtualAddressInfo(&csiDescriptor, &temp);
                AddRemVirtualAddress("down",&temp);
            }
            saAmfResponse(amfHandle, invocation, SA_AIS_OK);
            break;
        }

        case SA_AMF_HA_QUIESCING:
        {
            /*
             * AMF has requested application to quiesce the CSI currently
             * assigned the active HA state. The application must stop work
             * associated with the CSI gracefully and not accept any new
             * workloads while the work is being terminated.
             */

            /* There are two typical cases for quiescing.  Chooose one!
               CASE 1: Its possible to quiesce rapidly within this thread context */
            if (1)
              {
              /* App code here: Now finish your work and cleanly stop the work*/
            
              /* Call saAmfCSIQuiescingComplete when stopping the work is done */
              saAmfCSIQuiescingComplete(amfHandle, invocation, SA_AIS_OK);
              }
            else
              {
              /* CASE 2: You can't quiesce within this thread context or quiesce
               rapidly. */

              /* Respond immediately to the quiescing request */
              saAmfResponse(amfHandle, invocation, SA_AIS_OK);

              /* App code here: Signal or spawn a thread to cleanly stop the work*/
              /* When that thread is done, it should call:
                 saAmfCSIQuiescingComplete(amfHandle, invocation, SA_AIS_OK);
              */
              }

            break;
        }

        default:
        {
            assert(0);
            break;
        }
    }

    return;
}
static int clCreateCsiPython(char* s, int maxLen, const SaNameT* compName, SaAmfCSIDescriptorT* csiDescriptor, SaAmfHAStateT haState)
{
  //  #define maxLen 2048
  //  char s[maxLen];
  int curlen = 0;

  //snprintf(s+curlen,maxLen-curlen,"csi = { 'flags':'0' }\n"); 

  curlen += snprintf (s+curlen,maxLen-curlen, "{ 'csiFlags':'%s'",STRING_CSI_FLAGS(csiDescriptor->csiFlags));

  curlen += snprintf (s+curlen,maxLen-curlen, ", 'csiHaState':'%s' ",STRING_HA_STATE(haState));

  if (CL_AMS_CSI_FLAG_TARGET_ALL != csiDescriptor->csiFlags)
    {
      curlen += snprintf (s+curlen,maxLen-curlen, ", 'csiName':'%s' ", csiDescriptor->csiName.value);
    }

  if ((CL_AMS_CSI_FLAG_ADD_ONE == csiDescriptor->csiFlags) || (CL_AMS_CSI_FLAG_TARGET_ONE == csiDescriptor->csiFlags))
    {
      ClUint32T i = 0;
        
      //clprintf (CL_LOG_SEV_INFO, "   Name Value Pairs        : \n");
      for (i = 0; i < csiDescriptor->csiAttr.number; i++)
        {
          curlen += snprintf (s+curlen,maxLen-curlen, ", '%s':'%s' ", csiDescriptor->csiAttr.attr[i].attrName, csiDescriptor->csiAttr.attr[i].attrValue);
        }

      if (0)  
        {
          ClRcT rc;
          ClCpmCompCSIRefT csiRef = { 0 };
          unsigned int i,j;
          ClNameT clcName;
          
          clprintf(CL_LOG_SEV_INFO,"New CODE");

          strncpy (clcName.value, (ClCharT*) compName->value,compName->length);
          clcName.length = compName->length;
          clcName.value[clcName.length]=0;

          rc = clCpmCompCSIList(&clcName, &csiRef);
          if(rc != CL_OK)
            {
              clLogError("APP", "CSISET", "Comp CSI get returned [%#x]", rc);
            }
          else
            {
              for(i = 0; i < csiRef.numCSIs; ++i)
                {
                  ClCpmCompCSIT *pCSI = &csiRef.pCSIList[i];
                  clprintf(CL_LOG_SEV_INFO,"me: [%.*s] compared: [%.*s]",csiDescriptor->csiName.length,csiDescriptor->csiName.value, pCSI->csiDescriptor.csiName.length, pCSI->csiDescriptor.csiName.value);
                  if (strncmp((char*)csiDescriptor->csiName.value,(char*)pCSI->csiDescriptor.csiName.value,csiDescriptor->csiName.length)==0)
                    {
                      ClAmsCSIDescriptorT* cd = &pCSI->csiDescriptor;
                      for (j = 0; j < cd->csiAttributeList.numAttributes; j++)
                        {
                          curlen += snprintf (s+curlen,maxLen-curlen, ", '%s':'%s' ", cd->csiAttributeList.attribute[j].attributeName, cd->csiAttributeList.attribute[j].attributeValue);
                          clprintf(CL_LOG_SEV_INFO,s);
                        }
                   }
                }
              if(csiRef.pCSIList)
                clHeapFree(csiRef.pCSIList);
            }
        }
    }
    

  if (SA_AMF_HA_ACTIVE == haState)
    {
      curlen += snprintf (s+curlen,maxLen-curlen, ", 'csiTransitionDescriptor':'%d' ", (int) csiDescriptor->csiStateDescriptor.activeDescriptor.transitionDescriptor);
      curlen += snprintf (s+curlen,maxLen-curlen, ", 'csiActiveComponent':'%s' ", csiDescriptor->csiStateDescriptor.activeDescriptor.activeCompName.value);
    }
  else if (SA_AMF_HA_STANDBY == haState)
    {
      curlen += snprintf (s+curlen,maxLen-curlen, ", 'csiStandbyRank':'%d' ", (int) csiDescriptor->csiStateDescriptor.standbyDescriptor.standbyRank);
      curlen += snprintf (s+curlen,maxLen-curlen, ", 'csiActiveComponent':'%s' ", csiDescriptor->csiStateDescriptor.activeDescriptor.activeCompName.value);
    }


  curlen += snprintf (s+curlen,maxLen-curlen, "}");

  //clprintf (CL_LOG_SEV_INFO, "%s",s);
  //clRunPython(s);

  return curlen;

}
void clCompAppAMFCSISet(SaInvocationT       invocation,
                        const SaNameT       *compName,
                        SaAmfHAStateT       haState,
                        SaAmfCSIDescriptorT csiDescriptor)
{
    /*
     * Print information about the CSI Set
     */

    clprintf (CL_LOG_SEV_INFO, "Component [%.*s] : PID [%d]. CSI Set Received\n", 
              compName->length, compName->value, mypid);

    clCompAppAMFPrintCSI(csiDescriptor, haState);

    /*
     * Take appropriate action based on state
     */

    switch ( haState )
    {
        case SA_AMF_HA_ACTIVE:
        {
            /*
             * AMF has requested application to take the active HA state 
             * for the CSI.
             */

            if (csiDescriptor.csiFlags == CL_AMS_CSI_FLAG_TARGET_ALL)
              {
                ClRcT rc;
                ClCpmCompCSIRefT csiRef = { 0 };
                ClInt32T i;
                rc = clCpmCompCSIList((SaNameT*)compName, &csiRef);
                if(rc != CL_OK)
                  {
                    clLogError("APP", "CSISET", "Comp CSI get returned [%#x]", rc);
                  }
                else
                  {
                    for(i = 0; i < csiRef.numCSIs; ++i)
                      {
                        VirtualIpAddress temp;
                        ClCpmCompCSIT *pCSI = &csiRef.pCSIList[i];
                        clprintf(CL_LOG_SEV_INFO,"Comp [%.*s], CSI [%.*s], HA state [%s]",
                                 compName->length,
                                 compName->value, 
                                 pCSI->csiDescriptor.csiName.length,
                                 pCSI->csiDescriptor.csiName.value,
                                 STRING_HA_STATE((ClUint32T)pCSI->haState));

                        GetVirtualAddressInfoAsp(&pCSI->csiDescriptor, &temp);
                        AddRemVirtualAddress("up",&temp);

                      }
                    if(csiRef.pCSIList)
                      clHeapFree(csiRef.pCSIList);
                  }
              }
            else /* CL_AMS_CSI_FLAG_ADD_ONE */
              {
            	GetVirtualAddressInfo(&csiDescriptor, &gVirtualIp);
                AddRemVirtualAddress("up",&gVirtualIp);
              }

            saAmfResponse(amfHandle, invocation, SA_AIS_OK);
            break;
        }

        case SA_AMF_HA_STANDBY:
        {
            /*
             * AMF has requested application to take the standby HA state 
             * for this CSI.
             */

        	GetVirtualAddressInfo(&csiDescriptor, &gVirtualIp);
            AddRemVirtualAddress("down",&gVirtualIp);  /* Bring it down just in case it is up from a prior run */

            saAmfResponse(amfHandle, invocation, SA_AIS_OK);
            break;
        }

        case SA_AMF_HA_QUIESCED:
        {
            /*
             * AMF has requested application to quiesce the CSI currently
             * assigned the active or quiescing HA state. The application 
             * must stop work associated with the CSI immediately.
             */

              if (csiDescriptor.csiFlags == CL_AMS_CSI_FLAG_TARGET_ONE)
                {
                  AddRemVirtualAddress("down",&gVirtualIp);
                }           
              else if (csiDescriptor.csiFlags == CL_AMS_CSI_FLAG_TARGET_ALL)
              {                
                ClRcT rc;
                ClCpmCompCSIRefT csiRef = { 0 };
                ClInt32T i;
                rc = clCpmCompCSIList((SaNameT*)compName, &csiRef);
                if(rc != CL_OK)
                  {
                    clLogError("APP", "CSISET", "Comp CSI get returned [%#x]", rc);
                  }
                else
                  {
                    for(i = 0; i < csiRef.numCSIs; ++i)
                      {
                        VirtualIpAddress temp;
                        ClCpmCompCSIT *pCSI = &csiRef.pCSIList[i];

                        clprintf(CL_LOG_SEV_INFO,"Comp [%.*s], CSI [%.*s], HA state [%s]",
                                    compName->length,
                                    compName->value, 
                                    pCSI->csiDescriptor.csiName.length,
                                    pCSI->csiDescriptor.csiName.value,
                                    STRING_HA_STATE((ClUint32T)pCSI->haState));

                        GetVirtualAddressInfoAsp(&pCSI->csiDescriptor, &temp);
                        AddRemVirtualAddress("down",&temp);

                      }
                    if(csiRef.pCSIList)
                      clHeapFree(csiRef.pCSIList);
                  }
              }
              else /* CL_AMS_CSI_FLAG_ADD_ONE */
                {
                  VirtualIpAddress temp;
                  GetVirtualAddressInfo(&csiDescriptor, &temp);
                  AddRemVirtualAddress("down",&temp);
                }

            saAmfResponse(amfHandle, invocation, SA_AIS_OK);
            break;
        }

        case SA_AMF_HA_QUIESCING:
        {
            /*
             * AMF has requested application to quiesce the CSI currently
             * assigned the active HA state. The application must stop work
             * associated with the CSI gracefully and not accept any new
             * workloads while the work is being terminated.
             */

            saAmfCSIQuiescingComplete(amfHandle, invocation, SA_AIS_OK);
            break;
        }

        default:
        {
            assert(0);
            break;
        }
    }

    return;
}