diff --git a/plugins/hypervisors/hyperv/pom.xml b/plugins/hypervisors/hyperv/pom.xml index b65bd94ce2d..c3d0f4b4816 100644 --- a/plugins/hypervisors/hyperv/pom.xml +++ b/plugins/hypervisors/hyperv/pom.xml @@ -96,6 +96,35 @@ ${skipTests} + + maven-antrun-plugin + + + generate-resource + generate-resources + + run + + + + + + + + + + + + + + + + + + diff --git a/server/src/com/cloud/network/router/CommandSetupHelper.java b/server/src/com/cloud/network/router/CommandSetupHelper.java index e5d634c2ae4..13c80961e3f 100644 --- a/server/src/com/cloud/network/router/CommandSetupHelper.java +++ b/server/src/com/cloud/network/router/CommandSetupHelper.java @@ -108,8 +108,6 @@ import com.cloud.offering.NetworkOffering; import com.cloud.offerings.NetworkOfferingVO; import com.cloud.offerings.dao.NetworkOfferingDao; import com.cloud.service.dao.ServiceOfferingDao; -import com.cloud.storage.GuestOSVO; -import com.cloud.storage.dao.GuestOSDao; import com.cloud.user.Account; import com.cloud.uservm.UserVm; import com.cloud.utils.Pair; @@ -174,8 +172,6 @@ public class CommandSetupHelper { private VlanDao _vlanDao; @Inject private IPAddressDao _ipAddressDao; - @Inject - private GuestOSDao _guestOSDao; @Inject private RouterControlHelper _routerControlHelper; @@ -219,12 +215,6 @@ public class CommandSetupHelper { _networkModel.getExecuteInSeqNtwkElmtCmd()); String gatewayIp = nic.getIPv4Gateway(); - if (!nic.isDefaultNic()) { - final GuestOSVO guestOS = _guestOSDao.findById(vm.getGuestOSId()); - if (guestOS == null || !guestOS.getDisplayName().toLowerCase().contains("windows")) { - gatewayIp = "0.0.0.0"; - } - } final DataCenterVO dcVo = _dcDao.findById(router.getDataCenterId()); diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsDhcp.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsDhcp.py index 23b74995364..da9e6168ee0 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsDhcp.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsDhcp.py @@ -89,9 +89,10 @@ class CsDhcp(CsDataBag): gateway = gn.get_gateway() else: gateway = i['gateway'] - sline = "dhcp-option=tag:interface-%s-%s,3," % (device, idx) - line = "dhcp-option=tag:interface-%s-%s,3,%s" % (device, idx, gateway) - self.conf.search(sline, line) + if gateway != '0.0.0.0': + sline = "dhcp-option=tag:interface-%s-%s,3," % (device, idx) + line = "dhcp-option=tag:interface-%s-%s,3,%s" % (device, idx, gateway) + self.conf.search(sline, line) # Netmask netmask = '' if self.config.is_vpc(): diff --git a/systemvm/patches/debian/config/opt/cloud/bin/get_template_version.sh b/systemvm/patches/debian/config/opt/cloud/bin/get_template_version.sh index 996e9dd5ce5..53bdde30aa7 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/get_template_version.sh +++ b/systemvm/patches/debian/config/opt/cloud/bin/get_template_version.sh @@ -42,5 +42,6 @@ then exit fi -echo -n `cat /etc/cloudstack-release`'&' -cat /var/cache/cloud/cloud-scripts-signature +release=`cat /etc/cloudstack-release` +sig=`cat /var/cache/cloud/cloud-scripts-signature` +echo "${release}&${sig}" diff --git a/utils/pom.xml b/utils/pom.xml index 782c4617a51..a247c185924 100755 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -208,7 +208,6 @@ com/cloud/utils/testcase/*TestCase* com/cloud/utils/db/*Test* - com/cloud/utils/testcase/NioTest.java diff --git a/utils/src/main/java/com/cloud/utils/net/NetUtils.java b/utils/src/main/java/com/cloud/utils/net/NetUtils.java index 6c5211663ea..4972070ea66 100644 --- a/utils/src/main/java/com/cloud/utils/net/NetUtils.java +++ b/utils/src/main/java/com/cloud/utils/net/NetUtils.java @@ -891,7 +891,7 @@ public class NetUtils { Long[] cidrBLong = cidrToLong(cidrB); long shift = MAX_CIDR - cidrBLong[1]; - return cidrALong[0] >> shift == cidrBLong[0] >> shift; + return (cidrALong[0] >> shift == cidrBLong[0] >> shift) && (cidrALong[1] >= cidrBLong[1]); } static boolean areCidrsNotEmpty(String cidrA, String cidrB) { diff --git a/utils/src/main/java/com/cloud/utils/nio/NioConnection.java b/utils/src/main/java/com/cloud/utils/nio/NioConnection.java index 630b2ddab76..ce032462ec2 100644 --- a/utils/src/main/java/com/cloud/utils/nio/NioConnection.java +++ b/utils/src/main/java/com/cloud/utils/nio/NioConnection.java @@ -98,10 +98,9 @@ public abstract class NioConnection implements Callable { } _isStartup = true; - _threadExecutor = Executors.newSingleThreadExecutor(); - _futureTask = _threadExecutor.submit(this); - + _threadExecutor = Executors.newSingleThreadExecutor(new NamedThreadFactory(this._name + "-NioConnectionHandler")); _isRunning = true; + _futureTask = _threadExecutor.submit(this); } public void stop() { diff --git a/utils/src/test/java/com/cloud/utils/net/NetUtilsTest.java b/utils/src/test/java/com/cloud/utils/net/NetUtilsTest.java index 74a28fe672e..fb769dedd13 100644 --- a/utils/src/test/java/com/cloud/utils/net/NetUtilsTest.java +++ b/utils/src/test/java/com/cloud/utils/net/NetUtilsTest.java @@ -523,6 +523,19 @@ public class NetUtilsTest { assertEquals(false, NetUtils.isNetworkAWithinNetworkB("", null)); } + @Test + public void testIsNetworkAWithinNetworkB() { + assertTrue(NetUtils.isNetworkAWithinNetworkB("192.168.30.0/24", "192.168.30.0/23")); + assertTrue(NetUtils.isNetworkAWithinNetworkB("192.168.30.0/24", "192.168.30.0/22")); + assertFalse(NetUtils.isNetworkAWithinNetworkB("192.168.30.0/23", "192.168.30.0/24")); + assertFalse(NetUtils.isNetworkAWithinNetworkB("192.168.30.0/22", "192.168.30.0/24")); + assertTrue(NetUtils.isNetworkAWithinNetworkB("192.168.28.0/24", "192.168.28.0/23")); + assertTrue(NetUtils.isNetworkAWithinNetworkB("192.168.28.0/24", "192.168.28.0/22")); + assertFalse(NetUtils.isNetworkAWithinNetworkB("192.168.28.0/23", "192.168.28.0/24")); + assertFalse(NetUtils.isNetworkAWithinNetworkB("192.168.28.0/22", "192.168.28.0/24")); + assertTrue(NetUtils.isNetworkAWithinNetworkB("192.168.30.0/24", "192.168.28.0/22")); + } + @Test public void testIsNetworksOverlapWithEmptyValues() { assertEquals(false, NetUtils.isNetworksOverlap("", null)); diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/DistributedVirtualSwitchMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/DistributedVirtualSwitchMO.java index 9e19d655e7a..fbb4265bcfb 100644 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/DistributedVirtualSwitchMO.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/DistributedVirtualSwitchMO.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import org.apache.log4j.Logger; @@ -36,24 +37,67 @@ import com.cloud.hypervisor.vmware.util.VmwareContext; public class DistributedVirtualSwitchMO extends BaseMO { @SuppressWarnings("unused") private static final Logger s_logger = Logger.getLogger(DistributedVirtualSwitchMO.class); + private static ConcurrentHashMap> s_dvPortGroupCacheMap = null; public DistributedVirtualSwitchMO(VmwareContext context, ManagedObjectReference morDvs) { super(context, morDvs); + s_dvPortGroupCacheMap = new ConcurrentHashMap>(); } public DistributedVirtualSwitchMO(VmwareContext context, String morType, String morValue) { super(context, morType, morValue); + s_dvPortGroupCacheMap = new ConcurrentHashMap>(); } public void createDVPortGroup(DVPortgroupConfigSpec dvPortGroupSpec) throws Exception { List dvPortGroupSpecArray = new ArrayList(); dvPortGroupSpecArray.add(dvPortGroupSpec); - _context.getService().addDVPortgroupTask(_mor, dvPortGroupSpecArray); + boolean dvPortGroupExists = false; + String dvSwitchInstance = _mor.getValue(); + String dvPortGroupName = dvPortGroupSpec.getName(); + String uniquedvPortGroupPerDvs = dvSwitchInstance + dvPortGroupName; + List dvPortGroupList = null; + synchronized (uniquedvPortGroupPerDvs.intern()) { + // Looking up local cache rather than firing another API call to see if dvPortGroup exists already. + if (s_dvPortGroupCacheMap.containsKey(dvSwitchInstance)) { + dvPortGroupList = s_dvPortGroupCacheMap.get(dvSwitchInstance); + if (dvPortGroupList != null && dvPortGroupList.contains(dvPortGroupName)) { + dvPortGroupExists = true; + } + } + if (!dvPortGroupExists) { + ManagedObjectReference task = _context.getService().addDVPortgroupTask(_mor, dvPortGroupSpecArray); + if (!_context.getVimClient().waitForTask(task)) { + throw new Exception("Failed to create dvPortGroup " + dvPortGroupSpec.getName()); + } else { + if (s_dvPortGroupCacheMap.containsKey(dvSwitchInstance)) { + dvPortGroupList = s_dvPortGroupCacheMap.get(dvSwitchInstance); + if (dvPortGroupList == null) { + dvPortGroupList = new ArrayList(); + } + dvPortGroupList.add(dvPortGroupName); //does this update map? + } else { + dvPortGroupList = new ArrayList(); + dvPortGroupList.add(dvPortGroupName); + s_dvPortGroupCacheMap.put(dvSwitchInstance, dvPortGroupList); + } + } + if (s_logger.isTraceEnabled()) { + s_logger.trace("Created dvPortGroup. dvPortGroup cache is :" + s_dvPortGroupCacheMap); + } + } else if (s_logger.isDebugEnabled()) { + s_logger.debug("Detected dvPortGroup [" + dvPortGroupName + "] already present. Not attempting to create again."); + } + } } public void updateDvPortGroup(ManagedObjectReference dvPortGroupMor, DVPortgroupConfigSpec dvPortGroupSpec) throws Exception { - // TODO(sateesh): Update numPorts - _context.getService().reconfigureDVPortgroupTask(dvPortGroupMor, dvPortGroupSpec); + synchronized (dvPortGroupMor.getValue().intern()) { + ManagedObjectReference task = _context.getService().reconfigureDVPortgroupTask(dvPortGroupMor, dvPortGroupSpec); + if (!_context.getVimClient().waitForTask(task)) { + throw new Exception("Failed to update dvPortGroup " + dvPortGroupMor.getValue()); + } + } } public void updateVMWareDVSwitch(ManagedObjectReference dvSwitchMor, VMwareDVSConfigSpec dvsSpec) throws Exception {