Exemplo n.º 1
0
        internal void Bind(AsmToArm asmToArmForm, Azure.Asm.Disk asmDisk)
        {
            _AsmToArmForm = asmToArmForm;
            _AsmDataDisk  = asmDisk;

            BindCommon();
        }
Exemplo n.º 2
0
        internal void Bind(AsmToArm asmToArmForm, TreeNode armDataDiskNode)
        {
            _AsmToArmForm    = asmToArmForm;
            _ARMDataDiskNode = armDataDiskNode;
            _AsmDataDisk     = (Azure.Asm.Disk)_ARMDataDiskNode.Tag;

            BindCommon();
        }
Exemplo n.º 3
0
        private void BindCommon()
        {
            if (AllowManangedDisk)
            {
                rbManagedDisk.Checked = true;
            }
            else
            {
                if (_TargetDisk != null)
                {
                    if (_TargetDisk.TargetStorageAccount == null || (_TargetDisk.TargetStorageAccount != null && _TargetDisk.TargetStorageAccount.GetType() == typeof(Azure.MigrationTarget.StorageAccount)))
                    {
                        rbStorageAccountInMigration.Checked = true;
                    }
                    else if (_TargetDisk.TargetStorageAccount != null && _TargetDisk.TargetStorageAccount.GetType() == typeof(Azure.Arm.StorageAccount))
                    {
                        rbExistingARMStorageAccount.Checked = true;
                    }
                }
            }

            if (_TargetDisk != null)
            {
                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;

                if (_TargetDisk.SourceDisk != null)
                {
                    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.Disk))
                    {
                        Azure.Arm.Disk armDisk = (Azure.Arm.Disk)_TargetDisk.SourceDisk;
                        if (armDisk.SourceStorageAccount != null)
                        {
                            lblAsmStorageAccount.Text = armDisk.SourceStorageAccount.Name;
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void SeekAlertSourceRecursive(object sourceObject, TreeNodeCollection nodes)
        {
            foreach (TreeNode treeNode in nodes)
            {
                if (treeNode.Tag != null)
                {
                    object nodeObject = null;

                    if (treeNode.Tag.GetType() == typeof(TreeNode))
                    {
                        TreeNode asmTreeNode = (TreeNode)treeNode.Tag;
                        nodeObject = asmTreeNode.Tag;
                    }
                    else
                    {
                        nodeObject = treeNode.Tag;
                    }

                    // Note, this could probably be object compares, but was written this was to get it done.  Possible future change to object compares
                    if (nodeObject.GetType() == sourceObject.GetType())
                    {
                        if (sourceObject.GetType() == typeof(ResourceGroup))
                        {
                            treeTargetARM.SelectedNode = treeNode;
                        }
                        else if (sourceObject.GetType() == typeof(Azure.Asm.VirtualMachine))
                        {
                            Azure.Asm.VirtualMachine sourceMachine = (Azure.Asm.VirtualMachine)sourceObject;
                            Azure.Asm.VirtualMachine nodeMachine   = (Azure.Asm.VirtualMachine)nodeObject;
                            if (sourceMachine.RoleName == nodeMachine.RoleName)
                            {
                                treeTargetARM.SelectedNode = treeNode;
                            }
                        }
                        else if (sourceObject.GetType() == typeof(Azure.Asm.Disk))
                        {
                            Azure.Asm.Disk sourceDisk = (Azure.Asm.Disk)sourceObject;
                            Azure.Asm.Disk nodeDisk   = (Azure.Asm.Disk)nodeObject;
                            if (sourceDisk.DiskName == nodeDisk.DiskName)
                            {
                                treeTargetARM.SelectedNode = treeNode;
                            }
                        }
                    }
                }
                SeekAlertSourceRecursive(sourceObject, treeNode.Nodes);
            }
        }
Exemplo n.º 5
0
        private async Task BindCommon()
        {
            if (_TargetDisk == null)
            {
                throw new ArgumentException("MigrationTarget Disk object cannot be null.");
            }

            if (AllowManangedDisk && _TargetDisk.TargetStorageAccount != null && _TargetDisk.TargetStorageAccount.GetType() == typeof(Azure.MigrationTarget.ManagedDisk))
            {
                rbManagedDisk.Checked = true;
            }
            if (_TargetDisk.TargetStorageAccount == null || (_TargetDisk.TargetStorageAccount != null && _TargetDisk.TargetStorageAccount.GetType() == typeof(Azure.MigrationTarget.StorageAccount)))
            {
                rbStorageAccountInMigration.Checked = true;
            }
            else if (_TargetDisk.TargetStorageAccount != null && _TargetDisk.TargetStorageAccount.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.Disk))
                {
                    Azure.Arm.Disk armDisk = (Azure.Arm.Disk)_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;
                List <Azure.Arm.StorageAccount> a = await _AzureContext.AzureRetriever.GetAzureARMStorageAccounts(_TargetTreeView.TargetResourceGroup.TargetLocation);

                rbExistingARMStorageAccount.Enabled = a.Count() > 0;
            }
            else
            {
                // Cannot use existing ARM Storage without Target Location
                rbExistingARMStorageAccount.Enabled = false;
                rbExistingARMStorageAccount.Text    = "<Set Resource Group Location>";
            }
        }
Exemplo n.º 6
0
        private async void treeARM_AfterSelect(object sender, TreeViewEventArgs e)
        {
            LogProvider.WriteLog("treeARM_AfterSelect", "Start");
            _SourceArmNode = e.Node;

            _PropertyPanel.Clear();
            _PropertyPanel.ResourceText = String.Empty;
            if (e.Node.Tag != null)
            {
                if (e.Node.Tag.GetType() == typeof(TreeNode))
                {
                    TreeNode asmTreeNode = (TreeNode)e.Node.Tag;

                    if (asmTreeNode.Tag != null)
                    {
                        _PropertyPanel.ResourceText = e.Node.Text;

                        if (asmTreeNode.Tag.GetType() == typeof(Azure.Asm.VirtualNetwork) || asmTreeNode.Tag.GetType() == typeof(Azure.Arm.VirtualNetwork))
                        {
                            this._PropertyPanel.ResourceImage = imageList1.Images["VirtualNetwork"];

                            VirtualNetworkProperties properties = new VirtualNetworkProperties();
                            properties.PropertyChanged += Properties_PropertyChanged;
                            properties.Bind(e.Node);
                            _PropertyPanel.PropertyDetailControl = properties;
                        }
                        else if (asmTreeNode.Tag.GetType() == typeof(Azure.Asm.StorageAccount) || asmTreeNode.Tag.GetType() == typeof(Azure.Arm.StorageAccount))
                        {
                            this._PropertyPanel.ResourceImage = imageList1.Images["StorageAccount"];

                            StorageAccountProperties properties = new StorageAccountProperties();
                            properties.PropertyChanged += Properties_PropertyChanged;
                            properties.Bind(this._AzureContextTargetARM, e.Node);
                            _PropertyPanel.PropertyDetailControl = properties;
                        }
                        else if (asmTreeNode.Tag.GetType() == typeof(Azure.Asm.VirtualMachine) || asmTreeNode.Tag.GetType() == typeof(Azure.Arm.VirtualMachine))
                        {
                            this._PropertyPanel.ResourceImage = imageList1.Images["VirtualMachine"];

                            VirtualMachineProperties properties = new VirtualMachineProperties();
                            properties.LogProvider       = LogProvider;
                            properties.AllowManangedDisk = (await _AzureContextSourceASM.AzureRetriever.GetAzureARMManagedDisks() != null);
                            properties.PropertyChanged  += Properties_PropertyChanged;
                            await properties.Bind(e.Node, this);

                            _PropertyPanel.PropertyDetailControl = properties;
                        }
                        else if (asmTreeNode.Tag.GetType() == typeof(Azure.Asm.NetworkSecurityGroup) || asmTreeNode.Tag.GetType() == typeof(Azure.Arm.NetworkSecurityGroup))
                        {
                            this._PropertyPanel.ResourceImage = imageList1.Images["NetworkSecurityGroup"];

                            NetworkSecurityGroupProperties properties = new NetworkSecurityGroupProperties();
                            properties.PropertyChanged += Properties_PropertyChanged;
                            properties.Bind(e.Node, this);
                            _PropertyPanel.PropertyDetailControl = properties;
                        }
                    }
                }
                if (e.Node.Tag.GetType() == typeof(Azure.Asm.Subnet) || e.Node.Tag.GetType() == typeof(Azure.Arm.Subnet))
                {
                    this._PropertyPanel.ResourceImage = imageList1.Images["VirtualNetwork"];

                    SubnetProperties properties = new SubnetProperties();
                    properties.PropertyChanged += Properties_PropertyChanged;
                    properties.Bind(e.Node);
                    _PropertyPanel.PropertyDetailControl = properties;
                }
                else if (e.Node.Tag.GetType() == typeof(Azure.Asm.Disk) || e.Node.Tag.GetType() == typeof(Azure.Arm.Disk))
                {
                    Azure.Asm.Disk asmDisk = (Azure.Asm.Disk)e.Node.Tag;

                    this._PropertyPanel.ResourceImage = imageList1.Images["Disk"];

                    DiskProperties properties = new DiskProperties();
                    properties.LogProvider       = this.LogProvider;
                    properties.AllowManangedDisk = (await _AzureContextSourceASM.AzureRetriever.GetAzureARMManagedDisks() != null);
                    properties.PropertyChanged  += Properties_PropertyChanged;
                    properties.Bind(this, e.Node);
                    _PropertyPanel.PropertyDetailControl = properties;
                }
                else if (e.Node.Tag.GetType() == typeof(Azure.Asm.AvailabilitySet))
                {
                    this._PropertyPanel.ResourceImage = imageList1.Images["AvailabilitySet"];

                    AvailabilitySetProperties properties = new AvailabilitySetProperties();
                    properties.PropertyChanged += Properties_PropertyChanged;
                    properties.Bind(e.Node);
                    _PropertyPanel.PropertyDetailControl = properties;
                }
                else if (e.Node.Tag.GetType() == typeof(ResourceGroup))
                {
                    this._PropertyPanel.ResourceImage = imageList1.Images["ResourceGroup"];

                    ResourceGroupProperties properties = new ResourceGroupProperties();
                    properties.PropertyChanged += Properties_PropertyChanged;
                    await properties.Bind(this, e.Node);

                    _PropertyPanel.PropertyDetailControl = properties;
                }
            }

            _SourceArmNode = null;
            LogProvider.WriteLog("treeARM_AfterSelect", "End");
            StatusProvider.UpdateStatus("Ready");
        }
Exemplo n.º 7
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;
        }
Exemplo n.º 8
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;
        }