Example #1
0
        ///GENMHASH:AC21A10EE2E745A89E94E447800452C1:AE9E4236A459ED3A7B2F266E3CEED6AD
        override protected void BeforeCreating()
        {
            INetworkSecurityGroup networkSecurityGroup = null;

            if (creatableNetworkSecurityGroupKey != null)
            {
                networkSecurityGroup = (INetworkSecurityGroup)this.CreatedResource(creatableNetworkSecurityGroupKey);
            }
            else if (existingNetworkSecurityGroupToAssociate != null)
            {
                networkSecurityGroup = existingNetworkSecurityGroupToAssociate;
            }

            // Associate an NSG if needed
            if (networkSecurityGroup != null)
            {
                Inner.NetworkSecurityGroup = new SubResource(networkSecurityGroup.Id);
            }

            NicIPConfigurationImpl.EnsureConfigurations(new List <INicIPConfiguration>(nicIPConfigurations.Values));

            // Reset and update IP configs
            Inner.IpConfigurations =
                InnersFromWrappers <NetworkInterfaceIPConfigurationInner, INicIPConfiguration>(nicIPConfigurations.Values);
        }
Example #2
0
        ///GENMHASH:1A5C835DC24ABE531CD7B4E1F2C4F391:7BDC77D7459BF06955C66D87C1E7832C
        internal NicIPConfigurationImpl PrimaryIPConfiguration()
        {
            NicIPConfigurationImpl primaryIPConfig = null;

            if (nicIPConfigurations.Count == 0)
            {
                // If no primary IP config found yet, then create one automatically, otherwise the NIC is in a bad state
                primaryIPConfig = PrepareNewNicIPConfiguration("primary");
                primaryIPConfig.Inner.Primary = true;
                WithIPConfiguration(primaryIPConfig);
            }
            else if (nicIPConfigurations.Count == 1)
            {
                // If there is only one IP config, assume it is primary, regardless of the Primary flag
                primaryIPConfig = (NicIPConfigurationImpl)nicIPConfigurations.Values.First();
            }
            else
            {
                // If multiple IP configs, then find the one marked as primary
                foreach (var ipConfig in nicIPConfigurations.Values)
                {
                    if (ipConfig.IsPrimary)
                    {
                        primaryIPConfig = (NicIPConfigurationImpl)ipConfig;
                        break;
                    }
                }
            }

            // Return the found primary IP config, including null, if no primary IP config can be identified
            // in which case the NIC is in a bad state anyway
            return(primaryIPConfig);
        }
Example #3
0
 ///GENMHASH:7CC443FD7234FBAB801F3A061377BC25:70718CC85D42345B50C772B8A152E349
 internal static void EnsureConfigurations(List <INicIPConfiguration> nicIPConfigurations)
 {
     foreach (var nicIPConfiguration in nicIPConfigurations)
     {
         NicIPConfigurationImpl config = (NicIPConfigurationImpl)nicIPConfiguration;
         config.Inner.Subnet          = config.SubnetToAssociate();
         config.Inner.PublicIPAddress = config.PublicIPToAssociate();
     }
 }
Example #4
0
        ///GENMHASH:6D9F740D6D73C56877B02D9F1C96F6E7:5CCB2A8EEB0CC1B9E938900812D6B964
        override protected void InitializeChildrenFromInner()
        {
            nicIPConfigurations = new Dictionary <string, INicIPConfiguration>();
            IList <NetworkInterfaceIPConfigurationInner> inners = Inner.IpConfigurations;

            if (inners != null)
            {
                foreach (NetworkInterfaceIPConfigurationInner inner in inners)
                {
                    NicIPConfigurationImpl nicIPConfiguration = new NicIPConfigurationImpl(inner, this, Manager, false);
                    nicIPConfigurations.Add(nicIPConfiguration.Name(), nicIPConfiguration);
                }
            }
        }
Example #5
0
 ///GENMHASH:3AAE2F1D370F1B47CE756627E937038D:C2E0AC9E2C66569820DF9EE965656894
 internal NetworkInterfaceImpl WithIPConfiguration(NicIPConfigurationImpl nicIPConfiguration)
 {
     nicIPConfigurations[nicIPConfiguration.Name()] = nicIPConfiguration;
     return(this);
 }
Example #6
0
        /// <summary>
        /// Gets a new IP configuration child resource NicIPConfiguration wrapping NetworkInterfaceIPConfigurationInner.
        /// </summary>
        /// <param name="name">name the name for the new ip configuration</param>
        /// <returns>NicIPConfiguration</returns>

        ///GENMHASH:A51CE48925B788F198FDE3FE4EB5A4C4:D6C23BED8CC0D3D29D563B8BE47B4997
        private NicIPConfigurationImpl PrepareNewNicIPConfiguration(string name)
        {
            NicIPConfigurationImpl nicIPConfiguration = NicIPConfigurationImpl.PrepareNicIPConfiguration(name, this, Manager);

            return(nicIPConfiguration);
        }