logger.info("datastore " + datastore.getName()
+ " is inaccessible or in maintanence mode. Ignore it.");
continue;
}
if (this.dc.findAbstractDatastore(datastore.getName()) == null) {
AbstractDatastore ds = new AbstractDatastore(datastore.getName());
ds.setFreeSpace((int) (datastore.getFreeSpace() / (1024 * 1024 * 1024)));
this.dc.addDatastore(ds);
logger.info("added datastore " + ds.getName() + " with space "
+ ds.getFreeSpace() + " to datacenter");
}
}
// translate cluster and hosts
AbstractCluster abstractCluster = new AbstractCluster(cluster.getName());
try {
// add hosts
for (VcHost host : cluster.getHosts()) {
if (host.isConnected() && !host.isUnavailbleForManagement()
&& host.getDatastores() != null && host.getDatastores().size() > 0) {
AbstractHost abstractHost = new AbstractHost(host.getName());
for (VcDatastore datastore : host.getDatastores()) {
AbstractDatastore ds =
this.dc.findAbstractDatastore(datastore.getName());
if (ds != null) {
abstractHost.addDatastore(ds);
logger.info("added datastore " + ds.getName() + " to host "
+ host.getName());
}
}
abstractCluster.addHost(abstractHost);
logger.info("added host " + host.getName() + " to container");
}
}
// add datastores
for (VcDatastore datastore : cluster.getAllDatastores()) {
AbstractDatastore ds =
this.dc.findAbstractDatastore(datastore.getName());
if (ds != null) {
abstractCluster.addDatastore(ds);
logger.info("added datastore " + ds.getName() + " with space "
+ ds.getFreeSpace() + " to cluster " + cluster.getName());
}
}
this.dc.addCluster(abstractCluster);
} catch (Exception e) {