/// <summary>
        ///     Create stirage service
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public StorageAccount CreateStorageService(StorageAccountCreateParameters input)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }
            // storage services must use lowercase names
            input.Name = input.Name.ToLowerInvariant(); 

            var existing = GetStorageService(input.Name);
            if(existing != null)
            {
                return existing;
            }

            var affinityGroupManager = new AzureAffinityGroupManager();
            affinityGroupManager.EnsureAffinityGroupExists(input.AffinityGroup);

            TestEasyLog.Instance.Info(string.Format("Creating storage service '{0}'", input.Name));

            StorageManagementClient.StorageAccounts.CreateAsync(input, new CancellationToken()).Wait();

            existing = GetStorageService(input.Name);

            if (string.Compare(existing.Name, AzureServiceConstants.DefaultStorageServiceName,
                   StringComparison.InvariantCultureIgnoreCase) != 0) // never remember default storage service to avoid deletion
            {
                Dependencies.TestResourcesCollector.Remember(AzureResourceType.StorageService, existing.Name, existing.Name);
            }

            return existing;
        }
        /// <summary>
        ///     Create stirage service
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public StorageAccount CreateStorageService(StorageAccountCreateParameters input)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }
            // storage services must use lowercase names
            input.Name = input.Name.ToLowerInvariant();

            var existing = GetStorageService(input.Name);

            if (existing != null)
            {
                return(existing);
            }

            var affinityGroupManager = new AzureAffinityGroupManager();

            affinityGroupManager.EnsureAffinityGroupExists(input.AffinityGroup);

            TestEasyLog.Instance.Info(string.Format("Creating storage service '{0}'", input.Name));

            StorageManagementClient.StorageAccounts.CreateAsync(input, new CancellationToken()).Wait();

            existing = GetStorageService(input.Name);

            if (string.Compare(existing.Name, AzureServiceConstants.DefaultStorageServiceName,
                               StringComparison.InvariantCultureIgnoreCase) != 0) // never remember default storage service to avoid deletion
            {
                Dependencies.TestResourcesCollector.Remember(AzureResourceType.StorageService, existing.Name, existing.Name);
            }

            return(existing);
        }
        /// <summary>
        ///     Create hosted service
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public string CreateHostedService(HostedServiceCreateParameters input)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            if (HostedServiceExists(input.ServiceName)) return input.ServiceName;

            var affinityGroupManager = new AzureAffinityGroupManager();
            affinityGroupManager.EnsureAffinityGroupExists(input.AffinityGroup);

            ComputeManagementClient.HostedServices.CreateAsync(input, new CancellationToken()).Wait();

            Dependencies.TestResourcesCollector.Remember(AzureResourceType.HostedService, input.ServiceName, input.ServiceName);

            return input.ServiceName;
        }
예제 #4
0
        private void CleanupAffinityGroups(AzureResourceType type, Dictionary <string, object> resources)
        {
            SafeExecute(() =>
            {
                var manager = new AzureAffinityGroupManager();
                foreach (var obj in resources.Values)
                {
                    var group = obj as string;
                    if (group == null)
                    {
                        throw new Exception(string.Format("Incorrect resource was stored in '{0}' collection", type));
                    }

                    if (manager.GetAffinityGroup(group) != null)
                    {
                        manager.DeleteAffinityGroup(group);
                    }
                }

                resources.Clear();
            }, type.ToString());
        }
예제 #5
0
        /// <summary>
        ///     Create hosted service
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public string CreateHostedService(HostedServiceCreateParameters input)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            if (HostedServiceExists(input.ServiceName))
            {
                return(input.ServiceName);
            }

            var affinityGroupManager = new AzureAffinityGroupManager();

            affinityGroupManager.EnsureAffinityGroupExists(input.AffinityGroup);

            ComputeManagementClient.HostedServices.CreateAsync(input, new CancellationToken()).Wait();

            Dependencies.TestResourcesCollector.Remember(AzureResourceType.HostedService, input.ServiceName, input.ServiceName);

            return(input.ServiceName);
        }
예제 #6
0
        private void CleanupAffinityGroups(AzureResourceType type, Dictionary<string, object> resources)
        {
            SafeExecute(() =>
                {
                    var manager = new AzureAffinityGroupManager();
                    foreach (var obj in resources.Values)
                    {
                        var group = obj as string;
                        if (group == null)
                        {
                            throw new Exception(string.Format("Incorrect resource was stored in '{0}' collection", type));
                        }

                        if(manager.GetAffinityGroup(group) != null)
                        {
                            manager.DeleteAffinityGroup(group);
                        }
                    }

                    resources.Clear();
                }, type.ToString());
        }