internal void Bind(NetworkSecurityGroup networkSecurityGroup, TargetTreeView targetTreeView) { try { _IsBinding = true; _NetworkSecurityGroup = networkSecurityGroup; _TargetTreeView = targetTreeView; if (_NetworkSecurityGroup.SourceNetworkSecurityGroup != null) { if (_NetworkSecurityGroup.SourceNetworkSecurityGroup.GetType() == typeof(Azure.Asm.NetworkSecurityGroup)) { Azure.Asm.NetworkSecurityGroup asmNetworkSecurityGroup = (Azure.Asm.NetworkSecurityGroup)_NetworkSecurityGroup.SourceNetworkSecurityGroup; lblSourceName.Text = asmNetworkSecurityGroup.Name; } else if (_NetworkSecurityGroup.SourceNetworkSecurityGroup.GetType() == typeof(Azure.Arm.NetworkSecurityGroup)) { Azure.Arm.NetworkSecurityGroup armNetworkSecurityGroup = (Azure.Arm.NetworkSecurityGroup)_NetworkSecurityGroup.SourceNetworkSecurityGroup; lblSourceName.Text = armNetworkSecurityGroup.Name; } } txtTargetName.Text = _NetworkSecurityGroup.TargetName; } finally { _IsBinding = false; } }
internal void Bind(MigrationTarget.NetworkSecurityGroup networkSecurityGroup) { _NetworkSecurityGroup = networkSecurityGroup; if (_NetworkSecurityGroup.SourceNetworkSecurityGroup != null) { if (_NetworkSecurityGroup.SourceNetworkSecurityGroup.GetType() == typeof(Azure.Asm.NetworkSecurityGroup)) { Azure.Asm.NetworkSecurityGroup asmNetworkSecurityGroup = (Azure.Asm.NetworkSecurityGroup)_NetworkSecurityGroup.SourceNetworkSecurityGroup; lblSourceName.Text = asmNetworkSecurityGroup.Name; } else if (_NetworkSecurityGroup.SourceNetworkSecurityGroup.GetType() == typeof(Azure.Arm.NetworkSecurityGroup)) { Azure.Arm.NetworkSecurityGroup armNetworkSecurityGroup = (Azure.Arm.NetworkSecurityGroup)_NetworkSecurityGroup.SourceNetworkSecurityGroup; lblSourceName.Text = armNetworkSecurityGroup.Name; } } txtTargetName.Text = _NetworkSecurityGroup.TargetName; }
private async Task <TreeNode> AddASMNodeToARMTree(TreeNode asmTreeNode) { TreeNode targetResourceGroupNode = SeekARMChildTreeNode(treeTargetARM.Nodes, _TargetResourceGroup.Name, _TargetResourceGroup.Name, _TargetResourceGroup, true); Type tagType = asmTreeNode.Tag.GetType(); if (tagType == typeof(Azure.Asm.VirtualNetwork)) { Azure.Asm.VirtualNetwork asmVirtualNetwork = (Azure.Asm.VirtualNetwork)asmTreeNode.Tag; TreeNode virtualNetworksNode = SeekARMChildTreeNode(targetResourceGroupNode.Nodes, "Virtual Networks", "Virtual Networks", "Virtual Networks", true); TreeNode virtualNetworkNode = SeekARMChildTreeNode(virtualNetworksNode.Nodes, asmTreeNode.Name, asmVirtualNetwork.GetFinalTargetName(), asmTreeNode, true); foreach (Azure.Asm.Subnet asmSubnet in asmVirtualNetwork.Subnets) { // Property dialog not made available for Gateway Subnet if (!asmSubnet.IsGatewaySubnet) { TreeNode subnetNode = SeekARMChildTreeNode(virtualNetworkNode.Nodes, asmSubnet.Name, asmSubnet.Name, asmSubnet, true); } } targetResourceGroupNode.ExpandAll(); return(virtualNetworkNode); } else if (tagType == typeof(Azure.Asm.StorageAccount)) { Azure.Asm.StorageAccount asmStorageAccount = (Azure.Asm.StorageAccount)asmTreeNode.Tag; TreeNode storageAccountsNode = SeekARMChildTreeNode(targetResourceGroupNode.Nodes, "Storage Accounts", "Storage Accounts", "Storage Accounts", true); TreeNode storageAccountNode = SeekARMChildTreeNode(storageAccountsNode.Nodes, asmTreeNode.Name, asmStorageAccount.GetFinalTargetName(), asmTreeNode, true); targetResourceGroupNode.ExpandAll(); return(storageAccountNode); } else if (tagType == typeof(Azure.Asm.VirtualMachine)) { Azure.Asm.VirtualMachine asmVirtualMachine = (Azure.Asm.VirtualMachine)asmTreeNode.Tag; TreeNode availabilitySets = SeekARMChildTreeNode(targetResourceGroupNode.Nodes, "Availability Sets", "Availability Sets", "Availability Sets", true); TreeNode availabilitySet = SeekARMChildTreeNode(availabilitySets.Nodes, asmVirtualMachine.TargetAvailabilitySet.TargetName, asmVirtualMachine.TargetAvailabilitySet.GetFinalTargetName(), asmVirtualMachine.TargetAvailabilitySet, true); TreeNode virtualMachineNode = SeekARMChildTreeNode(availabilitySet.Nodes, asmVirtualMachine.RoleName, asmVirtualMachine.RoleName, asmTreeNode, true); foreach (Azure.Asm.Disk asmDataDisk in asmVirtualMachine.DataDisks) { TreeNode dataDiskNode = SeekARMChildTreeNode(virtualMachineNode.Nodes, asmDataDisk.DiskName, asmDataDisk.DiskName, asmDataDisk, true); } foreach (Azure.Asm.NetworkInterface asmNetworkInterface in asmVirtualMachine.NetworkInterfaces) { TreeNode dataDiskNode = SeekARMChildTreeNode(virtualMachineNode.Nodes, asmNetworkInterface.Name, asmNetworkInterface.Name, asmNetworkInterface, true); } targetResourceGroupNode.ExpandAll(); return(virtualMachineNode); } else if (tagType == typeof(Azure.Asm.NetworkSecurityGroup)) { Azure.Asm.NetworkSecurityGroup asmNetworkSecurityGroup = (Azure.Asm.NetworkSecurityGroup)asmTreeNode.Tag; TreeNode networkSecurityGroups = SeekARMChildTreeNode(targetResourceGroupNode.Nodes, "Network Security Groups", "Network Security Groups", "Network Security Groups", true); TreeNode networkSecurityGroupNode = SeekARMChildTreeNode(networkSecurityGroups.Nodes, asmNetworkSecurityGroup.Name, asmNetworkSecurityGroup.Name, asmTreeNode, true); targetResourceGroupNode.ExpandAll(); return(networkSecurityGroupNode); } else if (tagType == typeof(Azure.Arm.VirtualNetwork)) { Azure.Arm.VirtualNetwork armVirtualNetwork = (Azure.Arm.VirtualNetwork)asmTreeNode.Tag; TreeNode virtualNetworksNode = SeekARMChildTreeNode(targetResourceGroupNode.Nodes, "Virtual Networks", "Virtual Networks", "Virtual Networks", true); TreeNode virtualNetworkNode = SeekARMChildTreeNode(virtualNetworksNode.Nodes, asmTreeNode.Name, armVirtualNetwork.GetFinalTargetName(), asmTreeNode, true); foreach (Azure.Arm.Subnet armSubnet in armVirtualNetwork.Subnets) { // Property dialog not made available for Gateway Subnet if (!armSubnet.IsGatewaySubnet) { TreeNode subnetNode = SeekARMChildTreeNode(virtualNetworkNode.Nodes, armSubnet.Name, armSubnet.Name, armSubnet, true); } } targetResourceGroupNode.ExpandAll(); return(virtualNetworkNode); } else if (tagType == typeof(Azure.Arm.StorageAccount)) { Azure.Arm.StorageAccount armStorageAccount = (Azure.Arm.StorageAccount)asmTreeNode.Tag; TreeNode storageAccountsNode = SeekARMChildTreeNode(targetResourceGroupNode.Nodes, "Storage Accounts", "Storage Accounts", "Storage Accounts", true); TreeNode storageAccountNode = SeekARMChildTreeNode(storageAccountsNode.Nodes, asmTreeNode.Name, armStorageAccount.GetFinalTargetName(), asmTreeNode, true); targetResourceGroupNode.ExpandAll(); return(storageAccountNode); } else if (tagType == typeof(Azure.Arm.VirtualMachine)) { Azure.Arm.VirtualMachine armVirtualMachine = (Azure.Arm.VirtualMachine)asmTreeNode.Tag; TreeNode virtualMachineNode = null; if (armVirtualMachine.TargetAvailabilitySet != null) { TreeNode availabilitySets = SeekARMChildTreeNode(targetResourceGroupNode.Nodes, "Availability Sets", "Availability Sets", "Availability Sets", true); TreeNode availabilitySet = SeekARMChildTreeNode(availabilitySets.Nodes, armVirtualMachine.TargetAvailabilitySet.TargetName, armVirtualMachine.TargetAvailabilitySet.GetFinalTargetName(), armVirtualMachine.TargetAvailabilitySet, true); virtualMachineNode = SeekARMChildTreeNode(availabilitySet.Nodes, armVirtualMachine.Name, armVirtualMachine.Name, asmTreeNode, true); } else { virtualMachineNode = SeekARMChildTreeNode(targetResourceGroupNode.Nodes, armVirtualMachine.Name, armVirtualMachine.Name, asmTreeNode, true); } foreach (Azure.Arm.Disk armDataDisk in armVirtualMachine.DataDisks) { TreeNode dataDiskNode = SeekARMChildTreeNode(virtualMachineNode.Nodes, armDataDisk.Name, armDataDisk.Name, armDataDisk, true); } foreach (Azure.Arm.NetworkInterfaceCard asmNetworkInterface in armVirtualMachine.NetworkInterfaces) { TreeNode dataDiskNode = SeekARMChildTreeNode(virtualMachineNode.Nodes, asmNetworkInterface.Name, asmNetworkInterface.Name, asmNetworkInterface, true); } targetResourceGroupNode.ExpandAll(); return(virtualMachineNode); } else if (tagType == typeof(Azure.Arm.NetworkSecurityGroup)) { Azure.Arm.NetworkSecurityGroup armNetworkSecurityGroup = (Azure.Arm.NetworkSecurityGroup)asmTreeNode.Tag; TreeNode networkSecurityGroups = SeekARMChildTreeNode(targetResourceGroupNode.Nodes, "Network Security Groups", "Network Security Groups", "Network Security Groups", true); TreeNode networkSecurityGroupNode = SeekARMChildTreeNode(networkSecurityGroups.Nodes, armNetworkSecurityGroup.Name, armNetworkSecurityGroup.Name, asmTreeNode, true); targetResourceGroupNode.ExpandAll(); return(networkSecurityGroupNode); } else { throw new Exception("Unhandled Node Type in AddASMNodeToARMTree: " + tagType); } }
private async Task BindAsmResources(AzureContext azureContext, TargetSettings targetSettings) { treeAzureASM.Nodes.Clear(); try { if (_AzureContextSource != null && _AzureContextSource.AzureSubscription != null) { await _AzureContextSource.AzureSubscription.BindAsmResources(targetSettings); if (_AzureContextSource != null && _AzureContextSource.AzureSubscription != null) { TreeNode subscriptionNodeASM = new TreeNode(_AzureContextSource.AzureSubscription.Name); treeAzureASM.Nodes.Add(subscriptionNodeASM); subscriptionNodeASM.Expand(); foreach (Azure.MigrationTarget.NetworkSecurityGroup targetNetworkSecurityGroup in _AzureContextSource.AzureSubscription.AsmTargetNetworkSecurityGroups) { Azure.Asm.NetworkSecurityGroup asmNetworkSecurityGroup = (Azure.Asm.NetworkSecurityGroup)targetNetworkSecurityGroup.SourceNetworkSecurityGroup; TreeNode parentNode = GetDataCenterTreeViewNode(subscriptionNodeASM, asmNetworkSecurityGroup.Location, "Network Security Groups"); TreeNode tnNetworkSecurityGroup = new TreeNode(targetNetworkSecurityGroup.SourceName); tnNetworkSecurityGroup.Name = targetNetworkSecurityGroup.SourceName; tnNetworkSecurityGroup.Tag = targetNetworkSecurityGroup; parentNode.Nodes.Add(tnNetworkSecurityGroup); parentNode.Expand(); } foreach (Azure.MigrationTarget.VirtualNetwork targetVirtualNetwork in _AzureContextSource.AzureSubscription.AsmTargetVirtualNetworks) { Azure.Asm.VirtualNetwork asmVirtualNetwork = (Azure.Asm.VirtualNetwork)targetVirtualNetwork.SourceVirtualNetwork; TreeNode parentNode = GetDataCenterTreeViewNode(subscriptionNodeASM, asmVirtualNetwork.Location, "Virtual Networks"); TreeNode tnVirtualNetwork = new TreeNode(targetVirtualNetwork.SourceName); tnVirtualNetwork.Name = targetVirtualNetwork.SourceName; tnVirtualNetwork.Text = targetVirtualNetwork.SourceName; tnVirtualNetwork.Tag = targetVirtualNetwork; parentNode.Nodes.Add(tnVirtualNetwork); parentNode.Expand(); } foreach (Azure.MigrationTarget.StorageAccount targetStorageAccount in _AzureContextSource.AzureSubscription.AsmTargetStorageAccounts) { TreeNode parentNode = GetDataCenterTreeViewNode(subscriptionNodeASM, targetStorageAccount.SourceAccount.PrimaryLocation, "Storage Accounts"); TreeNode tnStorageAccount = new TreeNode(targetStorageAccount.SourceName); tnStorageAccount.Name = targetStorageAccount.SourceName; tnStorageAccount.Tag = targetStorageAccount; parentNode.Nodes.Add(tnStorageAccount); parentNode.Expand(); } foreach (Azure.MigrationTarget.VirtualMachine targetVirtualMachine in _AzureContextSource.AzureSubscription.AsmTargetVirtualMachines) { Azure.Asm.VirtualMachine asmVirtualMachine = (Azure.Asm.VirtualMachine)targetVirtualMachine.Source; TreeNode parentNode = GetDataCenterTreeViewNode(subscriptionNodeASM, asmVirtualMachine.Location, "Cloud Services"); TreeNode[] cloudServiceNodeSearch = parentNode.Nodes.Find(targetVirtualMachine.TargetAvailabilitySet.TargetName, false); TreeNode cloudServiceNode = null; if (cloudServiceNodeSearch.Count() == 1) { cloudServiceNode = cloudServiceNodeSearch[0]; } cloudServiceNode = new TreeNode(targetVirtualMachine.TargetAvailabilitySet.TargetName); cloudServiceNode.Name = targetVirtualMachine.TargetAvailabilitySet.TargetName; cloudServiceNode.Tag = targetVirtualMachine.TargetAvailabilitySet; parentNode.Nodes.Add(cloudServiceNode); parentNode.Expand(); TreeNode virtualMachineNode = new TreeNode(targetVirtualMachine.SourceName); virtualMachineNode.Name = targetVirtualMachine.SourceName; virtualMachineNode.Tag = targetVirtualMachine; cloudServiceNode.Nodes.Add(virtualMachineNode); cloudServiceNode.Expand(); foreach (Azure.MigrationTarget.NetworkInterface targetNetworkInterface in targetVirtualMachine.NetworkInterfaces) { if (targetNetworkInterface.BackEndAddressPool != null && targetNetworkInterface.BackEndAddressPool.LoadBalancer != null) { TreeNode loadBalancerNode = new TreeNode(targetNetworkInterface.BackEndAddressPool.LoadBalancer.SourceName); loadBalancerNode.Name = targetNetworkInterface.BackEndAddressPool.LoadBalancer.SourceName; loadBalancerNode.Tag = targetNetworkInterface.BackEndAddressPool.LoadBalancer; cloudServiceNode.Nodes.Add(loadBalancerNode); cloudServiceNode.Expand(); foreach (Azure.MigrationTarget.FrontEndIpConfiguration frontEnd in targetNetworkInterface.BackEndAddressPool.LoadBalancer.FrontEndIpConfigurations) { if (frontEnd.PublicIp != null) // if external load balancer { TreeNode publicIPAddressNode = new TreeNode(frontEnd.PublicIp.SourceName); publicIPAddressNode.Name = frontEnd.PublicIp.SourceName; publicIPAddressNode.Tag = frontEnd.PublicIp; cloudServiceNode.Nodes.Add(publicIPAddressNode); cloudServiceNode.Expand(); } } } } } subscriptionNodeASM.Expand(); treeAzureASM.Enabled = true; } } } catch (Exception exc) { if (exc.GetType() == typeof(System.Net.WebException)) { System.Net.WebException webException = (System.Net.WebException)exc; if (webException.Response != null) { HttpWebResponse exceptionResponse = (HttpWebResponse)webException.Response; if (exceptionResponse.StatusCode == HttpStatusCode.Forbidden) { ASM403ForbiddenExceptionDialog forbiddenDialog = new ASM403ForbiddenExceptionDialog(_AzureContextSource.LogProvider, exc); return; } } } UnhandledExceptionDialog exceptionDialog = new UnhandledExceptionDialog(_AzureContextSource.LogProvider, exc); exceptionDialog.ShowDialog(); } _AzureContextSource.StatusProvider.UpdateStatus("Ready"); }