void setProjectEnumValues(ref CreatableEnterpriseManagementObject cemoProject, ManagementPackClass mpcProject, PublishedProject project) { //set object status //Active (System.Library) (System.ConfigItem.ObjectStatusEnum.Active) (acdcedb7-100c-8c91-d664-4629a218bd94) cemoProject[mpcProject, "ObjectStatus"].Value = emg.EntityTypes.GetEnumeration(new Guid("acdcedb7-100c-8c91-d664-4629a218bd94")); //Project Status (Cireson.ProjectAutomation.Library) (Cireson.ProjectAutomation.ProjectStatusEnum) (3dbbdf0b-9b1e-1fbf-26f7-b09743fb5604) IList <ManagementPackEnumeration> projectStatusEnums = emg.EntityTypes.GetChildEnumerations(new Guid("3dbbdf0b-9b1e-1fbf-26f7-b09743fb5604"), TraversalDepth.OneLevel); //set project status //Completed (Cireson.ProjectAutomation.Library) (Cireson.ProjectAutomation.ProjectStatusEnum.Completed) (08cbcd28-a84a-67fe-ce4b-4be2c5320b2a) //In Progress (Cireson.ProjectAutomation.Library) (Cireson.ProjectAutomation.ProjectStatusEnum.InProgress) (0e5da073-9d56-c418-a05b-4026bfdfe8b0) //New (Cireson.ProjectAutomation.Library) (Cireson.ProjectAutomation.ProjectStatusEnum.New) (fec278c4-3761-1283-d4a6-6ca13320fe0e) if ((bool)emoSettings[null, "IsNewStatus"].Value && project.PercentComplete == 0) { cemoProject[mpcProject, "ProjectStatus"].Value = projectStatusEnums.First(mpe => mpe.Name == "Cireson.ProjectAutomation.ProjectStatusEnum.New"); } if ((bool)emoSettings[null, "IsInProgressStatus"].Value && (project.PercentComplete != 0 && project.PercentComplete != 100)) { cemoProject[mpcProject, "ProjectStatus"].Value = projectStatusEnums.First(mpe => mpe.Name == "Cireson.ProjectAutomation.ProjectStatusEnum.InProgress"); } if ((bool)emoSettings[null, "IsCompletedStatus"].Value && project.PercentComplete == 100) { cemoProject[mpcProject, "ProjectStatus"].Value = projectStatusEnums.First(mpe => mpe.Name == "Cireson.ProjectAutomation.ProjectStatusEnum.Completed"); } }
/// <summary> /// Default Constructor /// </summary> /// <param name="SyncFailoverGroupKey"></param> /// <param name="PartitionName"></param> public Partition(string SyncFailoverGroupKey, string PartitionName) { // Create Partition Management Pack Class ManagementPackClass mpc_Partition = SCOM.GetManagementPackClass("AP.F5.LTM.Partition"); // Create New NetworkInterface Object SCOM_Object = new CreatableEnterpriseManagementObject(SCOM.m_managementGroup, mpc_Partition); // Create Root Entity Class & Key Property ManagementPackClass mpc_Entity = SCOM.GetManagementPackClass("System.Entity"); ManagementPackProperty mpp_EntityDisplayName = mpc_Entity.PropertyCollection["DisplayName"]; SCOM_Object[mpp_EntityDisplayName].Value = PartitionName; // Create SyncFailoverGroup Management Pack Class & Key Property ManagementPackClass mpc_SyncFailoverGroup = SCOM.GetManagementPackClass("AP.F5.LTM.SyncFailoverGroup"); ManagementPackProperty mpp_SyncFailoverGroupKey = mpc_SyncFailoverGroup.PropertyCollection["Key"]; SCOM_Object[mpp_SyncFailoverGroupKey].Value = SyncFailoverGroupKey; // Create Properties of Partition ManagementPackProperty mpp_PartitionName = mpc_Partition.PropertyCollection["Name"]; SCOM_Object[mpp_PartitionName].Value = PartitionName; }
/// <summary> /// Default Constructor /// </summary> /// <param name="FullName">FullName of Virtual Center</param> /// <param name="Info">AboutInfo</param> public VirtualCenterSeed(string FullName) { // Get Key Property (MoRef) m_Key = FullName; // Create Virtual Center Management Pack Class ManagementPackClass mpc_VirtualCenterSeed = SCOM.GetManagementPackClass("AP.VMware.VirtualCenter.Seed"); // Create New Object SCOM_Object = new CreatableEnterpriseManagementObject(SCOM.m_managementGroup, mpc_VirtualCenterSeed); // Create Root Entity Class & Key Property ManagementPackClass mpc_Entity = SCOM.GetManagementPackClass("System.Entity"); ManagementPackProperty mpp_EntityDisplayName = mpc_Entity.PropertyCollection["DisplayName"]; SCOM_Object[mpp_EntityDisplayName].Value = FullName; // Create Properties of VirtualCenter // FullName ManagementPackProperty mpp_FullName = mpc_VirtualCenterSeed.PropertyCollection["FullName"]; SCOM_Object[mpp_FullName].Value = FullName; // ShortName ManagementPackProperty mpp_ShortName = mpc_VirtualCenterSeed.PropertyCollection["ShortName"]; SCOM_Object[mpp_ShortName].Value = FullName.Split('.')[0]; // IPAddress IPHostEntry he = Dns.GetHostEntry(FullName); ManagementPackProperty mpp_IPAddress = mpc_VirtualCenterSeed.PropertyCollection["IPAddress"]; SCOM_Object[mpp_IPAddress].Value = he.AddressList[0].ToString(); }
/// <summary> /// Default Constructor /// </summary> /// <param name="dg"></param> /// <param name="FullName"></param> /// <param name="Description"></param> /// <param name="Port"></param> /// <param name="MonitorRule"></param> public PoolMember(SyncFailoverGroup dg, string PartitionName, string PoolFullName, string FullName, string Description, string Port, string MonitorRule) { // Get ShortName string ShortName = FullName.Substring(FullName.LastIndexOf("/") + 1); // Get Partition string Partition = FullName.Substring(1, FullName.LastIndexOf("/") - 1); // Create Pool Management Pack Class ManagementPackClass mpc_PoolMember = SCOM.GetManagementPackClass("AP.F5.LTM.PoolMember"); // Create New NetworkInterface Object SCOM_Object = new CreatableEnterpriseManagementObject(SCOM.m_managementGroup, mpc_PoolMember); // Create Root Entity Class & Key Property ManagementPackClass mpc_Entity = SCOM.GetManagementPackClass("System.Entity"); ManagementPackProperty mpp_EntityDisplayName = mpc_Entity.PropertyCollection["DisplayName"]; SCOM_Object[mpp_EntityDisplayName].Value = ShortName; // Create SyncFailoverGroup Management Pack Class & Key Property ManagementPackClass mpc_SyncFailoverGroup = SCOM.GetManagementPackClass("AP.F5.LTM.SyncFailoverGroup"); ManagementPackProperty mpp_SyncFailoverGroupKey = mpc_SyncFailoverGroup.PropertyCollection["Key"]; SCOM_Object[mpp_SyncFailoverGroupKey].Value = dg.Key; // Create Partition Management Pack Class & Key Property ManagementPackClass mpc_Partition = SCOM.GetManagementPackClass("AP.F5.LTM.Partition"); ManagementPackProperty mpp_PartitionName = mpc_Partition.PropertyCollection["Name"]; SCOM_Object[mpp_PartitionName].Value = PartitionName; // Create Pool Management Pack Class ManagementPackClass mpc_Pool = SCOM.GetManagementPackClass("AP.F5.LTM.Pool"); ManagementPackProperty mpp_PoolKey = mpc_Pool.PropertyCollection["FullName"]; SCOM_Object[mpp_PoolKey].Value = PoolFullName; // Create PoolMember Management Pack Class & Properties ManagementPackProperty mpp_PoolMemberFullName = mpc_PoolMember.PropertyCollection["FullName"]; SCOM_Object[mpp_PoolMemberFullName].Value = FullName; ManagementPackProperty mpp_PoolMemberName = mpc_PoolMember.PropertyCollection["Name"]; SCOM_Object[mpp_PoolMemberName].Value = ShortName; ManagementPackProperty mpp_PoolMemberPartition = mpc_PoolMember.PropertyCollection["Partition"]; SCOM_Object[mpp_PoolMemberPartition].Value = Partition; ManagementPackProperty mpp_PoolMemberPort = mpc_PoolMember.PropertyCollection["Port"]; SCOM_Object[mpp_PoolMemberPort].Value = Port; ManagementPackProperty mpp_PoolMemberDescription = mpc_PoolMember.PropertyCollection["Description"]; SCOM_Object[mpp_PoolMemberDescription].Value = Description; ManagementPackProperty mpp_PoolMemberMonitorRule = mpc_PoolMember.PropertyCollection["MonitorRule"]; SCOM_Object[mpp_PoolMemberMonitorRule].Value = MonitorRule; ManagementPackProperty mpp_PoolMemberPoolName = mpc_PoolMember.PropertyCollection["PoolName"]; SCOM_Object[mpp_PoolMemberPoolName].Value = PoolFullName; }
void setProjectConnectorRelationship(ref CreatableEnterpriseManagementObject project) { CreatableEnterpriseManagementRelationshipObject cemroConnector = new CreatableEnterpriseManagementRelationshipObject(emg, mprRelationships.First(r => r.Name == "System.ProjectConfigItemRelatesToProjectConnector")); cemroConnector.SetSource(emoConnector); cemroConnector.SetTarget(project); iddObjects.Add(cemroConnector); }
/// <summary> /// Get Processors /// </summary> private void GetProcessors() { // Get var processors = SNMP.WalkSNMP(SNMP.sysMultiHostCpuIndex, Address, Port, Community); if (processors.Count > 0) { // Create Device Management Pack Class ManagementPackClass mpc_Device = SCOM_Functions.GetManagementPackClass("AP.F5.Device"); // Create Root Entity Class & Display Name Prop ManagementPackClass mpc_Entity = SCOM_Functions.GetManagementPackClass("System.Entity"); ManagementPackProperty mpp_EntityDisplayName = mpc_Entity.PropertyCollection["DisplayName"]; // Parent Device Key Property (IP Address) ManagementPackProperty mpp_DeviceKey = mpc_Device.PropertyCollection["DeviceName"]; // Create Processors Group Object ManagementPackClass mpc_DeviceProcessorsGroup = SCOM_Functions.GetManagementPackClass("AP.F5.Device.ProcessorsGroup"); SCOM_Object_ProcessorGroup = new CreatableEnterpriseManagementObject(m_managementGroup, mpc_DeviceProcessorsGroup); SCOM_Object_ProcessorGroup[mpp_DeviceKey].Value = SystemNodeName; // Set Key of Device ManagementPackProperty mpp_DeviceProcessorsGroupName = mpc_DeviceProcessorsGroup.PropertyCollection["Name"]; SCOM_Object_ProcessorGroup[mpp_DeviceProcessorsGroupName].Value = "Processors"; // Create Management Pack Class Objects for Processor and Needed Properties ManagementPackClass mpc_Processor = SCOM_Functions.GetManagementPackClass(className: "AP.F5.Device.Processor"); ManagementPackProperty mpp_ProcessorIndex = mpc_Processor.PropertyCollection["Index"]; ManagementPackProperty mpp_ProcessorName = mpc_Processor.PropertyCollection["Name"]; // Set Processor-Group Relationship ManagementPackRelationship mpr_ProcessorsGroup = SCOM_Functions.GetManagementPackRelationship("AP.F5.Device.ProcessorsGroup.HostsProcessors"); for (int i = 0; i < processors.Count; i++) { Processor newProcessor = new Processor(); string index = "." + processors[i].Id.ToString(); index = index.Replace(SNMP.sysMultiHostCpuIndex, ""); // Create SCOM Fan Object newProcessor.SCOM_Object_Processor = new CreatableEnterpriseManagementObject(SCOM_Functions.m_managementGroup, mpc_Processor); // Set Key of Device newProcessor.SCOM_Object_Processor[mpp_DeviceKey].Value = SystemNodeName; // Set Key of Fans Group newProcessor.SCOM_Object_Processor[mpp_DeviceProcessorsGroupName].Value = "Processors"; //Set Logical Entity Display Name newProcessor.SCOM_Object_Processor[mpp_EntityDisplayName].Value = "CPU-" + i.ToString(); // Set Fan Properties newProcessor.SCOM_Object_Processor[mpp_ProcessorIndex].Value = index; newProcessor.SCOM_Object_Processor[mpp_ProcessorName].Value = "CPU-" + i.ToString(); Processors.Add(newProcessor); } } }
/// <summary> /// Get DiskPartitions /// </summary> private void GetDiskPartitions() { // Get var diskPartitions = SNMP.WalkSNMP(SNMP.sysHostDiskPartition, Address, Port, Community); if (diskPartitions.Count > 0) { // Create Device Management Pack Class ManagementPackClass mpc_Device = SCOM_Functions.GetManagementPackClass("AP.F5.Device"); // Create Root Entity Class & Display Name Prop ManagementPackClass mpc_Entity = SCOM_Functions.GetManagementPackClass("System.Entity"); ManagementPackProperty mpp_EntityDisplayName = mpc_Entity.PropertyCollection["DisplayName"]; // Parent Device Key Property (IP Address) ManagementPackProperty mpp_DeviceKey = mpc_Device.PropertyCollection["DeviceName"]; // Create DiskPartitions Group Object ManagementPackClass mpc_DiskPartitionGroup = SCOM_Functions.GetManagementPackClass("AP.F5.Device.DiskPartitionsGroup"); SCOM_Object_DiskPartitionGroup = new CreatableEnterpriseManagementObject(m_managementGroup, mpc_DiskPartitionGroup); SCOM_Object_DiskPartitionGroup[mpp_DeviceKey].Value = SystemNodeName; // Set Key of Device ManagementPackProperty mpp_DiskPartitionGroupName = mpc_DiskPartitionGroup.PropertyCollection["Name"]; SCOM_Object_DiskPartitionGroup[mpp_DiskPartitionGroupName].Value = "Disks"; // Create Management Pack Class Objects for DiskPartition and Needed Properties ManagementPackClass mpc_DiskPartition = SCOM_Functions.GetManagementPackClass(className: "AP.F5.Device.DiskPartition"); ManagementPackProperty mpp_DiskPartitionIndex = mpc_DiskPartition.PropertyCollection["Index"]; ManagementPackProperty mpp_DiskPartitionMountpoint = mpc_DiskPartition.PropertyCollection["Mountpoint"]; // Set DiskPartition-Group Relationship ManagementPackRelationship mpr_DiskPartitionsGroup = SCOM_Functions.GetManagementPackRelationship("AP.F5.Device.DiskPartitionsGroup.HostsDiskPartitions"); for (int i = 0; i < diskPartitions.Count; i++) { DiskPartition newDiskPartition = new DiskPartition(); string index = "." + diskPartitions[i].Id.ToString(); index = index.Replace(SNMP.sysHostDiskPartition, ""); // Create SCOM Fan Object newDiskPartition.SCOM_Object_DiskPartition = new CreatableEnterpriseManagementObject(SCOM_Functions.m_managementGroup, mpc_DiskPartition); // Set Key of Device newDiskPartition.SCOM_Object_DiskPartition[mpp_DeviceKey].Value = SystemNodeName; // Set Key of DiskPartitions Group newDiskPartition.SCOM_Object_DiskPartition[mpp_DiskPartitionGroupName].Value = "Disks"; //Set Logical Entity Display Name newDiskPartition.SCOM_Object_DiskPartition[mpp_EntityDisplayName].Value = diskPartitions[i].Data.ToString(); // Set Fan Properties newDiskPartition.SCOM_Object_DiskPartition[mpp_DiskPartitionIndex].Value = index; newDiskPartition.SCOM_Object_DiskPartition[mpp_DiskPartitionMountpoint].Value = diskPartitions[i].Data.ToString(); DiskPartitions.Add(newDiskPartition); } } }
/// <summary> /// Get Fans /// </summary> private void GetFans() { // Get Count of Fans int fanCount = Convert.ToInt32(SNMP.GetSNMP(SNMP.sysChassisFanNumber, Address, Port, Community)[0].Data.ToString()); // If There Are Fans Then Create FanGroup and Relationship if (fanCount > 0) { // Create Device Group Management Pack Class ManagementPackClass mpc_Device = SCOM_Functions.GetManagementPackClass("AP.F5.Device"); // Create Root Entity Class & Display Name Prop ManagementPackClass mpc_Entity = SCOM_Functions.GetManagementPackClass("System.Entity"); ManagementPackProperty mpp_EntityDisplayName = mpc_Entity.PropertyCollection["DisplayName"]; // Parent Device Key Property (IP Address) ManagementPackProperty mpp_DeviceKey = mpc_Device.PropertyCollection["DeviceName"]; // Create FanGroup Object ManagementPackClass mpc_DeviceFanGroup = SCOM_Functions.GetManagementPackClass("AP.F5.Device.FansGroup"); SCOM_Object_FanGroup = new CreatableEnterpriseManagementObject(m_managementGroup, mpc_DeviceFanGroup); SCOM_Object_FanGroup[mpp_DeviceKey].Value = SystemNodeName; // Set Key of Device ManagementPackProperty mpp_DeviceFansGroupName = mpc_DeviceFanGroup.PropertyCollection["Name"]; SCOM_Object_FanGroup[mpp_DeviceFansGroupName].Value = "Fans"; // Create Management Pack Class Objects for Fan and Needed Properties ManagementPackClass mpc_Fan = SCOM_Functions.GetManagementPackClass(className: "AP.F5.Device.Fan"); ManagementPackProperty mpp_FanIndex = mpc_Fan.PropertyCollection["Index"]; ManagementPackProperty mpp_FanName = mpc_Fan.PropertyCollection["Name"]; // Set Fan-Group Relationship ManagementPackRelationship mpr_FanGroup = SCOM_Functions.GetManagementPackRelationship("AP.F5.Device.FansGroup.HostsFans"); // Create Fans for (int i = 1; i <= fanCount; i++) { Fan newfan = new Fan(); // Create SCOM Fan Object newfan.SCOM_Object_Fan = new CreatableEnterpriseManagementObject(SCOM_Functions.m_managementGroup, mpc_Fan); // Set Key of Device newfan.SCOM_Object_Fan[mpp_DeviceKey].Value = SystemNodeName; // Set Key of Fans Group newfan.SCOM_Object_Fan[mpp_DeviceFansGroupName].Value = "Fans"; //Set Logical Entity Display Name newfan.SCOM_Object_Fan[mpp_EntityDisplayName].Value = "Fan-" + i.ToString(); // Set Fan Properties newfan.SCOM_Object_Fan[mpp_FanIndex].Value = Convert.ToInt32(SNMP.GetSNMP(SNMP.sysChassisFanIndex + i.ToString(), Address, Port, Community)[0].Data.ToString());; newfan.SCOM_Object_Fan[mpp_FanName].Value = "Fan-" + i.ToString(); Fans.Add(newfan); } } }
public async Task <Result> Add(ESightAppliance appliance) { return(await Task.Run(() => { try { if (OM12Connection.Exsits(ESightAppliance.EntityClassName, $"Host='{appliance.Host}'")) { return Result.Failed(101, $"ESight {appliance.Host} already exsits."); } IncrementalDiscoveryData incrementalDiscoveryData = new IncrementalDiscoveryData(); // add appliance record ManagementPackClass MPClass = GetMPClass(); CreatableEnterpriseManagementObject EMOAppliance = new CreatableEnterpriseManagementObject(OM12Connection.HuaweiESightMG, MPClass); IDictionary <string, ManagementPackProperty> props = OM12Connection.GetManagementPackProperties(EMOAppliance); EMOAppliance[props["Host"]].Value = appliance.Host; EMOAppliance[props["Port"]].Value = appliance.Port; EMOAppliance[props["AliasName"]].Value = appliance.AliasName; EMOAppliance[props["SystemId"]].Value = appliance.SystemId; EMOAppliance[props["LoginAccount"]].Value = appliance.LoginAccount; EMOAppliance[props["LoginPassword"]].Value = RijndaelManagedCrypto.Instance .EncryptForCS(appliance.LoginPassword); EMOAppliance[props["LastModifiedOn"]].Value = DateTime.UtcNow; EMOAppliance[props["CreatedOn"]].Value = DateTime.UtcNow; EMOAppliance[props["OpenID"]].Value = Guid.NewGuid().ToString("D"); EMOAppliance[props["SubscribeID"]].Value = Guid.NewGuid().ToString("D"); EMOAppliance[props["SubKeepAliveStatus"]].Value = 0; EMOAppliance[props["SubscriptionAlarmStatus"]].Value = 0; EMOAppliance[props["SubscriptionNeDeviceStatus"]].Value = 0; EMOAppliance[props["SubKeepAliveError"]].Value = string.Empty; EMOAppliance[props["SubscripeAlarmError"]].Value = string.Empty; EMOAppliance[props["SubscripeNeDeviceError"]].Value = string.Empty; //EMOAppliance[props["LatestConnectInfo"]].Value = string.Empty; //EMOAppliance[props["LatestStatus"]].Value = Constants.ESightConnectionStatus.NONE; ManagementPackClass baseEntity = OM12Connection.GetManagementPackClass("System.Entity"); EMOAppliance[baseEntity, "DisplayName"].Value = appliance.Host; incrementalDiscoveryData.Add(EMOAppliance); incrementalDiscoveryData.Commit(OM12Connection.HuaweiESightMG); return Result.Done(); } catch (Exception e) { return Result.Failed(100, $"Internal error caused by {e.Message}", e); } })); }
/// <summary> /// Get Power Supplies /// </summary> private void GetPowerSupplies() { // Get Count of PowerSupplies int powerSupplyCount = Convert.ToInt16(SNMP.GetSNMP(SNMP.sysChassisPowerSupplyNumber, Address, Port, Community)[0].Data.ToString()); // If There are Fans Then Continue if (powerSupplyCount > 0) { // Create Device Group Management Pack Class ManagementPackClass mpc_Device = SCOM_Functions.GetManagementPackClass("AP.F5.Device"); // Create Root Entity Class & Display Name Prop ManagementPackClass mpc_Entity = SCOM_Functions.GetManagementPackClass("System.Entity"); ManagementPackProperty mpp_EntityDisplayName = mpc_Entity.PropertyCollection["DisplayName"]; // Parent Device Key Property (IP Address) ManagementPackProperty mpp_DeviceKey = mpc_Device.PropertyCollection["DeviceName"]; // Create PowerSuppliesGroup Object ManagementPackClass mpc_DevicePowerSupplyGroup = SCOM_Functions.GetManagementPackClass("AP.F5.Device.PowerSuppliesGroup"); SCOM_Object_PowerSupplyGroup = new CreatableEnterpriseManagementObject(m_managementGroup, mpc_DevicePowerSupplyGroup); SCOM_Object_PowerSupplyGroup[mpp_DeviceKey].Value = SystemNodeName; // Set Key of Device ManagementPackProperty mpp_DevicePowerSuppliesGroupName = mpc_DevicePowerSupplyGroup.PropertyCollection["Name"]; SCOM_Object_PowerSupplyGroup[mpp_DevicePowerSuppliesGroupName].Value = "PSUs"; // Create Management Pack Class Objects for PowerSupply and Needed Properties ManagementPackClass mpc_PowerSupply = SCOM_Functions.GetManagementPackClass(className: "AP.F5.Device.PowerSupply"); ManagementPackProperty mpp_PowerSupplyIndex = mpc_PowerSupply.PropertyCollection["Index"]; ManagementPackProperty mpp_PowerSupplyName = mpc_PowerSupply.PropertyCollection["Name"]; // Set PowerSupply-Group Relationship ManagementPackRelationship mpr_PowerSuppliesGroup = SCOM_Functions.GetManagementPackRelationship("AP.F5.Device.PowerSuppliesGroup.HostsPowerSupplies"); for (int i = 1; i <= powerSupplyCount; i++) { PowerSupply newpsu = new PowerSupply(); // Create SCOM Object newpsu.SCOM_Object_PowerSupply = new CreatableEnterpriseManagementObject(SCOM_Functions.m_managementGroup, mpc_PowerSupply); // Set Key of Device newpsu.SCOM_Object_PowerSupply[mpp_DeviceKey].Value = SystemNodeName; // Set Key of Fans Group newpsu.SCOM_Object_PowerSupply[mpp_DevicePowerSuppliesGroupName].Value = "PSUs"; //Set Logical Entity Display Name newpsu.SCOM_Object_PowerSupply[mpp_EntityDisplayName].Value = "PSU-" + i.ToString(); // Set Fan Properties newpsu.SCOM_Object_PowerSupply[mpp_PowerSupplyIndex].Value = Convert.ToInt32(SNMP.GetSNMP(SNMP.sysChassisPowerSupplyIndex + i.ToString(), Address, Port, Community)[0].Data.ToString()); newpsu.SCOM_Object_PowerSupply[mpp_PowerSupplyName].Value = "PSU-" + i.ToString(); PowerSupplies.Add(newpsu); } } }
/// <summary> /// Get Temp Sensor /// </summary> private void GetTempSensors() { // Get Count of Temperature Sensors int TempSensorCount = Convert.ToInt16(SNMP.GetSNMP(SNMP.sysChassisTempNumber, Address, Port, Community)[0].Data.ToString()); // If we have Temperature Sensors if (TempSensorCount > 0) { // Create Device Group Management Pack Class ManagementPackClass mpc_Device = SCOM_Functions.GetManagementPackClass("AP.F5.Device"); // Create Root Entity Class & Display Name Prop ManagementPackClass mpc_Entity = SCOM_Functions.GetManagementPackClass("System.Entity"); ManagementPackProperty mpp_EntityDisplayName = mpc_Entity.PropertyCollection["DisplayName"]; // Parent Device Key Property (IP Address) ManagementPackProperty mpp_DeviceKey = mpc_Device.PropertyCollection["DeviceName"]; // Create FanGroup Object ManagementPackClass mpc_DeviceTempSensorsGroup = SCOM_Functions.GetManagementPackClass("AP.F5.Device.TempSensorsGroup"); SCOM_Object_TempSensorsGroup = new CreatableEnterpriseManagementObject(m_managementGroup, mpc_DeviceTempSensorsGroup); SCOM_Object_TempSensorsGroup[mpp_DeviceKey].Value = SystemNodeName; // Set Key of Device ManagementPackProperty mpp_DeviceTempSensorsGroupName = mpc_DeviceTempSensorsGroup.PropertyCollection["Name"]; SCOM_Object_TempSensorsGroup[mpp_DeviceTempSensorsGroupName].Value = "Temp. Sensors"; // Create Management Pack Class Objects for TempSensor and Needed Properties ManagementPackClass mpc_TempSensor = SCOM_Functions.GetManagementPackClass(className: "AP.F5.Device.TempSensor"); ManagementPackProperty mpp_TempSensorIndex = mpc_TempSensor.PropertyCollection["Index"]; ManagementPackProperty mpp_TempSensorName = mpc_TempSensor.PropertyCollection["Name"]; // Set Fan-Group Relationship ManagementPackRelationship mpr_TempSensorsGroup = SCOM_Functions.GetManagementPackRelationship("AP.F5.Device.TempSensorsGroup.HostsTempSensors"); // Create Temp Sensors for (int i = 1; i <= TempSensorCount; i++) { TempSensor newTempSensor = new TempSensor(); // Create SCOM TempSensor Object newTempSensor.SCOM_Object_TempSensor = new CreatableEnterpriseManagementObject(SCOM_Functions.m_managementGroup, mpc_TempSensor); // Set Key of Device newTempSensor.SCOM_Object_TempSensor[mpp_DeviceKey].Value = SystemNodeName; // Set Key of Fans Group newTempSensor.SCOM_Object_TempSensor[mpp_DeviceTempSensorsGroupName].Value = "Temp. Sensors"; //Set Logical Entity Display Name newTempSensor.SCOM_Object_TempSensor[mpp_EntityDisplayName].Value = "TempSensor-" + i.ToString(); // Set Fan Properties newTempSensor.SCOM_Object_TempSensor[mpp_TempSensorIndex].Value = Convert.ToInt32(SNMP.GetSNMP(SNMP.sysChassisTempIndex + i.ToString(), Address, Port, Community)[0].Data.ToString()); newTempSensor.SCOM_Object_TempSensor[mpp_TempSensorName].Value = "TempSensor-" + i.ToString(); TempSensors.Add(newTempSensor); } } }
/// <summary> /// Create SCOM Object /// </summary> public void CreateDeviceGroupScomObject() { // Create Root Entity Class & Display Name Prop ManagementPackClass mpc_Entity = SCOM.GetManagementPackClass("System.Entity"); ManagementPackProperty mpp_EntityDisplayName = mpc_Entity.PropertyCollection["DisplayName"]; // Create Correct Group Management Pack Class ManagementPackClass mpc_DeviceGroup; if (Type == "Sync-Failover") { mpc_DeviceGroup = SCOM.GetManagementPackClass("AP.F5.LTM.SyncFailoverGroup"); } else { mpc_DeviceGroup = SCOM.GetManagementPackClass("AP.F5.LTM.SyncOnlyGroup"); } // Create Sync-Failover Group Object SCOM_Object = new CreatableEnterpriseManagementObject(SCOM.m_managementGroup, mpc_DeviceGroup); // Display Name of Parent (KEY Property) SCOM_Object[mpp_EntityDisplayName].Value = Name; // Set Properties of Device Group // Name (Key Property) ManagementPackProperty mpp_Name = mpc_DeviceGroup.PropertyCollection["Name"]; SCOM_Object[mpp_Name].Value = Name; // Key ManagementPackProperty mpp_Key = mpc_DeviceGroup.PropertyCollection["Key"]; SCOM_Object[mpp_Key].Value = Key; // Standalone ManagementPackProperty mpp_Standalone = mpc_DeviceGroup.PropertyCollection["Standalone"]; SCOM_Object[mpp_Standalone].Value = Standalone; // Devices ManagementPackProperty mpp_Devices = mpc_DeviceGroup.PropertyCollection["Devices"]; SCOM_Object[mpp_Devices].Value = Devices; // Monitor Address ManagementPackProperty mpp_MonitorAddress = mpc_DeviceGroup.PropertyCollection["Addresses"]; SCOM_Object[mpp_MonitorAddress].Value = Addresses; // Monitor Port ManagementPackProperty mpp_MonitorPort = mpc_DeviceGroup.PropertyCollection["Ports"]; SCOM_Object[mpp_MonitorPort].Value = Ports; // Monitor Community ManagementPackProperty mpp_MonitorCommunity = mpc_DeviceGroup.PropertyCollection["Communities"]; SCOM_Object[mpp_MonitorCommunity].Value = Communities; }
/// <summary> /// Default Constructor /// </summary> /// <param name="FullName"></param> /// <param name="Description"></param> /// <param name="MonitorRule"></param> /// <param name="TotalMembers"></param> /// <param name="ActiveMembers"></param> public Pool(SyncFailoverGroup dg, string PartitionName, string FullName, string ShortName, string Description, string MonitorRule, long TotalMembers, long ActiveMembers) { // Set Partition string Partition = FullName.Substring(1, FullName.LastIndexOf("/") - 1); // Create Pool Management Pack Class ManagementPackClass mpc_Pool = SCOM.GetManagementPackClass("AP.F5.LTM.Pool"); // Create New NetworkInterface Object SCOM_Object = new CreatableEnterpriseManagementObject(SCOM.m_managementGroup, mpc_Pool); // Create Root Entity Class & Key Property ManagementPackClass mpc_Entity = SCOM.GetManagementPackClass("System.Entity"); ManagementPackProperty mpp_EntityDisplayName = mpc_Entity.PropertyCollection["DisplayName"]; SCOM_Object[mpp_EntityDisplayName].Value = ShortName; // Create SyncFailoverGroup Management Pack Class & Key Property ManagementPackClass mpc_SyncFailoverGroup = SCOM.GetManagementPackClass("AP.F5.LTM.SyncFailoverGroup"); ManagementPackProperty mpp_SyncFailoverGroupKey = mpc_SyncFailoverGroup.PropertyCollection["Key"]; SCOM_Object[mpp_SyncFailoverGroupKey].Value = dg.Key; // Create Partition Management Pack Class & Key Property ManagementPackClass mpc_Partition = SCOM.GetManagementPackClass("AP.F5.LTM.Partition"); ManagementPackProperty mpp_PartitionName = mpc_Partition.PropertyCollection["Name"]; SCOM_Object[mpp_PartitionName].Value = PartitionName; // Create Properties of Pool ManagementPackProperty mpp_PoolFullName = mpc_Pool.PropertyCollection["FullName"]; SCOM_Object[mpp_PoolFullName].Value = FullName; ManagementPackProperty mpp_PoolName = mpc_Pool.PropertyCollection["Name"]; SCOM_Object[mpp_PoolName].Value = ShortName; ManagementPackProperty mpp_PoolPartition = mpc_Pool.PropertyCollection["Partition"]; SCOM_Object[mpp_PoolPartition].Value = Partition; ManagementPackProperty mpp_PoolTotalMembers = mpc_Pool.PropertyCollection["TotalMembers"]; SCOM_Object[mpp_PoolTotalMembers].Value = TotalMembers; ManagementPackProperty mpp_PoolActiveMembers = mpc_Pool.PropertyCollection["ActiveMembers"]; SCOM_Object[mpp_PoolActiveMembers].Value = ActiveMembers; ManagementPackProperty mpp_PoolDescription = mpc_Pool.PropertyCollection["Description"]; SCOM_Object[mpp_PoolDescription].Value = Description; ManagementPackProperty mpp_PoolMonitorRule = mpc_Pool.PropertyCollection["MonitorRule"]; SCOM_Object[mpp_PoolMonitorRule].Value = MonitorRule; }
protected override void ProcessRecord() { try { ManagementPackClass clsAnnouncement = SMHelpers.GetManagementPackClass(ClassTypes.System_Announcement_Item, SMHelpers.GetManagementPack(ManagementPacks.System_AdminItem_Library, _mg), _mg); ManagementPackEnumeration enumPriority = null; switch (_Priority) { case "Low": enumPriority = SMHelpers.GetEnum(Enumerations.System_Announcement_PriorityEnum_Low, _mg); break; case "Critical": enumPriority = SMHelpers.GetEnum(Enumerations.System_Announcement_PriorityEnum_Critical, _mg); break; case "Medium": enumPriority = SMHelpers.GetEnum(Enumerations.System_Announcement_PriorityEnum_Medium, _mg); break; default: enumPriority = SMHelpers.GetEnum(Enumerations.System_Announcement_PriorityEnum_Medium, _mg); break; } CreatableEnterpriseManagementObject emo = new CreatableEnterpriseManagementObject(_mg, clsAnnouncement); emo[clsAnnouncement, "Id"].Value = System.Guid.NewGuid().ToString(); if (_DisplayName != null) { emo[clsAnnouncement, "DisplayName"].Value = _DisplayName; } emo[clsAnnouncement, "Title"].Value = _DisplayName; if (_Body != null) { emo[clsAnnouncement, "Body"].Value = _Body; } emo[clsAnnouncement, "Priority"].Value = enumPriority.Id; emo[clsAnnouncement, "ExpirationDate"].Value = _ExpirationDate; emo.Commit(); if (_passThru) { WriteObject(ServiceManagerObjectHelper.AdaptManagementObject(this, _mg.EntityObjects.GetObject <EnterpriseManagementObject>(emo.Id, ObjectQueryOptions.Default))); } } catch (Exception) { } }
/// <summary> /// Default Constructor /// </summary> /// <param name="dg"></param> /// <param name="FullName"></param> /// <param name="Description"></param> /// <param name="CertFileName"></param> public ProfileServerSSL(SyncFailoverGroup dg, string PartitionName, string FullName, string Description, string CertFileNames) { // Get ShortName string ShortName = FullName.Substring(FullName.LastIndexOf("/") + 1); // Get Partition string Partition = FullName.Substring(1, FullName.LastIndexOf("/") - 1); // Create Profile Management Pack Class ManagementPackClass mpc_Profile = SCOM.GetManagementPackClass("AP.F5.LTM.ProfileServerSSL"); // Create New NetworkInterface Object SCOM_Object = new CreatableEnterpriseManagementObject(SCOM.m_managementGroup, mpc_Profile); // Create Root Entity Class & Key Property ManagementPackClass mpc_Entity = SCOM.GetManagementPackClass("System.Entity"); ManagementPackProperty mpp_EntityDisplayName = mpc_Entity.PropertyCollection["DisplayName"]; SCOM_Object[mpp_EntityDisplayName].Value = ShortName; // Create SyncFailoverGroup Management Pack Class & Key Property ManagementPackClass mpc_SyncFailoverGroup = SCOM.GetManagementPackClass("AP.F5.LTM.SyncFailoverGroup"); ManagementPackProperty mpp_SyncFailoverGroupKey = mpc_SyncFailoverGroup.PropertyCollection["Key"]; SCOM_Object[mpp_SyncFailoverGroupKey].Value = dg.Key; // Create Partition Management Pack Class & Key Property ManagementPackClass mpc_Partition = SCOM.GetManagementPackClass("AP.F5.LTM.Partition"); ManagementPackProperty mpp_PartitionName = mpc_Partition.PropertyCollection["Name"]; SCOM_Object[mpp_PartitionName].Value = PartitionName; // Now We Can Create Profile Properties ManagementPackProperty mpp_ProfileName = mpc_Profile.PropertyCollection["Name"]; SCOM_Object[mpp_ProfileName].Value = ShortName; ManagementPackProperty mpp_ProfileFullName = mpc_Profile.PropertyCollection["FullName"]; SCOM_Object[mpp_ProfileFullName].Value = FullName; ManagementPackProperty mpp_ProfilePartition = mpc_Profile.PropertyCollection["Partition"]; SCOM_Object[mpp_ProfilePartition].Value = Partition; ManagementPackProperty mpp_ProfileDeviceGroup = mpc_Profile.PropertyCollection["DeviceGroup"]; SCOM_Object[mpp_ProfileDeviceGroup].Value = dg.Name; ManagementPackProperty mpp_ProfileDescription = mpc_Profile.PropertyCollection["Description"]; SCOM_Object[mpp_ProfileDescription].Value = Description; ManagementPackProperty mpp_ProfileCertFileName = mpc_Profile.PropertyCollection["CertFileNames"]; SCOM_Object[mpp_ProfileCertFileName].Value = CertFileNames; }
public Node(string SyncFailoverGroupKey, string PartitionName, string NodeFullName, string NodeShortName, string Address, string Description, string MonitorRules) { // Set Partition string Partition = NodeFullName.Substring(1, NodeFullName.LastIndexOf("/") - 1); // Create Node Management Pack Class ManagementPackClass mpc_Node = SCOM.GetManagementPackClass("AP.F5.LTM.Node"); // Create New NetworkInterface Object SCOM_Object = new CreatableEnterpriseManagementObject(SCOM.m_managementGroup, mpc_Node); // Create Root Entity Class & Key Property ManagementPackClass mpc_Entity = SCOM.GetManagementPackClass("System.Entity"); ManagementPackProperty mpp_EntityDisplayName = mpc_Entity.PropertyCollection["DisplayName"]; SCOM_Object[mpp_EntityDisplayName].Value = NodeShortName; // Create SyncFailoverGroup Management Pack Class & Key Property ManagementPackClass mpc_SyncFailoverGroup = SCOM.GetManagementPackClass("AP.F5.LTM.SyncFailoverGroup"); ManagementPackProperty mpp_SyncFailoverGroupKey = mpc_SyncFailoverGroup.PropertyCollection["Key"]; SCOM_Object[mpp_SyncFailoverGroupKey].Value = SyncFailoverGroupKey; // Create Partition Management Pack Class & Key Property ManagementPackClass mpc_Partition = SCOM.GetManagementPackClass("AP.F5.LTM.Partition"); ManagementPackProperty mpp_PartitionName = mpc_Partition.PropertyCollection["Name"]; SCOM_Object[mpp_PartitionName].Value = PartitionName; // Set Node Properties // Create our Virtual Server Properties ManagementPackProperty mpp_Name = mpc_Node.PropertyCollection["Name"]; SCOM_Object[mpp_Name].Value = NodeShortName; ManagementPackProperty mpp_FullName = mpc_Node.PropertyCollection["FullName"]; SCOM_Object[mpp_FullName].Value = NodeFullName; ManagementPackProperty mpp_Description = mpc_Node.PropertyCollection["Description"]; SCOM_Object[mpp_Description].Value = Description; ManagementPackProperty mpp_Address = mpc_Node.PropertyCollection["Address"]; SCOM_Object[mpp_Address].Value = Address; ManagementPackProperty mpp_Partition = mpc_Node.PropertyCollection["Partition"]; SCOM_Object[mpp_Partition].Value = Partition; ManagementPackProperty mpp_MonitorRule = mpc_Node.PropertyCollection["MonitorRules"]; SCOM_Object[mpp_MonitorRule].Value = MonitorRules; }
private void OnDeleteTest(object sender, CommandEventArgs e) { if (DetailView is TestBrowser tb && tb.Grid.SelectedRows != null && tb.Grid.SelectedRows.Count > 0) { try { TestObjectAdapter firstDataItem = (TestObjectAdapter)tb.Grid.SelectedRows[0].DataBoundItem; bool doDelete = false; if (tb.Grid.SelectedRows.Count == 1) { doDelete = MessageBox.Show($"You're about to delete the {firstDataItem.DisplayName} destination.\r\nAre you sure?", "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes; } else { doDelete = MessageBox.Show($"You're about to delete multiple destinations.\r\nAre you sure?", "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes; } if (doDelete) { EnterpriseManagementConnector connector = ManagementGroup.ConnectorFramework.GetMonitoringConnector(); IncrementalDiscoveryData incrementalDiscovery = new IncrementalDiscoveryData(); ManagementPackClass fqdnClass = ManagementGroup.EntityTypes.GetClass(IDs.FullyQualifiedDomainNameClassId); foreach (DataGridViewRow gridRow in tb.Grid.SelectedRows) { TestObjectAdapter dataItem = (TestObjectAdapter)gridRow.DataBoundItem; MonitoringObject currentObject = ManagementGroup.EntityObjects.GetObject <MonitoringObject>(dataItem.Source.Id, ObjectQueryOptions.Default); CreatableEnterpriseManagementObject oldInstance = new CreatableEnterpriseManagementObject(ManagementGroup, currentObject.GetMostDerivedClasses().First()); // host keys oldInstance[IDs.FullyQualifiedDomainNameClassProperties.FullyQualifiedDomainNamePropertyId].Value = currentObject[IDs.FullyQualifiedDomainNameClassProperties.FullyQualifiedDomainNamePropertyId].Value; oldInstance[IDs.FullyQualifiedDomainNameClassProperties.TargetIndexPropertyId].Value = currentObject[IDs.FullyQualifiedDomainNameClassProperties.TargetIndexPropertyId].Value; // key oldInstance[IDs.TestBaseClassProperties.TestIdPropertyId].Value = currentObject[IDs.TestBaseClassProperties.TestIdPropertyId].Value; incrementalDiscovery.Remove(oldInstance); } incrementalDiscovery.Commit(connector); } // emulate Refresh command for detail view SendRefreshCommandToDetailView(); } catch (Exception ex) { MessageBox.Show($"In {System.Reflection.MethodBase.GetCurrentMethod().Name} {ex.GetType().Name} said {ex.Message} at {ex.StackTrace}"); } } }
public static CreatableEnterpriseManagementObject CreateNewObjectFromExistingObject(EnterpriseManagementObject emoToBeCopied, ManagementPackClass mpc, string[] strPropertiesToExclude, EnterpriseManagementGroup emg) { //Create a new object to copy property values into CreatableEnterpriseManagementObject cemo = new CreatableEnterpriseManagementObject(emg, mpc); //For each property copy the property value into the new object foreach (ManagementPackProperty property in emoToBeCopied.GetProperties()) { //.. unless it is in the list of properties to NOT copy over if (Array.IndexOf(strPropertiesToExclude, property.Name) == -1) { cemo[property.Id].Value = emoToBeCopied[property.Id].Value; } } return(cemo); }
//Add action log relationship to passed emo private bool AddActionLogEntry( EnterpriseManagementGroup emg, EnterpriseManagementObject emoIncident, string strTitle, string strDescription ) { try { //Get the System.WorkItem.Library mp ManagementPack mpWorkItemLibrary = emg.ManagementPacks.GetManagementPack(new Guid("405D5590-B45F-1C97-024F-24338290453E")); //Get the actionlog class ManagementPackClass typeActionLog = emg.EntityTypes.GetClass("System.WorkItem.TroubleTicket.ActionLog", mpWorkItemLibrary); //Create a new action log entry CreatableEnterpriseManagementObject objectActionLog = new CreatableEnterpriseManagementObject(emg, typeActionLog); //Setup the action log entry objectActionLog[typeActionLog, "Id"].Value = Guid.NewGuid().ToString(); objectActionLog[typeActionLog, "Description"].Value = strDescription + "\n"; objectActionLog[typeActionLog, "Title"].Value = strTitle; objectActionLog[typeActionLog, "EnteredBy"].Value = UserPrincipal.Current.DisplayName; objectActionLog[typeActionLog, "EnteredDate"].Value = DateTime.Now.ToUniversalTime(); //Get the enumeration and relationship for the actionlog entry ManagementPackEnumeration enumActionLog = mpWorkItemLibrary.GetEnumerations().GetItem("System.WorkItem.ActionLogEnum.TaskExecuted"); objectActionLog[typeActionLog, "ActionType"].Value = enumActionLog; ManagementPackRelationship relActionLog = emg.EntityTypes.GetRelationshipClass("System.WorkItem.TroubleTicketHasActionLog", mpWorkItemLibrary); //Get the projection for the incident from the emo EnterpriseManagementObjectProjection emopIncident = new EnterpriseManagementObjectProjection(emoIncident); //Add relationship and save emopIncident.Add(objectActionLog, relActionLog.Target); emopIncident.Commit(); return(true); } catch { return(false); } }
/// <summary> /// Create Memory SCOM Object and Relationship Object /// </summary> private void CreateMemoryScomObjects() { // Create Device Group Management Pack Class ManagementPackClass mpc_Device = SCOM_Functions.GetManagementPackClass("AP.F5.Device"); // Parent Device Key Property (IP Address) ManagementPackProperty mpp_DeviceKey = mpc_Device.PropertyCollection["DeviceName"]; // Create FailoverState Object ManagementPackClass mpc_DeviceMemory = SCOM_Functions.GetManagementPackClass("AP.F5.Device.Memory"); SCOM_Object_Memory = new CreatableEnterpriseManagementObject(m_managementGroup, mpc_DeviceMemory); SCOM_Object_Memory[mpp_DeviceKey].Value = SystemNodeName; // Set Key of Device ManagementPackProperty mpp_DeviceMemoryName = mpc_DeviceMemory.PropertyCollection["Name"]; SCOM_Object_Memory[mpp_DeviceMemoryName].Value = "Memory"; }
void setProjectHasOwnerRelationship(string nameId, ref CreatableEnterpriseManagementObject cemoProject) { //get the owner of the project as an EMO. EnterpriseManagementObjectCriteria ecoOwnerCriteria = new EnterpriseManagementObjectCriteria(string.Format(xmlOwnerCriteria, nameId), mpcClasses.First(mpc => mpc.Name == "Microsoft.AD.UserBase"), managementPacks.First(mp => mp.Name == "Microsoft.Windows.Library"), emg); EnterpriseManagementObject emoOwner = emg.EntityObjects.GetObjectReader <EnterpriseManagementObject>(ecoOwnerCriteria, ObjectQueryOptions.Default).FirstOrDefault(); if (emoOwner != null) { //set up the relationship between project owner and project. CreatableEnterpriseManagementRelationshipObject cemroOwner = new CreatableEnterpriseManagementRelationshipObject(emg, mprRelationships.First(r => r.Name == "Cireson.ProjectAutomation.ProjectHasOwner")); cemroOwner.SetSource(cemoProject); cemroOwner.SetTarget(emoOwner); iddObjects.Add(cemroOwner); } }
private void OnDeleteDestination(object sender, CommandEventArgs e) { if (Grid.SelectedRows != null && Grid.SelectedRows.Count > 0) { try { InstanceState firstDataItem = (InstanceState)(Grid.SelectedRows[0].Cells[0].Tag as GridDataItem).DataItem; bool doDelete = false; if (Grid.SelectedRows.Count == 1) { doDelete = MessageBox.Show($"You're about to delete the {firstDataItem.DisplayName} destination.\r\nAre you sure?", "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes; } else { doDelete = MessageBox.Show($"You're about to delete multiple destinations.\r\nAre you sure?", "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes; } if (doDelete) { EnterpriseManagementConnector connector = ManagementGroup.ConnectorFramework.GetMonitoringConnector(); IncrementalDiscoveryData incrementalDiscovery = new IncrementalDiscoveryData(); ManagementPackClass fqdnClass = ManagementGroup.EntityTypes.GetClass(IDs.FullyQualifiedDomainNameClassId); foreach (DataGridViewRow gridRow in Grid.SelectedRows) { InstanceState dataItem = (InstanceState)(gridRow.Cells[0].Tag as GridDataItem).DataItem; MonitoringObject currentObject = dataItem.GetMonitoringObject(ManagementGroup, ObjectQueryOptions.Default, retrieveAllProperties: true); CreatableEnterpriseManagementObject oldInstance = new CreatableEnterpriseManagementObject(ManagementGroup, fqdnClass); oldInstance[IDs.FullyQualifiedDomainNameClassProperties.FullyQualifiedDomainNamePropertyId].Value = currentObject[IDs.FullyQualifiedDomainNameClassProperties.FullyQualifiedDomainNamePropertyId].Value; oldInstance[IDs.FullyQualifiedDomainNameClassProperties.TargetIndexPropertyId].Value = currentObject[IDs.FullyQualifiedDomainNameClassProperties.TargetIndexPropertyId].Value; incrementalDiscovery.Remove(oldInstance); } incrementalDiscovery.Commit(connector); } // emulate Refresh command OnRefreshCommand(sender, e); } catch (Exception ex) { MessageBox.Show($"In {System.Reflection.MethodBase.GetCurrentMethod().Name} {ex.GetType().Name} said {ex.Message} at {ex.StackTrace}"); } } }
private void OnSubmitted(object sender, FormCommandExecutedEventArgs e) { try { CurrentDataItem = this.DataContext as IDataItem; if (!((bool)CurrentDataItem["$IsNew$"])) { CurrentEMO = emg.EntityObjects.GetObject <EnterpriseManagementObject>((Guid)CurrentDataItem["$Id$"], ObjectQueryOptions.Default); if (DrawingImage != null) { MemoryStream ms = new MemoryStream(); DrawingImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); CurrentEMO[classNetworkMap, "Image"].Value = ms; CurrentEMO.Commit(); ms.Close(); } else { CurrentEMO[classNetworkMap, "Image"].Value = null; CurrentEMO.Commit(); } } else { if (DrawingImage != null) { MemoryStream ms = new MemoryStream(); DrawingImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); CreatableEnterpriseManagementObject CreateNetworkMap = new CreatableEnterpriseManagementObject(emg, classNetworkMap); CreateNetworkMap[classNetworkMap, "Image"].Value = ms; CreateNetworkMap.Commit(); ms.Close(); } } } catch (Exception exc) { System.Windows.MessageBox.Show(DateTime.Now + " : " + "Error in OnSubmitted() " + exc.Message); } }
/// <summary> /// Default Constructor /// </summary> /// <param name="dg">Hosting Device Group</param> /// <param name="Name">name of Traffic Group</param> public void CreateScomObject() { // Create Traffic Group Management Pack Class ManagementPackClass mpc_Trafficgroup = SCOM.GetManagementPackClass("AP.F5.LTM.TrafficGroup"); // Create Traffic Group Object SCOM_Object = new CreatableEnterpriseManagementObject(SCOM.m_managementGroup, mpc_Trafficgroup); // Create Root Entity Class & Display Name Prop ManagementPackClass mpc_Entity = SCOM.GetManagementPackClass("System.Entity"); ManagementPackProperty mpp_EntityDisplayName = mpc_Entity.PropertyCollection["DisplayName"]; SCOM_Object[mpp_EntityDisplayName].Value = Name; // Add in Key Property of Hosting DeviceGroup ManagementPackClass mpc_DeviceGroup = SCOM.GetManagementPackClass("AP.F5.LTM.SyncFailoverGroup"); ManagementPackProperty mpp_SyncFailoverGroupKey = mpc_DeviceGroup.PropertyCollection["Key"]; // Set parent Cluster Property SCOM_Object[mpp_SyncFailoverGroupKey].Value = DeviceGroup.Key; // Key (Key Property) ManagementPackProperty mpp_TrafficGroupKey = mpc_Trafficgroup.PropertyCollection["Key"]; SCOM_Object[mpp_TrafficGroupKey].Value = Key; // Name ManagementPackProperty mpp_TrafficGroupName = mpc_Trafficgroup.PropertyCollection["Name"]; SCOM_Object[mpp_TrafficGroupName].Value = Name; // FullName ManagementPackProperty mpp_TrafficGroupFullName = mpc_Trafficgroup.PropertyCollection["FullName"]; SCOM_Object[mpp_TrafficGroupFullName].Value = FullName; // Devices ManagementPackProperty mpp_TrafficGroupDevices = mpc_Trafficgroup.PropertyCollection["Devices"]; SCOM_Object[mpp_TrafficGroupDevices].Value = Devices; // DeviceGroup ManagementPackProperty mpp_TrafficGroupDeviceGroup = mpc_Trafficgroup.PropertyCollection["DeviceGroup"]; SCOM_Object[mpp_TrafficGroupDeviceGroup].Value = DeviceGroup.Name; }
/// <summary> /// Adds the specified appliance. /// </summary> /// <param name="appliance">The appliance.</param> /// <returns>Result.</returns> public async Task <Result> Add(FdAppliance appliance) { return(await Task.Run(() => { try { if (MGroup.Instance.Exsits(this.FdApplianceClass, $"HostIP='{appliance.HostIP}'")) { return Result.Failed(101, $"FusionDirector {appliance.HostIP} already exsits."); } var incrementalDiscoveryData = new IncrementalDiscoveryData(); // add appliance record var emoAppliance = new CreatableEnterpriseManagementObject(MGroup.Instance, this.FdApplianceClass); var props = this.FdApplianceClass.PropertyCollection; emoAppliance[props["UniqueId"]].Value = FusionDirectUniqueIdPrefix + Guid.NewGuid().ToString("D"); emoAppliance[props["HostIP"]].Value = appliance.HostIP; emoAppliance[props["AliasName"]].Value = appliance.AliasName; emoAppliance[props["LoginAccount"]].Value = appliance.LoginAccount; emoAppliance[props["LoginPd"]].Value = RijndaelManagedCrypto.Instance.EncryptForCs(appliance.LoginPd); emoAppliance[props["Port"]].Value = appliance.Port; emoAppliance[props["EventUserName"]].Value = appliance.EventUserName; emoAppliance[props["EventPd"]].Value = RijndaelManagedCrypto.Instance.EncryptForCs(appliance.EventPd); emoAppliance[props["SubscribeId"]].Value = appliance.SubscribeId; emoAppliance[props["SubscribeStatus"]].Value = appliance.SubscribeStatus; emoAppliance[props["LatestSubscribeInfo"]].Value = appliance.LatestSubscribeInfo; emoAppliance[props["LastModifyTime"]].Value = appliance.LastModifyTime; emoAppliance[props["CreateTime"]].Value = appliance.CreateTime; emoAppliance[this.DisplayNameField].Value = appliance.HostIP; incrementalDiscoveryData.Add(emoAppliance); incrementalDiscoveryData.Commit(MGroup.Instance); return Result.Done(); } catch (Exception e) { return Result.Failed(100, $"Internal error caused by {e.Message}", e); } })); }
EnterpriseManagementObject buildProjectCI(PublishedProject project, ManagementPackClass mpcProject) { //get the project class from service manager CreatableEnterpriseManagementObject cemoProject = new CreatableEnterpriseManagementObject(emg, mpcProject); #region set Project properties... cemoProject[mpcProject, "GUID"].Value = project.Id; cemoProject[mpcProject, "ProjectCreatedDate"].Value = project.CreatedDate as DateTime?; cemoProject[mpcProject, "ProjectLastModified"].Value = project.LastPublishedDate as DateTime?; cemoProject[mpcProject, "Title"].Value = project.Name as string; cemoProject[mpcProject, "DisplayName"].Value = project.Name as string; //the next project properties need the data loaded. cemoProject[mpcProject, "NextMilestone"].Value = project.Tasks.Where(t => t.IsMilestone == true).FirstOrDefault() == null ? string.Empty : project.Tasks.Where(t => t.IsMilestone == true).FirstOrDefault().Name; cemoProject[mpcProject, "ProjectCalendar"].Value = project.Calendar.Name; cemoProject[mpcProject, "ProjectStartDate"].Value = project.StartDate as DateTime?; cemoProject[mpcProject, "ProjectEndDate"].Value = project.FinishDate as DateTime?; cemoProject[mpcProject, "ProjectWebUrl"].Value = project.ProjectSiteUrl as string; cemoProject[mpcProject, "Description"].Value = project.Description as string; cemoProject[mpcProject, "PercentComplete"].Value = project.PercentComplete + "%"; #endregion #region set Project relationships... setProjectHasOwnerRelationship(project.Owner.UserId.NameId, ref cemoProject); //create a relationship between the connector and project. setProjectConnectorRelationship(ref cemoProject); #endregion #region set Project enums... setProjectEnumValues(ref cemoProject, mpcProject, project); EventLog.WriteEntry(strEventLogTitle, string.Format("Project GUID: {0}, Name: {1} successfully processed.", cemoProject.Id, cemoProject[null, "DisplayName"].Value), EventLogEntryType.Information, 0); return(cemoProject); #endregion }
private void brd_Loc_Create_MouseDown(object sender, MouseButtonEventArgs e) { if (LocationTreeView.SelectedItem != null) { CreatableEnterpriseManagementObject newLocation = new CreatableEnterpriseManagementObject(emg, locationClass); //Add some property values newLocation[locationClass, "DisplayName"].Value = "Add some info"; newLocation.Commit(); //Treeview Item - Parent Item TreeViewItem TR = (TreeViewItem)LocationTreeView.SelectedItem; // Get an object by GUID Guid G = new Guid(TR.Tag.ToString()); EnterpriseManagementObject treeviewEMO = emg.EntityObjects.GetObject <EnterpriseManagementObject>(G, ObjectQueryOptions.Default); CreatableEnterpriseManagementRelationshipObject relationship = new CreatableEnterpriseManagementRelationshipObject(emg, relationClass); relationship.SetSource(treeviewEMO); relationship.SetTarget(newLocation); relationship.Commit(); //FillTreeView.Now(emg, locationClass, relationClass, LocationTreeView); Fill(); //Convert EnterpriseManagementObject to IDataItem EnterpriseManagementObjectDataType dataType = new EnterpriseManagementObjectDataType(locationClass); IDataItem newlocationDataItem = dataType.CreateProxyInstance(newLocation); //Open Console form for created object //ConsoleContextHelper.Instance.PopoutForm(itemIdentity); Microsoft.EnterpriseManagement.GenericForm.FormUtilities.Instance.PopoutForm(newlocationDataItem); } else { MessageBox.Show("Please select parent location!", "No location selected", MessageBoxButton.OK, MessageBoxImage.Warning); Trace.WriteLine(DateTime.Now + " : " + "Not have Values for create Rel"); } }
private void lbOk_MouseDown(object sender, MouseButtonEventArgs e) { try { //IDataItem DI = this.TemplateSoftwareTitle.sipInstance; //Guid CurrentNodeId = (Guid)DI["$Id$"]; //EnterpriseManagementObject SoftwareTitle_EMO = emg.EntityObjects.GetObject<EnterpriseManagementObject>(CurrentNodeId, ObjectQueryOptions.Default); //MessageBox.Show(SoftwareTitle_EMO.Name); //MessageBox.Show(TemplateSoftwareTitle.mpClass.Name); if (this.txtDisplayName.Text != "" && this.txtDisplayName.Text != null) { //ManagementPackClass classTask = ManagementGroup.EntityTypes.GetClass(“Task”, testMP) CreatableEnterpriseManagementObject Version = new CreatableEnterpriseManagementObject(emg, classSoftwareVersion); //Version [classTask, “Id”].Value = Guid.NewGuid().ToString(); Version[classSoftwareVersion, "DisplayName"].Value = this.txtDisplayName.Text; CreatableEnterpriseManagementRelationshipObject relationshipObject = new CreatableEnterpriseManagementRelationshipObject(emg, relSoftwareTitleHasSoftwareVersion); relationshipObject.SetSource(EMO_SoftwareTitle); relationshipObject.SetTarget(Version); IncrementalDiscoveryData dd = new IncrementalDiscoveryData(); dd.Add(Version); //target object dd.Add(relationshipObject); //relationship object dd.Commit(emg); this.Close(); } else { MessageBox.Show("Type SoftwareVersion DisplayName!", "Warning!!!", MessageBoxButton.OK, MessageBoxImage.Warning); } } catch (Exception ex) { System.Windows.MessageBox.Show("Ok_MouseDown void error : " + ex.Message, "Service Manager", MessageBoxButton.OK, MessageBoxImage.Error); this.Close(); } }
private void OnSubmitted(object sender, FormCommandExecutedEventArgs e) { try { CurrentDataItem = this.DataContext as IDataItem; CurrentEMO = emg.EntityObjects.GetObject <EnterpriseManagementObject>((Guid)CurrentDataItem["$Id$"], ObjectQueryOptions.Default); var racks = emg.EntityObjects.GetRelationshipObjectsWhereTarget <EnterpriseManagementObject>(CurrentEMO.Id, relConfigItemRefRack, DerivedClassTraversalDepth.None, TraversalDepth.OneLevel, ObjectQueryOptions.Default); foreach (EnterpriseManagementRelationshipObject <EnterpriseManagementObject> relobj in racks) { int res; if (!(int.TryParse(this.TemplateRackItem.Unit, out res)) && this.TemplateRackItem.Unit != null) { System.Windows.MessageBox.Show(DateTime.Now + " : " + "Значение Unit должно быть числовым!"); return; } if (this.TemplateRackItem.Unit != null) { relobj[relConfigItemRefRack, "UnitIndex"].Value = this.TemplateRackItem.Unit; relobj.Commit(); } } //Проверяем существуют ли порты var Ports = emg.EntityObjects.GetRelationshipObjectsWhereSource <EnterpriseManagementObject>(CurrentEMO.Id, relNodetoPort, DerivedClassTraversalDepth.None, TraversalDepth.OneLevel, ObjectQueryOptions.Default); if (Ports.Count > 0) { _LogFile.Write(String.Format("Return "), false); return; } //Создаем порты int intPortsNo = 48; int.TryParse(this.txtPortsNo.Text, out intPortsNo); if (intPortsNo == 0) { intPortsNo = 48; } _LogFile.Write(String.Format("PortsNo " + intPortsNo.ToString()), false); //int[] BBnumbers = null; //if (BackBonePortList != null && BackBonePortList != "") //{ // string[] BBlist = BackBonePortList.Split(",".ToCharArray()); // BBnumbers = BBlist.Select(s => int.Parse(s)).ToArray(); //} //int PortsNumber; //if (Uplink < 27) //{ PortsNumber = 26; } //else //{ PortsNumber = 50; } //if (PN.Contains("Cisco")) //{ PortsNumber = 50; } //else if (PN.Contains("DES-2108")) //{ PortsNumber = 8; } //ManagementPackEnumeration enumNodeType = EO.mpNetworkAssetLibrary.GetEnumeration("NodeType.Hub"); //objNode[EO.classNode, "NodeType"].Value = enumNodeType; //if (Node[EO.classNode, "NodeType"].Value == enumNodeType & Uplink == 0) //{ PortsNumber = 8; } for (int i = 1; i <= intPortsNo; i++) { _LogFile.Write(String.Format("i " + i.ToString()), false); //DeviceNetworkAdapter[classDevice, "Id"].Value = Device[classDevice, "Id"].Value; //DeviceNetworkAdapter[classDeviceNetworkAdapter, "DeviceID"].Value = strDeviceID; CreatableEnterpriseManagementObject objPort = new CreatableEnterpriseManagementObject(emg, classNAPort); _LogFile.Write(String.Format("CurrentEMO " + CurrentEMO.FullName + " port " + i.ToString()), false); //objPort[EO.classNode, "DeviceKey"].Value = Node[EO.classNode, "DeviceKey"].Value; objPort[classPatchPanel, "DeviceKey"].Value = CurrentEMO[classPatchPanel, "DeviceKey"].Value; objPort[classNAPort, "Index"].Value = i.ToString(); objPort[classNAPort, "Key"].Value = "PORT-" + CurrentEMO[classPatchPanel, "DeviceKey"].Value.ToString() + "/" + i.ToString(); objPort[classNAPort, "DisplayName"].Value = "PORT-" + i.ToString(); objPort.Overwrite(); //CreatableEnterpriseManagementRelationshipObject relobjNodetoPort = new CreatableEnterpriseManagementRelationshipObject(emg, relNodetoPort); //relobjNodetoPort.SetSource(Node); //relobjNodetoPort.SetTarget((EnterpriseManagementObject)objPort); //relobjNodetoPort.Commit(); //objPort[EO.classNodePort, "DisplayName"].Value = "PORT-" + i.ToString(); //objPort[EO.classNodePort, "InterfaceNumber"].Value = i.ToString(); //objPort[EO.classNodePort, "Key"].Value = "PORT-" + Node[EO.classNode, "SNMPAddress"].Value.ToString() + "/" + i.ToString(); //objPort.Overwrite(); } } catch (Exception exc) { System.Windows.MessageBox.Show(DateTime.Now + " : " + "Error in OnSubmitted() " + exc.Message); } }
/// <summary> /// Create Scom Object /// </summary> private void CreateDeviceScomObject() { // Create Root Entity Class & Display Name Prop ManagementPackClass mpc_Entity = SCOM_Functions.GetManagementPackClass("System.Entity"); ManagementPackProperty mpp_EntityDisplayName = mpc_Entity.PropertyCollection["DisplayName"]; // Create Device Group Management Pack Class ManagementPackClass mpc_Device = SCOM_Functions.GetManagementPackClass("AP.F5.Device"); // Create New Device Group Object SCOM_Object_Device = new CreatableEnterpriseManagementObject(m_managementGroup, mpc_Device); // Display Name of Parent (KEY Property) SCOM_Object_Device[mpp_EntityDisplayName].Value = SystemNodeName; // Set Properties of Device // IPAddress ManagementPackProperty mpp_DeviceAddress = mpc_Device.PropertyCollection["IPAddress"]; SCOM_Object_Device[mpp_DeviceAddress].Value = Address; // Name (Key Property) ManagementPackProperty mpp_DeviceName = mpc_Device.PropertyCollection["DeviceName"]; SCOM_Object_Device[mpp_DeviceName].Value = SystemNodeName; // Type ManagementPackProperty mpp_DeviceType = mpc_Device.PropertyCollection["Type"]; SCOM_Object_Device[mpp_DeviceType].Value = Type; // Port ManagementPackProperty mpp_DevicePort = mpc_Device.PropertyCollection["Port"]; SCOM_Object_Device[mpp_DevicePort].Value = Port; // Community ManagementPackProperty mpp_DeviceCommunity = mpc_Device.PropertyCollection["Community"]; SCOM_Object_Device[mpp_DeviceCommunity].Value = Community; // SystemOID ManagementPackProperty mpp_DeviceSystemOID = mpc_Device.PropertyCollection["SystemOID"]; SCOM_Object_Device[mpp_DeviceSystemOID].Value = SystemOID; // Location ManagementPackProperty mpp_DeviceLocation = mpc_Device.PropertyCollection["Location"]; SCOM_Object_Device[mpp_DeviceLocation].Value = Location; // Contact ManagementPackProperty mpp_DeviceContact = mpc_Device.PropertyCollection["Contact"]; SCOM_Object_Device[mpp_DeviceContact].Value = Contact; // Model ManagementPackProperty mpp_DeviceModel = mpc_Device.PropertyCollection["Model"]; SCOM_Object_Device[mpp_DeviceModel].Value = Model; // Vendor ManagementPackProperty mpp_DeviceVendor = mpc_Device.PropertyCollection["Vendor"]; SCOM_Object_Device[mpp_DeviceVendor].Value = "F5 Networks, Inc."; // Version ManagementPackProperty mpp_DeviceVersion = mpc_Device.PropertyCollection["Version"]; SCOM_Object_Device[mpp_DeviceVersion].Value = SoftwareVersion; // Build ManagementPackProperty mpp_DeviceBuild = mpc_Device.PropertyCollection["Build"]; SCOM_Object_Device[mpp_DeviceBuild].Value = SoftwareBuild; // HotFix ManagementPackProperty mpp_DeviceHotFix = mpc_Device.PropertyCollection["HotFix"]; SCOM_Object_Device[mpp_DeviceHotFix].Value = SoftwareHotFix; // SerialNumber ManagementPackProperty mpp_DeviceSerialNumber = mpc_Device.PropertyCollection["SerialNumber"]; SCOM_Object_Device[mpp_DeviceSerialNumber].Value = SerialNumber; // Standalone ManagementPackProperty mpp_DeviceStandalone = mpc_Device.PropertyCollection["Standalone"]; SCOM_Object_Device[mpp_DeviceStandalone].Value = Standalone; }
private void CreateConnectorInstance() { try { //Get the server name to connect to String strServerName = Registry.GetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\System Center\\2010\\Service Manager\\Console\\User Settings", "SDKServiceMachine", "localhost").ToString(); //Conneect to the server EnterpriseManagementGroup emg = new EnterpriseManagementGroup(strServerName); //Get the System MP so we can get the system key token and version so we can get other MPs using that info ManagementPack mpSystem = emg.ManagementPacks.GetManagementPack(SystemManagementPack.System); Version verSystemVersion = mpSystem.Version; string strSystemKeyToken = mpSystem.KeyToken; //Also get the System Center and Connector MPs - we'll need things from those MPs later ManagementPack mpSystemCenter = emg.ManagementPacks.GetManagementPack(SystemManagementPack.SystemCenter); ManagementPack mpConnectors = emg.GetManagementPack("SCSM.AzureAutomation", null, new Version("1.0.0.0")); //Get the AzureAutomationConnector class in the Connectors MP ManagementPackClass classAAConnector = mpConnectors.GetClass("SCSM.AzureAutomation.Connector"); //Create a new CreatableEnterpriseManagementObject. We'll set the properties on this and then post it to the database. EnterpriseManagementObject cemoAAConnector = new CreatableEnterpriseManagementObject(emg, classAAConnector); //Sytem.Entity properties cemoAAConnector[classAAConnector, "DisplayName"].Value = this.DisplayName; //Required //Microsoft.SystemCenter.Connector properties //This is just a tricky way to create a unique ID which conforms to the syntax rules for MP element ID attribute values. String strConnectorID = String.Format(CultureInfo.InvariantCulture, "{0}.{1}", "AAConnector", Guid.NewGuid().ToString("N")); cemoAAConnector[classAAConnector, "Id"].Value = strConnectorID; //Required; Key //System.LinkingFramework.DataSource properties cemoAAConnector[classAAConnector, "DataProviderDisplayName"].Value = "Azure Automation Connector"; //Optional, shown in Connectors view cemoAAConnector[classAAConnector, "Enabled"].Value = true; //Optional, shown in Connectors view cemoAAConnector[classAAConnector, "Name"].Value = this.DisplayName; //SCSM.AzureAutomation.Connecto properties cemoAAConnector[classAAConnector, "AutomationAccount"].Value = this.AutomationAccount; cemoAAConnector[classAAConnector, "SubscriptionID"].Value = this.SubscriptionID; cemoAAConnector[classAAConnector, "ResourceGroup"].Value = this.ResourceGroup; cemoAAConnector[classAAConnector, "RunAsAccountName"].Value = this.RunAsAccountName; cemoAAConnector[classAAConnector, "RunAsAccountPassword"].Value = this.RunAsAccountPassword; //Create Connector instance cemoAAConnector.Commit(); //Accept the rule changes which updates the database mpConnectors.AcceptChanges(); } catch (Exception e) { MessageBox.Show(e.Message + e.InnerException.Message); } }
private void CreateConnectorInstance() { try { //Get the server name to connect to String strServerName = Registry.GetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\System Center\\2010\\Service Manager\\Console\\User Settings", "SDKServiceMachine", "localhost").ToString(); //Conneect to the server EnterpriseManagementGroup emg = new EnterpriseManagementGroup(strServerName); //Get the System MP so we can get the system key token and version so we can get other MPs using that info ManagementPack mpSystem = emg.ManagementPacks.GetManagementPack(SystemManagementPack.System); string strSystemKeyToken = mpSystem.KeyToken; ManagementPack mpSubscriptions = emg.GetManagementPack("Microsoft.SystemCenter.Subscriptions", strSystemKeyToken, new Version("1.0.0.0")); //Also get the System Center and Connector MPs - we'll need things from those MPs later ManagementPack mpSystemCenter = emg.ManagementPacks.GetManagementPack(SystemManagementPack.SystemCenter); ManagementPack mpConnectors = emg.GetManagementPack("SCSM.AzureAutomation", "ac1fe0583b6c84af", new Version("1.0.0.0")); ManagementPack mpAAConnectorWorkflows = emg.GetManagementPack("SCSM.AzureAutomation.Workflows", null, new Version("1.0.0.0")); //Get the AzureAutomationConnector class in the Connectors MP ManagementPackClass classAAConnector = mpConnectors.GetClass("SCSM.AzureAutomation.Connector"); //Create a new CreatableEnterpriseManagementObject. We'll set the properties on this and then post it to the database. EnterpriseManagementObject cemoAAConnector = new CreatableEnterpriseManagementObject(emg, classAAConnector); //Sytem.Entity properties cemoAAConnector[classAAConnector, "DisplayName"].Value = this.DisplayName; //Required //Microsoft.SystemCenter.Connector properties //This is just a tricky way to create a unique ID which conforms to the syntax rules for MP element ID attribute values. String strConnectorID = String.Format(CultureInfo.InvariantCulture, "{0}.{1}", "AAConnector", Guid.NewGuid().ToString("N")); cemoAAConnector[classAAConnector, "Id"].Value = strConnectorID; //Required; Key //System.LinkingFramework.DataSource properties cemoAAConnector[classAAConnector, "DataProviderDisplayName"].Value = "Azure Automation Connector"; //Optional, shown in Connectors view cemoAAConnector[classAAConnector, "Enabled"].Value = true; //Optional, shown in Connectors view cemoAAConnector[classAAConnector, "Name"].Value = this.DisplayName; //SCSM.AzureAutomation.Connector properties cemoAAConnector[classAAConnector, "AutomationAccount"].Value = this.AutomationAccount; cemoAAConnector[classAAConnector, "SubscriptionID"].Value = this.SubscriptionID; cemoAAConnector[classAAConnector, "ResourceGroup"].Value = this.ResourceGroup; cemoAAConnector[classAAConnector, "RunAsAccountName"].Value = this.RunAsAccountName; cemoAAConnector[classAAConnector, "RunAsAccountPassword"].Value = this.RunAsAccountPassword; cemoAAConnector[classAAConnector, "RefreshIntervalHours"].Value = this.RefreshIntervalHours; //Create Connector instance cemoAAConnector.Commit(); //Now we need to create the CSV Connector rule... //Get the Scheduler data source module type from the System MP and the Windows Workflow Task Write Action Module Type from the Subscription MP ManagementPackDataSourceModuleType dsmtScheduler = (ManagementPackDataSourceModuleType)mpSystem.GetModuleType("System.Scheduler"); ManagementPackWriteActionModuleType wamtWindowsWorkflowTaskWriteAction = (ManagementPackWriteActionModuleType)mpSubscriptions.GetModuleType("Microsoft.EnterpriseManagement.SystemCenter.Subscription.WindowsWorkflowTaskWriteAction"); //Create a new rule for the CSV Connector in the Connectors MP. Set the name of this rule to be the same as the connector instance ID so there is a pairing between them ManagementPackRule ruleAAConnector = new ManagementPackRule(mpAAConnectorWorkflows, strConnectorID); //Set the target and other properties of the rule ruleAAConnector.Target = mpSystemCenter.GetClass("Microsoft.SystemCenter.SubscriptionWorkflowTarget"); //Create a new Data Source Module in the new CSV Connector rule ManagementPackDataSourceModule dsmSchedule = new ManagementPackDataSourceModule(ruleAAConnector, "DS1"); //Set the configuration of the data source rule. Pass in the frequency (number of minutes) dsmSchedule.Configuration = "<Scheduler>" + "<SimpleReccuringSchedule>" + "<Interval Unit=\"Hours\">" + strRefreshIntervalHours + "</Interval>" + "</SimpleReccuringSchedule>" + "<ExcludeDates />" + "</Scheduler>"; //Set the Schedule Data Source Module Type to the Simple Schedule Module Type from the System MP dsmSchedule.TypeID = dsmtScheduler; //Add the Scheduler Data Source to the Rule ruleAAConnector.DataSourceCollection.Add(dsmSchedule); //Now repeat essentially the same process for the Write Action module... //Create a new Write Action Module in the CSV Connector rule ManagementPackWriteActionModule wamAAConnector = new ManagementPackWriteActionModule(ruleAAConnector, "WA1"); //Set the Configuration XML wamAAConnector.Configuration = "<Subscription>" + "<WindowsWorkflowConfiguration>" + //Specify the Windows Workflow Foundation workflow Assembly name here "<AssemblyName>SCSM.AzureAutomation.Workflows.AT</AssemblyName>" + //Specify the type name of the workflow to call in the assembly here: "<WorkflowTypeName>WorkflowAuthoring.RefreshConnector</WorkflowTypeName>" + "<WorkflowParameters>" + //Pass in the parameters here. In this case the two parameters are the data file path and the mapping file path "<WorkflowParameter Name=\"RefreshConnectorScript_ConnectorId\" Type=\"string\">" + strConnectorID + "</WorkflowParameter>" + "</WorkflowParameters>" + "<RetryExceptions />" + "<RetryDelaySeconds>60</RetryDelaySeconds>" + "<MaximumRunningTimeSeconds>300</MaximumRunningTimeSeconds>" + "</WindowsWorkflowConfiguration>" + "</Subscription>"; //Set the module type of the module to be the Windows Workflow Task Write Action Module Type from the Subscriptions MP. wamAAConnector.TypeID = wamtWindowsWorkflowTaskWriteAction; //Add the Write Action Module to the rule ruleAAConnector.WriteActionCollection.Add(wamAAConnector); //Mark the rule as pending update ruleAAConnector.Status = ManagementPackElementStatus.PendingAdd; ; //Accept the rule changes which updates the database mpAAConnectorWorkflows.AcceptChanges(); } catch (Exception e) { MessageBox.Show(e.Message + e.InnerException.Message); } }