CLOUDSTACK-2317: NPE while cloudstack trying to get system ip and enable

static nat for the vm VM

splitting enableStaticNat() method in to a service and manager layer
method. So as to ensure action event annotation is present only on
service layer method.
This commit is contained in:
Murali Reddy 2013-05-03 15:37:25 +05:30
parent 3ae4819732
commit a3a5862301
3 changed files with 13 additions and 5 deletions

View File

@ -67,7 +67,7 @@ public interface RulesService {
boolean applyPortForwardingRules(long ipAdddressId, Account caller) throws ResourceUnavailableException;
boolean enableStaticNat(long ipAddressId, long vmId, long networkId, boolean isSystemVm, String vmGuestIp) throws NetworkRuleConflictException, ResourceUnavailableException;
boolean enableStaticNat(long ipAddressId, long vmId, long networkId, String vmGuestIp) throws NetworkRuleConflictException, ResourceUnavailableException;
PortForwardingRule getPortForwardigRule(long ruleId);

View File

@ -80,12 +80,14 @@ import com.cloud.utils.net.Ip;
import com.cloud.vm.Nic;
import com.cloud.vm.NicSecondaryIp;
import com.cloud.vm.UserVmVO;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachine.Type;
import com.cloud.vm.dao.NicDao;
import com.cloud.vm.dao.NicSecondaryIpDao;
import com.cloud.vm.dao.NicSecondaryIpVO;
import com.cloud.vm.dao.UserVmDao;
import com.cloud.vm.dao.VMInstanceDao;
@Component
@Local(value = { RulesManager.class, RulesService.class })
@ -103,6 +105,8 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules
@Inject
UserVmDao _vmDao;
@Inject
VMInstanceDao _vmInstanceDao;
@Inject
AccountManager _accountMgr;
@Inject
NetworkManager _networkMgr;
@ -416,7 +420,12 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules
@Override
@ActionEvent(eventType = EventTypes.EVENT_ENABLE_STATIC_NAT, eventDescription = "enabling static nat")
public boolean enableStaticNat(long ipId, long vmId, long networkId, boolean isSystemVm, String vmGuestIp)
public boolean enableStaticNat(long ipId, long vmId, long networkId, String vmGuestIp)
throws NetworkRuleConflictException, ResourceUnavailableException {
return enableStaticNat(ipId, vmId, networkId, false, vmGuestIp);
}
private boolean enableStaticNat(long ipId, long vmId, long networkId, boolean isSystemVm, String vmGuestIp)
throws NetworkRuleConflictException, ResourceUnavailableException {
UserContext ctx = UserContext.current();
Account caller = ctx.getCaller();
@ -1370,7 +1379,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules
throw new CloudRuntimeException("Ip address is not associated with any network");
}
UserVmVO vm = _vmDao.findById(sourceIp.getAssociatedWithVmId());
VMInstanceVO vm = _vmInstanceDao.findById(sourceIp.getAssociatedWithVmId());
Network network = _networkModel.getNetwork(networkId);
if (network == null) {
CloudRuntimeException ex = new CloudRuntimeException("Unable to find an ip address to map to specified vm id");

View File

@ -76,8 +76,7 @@ public class MockRulesManagerImpl extends ManagerBase implements RulesManager, R
@Override
public boolean enableStaticNat(long ipAddressId, long vmId, long networkId,
boolean isSystemVm, String ipAddr) throws NetworkRuleConflictException,
ResourceUnavailableException {
String ipAddr) throws NetworkRuleConflictException, ResourceUnavailableException {
// TODO Auto-generated method stub
return false;
}