private bool Create_VM_IaaS_Server_Rehost_Perf_Model()

in src/Assessment/Processor/ProcessDatasets.cs [1838:1929]


        private bool Create_VM_IaaS_Server_Rehost_Perf_Model(List<VM_IaaS_Server_Rehost_Perf> VM_IaaS_Server_Rehost_Perf_List, HashSet<string> AzureVM_Opportunity_Perf)
        {
            if (AzureVMPerformanceBasedMachinesData == null)
            {
                UserInputObj.LoggerObj.LogWarning("Not generating excel model for VM_IaaS_Server_Rehost_Perf as Azure VM Perf dataset is null");
                return false;
            }
            if (AzureVMPerformanceBasedMachinesData.Count <= 0)
            {
                UserInputObj.LoggerObj.LogWarning("Not generating excel model for VM_IaaS_Server_Rehost_Perf as Azure VM Perf dataset is empty");
                return false;
            }

            UserInputObj.LoggerObj.LogInformation("Creating excel model for VM_IaaS_Server_Rehost_Perf");

            if (VM_IaaS_Server_Rehost_Perf_List == null)
                VM_IaaS_Server_Rehost_Perf_List = new List<VM_IaaS_Server_Rehost_Perf>();
            if (AzureVM_Opportunity_Perf == null)
                AzureVM_Opportunity_Perf = new HashSet<string>();
            
            foreach (var discoveredMachineId in GeneralVM)
            {
                if (!AzureVMPerformanceBasedMachinesData.ContainsKey(discoveredMachineId))
                {
                    UserInputObj.LoggerObj.LogWarning($"Discovered Machine ID: {discoveredMachineId} does not exist in Azure VM Perf dataset, skipping");
                    continue;
                }

                var value = AzureVMPerformanceBasedMachinesData[discoveredMachineId];
                
                if (value.Suitability != Suitabilities.Suitable && value.Suitability != Suitabilities.ConditionallySuitable)
                {
                    if (!AzureVM_Opportunity_Perf.Contains(discoveredMachineId))
                        AzureVM_Opportunity_Perf.Add(discoveredMachineId);
                    continue;
                }

                VM_IaaS_Server_Rehost_Perf obj = new VM_IaaS_Server_Rehost_Perf();

                obj.MachineName = value.DisplayName;
                obj.Environment = value.Environment;
                obj.AzureVMReadiness = new EnumDescriptionHelper().GetEnumDescription(value.Suitability);
                obj.AzureVMReadiness_Warnings = value.SuitabilityExplanation;
                obj.RecommendedVMSize = value.RecommendedVMSize;
                obj.MonthlyComputeCostEstimate = value.MonthlyComputeCostEstimate;
                obj.MonthlyComputeCostEstimate_RI3year = value.MonthlyComputeCostEstimate_RI3year;
                obj.MonthlyComputeCostEstimate_AHUB = value.MonthlyComputeCostEstimate_AHUB;
                obj.MonthlyComputeCostEstimate_AHUB_RI3year = value.MonthlyComputeCostEstimate_AHUB_RI3year;
                obj.MonthlyComputeCostEstimate_ASP3year = value.MonthlyComputeCostEstimate_ASP3year;
                obj.MonthlyStorageCostEstimate = value.StorageMonthlyCost;
                obj.MonthlySecurityCostEstimate = value.MonthlySecurityCost;
                obj.OperatingSystem = UtilityFunctions.GetStringValue(value.OperatingSystem);
                obj.SupportStatus = value.SupportStatus;
                obj.VMHost = UtilityFunctions.GetStringValue(value.DatacenterManagementServerName);
                obj.BootType = UtilityFunctions.GetStringValue(value.BootType);
                obj.Cores = value.NumberOfCores;
                obj.MemoryInMB = value.MegabytesOfMemory;
                obj.CpuUtilizationPercentage = value.PercentageOfCoresUtilization;
                obj.MemoryUtilizationPercentage = value.PercentageOfMemoryUtilization;
                obj.StorageInGB = UtilityFunctions.GetTotalStorage(value.Disks);
                obj.NetworkAdapters = value.NetworkAdapters;

                var macIpKvp = UtilityFunctions.ParseMacIpAddress(value.NetworkAdapterList);
                obj.MacAddresses = macIpKvp.Key;
                obj.IpAddresses = macIpKvp.Value;

                obj.DiskNames = UtilityFunctions.GetDiskNames(value.Disks);
                obj.AzureDiskReadiness = UtilityFunctions.GetDiskReadiness(value.Disks);
                obj.RecommendedDiskSKUs = UtilityFunctions.GetRecommendedDiskSKUs(value.Disks);

                obj.StandardHddDisks = UtilityFunctions.GetDiskTypeCount(value.Disks, RecommendedDiskTypes.Standard);
                obj.StandardSsdDisks = UtilityFunctions.GetDiskTypeCount(value.Disks, RecommendedDiskTypes.StandardSSD);
                obj.PremiumDisks = UtilityFunctions.GetDiskTypeCount(value.Disks, RecommendedDiskTypes.Premium);
                obj.UltraDisks = UtilityFunctions.GetDiskTypeCount(value.Disks, RecommendedDiskTypes.Ultra);

                obj.MonthlyStorageCostForStandardHddDisks = UtilityFunctions.GetDiskTypeStorageCost(value.Disks, RecommendedDiskTypes.Standard);
                obj.MonthlyStorageCostForStandardSsdDisks = UtilityFunctions.GetDiskTypeStorageCost(value.Disks, RecommendedDiskTypes.StandardSSD);
                obj.MonthlyStorageCostForPremiumDisks = UtilityFunctions.GetDiskTypeStorageCost(value.Disks, RecommendedDiskTypes.Premium);
                obj.MonthlyStorageCostForUltraDisks = UtilityFunctions.GetDiskTypeStorageCost(value.Disks, RecommendedDiskTypes.Ultra);

                obj.MonthlyAzureSiteRecoveryCostEstimate = value.AzureSiteRecoveryMonthlyCostEstimate;
                obj.MonthlyAzureBackupCostEstimate = value.AzureBackupMonthlyCostEstimate;

                obj.GroupName = value.GroupName;
                obj.MachineId = value.DatacenterMachineArmId;

                VM_IaaS_Server_Rehost_Perf_List.Add(obj);
            }

            UserInputObj.LoggerObj.LogInformation($"Updated VM_IaaS_Server_Rehost_Perf excel model with data of {VM_IaaS_Server_Rehost_Perf_List.Count} machines");
            return true;
        }