You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ki...@apache.org on 2013/05/03 15:15:19 UTC
[37/50] [abbrv] git commit: updated refs/heads/network_acl to 1609d01
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.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/a3a58623
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/a3a58623
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/a3a58623
Branch: refs/heads/network_acl
Commit: a3a5862301b5b3d79abcf8dfef66283728954d55
Parents: 3ae4819
Author: Murali Reddy <mu...@citrix.com>
Authored: Fri May 3 15:37:25 2013 +0530
Committer: Murali Reddy <mu...@citrix.com>
Committed: Fri May 3 15:37:25 2013 +0530
----------------------------------------------------------------------
api/src/com/cloud/network/rules/RulesService.java | 2 +-
.../com/cloud/network/rules/RulesManagerImpl.java | 13 +++++++++++--
.../com/cloud/network/MockRulesManagerImpl.java | 3 +--
3 files changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a3a58623/api/src/com/cloud/network/rules/RulesService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/rules/RulesService.java b/api/src/com/cloud/network/rules/RulesService.java
index d47b38f..45abd84 100644
--- a/api/src/com/cloud/network/rules/RulesService.java
+++ b/api/src/com/cloud/network/rules/RulesService.java
@@ -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);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a3a58623/server/src/com/cloud/network/rules/RulesManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/RulesManagerImpl.java b/server/src/com/cloud/network/rules/RulesManagerImpl.java
index 8636d85..2355635 100755
--- a/server/src/com/cloud/network/rules/RulesManagerImpl.java
+++ b/server/src/com/cloud/network/rules/RulesManagerImpl.java
@@ -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");
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a3a58623/server/test/com/cloud/network/MockRulesManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/network/MockRulesManagerImpl.java b/server/test/com/cloud/network/MockRulesManagerImpl.java
index e5a6894..200fd2c 100644
--- a/server/test/com/cloud/network/MockRulesManagerImpl.java
+++ b/server/test/com/cloud/network/MockRulesManagerImpl.java
@@ -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;
}