mirror of https://github.com/apache/cloudstack.git
bug CS-15817 system VM's fail to create in basic zone with EIP/ELB network offering
removing the ActionEvent annotation on associate IP, acuquire IP methods on internal methods, so that static NAT for system VM succeeds
This commit is contained in:
parent
46fba35c99
commit
f837a0431d
|
|
@ -217,7 +217,7 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
|
|||
@Override
|
||||
public void create() throws ResourceAllocationException{
|
||||
try {
|
||||
IpAddress ip = _networkService.allocateIP(_accountService.getAccount(getEntityOwnerId()), false, getZoneId());
|
||||
IpAddress ip = _networkService.allocateIP(_accountService.getAccount(getEntityOwnerId()), getZoneId());
|
||||
if (ip != null) {
|
||||
this.setEntityId(ip.getId());
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ public class EnableStaticNatCmd extends BaseCmd{
|
|||
@Override
|
||||
public void execute() throws ResourceUnavailableException{
|
||||
try {
|
||||
boolean result = _rulesService.enableStaticNat(ipAddressId, virtualMachineId, getNetworkId(), false);
|
||||
boolean result = _rulesService.enableStaticNat(ipAddressId, virtualMachineId, getNetworkId());
|
||||
if (result) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public interface NetworkService {
|
|||
List<? extends Network> getIsolatedNetworksOwnedByAccountInZone(long zoneId, Account owner);
|
||||
|
||||
|
||||
IpAddress allocateIP(Account ipOwner, boolean isSystem, long zoneId) throws ResourceAllocationException,
|
||||
IpAddress allocateIP(Account ipOwner, long zoneId) throws ResourceAllocationException,
|
||||
InsufficientAddressCapacityException, ConcurrentOperationException;
|
||||
|
||||
boolean releaseIpAddress(long ipAddressId) throws InsufficientAddressCapacityException;
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public interface RulesService {
|
|||
|
||||
boolean applyPortForwardingRules(long ipAdddressId, Account caller) throws ResourceUnavailableException;
|
||||
|
||||
boolean enableStaticNat(long ipAddressId, long vmId, long networkId, boolean isSystemVm) throws NetworkRuleConflictException, ResourceUnavailableException;
|
||||
boolean enableStaticNat(long ipAddressId, long vmId, long networkId) throws NetworkRuleConflictException, ResourceUnavailableException;
|
||||
|
||||
PortForwardingRule getPortForwardigRule(long ruleId);
|
||||
|
||||
|
|
|
|||
|
|
@ -1013,21 +1013,29 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_NET_IP_ASSIGN, eventDescription = "allocating Ip", create = true)
|
||||
public IpAddress allocateIP(Account ipOwner, boolean isSystem, long zoneId)
|
||||
public IpAddress allocateIP(Account ipOwner, long zoneId)
|
||||
throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException {
|
||||
return allocateIP(ipOwner, false, zoneId);
|
||||
}
|
||||
|
||||
private IpAddress allocateIP(Account ipOwner, boolean isSystem, long zoneId)
|
||||
throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException {
|
||||
Account caller = UserContext.current().getCaller();
|
||||
long callerUserId = UserContext.current().getCallerUserId();
|
||||
|
||||
// check permissions
|
||||
_accountMgr.checkAccess(caller, null, false, ipOwner);
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Associate IP address called by the user " + callerUserId + " account " + ipOwner.getId());
|
||||
}
|
||||
|
||||
DataCenter zone = _configMgr.getZone(zoneId);
|
||||
|
||||
return allocateIp(ipOwner, isSystem, caller, callerUserId, zone);
|
||||
return allocateIp(ipOwner, isSystem, caller, zone);
|
||||
}
|
||||
|
||||
@DB
|
||||
public IpAddress allocateIp(Account ipOwner, boolean isSystem, Account caller, long callerUserId, DataCenter zone)
|
||||
public IpAddress allocateIp(Account ipOwner, boolean isSystem, Account caller, DataCenter zone)
|
||||
throws ConcurrentOperationException, ResourceAllocationException,
|
||||
InsufficientAddressCapacityException {
|
||||
|
||||
|
|
@ -1046,9 +1054,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
Transaction txn = Transaction.currentTxn();
|
||||
Account accountToLock = null;
|
||||
try {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Associate IP address called by the user " + callerUserId + " account " + ipOwner.getId());
|
||||
}
|
||||
accountToLock = _accountDao.acquireInLockTable(ipOwner.getId());
|
||||
if (accountToLock == null) {
|
||||
s_logger.warn("Unable to lock account: " + ipOwner.getId());
|
||||
|
|
@ -6981,7 +6986,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
// allocate ip
|
||||
ip = allocateIP(owner, true, guestNetwork.getDataCenterId());
|
||||
// apply ip associations
|
||||
ip = associateIPToNetwork(ip.getId(), networkId);
|
||||
ip = associateIpToNetwork(ip.getId(), networkId);
|
||||
} catch (ResourceAllocationException ex) {
|
||||
throw new CloudRuntimeException("Failed to allocate system ip due to ", ex);
|
||||
} catch (ConcurrentOperationException ex) {
|
||||
|
|
@ -7143,7 +7148,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
@ActionEvent(eventType = EventTypes.EVENT_NET_IP_ASSIGN, eventDescription = "associating Ip", async = true)
|
||||
public IpAddress associateIPToNetwork(long ipId, long networkId) throws InsufficientAddressCapacityException,
|
||||
ResourceAllocationException, ResourceUnavailableException, ConcurrentOperationException {
|
||||
return associateIpToNetwork(ipId, networkId);
|
||||
}
|
||||
|
||||
private IpAddress associateIpToNetwork(long ipId, long networkId) throws InsufficientAddressCapacityException,
|
||||
ResourceAllocationException, ResourceUnavailableException, ConcurrentOperationException {
|
||||
Network network = _networksDao.findById(networkId);
|
||||
if (network == null) {
|
||||
throw new InvalidParameterValueException("Invalid network id is given", null);
|
||||
|
|
|
|||
|
|
@ -382,7 +382,11 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
|||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_ENABLE_STATIC_NAT, eventDescription = "enabling static nat")
|
||||
public boolean enableStaticNat(long ipId, long vmId, long networkId, boolean isSystemVm)
|
||||
public boolean enableStaticNat(long ipId, long vmId, long networkId) throws NetworkRuleConflictException, ResourceUnavailableException {
|
||||
return enableStaticNat(ipId, vmId, networkId, false);
|
||||
}
|
||||
|
||||
private boolean enableStaticNat(long ipId, long vmId, long networkId, boolean isSystemVm)
|
||||
throws NetworkRuleConflictException, ResourceUnavailableException {
|
||||
UserContext ctx = UserContext.current();
|
||||
Account caller = ctx.getCaller();
|
||||
|
|
|
|||
Loading…
Reference in New Issue