示例#1
0
        internal void Bind(Subnet targetSubnet, TargetTreeView targetTreeView)
        {
            try
            {
                this.IsBinding  = true;
                _TargetTreeView = targetTreeView;
                _Subnet         = targetSubnet;

                txtTargetName.Text   = targetSubnet.TargetName;
                txtAddressSpace.Text = targetSubnet.AddressPrefix;

                if (targetSubnet.SourceSubnet != null)
                {
                    if (targetSubnet.SourceSubnet.GetType() == typeof(Azure.Asm.Subnet))
                    {
                        Asm.Subnet asmSubnet = (Asm.Subnet)targetSubnet.SourceSubnet;

                        lblSourceName.Text   = asmSubnet.Name;
                        lblAddressSpace.Text = asmSubnet.AddressPrefix;
                    }
                    else if (targetSubnet.SourceSubnet.GetType() == typeof(Azure.Arm.Subnet))
                    {
                        Arm.Subnet armSubnet = (Arm.Subnet)targetSubnet.SourceSubnet;

                        lblSourceName.Text   = armSubnet.Name;
                        lblAddressSpace.Text = armSubnet.AddressPrefix;
                    }
                }

                if (String.Compare(txtTargetName.Text, Core.ArmTemplate.ArmConst.GatewaySubnetName, true) == 0)
                {
                    // if gateway subnet, the name can't be changed
                    txtTargetName.Enabled = false;
                }

                networkSecurityGroup.Bind(_Subnet.NetworkSecurityGroup, _TargetTreeView);
                routeTable.Bind(_Subnet.RouteTable, _TargetTreeView);
            }
            finally
            {
                this.IsBinding = false;
            }
        }
示例#2
0
        public Subnet(AzureContext azureContext, MigrationTarget.VirtualNetwork parentVirtualNetwork, ISubnet source, List <NetworkSecurityGroup> networkSecurityGroups)
        {
            _AzureContext         = azureContext;
            _ParentVirtualNetwork = parentVirtualNetwork;
            _SourceSubnet         = source;

            if (source.GetType() == typeof(Asm.Subnet))
            {
                Asm.Subnet asmSubnet = (Asm.Subnet)source;

                if (asmSubnet.NetworkSecurityGroup != null)
                {
                    this.NetworkSecurityGroup = SeekNetworkSecurityGroup(networkSecurityGroups, asmSubnet.NetworkSecurityGroup.ToString());
                }

                if (asmSubnet.RouteTable != null)
                {
                    this.RouteTable = new RouteTable(azureContext, asmSubnet.RouteTable);
                }

                this.AddressPrefix = asmSubnet.AddressPrefix;
            }
            else if (source.GetType() == typeof(Arm.Subnet))
            {
                Arm.Subnet armSubnet = (Arm.Subnet)source;

                if (armSubnet.NetworkSecurityGroup != null)
                {
                    this.NetworkSecurityGroup = SeekNetworkSecurityGroup(networkSecurityGroups, armSubnet.NetworkSecurityGroup.ToString());
                }

                if (armSubnet.RouteTable != null)
                {
                    this.RouteTable = new RouteTable(azureContext, armSubnet.RouteTable);
                }

                this.AddressPrefix = armSubnet.AddressPrefix;
            }

            this.TargetName = source.Name;
        }
