Esempio n. 1
0
        /// <summary>
        /// Checks the available VM Platforms in the database to make sure that
        /// the number of VMs needed for the test does not exceed the available.
        /// </summary>
        /// <param name="scenario"></param>
        /// <param name="platform"></param>
        /// <param name="holdId"></param>
        /// <returns>true if enough VM Platforms are available, false otherwise.</returns>
        private static bool CheckPlatformsAvailable(EnterpriseScenario scenario, FrameworkClientPlatform platform, string holdId)
        {
            ScenarioPlatformUsageSet usages = new ScenarioPlatformUsageSet(scenario);

            if (platform != null)
            {
                usages.Load(UserManager.CurrentUser, platform);
            }
            else if (string.IsNullOrEmpty(holdId) == false)
            {
                usages.Load(UserManager.CurrentUser, holdId);
            }
            else
            {
                usages.Load(UserManager.CurrentUser);
            }

            if (!usages.PlatformsAvailable)
            {
                using (InsufficientPlatformsErrorForm form = new InsufficientPlatformsErrorForm(usages))
                {
                    form.ShowDialog();
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 2
0
        private void UpdateVirtualMachineList(bool isChecked, FrameworkClientPlatform currentPlatform, VirtualMachineRow virtualMachineRow)
        {
            FrameworkClient frameworkClient = _assetInventoryContext.FrameworkClients.Find(virtualMachineRow.Machine.Name);

            if (isChecked && !frameworkClient.Platforms.Contains(currentPlatform))
            {
                frameworkClient.Platforms.Add(currentPlatform);
            }
            else
            {
                frameworkClient.Platforms.Remove(currentPlatform);
            }
        }
Esempio n. 3
0
        private void platform_DataGridView_SelectionChanged(object sender, EventArgs e)
        {
            virtualMachine_DataGridView.ClearSelection();
            resourceType_DataGridView.ClearSelection();

            if (platform_DataGridView.SelectedRows.Count == 1)
            {
                FrameworkClientPlatform selectedPlatform = platform_DataGridView.SelectedRows[0].DataBoundItem as FrameworkClientPlatform;

                if (selectedPlatform != null)
                {
                    PopulateCheckboxes(selectedPlatform);
                }
            }
        }
Esempio n. 4
0
        private void virtualMachine_DataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                if (e.ColumnIndex == 0)
                {
                    // The boolean value here is swapped, because the checked value of the control is
                    // opposite of where it is heading.
                    bool isChecked = !(bool)virtualMachine_DataGridView.Rows[e.RowIndex].Cells["virtualMachineSelectedColumn"].Value;
                    FrameworkClientPlatform currentPlatform   = platform_DataGridView.SelectedRows[0].DataBoundItem as FrameworkClientPlatform;
                    VirtualMachineRow       virtualMachineRow = virtualMachine_DataGridView.Rows[e.RowIndex].DataBoundItem as VirtualMachineRow;

                    UpdateVirtualMachineList(isChecked, currentPlatform, virtualMachineRow);
                }
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Updates the resource type list.
 /// </summary>
 /// <param name="isChecked">if set to <c>true</c> the checkbox is checked.</param>
 /// <param name="currentPlatform">The current platform.</param>
 /// <param name="resourceType">Type of the resource.</param>
 private static void UpdateResourceTypeList(bool isChecked, FrameworkClientPlatform currentPlatform, ResourceType resourceType)
 {
     if (resourceType != null)
     {
         ResourceTypeFrameworkClientPlatformAssociation existingAssociation = resourceType.FrameworkClientPlatforms.FirstOrDefault(n => n.FrameworkClientPlatformId == currentPlatform.FrameworkClientPlatformId);
         if (isChecked && existingAssociation == null)
         {
             resourceType.FrameworkClientPlatforms.Add(new ResourceTypeFrameworkClientPlatformAssociation {
                 FrameworkClientPlatformId = currentPlatform.FrameworkClientPlatformId, ResourceTypeName = resourceType.Name
             });
         }
         else
         {
             resourceType.FrameworkClientPlatforms.Remove(existingAssociation);
         }
     }
 }
Esempio n. 6
0
        /// <summary>
        /// Populates the checkboxes.
        /// </summary>
        /// <param name="selectedPlatform">The selected platform.</param>
        private void PopulateCheckboxes(FrameworkClientPlatform selectedPlatform)
        {
            Cursor = Cursors.WaitCursor;
            if (selectedPlatform != null)
            {
                foreach (DataGridViewRow row in virtualMachine_DataGridView.Rows)
                {
                    bool check = ((VirtualMachineRow)row.DataBoundItem).Machine.Platforms.Any(n => n.FrameworkClientPlatformId == selectedPlatform.FrameworkClientPlatformId);
                    row.Cells[0].Value = check;
                }

                foreach (DataGridViewRow row in resourceType_DataGridView.Rows)
                {
                    bool check = ((ResourceTypeRow)row.DataBoundItem).ResourceType.FrameworkClientPlatforms.Any(n => n.FrameworkClientPlatformId == selectedPlatform.FrameworkClientPlatformId);
                    row.Cells[0].Value = check;
                }
            }
            Cursor = Cursors.Default;
        }
Esempio n. 7
0
        /// <summary>
        /// Deletes the platform entry.
        /// </summary>
        /// <param name="platform">The platform.</param>
        /// <returns></returns>
        private bool DeletePlatformEntry(FrameworkClientPlatform platform)
        {
            bool cancel = false;

            if (_enterpriseTestContext.VirtualResources.Any(f => f.Platform == platform.FrameworkClientPlatformId))
            {
                MessageBox.Show
                (
                    this,
                    "You cannot delete this Platform Association as it is currently being referenced by Virtual Resource entries in the database.",
                    "Cannot Delete Platform Association",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Stop
                );
                cancel = true;
            }
            else
            {
                _assetInventoryContext.FrameworkClientPlatforms.Remove(platform);
            }

            return(cancel);
        }
        /// <summary>
        /// Loads based on the specified user and Hold Id.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <param name="role">The role.</param>
        public void Load(UserCredential user, string holdId)
        {
            SessionResourceQuantity quantity = GetQuantities(Scenario);

            using (AssetInventoryContext context = DbConnect.AssetInventoryContext())
            {
                foreach (string platformId in quantity.MachineQuantity.Keys)
                {
                    FrameworkClientPlatform platform = context.FrameworkClientPlatforms.FirstOrDefault(x => x.FrameworkClientPlatformId.Equals(platformId));
                    int count = VirtualMachine.GetUsageCountByHold(platformId, holdId, user);

                    var usage = new ScenarioPlatformUsage()
                    {
                        PlatformId      = platformId,
                        Description     = platform.Name,
                        RequiredCount   = quantity.MachineQuantity[platformId],
                        AuthorizedCount = count
                    };

                    Add(usage);
                }
            }
        }
        /// <summary>
        /// Loads based on the specified user and Platform.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <param name="role">The user role (User, Admin, etc.).</param>
        /// <param name="platform">The virtual machine platform.</param>
        public void Load(UserCredential user, FrameworkClientPlatform platform)
        {
            SessionResourceQuantity quantity = GetQuantities(Scenario);

            int requiredCount = 0;

            if (quantity.MachineQuantity.ContainsKey(platform.FrameworkClientPlatformId))
            {
                requiredCount = quantity.MachineQuantity[platform.FrameworkClientPlatformId];
            }

            int count = VirtualMachine.GetUsageCountByPlatform(platform.FrameworkClientPlatformId, user);

            var usage = new ScenarioPlatformUsage()
            {
                PlatformId      = platform.FrameworkClientPlatformId,
                Description     = platform.Name,
                RequiredCount   = requiredCount,
                AuthorizedCount = count
            };

            Add(usage);
        }
Esempio n. 10
0
        /// <summary>
        /// Validates scenario data for the given scenario and checks to ensure enough free VMs (by platform type).
        /// </summary>
        /// <param name="scenario">The scenario to check.</param>
        /// <param name="platform">The Virtual Machine Platform requested, if any.</param>
        /// <param name="holdId">The Hold Id, if any.</param>
        /// <returns>true if the check passes, false otherwise.</returns>
        private static bool PerformScenarioIntegrityCheck(EnterpriseScenario scenario, FrameworkClientPlatform platform, string holdId)
        {
            List <string> issues = scenario.ValidateData().ToList();

            issues.AddRange(ValidateUsages(scenario));

            // STF-only
            if (GlobalSettings.IsDistributedSystem)
            {
                if (!CheckPlatformsAvailable(scenario, platform, holdId))
                {
                    return(false);
                }
            }

            if (issues.Any())
            {
                StringBuilder message = new StringBuilder("The following issues were found with the selected scenario:\n");
                message.Append(string.Join("\n", issues));
                message.Append("\n\nDo you want to continue?");
                DialogResult result = MessageBox.Show(message.ToString(), "Scenario Validation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                return(result == DialogResult.Yes);
            }

            return(true);
        }
Esempio n. 11
0
 /// <summary>
 /// Validates scenario data for the given scenario and checks to ensure enough free VMs (by platform type).
 /// </summary>
 /// <param name="scenario">The scenario to check.</param>
 /// <param name="platform"></param>
 /// <returns>true if the check passes, false otherwise.</returns>
 public static bool PerformScenarioIntegrityCheck(EnterpriseScenario scenario, FrameworkClientPlatform platform)
 {
     return(PerformScenarioIntegrityCheck(scenario, platform, null));
 }