Example #1
0
        public VirtualMachine(AzureContext azureContext, Arm.VirtualMachine virtualMachine, List <VirtualNetwork> targetVirtualNetworks, List <StorageAccount> targetStorageAccounts, List <NetworkSecurityGroup> networkSecurityGroups)
        {
            this._AzureContext       = azureContext;
            this.Source              = virtualMachine;
            this.TargetName          = virtualMachine.Name;
            this._TargetSize         = virtualMachine.VmSize;
            this.OSVirtualHardDiskOS = virtualMachine.OSVirtualHardDiskOS;

            this.OSVirtualHardDisk = new Disk(virtualMachine.OSVirtualHardDisk);

            if (virtualMachine.OSVirtualHardDisk.GetType() == typeof(Arm.Disk))
            {
                Arm.Disk armDisk = (Arm.Disk)virtualMachine.OSVirtualHardDisk;
                this.OSVirtualHardDisk.TargetStorageAccount = SeekTargetStorageAccount(targetStorageAccounts, armDisk.StorageAccountName);
            }

            foreach (IArmDisk dataDisk in virtualMachine.DataDisks)
            {
                Disk targetDataDisk = new Disk(dataDisk);
                this.DataDisks.Add(targetDataDisk);

                if (dataDisk.GetType() == typeof(Arm.Disk))
                {
                    Arm.Disk armDisk = (Arm.Disk)dataDisk;
                    targetDataDisk.TargetStorageAccount = SeekTargetStorageAccount(targetStorageAccounts, armDisk.StorageAccountName);
                }
            }

            foreach (Arm.NetworkInterface armNetworkInterface in virtualMachine.NetworkInterfaces)
            {
                Azure.MigrationTarget.NetworkInterface migrationNetworkInterface = new Azure.MigrationTarget.NetworkInterface(_AzureContext, armNetworkInterface, targetVirtualNetworks, networkSecurityGroups);
                this.NetworkInterfaces.Add(migrationNetworkInterface);
            }
        }
        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);
        }
Example #4
0
        public VirtualMachine(AzureContext azureContext, Arm.VirtualMachine virtualMachine, List <VirtualNetwork> targetVirtualNetworks, List <StorageAccount> targetStorageAccounts, List <NetworkSecurityGroup> networkSecurityGroups)
        {
            this._AzureContext       = azureContext;
            this.Source              = virtualMachine;
            this.TargetName          = virtualMachine.Name;
            this.TargetSize          = virtualMachine.VmSize;
            this.OSVirtualHardDiskOS = virtualMachine.OSVirtualHardDiskOS;

            this.OSVirtualHardDisk = new Disk(virtualMachine.OSVirtualHardDisk);

            if (virtualMachine.OSVirtualHardDisk.GetType() == typeof(Arm.Disk))
            {
                Arm.Disk armDisk = (Arm.Disk)virtualMachine.OSVirtualHardDisk;
                this.OSVirtualHardDisk.TargetStorageAccount = SeekTargetStorageAccount(targetStorageAccounts, armDisk.StorageAccountName);
            }

            foreach (IArmDisk dataDisk in virtualMachine.DataDisks)
            {
                Disk targetDataDisk = new Disk(dataDisk);
                this.DataDisks.Add(targetDataDisk);

                if (dataDisk.GetType() == typeof(Arm.Disk))
                {
                    Arm.Disk armDisk = (Arm.Disk)dataDisk;
                    targetDataDisk.TargetStorageAccount = SeekTargetStorageAccount(targetStorageAccounts, armDisk.StorageAccountName);
                }
            }

            foreach (Arm.NetworkInterface armNetworkInterface in virtualMachine.NetworkInterfaces)
            {
                Azure.MigrationTarget.NetworkInterface migrationNetworkInterface = new Azure.MigrationTarget.NetworkInterface(_AzureContext, armNetworkInterface, targetVirtualNetworks, networkSecurityGroups);
                this.NetworkInterfaces.Add(migrationNetworkInterface);
            }

            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(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;
                }
            }
        }
