CLOUDSTACK-685: This is the additional patch for CLOUDSTACK-685 (and
CLOUDSTACK-721 as well) after this commit
https://git-wip-us.apache.org/repos/asf/cloudstack/repo?p=cloudstack.git;a=commit;h=cd7f7716155c3cd2d29b97d7ea302518d81fdfab

PrepareStop part in VirtualNetworkApplianceImpl.java need to be changed
as well.

Signed-off-by: Chip Childers <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/aed9a623
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/aed9a623
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/aed9a623

Branch: refs/heads/4.1
Commit: aed9a623d81c922af53e9c1f7116c1c7c85fdda5
Parents: e6af3bf
Author: Wei Zhou <[email protected]>
Authored: Wed May 15 15:54:51 2013 +0100
Committer: Chip Childers <[email protected]>
Committed: Wed May 15 15:54:51 2013 +0100

----------------------------------------------------------------------
 .../router/VirtualNetworkApplianceManagerImpl.java |   33 ++++++++-------
 1 files changed, 18 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/aed9a623/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git 
a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java 
b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index 57f9493..e895a46 100755
--- 
a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ 
b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -3628,26 +3628,29 @@ public class VirtualNetworkApplianceManagerImpl extends 
ManagerBase implements V
         String privateIP = router.getPrivateIpAddress();
 
         if (privateIP != null) {
+            boolean forVpc = router.getVpcId() != null;
             List<? extends Nic> routerNics = 
_nicDao.listByVmId(router.getId());
             for (Nic routerNic : routerNics) {
                 Network network = 
_networkModel.getNetwork(routerNic.getNetworkId());
-                if (network.getTrafficType() == TrafficType.Public) {
-                    boolean forVpc = router.getVpcId() != null;
+                //Send network usage command for public nic in VPC VR
+                //Send network usage command for isolated guest nic of non VPC 
VR
+                if ((forVpc && network.getTrafficType() == TrafficType.Public) 
|| (!forVpc && network.getTrafficType() == TrafficType.Guest && 
network.getGuestType() == Network.GuestType.Isolated)) {
                     final NetworkUsageCommand usageCmd = new 
NetworkUsageCommand(privateIP, router.getHostName(),
                             forVpc, routerNic.getIp4Address());
+                    String routerType = router.getType().toString();
                     UserStatisticsVO previousStats = 
_userStatsDao.findBy(router.getAccountId(),
-                            router.getDataCenterId(), network.getId(), null, 
router.getId(), router.getType().toString());
+                            router.getDataCenterId(), network.getId(), (forVpc 
? routerNic.getIp4Address() : null), router.getId(), routerType);
                     NetworkUsageAnswer answer = null;
                     try {
                         answer = (NetworkUsageAnswer) 
_agentMgr.easySend(router.getHostId(), usageCmd);
                     } catch (Exception e) {
-                        s_logger.warn("Error while collecting network stats 
from router: "+router.getInstanceName()+" from host: "+router.getHostId(), e);
+                        s_logger.warn("Error while collecting network stats 
from router: " + router.getInstanceName() + " from host: " + 
router.getHostId(), e);
                         continue;
                     }
 
                     if (answer != null) {
                         if (!answer.getResult()) {
-                            s_logger.warn("Error while collecting network 
stats from router: "+router.getInstanceName()+" from host: "+router.getHostId() 
+ "; details: " + answer.getDetails());
+                            s_logger.warn("Error while collecting network 
stats from router: " + router.getInstanceName() + " from host: " + 
router.getHostId() + "; details: " + answer.getDetails());
                             continue;
                         }
                         Transaction txn = 
Transaction.open(Transaction.CLOUD_DB);
@@ -3658,26 +3661,26 @@ public class VirtualNetworkApplianceManagerImpl extends 
ManagerBase implements V
                             }
                             txn.start();
                             UserStatisticsVO stats = 
_userStatsDao.lock(router.getAccountId(),
-                                    router.getDataCenterId(), network.getId(), 
null, router.getId(), router.getType().toString());
+                                    router.getDataCenterId(), network.getId(), 
(forVpc ? routerNic.getIp4Address() : null), router.getId(), routerType);
                             if (stats == null) {
                                 s_logger.warn("unable to find stats for 
account: " + router.getAccountId());
                                 continue;
                             }
 
-                            if(previousStats != null 
-                                    && 
((previousStats.getCurrentBytesReceived() != stats.getCurrentBytesReceived()) 
-                                            || 
(previousStats.getCurrentBytesSent() != stats.getCurrentBytesSent()))){
+                            if (previousStats != null
+                                    && 
((previousStats.getCurrentBytesReceived() != stats.getCurrentBytesReceived())
+                                    || (previousStats.getCurrentBytesSent() != 
stats.getCurrentBytesSent()))){
                                 s_logger.debug("Router stats changed from the 
time NetworkUsageCommand was sent. " +
-                                        "Ignoring current answer. Router: 
"+answer.getRouterName()+" Rcvd: " + 
-                                        answer.getBytesReceived()+ "Sent: " 
+answer.getBytesSent());
+                                        "Ignoring current answer. Router: " + 
answer.getRouterName() + " Rcvd: " +
+                                        answer.getBytesReceived() + "Sent: " + 
answer.getBytesSent());
                                 continue;
                             }
 
                             if (stats.getCurrentBytesReceived() > 
answer.getBytesReceived()) {
                                 if (s_logger.isDebugEnabled()) {
                                     s_logger.debug("Received # of bytes that's 
less than the last one.  " +
-                                            "Assuming something went wrong and 
persisting it. Router: " + 
-                                            answer.getRouterName()+" Reported: 
" + answer.getBytesReceived()
+                                            "Assuming something went wrong and 
persisting it. Router: " +
+                                            answer.getRouterName() + " 
Reported: " + answer.getBytesReceived()
                                             + " Stored: " + 
stats.getCurrentBytesReceived());
                                 }
                                 
stats.setNetBytesReceived(stats.getNetBytesReceived() + 
stats.getCurrentBytesReceived());
@@ -3686,8 +3689,8 @@ public class VirtualNetworkApplianceManagerImpl extends 
ManagerBase implements V
                             if (stats.getCurrentBytesSent() > 
answer.getBytesSent()) {
                                 if (s_logger.isDebugEnabled()) {
                                     s_logger.debug("Received # of bytes that's 
less than the last one.  " +
-                                            "Assuming something went wrong and 
persisting it. Router: " + 
-                                            answer.getRouterName()+" Reported: 
" + answer.getBytesSent()
+                                            "Assuming something went wrong and 
persisting it. Router: " +
+                                            answer.getRouterName() + " 
Reported: " + answer.getBytesSent()
                                             + " Stored: " + 
stats.getCurrentBytesSent());
                                 }
                                 stats.setNetBytesSent(stats.getNetBytesSent() 
+ stats.getCurrentBytesSent());

Reply via email to