summaryrefslogtreecommitdiffstats
path: root/pomba/network-discovery
diff options
context:
space:
mode:
Diffstat (limited to 'pomba/network-discovery')
-rw-r--r--pomba/network-discovery/config/application.properties13
-rw-r--r--pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/EnricherConfiguration.java29
-rw-r--r--pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/service/SpringServiceImpl.java104
-rw-r--r--pomba/network-discovery/src/test/java/org/onap/sdnc/apps/pomba/networkdiscovery/unittest/service/NetworkDiscoveryTest.java96
4 files changed, 136 insertions, 106 deletions
diff --git a/pomba/network-discovery/config/application.properties b/pomba/network-discovery/config/application.properties
index 1536110..757e632 100644
--- a/pomba/network-discovery/config/application.properties
+++ b/pomba/network-discovery/config/application.properties
@@ -33,3 +33,16 @@ enricher.types = vserver, l3-network
enricher.type.vserver.url = /enricher/v11/cloud-infrastructure/vservers/vserver/{0}?sot=!aai
enricher.type.l3-network.url = /enricher/v11/network/l3-networks/l3-network/{0}?sot=!aai
+# Mapping from Enricher Attribute name to POMBA Attribute name in the format
+# <Enricher Attribute Name>:<Pomba Attribute Name>; and separated by semicolon ";"
+# for example,
+# vserser-id:id;
+# means Attribute name "vserer-id" from Enricher will be converted to "id" in POMBA.
+enricher.attributeNameMappingList=Id:id;id:id;vserver-id:id;name:name;locked:inMaintenance; \
+ hostname:hostname;status:status;vm_state:vmState;vm-state:vmState;admin_state_up:AdminState; \
+ favor.disk:flavorDisk;flavor.ephemeral:flavorEphemoral;flavor.extra_specs.hw.cpu_model:flavorHwCpuModel; \
+ flavor.extra_specs.hw.cpu_policy:flavorHwCpuPolicy;flavor.extra_specs.hw.mem_page_size:flavorHwMemPageSize; \
+ flavor.original_name:flavorOriginalName;flavor.ram:flavorRam;flavor.swap:flavorSwag;flavorvcpus:flavorVcpus; \
+ image.id:imageId;hostId:hostId;host:host;host_status:hostStatus;security_group.name:securityGroupName; \
+ serverName:serverName;metadata.myservername:otherServerName;shared:sharedNetwork;subnets:subnets; \
+ userId:userId;tenant_id:tenantId
diff --git a/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/EnricherConfiguration.java b/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/EnricherConfiguration.java
index 0fee505..0257687 100644
--- a/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/EnricherConfiguration.java
+++ b/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/EnricherConfiguration.java
@@ -26,6 +26,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
+import com.google.common.base.Splitter;
@Configuration
public class EnricherConfiguration {
@@ -47,24 +48,23 @@ public class EnricherConfiguration {
@Value("${enricher.readTimeout:60000}")
private int readTimeout;
- @Bean(name="enricherClient")
+ @Bean(name = "enricherClient")
public RestClient restClient() {
- return new RestClient()
- .validateServerHostname(false)
- .validateServerCertChain(false)
- .connectTimeoutMs(this.connectionTimeout)
- .readTimeoutMs(this.readTimeout)
- .clientCertFile(this.keyStorePath)
- .clientCertPassword(
- org.eclipse.jetty.util.security.Password.deobfuscate(this.keyStorePassword));
+ return new RestClient().validateServerHostname(false)
+ .validateServerCertChain(false)
+ .connectTimeoutMs(this.connectionTimeout)
+ .readTimeoutMs(this.readTimeout)
+ .clientCertFile(this.keyStorePath)
+ .clientCertPassword(org.eclipse.jetty.util.security.Password.deobfuscate(
+ this.keyStorePassword));
}
- @Bean(name="enricherBaseUrl")
+ @Bean(name = "enricherBaseUrl")
public String getURL() {
return this.url;
}
- @Bean(name="enricherTypeURLs")
+ @Bean(name = "enricherTypeURLs")
public Map<String, String> enricherTypeURLs() {
Map<String, String> result = new HashMap<>();
@@ -83,5 +83,12 @@ public class EnricherConfiguration {
return result;
}
+ @Value("${enricher.attributeNameMappingList}")
+ private String enricherAttributeNameMappingList;
+ @Bean(name = "enricherAttributeNameMapping")
+ public Map<String, String> getAttributeNameMap() {
+ String noWhiteSpaceString = enricherAttributeNameMappingList.replaceAll("\\s", "");
+ return (Splitter.on(";").withKeyValueSeparator(":").split(noWhiteSpaceString));
+ }
}
diff --git a/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/service/SpringServiceImpl.java b/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/service/SpringServiceImpl.java
index 3230a52..8b25e47 100644
--- a/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/service/SpringServiceImpl.java
+++ b/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/service/SpringServiceImpl.java
@@ -70,8 +70,8 @@ public class SpringServiceImpl implements SpringService {
private static final int DEFAULT_WORKER_THREADS = 3;
private ExecutorService executor = Executors.newFixedThreadPool(
- Integer.getInteger("discovery.threads", DEFAULT_WORKER_THREADS),
- new ThreadFactoryBuilder().setNameFormat("discovery-worker-%d").build());
+ Integer.getInteger("discovery.threads", DEFAULT_WORKER_THREADS),
+ new ThreadFactoryBuilder().setNameFormat("discovery-worker-%d").build());
@Autowired
private RestClient enricherClient;
@@ -87,6 +87,8 @@ public class SpringServiceImpl implements SpringService {
private DocumentBuilder parser;
+ @javax.annotation.Resource
+ private Map<String, String> enricherAttributeNameMapping;
public SpringServiceImpl() throws ParserConfigurationException {
this.parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
@@ -94,12 +96,12 @@ public class SpringServiceImpl implements SpringService {
@Override
public NetworkDiscoveryResponse findbyResourceIdAndType(String transactionId,
- String requestId,
- String resourceType,
- List<String> resourceIds,
- String notificationURL,
- String notificationAuthorization,
- ONAPLogAdapter adapter) throws ApplicationException {
+ String requestId,
+ String resourceType,
+ List<String> resourceIds,
+ String notificationURL,
+ String notificationAuthorization,
+ ONAPLogAdapter adapter) throws ApplicationException {
NetworkDiscoveryResponse response = new NetworkDiscoveryResponse();
response.setRequestId(requestId);
@@ -115,8 +117,8 @@ public class SpringServiceImpl implements SpringService {
}
// schedule discovery of specified resources
- Runnable task = new ResourceTask(transactionId, requestId, resourceType, resourceIds,
- notificationURL, notificationAuthorization, enricherURL, adapter);
+ Runnable task = new ResourceTask(transactionId, requestId, resourceType, resourceIds, notificationURL,
+ notificationAuthorization, enricherURL, adapter);
this.executor.submit(task);
response.setCode(Status.ACCEPTED.getStatusCode());
@@ -130,19 +132,31 @@ public class SpringServiceImpl implements SpringService {
this.executor.shutdown();
}
- private List<Attribute> toAttributeList(String xml) throws SAXException, IOException {
- // TODO don't return raw A&AI attributes but coerce to swagger-defined enums
+ private List<Attribute> toAttributeList(String xml, ONAPLogAdapter adapter) throws SAXException, IOException {
+ Logger log = adapter.unwrap();
Document doc = this.parser.parse(new InputSource(new StringReader(xml)));
NodeList children = doc.getDocumentElement().getChildNodes();
List<Attribute> result = new ArrayList<>();
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) {
- Attribute attr = new Attribute();
- attr.setName(((Element)child).getTagName());
- attr.setValue(((Element)child).getTextContent());
- attr.setDataQuality(DataQuality.ok());
- result.add(attr);
+
+ // remove white space before conversion
+ String attributeName = ((Element) child).getTagName().replaceAll("\\s", "");
+
+ // If the incoming attribute name is not listed in the
+ // attributeNameMapping, then this attribute will be removed.
+ String newName = enricherAttributeNameMapping.get(attributeName);
+ if (newName != null) {
+ Attribute attr = new Attribute();
+ attr.setName(newName);
+ attr.setValue(((Element) child).getTextContent());
+ attr.setDataQuality(DataQuality.ok());
+ result.add(attr);
+ } else {
+ log.debug("[" + ((Element) child).getTagName()
+ + "] was removed due to not listed in enricherAttributeNameMapping.");
+ }
}
}
return result;
@@ -150,10 +164,7 @@ public class SpringServiceImpl implements SpringService {
private void sendNotification(String url, String authorization, Object notification, ONAPLogAdapter adapter) {
- Invocation.Builder request = this.callbackClient
- .target(url)
- .request()
- .accept(MediaType.TEXT_PLAIN_TYPE);
+ Invocation.Builder request = this.callbackClient.target(url).request().accept(MediaType.TEXT_PLAIN_TYPE);
if (authorization != null) {
request.header(HttpHeaders.AUTHORIZATION, authorization);
@@ -168,21 +179,23 @@ public class SpringServiceImpl implements SpringService {
StringBuilder debugRequest = new StringBuilder("REQUEST:\n");
debugRequest.append("URL: ").append(url).append("\n");
debugRequest.append("Payload: ").append(notification).append("\n");
-// if (headers != null) {
-// debugRequest.append("Headers: ");
-// for (Entry<String, List<String>> header : headers.entrySet()) {
-// debugRequest.append("\n\t").append(header.getKey()).append(":");
-// for (String headerEntry : header.getValue()) {
-// debugRequest.append("\"").append(headerEntry).append("\" ");
-// }
-// }
-// }
+ // if (headers != null) {
+ // debugRequest.append("Headers: ");
+ // for (Entry<String, List<String>> header : headers.entrySet())
+ // {
+ // debugRequest.append("\n\t").append(header.getKey()).append(":");
+ // for (String headerEntry : header.getValue()) {
+ // debugRequest.append("\"").append(headerEntry).append("\" ");
+ // }
+ // }
+ // }
log.debug(debugRequest.toString());
}
Response result = request.post(Entity.json(notification));
- adapter.unwrap().info("request at url = {} resulted in http response: {}", url, result.getStatusInfo().getStatusCode() + " " + result.getStatusInfo().getReasonPhrase());
+ adapter.unwrap().info("request at url = {} resulted in http response: {}", url,
+ result.getStatusInfo().getStatusCode() + " " + result.getStatusInfo().getReasonPhrase());
if (log.isDebugEnabled()) {
StringBuilder debugResponse = new StringBuilder("RESPONSE:\n");
@@ -206,8 +219,8 @@ public class SpringServiceImpl implements SpringService {
}
} catch (Exception x) {
- log.error("Error during {} operation to endpoint at url = {} with error = {}",
- "POST", url, x.getLocalizedMessage());
+ log.error("Error during {} operation to endpoint at url = {} with error = {}", "POST", url,
+ x.getLocalizedMessage());
}
}
@@ -222,13 +235,13 @@ public class SpringServiceImpl implements SpringService {
private final ONAPLogAdapter adapter;
public ResourceTask(String transactionId,
- String requestId,
- String resourceType,
- List<String> resourceIds,
- String notificationURL,
- String notificationAuthorization,
- String resourceURL,
- ONAPLogAdapter adapter) {
+ String requestId,
+ String resourceType,
+ List<String> resourceIds,
+ String notificationURL,
+ String notificationAuthorization,
+ String resourceURL,
+ ONAPLogAdapter adapter) {
this.transactionId = transactionId;
this.requestId = requestId;
this.resourceType = resourceType;
@@ -249,9 +262,11 @@ public class SpringServiceImpl implements SpringService {
MultivaluedMap<String, String> headers = new MultivaluedHashMap<>();
headers.add(ENRICHER_HEADER_APPLICATION, RestService.SERVICE_NAME);
headers.add(ENRICHER_HEADER_TRANSACTION, this.transactionId);
+
for (String resourceId : this.resourceIds) {
String url = format.format(new Object[] { resourceId });
- OperationResult result = SpringServiceImpl.this.enricherClient.get(url, headers, MediaType.APPLICATION_XML_TYPE);
+ OperationResult result = SpringServiceImpl.this.enricherClient.get(url, headers,
+ MediaType.APPLICATION_XML_TYPE);
Resource resource = new Resource();
resource.setType(this.resourceType);
@@ -265,12 +280,12 @@ public class SpringServiceImpl implements SpringService {
if (result.wasSuccessful()) {
resource.setDataQuality(DataQuality.ok());
try {
- resource.setAttributeList(toAttributeList(result.getResult()));
+ List<Attribute> attributeList = toAttributeList(result.getResult(), adapter);
+ resource.setAttributeList(attributeList);
} catch (Exception x) {
resource.setDataQuality(DataQuality.error(x.getMessage()));
}
- }
- else {
+ } else {
resource.setDataQuality(DataQuality.error(result.getFailureCause()));
}
}
@@ -285,6 +300,7 @@ public class SpringServiceImpl implements SpringService {
private static class RequestBuilderWrapper implements RequestBuilder<RequestBuilderWrapper> {
private Invocation.Builder builder;
+
private RequestBuilderWrapper(Invocation.Builder builder) {
this.builder = builder;
}
diff --git a/pomba/network-discovery/src/test/java/org/onap/sdnc/apps/pomba/networkdiscovery/unittest/service/NetworkDiscoveryTest.java b/pomba/network-discovery/src/test/java/org/onap/sdnc/apps/pomba/networkdiscovery/unittest/service/NetworkDiscoveryTest.java
index 93a1304..939fc5c 100644
--- a/pomba/network-discovery/src/test/java/org/onap/sdnc/apps/pomba/networkdiscovery/unittest/service/NetworkDiscoveryTest.java
+++ b/pomba/network-discovery/src/test/java/org/onap/sdnc/apps/pomba/networkdiscovery/unittest/service/NetworkDiscoveryTest.java
@@ -73,12 +73,9 @@ import org.springframework.test.context.web.WebAppConfiguration;
@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class })
@WebAppConfiguration
@SpringBootTest
-@TestPropertySource(properties = {
- "enricher.url=http://localhost:9505",
+@TestPropertySource(properties = { "enricher.url=http://localhost:9505",
"basicAuth.username=admin",
- "basicAuth.password=OBF:1u2a1toa1w8v1tok1u30"
-})
-
+ "basicAuth.password=OBF:1u2a1toa1w8v1tok1u30" })
public class NetworkDiscoveryTest {
private static final String V1 = "v1";
private static final String APP = "junit";
@@ -121,7 +118,7 @@ public class NetworkDiscoveryTest {
// no Authorization header
List<String> resourceIds = Arrays.asList(UUID.randomUUID().toString());
Response response = this.service.findbyResourceIdAndType(this.httpRequest, V1, null, APP, this.transactionId,
- this.requestId, RESOURCE_TYPE_VSERVER, resourceIds, getCallbackUrl());
+ this.requestId, RESOURCE_TYPE_VSERVER, resourceIds, getCallbackUrl());
assertEquals(Status.UNAUTHORIZED.getStatusCode(), response.getStatus());
// should get WWW-Authenticate header in response
assertTrue(response.getHeaderString(HttpHeaders.WWW_AUTHENTICATE).startsWith("Basic realm"));
@@ -132,8 +129,8 @@ public class NetworkDiscoveryTest {
String authorization = "Basic " + Base64.getEncoder().encodeToString("aaa:bbb".getBytes());
// bad Authorization header
List<String> resourceIds = Arrays.asList(UUID.randomUUID().toString());
- Response response = this.service.findbyResourceIdAndType(this.httpRequest, V1, authorization, APP, this.transactionId,
- this.requestId, RESOURCE_TYPE_VSERVER, resourceIds, getCallbackUrl());
+ Response response = this.service.findbyResourceIdAndType(this.httpRequest, V1, authorization, APP,
+ this.transactionId, this.requestId, RESOURCE_TYPE_VSERVER, resourceIds, getCallbackUrl());
assertEquals(Status.UNAUTHORIZED.getStatusCode(), response.getStatus());
// should not get WWW-Authenticate header in response
assertNull(response.getHeaderString(HttpHeaders.WWW_AUTHENTICATE));
@@ -144,9 +141,9 @@ public class NetworkDiscoveryTest {
// no X-FromAppId header
List<String> resourceIds = Arrays.asList(UUID.randomUUID().toString());
Response response = this.service.findbyResourceIdAndType(this.httpRequest, V1, AUTH, null, this.transactionId,
- this.requestId, RESOURCE_TYPE_VSERVER, resourceIds, getCallbackUrl());
+ this.requestId, RESOURCE_TYPE_VSERVER, resourceIds, getCallbackUrl());
assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus());
- assertTrue(((String)response.getEntity()).contains(ONAPLogConstants.Headers.PARTNER_NAME));
+ assertTrue(((String) response.getEntity()).contains(ONAPLogConstants.Headers.PARTNER_NAME));
}
@Test
@@ -154,9 +151,9 @@ public class NetworkDiscoveryTest {
// no X-FromAppId header
List<String> resourceIds = Arrays.asList(UUID.randomUUID().toString());
Response response = this.service.findbyResourceIdAndType(this.httpRequest, V1, AUTH, APP, this.transactionId,
- null, RESOURCE_TYPE_VSERVER, resourceIds, getCallbackUrl());
+ null, RESOURCE_TYPE_VSERVER, resourceIds, getCallbackUrl());
assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus());
- assertTrue(((String)response.getEntity()).contains("requestId"));
+ assertTrue(((String) response.getEntity()).contains("requestId"));
}
@Test
@@ -164,9 +161,9 @@ public class NetworkDiscoveryTest {
// no X-FromAppId header
List<String> resourceIds = Arrays.asList(UUID.randomUUID().toString());
Response response = this.service.findbyResourceIdAndType(this.httpRequest, V1, AUTH, APP, this.transactionId,
- this.requestId, RESOURCE_TYPE_VSERVER, resourceIds, null);
+ this.requestId, RESOURCE_TYPE_VSERVER, resourceIds, null);
assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus());
- assertTrue(((String)response.getEntity()).contains("notificationURL"));
+ assertTrue(((String) response.getEntity()).contains("notificationURL"));
}
@Test
@@ -174,19 +171,19 @@ public class NetworkDiscoveryTest {
// no resourceIds list
{
List<String> resourceIds = null;
- Response response = this.service.findbyResourceIdAndType(this.httpRequest, V1, AUTH, APP, this.transactionId,
- this.requestId, RESOURCE_TYPE_VSERVER, resourceIds, getCallbackUrl());
+ Response response = this.service.findbyResourceIdAndType(this.httpRequest, V1, AUTH, APP,
+ this.transactionId, this.requestId, RESOURCE_TYPE_VSERVER, resourceIds, getCallbackUrl());
assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus());
- assertTrue(((String)response.getEntity()).contains("resourceIds"));
+ assertTrue(((String) response.getEntity()).contains("resourceIds"));
}
// empty resourceId list
{
List<String> resourceIds = new ArrayList<>();
- Response response = this.service.findbyResourceIdAndType(this.httpRequest, V1, AUTH, APP, this.transactionId,
- this.requestId, RESOURCE_TYPE_VSERVER, resourceIds, getCallbackUrl());
+ Response response = this.service.findbyResourceIdAndType(this.httpRequest, V1, AUTH, APP,
+ this.transactionId, this.requestId, RESOURCE_TYPE_VSERVER, resourceIds, getCallbackUrl());
assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus());
- assertTrue(((String)response.getEntity()).contains("resourceIds"));
+ assertTrue(((String) response.getEntity()).contains("resourceIds"));
}
}
@@ -195,9 +192,9 @@ public class NetworkDiscoveryTest {
// no resource type
List<String> resourceIds = Arrays.asList(UUID.randomUUID().toString());
Response response = this.service.findbyResourceIdAndType(this.httpRequest, V1, AUTH, APP, this.transactionId,
- this.requestId, null, resourceIds, getCallbackUrl());
+ this.requestId, null, resourceIds, getCallbackUrl());
assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus());
- assertTrue(((String)response.getEntity()).contains("resourceType"));
+ assertTrue(((String) response.getEntity()).contains("resourceType"));
}
@Test
@@ -205,29 +202,31 @@ public class NetworkDiscoveryTest {
String vserverId = UUID.randomUUID().toString();
String resourcePath = MessageFormat.format(
- this.environment.getProperty("enricher.type.vserver.url"),
- new Object[] { vserverId });
-
- String enricherPayload = String.format(
- "<vserver xmlns=\"http://org.onap.aai.inventory/v11\">\r\n"
- + " <vserver-id>%s</vserver-id>\r\n"
- + " <power-state>1</power-state>\r\n"
- + " <vm-state>active</vm-state>\r\n"
- + " <status>ACTIVE</status>\r\n"
- + " <host-status>UNKNOWN</host-status>\r\n"
- + " <updated>2017-11-20T04:26:13Z</updated>\r\n"
- + " <disk-allocation-gb>.010</disk-allocation-gb>\r\n"
- + " <memory-usage-mb>null</memory-usage-mb>\r\n"
- + " <cpu-util-percent>.043</cpu-util-percent>\r\n"
- + " <retrieval-timestamp>2018-06-27 19:41:49 +0000</retrieval-timestamp>\r\n"
- + "</vserver>", vserverId);
+ this.environment.getProperty("enricher.type.vserver.url"),
+ new Object[] { vserverId });
+
+ String enricherPayload = String.format("<vserver xmlns=\"http://org.onap.aai.inventory/v11\">\r\n"
+ + " <vserver-id>%s</vserver-id>\r\n"
+ + " <power-state>1</power-state>\r\n"
+ + " <locked>true</locked>\r\n"
+ + " <hostname>10.147.112.48</hostname>\r\n"
+ + " <vm-state>active</vm-state>\r\n"
+ + " <status>ACTIVE</status>\r\n"
+ + " <host-status>UNKNOWN</host-status>\r\n"
+ + " <updated>2017-11-20T04:26:13Z</updated>\r\n"
+ + " <disk-allocation-gb>.010</disk-allocation-gb>\r\n"
+ + " <memory-usage-mb>null</memory-usage-mb>\r\n"
+ + " <cpu-util-percent>.043</cpu-util-percent>\r\n"
+ + " <retrieval-timestamp>2018-06-27 19:41:49 +0000</retrieval-timestamp>\r\n"
+ + "</vserver>",
+ vserverId);
this.enricherRule.stubFor(get(resourcePath).willReturn(okTextXml(enricherPayload)));
this.callbackRule.stubFor(post(CALLBACK_PATH).willReturn(ok("Acknowledged")));
Response response = this.service.findbyResourceIdAndType(this.httpRequest, V1, AUTH, APP, null, this.requestId,
- RESOURCE_TYPE_VSERVER, Arrays.asList(vserverId), getCallbackUrl());
+ RESOURCE_TYPE_VSERVER, Arrays.asList(vserverId), getCallbackUrl());
assertEquals(Status.OK.getStatusCode(), response.getStatus());
NetworkDiscoveryResponse entity = (NetworkDiscoveryResponse) response.getEntity();
@@ -243,8 +242,8 @@ public class NetworkDiscoveryTest {
ObjectMapper mapper = new ObjectMapper();
AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance());
mapper.setAnnotationIntrospector(introspector);
- NetworkDiscoveryNotification notification =
- mapper.readValue(notificationJson, NetworkDiscoveryNotification.class);
+ NetworkDiscoveryNotification notification = mapper.readValue(notificationJson,
+ NetworkDiscoveryNotification.class);
assertEquals(requestId, notification.getRequestId());
assertEquals(Status.OK.getStatusCode(), notification.getCode().intValue());
@@ -256,15 +255,10 @@ public class NetworkDiscoveryTest {
assertEquals("vserver", vserver.getType());
assertEquals(DataQuality.Status.ok, vserver.getDataQuality().getStatus());
- verifyAttribute(vserver.getAttributeList(), "power-state", "1");
- verifyAttribute(vserver.getAttributeList(), "vm-state", "active");
verifyAttribute(vserver.getAttributeList(), "status", "ACTIVE");
- verifyAttribute(vserver.getAttributeList(), "host-status", "UNKNOWN");
- verifyAttribute(vserver.getAttributeList(), "updated", "2017-11-20T04:26:13Z");
- verifyAttribute(vserver.getAttributeList(), "disk-allocation-gb", ".010");
- verifyAttribute(vserver.getAttributeList(), "memory-usage-mb", "null");
- verifyAttribute(vserver.getAttributeList(), "cpu-util-percent", ".043");
- verifyAttribute(vserver.getAttributeList(), "retrieval-timestamp", "2018-06-27 19:41:49 +0000");
+ verifyAttribute(vserver.getAttributeList(), "inMaintenance", "true");
+ verifyAttribute(vserver.getAttributeList(), "hostname", "10.147.112.48");
+ verifyAttribute(vserver.getAttributeList(), "vmState", "active");
}
/**
@@ -276,7 +270,7 @@ public class NetworkDiscoveryTest {
String resourceType = "unsupported";
List<String> resourceIds = Arrays.asList("dummyId");
Response response = this.service.findbyResourceIdAndType(this.httpRequest, V1, AUTH, APP, this.transactionId,
- this.requestId, resourceType, resourceIds, getCallbackUrl());
+ this.requestId, resourceType, resourceIds, getCallbackUrl());
assertEquals(Status.OK.getStatusCode(), response.getStatus());
NetworkDiscoveryResponse entity = (NetworkDiscoveryResponse) response.getEntity();
@@ -295,7 +289,7 @@ public class NetworkDiscoveryTest {
}
private List<ServeEvent> waitForRequests(WireMockRule service, int minRequests, long timeoutSeconds)
- throws InterruptedException {
+ throws InterruptedException {
long remaining = timeoutSeconds * 1000L;
long retryInterval = Math.min(remaining / 5, 1000);