Esempio n. 1
0
 public WabStorageAbstractionSimulator(WindowsAzureStorageAccountCredentials credentials)
 {
     this.credentials          = credentials;
     this.RootPath             = this.credentials.Name;
     this.ChosenProtocol       = Constants.WabsProtocol;
     this.ChosenProtocolScheme = Constants.WabsProtocolSchemeName;
     this.Root = new StorageSimulatorItem(this.Account, string.Empty);
 }
 public async Task CreateContainerIfNotExists(string fullAccount, string key, string container)
 {
     var storageAbstractionCreds = new WindowsAzureStorageAccountCredentials()
     {
         Key = key, Name = fullAccount
     };
     var storageAbstraction = ServiceLocator.Instance.Locate <IWabStorageAbstractionFactory>().Create(storageAbstractionCreds);
     await storageAbstraction.CreateContainerIfNotExists(container);
 }
        public IStorageAbstraction Create(WindowsAzureStorageAccountCredentials credentials)
        {
            WabStorageAbstractionSimulator simulator;

            if (!this.simulators.TryGetValue(credentials.Name, out simulator))
            {
                simulator = new WabStorageAbstractionSimulator(credentials);
                this.simulators.Add(credentials.Name, simulator);
            }
            return(simulator);
        }
        public void GivenIHaveTheStorageAbstraction(string account)
        {
            account = Constants.WabsProtocolSchemeName + account;
            var factory = ServiceLocator.Instance.Locate <IWabStorageAbstractionFactory>();
            // NOTE: when run against production we should pull the key out of the valid creds file.
            var creds = new WindowsAzureStorageAccountCredentials()
            {
                Name = account, Key = string.Empty
            };

            abstraction = factory.Create(creds);
        }
Esempio n. 5
0
        public void CanGetStorageAccountName_Production()
        {
            var storageCreds = new WindowsAzureStorageAccountCredentials()
            {
                Name = "demostorage"
            };

            var wabsStorageClient = new WabStorageAbstraction(storageCreds);

            Assert.AreEqual(wabsStorageClient.StorageAccountName, "demostorage");
            Assert.AreEqual(wabsStorageClient.StorageAccountRoot, "http://demostorage.blob.core.windows.net/");
        }
Esempio n. 6
0
        public void CanGetStorageAccountName_Internal()
        {
            var storageCreds = new WindowsAzureStorageAccountCredentials()
            {
                Name = Constants.WabsProtocolSchemeName + "demostorage.blob.core.windows-int.net"
            };

            var wabsStorageClient = new WabStorageAbstraction(storageCreds);

            Assert.AreEqual("demostorage", wabsStorageClient.StorageAccountName);
            Assert.AreEqual("http://demostorage.blob.core.windows-int.net", wabsStorageClient.StorageAccountRoot);
        }
Esempio n. 7
0
        public void CanConvertWabsPathToHttpPath()
        {
            var storageCreds = new WindowsAzureStorageAccountCredentials()
            {
                Name = "demostorage.blob.core.windows-int.net"
            };

            var asvPath  = Constants.WabsProtocolSchemeName + "[email protected]/path1/path2";
            var httpPath = WabStorageAbstraction.ConvertToHttpPath(new Uri(asvPath));

            Assert.AreEqual("http://demostorage.blob.core.windows-int.net/container/path1/path2", httpPath.AbsoluteUri);
        }
 private void WriteJobResultFile(string statusDirectory, string content, string fileName)
 {
     if (!string.IsNullOrEmpty(statusDirectory))
     {
         var storageCreds = new WindowsAzureStorageAccountCredentials()
         {
             Name = Constants.WabsProtocolSchemeName + this.cluster.Cluster.DefaultStorageAccount.Name,
             Key  = this.cluster.Cluster.DefaultStorageAccount.Key
         };
         var storageHandler = ServiceLocator.Instance.Locate <IWabStorageAbstractionFactory>().Create(storageCreds);
         storageHandler.Write(this.GetStatusPath(statusDirectory, fileName), this.GetStream(content));
     }
 }
Esempio n. 9
0
        private IStorageAbstraction GetStorageClient()
        {
            var details            = this.GetJobSubmissionClusterDetails();
            var storageCredentials = new WindowsAzureStorageAccountCredentials()
            {
                Name          = GetAsvRootDirectory(details.Cluster.DefaultStorageAccount.Name),
                Key           = details.Cluster.DefaultStorageAccount.Key,
                ContainerName = details.Cluster.DefaultStorageAccount.Name
            };

            var storageClient = ServiceLocator.Instance.Locate <IWabStorageAbstractionFactory>().Create(storageCredentials);

            return(storageClient);
        }
