always add master host first

This commit is contained in:
anthony 2010-09-15 19:41:31 -07:00
parent 7abfb9f2e4
commit ec8a2a9579
1 changed files with 14 additions and 3 deletions

View File

@ -137,9 +137,11 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
}
Set<Pool> pools = Pool.getAll(conn);
Pool pool = pools.iterator().next();
String poolUuid = pool.getUuid(conn);
Pool.Record pr = pool.getRecord(conn);
String poolUuid = pr.uuid;
Map<Host, Host.Record> hosts = Host.getAllRecords(conn);
Host master = pr.master;
if (_checkHvm) {
for (Map.Entry<Host, Host.Record> entry : hosts.entrySet()) {
Host.Record record = entry.getValue();
@ -150,7 +152,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
support_hvm = true;
break;
}
}
}
if( !support_hvm ) {
String msg = "Unable to add host " + record.address + " because it doesn't support hvm";
_alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, dcId, podId, msg, msg);
@ -159,8 +161,16 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
}
}
}
for( int i = 0; i < 2; i++ ) {
for (Map.Entry<Host, Host.Record> entry : hosts.entrySet()) {
Host host = entry.getKey();
if( i== 0 ) {
if(!host.equals(master)) {
continue;
} else {
hosts.remove(host);
}
}
Host.Record record = entry.getValue();
String hostAddr = record.address;
@ -239,6 +249,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
resource.start();
resources.put(resource, details);
}
}
if (!addHostsToPool(url, conn, dcId, podId, clusterId, resources)) {
return null;