Mike Kolesnik has uploaded a new change for review.

Change subject: restapi: Don't set bootproto on VLAN attach to NIC
......................................................................

restapi: Don't set bootproto on VLAN attach to NIC

Setting the boot protocol on attaching a network to a host's NIC causes
the new VLAN to get the same boot parameters as the NIC itself, which
makes little sense as the VLAN is a different L2 network and it's boot
protocol info should be set accordingly and not automatically.

Change-Id: I78b415592e2bc1a9fea901cadb3ee928f2935a14
Bug-Url: https://bugzilla.redhat.com/??????
Signed-off-by: Mike Kolesnik <[email protected]>
---
M 
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendHostNicResource.java
M 
backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendHostNicResourceTest.java
M 
backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendHostNicsResourceTest.java
3 files changed, 34 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/40/17140/1

diff --git 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendHostNicResource.java
 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendHostNicResource.java
index 3658d6a..a7aa0fc 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendHostNicResource.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendHostNicResource.java
@@ -51,13 +51,18 @@
 
     protected Response doAttachAction(Action action, VdcActionType actionType) 
{
         VdsNetworkInterface hostInterface = parent.lookupInterface(id);
+        org.ovirt.engine.core.common.businessentities.network.Network network =
+                action.getNetwork() == null ? null : 
parent.lookupNetwork(action.getNetwork());
         AttachNetworkToVdsParameters params = new 
AttachNetworkToVdsParameters(asGuid(parent.getHostId()),
-                                                                               
action.getNetwork()==null ? null : parent.lookupNetwork(action.getNetwork()),
+                                                                               
network,
                                                                                
hostInterface);
         params.setBondingOptions(hostInterface.getBondOptions());
-        params.setBootProtocol(hostInterface.getBootProtocol());
-        params.setAddress(hostInterface.getAddress());
-        params.setSubnet(hostInterface.getSubnet());
+
+        if (network == null || network.getVlanId() == null) {
+            params.setBootProtocol(hostInterface.getBootProtocol());
+            params.setAddress(hostInterface.getAddress());
+            params.setSubnet(hostInterface.getSubnet());
+        }
 
         return doAction(actionType, params, action);
     }
diff --git 
a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendHostNicResourceTest.java
 
b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendHostNicResourceTest.java
index b5fba7e..7948beb 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendHostNicResourceTest.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendHostNicResourceTest.java
@@ -1,6 +1,7 @@
 package org.ovirt.engine.api.restapi.resource;
 
 import static org.easymock.EasyMock.expect;
+import static 
org.ovirt.engine.api.restapi.resource.BackendHostNicsResourceTest.BOOT_PROTOCOL;
 import static 
org.ovirt.engine.api.restapi.resource.BackendHostNicsResourceTest.NETWORK_GUID;
 import static 
org.ovirt.engine.api.restapi.resource.BackendHostNicsResourceTest.NETWORK_NAME;
 import static 
org.ovirt.engine.api.restapi.resource.BackendHostNicsResourceTest.PARENT_GUID;
@@ -27,6 +28,7 @@
 import org.ovirt.engine.core.common.action.UpdateNetworkToVdsParameters;
 import org.ovirt.engine.core.common.action.VdcActionType;
 import org.ovirt.engine.core.common.businessentities.VDS;
+import 
org.ovirt.engine.core.common.businessentities.network.NetworkBootProtocol;
 import 
org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface;
 import 
org.ovirt.engine.core.common.businessentities.network.VdsNetworkStatistics;
 import org.ovirt.engine.core.common.queries.IdQueryParameters;
@@ -144,6 +146,15 @@
     @Test
     public void testAttachNotFound() throws Exception {
         testActionNotFound(VdcActionType.AttachNetworkToVdsInterface);
+    }
+
+    @Test
+    public void testAttachVlan() throws Exception {
+        testAction(VdcActionType.AttachNetworkToVdsInterface,
+                null,
+                NETWORK_NAME,
+                new AttachNetworkToVdsParameters().getBootProtocol(),
+                100);
     }
 
     @Test
@@ -361,6 +372,14 @@
 
 
     protected void testAction(VdcActionType actionType, String networkId, 
String networkName) throws Exception {
+        testAction(actionType, networkId, networkName, BOOT_PROTOCOL, null);
+    }
+
+    protected void testAction(VdcActionType actionType,
+            String networkId,
+            String networkName,
+            NetworkBootProtocol bootProtocol,
+            Integer vlanId) throws Exception {
         Action action = new Action();
         action.setNetwork(new Network());
         if (networkId != null) {
@@ -369,18 +388,20 @@
             action.getNetwork().setName(networkName);
         }
 
+        org.ovirt.engine.core.common.businessentities.network.Network network 
= getNetwork();
+        network.setVlanId(vlanId);
         setUpEntityQueryExpectations(VdcQueryType.GetAllNetworks,
                                      IdQueryParameters.class,
                                      new String[] { "Id" },
                                      new Object[] { Guid.Empty },
-                                     asList(getNetwork()));
+                                     asList(network));
 
         setUpEntityQueryExpectations();
 
         setUriInfo(setUpActionExpectations(actionType,
                                            AttachNetworkToVdsParameters.class,
-                                           new String[] { "VdsId" },
-                                           new Object[] { PARENT_GUID },
+                                           new String[] { "VdsId", 
"BootProtocol" },
+                                           new Object[] { PARENT_GUID, 
bootProtocol },
                                            true,
                                            true,
                                            null,
diff --git 
a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendHostNicsResourceTest.java
 
b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendHostNicsResourceTest.java
index 175b83b..5316f30 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendHostNicsResourceTest.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendHostNicsResourceTest.java
@@ -41,6 +41,7 @@
     public static final Guid PARENT_GUID = GUIDS[0];
     public static final Guid NETWORK_GUID = new 
Guid("33333333-3333-3333-3333-333333333333");
     public static final String NETWORK_NAME = "skynet";
+    public static final NetworkBootProtocol BOOT_PROTOCOL = 
NetworkBootProtocol.STATIC_IP;
     private static final Guid MASTER_GUID = new 
Guid("99999999-9999-9999-9999-999999999999");
     private static final String MASTER_NAME = "master";
     private static final Guid SLAVE_GUID = new 
Guid("66666666-6666-6666-6666-666666666666");
@@ -48,7 +49,6 @@
     private static final int SINGLE_NIC_IDX = GUIDS.length - 2;
     private static final Integer NIC_SPEED = 100;
     private static final InterfaceStatus NIC_STATUS = InterfaceStatus.UP;
-    private static final NetworkBootProtocol BOOT_PROTOCOL = 
NetworkBootProtocol.STATIC_IP;
     private static final String SETUPNETWORKS_ACTION_BASE_URL = 
"/hosts/00000000-0000-0000-0000-000000000000/nics";
     private static final String SETUPNETWORKS_ACTION_URL = 
"/api/hosts/00000000-0000-0000-0000-000000000000/nics/setupnetworks";
     private static final String SETUPNETWORKS_ACTION_REL = "setupnetworks";


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

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

Reply via email to