Example #6
0
        public VirtualMachine(AzureContext azureContext, Asm.VirtualMachine virtualMachine, List <VirtualNetwork> targetVirtualNetworks, List <StorageAccount> targetStorageAccounts, List <NetworkSecurityGroup> networkSecurityGroups)
        {
            this._AzureContext       = azureContext;
            this.Source              = virtualMachine;
            this.TargetName          = virtualMachine.RoleName;
            this._TargetSize         = virtualMachine.RoleSize;
            this.OSVirtualHardDisk   = new Disk(virtualMachine.OSVirtualHardDisk);
            this.OSVirtualHardDiskOS = virtualMachine.OSVirtualHardDiskOS;
            this.OSVirtualHardDisk.TargetStorageAccount = SeekTargetStorageAccount(targetStorageAccounts, virtualMachine.OSVirtualHardDisk.StorageAccountName);

            foreach (Asm.Disk asmDataDisk in virtualMachine.DataDisks)
            {
                Disk targetDataDisk = new Disk(asmDataDisk);
                targetDataDisk.TargetStorageAccount = SeekTargetStorageAccount(targetStorageAccounts, asmDataDisk.StorageAccountName);
                this.DataDisks.Add(targetDataDisk);
            }

            foreach (Asm.NetworkInterface asmNetworkInterface in virtualMachine.NetworkInterfaces)
            {
                Azure.MigrationTarget.NetworkInterface migrationNetworkInterface = new Azure.MigrationTarget.NetworkInterface(_AzureContext, virtualMachine, asmNetworkInterface, targetVirtualNetworks, networkSecurityGroups);
                this.NetworkInterfaces.Add(migrationNetworkInterface);
            }
        }
Example #7
0
        public VirtualMachine(AzureContext azureContext, Asm.VirtualMachine virtualMachine, List <VirtualNetwork> targetVirtualNetworks, List <StorageAccount> targetStorageAccounts, List <NetworkSecurityGroup> networkSecurityGroups)
        {
            this._AzureContext       = azureContext;
            this.Source              = virtualMachine;
            this.TargetName          = virtualMachine.RoleName;
            this.OSVirtualHardDisk   = new Disk(virtualMachine.OSVirtualHardDisk);
            this.OSVirtualHardDiskOS = virtualMachine.OSVirtualHardDiskOS;
            this.OSVirtualHardDisk.TargetStorageAccount = SeekTargetStorageAccount(targetStorageAccounts, virtualMachine.OSVirtualHardDisk.StorageAccountName);

            foreach (Asm.Disk asmDataDisk in virtualMachine.DataDisks)
            {
                Disk targetDataDisk = new Disk(asmDataDisk);
                targetDataDisk.TargetStorageAccount = SeekTargetStorageAccount(targetStorageAccounts, asmDataDisk.StorageAccountName);
                this.DataDisks.Add(targetDataDisk);
            }

            foreach (Asm.NetworkInterface asmNetworkInterface in virtualMachine.NetworkInterfaces)
            {
                Azure.MigrationTarget.NetworkInterface migrationNetworkInterface = new Azure.MigrationTarget.NetworkInterface(_AzureContext, virtualMachine, asmNetworkInterface, targetVirtualNetworks, networkSecurityGroups);
                this.NetworkInterfaces.Add(migrationNetworkInterface);
            }

            #region Seek ARM Target Size

            // Get ARM Based Location (that matches location of Source ASM VM
            Arm.Location armLocation = _AzureContext.AzureRetriever.GetAzureARMLocation(virtualMachine.Location).Result;
            if (armLocation != null)
            {
                // First, try to seek matching ARM VM Size by name
                if (armLocation.VMSizes != null)
                {
                    this.TargetSize = armLocation.VMSizes.Where(a => a.Name == virtualMachine.RoleSize.Name).FirstOrDefault();

                    if (this.TargetSize == null)
                    {
                        // if not found, defer to alternate matching options

                        Dictionary <string, string> VMSizeTable = new Dictionary <string, string>();
                        VMSizeTable.Add("ExtraSmall", "Standard_A0");
                        VMSizeTable.Add("Small", "Standard_A1");
                        VMSizeTable.Add("Medium", "Standard_A2");
                        VMSizeTable.Add("Large", "Standard_A3");
                        VMSizeTable.Add("ExtraLarge", "Standard_A4");
                        VMSizeTable.Add("A5", "Standard_A5");
                        VMSizeTable.Add("A6", "Standard_A6");
                        VMSizeTable.Add("A7", "Standard_A7");
                        VMSizeTable.Add("A8", "Standard_A8");
                        VMSizeTable.Add("A9", "Standard_A9");
                        VMSizeTable.Add("A10", "Standard_A10");
                        VMSizeTable.Add("A11", "Standard_A11");

                        if (VMSizeTable.ContainsKey(virtualMachine.RoleSize.Name))
                        {
                            this.TargetSize = armLocation.VMSizes.Where(a => a.Name == VMSizeTable[virtualMachine.RoleSize.Name]).FirstOrDefault();
                        }
                    }
                }
            }

            #endregion
        }
        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;
            }
        }
