public void Undo() { if (oldRouteTable != null) { CreateRouteTableParameters createParameters = new CreateRouteTableParameters() { Name = oldRouteTable.Name, Label = oldRouteTable.Label, Location = oldRouteTable.Location, }; routeOperations.CreateRouteTable(createParameters); if (oldRouteTable.RouteList != null) { foreach (Route route in oldRouteTable.RouteList) { SetRouteParameters setParameters = new SetRouteParameters() { Name = route.Name, AddressPrefix = route.AddressPrefix, NextHop = route.NextHop, }; routeOperations.SetRoute(routeTableName, route.Name, setParameters); } } } }
public void PrepareAndAbortMigrationRouteTable() { using (NetworkTestClient networkTestClient = new NetworkTestClient()) { networkTestClient.Routes.EnsureRouteTableDoesntExist("MockName"); CreateRouteTableParameters parameters = CreateParameters("MockName", null, NetworkTestConstants.WideVNetLocation); AzureOperationResponse createResponse = networkTestClient.Routes.CreateRouteTable(parameters); Assert.NotNull(createResponse); Assert.NotNull(createResponse.RequestId); Assert.NotEqual(0, createResponse.RequestId.Length); Assert.Equal(HttpStatusCode.OK, createResponse.StatusCode); // Test Validate migration call var response = networkTestClient.ValidateRouteTableMigration("MockName"); Assert.NotNull(response); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.NotNull(response.ValidationMessages); Assert.Equal(0, response.ValidationMessages.Count); // Prepare OperationStatusResponse prepareVnetMigration = networkTestClient.PrepareRouteTableMigration("MockName"); Assert.Equal(OperationStatus.Succeeded, prepareVnetMigration.Status); // Abort OperationStatusResponse abortVnetMigration = networkTestClient.AbortRouteTableMigration("MockName"); Assert.Equal(OperationStatus.Succeeded, abortVnetMigration.Status); } }
public AzureOperationResponse CreateRouteTable(CreateRouteTableParameters parameters) { CreateRouteTable operation = new CreateRouteTable(routeOperations, parameters); testClient.InvokeTestOperation(operation); return(operation.InvokeResponse); }
public AzureOperationResponse CreateRouteTable(string routeTableName, string label, string location) { CreateRouteTableParameters parameters = new CreateRouteTableParameters() { Name = routeTableName, Label = label, Location = location, }; return(client.Routes.CreateRouteTable(parameters)); }
public void CreateRouteTableWhenLabelIsEmpty() { using (NetworkTestClient networkTestClient = new NetworkTestClient()) { networkTestClient.Routes.EnsureRouteTableDoesntExist("MockName"); CreateRouteTableParameters parameters = CreateParameters("MockName", "", NetworkTestConstants.WideVNetLocation); AzureOperationResponse createResponse = networkTestClient.Routes.CreateRouteTable(parameters); Assert.NotNull(createResponse); Assert.NotNull(createResponse.RequestId); Assert.NotEqual(0, createResponse.RequestId.Length); Assert.Equal(HttpStatusCode.OK, createResponse.StatusCode); } }
public CreateRouteTable(IRouteOperations routeOperations, CreateRouteTableParameters parameters) { this.routeOperations = routeOperations; this.parameters = parameters; if (parameters == null || string.IsNullOrEmpty(parameters.Name)) { tableExistedPreviously = false; } else { RouteTable routeTable = RouteTestClient.GetRouteTableSafe(routeOperations, parameters.Name); tableExistedPreviously = (routeTable != null); } }
public void CreateRouteTableWhenNameIsEmpty() { using (NetworkTestClient networkTestClient = new NetworkTestClient()) { CreateRouteTableParameters parameters = CreateParameters("", "MockLabel", NetworkTestConstants.WideVNetLocation); try { networkTestClient.Routes.CreateRouteTable(parameters); Assert.True(false, "CreateRouteTable should have thrown a CloudException when the table name value was empty."); } catch (Hyak.Common.CloudException e) { Assert.Equal("BadRequest", e.Error.Code); Assert.Equal("Route Table name is null or empty.", e.Error.Message); Assert.Equal("Bad Request", e.Response.ReasonPhrase); Assert.Equal(HttpStatusCode.BadRequest, e.Response.StatusCode); } } }
/// <summary> /// Create the specified route table for this subscription. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Network.IRouteOperations. /// </param> /// <param name='parameters'> /// Required. The parameters necessary to create a new route table. /// </param> /// <returns> /// The response body contains the status of the specified asynchronous /// operation, indicating whether it has succeeded, is inprogress, or /// has failed. Note that this status is distinct from the HTTP status /// code returned for the Get Operation Status operation itself. If /// the asynchronous operation succeeded, the response body includes /// the HTTP status code for the successful request. If the /// asynchronous operation failed, the response body includes the HTTP /// status code for the failed request, and also includes error /// information regarding the failure. /// </returns> public static Task <OperationStatusResponse> CreateRouteTableAsync(this IRouteOperations operations, CreateRouteTableParameters parameters) { return(operations.CreateRouteTableAsync(parameters, CancellationToken.None)); }
/// <summary> /// Create the specified route table for this subscription. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Network.IRouteOperations. /// </param> /// <param name='parameters'> /// Required. The parameters necessary to create a new route table. /// </param> /// <returns> /// The response body contains the status of the specified asynchronous /// operation, indicating whether it has succeeded, is inprogress, or /// has failed. Note that this status is distinct from the HTTP status /// code returned for the Get Operation Status operation itself. If /// the asynchronous operation succeeded, the response body includes /// the HTTP status code for the successful request. If the /// asynchronous operation failed, the response body includes the HTTP /// status code for the failed request, and also includes error /// information regarding the failure. /// </returns> public static OperationStatusResponse CreateRouteTable(this IRouteOperations operations, CreateRouteTableParameters parameters) { return(Task.Factory.StartNew((object s) => { return ((IRouteOperations)s).CreateRouteTableAsync(parameters); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
/// <summary> /// Create the specified route table for this subscription. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Network.IRouteOperations. /// </param> /// <param name='parameters'> /// Required. The parameters necessary to create a new route table. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public static Task <AzureOperationResponse> BeginCreateRouteTableAsync(this IRouteOperations operations, CreateRouteTableParameters parameters) { return(operations.BeginCreateRouteTableAsync(parameters, CancellationToken.None)); }
public void GetEffectiveRouteTableOnRoleSucceeds() { using (var undoContext = UndoContext.Current) { undoContext.Start(); using (NetworkTestBase _testFixture = new NetworkTestBase()) { // setup bool storageAccountCreated = false; bool hostedServiceCreated = false; string serviceName = _testFixture.GenerateRandomName(); string deploymentName = _testFixture.GenerateRandomName(); string roleName = "WebRole1"; string location = _testFixture.ManagementClient.GetDefaultLocation("Storage", "Compute", "PersistentVMRole"); string routeTableName = _testFixture.GenerateRandomName(); string routeName = "routename"; string vnetName = "virtualNetworkSiteName"; string subnetName = "FrontEndSubnet5"; string storageAccountName = _testFixture.GenerateRandomName().ToLower(); _testFixture.CreateStorageAccount(location, storageAccountName, out storageAccountCreated); _testFixture.SetSimpleVirtualNetwork(); _testFixture.CreateHostedService(location, serviceName, out hostedServiceCreated); CreateRouteTableParameters parameters = new CreateRouteTableParameters() { Name = routeTableName, Label = _testFixture.GenerateRandomName(), Location = location, }; AzureOperationResponse createResponse = _testFixture.NetworkClient.Routes.CreateRouteTable(parameters); var createRouteParameters = new SetRouteParameters() { Name = routeName, AddressPrefix = "0.0.0.0/0", NextHop = new NextHop() { IpAddress = "192.168.100.4", Type = "VirtualAppliance" }, }; _testFixture.NetworkClient.Routes.SetRoute(routeTableName, routeName, createRouteParameters); AddRouteTableToSubnetParameters addRouteTableToSubnetParameters = new AddRouteTableToSubnetParameters() { RouteTableName = routeTableName }; _testFixture.NetworkClient.Routes.AddRouteTableToSubnet(vnetName, subnetName, addRouteTableToSubnetParameters); var deployment = _testFixture.CreatePaaSDeployment( storageAccountName, serviceName, deploymentName, NetworkTestConstants.OneWebOneWorkerPkgFilePath, NetworkTestConstants.VnetOneWebOneWorkerCscfgFilePath); try { // action _testFixture.ComputeClient.Deployments.UpdateStatusByDeploymentName(serviceName, deploymentName, new DeploymentUpdateStatusParameters() { Status = UpdatedDeploymentStatus.Running }); RoleInstancePowerState roleStatus = RoleInstancePowerState.Unknown; Action getRole = () => { var vmStatus = _testFixture.ComputeClient.Deployments.GetByName(serviceName, deploymentName); roleStatus = vmStatus.RoleInstances.Single( r => string.Equals(r.RoleName, roleName, StringComparison.OrdinalIgnoreCase)) .PowerState; }; Func <bool> retryUntil = () => { return(roleStatus == RoleInstancePowerState.Started); }; TestUtilities.RetryActionWithTimeout( getRole, retryUntil, TimeSpan.FromMinutes(15), (code => { Thread.Sleep(5000); return(true); })); // assert var response = _testFixture.NetworkClient.Routes.GetEffectiveRouteTableForRoleInstance(serviceName, deploymentName, roleName + "_IN_0"); Assert.NotNull(response); Assert.NotNull(response.EffectiveRouteTable); Assert.NotEmpty(response.EffectiveRouteTable.EffectiveRoutes); var userDefinedRoute = response.EffectiveRouteTable.EffectiveRoutes.Single(r => r.Source == "User"); Assert.Equal(1, userDefinedRoute.AddressPrefixes.Count); Assert.Equal(createRouteParameters.AddressPrefix, userDefinedRoute.AddressPrefixes[0]); Assert.Equal(createRouteParameters.Name, userDefinedRoute.Name); Assert.Equal(createRouteParameters.NextHop.Type, userDefinedRoute.EffectiveNextHop.Type); Assert.Equal(1, userDefinedRoute.EffectiveNextHop.IpAddresses.Count); Assert.Equal(createRouteParameters.NextHop.IpAddress, userDefinedRoute.EffectiveNextHop.IpAddresses[0]); Assert.Equal("Active", userDefinedRoute.Status); } finally { _testFixture.NetworkClient.Routes.BeginRemoveRouteTableFromSubnet(vnetName, subnetName); if (storageAccountCreated) { _testFixture.StorageClient.StorageAccounts.Delete(storageAccountName); } if (hostedServiceCreated) { _testFixture.ComputeClient.HostedServices.DeleteAll(serviceName); } } } } }