Frank Kobzik has uploaded a new change for review.

Change subject: restapi: Allow enabling/disabling SSO
......................................................................

restapi: Allow enabling/disabling SSO

This small feature allows controlling SSO per VM via REST API.

Change-Id: I25bf94646ea89684152e48f25ad604db6e59e86c
Bug-Url: https://bugzilla.redhat.com/1035279
Signed-off-by: Frantisek Kobzik <[email protected]>
---
M 
backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
M 
backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml
M 
backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/TemplateMapper.java
M 
backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java
A 
backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/utils/SsoMethodUtils.java
M 
backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/TemplateMapperTest.java
M 
backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/VmMapperTest.java
7 files changed, 75 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/11/21911/1

diff --git 
a/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
 
b/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
index 365e36f..e65da5a 100644
--- 
a/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
+++ 
b/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
@@ -2236,6 +2236,7 @@
           <xs:element name="display" type="Display" minOccurs="0" 
maxOccurs="1"/>
           <xs:element name="stateless" type="xs:boolean" minOccurs="0"/>
           <xs:element name="delete_protected" type="xs:boolean" minOccurs="0"/>
+          <xs:element name="sso_method" type="SsoMethod" minOccurs="0" 
maxOccurs="1"/>
           <xs:element ref="console" minOccurs="0" maxOccurs="1"/>
           <xs:element name="timezone" type="xs:string" minOccurs="0" 
maxOccurs="1"/>
           <xs:element ref="domain" minOccurs="0" maxOccurs="1"/>
@@ -2294,6 +2295,13 @@
     </xs:sequence>
     <xs:attribute name="type" type="xs:string"/>
   </xs:complexType>
+
+  <xs:simpleType name="SsoMethod">
+    <xs:restriction base="xs:string">
+      <xs:enumeration value="NONE"/>
+      <xs:enumeration value="GUEST_AGENT"/>
+    </xs:restriction>
+  </xs:simpleType>
 
   <xs:complexType name="HighAvailability">
     <xs:sequence>
@@ -2502,6 +2510,7 @@
           <xs:element name="origin" type="xs:string" minOccurs="0"/>
           <xs:element name="stateless" type="xs:boolean" minOccurs="0"/>
           <xs:element name="delete_protected" type="xs:boolean" minOccurs="0"/>
+          <xs:element name="sso_method" type="SsoMethod" minOccurs="0" 
maxOccurs="1"/>
           <xs:element ref="console" minOccurs="0" maxOccurs="1"/>
           <xs:element name="timezone" type="xs:string" minOccurs="0" 
maxOccurs="1"/>
           <xs:element ref="domain" minOccurs="0" maxOccurs="1"/>
diff --git 
a/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml
 
b/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml
index 7ba6ea1..e8d673a 100644
--- 
a/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml
+++ 
b/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml
@@ -75,6 +75,7 @@
           vm.comment: xs:string
           vm.stateless: xs:boolean
           vm.delete_protected: xs:boolean
+          vm.sso_method: xs:string
           vm.console.enabled: xs:boolean
           vm.cpu.topology.sockets: xs:int
           vm.placement_policy.affinity: xs:string
@@ -143,6 +144,7 @@
           vm.stateless: xs:boolean
           vm.permissions.clone: xs:boolean
           vm.delete_protected: xs:boolean
+          vm.sso_method: xs:string
           vm.console.enabled: xs:boolean
           vm.cpu.mode: xs:string
           vm.cpu.topology.sockets: xs:int
@@ -190,6 +192,7 @@
           vm.comment: xs:string
           vm.stateless: xs:boolean
           vm.delete_protected: xs:boolean
+          vm.sso_method: xs:string
           vm.console.enabled: xs:boolean
           vm.cpu.topology.sockets: xs:int
           vm.placement_policy.affinity: xs:string
@@ -231,6 +234,7 @@
                 vm.stateless: xs:boolean
                 vm.permissions.clone: xs:boolean
                 vm.delete_protected: xs:boolean
+                vm.sso_method: xs:string
                 vm.cpu.mode: xs:string
                 vm.cpu.topology.sockets: xs:int
                 vm.placement_policy.affinity: xs:string
@@ -3151,6 +3155,7 @@
           template.type: xs:string
           template.stateless: 'xs:boolean'
           template.delete_protected: xs:boolean
