示例#1
0
        public AzureHDInsightCapabilities(CapabilitiesResult capabilitiesResult, BillingResponseListResult billingResponseListResult)
        {
            this.Versions = capabilitiesResult?.Versions?.ToDictionary(item => item.Key, item => new AzureHDInsightVersionsCapability(item.Value));

            this.Regions = capabilitiesResult?.Regions?.ToDictionary(item => item.Key, item => new AzureHDInsightRegionsCapability(item.Value));

            this.VmSizes = billingResponseListResult?.VmSizes;

            this.VmSizeFilters = billingResponseListResult?.VmSizeFilters?.Select(val => new AzureHDInsightVmSizeCompatibilityFilter(val)).ToList();

            this.Features = capabilitiesResult?.Features;

            this.Quota = new AzureHDInsightQuotaCapability(capabilitiesResult?.Quota);
        }
        public void CanGetProperties()
        {
            var features = new string[] { "feature1", "feature2" };
            var versions = new Dictionary <string, VersionsCapability> {
                { "key", new VersionsCapability() }
            };
            var regions = new Dictionary <string, RegionsCapability> {
                { "eastus", new RegionsCapability() }
            };
            var capabilitiesResult = new CapabilitiesResult
            {
                Features = features,
                Versions = versions,
                Regions  = regions
            };

            var billingResponseResult = new BillingResponseListResult()
            {
                VmSizes       = new List <string>(),
                VmSizeFilters = new List <VmSizeCompatibilityFilterV2>()
            };

            var propertiesResponse = new AzureHDInsightCapabilities(capabilitiesResult, billingResponseResult);

            hdinsightManagementMock.Setup(c => c.GetProperties(Location))
            .Returns(capabilitiesResult)
            .Verifiable();

            cmdlet.ExecuteCmdlet();

            commandRuntimeMock.VerifyAll();
            commandRuntimeMock.Verify(
                f =>
                f.WriteObject(
                    It.Is <AzureHDInsightCapabilities>(
                        resp =>
                        resp.Features == propertiesResponse.Features &&
                        resp.Regions["eastus"].Available == propertiesResponse.Regions["eastus"].Available &&
                        resp.Versions.Count == propertiesResponse.Versions.Count), true),
                Times.Once);
        }
示例#3
0
        protected Dictionary <string, Dictionary <string, string> > GetDefaultVmsizesConfigurations(string location)
        {
            Dictionary <string, Dictionary <string, string> > nodeTypeAndClusterTypeAndVmSizeDict = null;

            try
            {
                BillingResponseListResult billingResponseListResult = HDInsightManagementClient.ListBillingSpecs(location);

                /* The result is KeyValuePair<ZOOKEEPERNODEROLE, KeyValulePair<SPARK, STANDARD_A2_V2>> */
                var nodeTypeAndClusterTypeAndVmSizePairs = billingResponseListResult.VmSizeFilters.Where(filter => filter.FilterMode.Equals(FilterMode.Default)).SelectMany(x =>
                {
                    var clusterTypeAndVmSizePairs = x.ClusterFlavors.SelectMany(clusterType => x.VmSizes, (clusterType, vmSize) =>
                    {
                        return(new KeyValuePair <string, string>(clusterType.ToUpper(), vmSize));
                    });

                    var result = x.NodeTypes.SelectMany(nodeType => clusterTypeAndVmSizePairs, (nodeType, clusterTypeAndVmSizePair) => { return(new KeyValuePair <string, KeyValuePair <string, string> >(nodeType.ToUpper(), clusterTypeAndVmSizePair)); });
                    return(result);
                });

                nodeTypeAndClusterTypeAndVmSizeDict = new Dictionary <string, Dictionary <string, string> >(StringComparer.OrdinalIgnoreCase);
                foreach (var pair in nodeTypeAndClusterTypeAndVmSizePairs)
                {
                    if (!nodeTypeAndClusterTypeAndVmSizeDict.TryGetValue(pair.Key, out var tempDict))
                    {
                        nodeTypeAndClusterTypeAndVmSizeDict[pair.Key] = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
                        nodeTypeAndClusterTypeAndVmSizeDict[pair.Key].Add(pair.Value.Key, pair.Value.Value);
                    }
                    else
                    {
                        nodeTypeAndClusterTypeAndVmSizeDict[pair.Key].Add(pair.Value.Key, pair.Value.Value);
                    }
                }
            }
            catch (Exception)
            {
                return(null);
            }
            return(nodeTypeAndClusterTypeAndVmSizeDict);
        }