diff --git a/agent/src/com/cloud/agent/resource/computing/LibvirtComputingResource.java b/agent/src/com/cloud/agent/resource/computing/LibvirtComputingResource.java index 9adade3ad4e..394909342f8 100644 --- a/agent/src/com/cloud/agent/resource/computing/LibvirtComputingResource.java +++ b/agent/src/com/cloud/agent/resource/computing/LibvirtComputingResource.java @@ -1136,7 +1136,6 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv final Script command = new Script(_manageSnapshotPath, _cmdsTimeout, s_logger); command.add("-d", snapshotDestPath); - command.add("-n", cmd.getSnapshotName()); command.add("-f"); command.execute(); } catch (LibvirtException e) { diff --git a/agent/src/com/cloud/agent/resource/computing/LibvirtVMDef.java b/agent/src/com/cloud/agent/resource/computing/LibvirtVMDef.java index b69df8fabd3..e40453e80b2 100644 --- a/agent/src/com/cloud/agent/resource/computing/LibvirtVMDef.java +++ b/agent/src/com/cloud/agent/resource/computing/LibvirtVMDef.java @@ -384,7 +384,7 @@ public class LibvirtVMDef { } diskBuilder.append(" type='" + _diskType + "'"); diskBuilder.append(">\n"); - diskBuilder.append("\n"); + diskBuilder.append("\n"); if (_diskType == diskType.FILE) { diskBuilder.append("& /dev/null + rm -rf $disk >& /dev/null fi return $failed diff --git a/server/src/com/cloud/api/ApiDBUtils.java b/server/src/com/cloud/api/ApiDBUtils.java index 96ada100a2a..da1f6368697 100755 --- a/server/src/com/cloud/api/ApiDBUtils.java +++ b/server/src/com/cloud/api/ApiDBUtils.java @@ -543,11 +543,11 @@ public class ApiDBUtils { } public static boolean isSecurityGroupEnabledInZone(long zoneId) { - Network network = _networkMgr.getNetworkWithSecurityGroupEnabled(zoneId); - if (network != null) { - return true; - } else { + DataCenterVO dc = _zoneDao.findById(zoneId); + if (dc == null) { return false; + } else { + return dc.isSecurityGroupEnabled(); } } diff --git a/server/src/com/cloud/dc/dao/DataCenterDao.java b/server/src/com/cloud/dc/dao/DataCenterDao.java index 3bc660a452c..e280adfed8e 100644 --- a/server/src/com/cloud/dc/dao/DataCenterDao.java +++ b/server/src/com/cloud/dc/dao/DataCenterDao.java @@ -65,4 +65,6 @@ public interface DataCenterDao extends GenericDao { List listPublicZones(); List findChildZones(Object[] ids); + + List listSecurityGroupEnabledZones(); } diff --git a/server/src/com/cloud/dc/dao/DataCenterDaoImpl.java b/server/src/com/cloud/dc/dao/DataCenterDaoImpl.java index 4dd5ce8582d..32b17df2e1d 100644 --- a/server/src/com/cloud/dc/dao/DataCenterDaoImpl.java +++ b/server/src/com/cloud/dc/dao/DataCenterDaoImpl.java @@ -56,7 +56,8 @@ public class DataCenterDaoImpl extends GenericDaoBase implem protected SearchBuilder NameSearch; protected SearchBuilder ListZonesByDomainIdSearch; protected SearchBuilder PublicZonesSearch; - protected SearchBuilder ChildZonesSearch; + protected SearchBuilder ChildZonesSearch; + protected SearchBuilder securityGroupSearch; protected final DataCenterIpAddressDaoImpl _ipAllocDao = ComponentLocator.inject(DataCenterIpAddressDaoImpl.class); protected final DataCenterLinkLocalIpAddressDaoImpl _LinkLocalIpAllocDao = ComponentLocator.inject(DataCenterLinkLocalIpAddressDaoImpl.class); @@ -92,6 +93,12 @@ public class DataCenterDaoImpl extends GenericDaoBase implem SearchCriteria sc = PublicZonesSearch.create(); //sc.setParameters("domainId", domainId); return listBy(sc); + } + + @Override + public List listSecurityGroupEnabledZones() { + SearchCriteria sc = securityGroupSearch.create(); + return listBy(sc); } @Override @@ -252,6 +259,10 @@ public class DataCenterDaoImpl extends GenericDaoBase implem ChildZonesSearch.and("domainid", ChildZonesSearch.entity().getDomainId(), SearchCriteria.Op.IN); ChildZonesSearch.done(); + securityGroupSearch = createSearchBuilder(); + securityGroupSearch.and("isSgEnabled", securityGroupSearch.entity().isSecurityGroupEnabled(), SearchCriteria.Op.EQ); + securityGroupSearch.done(); + _tgMacAddress = _tgs.get("macAddress"); assert _tgMacAddress != null : "Couldn't get mac address table generator"; } diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index 28003310bff..32dc4168663 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -4189,15 +4189,16 @@ public class ManagementServerImpl implements ManagementServer { @Override public Map listCapabilities(ListCapabilitiesCmd cmd) { Map capabilities = new HashMap(); - String securityGroupsEnabled = "false"; - Network net = _networkMgr.getNetworkWithSecurityGroupEnabled(null); - if (net != null) { - securityGroupsEnabled = "true"; + + boolean securityGroupsEnabled = false; + List dc = _dcDao.listSecurityGroupEnabledZones(); + if (dc != null && !dc.isEmpty()) { + securityGroupsEnabled = true; } String userPublicTemplateEnabled = _configs.get(Config.AllowPublicUserTemplates.key()); - capabilities.put("securityGroupsEnabled", (securityGroupsEnabled == null || securityGroupsEnabled.equals("false") ? false : true)); + capabilities.put("securityGroupsEnabled", securityGroupsEnabled); capabilities.put("userPublicTemplateEnabled", (userPublicTemplateEnabled == null || userPublicTemplateEnabled.equals("false") ? false : true)); capabilities.put("cloudStackVersion", getVersion()); return capabilities;