示例#3
0
        public Subnet(MigrationTarget.VirtualNetwork parentVirtualNetwork, ISubnet source, List <NetworkSecurityGroup> networkSecurityGroups, List <RouteTable> routeTables, TargetSettings targetSettings, ILogProvider logProvider) : base(String.Empty, String.Empty, logProvider)
        {
            _ParentVirtualNetwork = parentVirtualNetwork;
            _SourceSubnet         = source;

            if (source.GetType() == typeof(Asm.Subnet))
            {
                Asm.Subnet asmSubnet = (Asm.Subnet)source;

                if (asmSubnet.NetworkSecurityGroup != null)
                {
                    this.NetworkSecurityGroup = SeekNetworkSecurityGroup(networkSecurityGroups, asmSubnet.NetworkSecurityGroup.ToString());
                }

                if (asmSubnet.RouteTable != null)
                {
                    this.RouteTable = SeekRouteTable(routeTables, asmSubnet.RouteTable.ToString());
                }
            }
            else if (source.GetType() == typeof(Arm.Subnet))
            {
                Arm.Subnet armSubnet = (Arm.Subnet)source;

                if (armSubnet.NetworkSecurityGroup != null)
                {
                    this.NetworkSecurityGroup = SeekNetworkSecurityGroup(networkSecurityGroups, armSubnet.NetworkSecurityGroup.ToString());
                }

                if (armSubnet.RouteTable != null)
                {
                    this.RouteTable = SeekRouteTable(routeTables, armSubnet.RouteTable.ToString());
                }
            }

            this.AddressPrefix = source.AddressPrefix;
            this.SetTargetName(source.Name, targetSettings);
        }
示例#4
0
        private async void rbExistingARMVNet_CheckedChanged(object sender, EventArgs e)
        {
            RadioButton rb = (RadioButton)sender;

            if (rb.Checked)
            {
                #region Add "Existing in Subscription / Location" ARM Virtual Networks to cmbExistingArmVNets

                cmbVirtualNetwork.Items.Clear();
                cmbSubnet.Items.Clear();

                foreach (Arm.VirtualNetwork armVirtualNetwork in _TargetTreeView.GetExistingVirtualNetworksInTargetLocation())
                {
                    if (armVirtualNetwork.HasNonGatewaySubnet)
                    {
                        cmbVirtualNetwork.Items.Add(armVirtualNetwork);
                    }
                }

                #endregion

                #region Seek Target VNet and Subnet as ComboBox SelectedItems

                if (_NetworkInterfaceTarget != null)
                {
                    if (_NetworkInterfaceTarget.GetType() == typeof(NetworkInterfaceIpConfiguration))
                    {
                        NetworkInterfaceIpConfiguration targetNetworkInterface = (NetworkInterfaceIpConfiguration)_NetworkInterfaceTarget;
                        if (targetNetworkInterface.TargetVirtualNetwork != null)
                        {
                            if (targetNetworkInterface.TargetVirtualNetwork.GetType() == typeof(Arm.VirtualNetwork))
                            {
                                Arm.VirtualNetwork targetVirtualNetwork = (Arm.VirtualNetwork)targetNetworkInterface.TargetVirtualNetwork;

                                // Attempt to match target to list items
                                for (int i = 0; i < cmbVirtualNetwork.Items.Count; i++)
                                {
                                    Arm.VirtualNetwork listVirtualNetwork = (Arm.VirtualNetwork)cmbVirtualNetwork.Items[i];
                                    if (listVirtualNetwork == targetVirtualNetwork)
                                    {
                                        cmbVirtualNetwork.SelectedIndex = i;
                                        break;
                                    }
                                }

                                if (targetNetworkInterface.TargetSubnet.GetType() == typeof(Arm.Subnet))
                                {
                                    Arm.Subnet targetSubnet = (Arm.Subnet)targetNetworkInterface.TargetSubnet;

                                    // Attempt to match target to list items
                                    for (int i = 0; i < cmbSubnet.Items.Count; i++)
                                    {
                                        Arm.Subnet listSubnet = (Arm.Subnet)cmbSubnet.Items[i];
                                        if (listSubnet == targetSubnet)
                                        {
                                            cmbSubnet.SelectedIndex = i;
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                #endregion

                if (cmbVirtualNetwork.SelectedIndex < 0 && cmbVirtualNetwork.Items.Count > 0)
                {
                    cmbVirtualNetwork.SelectedIndex = 0;
                }

                if (cmbSubnet.SelectedIndex < 0 && cmbSubnet.Items.Count > 0)
                {
                    cmbSubnet.SelectedIndex = 0;
                }

                if (!_IsBinding)
                {
                    PropertyChanged?.Invoke();
                }
            }
        }