Esempio n. 10
0
        public async Task ICanPerformA_PositiveCreateContainer_WithNonExistantContainer()
        {
            var storageCreds = new WindowsAzureStorageAccountCredentials()
            {
                Key  = IntegrationTestBase.TestCredentials.Environments[0].DefaultStorageAccount.Key,
                Name = IntegrationTestBase.TestCredentials.Environments[0].DefaultStorageAccount.Name
            };

            var nonExistantContainer = Guid.NewGuid().ToString("N").ToLowerInvariant();
            var client = ServiceLocator.Instance.Locate <IAsvValidatorClientFactory>().Create();
            await client.CreateContainerIfNotExists(storageCreds.Name, storageCreds.Key, nonExistantContainer);

            var storageAbstraction = ServiceLocator.Instance.Locate <IWabStorageAbstractionFactory>().Create(storageCreds);
            var listContainerPath  = new Uri(Constants.WabsProtocolSchemeName + nonExistantContainer + "@" + storageCreds.Name);
            var containers         = await storageAbstraction.List(listContainerPath, false);

            var containerExists = containers.Any(path => path.UserInfo == nonExistantContainer);

            Assert.IsTrue(containerExists);
        }
Esempio n. 11
0
 public async Task CreateContainerIfNotExists(string fullAccount, string key, string container)
 {
     try
     {
         var storageAbstractionCreds = new WindowsAzureStorageAccountCredentials()
         {
             Key = key, Name = fullAccount
         };
         var storageAbstraction = ServiceLocator.Instance.Locate <IWabStorageAbstractionFactory>().Create(storageAbstractionCreds);
         await storageAbstraction.CreateContainerIfNotExists(container);
     }
     catch (Exception e)
     {
         throw new ConfigurationErrorsException(string.Format(CultureInfo.InvariantCulture,
                                                              "Validating container '{0}' (storage '{1}') failed. Inner exception:{2}",
                                                              container,
                                                              fullAccount,
                                                              e.Message),
                                                e);
     }
 }
Esempio n. 12
0
 public async Task ValidateAccount(string fullAccount, string key)
 {
     try
     {
         var storageAbstractionCreds = new WindowsAzureStorageAccountCredentials()
         {
             Key = key, Name = fullAccount
         };
         var storageAbstraction = ServiceLocator.Instance.Locate <IWabStorageAbstractionFactory>().Create(storageAbstractionCreds);
         var listContainersUri  = new Uri(string.Format("{0}://{1}/", Constants.WabsProtocol, fullAccount));
         await storageAbstraction.List(listContainersUri, false);
     }
     catch (Exception e)
     {
         throw new ConfigurationErrorsException(string.Format(CultureInfo.InvariantCulture,
                                                              "Validating connection to '{0}' failed. Inner exception:{1}",
                                                              fullAccount,
                                                              e.Message),
                                                e);
     }
 }
Esempio n. 13
0
        public static async Task ValidateAndResolveWasbScriptActionEndpointUri(Uri uri, WabStorageAccountConfiguration storage)
        {
            if (uri == null)
            {
                throw new ArgumentNullException("uri");
            }

            if (storage == null)
            {
                throw new ArgumentNullException("storage");
            }

            // Try to check the existence of the script in the URI specified.
            var storageAbstractionCreds = new WindowsAzureStorageAccountCredentials()
            {
                Key  = storage.Key,
                Name = GetFullyQualifiedStorageAccountName(storage.Name),
            };

            var storageAbstraction = new WabStorageAbstraction(storageAbstractionCreds);

            bool exists = false;

            try
            {
                // Firstly converts the URI to wasb style and then test it against wasb storage for existence.
                exists = await storageAbstraction.Exists(ConvertToWasbUriIfNeeded(uri));
            }
            catch (Exception e)
            {
                throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Script action URI: {0} cannot be retrieved correctly. Inner exception: {1}", uri.AbsoluteUri, e.Message), e);
            }

            if (!exists)
            {
                throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Script action URI: {0} cannot be retrieved correctly because it does not exist", uri.AbsoluteUri));
            }
        }
 public IStorageAbstraction Create(WindowsAzureStorageAccountCredentials credentials)
 {
     return new WabStorageAbstraction(credentials);
 }
 public WabStorageAbstraction(WindowsAzureStorageAccountCredentials credentials)
 {
     credentials.ArgumentNotNull("credentials");
     this.credentials = credentials;
 }
 public WabStorageAbstraction(WindowsAzureStorageAccountCredentials credentials)
 {
     credentials.ArgumentNotNull("credentials");
     this.credentials = credentials;
 }
Esempio n. 17
0
 public IStorageAbstraction Create(WindowsAzureStorageAccountCredentials credentials)
 {
     return(new WabStorageAbstraction(credentials));
 }