internal async Task Bind(AzureContext azureContext, TargetTreeView targetTreeView, Azure.MigrationTarget.NetworkInterface targetNetworkInterface) { _AzureContext = azureContext; _TargetTreeView = targetTreeView; _TargetNetworkInterface = targetNetworkInterface; lblSourceName.Text = _TargetNetworkInterface.SourceName; txtTargetName.Text = _TargetNetworkInterface.TargetName; if (_TargetNetworkInterface.TargetNetworkInterfaceIpConfigurations.Count > 0) { cmbAllocationMethod.SelectedIndex = cmbAllocationMethod.FindString(_TargetNetworkInterface.TargetNetworkInterfaceIpConfigurations[0].TargetPrivateIPAllocationMethod); } 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; } } try { List <Azure.Arm.VirtualNetwork> a = await _AzureContext.AzureRetriever.GetAzureARMVirtualNetworks(); rbExistingARMVNet.Enabled = a.Count() > 0; } catch (Exception exc) { _AzureContext.LogProvider.WriteLog("VirtualMachineProperties.Bind", exc.Message); rbExistingARMVNet.Enabled = false; } if (rbExistingARMVNet.Enabled == false || _TargetNetworkInterface.TargetNetworkInterfaceIpConfigurations.Count() == 0 || _TargetNetworkInterface.TargetNetworkInterfaceIpConfigurations[0].TargetSubnet == null || _TargetNetworkInterface.TargetNetworkInterfaceIpConfigurations[0].TargetSubnet.GetType() == typeof(Azure.MigrationTarget.Subnet) ) { rbVNetInMigration.Checked = true; } else { rbExistingARMVNet.Checked = true; } }
internal async Task Bind(AzureContext azureContext, TargetTreeView targetTreeView, Azure.MigrationTarget.NetworkInterface targetNetworkInterface) { _AzureContext = azureContext; _TargetTreeView = targetTreeView; _TargetNetworkInterface = targetNetworkInterface; networkSelectionControl1.PropertyChanged += NetworkSelectionControl1_PropertyChanged; if (_TargetNetworkInterface.TargetNetworkInterfaceIpConfigurations.Count > 0) { await networkSelectionControl1.Bind(azureContext, targetTreeView, targetTreeView.GetVirtualNetworksInMigration()); networkSelectionControl1.VirtualNetworkTarget = _TargetNetworkInterface.TargetNetworkInterfaceIpConfigurations[0]; } lblSourceName.Text = _TargetNetworkInterface.SourceName; txtTargetName.Text = _TargetNetworkInterface.TargetName; if (_TargetNetworkInterface.EnableIPForwarding) { rbIPForwardingEnabled.Checked = true; } else { rbIPForwardingDisabled.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); }
internal async Task Bind(AzureContext azureContext, TargetTreeView targetTreeView, Azure.MigrationTarget.NetworkInterface targetNetworkInterface) { _AzureContext = azureContext; _TargetTreeView = targetTreeView; _TargetNetworkInterface = targetNetworkInterface; if (_TargetNetworkInterface.TargetNetworkInterfaceIpConfigurations.Count > 0) { await networkSelectionControl1.Bind(azureContext, targetTreeView.GetVirtualNetworksInMigration()); networkSelectionControl1.VirtualNetworkTarget = _TargetNetworkInterface.TargetNetworkInterfaceIpConfigurations[0]; } lblSourceName.Text = _TargetNetworkInterface.SourceName; txtTargetName.Text = _TargetNetworkInterface.TargetName; if (_TargetNetworkInterface.TargetNetworkInterfaceIpConfigurations.Count > 0) { cmbAllocationMethod.SelectedIndex = cmbAllocationMethod.FindString(_TargetNetworkInterface.TargetNetworkInterfaceIpConfigurations[0].TargetPrivateIPAllocationMethod); } 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; } } }
public VirtualMachine(Arm.VirtualMachine virtualMachine, TargetSettings targetSettings) : base(ArmConst.MicrosoftCompute, ArmConst.VirtualMachines) { this.Source = virtualMachine; this.SetTargetName(virtualMachine.Name, targetSettings); this.TargetSize = virtualMachine.VmSize; this.OSVirtualHardDiskOS = virtualMachine.OSVirtualHardDiskOS; if (virtualMachine.OSVirtualHardDisk != null && virtualMachine.OSVirtualHardDisk.GetType() == typeof(Azure.Arm.ManagedDisk)) { Azure.Arm.ManagedDisk sourceManagedDisk = (Azure.Arm.ManagedDisk)virtualMachine.OSVirtualHardDisk; foreach (Disk targetDisk in virtualMachine.AzureSubscription.ArmTargetManagedDisks) { if ((targetDisk.SourceDisk != null) && (targetDisk.SourceDisk.GetType() == typeof(Azure.Arm.ManagedDisk))) { Azure.Arm.ManagedDisk targetDiskSourceDisk = (Azure.Arm.ManagedDisk)targetDisk.SourceDisk; if (String.Compare(targetDiskSourceDisk.Name, sourceManagedDisk.Name, true) == 0) { this.OSVirtualHardDisk = targetDisk; targetDisk.ParentVirtualMachine = this; targetDisk.HostCaching = sourceManagedDisk.HostCaching; break; } } } } else { if (virtualMachine.OSVirtualHardDisk != null) { this.OSVirtualHardDisk = new Disk(virtualMachine.OSVirtualHardDisk, this, targetSettings); } } if (virtualMachine.OSVirtualHardDisk != null && virtualMachine.OSVirtualHardDisk.GetType() == typeof(Arm.ClassicDisk)) { Arm.ClassicDisk armDisk = (Arm.ClassicDisk)virtualMachine.OSVirtualHardDisk; if (targetSettings.DefaultTargetDiskType == ArmDiskType.ClassicDisk) { this.OSVirtualHardDisk.TargetStorage = SeekTargetStorageAccount(virtualMachine.AzureSubscription.ArmTargetStorageAccounts, armDisk.StorageAccountName); } } foreach (IArmDisk dataDisk in virtualMachine.DataDisks) { if (dataDisk.GetType() == typeof(Azure.Arm.ManagedDisk)) { Azure.Arm.ManagedDisk sourceManagedDisk = (Azure.Arm.ManagedDisk)dataDisk; MigrationTarget.Disk targetDataDisk = null; foreach (Disk targetDisk in virtualMachine.AzureSubscription.ArmTargetManagedDisks) { if ((targetDisk.SourceDisk != null) && (targetDisk.SourceDisk.GetType() == typeof(Azure.Arm.ManagedDisk))) { Azure.Arm.ManagedDisk targetDiskSourceDisk = (Azure.Arm.ManagedDisk)targetDisk.SourceDisk; if (String.Compare(targetDiskSourceDisk.Name, sourceManagedDisk.Name, true) == 0) { targetDataDisk = targetDisk; break; } } } if (targetDataDisk != null) { EnsureDataDiskTargetLunIsNotNull(ref targetDataDisk); targetDataDisk.ParentVirtualMachine = this; targetDataDisk.Lun = sourceManagedDisk.Lun; targetDataDisk.HostCaching = sourceManagedDisk.HostCaching; this.DataDisks.Add(targetDataDisk); } } else if (dataDisk.GetType() == typeof(Arm.ClassicDisk)) { Disk targetDataDisk = new Disk(dataDisk, this, targetSettings); Arm.ClassicDisk armDisk = (Arm.ClassicDisk)dataDisk; if (targetSettings.DefaultTargetDiskType == ArmDiskType.ClassicDisk) { targetDataDisk.TargetStorage = SeekTargetStorageAccount(virtualMachine.AzureSubscription.ArmTargetStorageAccounts, armDisk.StorageAccountName); } EnsureDataDiskTargetLunIsNotNull(ref targetDataDisk); this.DataDisks.Add(targetDataDisk); } } foreach (Arm.NetworkInterface armNetworkInterface in virtualMachine.NetworkInterfaces) { foreach (NetworkInterface targetNetworkInterface in virtualMachine.AzureSubscription.ArmTargetNetworkInterfaces) { if ((targetNetworkInterface.SourceNetworkInterface != null) && (targetNetworkInterface.SourceNetworkInterface.GetType() == typeof(Azure.Arm.NetworkInterface))) { Azure.Arm.NetworkInterface targetNetworkInterfaceSourceInterface = (Azure.Arm.NetworkInterface)targetNetworkInterface.SourceNetworkInterface; if (String.Compare(targetNetworkInterfaceSourceInterface.Name, armNetworkInterface.Name, true) == 0) { this.NetworkInterfaces.Add(targetNetworkInterface); targetNetworkInterface.ParentVirtualMachine = this; break; } } } } if (virtualMachine.HasPlan) { _PlanAttributes = new Dictionary <string, string>(); foreach (JProperty planAttribute in virtualMachine.ResourceToken["plan"]) { _PlanAttributes.Add(planAttribute.Name, planAttribute.Value.ToString()); } } }
internal async Task Bind(NetworkInterface targetNetworkInterface, TargetTreeView targetTreeView) { try { _IsBinding = true; _TargetTreeView = targetTreeView; _TargetNetworkInterface = targetNetworkInterface; networkSelectionControl1.PropertyChanged += NetworkSelectionControl1_PropertyChanged; await networkSelectionControl1.Bind(targetTreeView); if (_TargetNetworkInterface.TargetNetworkInterfaceIpConfigurations.Count > 0) { networkSelectionControl1.VirtualNetworkTarget = _TargetNetworkInterface.TargetNetworkInterfaceIpConfigurations[0]; } 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); if (_TargetNetworkInterface.TargetNetworkInterfaceIpConfigurations.Count() > 0) { resourceSummaryPublicIp.Bind(_TargetNetworkInterface.TargetNetworkInterfaceIpConfigurations[0].TargetPublicIp, _TargetTreeView); } } finally { _IsBinding = false; } }
public VirtualMachine(AzureContext azureContext, Arm.VirtualMachine virtualMachine, ArmDiskType targetDiskType) { this._AzureContext = azureContext; this.Source = virtualMachine; this.TargetName = virtualMachine.Name; this.TargetSize = virtualMachine.VmSize; this.OSVirtualHardDiskOS = virtualMachine.OSVirtualHardDiskOS; if (virtualMachine.OSVirtualHardDisk.GetType() == typeof(Azure.Arm.ManagedDisk)) { Azure.Arm.ManagedDisk sourceManagedDisk = (Azure.Arm.ManagedDisk)virtualMachine.OSVirtualHardDisk; foreach (Disk targetDisk in azureContext.AzureRetriever.ArmTargetManagedDisks) { if ((targetDisk.SourceDisk != null) && (targetDisk.SourceDisk.GetType() == typeof(Azure.Arm.ManagedDisk))) { Azure.Arm.ManagedDisk targetDiskSourceDisk = (Azure.Arm.ManagedDisk)targetDisk.SourceDisk; if (String.Compare(targetDiskSourceDisk.Name, sourceManagedDisk.Name, true) == 0) { this.OSVirtualHardDisk = targetDisk; targetDisk.ParentVirtualMachine = this; targetDisk.HostCaching = sourceManagedDisk.HostCaching; break; } } } } else { this.OSVirtualHardDisk = new Disk(virtualMachine.OSVirtualHardDisk, this); } if (virtualMachine.OSVirtualHardDisk.GetType() == typeof(Arm.ClassicDisk)) { Arm.ClassicDisk armDisk = (Arm.ClassicDisk)virtualMachine.OSVirtualHardDisk; if (targetDiskType == ArmDiskType.ClassicDisk) { this.OSVirtualHardDisk.TargetStorage = SeekTargetStorageAccount(azureContext.AzureRetriever.ArmTargetStorageAccounts, armDisk.StorageAccountName); } } foreach (IArmDisk dataDisk in virtualMachine.DataDisks) { if (dataDisk.GetType() == typeof(Azure.Arm.ManagedDisk)) { Azure.Arm.ManagedDisk sourceManagedDisk = (Azure.Arm.ManagedDisk)dataDisk; foreach (Disk targetDisk in azureContext.AzureRetriever.ArmTargetManagedDisks) { if ((targetDisk.SourceDisk != null) && (targetDisk.SourceDisk.GetType() == typeof(Azure.Arm.ManagedDisk))) { Azure.Arm.ManagedDisk targetDiskSourceDisk = (Azure.Arm.ManagedDisk)targetDisk.SourceDisk; if (String.Compare(targetDiskSourceDisk.Name, sourceManagedDisk.Name, true) == 0) { this.DataDisks.Add(targetDisk); targetDisk.ParentVirtualMachine = this; targetDisk.Lun = sourceManagedDisk.Lun; targetDisk.HostCaching = sourceManagedDisk.HostCaching; break; } } } } else if (dataDisk.GetType() == typeof(Arm.ClassicDisk)) { Disk targetDataDisk = new Disk(dataDisk, this); this.DataDisks.Add(targetDataDisk); Arm.ClassicDisk armDisk = (Arm.ClassicDisk)dataDisk; if (targetDiskType == ArmDiskType.ClassicDisk) { targetDataDisk.TargetStorage = SeekTargetStorageAccount(azureContext.AzureRetriever.ArmTargetStorageAccounts, armDisk.StorageAccountName); } } } foreach (Arm.NetworkInterface armNetworkInterface in virtualMachine.NetworkInterfaces) { foreach (NetworkInterface targetNetworkInterface in azureContext.AzureRetriever.ArmTargetNetworkInterfaces) { if ((targetNetworkInterface.SourceNetworkInterface != null) && (targetNetworkInterface.SourceNetworkInterface.GetType() == typeof(Azure.Arm.NetworkInterface))) { Azure.Arm.NetworkInterface targetNetworkInterfaceSourceInterface = (Azure.Arm.NetworkInterface)targetNetworkInterface.SourceNetworkInterface; if (String.Compare(targetNetworkInterfaceSourceInterface.Name, armNetworkInterface.Name, true) == 0) { this.NetworkInterfaces.Add(targetNetworkInterface); targetNetworkInterface.ParentVirtualMachine = this; break; } } } } if (virtualMachine.HasPlan) { _PlanAttributes = new Dictionary <string, string>(); foreach (JProperty planAttribute in virtualMachine.ResourceToken["plan"]) { _PlanAttributes.Add(planAttribute.Name, planAttribute.Value.ToString()); } } }