+          template.sso_method: xs:string
           template.console.enabled: xs:boolean
           template.placement_policy.affinity: xs:string
           template.description: xs:string
@@ -3196,6 +3201,7 @@
           template.type: xs:string
           template.stateless: 'xs:boolean'
           template.delete_protected: xs:boolean
+          template.sso_method: xs:string
           template.console.enabled: xs:boolean
           template.placement_policy.affinity: xs:string
           template.description: xs:string
diff --git 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/TemplateMapper.java
 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/TemplateMapper.java
index 7aee446..4b945e3 100644
--- 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/TemplateMapper.java
+++ 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/TemplateMapper.java
@@ -16,6 +16,7 @@
 import org.ovirt.engine.api.model.UsbType;
 import org.ovirt.engine.api.model.VmType;
 import org.ovirt.engine.api.restapi.utils.GuidUtils;
+import org.ovirt.engine.api.restapi.utils.SsoMethodUtils;
 import org.ovirt.engine.api.restapi.utils.UsbMapperUtils;
 import org.ovirt.engine.core.common.action.UpdateVmTemplateParameters;
 import org.ovirt.engine.core.common.businessentities.OriginType;
@@ -60,6 +61,9 @@
         }
         if (model.isSetDeleteProtected()) {
             entity.setDeleteProtected(model.isDeleteProtected());
+        }
+        if (model.isSetSsoMethod()) {
+            
entity.setSsoMethod(SsoMethodUtils.fromRestToBackend(model.getSsoMethod()));
         }
         if (model.isSetType()) {
             VmType vmType = VmType.fromValue(model.getType());
@@ -176,6 +180,9 @@
         if (model.isSetDeleteProtected()) {
             staticVm.setDeleteProtected(model.isDeleteProtected());
         }
+        if (model.isSetSsoMethod()) {
+            
staticVm.setSsoMethod(SsoMethodUtils.fromRestToBackend(model.getSsoMethod()));
+        }
         if (model.isSetType()) {
             VmType vmType = VmType.fromValue(model.getType());
             if (vmType != null) {
@@ -268,6 +275,7 @@
         model.getHighAvailability().setPriority(entity.getPriority());
         model.setStateless(entity.isStateless());
         model.setDeleteProtected(entity.isDeleteProtected());
+        
model.setSsoMethod(SsoMethodUtils.fromBackendToRest(entity.getSsoMethod()));
         if (entity.getVmType() != null) {
             model.setType(VmMapper.map(entity.getVmType(), null));
         }
diff --git 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java
 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java
index 054a97b..1ae9c85 100644
--- 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java
+++ 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java
@@ -54,6 +54,7 @@
 import org.ovirt.engine.api.model.VmType;
 import org.ovirt.engine.api.restapi.utils.CustomPropertiesParser;
 import org.ovirt.engine.api.restapi.utils.GuidUtils;
+import org.ovirt.engine.api.restapi.utils.SsoMethodUtils;
 import org.ovirt.engine.api.restapi.utils.UsbMapperUtils;
 import org.ovirt.engine.core.common.action.CloudInitParameters;
 import org.ovirt.engine.core.common.action.CloudInitParameters.Attachment;
@@ -97,6 +98,7 @@
         staticVm.setAutoStartup(entity.isAutoStartup());
         staticVm.setStateless(entity.isStateless());
         staticVm.setDeleteProtected(entity.isDeleteProtected());
+        staticVm.setSsoMethod(entity.getSsoMethod());
         staticVm.setSmartcardEnabled(entity.isSmartcardEnabled());
         staticVm.setAutoStartup(entity.isAutoStartup());
         staticVm.setDefaultBootSequence(entity.getDefaultBootSequence());
@@ -193,6 +195,9 @@
         }
         if (vm.isSetDeleteProtected()) {
             staticVm.setDeleteProtected(vm.isDeleteProtected());
+        }
+        if (vm.isSetSsoMethod()) {
+            
staticVm.setSsoMethod(SsoMethodUtils.fromRestToBackend(vm.getSsoMethod()));
         }
         if (vm.isSetHighAvailability()) {
             HighAvailability ha = vm.getHighAvailability();
@@ -429,6 +434,7 @@
         model.setType(map(entity.getVmType(), null));
         model.setStateless(entity.isStateless());
         model.setDeleteProtected(entity.isDeleteProtected());
+        
model.setSsoMethod(SsoMethodUtils.fromBackendToRest(entity.getSsoMethod()));
         model.setHighAvailability(new HighAvailability());
         model.getHighAvailability().setEnabled(entity.isAutoStartup());
         model.getHighAvailability().setPriority(entity.getPriority());
@@ -637,6 +643,19 @@
         }
     }
 
+    @Mapping(from =  org.ovirt.engine.api.model.SsoMethod.class, to = 
org.ovirt.engine.core.common.businessentities.SsoMethod.class)
+    public static org.ovirt.engine.core.common.businessentities.SsoMethod 
map(org.ovirt.engine.api.model.SsoMethod ssoMethod, 
org.ovirt.engine.core.common.businessentities.SsoMethod incoming) {
+        return SsoMethodUtils.fromRestToBackend(ssoMethod);
+    }
+
+    @Mapping(from = 
org.ovirt.engine.core.common.businessentities.SsoMethod.class, to = 
String.class)
+    public static String 
map(org.ovirt.engine.core.common.businessentities.SsoMethod ssoMethod, String 
incoming) {
+        org.ovirt.engine.api.model.SsoMethod ssoMethodRest = 
SsoMethodUtils.fromBackendToRest(ssoMethod);
+        return ssoMethodRest != null
+            ? ssoMethodRest.value()
+            : null;
+    }
+
     @Mapping(from = String.class, to = OriginType.class)
     public static OriginType map(String type, OriginType incoming) {
         try {
diff --git 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/utils/SsoMethodUtils.java
 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/utils/SsoMethodUtils.java
new file mode 100644
index 0000000..76fc2bd
--- /dev/null
+++ 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/utils/SsoMethodUtils.java
@@ -0,0 +1,31 @@
+package org.ovirt.engine.api.restapi.utils;
+
+import org.ovirt.engine.api.model.SsoMethod;
+
+public class SsoMethodUtils {
+
+    public static org.ovirt.engine.api.model.SsoMethod 
fromBackendToRest(org.ovirt.engine.core.common.businessentities.SsoMethod 
backendValue) {
+        if (backendValue != null) {
+            switch (backendValue) {
+                case GUEST_AGENT:
+                    return SsoMethod.GUEST_AGENT;
+                case NONE:
+                    return SsoMethod.NONE;
+            }
+        }
+        return null;
+    }
+
+    public static org.ovirt.engine.core.common.businessentities.SsoMethod 
fromRestToBackend(org.ovirt.engine.api.model.SsoMethod restValue) {
+        if (restValue != null) {
+            switch (restValue) {
+                case GUEST_AGENT:
+                    return 
org.ovirt.engine.core.common.businessentities.SsoMethod.GUEST_AGENT;
+                case NONE:
+                    return 
org.ovirt.engine.core.common.businessentities.SsoMethod.NONE;
+            }
+        }
+        return null;
+    }
+
+}
diff --git 
a/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/TemplateMapperTest.java
 
b/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/TemplateMapperTest.java
index d206616..1861d58 100644
--- 
a/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/TemplateMapperTest.java
+++ 
b/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/TemplateMapperTest.java
@@ -78,6 +78,7 @@
         assertEquals(model.getTimezone(), transform.getTimezone());
         assertEquals(model.getDisplay().isSmartcardEnabled(), 
transform.getDisplay().isSmartcardEnabled());
         assertEquals(model.isDeleteProtected(), transform.isDeleteProtected());
+        assertEquals(model.getSsoMethod(), transform.getSsoMethod());
         assertEquals(model.isTunnelMigration(), transform.isTunnelMigration());
     }
 }
diff --git 
a/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/VmMapperTest.java
 
b/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/VmMapperTest.java
index 25bbb38..efa7329 100644
--- 
a/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/VmMapperTest.java
+++ 
b/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/VmMapperTest.java
@@ -134,6 +134,7 @@
         assertEquals(model.getDisplay().isSmartcardEnabled(), 
transform.getDisplay().isSmartcardEnabled());
         assertEquals(model.getDisplay().getKeyboardLayout(), 
transform.getDisplay().getKeyboardLayout());
         assertEquals(model.isDeleteProtected(), transform.isDeleteProtected());
+        assertEquals(model.getSsoMethod(), transform.getSsoMethod());
         assertEquals(model.isTunnelMigration(), transform.isTunnelMigration());
     }
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I25bf94646ea89684152e48f25ad604db6e59e86c
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