Пример #1
0
        public void ICanResolveStagingStorageAccountsWithFQDN()
        {
            var internalAccountName  = "storageaccountaname.blob.core.windows-cint.net";
            var resolvedAcccountName = AsvValidationHelper.GetFullyQualifiedStorageAccountName(internalAccountName);

            Assert.AreEqual(internalAccountName, resolvedAcccountName);
        }
        /// <summary>
        /// Creates the container.
        /// </summary>
        /// <param name="clusterCreateParameters">The cluster create parameters.</param>
        /// <returns>A task.</returns>
        public async Task CreateContainer(HDInsight.ClusterCreateParameters clusterCreateParameters)
        {
            if (clusterCreateParameters == null)
            {
                throw new ArgumentNullException("clusterCreateParameters");
            }

            if (string.IsNullOrEmpty(clusterCreateParameters.Name))
            {
                throw new ArgumentException("ClusterCreateParameters.Name cannot be null or empty", "clusterCreateParameters");
            }

            if (string.IsNullOrEmpty(clusterCreateParameters.Location))
            {
                throw new ArgumentException("ClusterCreateParameters.Location cannot be null or empty", "clusterCreateParameters");
            }

            if (clusterCreateParameters.ClusterSizeInNodes < 1)
            {
                throw new ArgumentException("clusterCreateParameters.ClusterSizeInNodes must be > 0");
            }
            try
            {
                //Validate
                AsvValidationHelper.ValidateAndResolveAsvAccountsAndPrep(clusterCreateParameters);

                // Validates config action component.
                if (clusterCreateParameters.ConfigActions != null && clusterCreateParameters.ConfigActions.Count > 0)
                {
                    this.LogMessage("Validating parameters for config actions.", Severity.Informational, Verbosity.Detailed);

                    if (!ClustersPocoClient.HasClusterConfigActionCapability(this.capabilities) ||
                        !ClustersPocoClient.HasCorrectSchemaVersionForConfigAction(this.capabilities))
                    {
                        throw new NotSupportedException("Your subscription does not support config actions.");
                    }

                    this.LogMessage("Validating URIs for config actions.", Severity.Informational, Verbosity.Detailed);

                    // Validates that the config actions' Uris are downloadable.
                    UriEndpointValidator.ValidateAndResolveConfigActionEndpointUris(clusterCreateParameters);
                }

                var rdfeCapabilitiesClient =
                    ServiceLocator.Instance.Locate <IRdfeServiceRestClientFactory>().Create(this.credentials, this.Context, this.ignoreSslErrors);
                var capabilities = await rdfeCapabilitiesClient.GetResourceProviderProperties();

                // Validates the region for the cluster creation
                var locationClient     = ServiceLocator.Instance.Locate <ILocationFinderClientFactory>().Create(this.credentials, this.Context, this.ignoreSslErrors);
                var availableLocations = locationClient.ListAvailableLocations(capabilities);
                if (!availableLocations.Contains(clusterCreateParameters.Location, StringComparer.OrdinalIgnoreCase))
                {
                    throw new InvalidOperationException(string.Format(
                                                            "Cannot create a cluster in '{0}'. Available Locations for your subscription are: {1}",
                                                            clusterCreateParameters.Location,
                                                            string.Join(",", availableLocations)));
                }

                await this.RegisterSubscriptionIfExistsAsync();

                await this.CreateCloudServiceAsyncIfNotExists(clusterCreateParameters.Location);

                var wireCreateParameters           = PayloadConverterClusters.CreateWireClusterCreateParametersFromUserType(clusterCreateParameters);
                var rdfeResourceInputFromWireInput = PayloadConverterClusters.CreateRdfeResourceInputFromWireInput(wireCreateParameters, GetSchemaVersion(this.capabilities));

                await
                this.rdfeClustersRestClient.CreateCluster(
                    this.credentials.SubscriptionId.ToString(),
                    this.GetCloudServiceName(clusterCreateParameters.Location),
                    this.credentials.DeploymentNamespace,
                    clusterCreateParameters.Name,
                    rdfeResourceInputFromWireInput,
                    this.Context.CancellationToken);
            }
            catch (InvalidExpectedStatusCodeException iEx)
            {
                string content = iEx.Response.Content != null?iEx.Response.Content.ReadAsStringAsync().Result : string.Empty;

                throw new HttpLayerException(iEx.ReceivedStatusCode, content);
            }
        }
Пример #3
0
        public void ICanResolveProductionStorageAccountsWithName()
        {
            var resolvedAcccountName = AsvValidationHelper.GetFullyQualifiedStorageAccountName("storageaccountaname");

            Assert.AreEqual("storageaccountaname.blob.core.windows.net", resolvedAcccountName);
        }