try {
Map<Pool, Pool.Record> poolRecs = Pool.getAllRecords(conn);
if (poolRecs.size() != 1) {
throw new CloudRuntimeException("There are " + poolRecs.size() + " pool for host :" + _host.uuid);
}
Host master = poolRecs.values().iterator().next().master;
setupServer(conn, master);
Host host = Host.getByUuid(conn, _host.uuid);
setupServer(conn, host);
if (!setIptables(conn)) {
s_logger.warn("set xenserver Iptable failed");
return null;
}
if (_securityGroupEnabled) {
_canBridgeFirewall = can_bridge_firewall(conn);
if (!_canBridgeFirewall) {
String msg = "Failed to configure brige firewall";
s_logger.warn(msg);
s_logger.warn("Check host " + _host.ip +" for CSP is installed or not and check network mode for bridge");
return new SetupAnswer(cmd, msg);
}
}
boolean r = launchHeartBeat(conn);
if (!r) {
return null;
}
cleanupTemplateSR(conn);
try {
if (cmd.useMultipath()) {
// the config value is set to true
host.addToOtherConfig(conn, "multipathing", "true");
host.addToOtherConfig(conn, "multipathhandle", "dmp");
}
} catch (Types.MapDuplicateKey e) {
s_logger.debug("multipath is already set");
}
if (cmd.needSetup() ) {
String result = callHostPlugin(conn, "vmops", "setup_iscsi", "uuid", _host.uuid);
if (!result.contains("> DONE <")) {
s_logger.warn("Unable to setup iscsi: " + result);
return new SetupAnswer(cmd, result);
}
Pair<PIF, PIF.Record> mgmtPif = null;
Set<PIF> hostPifs = host.getPIFs(conn);
for (PIF pif : hostPifs) {
PIF.Record rec = pif.getRecord(conn);
if (rec.management) {
if (rec.VLAN != null && rec.VLAN != -1) {
String msg =