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