public Disk(IArmDisk sourceDisk, VirtualMachine parentVirtualMachine, TargetSettings targetSettings) : base(ArmConst.MicrosoftCompute, ArmConst.Disks) { this.SourceDisk = (IDisk)sourceDisk; this._ParentVirtualMachine = parentVirtualMachine; this.TargetStorage = new ManagedDiskStorage(sourceDisk); if (sourceDisk != null) { if (sourceDisk.GetType() == typeof(Azure.Arm.ClassicDisk)) { Azure.Arm.ClassicDisk armDisk = (Azure.Arm.ClassicDisk)sourceDisk; this.SetTargetName(armDisk.Name, targetSettings); this.Lun = armDisk.Lun; this.HostCaching = armDisk.Caching; this.DiskSizeInGB = armDisk.DiskSizeGb; this.TargetStorageAccountBlob = armDisk.StorageAccountBlob; this.SourceStorageAccount = armDisk.SourceStorageAccount; } else if (sourceDisk.GetType() == typeof(Azure.Arm.ManagedDisk)) { Azure.Arm.ManagedDisk armManagedDisk = (Azure.Arm.ManagedDisk)sourceDisk; this.SetTargetName(armManagedDisk.Name, targetSettings); this.DiskSizeInGB = armManagedDisk.DiskSizeGb; } } }
public Disk(IArmDisk sourceDisk, VirtualMachine parentVirtualMachine) { this.SourceDisk = (IDisk)sourceDisk; this._ParentVirtualMachine = parentVirtualMachine; this.TargetStorage = new ManagedDiskStorage(sourceDisk); if (sourceDisk.GetType() == typeof(Azure.Arm.ClassicDisk)) { Azure.Arm.ClassicDisk armDisk = (Azure.Arm.ClassicDisk)sourceDisk; this.TargetName = armDisk.Name; this.Lun = armDisk.Lun; this.HostCaching = armDisk.Caching; this.DiskSizeInGB = armDisk.DiskSizeGb; this.TargetStorageAccountBlob = armDisk.StorageAccountBlob; this.SourceStorageAccount = armDisk.SourceStorageAccount; } else if (sourceDisk.GetType() == typeof(Azure.Arm.ManagedDisk)) { Azure.Arm.ManagedDisk armManagedDisk = (Azure.Arm.ManagedDisk)sourceDisk; this.TargetName = armManagedDisk.Name; this.DiskSizeInGB = armManagedDisk.DiskSizeGb; } }
public Disk(IArmDisk sourceDisk) { this.SourceDisk = (IDisk)sourceDisk; if (sourceDisk.GetType() == typeof(Azure.Arm.Disk)) { Azure.Arm.Disk armDisk = (Azure.Arm.Disk)sourceDisk; this.TargetName = armDisk.Name; this.Lun = armDisk.Lun; this.HostCaching = armDisk.Caching; this.DiskSizeInGB = armDisk.DiskSizeGb; this.TargetStorageAccountBlob = armDisk.StorageAccountBlob; this.SourceStorageAccount = armDisk.SourceStorageAccount; } else if (sourceDisk.GetType() == typeof(Azure.Arm.ManagedDisk)) { Azure.Arm.ManagedDisk armManagedDisk = (Azure.Arm.ManagedDisk)sourceDisk; } }
public Disk(IArmDisk sourceDisk, VirtualMachine parentVirtualMachine, TargetSettings targetSettings, ILogProvider logProvider) : base(ArmConst.MicrosoftCompute, ArmConst.Disks, logProvider) { this.SourceDisk = (IDisk)sourceDisk; this._ParentVirtualMachine = parentVirtualMachine; this.TargetStorage = new ManagedDiskStorage(sourceDisk); if (sourceDisk != null) { if (sourceDisk.GetType() == typeof(Azure.Arm.ClassicDisk)) { Azure.Arm.ClassicDisk armDisk = (Azure.Arm.ClassicDisk)sourceDisk; this.SetTargetName(armDisk.Name, targetSettings); this.Lun = armDisk.Lun; this.HostCaching = armDisk.Caching; this.DiskSizeInGB = armDisk.DiskSizeGb; this.TargetStorageAccountBlob = armDisk.StorageAccountBlob; this.SourceStorageAccount = armDisk.SourceStorageAccount; this.IsEncrypted = armDisk.IsEncrypted; this.DiskEncryptionKeySourceVaultId = armDisk.DiskEncryptionKeySourceVaultId; this.DiskEncryptionKeySecretUrl = armDisk.DiskEncryptionKeySecretUrl; this.KeyEncryptionKeySourceVaultId = armDisk.KeyEncryptionKeySourceVaultId; this.KeyEncryptionKeyKeyUrl = armDisk.KeyEncryptionKeyKeyUrl; } else if (sourceDisk.GetType() == typeof(Azure.Arm.ManagedDisk)) { Azure.Arm.ManagedDisk armManagedDisk = (Azure.Arm.ManagedDisk)sourceDisk; this.SetTargetName(armManagedDisk.Name, targetSettings); this.DiskSizeInGB = armManagedDisk.DiskSizeGb; this.IsEncrypted = armManagedDisk.IsEncrypted; this.DiskEncryptionKeySourceVaultId = armManagedDisk.DiskEncryptionKeySourceVaultId; this.DiskEncryptionKeySecretUrl = armManagedDisk.DiskEncryptionKeySecretUrl; this.KeyEncryptionKeySourceVaultId = armManagedDisk.KeyEncryptionKeySourceVaultId; this.KeyEncryptionKeyKeyUrl = armManagedDisk.KeyEncryptionKeyKeyUrl; } } }
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()); } } }
private async Task AsmSelectDependencies(TreeNode selectedNode) { if (this.AutoSelectDependencies && (selectedNode.Checked) && (selectedNode.Tag != null)) { if (selectedNode.Tag.GetType() == typeof(Azure.MigrationTarget.AvailabilitySet)) { Azure.MigrationTarget.AvailabilitySet targetAvailabilitySet = (Azure.MigrationTarget.AvailabilitySet)selectedNode.Tag; foreach (Azure.MigrationTarget.VirtualMachine targetVirtualMachine in targetAvailabilitySet.TargetVirtualMachines) { foreach (TreeNode treeNode in selectedNode.TreeView.Nodes.Find(targetVirtualMachine.TargetName, true)) { if ((treeNode.Tag != null) && (treeNode.Tag.GetType() == typeof(Azure.MigrationTarget.VirtualMachine))) { if (!treeNode.Checked) { treeNode.Checked = true; } } } } } if (selectedNode.Tag.GetType() == typeof(Azure.MigrationTarget.VirtualMachine)) { Azure.MigrationTarget.VirtualMachine targetVirtualMachine = (Azure.MigrationTarget.VirtualMachine)selectedNode.Tag; if (targetVirtualMachine.Source != null) { if (targetVirtualMachine.Source.GetType() == typeof(Azure.Arm.VirtualMachine)) { Azure.Arm.VirtualMachine armVirtualMachine = (Azure.Arm.VirtualMachine)targetVirtualMachine.Source; #region process virtual network // This source code to auto select the Virtual Network as a Parent node has been commented out purposefully. // It was observed through use of MigAz that users were not aware that "including the Virtual Network" in multiple // migrations was actually creating new / independent / non-connected versions of the same Virtual Network. // It is valid that the user would want to migrate the Virtual Network during the first run migration; however, beyond // that first pass (the Azure ARM Virtual Network exists) the user is more likely to need to migrate the Virtual Machine(s) // into an existing Azure Virtual Network. In order to guide the user in this direction, we do not want to auto select the // source Virtual Network to be included in the Migration Template as a new Virtual Network. We want the user to explicitly // select and include the source Azure Virtual Network into the Migration Template (if they want to include it), or utilize // the built in property editor dialogs to "select an existing Virtual Network and Subnet". //foreach (Azure.Arm.NetworkInterface networkInterface in armVirtualMachine.NetworkInterfaces) //{ // foreach (Azure.Arm.NetworkInterfaceIpConfiguration ipConfiguration in networkInterface.NetworkInterfaceIpConfigurations) // { // if (ipConfiguration.VirtualNetwork != null) // { // foreach (TreeNode treeNode in selectedNode.TreeView.Nodes.Find(ipConfiguration.VirtualNetwork.Name, true)) // { // if ((treeNode.Tag != null) && (treeNode.Tag.GetType() == typeof(Azure.MigrationTarget.VirtualNetwork))) // { // if (!treeNode.Checked) // treeNode.Checked = true; // } // } // } // } //} #endregion #region process managed disks if (armVirtualMachine.OSVirtualHardDisk.GetType() == typeof(Azure.Arm.ManagedDisk)) { foreach (TreeNode treeNode in selectedNode.TreeView.Nodes.Find(((Azure.Arm.ManagedDisk)armVirtualMachine.OSVirtualHardDisk).Name, true)) { if ((treeNode.Tag != null) && (treeNode.Tag.GetType() == typeof(Azure.MigrationTarget.Disk))) { if (!treeNode.Checked) { treeNode.Checked = true; } } } } foreach (Azure.Interface.IArmDisk dataDisk in armVirtualMachine.DataDisks) { if (dataDisk.GetType() == typeof(Azure.Arm.ManagedDisk)) { Azure.Arm.ManagedDisk managedDisk = (Azure.Arm.ManagedDisk)dataDisk; foreach (TreeNode treeNode in selectedNode.TreeView.Nodes.Find(managedDisk.Name, true)) { if ((treeNode.Tag != null) && (treeNode.Tag.GetType() == typeof(Azure.MigrationTarget.Disk))) { if (!treeNode.Checked) { treeNode.Checked = true; } } } } } #endregion #region OS Disk Storage Account if (armVirtualMachine.OSVirtualHardDisk.GetType() == typeof(Azure.Arm.ClassicDisk)) // Disk in a Storage Account, not a Managed Disk { foreach (TreeNode treeNode in selectedNode.TreeView.Nodes.Find(((Azure.Arm.ClassicDisk)armVirtualMachine.OSVirtualHardDisk).StorageAccountName, true)) { if ((treeNode.Tag != null) && (treeNode.Tag.GetType() == typeof(Azure.MigrationTarget.StorageAccount))) { if (!treeNode.Checked) { treeNode.Checked = true; } } } } #endregion #region Data Disk(s) Storage Account(s) foreach (IArmDisk dataDisk in armVirtualMachine.DataDisks) { if (dataDisk.GetType() == typeof(Azure.Arm.ClassicDisk)) { Azure.Arm.ClassicDisk classicDisk = (Azure.Arm.ClassicDisk)dataDisk; foreach (TreeNode treeNode in selectedNode.TreeView.Nodes.Find(classicDisk.StorageAccountName, true)) { if ((treeNode.Tag != null) && (treeNode.Tag.GetType() == typeof(Azure.MigrationTarget.StorageAccount))) { if (!treeNode.Checked) { treeNode.Checked = true; } } } } else if (dataDisk.GetType() == typeof(Azure.Arm.ManagedDisk)) { Azure.Arm.ManagedDisk managedDisk = (Azure.Arm.ManagedDisk)dataDisk; foreach (TreeNode treeNode in selectedNode.TreeView.Nodes.Find(managedDisk.Name, true)) { if ((treeNode.Tag != null) && (treeNode.Tag.GetType() == typeof(Azure.MigrationTarget.Disk))) { if (!treeNode.Checked) { treeNode.Checked = true; } } } } } #endregion #region Network Interface Card(s) foreach (Azure.Arm.NetworkInterface networkInterface in armVirtualMachine.NetworkInterfaces) { foreach (TreeNode treeNode in selectedNode.TreeView.Nodes.Find(networkInterface.Name, true)) { if ((treeNode.Tag != null) && (treeNode.Tag.GetType() == typeof(Azure.MigrationTarget.NetworkInterface))) { if (!treeNode.Checked) { treeNode.Checked = true; } } } if (networkInterface.NetworkSecurityGroup != null) { foreach (TreeNode treeNode in selectedNode.TreeView.Nodes.Find(networkInterface.NetworkSecurityGroup.Name, true)) { if ((treeNode.Tag != null) && (treeNode.Tag.GetType() == typeof(Azure.MigrationTarget.NetworkSecurityGroup))) { if (!treeNode.Checked) { treeNode.Checked = true; } } } } foreach (Azure.Arm.NetworkInterfaceIpConfiguration ipConfiguration in networkInterface.NetworkInterfaceIpConfigurations) { if (ipConfiguration.BackEndAddressPool != null && ipConfiguration.BackEndAddressPool.LoadBalancer != null) { foreach (TreeNode treeNode in selectedNode.TreeView.Nodes.Find(ipConfiguration.BackEndAddressPool.LoadBalancer.Name, true)) { if ((treeNode.Tag != null) && (treeNode.Tag.GetType() == typeof(Azure.MigrationTarget.LoadBalancer))) { if (!treeNode.Checked) { treeNode.Checked = true; } } } } if (ipConfiguration.PublicIP != null) { foreach (TreeNode treeNode in selectedNode.TreeView.Nodes.Find(ipConfiguration.PublicIP.Name, true)) { if ((treeNode.Tag != null) && (treeNode.Tag.GetType() == typeof(Azure.MigrationTarget.PublicIp))) { if (!treeNode.Checked) { treeNode.Checked = true; } } } } } } #endregion #region Parent Availability Set if (armVirtualMachine.AvailabilitySet != null) { foreach (TreeNode treeNode in selectedNode.TreeView.Nodes.Find(armVirtualMachine.AvailabilitySet.Name, true)) { if ((treeNode.Tag != null) && (treeNode.Tag.GetType() == typeof(Azure.MigrationTarget.AvailabilitySet))) { if (!treeNode.Checked) { treeNode.Checked = true; } } } } #endregion } } } else if (selectedNode.Tag.GetType() == typeof(Azure.MigrationTarget.VirtualNetwork)) { Azure.MigrationTarget.VirtualNetwork targetVirtualNetwork = (Azure.MigrationTarget.VirtualNetwork)selectedNode.Tag; foreach (Azure.MigrationTarget.Subnet targetSubnet in targetVirtualNetwork.TargetSubnets) { if (targetSubnet.NetworkSecurityGroup != null) { if (targetSubnet.NetworkSecurityGroup.SourceNetworkSecurityGroup != null) { if (targetSubnet.NetworkSecurityGroup.SourceNetworkSecurityGroup.GetType() == typeof(Azure.Arm.NetworkSecurityGroup)) { foreach (TreeNode treeNode in selectedNode.TreeView.Nodes.Find(targetSubnet.NetworkSecurityGroup.SourceName, true)) { if ((treeNode.Tag != null) && (treeNode.Tag.GetType() == typeof(Azure.MigrationTarget.NetworkSecurityGroup))) { if (!treeNode.Checked) { treeNode.Checked = true; } } } } } } } } else if (selectedNode.Tag.GetType() == typeof(Azure.MigrationTarget.LoadBalancer)) { Azure.MigrationTarget.LoadBalancer targetLoadBalancer = (Azure.MigrationTarget.LoadBalancer)selectedNode.Tag; if (targetLoadBalancer.Source != null) { if (targetLoadBalancer.Source.GetType() == typeof(Azure.Arm.LoadBalancer)) { Azure.Arm.LoadBalancer armLoadBalaner = (Azure.Arm.LoadBalancer)targetLoadBalancer.Source; foreach (Azure.Arm.FrontEndIpConfiguration frontEndIpConfiguration in armLoadBalaner.FrontEndIpConfigurations) { if (frontEndIpConfiguration.PublicIP != null) { foreach (TreeNode treeNode in selectedNode.TreeView.Nodes.Find(frontEndIpConfiguration.PublicIP.Name, true)) { if ((treeNode.Tag != null) && (treeNode.Tag.GetType() == typeof(Azure.MigrationTarget.PublicIp))) { if (!treeNode.Checked) { treeNode.Checked = true; } } } } } } } } _StatusProvider.UpdateStatus("Ready"); } }
public async Task BindArmResources(AzureContext azureContext, AzureSubscription azureSubscription, TargetSettings targetSettings) { treeAzureARM.Nodes.Clear(); try { if (azureSubscription != null) { await azureSubscription.BindArmResources(targetSettings); if (azureSubscription != null) { TreeNode subscriptionNodeARM = new TreeNode(azureSubscription.Name); subscriptionNodeARM.ImageKey = "Subscription"; subscriptionNodeARM.SelectedImageKey = "Subscription"; treeAzureARM.Nodes.Add(subscriptionNodeARM); subscriptionNodeARM.Expand(); foreach (MigrationTarget.NetworkSecurityGroup targetNetworkSecurityGroup in azureSubscription.ArmTargetNetworkSecurityGroups) { TreeNode networkSecurityGroupParentNode = GetResourceGroupTreeNode(subscriptionNodeARM, ((Azure.Arm.NetworkSecurityGroup)targetNetworkSecurityGroup.SourceNetworkSecurityGroup).ResourceGroup); TreeNode tnNetworkSecurityGroup = new TreeNode(targetNetworkSecurityGroup.SourceName); tnNetworkSecurityGroup.Name = targetNetworkSecurityGroup.SourceName; tnNetworkSecurityGroup.Tag = targetNetworkSecurityGroup; tnNetworkSecurityGroup.ImageKey = targetNetworkSecurityGroup.ImageKey; tnNetworkSecurityGroup.SelectedImageKey = targetNetworkSecurityGroup.ImageKey; networkSecurityGroupParentNode.Nodes.Add(tnNetworkSecurityGroup); } foreach (MigrationTarget.PublicIp targetPublicIP in azureSubscription.ArmTargetPublicIPs) { TreeNode publicIpParentNode = GetResourceGroupTreeNode(subscriptionNodeARM, ((Azure.Arm.PublicIP)targetPublicIP.Source).ResourceGroup);; TreeNode tnPublicIP = new TreeNode(targetPublicIP.SourceName); tnPublicIP.Name = targetPublicIP.SourceName; tnPublicIP.Tag = targetPublicIP; tnPublicIP.ImageKey = targetPublicIP.ImageKey; tnPublicIP.SelectedImageKey = targetPublicIP.ImageKey; publicIpParentNode.Nodes.Add(tnPublicIP); } foreach (MigrationTarget.RouteTable targetRouteTable in azureSubscription.ArmTargetRouteTables) { TreeNode routeTableParentNode = GetResourceGroupTreeNode(subscriptionNodeARM, ((Azure.Arm.RouteTable)targetRouteTable.Source).ResourceGroup); TreeNode tnRouteTable = new TreeNode(targetRouteTable.SourceName); tnRouteTable.Name = targetRouteTable.SourceName; tnRouteTable.Tag = targetRouteTable; tnRouteTable.ImageKey = targetRouteTable.ImageKey; tnRouteTable.SelectedImageKey = targetRouteTable.ImageKey; routeTableParentNode.Nodes.Add(tnRouteTable); } foreach (MigrationTarget.VirtualNetwork targetVirtualNetwork in azureSubscription.ArmTargetVirtualNetworks) { TreeNode virtualNetworkParentNode = GetResourceGroupTreeNode(subscriptionNodeARM, ((Azure.Arm.VirtualNetwork)targetVirtualNetwork.SourceVirtualNetwork).ResourceGroup); TreeNode tnVirtualNetwork = new TreeNode(targetVirtualNetwork.SourceName); tnVirtualNetwork.Name = targetVirtualNetwork.SourceName; tnVirtualNetwork.Tag = targetVirtualNetwork; tnVirtualNetwork.ImageKey = targetVirtualNetwork.ImageKey; tnVirtualNetwork.SelectedImageKey = targetVirtualNetwork.ImageKey; virtualNetworkParentNode.Nodes.Add(tnVirtualNetwork); } foreach (MigrationTarget.VirtualNetworkGateway targetVirtualNetworkGateway in azureSubscription.ArmTargetVirtualNetworkGateways) { TreeNode virtualNetworkGatewayParentNode = GetResourceGroupTreeNode(subscriptionNodeARM, ((Azure.Arm.VirtualNetworkGateway)targetVirtualNetworkGateway.SourceVirtualNetworkGateway).ResourceGroup); TreeNode tnVirtualNetworkGateway = new TreeNode(targetVirtualNetworkGateway.SourceName); tnVirtualNetworkGateway.Name = targetVirtualNetworkGateway.SourceName; tnVirtualNetworkGateway.Tag = targetVirtualNetworkGateway; tnVirtualNetworkGateway.ImageKey = targetVirtualNetworkGateway.ImageKey; tnVirtualNetworkGateway.SelectedImageKey = targetVirtualNetworkGateway.ImageKey; virtualNetworkGatewayParentNode.Nodes.Add(tnVirtualNetworkGateway); } foreach (MigrationTarget.LocalNetworkGateway targetLocalNetworkGateway in azureSubscription.ArmTargetLocalNetworkGateways) { TreeNode localNetworkGatewayParentNode = GetResourceGroupTreeNode(subscriptionNodeARM, ((Azure.Arm.LocalNetworkGateway)targetLocalNetworkGateway.SourceLocalNetworkGateway).ResourceGroup); TreeNode tnLocalNetworkGateway = new TreeNode(targetLocalNetworkGateway.SourceName); tnLocalNetworkGateway.Name = targetLocalNetworkGateway.SourceName; tnLocalNetworkGateway.Tag = targetLocalNetworkGateway; tnLocalNetworkGateway.ImageKey = targetLocalNetworkGateway.ImageKey; tnLocalNetworkGateway.SelectedImageKey = targetLocalNetworkGateway.ImageKey; localNetworkGatewayParentNode.Nodes.Add(tnLocalNetworkGateway); } foreach (MigrationTarget.VirtualNetworkGatewayConnection targetConnection in azureSubscription.ArmTargetConnections) { TreeNode connectionParentNode = GetResourceGroupTreeNode(subscriptionNodeARM, ((Azure.Arm.VirtualNetworkGatewayConnection)targetConnection.SourceConnection).ResourceGroup); TreeNode tnConnection = new TreeNode(targetConnection.SourceName); tnConnection.Name = targetConnection.SourceName; tnConnection.Tag = targetConnection; tnConnection.ImageKey = targetConnection.ImageKey; tnConnection.SelectedImageKey = targetConnection.ImageKey; connectionParentNode.Nodes.Add(tnConnection); } foreach (MigrationTarget.StorageAccount targetStorageAccount in azureSubscription.ArmTargetStorageAccounts) { TreeNode storageAccountParentNode = GetResourceGroupTreeNode(subscriptionNodeARM, ((Azure.Arm.StorageAccount)targetStorageAccount.SourceAccount).ResourceGroup); TreeNode tnStorageAccount = new TreeNode(targetStorageAccount.SourceName); tnStorageAccount.Name = targetStorageAccount.SourceName; tnStorageAccount.Tag = targetStorageAccount; tnStorageAccount.ImageKey = targetStorageAccount.ImageKey; tnStorageAccount.SelectedImageKey = targetStorageAccount.ImageKey; storageAccountParentNode.Nodes.Add(tnStorageAccount); } foreach (MigrationTarget.Disk targetManagedDisk in azureSubscription.ArmTargetManagedDisks) { Azure.Arm.ManagedDisk armManagedDisk = (Azure.Arm.ManagedDisk)targetManagedDisk.SourceDisk; TreeNode managedDiskParentNode = GetResourceGroupTreeNode(subscriptionNodeARM, armManagedDisk.ResourceGroup); TreeNode tnDisk = new TreeNode(targetManagedDisk.SourceName); tnDisk.Name = targetManagedDisk.SourceName; tnDisk.Tag = targetManagedDisk; tnDisk.ImageKey = targetManagedDisk.ImageKey; tnDisk.SelectedImageKey = targetManagedDisk.ImageKey; managedDiskParentNode.Nodes.Add(tnDisk); } foreach (MigrationTarget.AvailabilitySet targetAvailabilitySet in azureSubscription.ArmTargetAvailabilitySets) { TreeNode availabilitySetParentNode = GetResourceGroupTreeNode(subscriptionNodeARM, ((Azure.Arm.AvailabilitySet)targetAvailabilitySet.SourceAvailabilitySet).ResourceGroup); TreeNode tnAvailabilitySet = new TreeNode(targetAvailabilitySet.SourceName); tnAvailabilitySet.Name = targetAvailabilitySet.SourceName; tnAvailabilitySet.Tag = targetAvailabilitySet; tnAvailabilitySet.ImageKey = targetAvailabilitySet.ImageKey; tnAvailabilitySet.SelectedImageKey = targetAvailabilitySet.ImageKey; availabilitySetParentNode.Nodes.Add(tnAvailabilitySet); } foreach (MigrationTarget.NetworkInterface targetNetworkInterface in azureSubscription.ArmTargetNetworkInterfaces) { TreeNode tnResourceGroup = GetResourceGroupTreeNode(subscriptionNodeARM, ((Azure.Arm.NetworkInterface)targetNetworkInterface.SourceNetworkInterface).ResourceGroup); TreeNode txNetworkInterface = new TreeNode(targetNetworkInterface.SourceName); txNetworkInterface.Name = targetNetworkInterface.SourceName; txNetworkInterface.Tag = targetNetworkInterface; txNetworkInterface.ImageKey = targetNetworkInterface.ImageKey; txNetworkInterface.SelectedImageKey = targetNetworkInterface.ImageKey; tnResourceGroup.Nodes.Add(txNetworkInterface); } foreach (MigrationTarget.VirtualMachine targetVirtualMachine in azureSubscription.ArmTargetVirtualMachines) { TreeNode tnResourceGroup = GetResourceGroupTreeNode(subscriptionNodeARM, ((Azure.Arm.VirtualMachine)targetVirtualMachine.Source).ResourceGroup); TreeNode tnVirtualMachine = new TreeNode(targetVirtualMachine.SourceName); tnVirtualMachine.Name = targetVirtualMachine.SourceName; tnVirtualMachine.Tag = targetVirtualMachine; tnVirtualMachine.ImageKey = targetVirtualMachine.ImageKey; tnVirtualMachine.SelectedImageKey = targetVirtualMachine.ImageKey; tnResourceGroup.Nodes.Add(tnVirtualMachine); } foreach (MigrationTarget.LoadBalancer targetLoadBalancer in azureSubscription.ArmTargetLoadBalancers) { TreeNode networkSecurityGroupParentNode = GetResourceGroupTreeNode(subscriptionNodeARM, ((Azure.Arm.LoadBalancer)targetLoadBalancer.Source).ResourceGroup); TreeNode tnNetworkSecurityGroup = new TreeNode(targetLoadBalancer.SourceName); tnNetworkSecurityGroup.Name = targetLoadBalancer.SourceName; tnNetworkSecurityGroup.Tag = targetLoadBalancer; tnNetworkSecurityGroup.ImageKey = targetLoadBalancer.ImageKey; tnNetworkSecurityGroup.SelectedImageKey = targetLoadBalancer.ImageKey; networkSecurityGroupParentNode.Nodes.Add(tnNetworkSecurityGroup); } //foreach (MigrationTarget.VirtualMachineImage targetVirtualMachineImage in _AzureContextSource.AzureSubscription.ArmTargetVirtualMachineImages) //{ // TreeNode virtualMachineImageParentNode = GetResourceGroupTreeNode(subscriptionNodeARM, ((Azure.Arm.VirtualMachineImage)targetVirtualMachineImage.Source).ResourceGroup); // TreeNode tnVirtualMachineImage = new TreeNode(targetVirtualMachineImage.SourceName); // tnVirtualMachineImage.Name = targetVirtualMachineImage.SourceName; // tnVirtualMachineImage.Tag = targetVirtualMachineImage; // tnVirtualMachineImage.ImageKey = "VirtualMachineImage"; // tnVirtualMachineImage.SelectedImageKey = "VirtualMachineImage"; // virtualMachineImageParentNode.Nodes.Add(tnVirtualMachineImage); //} subscriptionNodeARM.Expand(); treeAzureARM.Sort(); treeAzureARM.Enabled = true; } } } catch (Exception exc) { UnhandledExceptionDialog exceptionDialog = new UnhandledExceptionDialog(_LogProvider, exc); exceptionDialog.ShowDialog(); } _StatusProvider.UpdateStatus("Ready"); }
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()); } } }
public ManagedDisk(Azure.Arm.ManagedDisk sourceManagedDisk) { _SourceManagedDisk = sourceManagedDisk; this.TargetName = sourceManagedDisk.Name; }