Shahar Havivi has uploaded a new change for review.

Change subject: core: Static IP is set as none bootproto for cloud-init
......................................................................

core: Static IP is set as none bootproto for cloud-init

1. Setting the bootproto for static if not dhcp (was set as none)
2. Adding display name for NetworkBootProtocol enum
3. Fix CloudInitHandler for sending nulls for ip and subnet on dhcp bootproto.

Change-Id: I53159a6ead92d890f7abe2ec78196bb967994a5f
Bug-Url: https://bugzilla.redhat.com/1036013
Signed-off-by: Shahar Havivi <shah...@redhat.com>
---
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/network/NetworkBootProtocol.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/CloudInitHandler.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInitModel.java
3 files changed, 21 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/09/27109/1

diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/network/NetworkBootProtocol.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/network/NetworkBootProtocol.java
index 6fffea3..93aaf21 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/network/NetworkBootProtocol.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/network/NetworkBootProtocol.java
@@ -6,10 +6,11 @@
 public enum NetworkBootProtocol {
     NONE(0),
     DHCP(1),
-    STATIC_IP(2);
+    STATIC_IP(2, "static");
 
     private int intValue;
     private static Map<Integer, NetworkBootProtocol> mappings;
+    private String displayName;
 
     static {
         mappings = new HashMap<Integer, NetworkBootProtocol>();
@@ -20,6 +21,12 @@
 
     private NetworkBootProtocol(int value) {
         intValue = value;
+        displayName = name().toLowerCase();
+    }
+
+    private NetworkBootProtocol(int value, String displayName) {
+        intValue = value;
+        this.displayName = displayName;
     }
 
     public int getValue() {
@@ -29,4 +36,8 @@
     public static NetworkBootProtocol forValue(int value) {
         return mappings.get(value);
     }
+
+    public String getDisplayName() {
+        return displayName;
+    }
 }
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/CloudInitHandler.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/CloudInitHandler.java
index 4e38cd8..829d4ce 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/CloudInitHandler.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/CloudInitHandler.java
@@ -133,10 +133,14 @@
 
             for (VmInitNetwork iface: networks) {
                 output.append("iface " + iface.getName() + " inet "
-                        + iface.getBootProtocol().toString().toLowerCase() + 
"\n");
-                output.append("  address " + iface.getIp() + "\n");
-                output.append("  netmask " + iface.getNetmask() + "\n");
-                if (!StringUtils.isEmpty(iface.getGateway())) {
+                        + iface.getBootProtocol().getDisplayName() + "\n");
+                if (StringUtils.isNotEmpty(iface.getIp())) {
+                    output.append("  address " + iface.getIp() + "\n");
+                }
+                if (StringUtils.isNotEmpty(iface.getNetmask())) {
+                    output.append("  netmask " + iface.getNetmask() + "\n");
+                }
+                if (StringUtils.isNotEmpty(iface.getGateway())) {
                     output.append("  gateway " + iface.getGateway() + "\n");
                 }
 
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInitModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInitModel.java
index 6559e2a..7925cbf 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInitModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInitModel.java
@@ -810,7 +810,7 @@
             VmInitNetwork obj = networkMap.get(lastSelectedNetworkName);
             if (obj != null) {
                 obj.setBootProtocol((getNetworkDhcp().getEntity() != null && 
(Boolean) getNetworkDhcp().getEntity())
-                                    ? NetworkBootProtocol.DHCP : 
NetworkBootProtocol.NONE);
+                                    ? NetworkBootProtocol.DHCP : 
NetworkBootProtocol.STATIC_IP);
                 obj.setIp((String) getNetworkIpAddress().getEntity());
                 obj.setNetmask((String) getNetworkNetmask().getEntity());
                 obj.setGateway((String) getNetworkGateway().getEntity());


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I53159a6ead92d890f7abe2ec78196bb967994a5f
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.4
Gerrit-Owner: Shahar Havivi <shav...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to