Skip to content

Commit

Permalink
[Network] Fix HopLink format error issue when resourceId return "" (A…
Browse files Browse the repository at this point in the history
  • Loading branch information
dvbb authored and matthohn-msft committed Oct 27, 2023
1 parent 86ccfa0 commit 3345ebf
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 82 deletions.
3 changes: 2 additions & 1 deletion sdk/network/Azure.ResourceManager.Network/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@

### Bugs Fixed

- Fix an issue that the `DeserializeHopLink` can't handle empty `resourceId`.

### Other Changes

## 1.6.0-beta.1 (2023-09-25)

### Features Added

- Add support to VMSS features.

## 1.5.0 (2023-09-16)
Expand Down
2 changes: 1 addition & 1 deletion sdk/network/Azure.ResourceManager.Network/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "net",
"TagPrefix": "net/network/Azure.ResourceManager.Network",
"Tag": "net/network/Azure.ResourceManager.Network_e310e8910d"
"Tag": "net/network/Azure.ResourceManager.Network_8a3f0c72db"
}
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,4 @@ public static SubnetData SubnetData(ResourceIdentifier id, string name, Resource
public static VirtualNetworkGatewayData VirtualNetworkGatewayData(ResourceIdentifier id, string name, ResourceType? resourceType, AzureLocation? location, IDictionary<string, string> tags, ExtendedLocation extendedLocation, ETag? etag, IEnumerable<VirtualNetworkGatewayIPConfiguration> ipConfigurations, VirtualNetworkGatewayType? gatewayType, VpnType? vpnType, VpnGatewayGeneration? vpnGatewayGeneration, bool? enableBgp, bool? enablePrivateIPAddress, bool? active, bool? disableIPSecReplayProtection, ResourceIdentifier gatewayDefaultSiteId, VirtualNetworkGatewaySku sku, VpnClientConfiguration vpnClientConfiguration, IEnumerable<VirtualNetworkGatewayPolicyGroup> virtualNetworkGatewayPolicyGroups, BgpSettings bgpSettings, IEnumerable<string> customRoutesAddressPrefixes, Guid? resourceGuid, NetworkProvisioningState? provisioningState, bool? enableDnsForwarding, string inboundDnsForwardingEndpoint, ResourceIdentifier vNetExtendedLocationResourceId, IEnumerable<VirtualNetworkGatewayNatRuleData> natRules, bool? enableBgpRouteTranslationForNat, bool? allowVirtualWanTraffic, bool? allowRemoteVnetTraffic, ExpressRouteGatewayAdminState? adminState)
=> VirtualNetworkGatewayData(id, name, resourceType, location, tags, extendedLocation, etag, null, ipConfigurations, gatewayType, vpnType, vpnGatewayGeneration, enableBgp, enablePrivateIPAddress, active, disableIPSecReplayProtection, gatewayDefaultSiteId, sku, vpnClientConfiguration, virtualNetworkGatewayPolicyGroups, bgpSettings, customRoutesAddressPrefixes, resourceGuid, provisioningState, enableDnsForwarding, inboundDnsForwardingEndpoint, vNetExtendedLocationResourceId, natRules, enableBgpRouteTranslationForNat, allowVirtualWanTraffic, allowRemoteVnetTraffic, adminState);
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions sdk/network/Azure.ResourceManager.Network/src/autorest.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ public-clients: false
head-as-boolean: false
resource-model-requires-type: false

# csharpgen:
# attach: true
#mgmt-debug:
# show-serialized-names: true

Expand Down Expand Up @@ -197,6 +195,9 @@ rename-mapping:
keep-plural-resource-data:
- PolicySignaturesOverridesForIdps

models-to-treat-empty-string-as-null:
- HopLink

format-by-name-rules:
'tenantId': 'uuid'
'ETag': 'etag'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected async Task<ResourceGroupResource> CreateResourceGroup(string name)
SubscriptionResource subscription = await ArmClient.GetDefaultSubscriptionAsync();
return (await subscription.GetResourceGroups().CreateOrUpdateAsync(WaitUntil.Completed, name, new ResourceGroupData(TestEnvironment.Location))).Value;
}
protected async Task<ResourceGroupResource> CreateResourceGroup(string name,string location)
protected async Task<ResourceGroupResource> CreateResourceGroup(string name, string location)
{
SubscriptionResource subscription = await ArmClient.GetDefaultSubscriptionAsync();
return (await subscription.GetResourceGroups().CreateOrUpdateAsync(WaitUntil.Completed, name, new ResourceGroupData(location))).Value;
Expand Down Expand Up @@ -261,7 +261,7 @@ public async Task<GenericResource> CreateWindowsVM(string vmName, string network

var vmId = new ResourceIdentifier($"{resourceGroup.Id}/providers/Microsoft.Compute/virtualMachines/{vmName}");
SubscriptionResource subscription = await ArmClient.GetDefaultSubscriptionAsync();
var genericResouces = subscription.GetGenericResources();
var genericResouces = subscription.GetGenericResourcesAsync();
GenericResourceData data = new GenericResourceData(location)
{
Properties = BinaryData.FromObjectAsJson(new Dictionary<string, object>
Expand Down Expand Up @@ -299,7 +299,7 @@ public async Task<GenericResource> CreateWindowsVM(string vmName, string network
{ "osProfile", new Dictionary<string, object>
{
{ "adminUsername", Recording.GenerateAssetName("admin") },
{ "adminPassword", Recording.GenerateAlphaNumericId("adminPass") },
{ "adminPassword", Recording.GenerateAlphaNumericId("adminPass!") },
{ "computerName", vmName }
}
},
Expand Down Expand Up @@ -631,7 +631,7 @@ public async Task<NetworkInterfaceResource> CreateNetworkInterface(string name,
return getNicResponse;
}

public async Task<NetworkInterfaceResource> CreateNetworkInterface(string name, string publicIpAddressId, string subnetId,
public async Task<NetworkInterfaceResource> CreateNetworkInterface(string name, string publicIpAddressId, string subnetId,
string location, string ipConfigName, NetworkInterfaceCollection networkInterfaceCollection)
{
var nicParameters = new NetworkInterfaceData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Azure.ResourceManager.Network.Models;
using Azure.ResourceManager.Network.Tests.Helpers;
using NUnit.Framework;
using Azure.Core;

namespace Azure.ResourceManager.Network.Tests
{
Expand Down Expand Up @@ -111,5 +112,35 @@ public async Task NetworkWatcherApiTest()
Assert.AreEqual(countBeforeTest, listAllAfterDeletingResponse.Count);
Assert.False(listAllAfterDeletingResponse.Any(w => w.Data.Name == networkWatcherName));
}

[Test]
[RecordedTest]
public async Task NetworkWatcherCheckConnectivityTest()
{
var location = AzureLocation.EastUS2;

string rgName = Recording.GenerateAssetName("networkRG");
var resourceGroup = await CreateResourceGroup(rgName, location);

// Create Network Watcher in the resource group
string networkWatcherName = Recording.GenerateAssetName("azsmnet");
var properties = new NetworkWatcherData { Location = location };
var networkWatcherLro = await resourceGroup.GetNetworkWatchers().CreateOrUpdateAsync(WaitUntil.Completed, networkWatcherName, properties);
NetworkWatcherResource networkWatcher = networkWatcherLro.Value;

// Create two VMs for test vm connectivity
var vm1 = await CreateWindowsVM(Recording.GenerateAssetName("vm"), Recording.GenerateAssetName("nic"), location, resourceGroup);
var vm2 = await CreateWindowsVM(Recording.GenerateAssetName("vm"), Recording.GenerateAssetName("nic"), location, resourceGroup);
await deployWindowsNetworkAgent(vm1.Data.Name, location, resourceGroup);
await deployWindowsNetworkAgent(vm2.Data.Name, location, resourceGroup);

// Test connectivity
ConnectivityContent content = new ConnectivityContent(
new ConnectivitySource(vm1.Id),
new ConnectivityDestination() { Port = 22, ResourceId = vm2.Id });
var connectivityResult = await networkWatcher.CheckConnectivityAsync(WaitUntil.Completed, content);
Assert.IsNotNull(connectivityResult.Value.NetworkConnectionStatus);
Assert.IsNull(connectivityResult.Value.Hops.First().Links.First().ResourceId);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
### Features Added

- Upgraded api-version tag from 'package-2023-04' to 'package-2023-06'. Tag detail available at https://github.com/Azure/azure-rest-api-specs/blob/5dd1107d5f2be8d600325d795450e1d854fbe7e8/specification/recoveryservicessiterecovery/resource-manager/readme.md
- Changes Related to Integration of In place OS upgrade.
- Changes Related to Integration of In place OS upgrade [Upgrade Windows Guideline](https://learn.microsoft.com/azure/migrate/how-to-upgrade-windows).
- Changes Releated to Implementing Monitoring Flow.

### Other Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,77 +17,6 @@ namespace Azure.ResourceManager.RecoveryServicesSiteRecovery.Models
/// <summary> Model factory for models. </summary>
public static partial class ArmRecoveryServicesSiteRecoveryModelFactory
{
/// <summary> Initializes a new instance of SiteRecoveryMigrationItemProperties. </summary>
/// <param name="machineName"> The on-premise virtual machine name. </param>
/// <param name="policyId"> The ARM Id of policy governing this item. </param>
/// <param name="policyFriendlyName"> The name of policy governing this item. </param>
/// <param name="recoveryServicesProviderId"> The recovery services provider ARM Id. </param>
/// <param name="replicationStatus"> The replication status. </param>
/// <param name="migrationState"> The migration status. </param>
/// <param name="migrationStateDescription"> The migration state description. </param>
/// <param name="lastTestMigrationOn"> The last test migration time. </param>
/// <param name="lastTestMigrationStatus"> The status of the last test migration. </param>
/// <param name="lastMigrationOn"> The last migration time. </param>
/// <param name="lastMigrationStatus"> The status of the last migration. </param>
/// <param name="testMigrateState"> The test migrate state. </param>
/// <param name="testMigrateStateDescription"> The test migrate state description. </param>
/// <param name="health"> The consolidated health. </param>
/// <param name="healthErrors"> The list of health errors. </param>
/// <param name="allowedOperations"> The allowed operations on the migration item based on the current migration state of the item. </param>
/// <param name="currentJob"> The current job details. </param>
/// <param name="criticalJobHistory"> The critical past job details. </param>
/// <param name="eventCorrelationId"> The correlation Id for events associated with this migration item. </param>
/// <param name="providerSpecificDetails"> The migration provider custom settings. </param>
/// <returns> A new <see cref="Models.SiteRecoveryMigrationItemProperties"/> instance for mocking. </returns>
public static SiteRecoveryMigrationItemProperties SiteRecoveryMigrationItemProperties(string machineName = null, ResourceIdentifier policyId = null, string policyFriendlyName = null, string recoveryServicesProviderId = null, string replicationStatus = null, SiteRecoveryMigrationState? migrationState = null, string migrationStateDescription = null, DateTimeOffset? lastTestMigrationOn = null, string lastTestMigrationStatus = null, DateTimeOffset? lastMigrationOn = null, string lastMigrationStatus = null, TestMigrationState? testMigrateState = null, string testMigrateStateDescription = null, SiteRecoveryProtectionHealth? health = null, IEnumerable<SiteRecoveryHealthError> healthErrors = null, IEnumerable<MigrationItemOperation> allowedOperations = null, CurrentJobDetails currentJob = null, IEnumerable<CriticalJobHistoryDetails> criticalJobHistory = null, string eventCorrelationId = null, MigrationProviderSpecificSettings providerSpecificDetails = null)
{
healthErrors ??= new List<SiteRecoveryHealthError>();
allowedOperations ??= new List<MigrationItemOperation>();
criticalJobHistory ??= new List<CriticalJobHistoryDetails>();

return new SiteRecoveryMigrationItemProperties(machineName, policyId, policyFriendlyName, recoveryServicesProviderId, replicationStatus, migrationState, migrationStateDescription, lastTestMigrationOn, lastTestMigrationStatus, lastMigrationOn, lastMigrationStatus, testMigrateState, testMigrateStateDescription, health, healthErrors?.ToList(), allowedOperations?.ToList(), currentJob, criticalJobHistory?.ToList(), eventCorrelationId, providerSpecificDetails);
}

/// <summary> Initializes a new instance of ReplicationProtectedItemProperties. </summary>
/// <param name="friendlyName"> The name. </param>
/// <param name="protectedItemType"> The type of protected item type. </param>
/// <param name="protectableItemId"> The protected item ARM Id. </param>
/// <param name="recoveryServicesProviderId"> The recovery provider ARM Id. </param>
/// <param name="primaryFabricFriendlyName"> The friendly name of the primary fabric. </param>
/// <param name="primaryFabricProvider"> The fabric provider of the primary fabric. </param>
/// <param name="recoveryFabricFriendlyName"> The friendly name of recovery fabric. </param>
/// <param name="recoveryFabricId"> The Arm Id of recovery fabric. </param>
/// <param name="primaryProtectionContainerFriendlyName"> The name of primary protection container friendly name. </param>
/// <param name="recoveryProtectionContainerFriendlyName"> The name of recovery container friendly name. </param>
/// <param name="protectionState"> The protection status. </param>
/// <param name="protectionStateDescription"> The protection state description. </param>
/// <param name="activeLocation"> The Current active location of the PE. </param>
/// <param name="testFailoverState"> The Test failover state. </param>
/// <param name="testFailoverStateDescription"> The Test failover state description. </param>
/// <param name="switchProviderState"> The switch provider state. </param>
/// <param name="switchProviderStateDescription"> The switch provider state description. </param>
/// <param name="allowedOperations"> The allowed operations on the Replication protected item. </param>
/// <param name="replicationHealth"> The consolidated protection health for the VM taking any issues with SRS as well as all the replication units associated with the VM's replication group into account. This is a string representation of the ProtectionHealth enumeration. </param>
/// <param name="failoverHealth"> The consolidated failover health for the VM. </param>
/// <param name="healthErrors"> List of health errors. </param>
/// <param name="policyId"> The ID of Policy governing this PE. </param>
/// <param name="policyFriendlyName"> The name of Policy governing this PE. </param>
/// <param name="lastSuccessfulFailoverOn"> The Last successful failover time. </param>
/// <param name="lastSuccessfulTestFailoverOn"> The Last successful test failover time. </param>
/// <param name="currentScenario"> The current scenario. </param>
/// <param name="failoverRecoveryPointId"> The recovery point ARM Id to which the Vm was failed over. </param>
/// <param name="providerSpecificDetails"> The Replication provider custom settings. </param>
/// <param name="recoveryContainerId"> The recovery container Id. </param>
/// <param name="eventCorrelationId"> The correlation Id for events associated with this protected item. </param>
/// <returns> A new <see cref="Models.ReplicationProtectedItemProperties"/> instance for mocking. </returns>
public static ReplicationProtectedItemProperties ReplicationProtectedItemProperties(string friendlyName = null, string protectedItemType = null, ResourceIdentifier protectableItemId = null, string recoveryServicesProviderId = null, string primaryFabricFriendlyName = null, string primaryFabricProvider = null, string recoveryFabricFriendlyName = null, ResourceIdentifier recoveryFabricId = null, string primaryProtectionContainerFriendlyName = null, string recoveryProtectionContainerFriendlyName = null, string protectionState = null, string protectionStateDescription = null, string activeLocation = null, string testFailoverState = null, string testFailoverStateDescription = null, string switchProviderState = null, string switchProviderStateDescription = null, IEnumerable<string> allowedOperations = null, string replicationHealth = null, string failoverHealth = null, IEnumerable<SiteRecoveryHealthError> healthErrors = null, ResourceIdentifier policyId = null, string policyFriendlyName = null, DateTimeOffset? lastSuccessfulFailoverOn = null, DateTimeOffset? lastSuccessfulTestFailoverOn = null, CurrentScenarioDetails currentScenario = null, ResourceIdentifier failoverRecoveryPointId = null, ReplicationProviderSpecificSettings providerSpecificDetails = null, ResourceIdentifier recoveryContainerId = null, Guid? eventCorrelationId = null)
{
allowedOperations ??= new List<string>();
healthErrors ??= new List<SiteRecoveryHealthError>();

return new ReplicationProtectedItemProperties(friendlyName, protectedItemType, protectableItemId, recoveryServicesProviderId, primaryFabricFriendlyName, primaryFabricProvider, recoveryFabricFriendlyName, recoveryFabricId, primaryProtectionContainerFriendlyName, recoveryProtectionContainerFriendlyName, protectionState, protectionStateDescription, activeLocation, testFailoverState, testFailoverStateDescription, switchProviderState, switchProviderStateDescription, allowedOperations?.ToList(), replicationHealth, failoverHealth, healthErrors?.ToList(), policyId, policyFriendlyName, lastSuccessfulFailoverOn, lastSuccessfulTestFailoverOn, currentScenario, failoverRecoveryPointId, providerSpecificDetails, recoveryContainerId, eventCorrelationId);
}

/// <summary> Initializes a new instance of A2AReplicationDetails. </summary>
/// <param name="fabricObjectId"> The fabric specific object Id of the virtual machine. </param>
/// <param name="initialPrimaryZone"> The initial primary availability zone. </param>
Expand Down
Loading

0 comments on commit 3345ebf

Please sign in to comment.