Example #9
0
        public async Task <TreeNode> AddMigrationTargetToTargetTree(IMigrationTarget parentNode)
        {
            if (parentNode == null)
            {
                throw new ArgumentNullException("Migration Target cannot be null.");
            }

            TreeNode targetResourceGroupNode = SeekResourceGroupTreeNode();

            if (parentNode.GetType() == typeof(Azure.MigrationTarget.VirtualNetwork))
            {
                Azure.MigrationTarget.VirtualNetwork targetVirtualNetwork = (Azure.MigrationTarget.VirtualNetwork)parentNode;
                TreeNode virtualNetworkNode = SeekARMChildTreeNode(targetResourceGroupNode.Nodes, targetVirtualNetwork.SourceName, targetVirtualNetwork.ToString(), targetVirtualNetwork, true);

                foreach (Azure.MigrationTarget.Subnet targetSubnet in targetVirtualNetwork.TargetSubnets)
                {
                    TreeNode subnetNode = SeekARMChildTreeNode(virtualNetworkNode.Nodes, targetVirtualNetwork.ToString(), targetSubnet.ToString(), targetSubnet, true);
                }

                targetResourceGroupNode.ExpandAll();
                return(virtualNetworkNode);
            }
            else if (parentNode.GetType() == typeof(Azure.MigrationTarget.StorageAccount))
            {
                Azure.MigrationTarget.StorageAccount targetStorageAccount = (Azure.MigrationTarget.StorageAccount)parentNode;

                TreeNode storageAccountNode = SeekARMChildTreeNode(targetResourceGroupNode.Nodes, targetStorageAccount.SourceName, targetStorageAccount.ToString(), targetStorageAccount, true);

                targetResourceGroupNode.ExpandAll();
                return(storageAccountNode);
            }
            else if (parentNode.GetType() == typeof(Azure.MigrationTarget.NetworkSecurityGroup))
            {
                Azure.MigrationTarget.NetworkSecurityGroup targetNetworkSecurityGroup = (Azure.MigrationTarget.NetworkSecurityGroup)parentNode;
                TreeNode networkSecurityGroupNode = SeekARMChildTreeNode(targetResourceGroupNode.Nodes, targetNetworkSecurityGroup.SourceName, targetNetworkSecurityGroup.ToString(), targetNetworkSecurityGroup, true);

                targetResourceGroupNode.ExpandAll();
                return(networkSecurityGroupNode);
            }
            else if (parentNode.GetType() == typeof(Azure.MigrationTarget.LoadBalancer))
            {
                Azure.MigrationTarget.LoadBalancer targetLoadBalancer = (Azure.MigrationTarget.LoadBalancer)parentNode;
                TreeNode targetLoadBalancerNode = SeekARMChildTreeNode(targetResourceGroupNode.Nodes, targetLoadBalancer.SourceName, targetLoadBalancer.ToString(), targetLoadBalancer, true);

                targetResourceGroupNode.ExpandAll();
                return(targetLoadBalancerNode);
            }
            else if (parentNode.GetType() == typeof(Azure.MigrationTarget.PublicIp))
            {
                Azure.MigrationTarget.PublicIp targetPublicIp = (Azure.MigrationTarget.PublicIp)parentNode;
                TreeNode targetPublicIpNode = SeekARMChildTreeNode(targetResourceGroupNode.Nodes, targetPublicIp.SourceName, targetPublicIp.ToString(), targetPublicIp, true);

                targetResourceGroupNode.ExpandAll();
                return(targetPublicIpNode);
            }
            else if (parentNode.GetType() == typeof(Azure.MigrationTarget.NetworkInterface))
            {
                Azure.MigrationTarget.NetworkInterface targetNetworkInterface = (Azure.MigrationTarget.NetworkInterface)parentNode;
                TreeNode targetNetworkInterfaceNode = SeekARMChildTreeNode(targetResourceGroupNode.Nodes, targetNetworkInterface.ToString(), targetNetworkInterface.ToString(), targetNetworkInterface, true);

                targetResourceGroupNode.ExpandAll();
                return(targetNetworkInterfaceNode);
            }
            else if (parentNode.GetType() == typeof(Azure.MigrationTarget.AvailabilitySet))
            {
                Azure.MigrationTarget.AvailabilitySet targetAvailabilitySet = (Azure.MigrationTarget.AvailabilitySet)parentNode;
                TreeNode targetAvailabilitySetNode = SeekARMChildTreeNode(targetResourceGroupNode.Nodes, targetAvailabilitySet.ToString(), targetAvailabilitySet.ToString(), targetAvailabilitySet, true);

                targetResourceGroupNode.ExpandAll();
                return(targetAvailabilitySetNode);
            }
            else if (parentNode.GetType() == typeof(Azure.MigrationTarget.VirtualMachine))
            {
                Azure.MigrationTarget.VirtualMachine targetVirtualMachine = (Azure.MigrationTarget.VirtualMachine)parentNode;

                TreeNode virtualMachineParentNode = targetResourceGroupNode;
                TreeNode virtualMachineNode       = SeekARMChildTreeNode(virtualMachineParentNode.Nodes, targetVirtualMachine.SourceName, targetVirtualMachine.ToString(), targetVirtualMachine, true);

                if (targetVirtualMachine.TargetAvailabilitySet != null)
                {
                    if (targetVirtualMachine.TargetAvailabilitySet.SourceAvailabilitySet != null && targetVirtualMachine.TargetAvailabilitySet.SourceAvailabilitySet.GetType() == typeof(Asm.CloudService))
                    {
                        // Adding under Virtual Machine, as it is not a managed disk
                        TreeNode dataDiskNode = SeekARMChildTreeNode(targetResourceGroupNode.Nodes, targetVirtualMachine.TargetAvailabilitySet.ToString(), targetVirtualMachine.TargetAvailabilitySet.ToString(), targetVirtualMachine.TargetAvailabilitySet, true);
                    }
                }

                if (targetVirtualMachine.OSVirtualHardDisk.IsUnmanagedDisk)
                {
                    // Adding under Virtual Machine, as it is not a managed disk
                    TreeNode dataDiskNode = SeekARMChildTreeNode(virtualMachineNode.Nodes, targetVirtualMachine.OSVirtualHardDisk.ToString(), targetVirtualMachine.OSVirtualHardDisk.ToString(), targetVirtualMachine.OSVirtualHardDisk, true);
                }
                else
                {
                    // Under Resource Group, as it is a managed Disk
                    TreeNode dataDiskNode = SeekARMChildTreeNode(virtualMachineParentNode.Nodes, targetVirtualMachine.OSVirtualHardDisk.ToString(), targetVirtualMachine.OSVirtualHardDisk.ToString(), targetVirtualMachine.OSVirtualHardDisk, true);
                }

                foreach (Azure.MigrationTarget.Disk targetDisk in targetVirtualMachine.DataDisks)
                {
                    if (targetDisk.IsUnmanagedDisk)
                    {
                        // Adding under Virtual Machine, as it is not a managed disk
                        TreeNode dataDiskNode = SeekARMChildTreeNode(virtualMachineNode.Nodes, targetDisk.ToString(), targetDisk.ToString(), targetDisk, true);
                    }
                    else
                    {
                        // Under Resource Group, as it is a managed Disk
                        TreeNode dataDiskNode = SeekARMChildTreeNode(virtualMachineParentNode.Nodes, targetDisk.ToString(), targetDisk.ToString(), targetDisk, true);
                    }
                }

                foreach (Azure.MigrationTarget.NetworkInterface targetNetworkInterface in targetVirtualMachine.NetworkInterfaces)
                {
                    if (targetNetworkInterface.SourceNetworkInterface != null && targetNetworkInterface.SourceNetworkInterface.GetType() == typeof(Azure.Asm.NetworkInterface))
                    {
                        // We are only adding as a child node if it is an ASM Network Interface, otherwise we expect this to follow ARM convention in which NIC is a first class object in the resource group (not embededded under the VM).
                        TreeNode networkInterfaceNode = SeekARMChildTreeNode(targetResourceGroupNode.Nodes, targetNetworkInterface.ToString(), targetNetworkInterface.ToString(), targetNetworkInterface, true);
                    }
                }

                targetResourceGroupNode.ExpandAll();
                return(virtualMachineNode);
            }
            else if (parentNode.GetType() == typeof(Azure.MigrationTarget.Disk))
            {
                Azure.MigrationTarget.Disk targetDisk = (Azure.MigrationTarget.Disk)parentNode;
                TreeNode targetDiskNode = SeekARMChildTreeNode(targetResourceGroupNode.Nodes, targetDisk.SourceName, targetDisk.ToString(), targetDisk, true);

                targetResourceGroupNode.ExpandAll();
                return(targetDiskNode);
            }
            else if (parentNode.GetType() == typeof(Azure.MigrationTarget.VirtualMachineImage))
            {
                Azure.MigrationTarget.VirtualMachineImage targetVirtualMachineImage = (Azure.MigrationTarget.VirtualMachineImage)parentNode;
                TreeNode targetVirtualMachineImageNode = SeekARMChildTreeNode(targetResourceGroupNode.Nodes, targetVirtualMachineImage.SourceName, targetVirtualMachineImage.ToString(), targetVirtualMachineImage, true);

                targetResourceGroupNode.ExpandAll();
                return(targetVirtualMachineImageNode);
            }
            else if (parentNode.GetType() == typeof(Azure.MigrationTarget.NetworkInterface))
            {
                Azure.MigrationTarget.NetworkInterface targetNetworkInterface = (Azure.MigrationTarget.NetworkInterface)parentNode;
                TreeNode targetNetworkInterfaceNode = SeekARMChildTreeNode(targetResourceGroupNode.Nodes, targetNetworkInterface.SourceName, targetNetworkInterface.ToString(), targetNetworkInterface, true);

                targetResourceGroupNode.ExpandAll();
                return(targetNetworkInterfaceNode);
            }
            else if (parentNode.GetType() == typeof(Azure.MigrationTarget.RouteTable))
            {
                Azure.MigrationTarget.RouteTable targetRouteTable = (Azure.MigrationTarget.RouteTable)parentNode;
                TreeNode targetRouteTableNode = SeekARMChildTreeNode(targetResourceGroupNode.Nodes, targetRouteTable.SourceName, targetRouteTable.ToString(), targetRouteTable, true);

                targetRouteTableNode.ExpandAll();
                return(targetRouteTableNode);
            }
            else
            {
                throw new Exception("Unhandled Node Type in AddMigrationTargetToTargetTree: " + parentNode.GetType());
            }
        }