cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ni...@apache.org
Subject git commit: updated refs/heads/master to c0f72b2
Date Thu, 08 May 2014 22:37:29 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 3f26eeb6e -> c0f72b25c


CLOUDSTACK-6530: Make Network and Volume implement Displayable interface. Iterate over all
first class entities in the context to decide the display property for event display.


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

Branch: refs/heads/master
Commit: c0f72b25c68927d2a3e469186d982afa9b8de965
Parents: 3f26eeb
Author: Nitin Mehta <nitin.mehta@citrix.com>
Authored: Thu May 8 15:36:25 2014 -0700
Committer: Nitin Mehta <nitin.mehta@citrix.com>
Committed: Thu May 8 15:37:20 2014 -0700

----------------------------------------------------------------------
 api/src/com/cloud/network/Network.java          |  6 ++-
 api/src/com/cloud/network/NetworkProfile.java   |  5 +++
 .../com/cloud/network/rules/FirewallRule.java   |  4 +-
 api/src/com/cloud/storage/Volume.java           |  6 ++-
 .../org/apache/cloudstack/api/BaseAsyncCmd.java | 24 ------------
 api/src/org/apache/cloudstack/api/BaseCmd.java  | 40 +++++++++++++++++++-
 .../command/user/network/CreateNetworkCmd.java  |  8 ++++
 .../api/command/user/vm/UpdateVMCmd.java        | 10 -----
 .../api/command/user/vm/UpgradeVMCmd.java       |  5 ---
 .../command/user/volume/CreateVolumeCmd.java    |  8 ++++
 .../command/user/volume/DeleteVolumeCmd.java    |  5 ---
 .../src/com/cloud/network/dao/NetworkVO.java    |  5 +++
 .../schema/src/com/cloud/storage/VolumeVO.java  |  9 +++++
 .../cloudstack/storage/volume/VolumeObject.java |  5 +++
 14 files changed, 92 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c0f72b25/api/src/com/cloud/network/Network.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/Network.java b/api/src/com/cloud/network/Network.java
index ef3bcdf..885bffe 100644
--- a/api/src/com/cloud/network/Network.java
+++ b/api/src/com/cloud/network/Network.java
@@ -22,6 +22,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.cloudstack.acl.ControlledEntity;
+import org.apache.cloudstack.api.Displayable;
 import org.apache.cloudstack.api.Identity;
 import org.apache.cloudstack.api.InternalIdentity;
 
@@ -34,7 +35,7 @@ import com.cloud.utils.fsm.StateObject;
 /**
  * owned by an account.
  */
