merging 6271 int0 2.1.x

This commit is contained in:
abhishek 2010-09-22 11:27:03 -07:00
parent e8b63e7f9d
commit 843cfc8793
3 changed files with 42 additions and 12 deletions

View File

@ -142,8 +142,9 @@ public class IPAddressDaoImpl extends GenericDaoBase<IPAddressVO, String> implem
txn.commit();
return ip.getAddress();
} else {
txn.rollback();
s_logger.error("Unable to find an available IP address with related vlan, vlanDbId: " + vlanDbId);
txn.rollback();
//we do not log this as an error now, as there can be multiple vlans across which we iterate
s_logger.warn("Unable to find an available IP address with related vlan, vlanDbId: " + vlanDbId);
}
} catch (Exception e) {
s_logger.warn("Unable to assign IP", e);

View File

@ -988,13 +988,13 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
}
// Make sure the specified account isn't already assigned to a VLAN in this zone
List<AccountVlanMapVO> accountVlanMaps = _accountVlanMapDao.listAccountVlanMapsByAccount(accountId);
for (AccountVlanMapVO accountVlanMap : accountVlanMaps) {
VlanVO vlan = _vlanDao.findById(accountVlanMap.getVlanDbId());
if (vlan.getDataCenterId() == zone.getId().longValue()) {
throw new InvalidParameterValueException("The account " + account.getAccountName() + " is already assigned to the VLAN with ID " + vlan.getVlanId() + " in zone " + zone.getName() + ".");
}
}
// List<AccountVlanMapVO> accountVlanMaps = _accountVlanMapDao.listAccountVlanMapsByAccount(accountId);
// for (AccountVlanMapVO accountVlanMap : accountVlanMaps) {
// VlanVO vlan = _vlanDao.findById(accountVlanMap.getVlanDbId());
// if (vlan.getDataCenterId() == zone.getId().longValue()) {
// throw new InvalidParameterValueException("The account " + account.getAccountName() + " is already assigned to the VLAN with ID " + vlan.getVlanId() + " in zone " + zone.getName() + ".");
// }
// }
}
}
}

View File

@ -2447,7 +2447,8 @@ public class UserVmManagerImpl implements UserVmManager {
Set<Long> avoids = new HashSet<Long>();
VlanVO guestVlan = null;
List<VlanVO> vlansForAccount = _vlanDao.listVlansForAccountByType(dc.getId(), account.getId(), VlanType.DirectAttached);
List<VlanVO> vlansForPod = null;
boolean forAccount = false;
if (vlansForAccount.size() > 0) {
forAccount = true;
@ -2472,7 +2473,7 @@ public class UserVmManagerImpl implements UserVmManager {
s_logger.debug("Attempting to create direct attached vm in pod " + pod.first().getName());
}
if (!forAccount && !forZone) {
List<VlanVO> vlansForPod = _vlanDao.listVlansForPodByType(pod.first().getId(), VlanType.DirectAttached);
vlansForPod = _vlanDao.listVlansForPodByType(pod.first().getId(), VlanType.DirectAttached);
if (vlansForPod.size() < 1) {
avoids.add(pod.first().getId());
if (s_logger.isDebugEnabled()) {
@ -2499,7 +2500,35 @@ public class UserVmManagerImpl implements UserVmManager {
}
routerId = router.getId();
}
String guestIp = _ipAddressDao.assignIpAddress(accountId, account.getDomainId().longValue(), guestVlan.getId(), false);
String guestIp = null;
if(forAccount)
{
for(VlanVO vlanForAcc : vlansForAccount)
{
guestIp = _ipAddressDao.assignIpAddress(accountId, account.getDomainId(), vlanForAcc.getId(), false);
if(guestIp!=null)
break; //got an ip
}
}
else if(!forAccount && !forZone)
{
//i.e. for pod
for(VlanVO vlanForPod : vlansForPod)
{
guestIp = _ipAddressDao.assignIpAddress(accountId, account.getDomainId(), vlanForPod.getId(), false);
if(guestIp!=null)
break;//got an ip
}
}
else
{
//for zone
guestIp = _ipAddressDao.assignIpAddress(accountId, account.getDomainId().longValue(), guestVlan.getId(), false);
}
if (guestIp == null) {
s_logger.debug("No guest IP available in pod id=" + pod.first().getId());
avoids.add(pod.first().getId());