Exemplo n.º 1
0
        public static bool IsContainersFeaturePresent()
        {
            try
            {
                DismPackageFeatureState featureState = DismHelper.GetFeatureState(ContainersFeatureName);

                switch (featureState)
                {
                case DismPackageFeatureState.DismStateInstallPending:
                case DismPackageFeatureState.DismStateInstalled:
                case DismPackageFeatureState.DismStateSuperseded:
                    return(true);
                }
            }
            catch (COMException ex)
            {
                // Dism COM errors aren't well understood yet across different OSes. TODO Handle specific error codes and throw the rest
                DeployerTrace.WriteWarning(StringResources.Warning_FabricDeployer_DockerDnsSetup_ErrorGettingFeatureState1, ContainersFeatureName, ex);
            }
            catch (DllNotFoundException ex)
            {
                // This happens on platforms that don't have dismapi.dll
                // https://technet.microsoft.com/en-us/library/hh825186.aspx
                DeployerTrace.WriteWarning(
                    StringResources.Warning_FabricDeployer_DockerDnsSetup_ErrorGettingFeatureState2,
                    ContainersFeatureName,
                    ex);
            }
            catch (Exception ex)
            {
                // Swallowing all!
                // Setup for Docker isn't a mainline scenario currently. Hence try and continue.
                // If an exception is thrown on an OS that has Docker, and setup doesn't continue, we have mitigation
                // steps on the VM by setting ContinueIfContainersFeatureNotInstalled.
                // E.g. FabricDeployer.exe /operation:DockerDnsSetup /continueIfContainersFeatureNotInstalled:true
                DeployerTrace.WriteWarning(
                    StringResources.Warning_FabricDeployer_DockerDnsSetup_ErrorGettingFeatureState3,
                    ContainersFeatureName,
                    ex);
            }

            return(false);
        }
Exemplo n.º 2
0
        internal static bool IsContainersFeaturePresent()
        {
            try
            {
                DismPackageFeatureState featureState = DismHelper.GetFeatureState(Constants.ContainersFeatureName);

                switch (featureState)
                {
                case DismPackageFeatureState.DismStateInstallPending:
                case DismPackageFeatureState.DismStateInstalled:
                case DismPackageFeatureState.DismStateSuperseded:
                    return(true);
                }
            }
            catch (COMException ex)
            {
                // Dism COM errors aren't well understood yet across different OSes. TODO Handle specific error codes and throw the rest
                DeployerTrace.WriteWarning("Error getting feature state for feature {0}. Treating feature as not present and continuing. Exception: {1}", Constants.ContainersFeatureName, ex);
            }
            catch (DllNotFoundException ex)
            {
                // This happens on platforms that don't have dismapi.dll
                // https://technet.microsoft.com/en-us/library/hh825186.aspx
                DeployerTrace.WriteWarning(
                    "Error getting feature state for feature {0}. This usually means that the platform doesn't support DISM APIs. " +
                    "Treating feature as not present and continuing. Exception: {1}",
                    Constants.ContainersFeatureName,
                    ex);
            }
            catch (Exception ex)
            {
                // Swallowing all!
                DeployerTrace.WriteWarning(
                    "Unexpected error getting feature state for feature {0}. " +
                    "Treating feature as not present and continuing. Exception: {1}",
                    Constants.ContainersFeatureName,
                    ex);
            }

            return(false);
        }