Ejemplo n.º 1
0
        public async Task Bind(VirtualMachine virtualMachine, TargetTreeView targetTreeView)
        {
            try
            {
                this.IsBinding  = true;
                _TargetTreeView = targetTreeView;
                _VirtualMachine = virtualMachine;

                txtTargetName.Text = _VirtualMachine.TargetName;

                if (_VirtualMachine.Source != null)
                {
                    if (_VirtualMachine.Source.GetType() == typeof(Azure.Asm.VirtualMachine))
                    {
                        Azure.Asm.VirtualMachine asmVirtualMachine = (Azure.Asm.VirtualMachine)_VirtualMachine.Source;

                        if (asmVirtualMachine.RoleSize != null)
                        {
                            lblRoleSize.Text           = asmVirtualMachine.RoleSize.Name;
                            lblSourceCPUCores.Text     = asmVirtualMachine.RoleSize.Cores.ToString();
                            lblSourceMemoryInGb.Text   = ((double)asmVirtualMachine.RoleSize.MemoryInMb / 1024).ToString();
                            lblSourceMaxDataDisks.Text = asmVirtualMachine.RoleSize.MaxDataDiskCount.ToString();
                        }

                        lblOS.Text = asmVirtualMachine.OSVirtualHardDiskOS;
                    }
                    else if (_VirtualMachine.Source.GetType() == typeof(Azure.Arm.VirtualMachine))
                    {
                        Azure.Arm.VirtualMachine armVirtualMachine = (Azure.Arm.VirtualMachine)_VirtualMachine.Source;

                        if (armVirtualMachine.VmSize != null)
                        {
                            lblRoleSize.Text           = armVirtualMachine.VmSize.ToString();
                            lblSourceCPUCores.Text     = armVirtualMachine.VmSize.NumberOfCores.ToString();
                            lblSourceMemoryInGb.Text   = ((double)armVirtualMachine.VmSize.memoryInMB / 1024).ToString();
                            lblSourceMaxDataDisks.Text = armVirtualMachine.VmSize.maxDataDiskCount.ToString();
                        }

                        lblOS.Text = armVirtualMachine.OSVirtualHardDiskOS;
                    }
                }

                cbRoleSizes.Items.Clear();
                if (targetTreeView.TargetResourceGroup != null && targetTreeView.TargetResourceGroup.TargetLocation != null)
                {
                    cbRoleSizes.Enabled = true;
                    cbRoleSizes.Visible = true;
                    lblTargetLocationRequired.Enabled = false;
                    lblTargetLocationRequired.Visible = false;

                    if (targetTreeView.TargetResourceGroup.TargetLocation.VMSizes != null)
                    {
                        foreach (Arm.VMSize vmSize in targetTreeView.TargetResourceGroup.TargetLocation.VMSizes)
                        {
                            if (vmSize.IsStorageTypeSupported(_VirtualMachine.OSVirtualHardDisk.StorageAccountType))
                            {
                                cbRoleSizes.Items.Add(vmSize);
                            }
                        }
                    }

                    if (_VirtualMachine.TargetSize != null)
                    {
                        int sizeIndex = cbRoleSizes.FindStringExact(_VirtualMachine.TargetSize.ToString());
                        cbRoleSizes.SelectedIndex = sizeIndex;
                    }
                }
                else
                {
                    cbRoleSizes.Enabled = false;
                    cbRoleSizes.Visible = false;
                    lblTargetLocationRequired.Enabled = true;
                    lblTargetLocationRequired.Visible = true;
                }

                availabilitySetSummary.Bind(virtualMachine.TargetAvailabilitySet, _TargetTreeView, true, true, _TargetTreeView.ExportArtifacts.AvailablitySets.Cast <Core.MigrationTarget>().ToList());
                osDiskSummary.Bind(virtualMachine.OSVirtualHardDisk, _TargetTreeView, false, false, null);
                primaryNICSummary.Bind(virtualMachine.PrimaryNetworkInterface, _TargetTreeView, false, false, null);

                foreach (Disk targetDisk in virtualMachine.DataDisks)
                {
                    AddResourceSummary(new ResourceSummary(targetDisk, targetTreeView));
                }
                foreach (NetworkInterface targetNIC in virtualMachine.NetworkInterfaces)
                {
                    if (!targetNIC.IsPrimary)
                    {
                        AddResourceSummary(new ResourceSummary(targetNIC, targetTreeView));
                    }
                }

                label15.Visible = pictureBox1.Controls.Count > 0;
            }
            finally
            {
                this.IsBinding = false;
            }
        }
