mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-17 02:53:18 +01:00
Error deployVm when elasticIp/staticNat failed to assign to the vm
This commit is contained in:
parent
0f6f231ee6
commit
d5752eca61
@ -2608,10 +2608,6 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||||||
updateVmStateForFailedVmCreation(vm.getId());
|
updateVmStateForFailedVmCreation(vm.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!finalizeDeploy(vm, true)) {
|
|
||||||
//FIXME alena - if fails, expunge the vm
|
|
||||||
}
|
|
||||||
|
|
||||||
if (template.getEnablePassword()) {
|
if (template.getEnablePassword()) {
|
||||||
// this value is not being sent to the backend; need only for api display purposes
|
// this value is not being sent to the backend; need only for api display purposes
|
||||||
vm.setPassword(password);
|
vm.setPassword(password);
|
||||||
@ -2668,7 +2664,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean finalizeDeployment(Commands cmds, VirtualMachineProfile<UserVmVO> profile, DeployDestination dest, ReservationContext context) {
|
public boolean finalizeDeployment(Commands cmds, VirtualMachineProfile<UserVmVO> profile, DeployDestination dest, ReservationContext context) {
|
||||||
UserVmVO userVm = profile.getVirtualMachine();
|
UserVmVO userVm = profile.getVirtualMachine();
|
||||||
List<NicVO> nics = _nicDao.listByVmId(userVm.getId());
|
List<NicVO> nics = _nicDao.listByVmId(userVm.getId());
|
||||||
for (NicVO nic : nics) {
|
for (NicVO nic : nics) {
|
||||||
NetworkVO network = _networkDao.findById(nic.getNetworkId());
|
NetworkVO network = _networkDao.findById(nic.getNetworkId());
|
||||||
@ -2677,7 +2673,6 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||||||
userVm.setPrivateMacAddress(nic.getMacAddress());
|
userVm.setPrivateMacAddress(nic.getMacAddress());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_vmDao.update(userVm.getId(), userVm);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2750,7 +2745,9 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
//enable elastic ip for vm
|
||||||
|
boolean success = enableElasticIpAndStaticNatForVm(profile.getVirtualMachine(), true);
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -3607,7 +3604,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||||||
return vm;
|
return vm;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean finalizeDeploy(UserVm vm, boolean stopOnError) {
|
protected boolean enableElasticIpAndStaticNatForVm(UserVm vm, boolean stopOnError) {
|
||||||
boolean success = true;
|
boolean success = true;
|
||||||
Account vmOwner = _accountMgr.getAccount(vm.getAccountId());
|
Account vmOwner = _accountMgr.getAccount(vm.getAccountId());
|
||||||
|
|
||||||
@ -3618,6 +3615,12 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||||||
NetworkOffering offering = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId());
|
NetworkOffering offering = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId());
|
||||||
if (offering.getElasticIp()) {
|
if (offering.getElasticIp()) {
|
||||||
try {
|
try {
|
||||||
|
//check if there is already static nat enabled
|
||||||
|
if (_ipAddressDao.findByAssociatedVmId(vm.getId()) != null) {
|
||||||
|
s_logger.debug("Vm " + vm + " already has elastic ip associated with it in guest network " + guestNetwork);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
s_logger.debug("Allocating elastic ip and enabling static nat for it for the vm " + vm + " in guest network " + guestNetwork);
|
s_logger.debug("Allocating elastic ip and enabling static nat for it for the vm " + vm + " in guest network " + guestNetwork);
|
||||||
IpAddress ip = _networkMgr.assignElasticIp(guestNetwork.getId(), vmOwner, false, true);
|
IpAddress ip = _networkMgr.assignElasticIp(guestNetwork.getId(), vmOwner, false, true);
|
||||||
if (ip == null) {
|
if (ip == null) {
|
||||||
|
|||||||
@ -142,7 +142,6 @@ import com.cloud.utils.component.Inject;
|
|||||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
import com.cloud.utils.db.GlobalLock;
|
import com.cloud.utils.db.GlobalLock;
|
||||||
import com.cloud.utils.db.SearchCriteria;
|
|
||||||
import com.cloud.utils.db.Transaction;
|
import com.cloud.utils.db.Transaction;
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
import com.cloud.utils.exception.ExecutionException;
|
import com.cloud.utils.exception.ExecutionException;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user