public virtual Response <DedicatedHostGroup> Update(DedicatedHostGroupUpdate parameters, CancellationToken cancellationToken = default) { if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _dedicatedHostGroupClientDiagnostics.CreateScope("DedicatedHostGroup.Update"); scope.Start(); try { var response = _dedicatedHostGroupRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, parameters, cancellationToken); return(Response.FromValue(new DedicatedHostGroup(ArmClient, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <Response <DedicatedHostGroup> > UpdateAsync(DedicatedHostGroupUpdate parameters, CancellationToken cancellationToken = default) { if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _clientDiagnostics.CreateScope("DedicatedHostGroup.Update"); scope.Start(); try { var response = await _dedicatedHostGroupsRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, parameters, cancellationToken).ConfigureAwait(false); return(Response.FromValue(new DedicatedHostGroup(this, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public void TestDedicatedHostOperations() { string originalTestLocation = Environment.GetEnvironmentVariable("AZURE_VM_TEST_LOCATION"); using (MockContext context = MockContext.Start(this.GetType())) { Environment.SetEnvironmentVariable("AZURE_VM_TEST_LOCATION", "eastus2"); EnsureClientsInitialized(context); string baseRGName = ComputeManagementTestUtilities.GenerateName(TestPrefix); string rgName = baseRGName + "DH"; string dhgName = "DHG-1"; string dhName = "DH-1"; try { // Create a dedicated host group, then get the dedicated host group and validate that they match DedicatedHostGroup createdDHG = CreateDedicatedHostGroup(rgName, dhgName); DedicatedHostGroup returnedDHG = m_CrpClient.DedicatedHostGroups.Get(rgName, dhgName); ValidateDedicatedHostGroup(createdDHG, returnedDHG); // Update existing dedicated host group DedicatedHostGroupUpdate updateDHGInput = new DedicatedHostGroupUpdate() { Tags = new Dictionary <string, string>() { { "testKey", "testValue" } } }; createdDHG.Tags = updateDHGInput.Tags; updateDHGInput.PlatformFaultDomainCount = returnedDHG.PlatformFaultDomainCount; // There is a bug in PATCH. PlatformFaultDomainCount is a required property now. returnedDHG = m_CrpClient.DedicatedHostGroups.Update(rgName, dhgName, updateDHGInput); ValidateDedicatedHostGroup(createdDHG, returnedDHG); //List DedicatedHostGroups by subscription and by resourceGroup var listDHGsResponse = m_CrpClient.DedicatedHostGroups.ListByResourceGroup(rgName); Assert.Single(listDHGsResponse); ValidateDedicatedHostGroup(createdDHG, listDHGsResponse.First()); listDHGsResponse = m_CrpClient.DedicatedHostGroups.ListBySubscription(); //There might be multiple dedicated host groups in the subscription, we only care about the one that we created. returnedDHG = listDHGsResponse.First(dhg => dhg.Id == createdDHG.Id); Assert.NotNull(returnedDHG); ValidateDedicatedHostGroup(createdDHG, returnedDHG); //Create DedicatedHost within the DedicatedHostGroup and validate var createdDH = CreateDedicatedHost(rgName, dhgName, dhName, "ESv3-Type1"); var returnedDH = m_CrpClient.DedicatedHosts.Get(rgName, dhgName, dhName); ValidateDedicatedHost(createdDH, returnedDH); //List DedicatedHosts var listDHsResponse = m_CrpClient.DedicatedHosts.ListByHostGroup(rgName, dhgName); Assert.Single(listDHsResponse); ValidateDedicatedHost(createdDH, listDHsResponse.First()); //Delete DedicatedHosts and DedicatedHostGroups m_CrpClient.DedicatedHosts.Delete(rgName, dhgName, dhName); m_CrpClient.DedicatedHostGroups.Delete(rgName, dhgName); } finally { m_ResourcesClient.ResourceGroups.Delete(rgName); Environment.SetEnvironmentVariable("AZURE_VM_TEST_LOCATION", originalTestLocation); } } }
public virtual async Task <Response <DedicatedHostGroup> > UpdateAsync(string resourceGroupName, string hostGroupName, DedicatedHostGroupUpdate parameters, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("DedicatedHostGroupsOperations.Update"); scope.Start(); try { return(await RestClient.UpdateAsync(resourceGroupName, hostGroupName, parameters, cancellationToken).ConfigureAwait(false)); } catch (Exception e) { scope.Failed(e); throw; } }
public async Task TestDedicatedHostOperations() { EnsureClientsInitialized(LocationEastUs2UpperCase.ToLower()); string baseRGName = Recording.GenerateAssetName(TestPrefix); string rgName = baseRGName + "DH"; string dhgName = "DHG-1"; string dhName = "DH-1"; // Create a dedicated host group, then get the dedicated host group and validate that they match DedicatedHostGroup createdDHG = await CreateDedicatedHostGroup(rgName, dhgName); DedicatedHostGroup returnedDHG = await DedicatedHostGroupsOperations.GetAsync(rgName, dhgName); ValidateDedicatedHostGroup(createdDHG, returnedDHG); // Update existing dedicated host group DedicatedHostGroupUpdate updateDHGInput = new DedicatedHostGroupUpdate() { Tags = { { "testKey", "testValue" } } }; createdDHG.Tags.InitializeFrom(updateDHGInput.Tags); updateDHGInput.PlatformFaultDomainCount = returnedDHG.PlatformFaultDomainCount; // There is a bug in PATCH. PlatformFaultDomainCount is a required property now. returnedDHG = await DedicatedHostGroupsOperations.UpdateAsync(rgName, dhgName, updateDHGInput); ValidateDedicatedHostGroup(createdDHG, returnedDHG); //List DedicatedHostGroups by subscription and by resourceGroup var listDHGsResponse = DedicatedHostGroupsOperations.ListByResourceGroupAsync(rgName); var listDHGsResponseRes = await listDHGsResponse.ToEnumerableAsync(); Assert.IsTrue(listDHGsResponseRes.Count() == 1); //Assert.Single(listDHGsResponse); ValidateDedicatedHostGroup(createdDHG, listDHGsResponseRes.First()); listDHGsResponse = DedicatedHostGroupsOperations.ListBySubscriptionAsync(); listDHGsResponseRes = await listDHGsResponse.ToEnumerableAsync(); //There might be multiple dedicated host groups in the subscription, we only care about the one that we created. returnedDHG = listDHGsResponseRes.First(dhg => dhg.Id == createdDHG.Id); Assert.NotNull(returnedDHG); ValidateDedicatedHostGroup(createdDHG, returnedDHG); //Create DedicatedHost within the DedicatedHostGroup and validate var createdDH = await CreateDedicatedHost(rgName, dhgName, dhName); var returnedDH = await DedicatedHostsOperations.GetAsync(rgName, dhgName, dhName); ValidateDedicatedHost(createdDH, returnedDH); //List DedicatedHosts var listDHsResponse = DedicatedHostsOperations.ListByHostGroupAsync(rgName, dhgName); var listDHsResponseRes = await listDHsResponse.ToEnumerableAsync(); Assert.IsTrue(listDHsResponseRes.Count() == 1); ValidateDedicatedHost(createdDH, listDHsResponseRes.First()); //Delete DedicatedHosts and DedicatedHostGroups await WaitForCompletionAsync(await DedicatedHostsOperations.StartDeleteAsync(rgName, dhgName, dhName)); await DedicatedHostGroupsOperations.DeleteAsync(rgName, dhgName); WaitMinutes(1); }
/// <summary> /// Update an dedicated host group. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='hostGroupName'> /// The name of the dedicated host group. /// </param> /// <param name='parameters'> /// Parameters supplied to the Update Dedicated Host Group operation. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <DedicatedHostGroupInner> UpdateAsync(this IDedicatedHostGroupsOperations operations, string resourceGroupName, string hostGroupName, DedicatedHostGroupUpdate parameters, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, hostGroupName, parameters, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
public virtual Response <DedicatedHostGroup> Update(string resourceGroupName, string hostGroupName, DedicatedHostGroupUpdate parameters, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("DedicatedHostGroupsClient.Update"); scope.Start(); try { return(RestClient.Update(resourceGroupName, hostGroupName, parameters, cancellationToken)); } catch (Exception e) { scope.Failed(e); throw; } }
/// <summary> /// Update an dedicated host group. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='hostGroupName'> /// The name of the dedicated host group. /// </param> /// <param name='parameters'> /// Parameters supplied to the Update Dedicated Host Group operation. /// </param> public static DedicatedHostGroup Update(this IDedicatedHostGroupsOperations operations, string resourceGroupName, string hostGroupName, DedicatedHostGroupUpdate parameters) { return(operations.UpdateAsync(resourceGroupName, hostGroupName, parameters).GetAwaiter().GetResult()); }