Example #1
0
        internal static IImageStore CreateImageStore(
            string imageStoreUri,
            string localRoot,
            string[] connectionStrings,
            SecurityCredentials credentials,
            string workingDirectory,
            bool isInternal)
        {
            if (imageStoreUri == null)
            {
                throw new ArgumentException(StringResources.Error_InvalidImageStoreConnectionString);
            }

            if (FileImageStore.IsFileStoreUri(imageStoreUri))
            {
                string rootUri;
                string accountName, accountPassword;
                bool   isManagedServiceAccount;

                ImageStoreFactory.ParseFileImageStoreConnectionString(
                    imageStoreUri,
                    out rootUri,
                    out accountName,
                    out accountPassword,
                    out isManagedServiceAccount);

                ImageStoreAccessDescription accessDescription = null;

#if !DotNetCoreClrLinux
                WindowsIdentity windowsIdentity = null;

                windowsIdentity = GetWindowsIdentity(accountName, accountPassword, isManagedServiceAccount);

                if (windowsIdentity != null)
                {
                    accessDescription = new ImageStoreAccessDescription(windowsIdentity, localRoot);
                }
#endif

                return(new FileImageStore(rootUri, localRoot, accessDescription));
            }
            else if (XStoreProxy.IsXStoreUri(imageStoreUri))
            {
                return(new XStoreProxy(imageStoreUri, localRoot));
            }
            else if (NativeImageStoreClient.IsNativeImageStoreUri(imageStoreUri))
            {
                return(new NativeImageStoreClient(connectionStrings, isInternal, workingDirectory, credentials));
            }
            else
            {
                throw new ArgumentException(StringResources.ImageStoreError_InvalidImageStoreUriScheme);
            }
        }
Example #2
0
 /// <summary>
 /// Helper method to determine the Image Store provider type based on an unencrypted Image Store connection string.
 /// </summary>
 /// <param name="imageStoreConnectionString">The unencrypted Image Store connection string found in the cluster manifest.</param>
 /// <returns>
 /// <para>The Image Store provider type.</para>
 /// </returns>
 internal static ImageStoreProviderType GetImageStoreProviderType(string imageStoreConnectionString)
 {
     if (FileImageStore.IsFileStoreUri(imageStoreConnectionString))
     {
         return(ImageStoreProviderType.FileShare);
     }
     else if (XStoreProxy.IsXStoreUri(imageStoreConnectionString))
     {
         return(ImageStoreProviderType.AzureStorage);
     }
     else if (NativeImageStoreClient.IsNativeImageStoreUri(imageStoreConnectionString))
     {
         return(ImageStoreProviderType.ImageStoreService);
     }
     else
     {
         return(ImageStoreProviderType.Invalid);
     }
 }