mirror of https://github.com/apache/cloudstack.git
cleanup, refactor; add plugin config keys
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
2604f81264
commit
b961a4d70b
|
|
@ -48,9 +48,20 @@ import java.util.HashMap;
|
|||
public class NASBackupProvider extends AdapterBase implements BackupProvider, Configurable {
|
||||
private static final Logger LOG = LogManager.getLogger(NASBackupProvider.class);
|
||||
|
||||
private final ConfigKey<String> NASDetails = new ConfigKey<>("Advanced", String.class,
|
||||
"backup.plugin.nas.details", "Default",
|
||||
"The NFS/NAS storage details", true, ConfigKey.Scope.Zone);
|
||||
private final ConfigKey<String> NasType = new ConfigKey<>("Advanced", String.class,
|
||||
"backup.plugin.nas.target.type", "nfs",
|
||||
"The NAS storage target type. Only supported: nfs and cephfs", true, ConfigKey.Scope.Zone);
|
||||
private final ConfigKey<String> NfsPool = new ConfigKey<>("Advanced", String.class,
|
||||
"backup.plugin.nas.nfs.pool", "",
|
||||
"The NFS NAS storage pool URL (format <domain|ip>:<path>", true, ConfigKey.Scope.Zone);
|
||||
|
||||
private final ConfigKey<String> CephFSPool = new ConfigKey<>("Advanced", String.class,
|
||||
"backup.plugin.nas.cephfs.pool", "",
|
||||
"The CephFS storage pool URL (format: <comma-separated domain|ip>:<path>)", true, ConfigKey.Scope.Zone);
|
||||
|
||||
private final ConfigKey<String> CephFSPoolCredentials = new ConfigKey<>("Advanced", String.class,
|
||||
"backup.plugin.nas.cephfs.credentials", "",
|
||||
"The CephFS storage pool URL (format: <name=username,secret=secretkey>)", true, ConfigKey.Scope.Zone);
|
||||
|
||||
@Inject
|
||||
private BackupDao backupDao;
|
||||
|
|
@ -70,28 +81,6 @@ public class NASBackupProvider extends AdapterBase implements BackupProvider, Co
|
|||
@Inject
|
||||
private VMInstanceDao vmInstanceDao;
|
||||
|
||||
@Override
|
||||
public ConfigKey<?>[] getConfigKeys() {
|
||||
return new ConfigKey[]{
|
||||
NASDetails
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "nas";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "NAS KVM Backup Plugin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConfigComponentName() {
|
||||
return BackupService.class.getSimpleName();
|
||||
}
|
||||
|
||||
protected Host getLastVMHypervisorHost(VirtualMachine vm) {
|
||||
Long hostId = vm.getLastHostId();
|
||||
if (hostId == null) {
|
||||
|
|
@ -129,6 +118,20 @@ public class NASBackupProvider extends AdapterBase implements BackupProvider, Co
|
|||
return hostDao.findById(hostId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean takeBackup(VirtualMachine vm) {
|
||||
// Find where the VM is currently running
|
||||
Host hostVO = getRunningVMHypervisorHost(vm);
|
||||
// Get retention Period for our Backup
|
||||
BackupOfferingVO vmBackupOffering = new BackupOfferingDaoImpl().findById(vm.getBackupOfferingId());
|
||||
|
||||
LOG.debug("Starting backup for VM ID " + vm.getUuid() + " on NAS provider");
|
||||
// TODO: initiate backup to NAS by KVM agent
|
||||
// TODO: perisist object based on Answer: backupDao.persist(backup);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean restoreVMFromBackup(VirtualMachine vm, Backup backup) {
|
||||
final Long zoneId = backup.getZoneId();
|
||||
|
|
@ -169,20 +172,6 @@ public class NASBackupProvider extends AdapterBase implements BackupProvider, Co
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean takeBackup(VirtualMachine vm) {
|
||||
// Find where the VM is currently running
|
||||
Host hostVO = getRunningVMHypervisorHost(vm);
|
||||
// Get retention Period for our Backup
|
||||
BackupOfferingVO vmBackupOffering = new BackupOfferingDaoImpl().findById(vm.getBackupOfferingId());
|
||||
|
||||
LOG.debug("Starting backup for VM ID " + vm.getUuid() + " on NAS provider");
|
||||
// TODO: initiate backup to NAS by KVM agent
|
||||
// TODO: perisist object based on Answer: backupDao.persist(backup);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteBackup(Backup backup, boolean forced) {
|
||||
|
||||
|
|
@ -215,6 +204,25 @@ public class NASBackupProvider extends AdapterBase implements BackupProvider, Co
|
|||
return metrics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean assignVMToBackupOffering(VirtualMachine vm, BackupOffering backupOffering) {
|
||||
return Hypervisor.HypervisorType.KVM.equals(vm.getHypervisorType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeVMFromBackupOffering(VirtualMachine vm) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean willDeleteBackupsOnOfferingRemoval() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncBackups(VirtualMachine vm, Backup.Metric metric) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BackupOffering> listBackupOfferings(Long zoneId) {
|
||||
return new ArrayList<>();
|
||||
|
|
@ -227,19 +235,27 @@ public class NASBackupProvider extends AdapterBase implements BackupProvider, Co
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean assignVMToBackupOffering(VirtualMachine vm, BackupOffering backupOffering) {
|
||||
return Hypervisor.HypervisorType.KVM.equals(vm.getHypervisorType());
|
||||
public ConfigKey<?>[] getConfigKeys() {
|
||||
return new ConfigKey[]{
|
||||
NasType,
|
||||
NfsPool,
|
||||
CephFSPool,
|
||||
CephFSPoolCredentials
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeVMFromBackupOffering(VirtualMachine vm) {
|
||||
return true;
|
||||
public String getName() {
|
||||
return "nas";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncBackups(VirtualMachine vm, Backup.Metric metric) {
|
||||
public String getDescription() {
|
||||
return "NAS KVM Backup Plugin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean willDeleteBackupsOnOfferingRemoval() { return false; }
|
||||
public String getConfigComponentName() {
|
||||
return BackupService.class.getSimpleName();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue