use of com.emc.sa.service.vmware.tasks.DeleteDatastore in project coprhd-controller by CoprHD.
the class VMwareSupport method deleteNfsDatastore.
/**
* Deletes an NFS datastore. The datastore will be removed from all hosts.
*
* @param datastore
* the NFS datastore.
*/
public void deleteNfsDatastore(FileShareRestRep fileSystem, URI datacenterId, Datastore datastore) {
String datastoreName = datastore.getName();
List<HostSystem> hosts = getHostsForDatastore(datastore);
if (hosts.isEmpty()) {
throw new IllegalStateException("Datastore is not mounted by any hosts");
}
enterMaintenanceMode(datastore);
setStorageIOControl(datastore, false);
for (HostSystem host : hosts) {
execute(new DeleteDatastore(host, datastore));
}
removeNfsDatastoreTag(fileSystem, datacenterId, datastoreName);
}
use of com.emc.sa.service.vmware.tasks.DeleteDatastore in project coprhd-controller by CoprHD.
the class VMwareSupport method deleteVmfsDatastore.
/**
* Deletes a VMFS datastore. Because VMFS datastores are shared across hosts, it only needs to be deleted from a
* single host for it to be deleted.
*
* @param volumes
* the volumes backing the datastore.
* @param hostOrClusterId
* the id of the host or cluster where the datastore is mounted.
* @param datastore
* the datastore to delete
* @param detachLuns
* if true, detach the luns from each host
*/
public void deleteVmfsDatastore(Collection<VolumeRestRep> volumes, URI hostOrClusterId, final Datastore datastore, boolean detachLuns) {
List<HostSystem> hosts = getHostsForDatastore(datastore);
if (hosts.isEmpty()) {
throw new IllegalStateException("Datastore is not mounted by any hosts");
}
enterMaintenanceMode(datastore);
setStorageIOControl(datastore, false);
HostSystem mountedHost = getHostMountedDatastore(hosts, datastore);
if (mountedHost == null) {
throw new IllegalStateException("Datastore is not mounted by any hosts");
}
executeOnHosts(hosts, new HostSystemCallback() {
@Override
public void exec(HostSystem host) {
if (VMwareUtils.isDatastoreMountedOnHost(datastore, host)) {
unmountVmfsDatastore(host, datastore);
}
}
});
final Map<HostSystem, List<HostScsiDisk>> hostDisks = buildHostDiskMap(hosts, datastore);
execute(new DeleteDatastore(mountedHost, datastore));
if (detachLuns) {
executeOnHosts(hosts, new HostSystemCallback() {
@Override
public void exec(HostSystem host) {
List<HostScsiDisk> disks = hostDisks.get(host);
detachLuns(host, disks);
}
});
}
removeVmfsDatastoreTag(volumes, hostOrClusterId);
}
Aggregations