Beispiel #1
0
        private void cmbExistingArmSubnet_SelectedIndexChanged(object sender, EventArgs e)
        {
            TreeNode          asmTreeNode       = (TreeNode)_VirtualMachineNode.Tag;
            AsmVirtualMachine asmVirtualMachine = (AsmVirtualMachine)asmTreeNode.Tag;
            ComboBox          cmbSender         = (ComboBox)sender;

            if (cmbSender.SelectedItem == null)
            {
                asmVirtualMachine.TargetVirtualNetwork = null;
                asmVirtualMachine.TargetSubnet         = null;
            }
            else
            {
                if (cmbSender.SelectedItem.GetType() == typeof(AsmSubnet))
                {
                    AsmSubnet asmSubnet = (AsmSubnet)cmbSender.SelectedItem;
                    asmVirtualMachine.TargetVirtualNetwork = asmSubnet.Parent;
                    asmVirtualMachine.TargetSubnet         = asmSubnet;
                }
                else if (cmbSender.SelectedItem.GetType() == typeof(ArmSubnet))
                {
                    ArmSubnet armSubnet = (ArmSubnet)cmbSender.SelectedItem;
                    asmVirtualMachine.TargetVirtualNetwork = armSubnet.Parent;
                    asmVirtualMachine.TargetSubnet         = armSubnet;
                }
            }
        }
Beispiel #2
0
        private void txtTargetName_TextChanged(object sender, EventArgs e)
        {
            TextBox   txtSender = (TextBox)sender;
            AsmSubnet asmSubnet = (AsmSubnet)_AsmSubnetNode.Tag;

            asmSubnet.TargetName = txtSender.Text;
            _AsmSubnetNode.Text  = asmSubnet.TargetName;
        }
Beispiel #3
0
        internal void Bind(TreeNode asmSubnetNode)
        {
            _AsmSubnetNode = asmSubnetNode;

            AsmSubnet asmSubnet = (AsmSubnet)_AsmSubnetNode.Tag;

            lblSourceName.Text   = asmSubnet.Name;
            lblAddressSpace.Text = asmSubnet.AddressPrefix;
            txtTargetName.Text   = asmSubnet.TargetName;
        }
Beispiel #4
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);
        }
Beispiel #5
0
        private async void treeARM_AfterSelect(object sender, TreeViewEventArgs e)
        {
            ClearAzureResourceManagerProperties();

            lblAzureObjectName.Text = String.Empty;

            if (e.Node.Tag != null)
            {
                if (e.Node.Tag.GetType() == typeof(TreeNode))
                {
                    TreeNode asmTreeNode = (TreeNode)e.Node.Tag;

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

                        if (asmTreeNode.Tag.GetType() == typeof(AsmVirtualNetwork))
                        {
                            pictureBox1.Image = imageList1.Images["VirtualNetwork"];

                            VirtualNetworkProperties properties = new VirtualNetworkProperties();
                            properties.Bind(e.Node);
                            panel1.Controls.Add(properties);
                        }
                        else if (asmTreeNode.Tag.GetType() == typeof(AsmStorageAccount))
                        {
                            pictureBox1.Image = imageList1.Images["StorageAccount"];

                            AsmStorageAccount storageAccount = (AsmStorageAccount)asmTreeNode.Tag;
                            lblAzureObjectName.Text = storageAccount.Name;

                            StorageAccountProperties properties = new StorageAccountProperties();
                            properties.Bind(this._AzureContextTargetARM, e.Node);
                            panel1.Controls.Add(properties);
                        }
                        else if (asmTreeNode.Tag.GetType() == typeof(AsmVirtualMachine))
                        {
                            pictureBox1.Image = imageList1.Images["VirtualMachine"];

                            VirtualMachineProperties properties = new VirtualMachineProperties();
                            properties.Bind(e.Node, this);
                            panel1.Controls.Add(properties);
                        }
                        else if (asmTreeNode.Tag.GetType() == typeof(AsmNetworkSecurityGroup))
                        {
                            pictureBox1.Image = imageList1.Images["NetworkSecurityGroup"];

                            NetworkSecurityGroupProperties properties = new NetworkSecurityGroupProperties();
                            properties.Bind(e.Node, this);
                            panel1.Controls.Add(properties);
                        }
                    }
                }
                if (e.Node.Tag.GetType() == typeof(AsmSubnet))
                {
                    pictureBox1.Image = imageList1.Images["VirtualNetwork"];

                    AsmSubnet asmSubnet = (AsmSubnet)e.Node.Tag;

                    SubnetProperties properties = new SubnetProperties();
                    properties.Bind(e.Node);
                    panel1.Controls.Add(properties);
                }
                else if (e.Node.Tag.GetType() == typeof(AsmDisk))
                {
                    AsmDisk asmDisk = (AsmDisk)e.Node.Tag;

                    pictureBox1.Image = imageList1.Images["Disk"];

                    DiskProperties properties = new DiskProperties();
                    properties.Bind(this, e.Node);
                    panel1.Controls.Add(properties);
                }
                else if (e.Node.Tag.GetType() == typeof(ArmAvailabilitySet))
                {
                    pictureBox1.Image = imageList1.Images["AvailabilitySet"];

                    AvailabilitySetProperties properties = new AvailabilitySetProperties();
                    properties.Bind(e.Node);
                    panel1.Controls.Add(properties);
                }
                else if (e.Node.Tag.GetType() == typeof(ArmResourceGroup))
                {
                    pictureBox1.Image = imageList1.Images["ResourceGroup"];

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

                    panel1.Controls.Add(properties);
                }
            }

            _statusProvider.UpdateStatus("Ready");
        }