Ejemplo n.º 2
0
        internal async Task Bind(NetworkInterface targetNetworkInterface, TargetTreeView targetTreeView)
        {
            try
            {
                this.IsBinding          = true;
                _TargetTreeView         = targetTreeView;
                _TargetNetworkInterface = targetNetworkInterface;
                await publicIpSelectionControl1.Bind(targetTreeView);

                await networkSelectionControl1.Bind(targetTreeView);

                if (_TargetNetworkInterface.TargetNetworkInterfaceIpConfigurations.Count > 0)
                {
                    networkSelectionControl1.VirtualNetworkTarget = _TargetNetworkInterface.TargetNetworkInterfaceIpConfigurations[0];

                    if (_TargetNetworkInterface.TargetNetworkInterfaceIpConfigurations[0].TargetPublicIp == null)
                    {
                        rbPublicIpDisabled.Checked = true;
                    }
                    else
                    {
                        rbPublicIpEnabled.Checked = true;
                    }

                    publicIpSelectionControl1.PublicIp = _TargetNetworkInterface.TargetNetworkInterfaceIpConfigurations[0].TargetPublicIp;
                }

                lblSourceName.Text = _TargetNetworkInterface.SourceName;
                txtTargetName.Text = _TargetNetworkInterface.TargetName;

                if (_TargetNetworkInterface.EnableIPForwarding)
                {
                    rbIPForwardingEnabled.Checked = true;
                }
                else
                {
                    rbIPForwardingDisabled.Checked = true;
                }

                if (_TargetNetworkInterface.EnableAcceleratedNetworking)
                {
                    rbAcceleratedNetworkingEnabled.Checked = true;
                }
                else
                {
                    rbAcceleratedNetworkingDisabled.Checked = true;
                }

                if (_TargetNetworkInterface.SourceNetworkInterface != null)
                {
                    if (_TargetNetworkInterface.SourceNetworkInterface.GetType() == typeof(Azure.Asm.NetworkInterface))
                    {
                        Azure.Asm.NetworkInterface asmNetworkInterface = (Azure.Asm.NetworkInterface)_TargetNetworkInterface.SourceNetworkInterface;

                        lblVirtualNetworkName.Text = asmNetworkInterface.NetworkInterfaceIpConfigurations[0].VirtualNetworkName;
                        lblSubnetName.Text         = asmNetworkInterface.NetworkInterfaceIpConfigurations[0].SubnetName;
                        lblStaticIpAddress.Text    = asmNetworkInterface.NetworkInterfaceIpConfigurations[0].PrivateIpAddress;
                    }
                    else if (_TargetNetworkInterface.SourceNetworkInterface.GetType() == typeof(Azure.Arm.NetworkInterface))
                    {
                        Azure.Arm.NetworkInterface armNetworkInterface = (Azure.Arm.NetworkInterface)_TargetNetworkInterface.SourceNetworkInterface;

                        lblVirtualNetworkName.Text = armNetworkInterface.NetworkInterfaceIpConfigurations[0].VirtualNetworkName;
                        lblSubnetName.Text         = armNetworkInterface.NetworkInterfaceIpConfigurations[0].SubnetName;
                        lblStaticIpAddress.Text    = armNetworkInterface.NetworkInterfaceIpConfigurations[0].PrivateIpAddress;
                    }
                }

                virtualMachineSummary.Bind(_TargetNetworkInterface.ParentVirtualMachine, _TargetTreeView);
                networkSecurityGroup.Bind(_TargetNetworkInterface.NetworkSecurityGroup, _TargetTreeView);

                await this.publicIpSelectionControl1.Bind(_TargetTreeView);

                this.UpdatePropertyEnablement();
            }
            finally
            {
                this.IsBinding = false;
            }
        }
        internal void Bind(VirtualNetworkGatewayConnection virtualNetworkGatewayConnection, TargetTreeView targetTreeView)
        {
            try
            {
                this.IsBinding = true;
                _VirtualNetworkGatewayConnection = virtualNetworkGatewayConnection;
                _TargetTreeView = targetTreeView;

                txtTargetName.Text = _VirtualNetworkGatewayConnection.TargetName;
            }
            finally
            {
                this.IsBinding = false;
            }
        }