Bug 12103: Adding host without labelling guest network fails

We do not set the default network labels as 'cloud-private' anymore. Instead it is set to the values set in global config variable. This should avoid the host connect failures requiring the network labels to be setup.
This commit is contained in:
prachi 2011-11-21 14:45:39 -08:00
parent 20dbde5c82
commit 6dc4ae47db
3 changed files with 63 additions and 19 deletions

View File

@ -1408,13 +1408,13 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
}
PhysicalNetwork defaultNetwork = _networkMgr.createPhysicalNetwork(zone.getId(), null, null, null, broadcastDomainRange, domainId, null);
String defaultXenLabel = "cloud-private";
//String defaultXenLabel = "cloud-private";
//add default Traffic types to the physical network
_networkMgr.addTrafficTypeToPhysicalNetwork(defaultNetwork.getId(), TrafficType.Guest.toString(), defaultXenLabel, null, null, null);
_networkMgr.addTrafficTypeToPhysicalNetwork(defaultNetwork.getId(), TrafficType.Public.toString(), defaultXenLabel, null, null, null);
_networkMgr.addTrafficTypeToPhysicalNetwork(defaultNetwork.getId(), TrafficType.Management.toString(), defaultXenLabel, null, null, null);
_networkMgr.addTrafficTypeToPhysicalNetwork(defaultNetwork.getId(), TrafficType.Storage.toString(), defaultXenLabel, null, null, null);
_networkMgr.addTrafficTypeToPhysicalNetwork(defaultNetwork.getId(), TrafficType.Guest.toString(), null, null, null, null);
_networkMgr.addTrafficTypeToPhysicalNetwork(defaultNetwork.getId(), TrafficType.Public.toString(), null, null, null, null);
_networkMgr.addTrafficTypeToPhysicalNetwork(defaultNetwork.getId(), TrafficType.Management.toString(), null, null, null, null);
_networkMgr.addTrafficTypeToPhysicalNetwork(defaultNetwork.getId(), TrafficType.Storage.toString(), null, null, null, null);
return defaultNetwork.getId();
}

View File

@ -4671,16 +4671,16 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
private String getDefaultXenNetworkLabel(TrafficType trafficType){
String xenLabel = null;
switch(trafficType){
case Public: xenLabel = "cloud-public";
break;
case Guest: xenLabel = "cloud-guest";
break;
case Storage: xenLabel = "cloud-storage";
break;
case Management: xenLabel = "cloud-private";
break;
case Control: xenLabel = "cloud_link_local_network";
break;
case Public: xenLabel = _configDao.getValue(Config.XenPublicNetwork.key());
break;
case Guest: xenLabel = _configDao.getValue(Config.XenGuestNetwork.key());
break;
case Storage: xenLabel = _configDao.getValue(Config.XenStorageNetwork1.key());
break;
case Management: xenLabel = _configDao.getValue(Config.XenPrivateNetwork.key());
break;
case Control: xenLabel = "cloud_link_local_network";
break;
}
return xenLabel;
}
@ -4800,7 +4800,10 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
dcId = dc.getId();
HypervisorType hypervisorType = startup.getHypervisorType();
if(s_logger.isDebugEnabled()){
s_logger.debug("Host's hypervisorType is: "+hypervisorType);
}
List<PhysicalNetworkSetupInfo> networkInfoList = new ArrayList<PhysicalNetworkSetupInfo>();
//list all physicalnetworks in the zone & for each get the network names

View File

@ -370,7 +370,13 @@ public class PodZoneConfig {
}
//add default traffic types
String defaultXenLabel = "cloud-private";
//get default Xen network labels
String defaultXenPrivateNetworkLabel = getDefaultXenNetworkLabel(TrafficType.Management);
String defaultXenPublicNetworkLabel = getDefaultXenNetworkLabel(TrafficType.Public);
String defaultXenStorageNetworkLabel = getDefaultXenNetworkLabel(TrafficType.Storage);
String defaultXenGuestNetworkLabel = getDefaultXenNetworkLabel(TrafficType.Guest);
String insertTraficType = "INSERT INTO `cloud`.`physical_network_traffic_types` (physical_network_id, traffic_type, xen_network_label) VALUES ( ?, ?, ?)";
try {
@ -381,7 +387,16 @@ public class PodZoneConfig {
}
stmt.setLong(1, id);
stmt.setString(2, traffic.toString());
stmt.setString(3, defaultXenLabel);
if(traffic.equals(TrafficType.Public)){
stmt.setString(3, defaultXenPublicNetworkLabel);
}else if(traffic.equals(TrafficType.Management)){
stmt.setString(3, defaultXenPrivateNetworkLabel);
}else if(traffic.equals(TrafficType.Storage)){
stmt.setString(3, defaultXenStorageNetworkLabel);
}else if(traffic.equals(TrafficType.Guest)){
stmt.setString(3, defaultXenGuestNetworkLabel);
}
stmt.addBatch();
}
stmt.executeBatch();
@ -390,7 +405,33 @@ public class PodZoneConfig {
}
if (printOutput) System.out.println("Successfully saved physical network.");
}
}
private String getDefaultXenNetworkLabel(TrafficType trafficType){
String xenLabel = null;
String configName = null;
switch(trafficType){
case Public: configName = "xen.public.network.device";
break;
case Guest: configName = "xen.guest.network.device";
break;
case Storage: configName = "xen.storage.network.device1";
break;
case Management: configName = "xen.private.network.device";
break;
}
if(configName != null){
xenLabel = getConfiguredValue(configName);
}
return xenLabel;
}
public static String getConfiguredValue(String configName)
{
return DatabaseConfig.getDatabaseValueString("SELECT value FROM `cloud`.`configuration` where name = \"" + configName + "\"","value",
"Unable to start DB connection to read configuration. Please contact Cloud Support.");
}
public void deleteZone(String name) {
String sql = "DELETE FROM `cloud`.`data_center` WHERE name=\"" + name + "\"";