Exemple #1
0
        public async Task InitializeChildren()
        {
            this._TargetAvailabilitySet = _AzureContext.AzureRetriever.GetAzureARMAvailabilitySet(this);


            if (this.VirtualNetworkName != String.Empty)
            {
                _SourceVirtualNetwork = await _AzureContext.AzureRetriever.GetAzureAsmVirtualNetwork(this.VirtualNetworkName);

                if (_SourceVirtualNetwork != null)
                {
                    foreach (AsmSubnet asmSubnet in _SourceVirtualNetwork.Subnets)
                    {
                        if (asmSubnet.Name == this.SubnetName)
                        {
                            _SourceSubnet = asmSubnet;
                            break;
                        }
                    }
                }
            }

            await _OSVirtualHardDisk.InitializeChildren();

            foreach (AsmDisk asmDisk in this.DataDisks)
            {
                await asmDisk.InitializeChildren();
            }

            if (this.NetworkSecurityGroupName != String.Empty)
            {
                _AsmNetworkSecurityGroup = await _AzureContext.AzureRetriever.GetAzureAsmNetworkSecurityGroup(this.NetworkSecurityGroupName);
            }
        }
        private void txtTargetName_TextChanged(object sender, EventArgs e)
        {
            TextBox txtSender = (TextBox)sender;

            ArmAvailabilitySet armAvailabilitySet = (ArmAvailabilitySet)_armAvailabilitySetNode.Tag;

            armAvailabilitySet.TargetName = txtSender.Text;
            _armAvailabilitySetNode.Text  = armAvailabilitySet.GetFinalTargetName();
        }
        internal void Bind(TreeNode availabilitySetNode)
        {
            _armAvailabilitySetNode = availabilitySetNode;

            ArmAvailabilitySet armAvailabilitySet = (ArmAvailabilitySet)_armAvailabilitySetNode.Tag;

            //lblAccountType.Text = asmCloudService.AccountType;
            txtTargetName.Text = armAvailabilitySet.TargetName;
        }
Exemple #4
0
        internal ArmAvailabilitySet GetAzureARMAvailabilitySet(AsmVirtualMachine asmVirtualMachine)
        {
            if (_ArmAvailabilitySets == null)
            {
                _ArmAvailabilitySets = new List <ArmAvailabilitySet>();
            }

            foreach (ArmAvailabilitySet armAvailabilitySet in _ArmAvailabilitySets)
            {
                if (armAvailabilitySet.name == asmVirtualMachine.GetDefaultAvailabilitySetName())
                {
                    return(armAvailabilitySet);
                }
            }

            ArmAvailabilitySet newArmAvailabilitySet = new ArmAvailabilitySet(this._AzureContext, asmVirtualMachine);

            _ArmAvailabilitySets.Add(newArmAvailabilitySet);

            return(newArmAvailabilitySet);
        }
