mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Remove old DeleteTemplateCommand, DeleteVolumeCommand,
DeleteSnapshotBackupCommand, replaced by DeleteCommand.
This commit is contained in:
parent
04b5f53392
commit
cc0de88088
@ -1,32 +0,0 @@
|
|||||||
// Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
// or more contributor license agreements. See the NOTICE file
|
|
||||||
// distributed with this work for additional information
|
|
||||||
// regarding copyright ownership. The ASF licenses this file
|
|
||||||
// to you under the Apache License, Version 2.0 (the
|
|
||||||
// "License"); you may not use this file except in compliance
|
|
||||||
// with the License. You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing,
|
|
||||||
// software distributed under the License is distributed on an
|
|
||||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
// KIND, either express or implied. See the License for the
|
|
||||||
// specific language governing permissions and limitations
|
|
||||||
// under the License.
|
|
||||||
package com.cloud.agent.api;
|
|
||||||
|
|
||||||
|
|
||||||
public class DeleteSnapshotBackupAnswer extends Answer {
|
|
||||||
|
|
||||||
protected DeleteSnapshotBackupAnswer() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public DeleteSnapshotBackupAnswer(DeleteSnapshotBackupCommand cmd, boolean success, String details) {
|
|
||||||
super(cmd, success, details);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,85 +0,0 @@
|
|||||||
// Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
// or more contributor license agreements. See the NOTICE file
|
|
||||||
// distributed with this work for additional information
|
|
||||||
// regarding copyright ownership. The ASF licenses this file
|
|
||||||
// to you under the Apache License, Version 2.0 (the
|
|
||||||
// "License"); you may not use this file except in compliance
|
|
||||||
// with the License. You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing,
|
|
||||||
// software distributed under the License is distributed on an
|
|
||||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
// KIND, either express or implied. See the License for the
|
|
||||||
// specific language governing permissions and limitations
|
|
||||||
// under the License.
|
|
||||||
package com.cloud.agent.api;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.LogLevel.Log4jLevel;
|
|
||||||
import com.cloud.agent.api.to.DataStoreTO;
|
|
||||||
import com.cloud.agent.api.to.S3TO;
|
|
||||||
import com.cloud.agent.api.to.SwiftTO;
|
|
||||||
import com.cloud.storage.StoragePool;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This command encapsulates a primitive operation which enables coalescing the backed up VHD snapshots on the secondary server
|
|
||||||
* This currently assumes that the secondary storage are mounted on the XenServer.
|
|
||||||
*/
|
|
||||||
public class DeleteSnapshotBackupCommand extends SnapshotCommand {
|
|
||||||
@LogLevel(Log4jLevel.Off)
|
|
||||||
private DataStoreTO store;
|
|
||||||
private Boolean all;
|
|
||||||
|
|
||||||
public Boolean isAll() {
|
|
||||||
return all;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAll(Boolean all) {
|
|
||||||
this.all = all;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DataStoreTO getDataStore(){
|
|
||||||
return store;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected DeleteSnapshotBackupCommand() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given 2 VHD files on the secondary storage which are linked in a parent chain as follows:
|
|
||||||
* backupUUID = parent(childUUID)
|
|
||||||
* It gets another VHD
|
|
||||||
* previousBackupVHD = parent(backupUUID)
|
|
||||||
*
|
|
||||||
* And
|
|
||||||
* 1) it coalesces backupUuid into its parent.
|
|
||||||
* 2) It deletes the VHD file corresponding to backupUuid
|
|
||||||
* 3) It sets the parent VHD of childUUID to that of previousBackupUuid
|
|
||||||
*
|
|
||||||
* It takes care of the cases when
|
|
||||||
* 1) childUUID is null. - Step 3 is not done.
|
|
||||||
* 2) previousBackupUUID is null
|
|
||||||
* - Merge childUUID into its parent backupUUID
|
|
||||||
* - Set the UUID of the resultant VHD to childUUID
|
|
||||||
* - Essentially we are deleting the oldest VHD file and setting the current oldest VHD to childUUID
|
|
||||||
*
|
|
||||||
* @param volumeName The name of the volume whose snapshot was taken (something like i-3-SV-ROOT)
|
|
||||||
* @param secondaryStoragePoolURL This is what shows up in the UI when you click on Secondary storage.
|
|
||||||
* In the code, it is present as: In the vmops.host_details table, there is a field mount.parent. This is the value of that field
|
|
||||||
* If you have better ideas on how to get it, you are welcome.
|
|
||||||
* @param backupUUID The VHD which has to be deleted
|
|
||||||
* @param childUUID The child VHD file of the backup whose parent is reset to its grandparent.
|
|
||||||
*/
|
|
||||||
public DeleteSnapshotBackupCommand(DataStoreTO store,
|
|
||||||
String secondaryStoragePoolURL,
|
|
||||||
Long dcId,
|
|
||||||
Long accountId,
|
|
||||||
Long volumeId,
|
|
||||||
String backupUUID, Boolean all)
|
|
||||||
{
|
|
||||||
super(null, secondaryStoragePoolURL, backupUUID, null, dcId, accountId, volumeId);
|
|
||||||
this.store = store;
|
|
||||||
setAll(all);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,62 +0,0 @@
|
|||||||
// Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
// or more contributor license agreements. See the NOTICE file
|
|
||||||
// distributed with this work for additional information
|
|
||||||
// regarding copyright ownership. The ASF licenses this file
|
|
||||||
// to you under the Apache License, Version 2.0 (the
|
|
||||||
// "License"); you may not use this file except in compliance
|
|
||||||
// with the License. You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing,
|
|
||||||
// software distributed under the License is distributed on an
|
|
||||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
// KIND, either express or implied. See the License for the
|
|
||||||
// specific language governing permissions and limitations
|
|
||||||
// under the License.
|
|
||||||
package com.cloud.agent.api.storage;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.to.DataStoreTO;
|
|
||||||
|
|
||||||
|
|
||||||
public class DeleteTemplateCommand extends ssCommand {
|
|
||||||
private DataStoreTO store;
|
|
||||||
private String templatePath;
|
|
||||||
private Long templateId;
|
|
||||||
private Long accountId;
|
|
||||||
|
|
||||||
|
|
||||||
public DeleteTemplateCommand() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public DeleteTemplateCommand(DataStoreTO store, String templatePath, Long templateId, Long accountId) {
|
|
||||||
this.templatePath = templatePath;
|
|
||||||
this.templateId = templateId;
|
|
||||||
this.accountId = accountId;
|
|
||||||
this.store = store;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean executeInSequence() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTemplatePath() {
|
|
||||||
return templatePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getTemplateId() {
|
|
||||||
return templateId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getAccountId() {
|
|
||||||
return accountId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DataStoreTO getDataStore() {
|
|
||||||
return store;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,54 +0,0 @@
|
|||||||
// Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
// or more contributor license agreements. See the NOTICE file
|
|
||||||
// distributed with this work for additional information
|
|
||||||
// regarding copyright ownership. The ASF licenses this file
|
|
||||||
// to you under the Apache License, Version 2.0 (the
|
|
||||||
// "License"); you may not use this file except in compliance
|
|
||||||
// with the License. You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing,
|
|
||||||
// software distributed under the License is distributed on an
|
|
||||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
// KIND, either express or implied. See the License for the
|
|
||||||
// specific language governing permissions and limitations
|
|
||||||
// under the License.
|
|
||||||
package com.cloud.agent.api.storage;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.to.DataStoreTO;
|
|
||||||
|
|
||||||
public class DeleteVolumeCommand extends ssCommand {
|
|
||||||
private DataStoreTO store;
|
|
||||||
private String volumePath;
|
|
||||||
private Long volumeId;
|
|
||||||
|
|
||||||
public DeleteVolumeCommand() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public DeleteVolumeCommand(DataStoreTO store, Long volumeId, String volumePath) {
|
|
||||||
this.store = store;
|
|
||||||
this.volumeId = volumeId;
|
|
||||||
this.volumePath = volumePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean executeInSequence() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getVolumePath() {
|
|
||||||
return volumePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DataStoreTO getDataStore() {
|
|
||||||
return store;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getVolumeId() {
|
|
||||||
return volumeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -85,6 +85,10 @@ public class TemplateObjectTO implements DataTO {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setId(long id){
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
public ImageFormat getFormat() {
|
public ImageFormat getFormat() {
|
||||||
return format;
|
return format;
|
||||||
}
|
}
|
||||||
@ -113,9 +117,6 @@ public class TemplateObjectTO implements DataTO {
|
|||||||
this.displayText = desc;
|
this.displayText = desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataStoreTO getImageDataStore() {
|
|
||||||
return this.imageDataStore;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataObjectType getObjectType() {
|
public DataObjectType getObjectType() {
|
||||||
@ -124,7 +125,11 @@ public class TemplateObjectTO implements DataTO {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataStoreTO getDataStore() {
|
public DataStoreTO getDataStore() {
|
||||||
return (DataStoreTO) this.imageDataStore;
|
return this.imageDataStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDataStore(DataStoreTO store){
|
||||||
|
this.imageDataStore = store;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -79,6 +79,11 @@ public class VolumeObjectTO implements DataTO {
|
|||||||
return this.dataStore;
|
return this.dataStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setDataStore(DataStoreTO store){
|
||||||
|
this.dataStore = store;
|
||||||
|
}
|
||||||
|
|
||||||
public void setDataStore(PrimaryDataStoreTO dataStore) {
|
public void setDataStore(PrimaryDataStoreTO dataStore) {
|
||||||
this.dataStore = dataStore;
|
this.dataStore = dataStore;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,6 +51,7 @@ import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
|
|||||||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||||
import org.apache.cloudstack.framework.async.AsyncRpcConext;
|
import org.apache.cloudstack.framework.async.AsyncRpcConext;
|
||||||
import org.apache.cloudstack.storage.command.CommandResult;
|
import org.apache.cloudstack.storage.command.CommandResult;
|
||||||
|
import org.apache.cloudstack.storage.command.DeleteCommand;
|
||||||
import org.apache.cloudstack.storage.datastore.DataObjectManager;
|
import org.apache.cloudstack.storage.datastore.DataObjectManager;
|
||||||
import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
|
import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
|
||||||
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
|
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
|
||||||
@ -58,11 +59,11 @@ import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
|
|||||||
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao;
|
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao;
|
||||||
import org.apache.cloudstack.storage.image.manager.ImageDataManager;
|
import org.apache.cloudstack.storage.image.manager.ImageDataManager;
|
||||||
import org.apache.cloudstack.storage.image.store.TemplateObject;
|
import org.apache.cloudstack.storage.image.store.TemplateObject;
|
||||||
|
import org.apache.cloudstack.storage.to.TemplateObjectTO;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.cloud.agent.api.Answer;
|
import com.cloud.agent.api.Answer;
|
||||||
import com.cloud.agent.api.storage.DeleteTemplateCommand;
|
|
||||||
import com.cloud.agent.api.storage.ListTemplateAnswer;
|
import com.cloud.agent.api.storage.ListTemplateAnswer;
|
||||||
import com.cloud.agent.api.storage.ListTemplateCommand;
|
import com.cloud.agent.api.storage.ListTemplateCommand;
|
||||||
import com.cloud.alert.AlertManager;
|
import com.cloud.alert.AlertManager;
|
||||||
@ -445,11 +446,14 @@ public class TemplateServiceImpl implements TemplateService {
|
|||||||
for (String uniqueName : templateInfos.keySet()) {
|
for (String uniqueName : templateInfos.keySet()) {
|
||||||
TemplateProp tInfo = templateInfos.get(uniqueName);
|
TemplateProp tInfo = templateInfos.get(uniqueName);
|
||||||
if (_tmpltMgr.templateIsDeleteable(tInfo.getId())) {
|
if (_tmpltMgr.templateIsDeleteable(tInfo.getId())) {
|
||||||
// TODO: we cannot directly call deleteTemplateSync here to
|
// we cannot directly call deleteTemplateSync here to
|
||||||
// reuse delete logic since in this case, our db does not have
|
// reuse delete logic since in this case, our db does not have
|
||||||
// this template at all.
|
// this template at all.
|
||||||
DeleteTemplateCommand dtCommand = new DeleteTemplateCommand(store.getTO(), tInfo.getInstallPath(),
|
TemplateObjectTO tmplTO = new TemplateObjectTO();
|
||||||
null, null);
|
tmplTO.setDataStore(store.getTO());
|
||||||
|
tmplTO.setPath(tInfo.getInstallPath());
|
||||||
|
tmplTO.setId(tInfo.getId());
|
||||||
|
DeleteCommand dtCommand = new DeleteCommand(tmplTO);
|
||||||
EndPoint ep = _epSelector.select(store);
|
EndPoint ep = _epSelector.select(store);
|
||||||
Answer answer = ep.sendMessage(dtCommand);
|
Answer answer = ep.sendMessage(dtCommand);
|
||||||
if (answer == null || !answer.getResult()) {
|
if (answer == null || !answer.getResult()) {
|
||||||
|
|||||||
@ -137,7 +137,7 @@ public class DirectAgentTest extends CloudStackTestNGBase {
|
|||||||
|
|
||||||
TemplateObjectTO template = Mockito.mock(TemplateObjectTO.class);
|
TemplateObjectTO template = Mockito.mock(TemplateObjectTO.class);
|
||||||
Mockito.when(template.getPath()).thenReturn(getTemplateUrl());
|
Mockito.when(template.getPath()).thenReturn(getTemplateUrl());
|
||||||
Mockito.when(template.getImageDataStore()).thenReturn(imageStore);
|
Mockito.when(template.getDataStore()).thenReturn(imageStore);
|
||||||
|
|
||||||
// Mockito.when(image.getTemplate()).thenReturn(template);
|
// Mockito.when(image.getTemplate()).thenReturn(template);
|
||||||
// CopyTemplateToPrimaryStorageCmd cmd = new
|
// CopyTemplateToPrimaryStorageCmd cmd = new
|
||||||
|
|||||||
@ -44,18 +44,20 @@ import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
|
|||||||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||||
import org.apache.cloudstack.framework.async.AsyncRpcConext;
|
import org.apache.cloudstack.framework.async.AsyncRpcConext;
|
||||||
import org.apache.cloudstack.storage.command.CommandResult;
|
import org.apache.cloudstack.storage.command.CommandResult;
|
||||||
|
import org.apache.cloudstack.storage.command.DeleteCommand;
|
||||||
import org.apache.cloudstack.storage.datastore.DataObjectManager;
|
import org.apache.cloudstack.storage.datastore.DataObjectManager;
|
||||||
import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
|
import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
|
||||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
||||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStoreProviderManager;
|
import org.apache.cloudstack.storage.datastore.PrimaryDataStoreProviderManager;
|
||||||
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao;
|
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao;
|
||||||
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO;
|
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO;
|
||||||
|
import org.apache.cloudstack.storage.to.TemplateObjectTO;
|
||||||
|
import org.apache.cloudstack.storage.to.VolumeObjectTO;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.cloud.agent.AgentManager;
|
import com.cloud.agent.AgentManager;
|
||||||
import com.cloud.agent.api.Answer;
|
import com.cloud.agent.api.Answer;
|
||||||
import com.cloud.agent.api.storage.DeleteVolumeCommand;
|
|
||||||
import com.cloud.agent.api.storage.ListVolumeAnswer;
|
import com.cloud.agent.api.storage.ListVolumeAnswer;
|
||||||
import com.cloud.agent.api.storage.ListVolumeCommand;
|
import com.cloud.agent.api.storage.ListVolumeCommand;
|
||||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||||
@ -80,7 +82,6 @@ import com.cloud.user.AccountManager;
|
|||||||
import com.cloud.user.ResourceLimitService;
|
import com.cloud.user.ResourceLimitService;
|
||||||
import com.cloud.utils.NumbersUtil;
|
import com.cloud.utils.NumbersUtil;
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
|
||||||
import com.cloud.vm.dao.VMInstanceDao;
|
import com.cloud.vm.dao.VMInstanceDao;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@ -1127,15 +1128,27 @@ public class VolumeServiceImpl implements VolumeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Delete volumes which are not present on DB.
|
// Delete volumes which are not present on DB.
|
||||||
/*
|
for (Long uniqueName : volumeInfos.keySet()) {
|
||||||
* for (Long uniqueName : volumeInfos.keySet()) { TemplateProp vInfo =
|
TemplateProp tInfo = volumeInfos.get(uniqueName);
|
||||||
* volumeInfos.get(uniqueName);
|
|
||||||
* expungeVolumeAsync(volFactory.getVolume(vInfo.getId(), store));
|
|
||||||
*
|
|
||||||
* String description = "Deleted volume " + vInfo.getTemplateName() +
|
|
||||||
* " on image store " + storeId; s_logger.info(description); }
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
//we cannot directly call expungeVolumeAsync here to
|
||||||
|
// reuse delete logic since in this case, our db does not have
|
||||||
|
// this template at all.
|
||||||
|
VolumeObjectTO tmplTO = new VolumeObjectTO();
|
||||||
|
tmplTO.setDataStore(store.getTO());
|
||||||
|
tmplTO.setPath(tInfo.getInstallPath());
|
||||||
|
tmplTO.setId(tInfo.getId());
|
||||||
|
DeleteCommand dtCommand = new DeleteCommand(tmplTO);
|
||||||
|
EndPoint ep = _epSelector.select(store);
|
||||||
|
Answer answer = ep.sendMessage(dtCommand);
|
||||||
|
if (answer == null || !answer.getResult()) {
|
||||||
|
s_logger.info("Failed to deleted volume at store: " + store.getName());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
String description = "Deleted volume " + tInfo.getTemplateName() + " on secondary storage " + storeId;
|
||||||
|
s_logger.info(description);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<Long, TemplateProp> listVolume(DataStore store) {
|
private Map<Long, TemplateProp> listVolume(DataStore store) {
|
||||||
|
|||||||
@ -91,9 +91,6 @@ import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand;
|
|||||||
import com.cloud.agent.api.CreateStoragePoolCommand;
|
import com.cloud.agent.api.CreateStoragePoolCommand;
|
||||||
import com.cloud.agent.api.CreateVolumeFromSnapshotAnswer;
|
import com.cloud.agent.api.CreateVolumeFromSnapshotAnswer;
|
||||||
import com.cloud.agent.api.CreateVolumeFromSnapshotCommand;
|
import com.cloud.agent.api.CreateVolumeFromSnapshotCommand;
|
||||||
import com.cloud.agent.api.DeleteSnapshotBackupAnswer;
|
|
||||||
import com.cloud.agent.api.DeleteSnapshotBackupCommand;
|
|
||||||
import com.cloud.agent.api.DeleteSnapshotsDirCommand;
|
|
||||||
import com.cloud.agent.api.DeleteStoragePoolCommand;
|
import com.cloud.agent.api.DeleteStoragePoolCommand;
|
||||||
import com.cloud.agent.api.FenceAnswer;
|
import com.cloud.agent.api.FenceAnswer;
|
||||||
import com.cloud.agent.api.FenceCommand;
|
import com.cloud.agent.api.FenceCommand;
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package com.cloud.agent.manager;
|
package com.cloud.agent.manager;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.storage.command.DeleteCommand;
|
||||||
import org.apache.cloudstack.storage.command.DownloadCommand;
|
import org.apache.cloudstack.storage.command.DownloadCommand;
|
||||||
import org.apache.cloudstack.storage.command.DownloadProgressCommand;
|
import org.apache.cloudstack.storage.command.DownloadProgressCommand;
|
||||||
|
|
||||||
@ -29,7 +30,6 @@ import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand;
|
|||||||
import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand;
|
import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand;
|
||||||
import com.cloud.agent.api.CreateStoragePoolCommand;
|
import com.cloud.agent.api.CreateStoragePoolCommand;
|
||||||
import com.cloud.agent.api.CreateVolumeFromSnapshotCommand;
|
import com.cloud.agent.api.CreateVolumeFromSnapshotCommand;
|
||||||
import com.cloud.agent.api.DeleteSnapshotBackupCommand;
|
|
||||||
import com.cloud.agent.api.DeleteStoragePoolCommand;
|
import com.cloud.agent.api.DeleteStoragePoolCommand;
|
||||||
import com.cloud.agent.api.GetStorageStatsAnswer;
|
import com.cloud.agent.api.GetStorageStatsAnswer;
|
||||||
import com.cloud.agent.api.GetStorageStatsCommand;
|
import com.cloud.agent.api.GetStorageStatsCommand;
|
||||||
@ -42,7 +42,6 @@ import com.cloud.agent.api.storage.CopyVolumeAnswer;
|
|||||||
import com.cloud.agent.api.storage.CopyVolumeCommand;
|
import com.cloud.agent.api.storage.CopyVolumeCommand;
|
||||||
import com.cloud.agent.api.storage.CreateAnswer;
|
import com.cloud.agent.api.storage.CreateAnswer;
|
||||||
import com.cloud.agent.api.storage.CreateCommand;
|
import com.cloud.agent.api.storage.CreateCommand;
|
||||||
import com.cloud.agent.api.storage.DeleteTemplateCommand;
|
|
||||||
import com.cloud.agent.api.storage.DestroyCommand;
|
import com.cloud.agent.api.storage.DestroyCommand;
|
||||||
import com.cloud.agent.api.storage.ListTemplateCommand;
|
import com.cloud.agent.api.storage.ListTemplateCommand;
|
||||||
import com.cloud.agent.api.storage.ListVolumeCommand;
|
import com.cloud.agent.api.storage.ListVolumeCommand;
|
||||||
@ -73,9 +72,10 @@ public interface MockStorageManager extends Manager {
|
|||||||
public GetStorageStatsAnswer GetStorageStats(GetStorageStatsCommand cmd);
|
public GetStorageStatsAnswer GetStorageStats(GetStorageStatsCommand cmd);
|
||||||
public Answer ManageSnapshot(ManageSnapshotCommand cmd);
|
public Answer ManageSnapshot(ManageSnapshotCommand cmd);
|
||||||
public Answer BackupSnapshot(BackupSnapshotCommand cmd, SimulatorInfo info);
|
public Answer BackupSnapshot(BackupSnapshotCommand cmd, SimulatorInfo info);
|
||||||
public Answer DeleteSnapshotBackup(DeleteSnapshotBackupCommand cmd);
|
//public Answer DeleteSnapshotBackup(DeleteSnapshotBackupCommand cmd);
|
||||||
public Answer CreateVolumeFromSnapshot(CreateVolumeFromSnapshotCommand cmd);
|
public Answer CreateVolumeFromSnapshot(CreateVolumeFromSnapshotCommand cmd);
|
||||||
public Answer DeleteTemplate(DeleteTemplateCommand cmd);
|
//public Answer DeleteTemplate(DeleteTemplateCommand cmd);
|
||||||
|
public Answer Delete(DeleteCommand cmd);
|
||||||
public Answer SecStorageVMSetup(SecStorageVMSetupCommand cmd);
|
public Answer SecStorageVMSetup(SecStorageVMSetupCommand cmd);
|
||||||
|
|
||||||
public void preinstallTemplates(String url, long zoneId);
|
public void preinstallTemplates(String url, long zoneId);
|
||||||
|
|||||||
@ -28,7 +28,6 @@ import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand;
|
|||||||
import com.cloud.agent.api.CreateStoragePoolCommand;
|
import com.cloud.agent.api.CreateStoragePoolCommand;
|
||||||
import com.cloud.agent.api.CreateVolumeFromSnapshotAnswer;
|
import com.cloud.agent.api.CreateVolumeFromSnapshotAnswer;
|
||||||
import com.cloud.agent.api.CreateVolumeFromSnapshotCommand;
|
import com.cloud.agent.api.CreateVolumeFromSnapshotCommand;
|
||||||
import com.cloud.agent.api.DeleteSnapshotBackupCommand;
|
|
||||||
import com.cloud.agent.api.DeleteStoragePoolCommand;
|
import com.cloud.agent.api.DeleteStoragePoolCommand;
|
||||||
import com.cloud.agent.api.GetStorageStatsAnswer;
|
import com.cloud.agent.api.GetStorageStatsAnswer;
|
||||||
import com.cloud.agent.api.GetStorageStatsCommand;
|
import com.cloud.agent.api.GetStorageStatsCommand;
|
||||||
@ -45,7 +44,6 @@ import com.cloud.agent.api.storage.CopyVolumeCommand;
|
|||||||
import com.cloud.agent.api.storage.CreateAnswer;
|
import com.cloud.agent.api.storage.CreateAnswer;
|
||||||
import com.cloud.agent.api.storage.CreateCommand;
|
import com.cloud.agent.api.storage.CreateCommand;
|
||||||
import com.cloud.agent.api.storage.CreatePrivateTemplateAnswer;
|
import com.cloud.agent.api.storage.CreatePrivateTemplateAnswer;
|
||||||
import com.cloud.agent.api.storage.DeleteTemplateCommand;
|
|
||||||
import com.cloud.agent.api.storage.DestroyCommand;
|
import com.cloud.agent.api.storage.DestroyCommand;
|
||||||
import com.cloud.agent.api.storage.DownloadAnswer;
|
import com.cloud.agent.api.storage.DownloadAnswer;
|
||||||
import com.cloud.agent.api.storage.ListTemplateAnswer;
|
import com.cloud.agent.api.storage.ListTemplateAnswer;
|
||||||
@ -54,7 +52,9 @@ import com.cloud.agent.api.storage.ListVolumeAnswer;
|
|||||||
import com.cloud.agent.api.storage.ListVolumeCommand;
|
import com.cloud.agent.api.storage.ListVolumeCommand;
|
||||||
import com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer;
|
import com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer;
|
||||||
import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;
|
import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;
|
||||||
|
import com.cloud.agent.api.to.DataObjectType;
|
||||||
import com.cloud.agent.api.to.DataStoreTO;
|
import com.cloud.agent.api.to.DataStoreTO;
|
||||||
|
import com.cloud.agent.api.to.DataTO;
|
||||||
import com.cloud.agent.api.to.StorageFilerTO;
|
import com.cloud.agent.api.to.StorageFilerTO;
|
||||||
import com.cloud.agent.api.to.VolumeTO;
|
import com.cloud.agent.api.to.VolumeTO;
|
||||||
import com.cloud.simulator.MockHost;
|
import com.cloud.simulator.MockHost;
|
||||||
@ -80,6 +80,7 @@ import com.cloud.utils.exception.CloudRuntimeException;
|
|||||||
import com.cloud.vm.DiskProfile;
|
import com.cloud.vm.DiskProfile;
|
||||||
import com.cloud.vm.VirtualMachine.State;
|
import com.cloud.vm.VirtualMachine.State;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.storage.command.DeleteCommand;
|
||||||
import org.apache.cloudstack.storage.command.DownloadCommand;
|
import org.apache.cloudstack.storage.command.DownloadCommand;
|
||||||
import org.apache.cloudstack.storage.command.DownloadProgressCommand;
|
import org.apache.cloudstack.storage.command.DownloadProgressCommand;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
@ -782,28 +783,6 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
|
|||||||
return new BackupSnapshotAnswer(cmd, true, null, newsnapshot.getName(), true);
|
return new BackupSnapshotAnswer(cmd, true, null, newsnapshot.getName(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Answer DeleteSnapshotBackup(DeleteSnapshotBackupCommand cmd) {
|
|
||||||
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
|
|
||||||
try {
|
|
||||||
txn.start();
|
|
||||||
MockVolumeVO backSnapshot = _mockVolumeDao.findByName(cmd.getSnapshotUuid());
|
|
||||||
if (backSnapshot == null) {
|
|
||||||
return new Answer(cmd, false, "can't find the backupsnapshot: " + cmd.getSnapshotUuid());
|
|
||||||
}
|
|
||||||
_mockVolumeDao.remove(backSnapshot.getId());
|
|
||||||
txn.commit();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
txn.rollback();
|
|
||||||
throw new CloudRuntimeException("Error when deleting snapshot");
|
|
||||||
} finally {
|
|
||||||
txn.close();
|
|
||||||
txn = Transaction.open(Transaction.CLOUD_DB);
|
|
||||||
txn.close();
|
|
||||||
}
|
|
||||||
return new Answer(cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CreateVolumeFromSnapshotAnswer CreateVolumeFromSnapshot(CreateVolumeFromSnapshotCommand cmd) {
|
public CreateVolumeFromSnapshotAnswer CreateVolumeFromSnapshot(CreateVolumeFromSnapshotCommand cmd) {
|
||||||
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
|
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
|
||||||
@ -858,20 +837,21 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
|
|||||||
return new CreateVolumeFromSnapshotAnswer(cmd, true, null, volume.getPath());
|
return new CreateVolumeFromSnapshotAnswer(cmd, true, null, volume.getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Answer DeleteTemplate(DeleteTemplateCommand cmd) {
|
public Answer Delete(DeleteCommand cmd) {
|
||||||
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
|
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
|
||||||
try {
|
try {
|
||||||
txn.start();
|
txn.start();
|
||||||
MockVolumeVO template = _mockVolumeDao.findByStoragePathAndType(cmd.getTemplatePath());
|
MockVolumeVO template = _mockVolumeDao.findByStoragePathAndType(cmd.getData().getPath());
|
||||||
if (template == null) {
|
if (template == null) {
|
||||||
return new Answer(cmd, false, "can't find template:" + cmd.getTemplatePath());
|
return new Answer(cmd, false, "can't find object to delete:" + cmd.getData().getPath());
|
||||||
}
|
}
|
||||||
_mockVolumeDao.remove(template.getId());
|
_mockVolumeDao.remove(template.getId());
|
||||||
txn.commit();
|
txn.commit();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
txn.rollback();
|
txn.rollback();
|
||||||
throw new CloudRuntimeException("Error when deleting template");
|
throw new CloudRuntimeException("Error when deleting object");
|
||||||
} finally {
|
} finally {
|
||||||
txn.close();
|
txn.close();
|
||||||
txn = Transaction.open(Transaction.CLOUD_DB);
|
txn = Transaction.open(Transaction.CLOUD_DB);
|
||||||
@ -880,6 +860,9 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
|
|||||||
return new Answer(cmd);
|
return new Answer(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Answer SecStorageVMSetup(SecStorageVMSetupCommand cmd) {
|
public Answer SecStorageVMSetup(SecStorageVMSetupCommand cmd) {
|
||||||
return new Answer(cmd);
|
return new Answer(cmd);
|
||||||
|
|||||||
@ -26,6 +26,7 @@ import javax.naming.ConfigurationException;
|
|||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.storage.command.DeleteCommand;
|
||||||
import org.apache.cloudstack.storage.command.DownloadCommand;
|
import org.apache.cloudstack.storage.command.DownloadCommand;
|
||||||
import org.apache.cloudstack.storage.command.DownloadProgressCommand;
|
import org.apache.cloudstack.storage.command.DownloadProgressCommand;
|
||||||
|
|
||||||
@ -46,7 +47,6 @@ import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand;
|
|||||||
import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand;
|
import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand;
|
||||||
import com.cloud.agent.api.CreateStoragePoolCommand;
|
import com.cloud.agent.api.CreateStoragePoolCommand;
|
||||||
import com.cloud.agent.api.CreateVolumeFromSnapshotCommand;
|
import com.cloud.agent.api.CreateVolumeFromSnapshotCommand;
|
||||||
import com.cloud.agent.api.DeleteSnapshotBackupCommand;
|
|
||||||
import com.cloud.agent.api.DeleteStoragePoolCommand;
|
import com.cloud.agent.api.DeleteStoragePoolCommand;
|
||||||
import com.cloud.agent.api.GetDomRVersionCmd;
|
import com.cloud.agent.api.GetDomRVersionCmd;
|
||||||
import com.cloud.agent.api.GetHostStatsCommand;
|
import com.cloud.agent.api.GetHostStatsCommand;
|
||||||
@ -80,7 +80,6 @@ import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
|
|||||||
import com.cloud.agent.api.routing.VmDataCommand;
|
import com.cloud.agent.api.routing.VmDataCommand;
|
||||||
import com.cloud.agent.api.storage.CopyVolumeCommand;
|
import com.cloud.agent.api.storage.CopyVolumeCommand;
|
||||||
import com.cloud.agent.api.storage.CreateCommand;
|
import com.cloud.agent.api.storage.CreateCommand;
|
||||||
import com.cloud.agent.api.storage.DeleteTemplateCommand;
|
|
||||||
import com.cloud.agent.api.storage.DestroyCommand;
|
import com.cloud.agent.api.storage.DestroyCommand;
|
||||||
import com.cloud.agent.api.storage.ListTemplateCommand;
|
import com.cloud.agent.api.storage.ListTemplateCommand;
|
||||||
import com.cloud.agent.api.storage.ListVolumeCommand;
|
import com.cloud.agent.api.storage.ListVolumeCommand;
|
||||||
@ -279,12 +278,10 @@ public class SimulatorManagerImpl extends ManagerBase implements SimulatorManage
|
|||||||
return _mockStorageMgr.ManageSnapshot((ManageSnapshotCommand)cmd);
|
return _mockStorageMgr.ManageSnapshot((ManageSnapshotCommand)cmd);
|
||||||
} else if (cmd instanceof BackupSnapshotCommand) {
|
} else if (cmd instanceof BackupSnapshotCommand) {
|
||||||
return _mockStorageMgr.BackupSnapshot((BackupSnapshotCommand)cmd, info);
|
return _mockStorageMgr.BackupSnapshot((BackupSnapshotCommand)cmd, info);
|
||||||
} else if (cmd instanceof DeleteSnapshotBackupCommand) {
|
|
||||||
return _mockStorageMgr.DeleteSnapshotBackup((DeleteSnapshotBackupCommand)cmd);
|
|
||||||
} else if (cmd instanceof CreateVolumeFromSnapshotCommand) {
|
} else if (cmd instanceof CreateVolumeFromSnapshotCommand) {
|
||||||
return _mockStorageMgr.CreateVolumeFromSnapshot((CreateVolumeFromSnapshotCommand)cmd);
|
return _mockStorageMgr.CreateVolumeFromSnapshot((CreateVolumeFromSnapshotCommand)cmd);
|
||||||
} else if (cmd instanceof DeleteTemplateCommand) {
|
} else if (cmd instanceof DeleteCommand) {
|
||||||
return _mockStorageMgr.DeleteTemplate((DeleteTemplateCommand)cmd);
|
return _mockStorageMgr.Delete((DeleteCommand)cmd);
|
||||||
} else if (cmd instanceof SecStorageVMSetupCommand) {
|
} else if (cmd instanceof SecStorageVMSetupCommand) {
|
||||||
return _mockStorageMgr.SecStorageVMSetup((SecStorageVMSetupCommand)cmd);
|
return _mockStorageMgr.SecStorageVMSetup((SecStorageVMSetupCommand)cmd);
|
||||||
} else if (cmd instanceof CreatePrivateTemplateFromSnapshotCommand) {
|
} else if (cmd instanceof CreatePrivateTemplateFromSnapshotCommand) {
|
||||||
|
|||||||
@ -65,8 +65,10 @@ import org.apache.cloudstack.engine.subsystem.api.storage.ImageStoreProvider;
|
|||||||
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
|
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
|
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
|
import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateService;
|
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateService;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
|
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService;
|
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult;
|
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
|
import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
|
||||||
@ -90,10 +92,7 @@ import com.cloud.agent.AgentManager;
|
|||||||
import com.cloud.agent.api.Answer;
|
import com.cloud.agent.api.Answer;
|
||||||
import com.cloud.agent.api.Command;
|
import com.cloud.agent.api.Command;
|
||||||
import com.cloud.agent.api.StoragePoolInfo;
|
import com.cloud.agent.api.StoragePoolInfo;
|
||||||
import com.cloud.agent.api.storage.DeleteTemplateCommand;
|
|
||||||
import com.cloud.agent.api.storage.DeleteVolumeCommand;
|
|
||||||
import com.cloud.agent.manager.Commands;
|
import com.cloud.agent.manager.Commands;
|
||||||
import com.cloud.alert.AlertManager;
|
|
||||||
import com.cloud.api.ApiDBUtils;
|
import com.cloud.api.ApiDBUtils;
|
||||||
import com.cloud.api.query.dao.TemplateJoinDao;
|
import com.cloud.api.query.dao.TemplateJoinDao;
|
||||||
import com.cloud.api.query.vo.TemplateJoinVO;
|
import com.cloud.api.query.vo.TemplateJoinVO;
|
||||||
@ -112,11 +111,8 @@ import com.cloud.dc.DataCenterVO;
|
|||||||
import com.cloud.dc.HostPodVO;
|
import com.cloud.dc.HostPodVO;
|
||||||
import com.cloud.dc.dao.ClusterDao;
|
import com.cloud.dc.dao.ClusterDao;
|
||||||
import com.cloud.dc.dao.DataCenterDao;
|
import com.cloud.dc.dao.DataCenterDao;
|
||||||
import com.cloud.dc.dao.HostPodDao;
|
|
||||||
import com.cloud.deploy.DataCenterDeployment;
|
import com.cloud.deploy.DataCenterDeployment;
|
||||||
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
|
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
|
||||||
import com.cloud.domain.dao.DomainDao;
|
|
||||||
import com.cloud.event.dao.EventDao;
|
|
||||||
import com.cloud.exception.AgentUnavailableException;
|
import com.cloud.exception.AgentUnavailableException;
|
||||||
import com.cloud.exception.ConnectionException;
|
import com.cloud.exception.ConnectionException;
|
||||||
import com.cloud.exception.DiscoveryException;
|
import com.cloud.exception.DiscoveryException;
|
||||||
@ -133,39 +129,28 @@ import com.cloud.host.Status;
|
|||||||
import com.cloud.host.dao.HostDao;
|
import com.cloud.host.dao.HostDao;
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
import com.cloud.hypervisor.HypervisorGuruManager;
|
import com.cloud.hypervisor.HypervisorGuruManager;
|
||||||
import com.cloud.hypervisor.dao.HypervisorCapabilitiesDao;
|
|
||||||
import com.cloud.org.Grouping;
|
import com.cloud.org.Grouping;
|
||||||
import com.cloud.org.Grouping.AllocationState;
|
import com.cloud.org.Grouping.AllocationState;
|
||||||
import com.cloud.resource.ResourceState;
|
import com.cloud.resource.ResourceState;
|
||||||
import com.cloud.server.ManagementServer;
|
import com.cloud.server.ManagementServer;
|
||||||
import com.cloud.server.StatsCollector;
|
import com.cloud.server.StatsCollector;
|
||||||
import com.cloud.service.dao.ServiceOfferingDao;
|
|
||||||
import com.cloud.storage.Storage.ImageFormat;
|
import com.cloud.storage.Storage.ImageFormat;
|
||||||
import com.cloud.storage.Storage.StoragePoolType;
|
import com.cloud.storage.Storage.StoragePoolType;
|
||||||
import com.cloud.storage.Volume.Type;
|
import com.cloud.storage.Volume.Type;
|
||||||
import com.cloud.storage.dao.DiskOfferingDao;
|
|
||||||
import com.cloud.storage.dao.SnapshotDao;
|
import com.cloud.storage.dao.SnapshotDao;
|
||||||
import com.cloud.storage.dao.SnapshotPolicyDao;
|
|
||||||
import com.cloud.storage.dao.StoragePoolHostDao;
|
import com.cloud.storage.dao.StoragePoolHostDao;
|
||||||
import com.cloud.storage.dao.StoragePoolWorkDao;
|
import com.cloud.storage.dao.StoragePoolWorkDao;
|
||||||
import com.cloud.storage.dao.VMTemplateDao;
|
import com.cloud.storage.dao.VMTemplateDao;
|
||||||
import com.cloud.storage.dao.VMTemplatePoolDao;
|
import com.cloud.storage.dao.VMTemplatePoolDao;
|
||||||
import com.cloud.storage.dao.VMTemplateS3Dao;
|
|
||||||
import com.cloud.storage.dao.VMTemplateSwiftDao;
|
|
||||||
import com.cloud.storage.dao.VMTemplateZoneDao;
|
import com.cloud.storage.dao.VMTemplateZoneDao;
|
||||||
import com.cloud.storage.dao.VolumeDao;
|
import com.cloud.storage.dao.VolumeDao;
|
||||||
import com.cloud.storage.listener.StoragePoolMonitor;
|
import com.cloud.storage.listener.StoragePoolMonitor;
|
||||||
import com.cloud.storage.listener.VolumeStateListener;
|
import com.cloud.storage.listener.VolumeStateListener;
|
||||||
import com.cloud.storage.s3.S3Manager;
|
|
||||||
import com.cloud.storage.secondary.SecondaryStorageVmManager;
|
|
||||||
import com.cloud.storage.snapshot.SnapshotManager;
|
|
||||||
import com.cloud.tags.dao.ResourceTagDao;
|
|
||||||
import com.cloud.template.TemplateManager;
|
import com.cloud.template.TemplateManager;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.user.AccountManager;
|
import com.cloud.user.AccountManager;
|
||||||
import com.cloud.user.User;
|
import com.cloud.user.User;
|
||||||
import com.cloud.user.UserContext;
|
import com.cloud.user.UserContext;
|
||||||
import com.cloud.user.dao.AccountDao;
|
|
||||||
import com.cloud.user.dao.UserDao;
|
import com.cloud.user.dao.UserDao;
|
||||||
import com.cloud.utils.NumbersUtil;
|
import com.cloud.utils.NumbersUtil;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
@ -184,13 +169,10 @@ import com.cloud.utils.db.SearchCriteria.Op;
|
|||||||
import com.cloud.utils.db.Transaction;
|
import com.cloud.utils.db.Transaction;
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
import com.cloud.vm.DiskProfile;
|
import com.cloud.vm.DiskProfile;
|
||||||
import com.cloud.vm.UserVmManager;
|
|
||||||
import com.cloud.vm.VMInstanceVO;
|
import com.cloud.vm.VMInstanceVO;
|
||||||
import com.cloud.vm.VirtualMachine.State;
|
import com.cloud.vm.VirtualMachine.State;
|
||||||
import com.cloud.vm.VirtualMachineProfile;
|
import com.cloud.vm.VirtualMachineProfile;
|
||||||
import com.cloud.vm.VirtualMachineProfileImpl;
|
import com.cloud.vm.VirtualMachineProfileImpl;
|
||||||
import com.cloud.vm.dao.ConsoleProxyDao;
|
|
||||||
import com.cloud.vm.dao.UserVmDao;
|
|
||||||
import com.cloud.vm.dao.VMInstanceDao;
|
import com.cloud.vm.dao.VMInstanceDao;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@ -200,8 +182,6 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
|||||||
|
|
||||||
protected String _name;
|
protected String _name;
|
||||||
@Inject
|
@Inject
|
||||||
protected UserVmManager _userVmMgr;
|
|
||||||
@Inject
|
|
||||||
protected AgentManager _agentMgr;
|
protected AgentManager _agentMgr;
|
||||||
@Inject
|
@Inject
|
||||||
protected TemplateManager _tmpltMgr;
|
protected TemplateManager _tmpltMgr;
|
||||||
@ -214,34 +194,16 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
|||||||
@Inject
|
@Inject
|
||||||
protected HostDao _hostDao;
|
protected HostDao _hostDao;
|
||||||
@Inject
|
@Inject
|
||||||
protected ConsoleProxyDao _consoleProxyDao;
|
|
||||||
@Inject
|
|
||||||
protected SnapshotDao _snapshotDao;
|
protected SnapshotDao _snapshotDao;
|
||||||
@Inject
|
@Inject
|
||||||
protected SnapshotManager _snapMgr;
|
|
||||||
@Inject
|
|
||||||
protected SnapshotPolicyDao _snapshotPolicyDao;
|
|
||||||
@Inject
|
|
||||||
protected StoragePoolHostDao _storagePoolHostDao;
|
protected StoragePoolHostDao _storagePoolHostDao;
|
||||||
@Inject
|
@Inject
|
||||||
protected AlertManager _alertMgr;
|
|
||||||
@Inject
|
|
||||||
protected VMTemplatePoolDao _vmTemplatePoolDao = null;
|
protected VMTemplatePoolDao _vmTemplatePoolDao = null;
|
||||||
@Inject
|
@Inject
|
||||||
protected VMTemplateZoneDao _vmTemplateZoneDao;
|
protected VMTemplateZoneDao _vmTemplateZoneDao;
|
||||||
@Inject
|
@Inject
|
||||||
protected VMTemplateSwiftDao _vmTemplateSwiftDao = null;
|
|
||||||
@Inject
|
|
||||||
protected VMTemplateS3Dao _vmTemplateS3Dao;
|
|
||||||
@Inject
|
|
||||||
protected S3Manager _s3Mgr;
|
|
||||||
@Inject
|
|
||||||
protected VMTemplateDao _vmTemplateDao = null;
|
protected VMTemplateDao _vmTemplateDao = null;
|
||||||
@Inject
|
@Inject
|
||||||
protected StoragePoolHostDao _poolHostDao = null;
|
|
||||||
@Inject
|
|
||||||
protected UserVmDao _userVmDao;
|
|
||||||
@Inject
|
|
||||||
protected VMInstanceDao _vmInstanceDao;
|
protected VMInstanceDao _vmInstanceDao;
|
||||||
@Inject
|
@Inject
|
||||||
protected PrimaryDataStoreDao _storagePoolDao = null;
|
protected PrimaryDataStoreDao _storagePoolDao = null;
|
||||||
@ -262,22 +224,10 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
|||||||
@Inject
|
@Inject
|
||||||
protected CapacityManager _capacityMgr;
|
protected CapacityManager _capacityMgr;
|
||||||
@Inject
|
@Inject
|
||||||
protected DiskOfferingDao _diskOfferingDao;
|
|
||||||
@Inject
|
|
||||||
protected AccountDao _accountDao;
|
|
||||||
@Inject
|
|
||||||
protected EventDao _eventDao = null;
|
|
||||||
@Inject
|
|
||||||
protected DataCenterDao _dcDao = null;
|
protected DataCenterDao _dcDao = null;
|
||||||
@Inject
|
@Inject
|
||||||
protected HostPodDao _podDao = null;
|
|
||||||
@Inject
|
|
||||||
protected VMTemplateDao _templateDao;
|
protected VMTemplateDao _templateDao;
|
||||||
@Inject
|
@Inject
|
||||||
protected ServiceOfferingDao _offeringDao;
|
|
||||||
@Inject
|
|
||||||
protected DomainDao _domainDao;
|
|
||||||
@Inject
|
|
||||||
protected UserDao _userDao;
|
protected UserDao _userDao;
|
||||||
@Inject
|
@Inject
|
||||||
protected ClusterDao _clusterDao;
|
protected ClusterDao _clusterDao;
|
||||||
@ -288,8 +238,6 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
|||||||
@Inject
|
@Inject
|
||||||
protected VolumeDao _volumeDao;
|
protected VolumeDao _volumeDao;
|
||||||
@Inject
|
@Inject
|
||||||
protected SecondaryStorageVmManager _ssvmMgr;
|
|
||||||
@Inject
|
|
||||||
ConfigurationDao _configDao;
|
ConfigurationDao _configDao;
|
||||||
@Inject
|
@Inject
|
||||||
ManagementServer _msServer;
|
ManagementServer _msServer;
|
||||||
@ -306,13 +254,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
|||||||
@Inject
|
@Inject
|
||||||
SnapshotDataFactory snapshotFactory;
|
SnapshotDataFactory snapshotFactory;
|
||||||
@Inject
|
@Inject
|
||||||
protected HypervisorCapabilitiesDao _hypervisorCapabilitiesDao;
|
|
||||||
@Inject
|
|
||||||
ConfigurationServer _configServer;
|
ConfigurationServer _configServer;
|
||||||
|
|
||||||
@Inject
|
|
||||||
protected ResourceTagDao _resourceTagDao;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
DataStoreManager _dataStoreMgr;
|
DataStoreManager _dataStoreMgr;
|
||||||
@Inject
|
@Inject
|
||||||
@ -514,7 +456,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
|||||||
* cmd
|
* cmd
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
List<StoragePoolHostVO> poolHosts = _poolHostDao.listByHostStatus(poolVO.getId(), Status.Up);
|
List<StoragePoolHostVO> poolHosts = _storagePoolHostDao.listByHostStatus(poolVO.getId(), Status.Up);
|
||||||
Collections.shuffle(poolHosts);
|
Collections.shuffle(poolHosts);
|
||||||
if (poolHosts != null && poolHosts.size() > 0) {
|
if (poolHosts != null && poolHosts.size() > 0) {
|
||||||
for (StoragePoolHostVO sphvo : poolHosts) {
|
for (StoragePoolHostVO sphvo : poolHosts) {
|
||||||
@ -1153,10 +1095,10 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
|||||||
}
|
}
|
||||||
String installPath = destroyedTemplateStoreVO.getInstallPath();
|
String installPath = destroyedTemplateStoreVO.getInstallPath();
|
||||||
|
|
||||||
|
TemplateInfo tmpl = tmplFactory.getTemplate(destroyedTemplateStoreVO.getTemplateId(), store);
|
||||||
if (installPath != null) {
|
if (installPath != null) {
|
||||||
EndPoint ep = _epSelector.select(store);
|
EndPoint ep = _epSelector.select(store);
|
||||||
Command cmd = new DeleteTemplateCommand(store.getTO(), destroyedTemplateStoreVO.getInstallPath(),
|
Command cmd = new DeleteCommand(tmpl.getTO());
|
||||||
destroyedTemplate.getId(), destroyedTemplate.getAccountId());
|
|
||||||
Answer answer = ep.sendMessage(cmd);
|
Answer answer = ep.sendMessage(cmd);
|
||||||
|
|
||||||
if (answer == null || !answer.getResult()) {
|
if (answer == null || !answer.getResult()) {
|
||||||
@ -1230,10 +1172,11 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
|||||||
|
|
||||||
String installPath = destroyedStoreVO.getInstallPath();
|
String installPath = destroyedStoreVO.getInstallPath();
|
||||||
|
|
||||||
|
VolumeInfo vol = this.volFactory.getVolume(destroyedStoreVO.getVolumeId(), store);
|
||||||
|
|
||||||
if (installPath != null) {
|
if (installPath != null) {
|
||||||
EndPoint ep = _epSelector.select(store);
|
EndPoint ep = _epSelector.select(store);
|
||||||
DeleteVolumeCommand cmd = new DeleteVolumeCommand(store.getTO(), destroyedStoreVO.getVolumeId(),
|
DeleteCommand cmd = new DeleteCommand(vol.getTO());
|
||||||
destroyedStoreVO.getInstallPath());
|
|
||||||
Answer answer = ep.sendMessage(cmd);
|
Answer answer = ep.sendMessage(cmd);
|
||||||
if (answer == null || !answer.getResult()) {
|
if (answer == null || !answer.getResult()) {
|
||||||
s_logger.debug("Failed to delete " + destroyedStoreVO + " due to "
|
s_logger.debug("Failed to delete " + destroyedStoreVO + " due to "
|
||||||
|
|||||||
@ -34,9 +34,11 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
import com.cloud.agent.AgentManager;
|
import com.cloud.agent.AgentManager;
|
||||||
import com.cloud.agent.api.Answer;
|
import com.cloud.agent.api.Answer;
|
||||||
import com.cloud.agent.api.storage.DeleteTemplateCommand;
|
|
||||||
import com.cloud.agent.api.to.SwiftTO;
|
import com.cloud.agent.api.to.SwiftTO;
|
||||||
import org.apache.cloudstack.api.command.admin.swift.AddSwiftCmd;
|
import org.apache.cloudstack.api.command.admin.swift.AddSwiftCmd;
|
||||||
|
import org.apache.cloudstack.storage.command.DeleteCommand;
|
||||||
|
import org.apache.cloudstack.storage.to.TemplateObjectTO;
|
||||||
|
|
||||||
import com.cloud.configuration.Config;
|
import com.cloud.configuration.Config;
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
import com.cloud.dc.DataCenterVO;
|
import com.cloud.dc.DataCenterVO;
|
||||||
@ -144,7 +146,10 @@ public class SwiftManagerImpl extends ManagerBase implements SwiftManager {
|
|||||||
s_logger.warn(msg);
|
s_logger.warn(msg);
|
||||||
throw new CloudRuntimeException(msg);
|
throw new CloudRuntimeException(msg);
|
||||||
}
|
}
|
||||||
Answer answer = _agentMgr.sendToSSVM(null, new DeleteTemplateCommand(swift, null, cmd.getId(), null));
|
TemplateObjectTO tmplTO = new TemplateObjectTO();
|
||||||
|
tmplTO.setDataStore(swift);
|
||||||
|
tmplTO.setId(cmd.getId());
|
||||||
|
Answer answer = _agentMgr.sendToSSVM(null, new DeleteCommand(tmplTO));
|
||||||
if (answer == null || !answer.getResult()) {
|
if (answer == null || !answer.getResult()) {
|
||||||
msg = "Failed to delete " + tmpltSwiftRef + " due to " + ((answer == null) ? "answer is null" : answer.getDetails());
|
msg = "Failed to delete " + tmpltSwiftRef + " due to " + ((answer == null) ? "answer is null" : answer.getDetails());
|
||||||
s_logger.warn(msg);
|
s_logger.warn(msg);
|
||||||
@ -170,7 +175,9 @@ public class SwiftManagerImpl extends ManagerBase implements SwiftManager {
|
|||||||
s_logger.warn(msg);
|
s_logger.warn(msg);
|
||||||
throw new CloudRuntimeException(msg);
|
throw new CloudRuntimeException(msg);
|
||||||
}
|
}
|
||||||
Answer answer = _agentMgr.sendToSSVM(null, new DeleteTemplateCommand(swift, null, cmd.getId(), null));
|
TemplateObjectTO tmplTO = new TemplateObjectTO();
|
||||||
|
tmplTO.setId(cmd.getId());
|
||||||
|
Answer answer = _agentMgr.sendToSSVM(null, new DeleteCommand(tmplTO));
|
||||||
if (answer == null || !answer.getResult()) {
|
if (answer == null || !answer.getResult()) {
|
||||||
msg = "Failed to delete " + tmpltSwiftRef + " due to " + ((answer == null) ? "answer is null" : answer.getDetails());
|
msg = "Failed to delete " + tmpltSwiftRef + " due to " + ((answer == null) ? "answer is null" : answer.getDetails());
|
||||||
s_logger.warn(msg);
|
s_logger.warn(msg);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user