예제 #1
0
        private async Task BindCommon()
        {
            if (_TargetDisk == null)
            {
                throw new ArgumentException("MigrationTarget Disk object cannot be null.");
            }

            _IsBinding = true;

            if (_TargetDisk.TargetStorage != null && _TargetDisk.TargetStorage.GetType() == typeof(Azure.MigrationTarget.ManagedDiskStorage))
            {
                rbManagedDisk.Checked = true;
            }
            if (_TargetDisk.TargetStorage != null && _TargetDisk.TargetStorage.GetType() == typeof(Azure.MigrationTarget.StorageAccount))
            {
                rbStorageAccountInMigration.Checked = true;
            }
            else if (_TargetDisk.TargetStorage != null && _TargetDisk.TargetStorage.GetType() == typeof(Azure.Arm.StorageAccount))
            {
                rbExistingARMStorageAccount.Checked = true;
            }

            txtTargetDiskName.Text = _TargetDisk.TargetName;
            txtBlobName.Text       = _TargetDisk.TargetStorageAccountBlob;

            txtTargetSize.Text = _TargetDisk.DiskSizeInGB.ToString();

            lblAsmStorageAccount.Text = String.Empty;
            if (_TargetDisk.SourceDisk != null)
            {
                lblDiskName.Text     = _TargetDisk.TargetName;
                lblHostCaching.Text  = _TargetDisk.SourceDisk.HostCaching;
                lblLUN.Text          = _TargetDisk.SourceDisk.Lun.ToString();
                lblSourceSizeGb.Text = _TargetDisk.SourceDisk.DiskSizeGb.ToString();

                if (_TargetDisk.SourceDisk.GetType() == typeof(Azure.Asm.Disk))
                {
                    Azure.Asm.Disk asmDisk = (Azure.Asm.Disk)_TargetDisk.SourceDisk;
                    if (asmDisk.SourceStorageAccount != null)
                    {
                        lblAsmStorageAccount.Text = asmDisk.SourceStorageAccount.Name;
                    }
                }
                else if (_TargetDisk.SourceDisk.GetType() == typeof(Azure.Arm.ClassicDisk))
                {
                    Azure.Arm.ClassicDisk armDisk = (Azure.Arm.ClassicDisk)_TargetDisk.SourceDisk;
                    if (armDisk.SourceStorageAccount != null)
                    {
                        lblAsmStorageAccount.Text = armDisk.SourceStorageAccount.Name;
                    }
                }
            }
            else
            {
                lblDiskName.Text          = String.Empty;
                lblHostCaching.Text       = String.Empty;
                lblLUN.Text               = String.Empty;
                lblSourceSizeGb.Text      = String.Empty;
                lblAsmStorageAccount.Text = String.Empty;
            }

            if (_TargetTreeView.TargetResourceGroup != null && _TargetTreeView.TargetResourceGroup.TargetLocation != null)
            {
                rbExistingARMStorageAccount.Text    = "Existing Storage in " + _TargetTreeView.TargetResourceGroup.TargetLocation.DisplayName;
                rbExistingARMStorageAccount.Enabled = _TargetTreeView.GetExistingArmStorageAccounts().Count > 0;
            }
            else
            {
                // Cannot use existing ARM Storage without Target Location
                rbExistingARMStorageAccount.Enabled = false;
                rbExistingARMStorageAccount.Text    = "<Set Resource Group Location>";
            }

            if (!_TargetTreeView.HasStorageAccount)
            {
                rbStorageAccountInMigration.Enabled = false;
            }

            upDownLUN.Visible = _TargetDisk.Lun.HasValue;
            upDownLUN.Enabled = _TargetDisk.Lun.HasValue;
            if (_TargetDisk.Lun.HasValue)
            {
                // There is a chance that the assigned LUN Value exceeds the Max Allowed LUN Value.
                // This can happen, for example, if the Disk LUN was index 15 and the VM is resized from DS3 to DS2
                // thus exceeding the Max allowed.  In this case, we're going to temporarily increase the Max value
                // to avoid value assignment error, and then handle downsizing / scaling back the Max allowed value
                // as the value is decreased (max value reassignment to occur in the UpDown ValueChanged Event).
                // We are utilizing the MigAz Error validation here to tell the user their LUN index exceeds that of the VM Size.
                if (upDownLUN.Maximum < _TargetDisk.Lun.Value)
                {
                    // Since it exceeds, we'll allow the Max value increase, and downsize in the UpDown ValueChanged Event
                    upDownLUN.Maximum = _TargetDisk.Lun.Value;
                }

                if (_TargetDisk.Lun.Value == -1)
                {
                    upDownLUN.Minimum = -1;
                }
                else
                {
                    upDownLUN.Minimum = 0;
                }

                upDownLUN.Value = _TargetDisk.Lun.Value;
            }

            virtualMachineSummary.Bind(_TargetDisk.ParentVirtualMachine, _TargetTreeView, false);

            _IsBinding = false;
        }
