if (hostuuid.equals(masterRec.uuid)) {
s_logger.debug("This is last host to eject, so don't need to eject: " + hostuuid);
return new Answer(cmd);
}
Host host = Host.getByUuid(conn, hostuuid);
// remove all tags cloud stack add before eject
Host.Record hr = host.getRecord(conn);
Iterator<String> it = hr.tags.iterator();
while (it.hasNext()) {
String tag = it.next();
if (tag.startsWith("vmops-version-")) {
it.remove();
}
}
// eject from pool
try {
Pool.eject(conn, host);
try {
Thread.sleep(10 * 1000);
} catch (InterruptedException e) {
}
} catch (XenAPIException e) {
String msg = "Unable to eject host " + _host.uuid + " due to " + e.toString();
s_logger.warn(msg);
host.destroy(conn);
}
return new Answer(cmd);
} catch (XenAPIException e) {
String msg = "XenAPIException Unable to destroy host " + _host.uuid + " in xenserver database due to " + e.toString();
s_logger.warn(msg, e);