locked
How to synchronize SCOM pragmatically by Service Manager SDK RRS feed

  • Question

  • This is our attempt:

                    IList<Microsoft.EnterpriseManagement.ConnectorFramework.EnterpriseManagementConnector> list = smg.ConnectorFramework.GetConnectors();
                    foreach (EnterpriseManagementConnector conn in list) {
                       if (conn.DisplayName.Equals(%SCOM_NAME%))
                       {
                           smg.LinkingFramework.SyncNow(conn.Id);
                       }

    But when SyncNow is invoked, SCSM raised an error:

     Microsoft.EnterpriseManagement.LinkingFramework.LinkingFrameworkRemotingException: Server request failed for command 1. The data source GUID is not valid: %Connector ID%
       at Microsoft.EnterpriseManagement.LinkingFramework.LinkingFrameworkServerRequest.LinkingFrameworkRequest(Int32 commandId, ResultSet values)
       at Microsoft.EnterpriseManagement.ServiceDataLayer.LinkingFrameworkService.LfxServerRequest(Int32 commandId, ResultSet values)

     

    I'm very confused, because the Connector ID is absolutely correct according to database. So, What kind of Connector ID it would take?

    Anybody gives me a hint?

    Tuesday, June 21, 2011 8:36 AM

Answers


  • Try something like this: 

    IList<Microsoft.EnterpriseManagement.ConnectorFramework.EnterpriseManagementConnector> list = smg.ConnectorFramework.GetConnectors();
    foreach (EnterpriseManagementConnector conn in list) 
    {
      if (conn.DisplayName.Equals(%SCOM_NAME%))
      {
       ManagementPackTaskCriteria criteria = new ManagementPackTaskCriteria(string.Format(CultureInfo.InvariantCulture, "Name='{0}'", new object[] { conn.Name + "_SyncNowTask" }));
       ManagementPackTask task = smg.TaskConfiguration.GetTasks(criteria)[0];
       if (task.Enabled)
       {
         guid = smg.TaskRuntime.SubmitTask(conn.ConnectorObject, task, new TaskConfiguration());
         Thread.Sleep(15000);
         IList<TaskResult> list = smg.TaskRuntime.GetTaskResultsByBatchId(guid);
         if(list[0].Status != TaskStatus.Failed)
          //it's OK
       }
      }
    }
    

     


    http://opsmgr.ru
    • Marked as answer by Rarara2011 Wednesday, June 22, 2011 4:25 AM
    Tuesday, June 21, 2011 6:19 PM
  • Or more simple

    IList<Microsoft.EnterpriseManagement.ConnectorFramework.EnterpriseManagementConnector> list = smg.ConnectorFramework.GetConnectors();
    foreach (EnterpriseManagementConnector conn in list) 
    {
     if (conn.DisplayName.Equals(%SCOM_NAME%))
     {
       Microsoft.EnterpriseManagement.ServiceManager.Connectors.OpsMgr.OpsMgrConnectorHelper opsHelper = new Microsoft.EnterpriseManagement.ServiceManager.Connectors.OpsMgr.OpsMgrConnectorHelper(smg);
       if(opsHelper.SyncNow(conn.Name))
        // it's OK
    
     }

     


    http://opsmgr.ru
    • Marked as answer by Rarara2011 Wednesday, June 22, 2011 4:25 AM
    Tuesday, June 21, 2011 6:28 PM

All replies


  • Try something like this: 

    IList<Microsoft.EnterpriseManagement.ConnectorFramework.EnterpriseManagementConnector> list = smg.ConnectorFramework.GetConnectors();
    foreach (EnterpriseManagementConnector conn in list) 
    {
      if (conn.DisplayName.Equals(%SCOM_NAME%))
      {
       ManagementPackTaskCriteria criteria = new ManagementPackTaskCriteria(string.Format(CultureInfo.InvariantCulture, "Name='{0}'", new object[] { conn.Name + "_SyncNowTask" }));
       ManagementPackTask task = smg.TaskConfiguration.GetTasks(criteria)[0];
       if (task.Enabled)
       {
         guid = smg.TaskRuntime.SubmitTask(conn.ConnectorObject, task, new TaskConfiguration());
         Thread.Sleep(15000);
         IList<TaskResult> list = smg.TaskRuntime.GetTaskResultsByBatchId(guid);
         if(list[0].Status != TaskStatus.Failed)
          //it's OK
       }
      }
    }
    

     


    http://opsmgr.ru
    • Marked as answer by Rarara2011 Wednesday, June 22, 2011 4:25 AM
    Tuesday, June 21, 2011 6:19 PM
  • Or more simple

    IList<Microsoft.EnterpriseManagement.ConnectorFramework.EnterpriseManagementConnector> list = smg.ConnectorFramework.GetConnectors();
    foreach (EnterpriseManagementConnector conn in list) 
    {
     if (conn.DisplayName.Equals(%SCOM_NAME%))
     {
       Microsoft.EnterpriseManagement.ServiceManager.Connectors.OpsMgr.OpsMgrConnectorHelper opsHelper = new Microsoft.EnterpriseManagement.ServiceManager.Connectors.OpsMgr.OpsMgrConnectorHelper(smg);
       if(opsHelper.SyncNow(conn.Name))
        // it's OK
    
     }

     


    http://opsmgr.ru
    • Marked as answer by Rarara2011 Wednesday, June 22, 2011 4:25 AM
    Tuesday, June 21, 2011 6:28 PM
  • Thank you very much, Anton.

    By the way, where could I get the documentation of OpsMgr classes? I googled it, but got nothing.

    Would you give some tips?

    Wednesday, June 22, 2011 4:25 AM
  • Do you talk about OpsMgr SDK?
    http://opsmgr.ru
    Wednesday, June 22, 2011 6:58 AM