Exemple #5
0
        private bool RecursiveHealthCheckNode(TreeNode treeNode)
        {
            if (treeNode.Tag != null)
            {
                if (treeNode.Tag.GetType() == typeof(ArmResourceGroup))
                {
                    ArmResourceGroup armResourceGroup = (ArmResourceGroup)treeNode.Tag;

                    if (armResourceGroup.Location == null)
                    {
                        treeARM.SelectedNode = treeNode;
                        this.Refresh();
                        MessageBox.Show("Target Location must be selected before exporting.");
                        return(false);
                    }
                }
                else if (treeNode.Tag.GetType() == typeof(TreeNode)) // Tag is the sourced ASM TreeNode
                {
                    TreeNode asmTreeNode = (TreeNode)treeNode.Tag;

                    if (asmTreeNode.Tag != null)
                    {
                        if (asmTreeNode.Tag.GetType() == typeof(AsmNetworkSecurityGroup))
                        {
                            AsmNetworkSecurityGroup asmNetworkSecurityGroup = (AsmNetworkSecurityGroup)asmTreeNode.Tag;

                            // Validate the Target Name is not blank
                            if (asmNetworkSecurityGroup.TargetName == String.Empty)
                            {
                                treeARM.SelectedNode = treeNode;
                                this.Refresh();
                                MessageBox.Show("Target Name must be selected before exporting.");
                                return(false);
                            }
                        }
                        else if (asmTreeNode.Tag.GetType() == typeof(AsmVirtualNetwork))
                        {
                            AsmVirtualNetwork asmVirtualNetwork = (AsmVirtualNetwork)asmTreeNode.Tag;

                            // Validate the Target Name is not blank
                            if (asmVirtualNetwork.TargetName == String.Empty)
                            {
                                treeARM.SelectedNode = treeNode;
                                this.Refresh();
                                MessageBox.Show("Target Name must be selected before exporting.");
                                return(false);
                            }

                            foreach (TreeNode virtualNetworkNode in treeNode.Parent.Nodes)
                            {
                                TreeNode          asmVirtualNetworkNode    = (TreeNode)virtualNetworkNode.Tag;
                                AsmVirtualNetwork asmVirtualNetworkCompare = (AsmVirtualNetwork)asmVirtualNetworkNode.Tag;

                                if (asmVirtualNetworkCompare.Name != asmVirtualNetwork.Name && asmVirtualNetworkCompare.TargetName == asmVirtualNetwork.TargetName)
                                {
                                    treeARM.SelectedNode = treeNode;
                                    this.Refresh();
                                    MessageBox.Show("Target Names must be unique to migrate Virtual Networks.");
                                    return(false);
                                }
                            }
                        }
                        else if (asmTreeNode.Tag.GetType() == typeof(AsmVirtualMachine))
                        {
                            AsmVirtualMachine asmVirtualMachine = (AsmVirtualMachine)asmTreeNode.Tag;

                            if (asmVirtualMachine.TargetName == String.Empty)
                            {
                                treeARM.SelectedNode = treeNode;
                                this.Refresh();
                                MessageBox.Show("Target Name for Virtual Machine must be specified.");
                                return(false);
                            }

                            if (asmVirtualMachine.TargetAvailabilitySet == null)
                            {
                                treeARM.SelectedNode = treeNode;
                                this.Refresh();
                                MessageBox.Show("Target Availability Set for Virtual Machine must be specified.");
                                return(false);
                            }

                            if (asmVirtualMachine.TargetVirtualNetwork == null)
                            {
                                treeARM.SelectedNode = treeNode;
                                this.Refresh();
                                MessageBox.Show("Target Virtual Network for Virtual Machine must be specified.");
                                return(false);
                            }

                            if (asmVirtualMachine.TargetSubnet == null)
                            {
                                treeARM.SelectedNode = treeNode;
                                this.Refresh();
                                MessageBox.Show("Target Subnet for Virtual Machine must be specified.");
                                return(false);
                            }

                            if (asmVirtualMachine.OSVirtualHardDisk.TargetStorageAccount == null)
                            {
                                treeARM.SelectedNode = treeNode;
                                this.Refresh();
                                MessageBox.Show("Target VM OS Disk Storage Account must be specified.");
                                return(false);
                            }
                        }
                        else if (asmTreeNode.Tag.GetType() == typeof(AsmStorageAccount))
                        {
                            AsmStorageAccount asmStorageAccount = (AsmStorageAccount)asmTreeNode.Tag;
                            if (asmStorageAccount.TargetName == String.Empty)
                            {
                                treeARM.SelectedNode = treeNode;
                                this.Refresh();
                                MessageBox.Show("Target Storage Account Name must be specified.");
                                return(false);
                            }
                        }
                    }
                }
                else if (treeNode.Tag.GetType() == typeof(AsmSubnet))
                {
                    AsmSubnet asmSubnet = (AsmSubnet)treeNode.Tag;
                    if (asmSubnet.TargetName == String.Empty)
                    {
                        treeARM.SelectedNode = treeNode;
                        this.Refresh();
                        MessageBox.Show("Target Subnet Name must be specified.");
                        return(false);
                    }
                }
                else if (treeNode.Tag.GetType() == typeof(ArmAvailabilitySet))
                {
                    ArmAvailabilitySet armAvailabilitySet = (ArmAvailabilitySet)treeNode.Tag;
                    if (armAvailabilitySet.TargetName == String.Empty)
                    {
                        treeARM.SelectedNode = treeNode;
                        this.Refresh();
                        MessageBox.Show("Target Availability Set Name must be specified.");
                        return(false);
                    }
                }
                else if (treeNode.Tag.GetType() == typeof(AsmDisk))
                {
                    AsmDisk asmDisk = (AsmDisk)treeNode.Tag;

                    if (asmDisk.TargetStorageAccount == null)
                    {
                        treeARM.SelectedNode = treeNode;
                        this.Refresh();
                        MessageBox.Show("Target VM Data Disk Storage Account must be specified.");
                        return(false);
                    }
                }
            }

            foreach (TreeNode childNode in treeNode.Nodes)
            {
                bool nodeResult = RecursiveHealthCheckNode(childNode);
                if (nodeResult == false)
                {
                    return(false);
                }
            }

            return(true);
        }