Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,10 @@ public AsyncCallFuture<TemplateApiResult> copyTemplate(TemplateInfo srcTemplate,
DataObject templateOnStore = destStore.create(tmplForCopy);
templateOnStore.processEvent(Event.CreateOnlyRequested);

if (templateOnStore instanceof TemplateObject) {
((TemplateObject)templateOnStore).getImage().setChecksum(null);
} // else we don't know what to do.

if (s_logger.isDebugEnabled()) {
s_logger.debug("Invoke datastore driver createAsync to create template on destination store");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,29 +53,21 @@
import com.cloud.storage.RegisterVolumePayload;
import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
import com.cloud.storage.Volume;
import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.storage.template.TemplateConstants;
import com.cloud.storage.upload.UploadListener;
import com.cloud.template.VirtualMachineTemplate;
import com.cloud.utils.component.ComponentContext;
import com.cloud.utils.component.ManagerBase;
import com.cloud.utils.exception.CloudRuntimeException;

@Component
public class DownloadMonitorImpl extends ManagerBase implements DownloadMonitor {
static final Logger s_logger = Logger.getLogger(DownloadMonitorImpl.class);
static final Logger LOGGER = Logger.getLogger(DownloadMonitorImpl.class);

@Inject
private TemplateDataStoreDao _vmTemplateStoreDao;
@Inject
private VolumeDao _volumeDao;
@Inject
private VolumeDataStoreDao _volumeStoreDao;
@Inject
private final VMTemplateDao _templateDao = null;
@Inject
private AgentManager _agentMgr;
@Inject
private ConfigurationDao _configDao;
Expand All @@ -94,7 +86,7 @@ public boolean configure(String name, Map<String, Object> params) {

String cert = configs.get("secstorage.ssl.cert.domain");
if (!"realhostip.com".equalsIgnoreCase(cert)) {
s_logger.warn("Only realhostip.com ssl cert is supported, ignoring self-signed and other certs");
LOGGER.warn("Only realhostip.com ssl cert is supported, ignoring self-signed and other certs");
}

_copyAuthPasswd = configs.get("secstorage.copy.password");
Expand Down Expand Up @@ -125,7 +117,7 @@ public boolean isTemplateUpdateable(Long templateId, Long storeId) {

private void initiateTemplateDownload(DataObject template, AsyncCompletionCallback<DownloadAnswer> callback) {
boolean downloadJobExists = false;
TemplateDataStoreVO vmTemplateStore = null;
TemplateDataStoreVO vmTemplateStore;
DataStore store = template.getDataStore();

vmTemplateStore = _vmTemplateStoreDao.findByStoreTemplate(store.getId(), template.getId());
Expand All @@ -141,7 +133,6 @@ private void initiateTemplateDownload(DataObject template, AsyncCompletionCallba
Long maxTemplateSizeInBytes = getMaxTemplateSizeInBytes();
if (vmTemplateStore != null) {
start();
VirtualMachineTemplate tmpl = _templateDao.findById(template.getId());
DownloadCommand dcmd = new DownloadCommand((TemplateObjectTO)(template.getTO()), maxTemplateSizeInBytes);
dcmd.setProxy(getHttpProxy());
if (downloadJobExists) {
Expand All @@ -153,7 +144,7 @@ private void initiateTemplateDownload(DataObject template, AsyncCompletionCallba
EndPoint ep = _epSelector.select(template);
if (ep == null) {
String errMsg = "There is no secondary storage VM for downloading template to image store " + store.getName();
s_logger.warn(errMsg);
LOGGER.warn(errMsg);
throw new CloudRuntimeException(errMsg);
}
DownloadListener dl = new DownloadListener(ep, store, template, _timer, this, dcmd, callback);
Expand All @@ -164,14 +155,14 @@ private void initiateTemplateDownload(DataObject template, AsyncCompletionCallba
// DownloadListener to use
// new ObjectInDataStore.State transition. TODO: fix this later
// to be able to remove downloadState from template_store_ref.
s_logger.info("found existing download job");
LOGGER.info("found existing download job");
dl.setCurrState(vmTemplateStore.getDownloadState());
}

try {
ep.sendMessageAsync(dcmd, new UploadListener.Callback(ep.getId(), dl));
} catch (Exception e) {
s_logger.warn("Unable to start /resume download of template " + template.getId() + " to " + store.getName(), e);
LOGGER.warn("Unable to start /resume download of template " + template.getId() + " to " + store.getName(), e);
dl.setDisconnected();
dl.scheduleStatusCheck(RequestType.GET_OR_RESTART);
}
Expand All @@ -187,12 +178,12 @@ public void downloadTemplateToStorage(DataObject template, AsyncCompletionCallba
if (template.getUri() != null) {
initiateTemplateDownload(template, callback);
} else {
s_logger.info("Template url is null, cannot download");
LOGGER.info("Template url is null, cannot download");
DownloadAnswer ans = new DownloadAnswer("Template url is null", Status.UNKNOWN);
callback.complete(ans);
}
} else {
s_logger.info("Template download is already in progress or already downloaded");
LOGGER.info("Template download is already in progress or already downloaded");
DownloadAnswer ans =
new DownloadAnswer("Template download is already in progress or already downloaded", Status.UNKNOWN);
callback.complete(ans);
Expand All @@ -203,7 +194,7 @@ public void downloadTemplateToStorage(DataObject template, AsyncCompletionCallba
@Override
public void downloadVolumeToStorage(DataObject volume, AsyncCompletionCallback<DownloadAnswer> callback) {
boolean downloadJobExists = false;
VolumeDataStoreVO volumeHost = null;
VolumeDataStoreVO volumeHost;
DataStore store = volume.getDataStore();
VolumeInfo volInfo = (VolumeInfo)volume;
RegisterVolumePayload payload = (RegisterVolumePayload)volInfo.getpayload();
Expand All @@ -214,7 +205,7 @@ public void downloadVolumeToStorage(DataObject volume, AsyncCompletionCallback<D
volumeHost = _volumeStoreDao.findByStoreVolume(store.getId(), volume.getId());
if (volumeHost == null) {
volumeHost = new VolumeDataStoreVO(store.getId(), volume.getId(), new Date(), 0, Status.NOT_DOWNLOADED, null, null, "jobid0000", null, url, checkSum);
_volumeStoreDao.persist(volumeHost);
volumeHost = _volumeStoreDao.persist(volumeHost);
} else if ((volumeHost.getJobId() != null) && (volumeHost.getJobId().length() > 2)) {
downloadJobExists = true;
} else {
Expand All @@ -225,35 +216,32 @@ public void downloadVolumeToStorage(DataObject volume, AsyncCompletionCallback<D
}

Long maxVolumeSizeInBytes = getMaxVolumeSizeInBytes();
if (volumeHost != null) {
start();
Volume vol = _volumeDao.findById(volume.getId());
DownloadCommand dcmd = new DownloadCommand((VolumeObjectTO)(volume.getTO()), maxVolumeSizeInBytes, checkSum, url, format);
dcmd.setProxy(getHttpProxy());
if (downloadJobExists) {
dcmd = new DownloadProgressCommand(dcmd, volumeHost.getJobId(), RequestType.GET_OR_RESTART);
dcmd.setResourceType(ResourceType.VOLUME);
}
start();
DownloadCommand dcmd = new DownloadCommand((VolumeObjectTO)(volume.getTO()), maxVolumeSizeInBytes, checkSum, url, format);
dcmd.setProxy(getHttpProxy());
if (downloadJobExists) {
dcmd = new DownloadProgressCommand(dcmd, volumeHost.getJobId(), RequestType.GET_OR_RESTART);
dcmd.setResourceType(ResourceType.VOLUME);
}

EndPoint ep = _epSelector.select(volume);
if (ep == null) {
s_logger.warn("There is no secondary storage VM for image store " + store.getName());
return;
}
DownloadListener dl = new DownloadListener(ep, store, volume, _timer, this, dcmd, callback);
ComponentContext.inject(dl); // auto-wired those injected fields in DownloadListener
EndPoint ep = _epSelector.select(volume);
if (ep == null) {
LOGGER.warn("There is no secondary storage VM for image store " + store.getName());
return;
}
DownloadListener dl = new DownloadListener(ep, store, volume, _timer, this, dcmd, callback);
ComponentContext.inject(dl); // auto-wired those injected fields in DownloadListener

if (downloadJobExists) {
dl.setCurrState(volumeHost.getDownloadState());
}
if (downloadJobExists) {
dl.setCurrState(volumeHost.getDownloadState());
}

try {
ep.sendMessageAsync(dcmd, new UploadListener.Callback(ep.getId(), dl));
} catch (Exception e) {
s_logger.warn("Unable to start /resume download of volume " + volume.getId() + " to " + store.getName(), e);
dl.setDisconnected();
dl.scheduleStatusCheck(RequestType.GET_OR_RESTART);
}
try {
ep.sendMessageAsync(dcmd, new UploadListener.Callback(ep.getId(), dl));
} catch (Exception e) {
LOGGER.warn("Unable to start /resume download of volume " + volume.getId() + " to " + store.getName(), e);
dl.setDisconnected();
dl.scheduleStatusCheck(RequestType.GET_OR_RESTART);
}
}

Expand All @@ -279,8 +267,7 @@ private Proxy getHttpProxy() {
}
try {
URI uri = new URI(_proxy);
Proxy prx = new Proxy(uri);
return prx;
return new Proxy(uri);
} catch (URISyntaxException e) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -927,8 +927,6 @@ public VirtualMachineTemplate copyTemplate(CopyTemplateCmd cmd) throws StorageUn
}
}
}


}

if ((destZoneIds != null) && (destZoneIds.size() > failedZones.size())){
Expand Down
Loading