@Test(dependsOnMethods = "testCreateAggregate") public void testModifyMetadata() { if (apiOption.isPresent()) { HostAggregateApi api = apiOption.get(); for (Map<String, String> theMetaData : ImmutableSet.of( ImmutableMap.of("somekey", "somevalue"), ImmutableMap.of("somekey", "some other value", "anotherkey", "another val") )) { // Apply changes HostAggregate details = api.setMetadata(testAggregate.getId(), theMetaData); // bug in openstack - metadata values are never removed, so we just checking what we've set for (Map.Entry<String, String> entry : theMetaData.entrySet()) { assertEquals(details.getMetadata().get(entry.getKey()), entry.getValue()); } // Re-fetch to double-check details = api.get(testAggregate.getId()); for (Map.Entry<String, String> entry : theMetaData.entrySet()) { assertEquals(details.getMetadata().get(entry.getKey()), entry.getValue()); } } } }
@Test(dependsOnMethods = "testCreateAggregate") public void testModifyMetadata() { if (apiOption.isPresent()) { HostAggregateApi api = apiOption.get(); for (Map<String, String> theMetaData : ImmutableSet.of( ImmutableMap.of("somekey", "somevalue"), ImmutableMap.of("somekey", "some other value", "anotherkey", "another val") )) { // Apply changes HostAggregate details = api.setMetadata(testAggregate.getId(), theMetaData); // bug in openstack - metadata values are never removed, so we just checking what we've set for (Map.Entry<String, String> entry : theMetaData.entrySet()) { assertEquals(details.getMetadata().get(entry.getKey()), entry.getValue()); } // Re-fetch to double-check details = api.get(testAggregate.getId()); for (Map.Entry<String, String> entry : theMetaData.entrySet()) { assertEquals(details.getMetadata().get(entry.getKey()), entry.getValue()); } } } }
public void testSetMetadata() { URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-aggregates/1/action"); HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).method("POST") .payload(payloadFromStringWithContentType("{\"set_metadata\":{\"metadata\":{\"mykey\":\"some value or other\"}}}", MediaType.APPLICATION_JSON)).build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_details.json")).build()).getHostAggregateExtensionForZone("az-1.region-a.geo-1").get(); assertEquals(api.setMetadata("1", ImmutableMap.of("mykey", "some value or other")), exampleHostAggregate()); }
public void testSetMetadata() { URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-aggregates/1/action"); HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).method("POST") .payload(payloadFromStringWithContentType("{\"set_metadata\":{\"metadata\":{\"mykey\":\"some value or other\"}}}", MediaType.APPLICATION_JSON)).build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_details.json")).build()).getHostAggregateApi("az-1.region-a.geo-1").get(); assertEquals(api.setMetadata("1", ImmutableMap.of("mykey", "some value or other")), exampleHostAggregate()); }