-public interface Network extends ControlledEntity, StateObject<Network.State>, InternalIdentity,
Identity, Serializable {
+public interface Network extends ControlledEntity, StateObject<Network.State>, InternalIdentity,
Identity, Serializable, Displayable {
 
     public enum GuestType {
         Shared, Isolated
@@ -327,8 +328,11 @@ public interface Network extends ControlledEntity, StateObject<Network.State>,
I
 
     boolean getSpecifyIpRanges();
 
+    @Deprecated
     boolean getDisplayNetwork();
 
+    boolean isDisplay();
+
     String getGuruName();
 
     /**

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c0f72b25/api/src/com/cloud/network/NetworkProfile.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/NetworkProfile.java b/api/src/com/cloud/network/NetworkProfile.java
index db3cba5..1b806d5 100644
--- a/api/src/com/cloud/network/NetworkProfile.java
+++ b/api/src/com/cloud/network/NetworkProfile.java
@@ -249,6 +249,11 @@ public class NetworkProfile implements Network {
     }
 
     @Override
+    public boolean isDisplay(){
+        return displayNetwork;
+    }
+
+    @Override
     public Long getVpcId() {
         return vpcId;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c0f72b25/api/src/com/cloud/network/rules/FirewallRule.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/rules/FirewallRule.java b/api/src/com/cloud/network/rules/FirewallRule.java
index b02257b..4346e2f 100644
--- a/api/src/com/cloud/network/rules/FirewallRule.java
+++ b/api/src/com/cloud/network/rules/FirewallRule.java
@@ -19,10 +19,11 @@ package com.cloud.network.rules;
 import java.util.List;
 
 import org.apache.cloudstack.acl.ControlledEntity;
+import org.apache.cloudstack.api.Displayable;
 import org.apache.cloudstack.api.Identity;
 import org.apache.cloudstack.api.InternalIdentity;
 
-public interface FirewallRule extends ControlledEntity, Identity, InternalIdentity {
+public interface FirewallRule extends ControlledEntity, Identity, InternalIdentity, Displayable
{
     enum Purpose {
         Firewall, PortForwarding, LoadBalancing, Vpn, StaticNat, NetworkACL,
     }
@@ -87,6 +88,7 @@ public interface FirewallRule extends ControlledEntity, Identity, InternalIdenti
      */
     TrafficType getTrafficType();
 
+    @Override
     boolean isDisplay();
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c0f72b25/api/src/com/cloud/storage/Volume.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/storage/Volume.java b/api/src/com/cloud/storage/Volume.java
index b9c27d7..b67a395 100755
--- a/api/src/com/cloud/storage/Volume.java
+++ b/api/src/com/cloud/storage/Volume.java
@@ -19,6 +19,7 @@ package com.cloud.storage;
 import java.util.Date;
 
 import org.apache.cloudstack.acl.ControlledEntity;
+import org.apache.cloudstack.api.Displayable;
 import org.apache.cloudstack.api.Identity;
 import org.apache.cloudstack.api.InternalIdentity;
 
@@ -26,7 +27,7 @@ import com.cloud.template.BasedOn;
 import com.cloud.utils.fsm.StateMachine2;
 import com.cloud.utils.fsm.StateObject;
 
-public interface Volume extends ControlledEntity, Identity, InternalIdentity, BasedOn, StateObject<Volume.State>
{
+public interface Volume extends ControlledEntity, Identity, InternalIdentity, BasedOn, StateObject<Volume.State>,
Displayable {
     enum Type {
         UNKNOWN, ROOT, SWAP, DATADISK, ISO
     };
@@ -193,5 +194,8 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity,
Ba
 
     Integer getHypervisorSnapshotReserve();
 
+    @Deprecated
     boolean isDisplayVolume();
+
+    boolean isDisplay();
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c0f72b25/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java b/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java
index 82886aa..6b83d39 100644
--- a/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java
+++ b/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java
@@ -17,8 +17,6 @@
 package org.apache.cloudstack.api;
 
 
-import com.cloud.event.EventTypes;
-import org.apache.cloudstack.context.CallContext;
 import org.apache.log4j.Logger;
 
 /**
@@ -95,26 +93,4 @@ public abstract class BaseAsyncCmd extends BaseCmd {
         return job;
     }
 
-    @Override
-    public boolean isDisplay(){
-
-        // Get entity Class from the event name. Eg. - Volume.class
-        final CallContext ctx = CallContext.current();
-        Class entityClass = EventTypes.getEntityClassForEvent(getEventType());
-        boolean isDisplay = true;
-
-        try{
-            // If the entity Class implements Displayable interface then see the flag from
VO
-            if (entityClass != null && Displayable.class.isAssignableFrom(entityClass)){
-                Object objVO =_entityMgr.findById(entityClass, (Long)ctx.getContextParameter(entityClass.getName()));
-                isDisplay = ((Displayable)objVO).isDisplay();
-                ctx.setEventDisplayEnabled(isDisplay);
-            }
-        }catch (Exception e){
-           s_logger.trace("Caught exception while finding the display property, defaulting
to true and moving on " +e);
-        }
-
-        return isDisplay;
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c0f72b25/api/src/org/apache/cloudstack/api/BaseCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/BaseCmd.java b/api/src/org/apache/cloudstack/api/BaseCmd.java
index 6a4b4a8..ed7e983 100644
--- a/api/src/org/apache/cloudstack/api/BaseCmd.java
+++ b/api/src/org/apache/cloudstack/api/BaseCmd.java
@@ -361,6 +361,44 @@ public abstract class BaseCmd {
      * @return display flag
      */
     public boolean isDisplay(){
-        return true;
+        CallContext context = CallContext.current();
+        Map<Object, Object> contextMap = context.getContextParameters();
+        boolean isDisplay = true;
+
+        // Iterate over all the first class entities in context and check their display property.
+        for(Map.Entry<Object, Object> entry : contextMap.entrySet()){
+            try{
+                Object key = entry.getKey();
+                Class clz = Class.forName((String)key);
+                if(Displayable.class.isAssignableFrom(clz)){
+                    final Object objVO = _entityMgr.findById(clz, getInternalId(entry.getValue()));
+                    isDisplay = ((Displayable) objVO).isDisplay();
+                }
+
+                // If the flag is false break immediately
+                if(!isDisplay)
+                    break;
+            } catch (Exception e){
+                s_logger.trace("Caught exception while checking first class entities for
display property, continuing on", e);
+            }
+        }
+
+        context.setEventDisplayEnabled(isDisplay);
+        return isDisplay;
+
     }
+
+    private static Long getInternalId(Object internalIdObj){
+        Long internalId = null;
+
+        // In case its an async job the value would be a string because of json deserialization
+        if(internalIdObj instanceof String){
+            internalId = Long.valueOf((String) internalIdObj);
+        }else if (internalIdObj instanceof Long){
+            internalId = (Long) internalIdObj;
+        }
+
+        return internalId;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c0f72b25/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java
b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java
index 43c3d1b..40bf587 100644
--- a/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java
@@ -212,6 +212,14 @@ public class CreateNetworkCmd extends BaseCmd {
         return displayNetwork;
     }
 
+    @Override
+    public boolean isDisplay() {
+        if(displayNetwork == null)
+            return true;
+        else
+            return displayNetwork;
+    }
+
     public Long getZoneId() {
         Long physicalNetworkId = getPhysicalNetworkId();
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c0f72b25/api/src/org/apache/cloudstack/api/command/user/vm/UpdateVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/UpdateVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/UpdateVMCmd.java
index 0983642..d185b91 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vm/UpdateVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/UpdateVMCmd.java
@@ -157,16 +157,6 @@ public class UpdateVMCmd extends BaseCustomIdCmd {
     }
 
     @Override
-    public boolean isDisplay(){
-        UserVm userVm = _entityMgr.findById(UserVm.class, getId());
-        if (userVm != null) {
-            return userVm.isDisplayVm();
-        }
-
-        return true; // no info means true
-    }
-
-    @Override
     public void execute() throws ResourceUnavailableException, InsufficientCapacityException,
ServerApiException {
         CallContext.current().setEventDetails("Vm Id: " + getId());
         UserVm result = _userVmService.updateVirtualMachine(this);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c0f72b25/api/src/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java
index dec9243..b105555 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java
@@ -118,11 +118,6 @@ public class UpgradeVMCmd extends BaseCmd {
     }
 
     @Override
-    public boolean isDisplay(){
-        return _userVmService.isDisplayResourceEnabled(getId());
-    }
-
-    @Override
     public void execute() throws ResourceAllocationException {
         CallContext.current().setEventDetails("Vm Id: " + getId());
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c0f72b25/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java
index 90c1a16..dc91261 100644
--- a/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java
@@ -161,6 +161,14 @@ public class CreateVolumeCmd extends BaseAsyncCreateCustomIdCmd {
         return displayVolume;
     }
 
+    @Override
+    public boolean isDisplay() {
+        if(displayVolume == null)
+            return true;
+        else
+            return displayVolume;
+    }
+
     public Long getVirtualMachineId() {
         return virtualMachineId;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c0f72b25/api/src/org/apache/cloudstack/api/command/user/volume/DeleteVolumeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/DeleteVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/DeleteVolumeCmd.java
index 3e267b9..0b0c1b7 100644
--- a/api/src/org/apache/cloudstack/api/command/user/volume/DeleteVolumeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/DeleteVolumeCmd.java
@@ -80,11 +80,6 @@ public class DeleteVolumeCmd extends BaseCmd {
     }
 
     @Override
-    public boolean isDisplay(){
-        return _volumeService.isDisplayResourceEnabled(getId());
-    }
-
-    @Override
     public void execute() throws ConcurrentOperationException {
         CallContext.current().setEventDetails("Volume Id: " + getId());
         boolean result = _volumeService.deleteVolume(id, CallContext.current().getCallingAccount());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c0f72b25/engine/schema/src/com/cloud/network/dao/NetworkVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/NetworkVO.java b/engine/schema/src/com/cloud/network/dao/NetworkVO.java
index f1d7e7e..1b284de 100644
--- a/engine/schema/src/com/cloud/network/dao/NetworkVO.java
+++ b/engine/schema/src/com/cloud/network/dao/NetworkVO.java
@@ -578,6 +578,11 @@ public class NetworkVO implements Network {
     }
 
     @Override
+    public boolean isDisplay(){
+        return displayNetwork;
+    }
+
+    @Override
     public void setNetworkACLId(Long networkACLId) {
         this.networkACLId = networkACLId;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c0f72b25/engine/schema/src/com/cloud/storage/VolumeVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/VolumeVO.java b/engine/schema/src/com/cloud/storage/VolumeVO.java
index ec9afbe..e328253 100755
--- a/engine/schema/src/com/cloud/storage/VolumeVO.java
+++ b/engine/schema/src/com/cloud/storage/VolumeVO.java
@@ -567,6 +567,15 @@ public class VolumeVO implements Volume {
         return displayVolume;
     }
 
+    @Override
+    public  boolean isDisplay(){
+        return displayVolume;
+    }
+
+    public void setDisplay(boolean display){
+        this.displayVolume = display;
+    }
+
     public void setDisplayVolume(boolean displayVolume) {
         this.displayVolume = displayVolume;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c0f72b25/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java
b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java
index 08925d0..f2b4c95 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java
@@ -168,6 +168,11 @@ public class VolumeObject implements VolumeInfo {
         return volumeVO.isDisplayVolume();
     }
 
+    @Override
+    public boolean isDisplay() {
+        return volumeVO.isDisplay();
+    }
+
     public long getVolumeId() {
         return volumeVO.getId();
     }


Mime
View raw message