Hi there!

After upgrading a working 4.9.2 setup to 4.11.0.0 we've noticed that we're 
unable to add a NIC (shared network) to a running VM via GUI.
The Error is "A NIC with this MAC address exits for network: (uuid of the 
current (other NIC) network)"
Using cloudmonkey and giving a self-computed MAC-address does not rise the 
error and works as expected.

After digging into the code, I think I've found the problem, but am too bad in 
java to provide a sustainable fix.

I've attached a patch which obviously (with own manual tests) fixes that issue 
by simply commenting out the respective codeblock.

As far as I dug into the code, the third parameter of NicProfile is handled by 

NetUtils.long2Mac(NetUtils.createSequenceBasedMacAddress(ipVO.getMacAddress(), 
NetworkModel.MACIdentifier.value())

inside

NicProfileHelperImpl.java

I assume createSequenceBasedMacAddress can handle null as MAC, but doesn't get 
called at all if 


_nicDao.findByNetworkIdAndMacAddress(networkId, macAddress) results != null if 
macAddress is null.



Sorry, if I'm wrong, didn't had decent IDE at hand :)



Cheers,

Stephan Seitz

--

Heinlein Support GmbH
Schwedter Str. 8/9b, 10119 Berlin

http://www.heinlein-support.de

Tel: 030 / 405051-44
Fax: 030 / 405051-19

Zwangsangaben lt. §35a GmbHG: HRB 93818 B / Amtsgericht
Berlin-Charlottenburg,
Geschäftsführer: Peer Heinlein -- Sitz: Berlin


--- a/server/src/com/cloud/vm/UserVmManagerImpl.java	2018-04-02 08:29:09.250154334 +0200
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java	2018-04-02 08:34:26.012242484 +0200
@@ -1199,10 +1199,10 @@
                 throw new CloudRuntimeException("A NIC already exists for VM:" + vmInstance.getInstanceName() + " in network: " + network.getUuid());
         }
 
-        if(_nicDao.findByNetworkIdAndMacAddress(networkId, macAddress) != null) {
-            throw new CloudRuntimeException("A NIC with this MAC address exists for network: " + network.getUuid());
-        }
-
+        //if(_nicDao.findByNetworkIdAndMacAddress(networkId, macAddress) != null) {
+        //    throw new CloudRuntimeException("A NIC with this MAC address exists for network: " + network.getUuid());
+        //}
+        // NicProfile can handle duplicates by itself
         NicProfile profile = new NicProfile(ipAddress, null, macAddress);
         if (ipAddress != null) {
             if (!(NetUtils.isValidIp4(ipAddress) || NetUtils.isValidIp6(ipAddress))) {

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to