예제 #2
0
        private async Task BindCommon()
        {
            if (_TargetDisk == null)
            {
                throw new ArgumentException("MigrationTarget Disk object cannot be null.");
            }

            _IsBinding = true;

            if (_TargetDisk.TargetStorage != null && _TargetDisk.TargetStorage.GetType() == typeof(Azure.MigrationTarget.ManagedDiskStorage))
            {
                rbManagedDisk.Checked = true;
            }
            if (_TargetDisk.TargetStorage != null && _TargetDisk.TargetStorage.GetType() == typeof(Azure.MigrationTarget.StorageAccount))
            {
                rbStorageAccountInMigration.Checked = true;
            }
            else if (_TargetDisk.TargetStorage != null && _TargetDisk.TargetStorage.GetType() == typeof(Azure.Arm.StorageAccount))
            {
                rbExistingARMStorageAccount.Checked = true;
            }

            lblAsmStorageAccount.Text = String.Empty;
            lblDiskName.Text          = _TargetDisk.TargetName;
            lblHostCaching.Text       = _TargetDisk.HostCaching;
            lblLUN.Text            = _TargetDisk.Lun.ToString();
            txtTargetDiskName.Text = _TargetDisk.TargetName;
            txtBlobName.Text       = _TargetDisk.TargetStorageAccountBlob;

            txtTargetSize.Text = _TargetDisk.DiskSizeInGB.ToString();

            if (_TargetDisk.SourceDisk != null)
            {
                lblSourceSizeGb.Text = _TargetDisk.SourceDisk.DiskSizeGb.ToString();

                if (_TargetDisk.SourceDisk.GetType() == typeof(Azure.Asm.Disk))
                {
                    Azure.Asm.Disk asmDisk = (Azure.Asm.Disk)_TargetDisk.SourceDisk;
                    if (asmDisk.SourceStorageAccount != null)
                    {
                        lblAsmStorageAccount.Text = asmDisk.SourceStorageAccount.Name;
                    }
                }
                else if (_TargetDisk.SourceDisk.GetType() == typeof(Azure.Arm.ClassicDisk))
                {
                    Azure.Arm.ClassicDisk armDisk = (Azure.Arm.ClassicDisk)_TargetDisk.SourceDisk;
                    if (armDisk.SourceStorageAccount != null)
                    {
                        lblAsmStorageAccount.Text = armDisk.SourceStorageAccount.Name;
                    }
                }
            }

            if (_TargetTreeView.TargetResourceGroup != null && _TargetTreeView.TargetResourceGroup.TargetLocation != null)
            {
                rbExistingARMStorageAccount.Text    = "Existing Storage in " + _TargetTreeView.TargetResourceGroup.TargetLocation.DisplayName;
                rbExistingARMStorageAccount.Enabled = _TargetTreeView.GetExistingArmStorageAccounts().Count > 0;
            }
            else
            {
                // Cannot use existing ARM Storage without Target Location
                rbExistingARMStorageAccount.Enabled = false;
                rbExistingARMStorageAccount.Text    = "<Set Resource Group Location>";
            }

            if (!_TargetTreeView.HasStorageAccount)
            {
                rbStorageAccountInMigration.Enabled = false;
            }

            virtualMachineSummary.Bind(_TargetDisk.ParentVirtualMachine, _TargetTreeView, false);

            _IsBinding = false;
        }