/// <summary> /// Get Virtual Servers, Pools, PoolMembers, Profiles and Certificates from Group /// </summary> /// <param name="devGroup">Group to Collect Info From</param> private static void GetObjectsFromDeviceGroup(SyncFailoverGroup sfog) { // Create Common Partition Holder Partition CommonPartition = new Partition("Blank", "Blank"); // Attach to First Device in Device Group m_interfaces.initialize(sfog.DeviceList[0].Address, sfog.DeviceList[0].F5usr, sfog.DeviceList[0].F5pwd); if (m_interfaces.initialized) { // Get SNMP Info (Not Partition Dependant) // Virtual Server List <Variable> VirtualServerSnmpResults = SNMP.WalkSNMP(SNMP.ltmVsStatusName, sfog.DeviceList[0].Address, sfog.DeviceList[0].Port, sfog.DeviceList[0].Community); // Pools List <Variable> PoolSnmpResults = SNMP.WalkSNMP(SNMP.ltmPoolStatusName, sfog.DeviceList[0].Address, sfog.DeviceList[0].Port, sfog.DeviceList[0].Community); // Pool Members List <Variable> PoolMemberSnmpResults = SNMP.WalkSNMP(SNMP.ltmPoolMbrStatusNodeName, sfog.DeviceList[0].Address, sfog.DeviceList[0].Port, sfog.DeviceList[0].Community); // Client SSL Profiles List <Variable> ClientSslProfileSnmpResults = SNMP.WalkSNMP(SNMP.ltmClientSslName, sfog.DeviceList[0].Address, sfog.DeviceList[0].Port, sfog.DeviceList[0].Community); // Server SSL Profiles List <Variable> ServerSslProfileSnmpResults = SNMP.WalkSNMP(SNMP.ltmServerSslName, sfog.DeviceList[0].Address, sfog.DeviceList[0].Port, sfog.DeviceList[0].Community); // Get List of Partitions ManagementPartitionAuthZPartition[] partitionList = m_interfaces.ManagementPartition.get_partition_list(); // Loop through Partitions foreach (ManagementPartitionAuthZPartition partition in partitionList) { // Set Active Partition m_interfaces.ManagementPartition.set_active_partition(partition.partition_name); // Create Partition Partition newPartition = new Partition(sfog.Key, partition.partition_name); sfog.PartitionList.Add(newPartition); // Get Certificates ManagementKeyCertificateCertificateInformation_v2[] certs = m_interfaces.ManagementKeyCertificate.get_certificate_list_v2(ManagementKeyCertificateManagementModeType.MANAGEMENT_MODE_DEFAULT); foreach (ManagementKeyCertificateCertificateInformation_v2 cert in certs) { Certificate newCert = new Certificate(cert, sfog, partition.partition_name); newPartition.CertificateList.Add(newCert); } // Get Client SSL Profiles // Get iControl Info string[] ProfileClientSSLList = m_interfaces.LocalLBProfileClientSSL.get_list(); string[] ProfileClientSSLDescriptionList = m_interfaces.LocalLBProfileClientSSL.get_description(ProfileClientSSLList); LocalLBProfileString[] ProfileClientSSL_ca_files = m_interfaces.LocalLBProfileClientSSL.get_certificate_file_v2(ProfileClientSSLList); // Loop Through All Client SSL profiles for (int i = 0; i < ProfileClientSSLList.Length; i++) { // Create Profile ProfileClientSSL newProfile = new ProfileClientSSL(sfog, partition.partition_name, ProfileClientSSLList[i], ProfileClientSSLDescriptionList[i], ProfileClientSSL_ca_files[i].value); // Look for Matching Certs in This Partition foreach (Certificate cert in newPartition.CertificateList) { if (ProfileClientSSL_ca_files[i].value == cert.SCOM_Object.Values[3].ToString()) { newProfile.CertificateList.Add(cert); } } // Look For Matching Certificates in Common Partition if (partition.partition_name != "Common") { foreach (Certificate cert in CommonPartition.CertificateList) { if (ProfileClientSSL_ca_files[i].value == cert.SCOM_Object.Values[3].ToString()) { newProfile.CertificateList.Add(cert); } } } // Save ClientSslProfile newPartition.ClientSslProfileList.Add(newProfile); } // Get Server SSL Profiles string[] ProfileServerSSLList = m_interfaces.LocalLBProfileServerSSL.get_list(); string[] ProfileServerSSLDescriptionList = m_interfaces.LocalLBProfileServerSSL.get_description(ProfileServerSSLList); LocalLBProfileString[] ProfileServerSSL_ca_files = m_interfaces.LocalLBProfileServerSSL.get_certificate_file_v2(ProfileServerSSLList); // Loop Through All Server SSL profiles for (int i = 0; i < ProfileServerSSLList.Length; i++) { // Create Profile ProfileServerSSL newProfile = new ProfileServerSSL(sfog, partition.partition_name, ProfileServerSSLList[i], ProfileServerSSLDescriptionList[i], ProfileServerSSL_ca_files[i].value); // Look for Matching Certs in This Partition foreach (Certificate cert in newPartition.CertificateList) { if (ProfileServerSSL_ca_files[i].value == cert.SCOM_Object.Values[3].ToString()) { newProfile.CertificateList.Add(cert); } } // Look For Matching Certificates in Common Partition if (partition.partition_name != "Common") { foreach (Certificate cert in CommonPartition.CertificateList) { if (ProfileServerSSL_ca_files[i].value == cert.SCOM_Object.Values[3].ToString()) { newProfile.CertificateList.Add(cert); } } } newPartition.ServerSslProfileList.Add(newProfile); } // Get Virtual Servers // Get iControl Info string[] vipNames = m_interfaces.LocalLBVirtualServer.get_list(); string[] vipDefaultPools = m_interfaces.LocalLBVirtualServer.get_default_pool_name(vipNames); LocalLBVirtualServerVirtualServerType[] vipTypes = m_interfaces.LocalLBVirtualServer.get_type(vipNames); CommonAddressPort[] vipAddressPorts = m_interfaces.LocalLBVirtualServer.get_destination_v2(vipNames); string[] vipDescriptions = m_interfaces.LocalLBVirtualServer.get_description(vipNames); CommonULong64[] vipConnectionLimits = m_interfaces.LocalLBVirtualServer.get_connection_limit(vipNames); LocalLBVirtualServerVirtualServerProfileAttribute[][] vipProfiles = m_interfaces.LocalLBVirtualServer.get_profile(vipNames); // Loop Through All Virtual Servers for (int i = 0; i < vipNames.Length; i++) { // Set Address string vipAddress = vipAddressPorts[i].address; vipAddress = vipAddress.Substring(vipAddress.LastIndexOf("/") + 1); // Get Connection Limit string vipConnectionLimit = ConvertUlong(vipConnectionLimits[i]).ToString(); // Get Oid Suffix string vipOidSuffix = GetOidSuffix(vipNames[i], SNMP.ltmVsStatusName, VirtualServerSnmpResults); // Get Client SSL Profiles string vipClientSSLProfiles = ""; string vipServerSSLProfiles = ""; foreach (LocalLBVirtualServerVirtualServerProfileAttribute profileAttr in vipProfiles[i]) { if (profileAttr.profile_type == LocalLBProfileType.PROFILE_TYPE_CLIENT_SSL) { vipClientSSLProfiles += profileAttr.profile_name + ","; } if (profileAttr.profile_type == LocalLBProfileType.PROFILE_TYPE_SERVER_SSL) { vipServerSSLProfiles += profileAttr.profile_name + ","; } } vipClientSSLProfiles = vipClientSSLProfiles.TrimEnd(','); vipServerSSLProfiles = vipServerSSLProfiles.TrimEnd(','); // Get Device Group string vipDeviceGroup = sfog.Name; VirtualServer vs = new VirtualServer(sfog, partition.partition_name, vipNames[i], vipAddress, vipAddressPorts[i].port.ToString(), vipDescriptions[i], vipTypes[i].ToString(), vipDefaultPools[i], vipConnectionLimit, vipClientSSLProfiles, vipServerSSLProfiles); // Look For Matching ClientSslProfiles in this Partition foreach (ProfileClientSSL profile in newPartition.ClientSslProfileList) { if (vipClientSSLProfiles.Contains(profile.SCOM_Object.Values[0].ToString())) { vs.ProfileClientSslList.Add(profile); } } // Look For Matching ClientSslProfiles in Common Partition if (partition.partition_name != "Common") { foreach (ProfileClientSSL profile in CommonPartition.ClientSslProfileList) { if (vipClientSSLProfiles.Contains(profile.SCOM_Object.Values[0].ToString())) { vs.ProfileClientSslList.Add(profile); } } } // Look For Matching ServerSslProfiles in this Partition foreach (ProfileServerSSL profile in newPartition.ServerSslProfileList) { if (vipServerSSLProfiles.Contains(profile.SCOM_Object.Values[0].ToString())) { vs.ProfileServerSslList.Add(profile); } } // Look For Matching ClientSslProfiles in Common Partition if (partition.partition_name != "Common") { foreach (ProfileServerSSL profile in CommonPartition.ServerSslProfileList) { if (vipServerSSLProfiles.Contains(profile.SCOM_Object.Values[0].ToString())) { vs.ProfileServerSslList.Add(profile); } } } // Add it to the List newPartition.VirtualServerList.Add(vs); } // Get Pools & Pool Members // Get iControl Info string[] poolNames = m_interfaces.LocalLBPool.get_list(); string[] poolDescriptions = m_interfaces.LocalLBPool.get_description(poolNames); long[] poolActiveMemberCount = m_interfaces.LocalLBPool.get_active_member_count(poolNames); CommonAddressPort[][] poolMembers = m_interfaces.LocalLBPool.get_member_v2(poolNames); string[][] poolMemberDescriptions = m_interfaces.LocalLBPool.get_member_description(poolNames, poolMembers); // Loop Through All Pools for (int i = 0; i < poolNames.Length; i++) { // Get Full Name string sPoolName = poolNames[i]; // Get Node Short Name string sShortPoolName = sPoolName.Substring(sPoolName.LastIndexOf("/") + 1); // Ignore _auto_ Nodes if (sShortPoolName.ToLower().StartsWith("_auto_")) { continue; } // Get Oid Suffix string OidSuffix = GetOidSuffix(sPoolName, SNMP.ltmPoolStatusName, PoolSnmpResults); // Get Monitor Rule string MonitorRule = SNMP.GetSNMP(SNMP.ltmPoolMonitorRule + OidSuffix, sfog.DeviceList[0].Address, sfog.DeviceList[0].Port, sfog.DeviceList[0].Community)[0].Data.ToString(); // Create new Pool Pool newPool = new Pool(sfog, partition.partition_name, sPoolName, sShortPoolName, poolDescriptions[i], MonitorRule, poolMembers[i].Length, poolActiveMemberCount[i]); // Add Pool Members for (int j = 0; j < poolMembers[i].Length; j++) { // Get Oid Suffix string pmOidSuffix = GetOidSuffix(poolMembers[i][j].address, SNMP.ltmPoolMbrStatusNodeName, PoolMemberSnmpResults); // Get Monitor Rule (using SNMP as iControl seems to Error) string pmMonitorRule = SNMP.GetSNMP(SNMP.ltmPoolMemberMonitorRule + pmOidSuffix, sfog.DeviceList[0].Address, sfog.DeviceList[0].Port, sfog.DeviceList[0].Community)[0].Data.ToString(); // Create New Pool Member PoolMember newPoolMember = new PoolMember(sfog, partition.partition_name, sPoolName, poolMembers[i][j].address, poolMemberDescriptions[i][j], poolMembers[i][j].port.ToString(), pmMonitorRule); // Add to Pool newPool.PoolMembers.Add(newPoolMember); } // Add it to the List newPartition.PoolList.Add(newPool); // Match To Virtual Servers (DefaultPool) foreach (VirtualServer vs in newPartition.VirtualServerList) { if (vs.DefaultPoolName == sPoolName) { vs.DefaultPool = newPool; } } } // Get Nodes string[] nodeNameList = m_interfaces.LocalLBNodeAddressV2.get_list(); string[] nodeAddressList = m_interfaces.LocalLBNodeAddressV2.get_address(nodeNameList); string[] nodeDescriptionList = m_interfaces.LocalLBNodeAddressV2.get_description(nodeNameList); for (int i = 0; i < nodeNameList.Length; i++) { // Get Node Full Name string sNodeName = nodeNameList[i]; // Get Node Short Name string sShortNodeName = sNodeName.Substring(sNodeName.LastIndexOf("/") + 1); // Ignore _auto_ Nodes if (sShortNodeName.ToLower().StartsWith("_auto_")) { continue; } string MonitorRules = ""; try { LocalLBMonitorRule[] nodeMonitorRuleList = m_interfaces.LocalLBNodeAddressV2.get_monitor_rule(new string[] { sNodeName }); for (int j = 0; j < nodeMonitorRuleList[0].monitor_templates.Length; j++) { MonitorRules += nodeMonitorRuleList[0].monitor_templates[j].ToString() + ","; } MonitorRules = MonitorRules.TrimEnd(','); } catch (Exception) { } // Create a New Node Node newNode = new Node(sfog.Key, partition.partition_name, sNodeName, sShortNodeName, nodeAddressList[i], nodeDescriptionList[i], MonitorRules); newPartition.NodeList.Add(newNode); } // Take a Copy of Common Parition if (partition.partition_name == "Common") { CommonPartition = newPartition; } } } }