Frank Kobzik has uploaded a new change for review.

Change subject: engine: GraphicsInfo in entities
......................................................................

engine: GraphicsInfo in entities

This patch adds GraphicsInfo structure to VM and VmDynamic.

GraphicsInfo is a class that holds dynamic information about
GraphicsDevice (which contains static, non-runtime information only).

Change-Id: Ib11a8b63e76031f3137f2dfd0cd6551e9c19aca0
Signed-off-by: Frantisek Kobzik <[email protected]>
Bug-Url: https://bugzilla.redhat.com/1033547
---
A 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/GraphicsInfo.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/GraphicsType.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDynamic.java
M 
frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml
5 files changed, 85 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/69/28569/1

diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/GraphicsInfo.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/GraphicsInfo.java
new file mode 100644
index 0000000..85fb634
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/GraphicsInfo.java
@@ -0,0 +1,56 @@
+package org.ovirt.engine.core.common.businessentities;
+
+import java.io.Serializable;
+
+public class GraphicsInfo implements Serializable {
+
+    private static final long serialVersionUID = -633727623243243619L;
+
+    private String ip;
+    private Integer port;
+    private Integer tlsPort;
+
+    public GraphicsInfo() { }
+
+
+    /**
+     * Return true if the class is in usable state (the class can serve as a 
null object as well and purpose of this
+     * is to have instance of the class non-null in vm dynamic - this will 
save a lot of non-necessary null checks).
+     */
+    public boolean isSet() {
+        return port != null || tlsPort != null;
+    }
+
+    public String getIp() {
+        return ip;
+    }
+
+    public Integer getPort() {
+        return port;
+    }
+
+    public Integer getTlsPort() {
+        return tlsPort;
+    }
+
+    public GraphicsInfo setIp(String ip) {
+        this.ip = ip;
+        return this;
+    }
+
+    public GraphicsInfo setPort(Integer port) {
+        this.port = port;
+        return this;
+    }
+
+    public GraphicsInfo setTlsPort(Integer tlsPort) {
+        this.tlsPort = tlsPort;
+        return this;
+    }
+
+    public GraphicsInfo update(GraphicsInfo other) {
+        return setPort(other.getPort())
+                .setTlsPort(other.getTlsPort())
+                .setIp(other.getIp());
+    }
+}
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/GraphicsType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/GraphicsType.java
index a8b8e22..b203270 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/GraphicsType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/GraphicsType.java
@@ -13,6 +13,16 @@
         this.devType = type;
     }
 
+    public static GraphicsType fromString(String s) {
+        for (GraphicsType graphicsType : GraphicsType.values()) {
+            if (graphicsType.toString().equalsIgnoreCase(s)) {
+                return graphicsType;
+            }
+        }
+
+        return null;
+    }
+
     public VmDeviceType getCorrespondingDeviceType() {
         return devType;
     }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java
index 8d507f1..e3b60b1 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java
@@ -380,6 +380,10 @@
         vmStatic.setDefaultDisplayType(value);
     }
 
+    public Map<GraphicsType, GraphicsInfo> getGraphicsInfos() {
+        return vmDynamic.getGraphicsInfos();
+    }
+
     public int getPriority() {
         return vmStatic.getPriority();
     }
@@ -1284,6 +1288,7 @@
         setVmPauseStatus(vm.getPauseStatus());
         setLastWatchdogEvent(vm.getLastWatchdogEvent());
         setGuestCpuCount(vm.getGuestCpuCount());
+        getGraphicsInfos().putAll(vm.getGraphicsInfos());
         // TODO: check what to do with update disk data
         // updateDisksData(vm);
 
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDynamic.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDynamic.java
index ca32358..adc9b45 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDynamic.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDynamic.java
@@ -3,6 +3,8 @@
 import java.util.ArrayList;
 import java.util.Date;
 
+import java.util.HashMap;
+import java.util.Map;
 import 
org.ovirt.engine.core.common.businessentities.comparators.BusinessEntityGuidComparator;
 import org.ovirt.engine.core.common.utils.ObjectUtils;
 import org.ovirt.engine.core.compat.Guid;
@@ -71,6 +73,10 @@
     private String stopReason;
     private VmExitReason exitReason;
     private int guestCpuCount;
+    @UnchangeableByVdsm
+    private String overridenConsoleAddress;
+    private String vdsHostName;
+    private Map<GraphicsType, GraphicsInfo> graphicsInfos;
 
     public static final String APPLICATIONS_LIST_FIELD_NAME = "appList";
     public static final String STATUS_FIELD_NAME = "status";
@@ -242,6 +248,9 @@
         session = SessionState.Unknown;
         bootSequence = BootSequence.C;
         exitReason = VmExitReason.Unknown;
+        graphicsInfos = new HashMap<GraphicsType, GraphicsInfo>();
+        graphicsInfos.put(GraphicsType.SPICE, new GraphicsInfo());
+        graphicsInfos.put(GraphicsType.VNC, new GraphicsInfo());
     }
 
     public String getAppList() {
@@ -392,6 +401,10 @@
         this.display = value;
     }
 
+    public Map<GraphicsType, GraphicsInfo> getGraphicsInfos() { // todo rename 
this awful thing! lol
+        return graphicsInfos;
+    }
+
     public Boolean getAcpiEnable() {
         return this.acpiEnabled;
     }
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml
 
b/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml
index 52aa654..68fa29c 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml
@@ -36,6 +36,7 @@
                <include name="common/businessentities/DisplayType.java" />
         <include name="common/businessentities/GraphicsDevice.java" />
         <include name="common/businessentities/GraphicsType.java" />
+        <include name="common/businessentities/GraphicsInfo.java" />
                <include name="common/businessentities/event_subscriber.java" />
                <include 
name="common/businessentities/event_subscriber_id.java" />
                <include name="common/businessentities/DbGroup.java" />


-- 
To view, visit http://gerrit.ovirt.org/28569
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib11a8b63e76031f3137f2dfd0cd6551e9c19aca0
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Frank Kobzik <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to