public void AzureReachabilityReportStateLevelAggregationTest()
        {
            var handler1 = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };
            var handler2 = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (MockContext context = MockContext.Start(this.GetType().FullName))
            {
                var resourcesClient         = ResourcesManagementTestUtilities.GetResourceManagementClientWithHandler(context, handler1);
                var networkManagementClient = NetworkManagementTestUtilities.GetNetworkManagementClientWithHandler(context, handler2);

                AzureReachabilityReportParameters parameters = new AzureReachabilityReportParameters();
                parameters.AzureLocations = new List <string>();
                parameters.AzureLocations.Add("West US");

                parameters.ProviderLocation         = new AzureReachabilityReportLocation();
                parameters.ProviderLocation.Country = "United States";
                parameters.ProviderLocation.State   = "washington";

                parameters.StartTime = DateTime.Now.AddDays(-10);
                parameters.EndTime   = DateTime.Now.AddDays(-5);

                var report = networkManagementClient.NetworkWatchers.GetAzureReachabilityReport("NetworkWatcherRG", "NetworkWatcher", parameters);

                //Validation
                Assert.Equal("State", report.AggregationLevel);
                Assert.Equal("United States", report.ProviderLocation.Country);
                Assert.Equal("washington", report.ProviderLocation.State);
                Assert.Equal("West US", report.ReachabilityReport[0].AzureLocation);
            }
        }
Exemplo n.º 2
0
        public async Task AzureReachabilityReportCountryLevelAggregationTest()
        {
            AzureReachabilityReportParameters parameters = new AzureReachabilityReportParameters(
                new AzureReachabilityReportLocation("United States"), Recording.UtcNow.AddDays(-10), Recording.UtcNow.AddDays(-5))
            {
                AzureLocations = { "West US" }
            };
            Operation <AzureReachabilityReport> reportOperation = await GetResourceGroup("NetworkWatcherRG").GetNetworkWatchers().Get("NetworkWatcher_westus").Value.GetAzureReachabilityReportAsync(WaitUntil.Completed, parameters);

            Response <AzureReachabilityReport> report = await reportOperation.WaitForCompletionAsync();;

            //Validation
            Assert.AreEqual("Country", report.Value.AggregationLevel);
            Assert.AreEqual("United States", report.Value.ProviderLocation.Country);
            Assert.AreEqual("West US", report.Value.ReachabilityReport[0].AzureLocation);
        }
Exemplo n.º 3
0
        public async Task AzureReachabilityReportCountryLevelAggregationTest()
        {
            AzureReachabilityReportParameters parameters = new AzureReachabilityReportParameters(
                new AzureReachabilityReportLocation("United States"), Recording.UtcNow.AddDays(-10), Recording.UtcNow.AddDays(-5))
            {
                AzureLocations = { "West US" }
            };
            Operation <AzureReachabilityReport> reportOperation = await NetworkManagementClient.NetworkWatchers.StartGetAzureReachabilityReportAsync("NetworkWatcherRG", "NetworkWatcher_westus", parameters);

            Response <AzureReachabilityReport> report = await WaitForCompletionAsync(reportOperation);

            //Validation
            Assert.AreEqual("Country", report.Value.AggregationLevel);
            Assert.AreEqual("United States", report.Value.ProviderLocation.Country);
            Assert.AreEqual("West US", report.Value.ReachabilityReport[0].AzureLocation);
        }
        public override void Execute()
        {
            base.Execute();

            // ProviderLocation
            PSAzureReachabilityReportLocation vProviderLocation = null;

            if (this.Country != null)
            {
                if (vProviderLocation == null)
                {
                    vProviderLocation = new PSAzureReachabilityReportLocation();
                }
                vProviderLocation.Country = this.Country;
            }

            if (this.State != null)
            {
                if (vProviderLocation == null)
                {
                    vProviderLocation = new PSAzureReachabilityReportLocation();
                }
                vProviderLocation.State = this.State;
            }

            if (this.City != null)
            {
                if (vProviderLocation == null)
                {
                    vProviderLocation = new PSAzureReachabilityReportLocation();
                }
                vProviderLocation.City = this.City;
            }

            var vAzureReachabilityReportParameters = new AzureReachabilityReportParameters
            {
                Providers        = this.Provider,
                AzureLocations   = this.Location,
                StartTime        = this.StartTime,
                EndTime          = this.EndTime,
                ProviderLocation = NetworkResourceManagerProfile.Mapper.Map <MNM.AzureReachabilityReportLocation>(vProviderLocation),
            };

            if (string.Equals(this.ParameterSetName, "SetByResource", StringComparison.OrdinalIgnoreCase))
            {
                ResourceGroupName  = this.NetworkWatcher.ResourceGroupName;
                NetworkWatcherName = this.NetworkWatcher.Name;
            }

            if (string.Equals(this.ParameterSetName, "SetByResourceId", StringComparison.OrdinalIgnoreCase))
            {
                var resourceInfo = new ResourceIdentifier(this.ResourceId);
                ResourceGroupName  = resourceInfo.ResourceGroupName;
                NetworkWatcherName = resourceInfo.ResourceName;
            }

            var vNetworkWatcherResult = this.NetworkClient.NetworkManagementClient.NetworkWatchers.GetAzureReachabilityReport(ResourceGroupName, NetworkWatcherName, vAzureReachabilityReportParameters);
            var vNetworkWatcherModel  = NetworkResourceManagerProfile.Mapper.Map <PSAzureReachabilityReport>(vNetworkWatcherResult);

            WriteObject(vNetworkWatcherModel);
        }
 /// <summary>
 /// Gets the relative latency score for internet service providers from a
 /// specified location to Azure regions.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the network watcher resource group.
 /// </param>
 /// <param name='networkWatcherName'>
 /// The name of the network watcher resource.
 /// </param>
 /// <param name='parameters'>
 /// Parameters that determine Azure reachability report configuration.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <AzureReachabilityReportInner> BeginGetAzureReachabilityReportAsync(this INetworkWatchersOperations operations, string resourceGroupName, string networkWatcherName, AzureReachabilityReportParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.BeginGetAzureReachabilityReportWithHttpMessagesAsync(resourceGroupName, networkWatcherName, parameters, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }