public NetworkInterfaceIpConfiguration(Azure.Arm.NetworkInterfaceIpConfiguration ipConfiguration, List <VirtualNetwork> virtualNetworks, TargetSettings targetSettings) : base(String.Empty, String.Empty)
        {
            _SourceIpConfiguration = ipConfiguration;

            #region Attempt to default Target Virtual Network and Target Subnet objects from source names

            this.SetTargetName(ipConfiguration.Name, targetSettings);
            if (ipConfiguration.PrivateIpAllocationMethod.Trim().ToLower() == "static")
            {
                this.TargetPrivateIPAllocationMethod = IPAllocationMethodEnum.Static;
            }
            else
            {
                this.TargetPrivateIPAllocationMethod = IPAllocationMethodEnum.Dynamic;
            }

            this.TargetPrivateIpAddress = ipConfiguration.PrivateIpAddress;
            this.TargetVirtualNetwork   = SeekVirtualNetwork(virtualNetworks, ipConfiguration.VirtualNetworkName);
            if (this.TargetVirtualNetwork != null && this.TargetVirtualNetwork.GetType() == typeof(Azure.MigrationTarget.VirtualNetwork)) // Should only be of this type, as we don't default to another existing ARM VNet (which would be of the base interface type also)
            {
                Azure.MigrationTarget.VirtualNetwork targetVirtualNetwork = (Azure.MigrationTarget.VirtualNetwork) this.TargetVirtualNetwork;
                foreach (Subnet targetSubnet in targetVirtualNetwork.TargetSubnets)
                {
                    if (targetSubnet.SourceName == ipConfiguration.SubnetName)
                    {
                        this.TargetSubnet = targetSubnet;
                        break;
                    }
                }
            }

            #endregion
        }
Exemplo n.º 2
0
        public NetworkInterfaceIpConfiguration(AzureContext azureContext, Azure.Arm.NetworkInterfaceIpConfiguration ipConfiguration, List <VirtualNetwork> virtualNetworks)
        {
            _AzureContext          = azureContext;
            _SourceIpConfiguration = ipConfiguration;

            #region Attempt to default Target Virtual Network and Target Subnet objects from source names

            this.TargetName = ipConfiguration.Name;
            this.TargetPrivateIPAllocationMethod = ipConfiguration.PrivateIpAllocationMethod;
            this.TargetPrivateIpAddress          = ipConfiguration.PrivateIpAddress;
            this.TargetVirtualNetwork            = SeekVirtualNetwork(virtualNetworks, ipConfiguration.VirtualNetworkName);
            if (this.TargetVirtualNetwork != null && this.TargetVirtualNetwork.GetType() == typeof(Azure.MigrationTarget.VirtualNetwork)) // Should only be of this type, as we don't default to another existing ARM VNet (which would be of the base interface type also)
            {
                Azure.MigrationTarget.VirtualNetwork targetVirtualNetwork = (Azure.MigrationTarget.VirtualNetwork) this.TargetVirtualNetwork;
                foreach (Subnet targetSubnet in targetVirtualNetwork.TargetSubnets)
                {
                    if (targetSubnet.SourceName == ipConfiguration.SubnetName)
                    {
                        this.TargetSubnet = targetSubnet;
                        break;
                    }
                }
            }

            #endregion
        }