mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Merge remote-tracking branch 'origin/4.11'
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
commit
323d381767
@ -46,6 +46,7 @@ public class TemplateObjectTO implements DataTO {
|
||||
private Hypervisor.HypervisorType hypervisorType;
|
||||
private boolean bootable;
|
||||
private String uniqueName;
|
||||
private boolean directDownload;
|
||||
|
||||
public TemplateObjectTO() {
|
||||
|
||||
@ -235,6 +236,14 @@ public class TemplateObjectTO implements DataTO {
|
||||
this.uniqueName = uniqueName;
|
||||
}
|
||||
|
||||
public boolean isDirectDownload() {
|
||||
return directDownload;
|
||||
}
|
||||
|
||||
public void setDirectDownload(boolean directDownload) {
|
||||
this.directDownload = directDownload;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringBuilder("TemplateTO[id=").append(id).append("|origUrl=").append(origUrl).append("|name").append(name).append("]").toString();
|
||||
|
||||
@ -2959,6 +2959,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
|
||||
|
||||
// Destroy old routers
|
||||
for (final DomainRouterVO oldRouter : oldRouters) {
|
||||
_routerService.stopRouter(oldRouter.getId(), true);
|
||||
_routerService.destroyRouter(oldRouter.getId(), context.getAccount(), context.getCaller().getId());
|
||||
}
|
||||
|
||||
|
||||
@ -49,6 +49,7 @@ import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import com.cloud.resource.RequestWrapper;
|
||||
import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
|
||||
import org.apache.cloudstack.storage.to.TemplateObjectTO;
|
||||
import org.apache.cloudstack.storage.to.VolumeObjectTO;
|
||||
import org.apache.cloudstack.utils.hypervisor.HypervisorUtils;
|
||||
import org.apache.cloudstack.utils.linux.CPUStat;
|
||||
@ -2214,7 +2215,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
||||
final DataTO data = volume.getData();
|
||||
final DataStoreTO store = data.getDataStore();
|
||||
|
||||
if (volume.getType() == Volume.Type.ISO && data.getPath() != null && (store instanceof NfsTO || store instanceof PrimaryDataStoreTO)) {
|
||||
if (volume.getType() == Volume.Type.ISO && data.getPath() != null && (store instanceof NfsTO ||
|
||||
store instanceof PrimaryDataStoreTO && data instanceof TemplateObjectTO && !((TemplateObjectTO) data).isDirectDownload())) {
|
||||
final String isoPath = store.getUrl().split("\\?")[0] + File.separator + data.getPath();
|
||||
final int index = isoPath.lastIndexOf("/");
|
||||
final String path = isoPath.substring(0, index);
|
||||
|
||||
@ -48,11 +48,7 @@ addVlan() {
|
||||
fi
|
||||
|
||||
# is up?
|
||||
ifconfig |grep -w $vlanDev > /dev/null
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
ifconfig $vlanDev up > /dev/null
|
||||
fi
|
||||
ip link set $vlanDev up > /dev/null 2>/dev/null
|
||||
|
||||
if [ ! -d /sys/class/net/$vlanBr ]
|
||||
then
|
||||
@ -86,11 +82,7 @@ addVlan() {
|
||||
fi
|
||||
fi
|
||||
# is vlanBr up?
|
||||
ifconfig |grep -w $vlanBr > /dev/null
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
ifconfig $vlanBr up
|
||||
fi
|
||||
ip link set $vlanBr up > /dev/null 2>/dev/null
|
||||
|
||||
return 0
|
||||
}
|
||||
@ -109,7 +101,7 @@ deleteVlan() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
ifconfig $vlanBr down
|
||||
ip link set $vlanBr down
|
||||
|
||||
if [ $? -gt 0 ]
|
||||
then
|
||||
|
||||
@ -2490,6 +2490,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
|
||||
|
||||
// Destroy old routers
|
||||
for (final DomainRouterVO oldRouter : oldRouters) {
|
||||
_routerService.stopRouter(oldRouter.getId(), true);
|
||||
_routerService.destroyRouter(oldRouter.getId(), context.getAccount(), context.getCaller().getId());
|
||||
}
|
||||
|
||||
|
||||
@ -96,6 +96,7 @@ import com.cloud.utils.db.SearchCriteria.Func;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionCallback;
|
||||
import com.cloud.utils.db.TransactionCallbackNoReturn;
|
||||
import com.cloud.utils.db.TransactionCallbackWithExceptionNoReturn;
|
||||
import com.cloud.utils.db.TransactionStatus;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
@ -869,23 +870,12 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim
|
||||
|
||||
@DB
|
||||
protected long recalculateAccountResourceCount(final long accountId, final ResourceType type) {
|
||||
Long newCount = Transaction.execute(new TransactionCallback<Long>() {
|
||||
@Override
|
||||
public Long doInTransaction(TransactionStatus status) {
|
||||
Long newCount = null;
|
||||
lockAccountAndOwnerDomainRows(accountId, type);
|
||||
ResourceCountVO accountRC = _resourceCountDao.findByOwnerAndType(accountId, ResourceOwnerType.Account, type);
|
||||
long oldCount = 0;
|
||||
if (accountRC != null) {
|
||||
oldCount = accountRC.getCount();
|
||||
}
|
||||
|
||||
final Long newCount;
|
||||
if (type == Resource.ResourceType.user_vm) {
|
||||
newCount = _userVmDao.countAllocatedVMsForAccount(accountId);
|
||||
} else if (type == Resource.ResourceType.volume) {
|
||||
newCount = _volumeDao.countAllocatedVolumesForAccount(accountId);
|
||||
long virtualRouterCount = _vmDao.findIdsOfAllocatedVirtualRoutersForAccount(accountId).size();
|
||||
newCount = newCount - virtualRouterCount; // don't count the volumes of virtual router
|
||||
newCount = _volumeDao.countAllocatedVolumesForAccount(accountId) - virtualRouterCount; // don't count the volumes of virtual router
|
||||
} else if (type == Resource.ResourceType.snapshot) {
|
||||
newCount = _snapshotDao.countSnapshotsForAccount(accountId);
|
||||
} else if (type == Resource.ResourceType.public_ip) {
|
||||
@ -910,19 +900,32 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim
|
||||
} else {
|
||||
throw new InvalidParameterValueException("Unsupported resource type " + type);
|
||||
}
|
||||
_resourceCountDao.setResourceCount(accountId, ResourceOwnerType.Account, type, (newCount == null) ? 0 : newCount.longValue());
|
||||
|
||||
long oldCount = 0;
|
||||
final ResourceCountVO accountRC = _resourceCountDao.findByOwnerAndType(accountId, ResourceOwnerType.Account, type);
|
||||
if (accountRC != null) {
|
||||
oldCount = accountRC.getCount();
|
||||
}
|
||||
|
||||
if (newCount == null || !newCount.equals(oldCount)) {
|
||||
Transaction.execute(new TransactionCallbackNoReturn() {
|
||||
@Override
|
||||
public void doInTransactionWithoutResult(TransactionStatus status) {
|
||||
lockAccountAndOwnerDomainRows(accountId, type);
|
||||
_resourceCountDao.setResourceCount(accountId, ResourceOwnerType.Account, type, (newCount == null) ? 0 : newCount);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// No need to log message for primary and secondary storage because both are recalculating the
|
||||
// resource count which will not lead to any discrepancy.
|
||||
if (!Long.valueOf(oldCount).equals(newCount) && (type != Resource.ResourceType.primary_storage && type != Resource.ResourceType.secondary_storage)) {
|
||||
s_logger.warn("Discrepency in the resource count " + "(original count=" + oldCount + " correct count = " + newCount + ") for type " + type + " for account ID " + accountId
|
||||
+ " is fixed during resource count recalculation.");
|
||||
if (newCount != null && !newCount.equals(oldCount) &&
|
||||
type != Resource.ResourceType.primary_storage && type != Resource.ResourceType.secondary_storage) {
|
||||
s_logger.warn("Discrepancy in the resource count " + "(original count=" + oldCount + " correct count = " + newCount + ") for type " + type +
|
||||
" for account ID " + accountId + " is fixed during resource count recalculation.");
|
||||
}
|
||||
return newCount;
|
||||
}
|
||||
});
|
||||
|
||||
return (newCount == null) ? 0 : newCount.longValue();
|
||||
return (newCount == null) ? 0 : newCount;
|
||||
}
|
||||
|
||||
public long countCpusForAccount(long accountId) {
|
||||
|
||||
@ -50,6 +50,7 @@ import org.apache.cloudstack.storage.datastore.db.ImageStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.ImageStoreVO;
|
||||
import org.apache.cloudstack.utils.imagestore.ImageStoreUtil;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
@ -557,12 +558,14 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
||||
if (vm.getIsoId() != null) {
|
||||
Map<Volume, StoragePool> storageForDisks = dest.getStorageForDisks();
|
||||
Long poolId = null;
|
||||
if (MapUtils.isNotEmpty(storageForDisks)) {
|
||||
for (StoragePool storagePool : storageForDisks.values()) {
|
||||
if (poolId != null && storagePool.getId() != poolId) {
|
||||
throw new CloudRuntimeException("Cannot determine where to download iso");
|
||||
}
|
||||
poolId = storagePool.getId();
|
||||
}
|
||||
}
|
||||
TemplateInfo template = prepareIso(vm.getIsoId(), vm.getDataCenterId(), dest.getHost().getId(), poolId);
|
||||
if (template == null){
|
||||
s_logger.error("Failed to prepare ISO on secondary or cache storage");
|
||||
@ -579,6 +582,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
||||
}
|
||||
|
||||
TemplateObjectTO iso = (TemplateObjectTO)template.getTO();
|
||||
iso.setDirectDownload(template.isDirectDownload());
|
||||
iso.setGuestOsType(displayName);
|
||||
DiskTO disk = new DiskTO(iso, 3L, null, Volume.Type.ISO);
|
||||
profile.addDisk(disk);
|
||||
|
||||
@ -52,7 +52,7 @@ def process_file():
|
||||
qf.setFile(sys.argv[1])
|
||||
qf.load(None)
|
||||
# These can be safely deferred, dramatically speeding up loading times
|
||||
if not (os.environ.get('DEFER_CONFIG', False) and sys.argv[1] in ('vm_dhcp_entry.json', 'vm_metadata.json')):
|
||||
if not (os.environ.get('DEFER_CONFIG', False) and ('vm_dhcp_entry.json' in sys.argv[1] or 'vm_metadata.json' in sys.argv[1])):
|
||||
# Converge
|
||||
finish_config()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user