logger.info(json);
ObjectMapper mapper = new ObjectMapper();
try {
AbstractDatacenter dc = mapper.readValue(json, AbstractDatacenter.class);
// replace the abstract datastore objects in cluster/host with the ones
// in dc.datastores
for (AbstractCluster cluster : dc.getClusters()) {
// replace datastores in cluster level
List<AbstractDatastore> dsList = new ArrayList<AbstractDatastore>();
for (AbstractDatastore datastore : cluster.getDatastores()) {
AbstractDatastore ds =
dc.findAbstractDatastore(datastore.getName());
AuAssert.check(ds != null);
dsList.add(ds);
}
cluster.setDatastores(dsList);
// replace datastores in host level
for (AbstractHost host : cluster.getHosts()) {
List<AbstractDatastore> datastores =
new ArrayList<AbstractDatastore>();
for (AbstractDatastore datastore : host.getDatastores()) {
AbstractDatastore ds =
dc.findAbstractDatastore(datastore.getName());
AuAssert.check(ds != null);
datastores.add(ds);
}
host.setDatastores(datastores);
host.setParent(cluster);
}
}
Assert.assertTrue(dc.findAbstractCluster("cluster-ws") != null,
"cluster-ws is missing, datacenter spec is not correctly resolved");
return dc;
} catch (Exception e) {
logger.error(e.getMessage());
throw e;