use of com.iwave.ext.vmware.HostStorageAPI in project coprhd-controller by CoprHD.
the class RefreshStorage method execute.
@Override
public void execute() throws Exception {
debug("Executing: %s", getDetail());
for (HostSystem host : hosts) {
try {
HostStorageAPI storageAPI = new HostStorageAPI(host);
storageAPI.refreshStorage();
} catch (Exception e) {
logWarn("RefreshStorage.detail.error", host.getName());
}
}
}
use of com.iwave.ext.vmware.HostStorageAPI in project coprhd-controller by CoprHD.
the class UnmountVmfsDatastore method tryExecute.
@Override
protected Void tryExecute() {
final String dataStoreName = datastore.getName();
for (HostFileSystemMountInfo mount : new HostStorageAPI(host).getStorageSystem().getFileSystemVolumeInfo().getMountInfo()) {
HostFileSystemVolume mountVolume = mount.getVolume();
if (mountVolume == null) {
warn("No volume attached to mount : " + mount.getMountInfo().getPath());
continue;
}
if (mount.getVolume() instanceof HostVmfsVolume && dataStoreName.equals(mount.getVolume().getName())) {
HostVmfsVolume volume = (HostVmfsVolume) mountVolume;
String vmfsUuid = volume.getUuid();
info("Unmounting volume : " + vmfsUuid);
try {
new HostStorageAPI(host).getStorageSystem().unmountVmfsVolume(vmfsUuid);
} catch (RemoteException e) {
throw new VMWareException(e);
}
}
}
return null;
}
use of com.iwave.ext.vmware.HostStorageAPI in project coprhd-controller by CoprHD.
the class HostRescanDeviceController method getRescanAdapter.
private HostRescanAdapter getRescanAdapter(Host host) {
if (HostType.Linux.name().equalsIgnoreCase(host.getType())) {
return new LinuxSystemCLI(host.getHostName(), host.getPortNumber(), host.getUsername(), host.getPassword());
} else if (HostType.AIX.name().equalsIgnoreCase(host.getType())) {
return new AixSystem(host.getHostName(), host.getPortNumber(), host.getUsername(), host.getPassword());
} else if (HostType.HPUX.name().equalsIgnoreCase(host.getType())) {
return new HpuxSystem(host.getHostName(), host.getPortNumber(), host.getUsername(), host.getPassword());
} else if (HostType.Windows.name().equalsIgnoreCase(host.getType())) {
List<AuthnProvider> authProviders = new ArrayList<AuthnProvider>();
for (URI authProviderId : getDbClient().queryByType(AuthnProvider.class, true)) {
AuthnProvider authProvider = getDbClient().queryObject(AuthnProvider.class, authProviderId);
authProviders.add(authProvider);
}
KerberosUtil.initializeKerberos(authProviders);
return WindowsHostDiscoveryAdapter.createWindowsSystem(host);
} else if (HostType.Esx.name().equalsIgnoreCase(host.getType())) {
if (host.getUsername() != null && host.getPassword() != null) {
VCenterAPI vcenterAPI = EsxHostDiscoveryAdapter.createVCenterAPI(host);
List<HostSystem> hostSystems = vcenterAPI.listAllHostSystems();
if (hostSystems != null && !hostSystems.isEmpty()) {
return new HostStorageAPI(hostSystems.get(0));
} else {
return null;
}
} else if (host.getVcenterDataCenter() != null) {
// Lookup the vcenter datacenter and vcenter to retreive the HostSystem
VcenterDataCenter dataCenter = dbClient.queryObject(VcenterDataCenter.class, host.getVcenterDataCenter());
if (dataCenter == null || dataCenter.getInactive()) {
throw DeviceControllerException.exceptions.objectNotFound(host.getVcenterDataCenter());
}
Vcenter vcenter = dbClient.queryObject(Vcenter.class, dataCenter.getVcenter());
if (vcenter == null || vcenter.getInactive()) {
throw DeviceControllerException.exceptions.objectNotFound(dataCenter.getVcenter());
}
VCenterAPI vCenterAPI = VcenterDiscoveryAdapter.createVCenterAPI(vcenter);
String datacenterName = dataCenter.getLabel();
HostSystem hostSystem = vCenterAPI.findHostSystem(datacenterName, host.getHostName());
if (hostSystem != null) {
return new HostStorageAPI(hostSystem);
} else {
return null;
}
}
} else {
// Unanticipated host type
return null;
}
return null;
}
use of com.iwave.ext.vmware.HostStorageAPI in project coprhd-controller by CoprHD.
the class ComputeSystemControllerImpl method unmountAndDetach.
/**
* Unmounts and detaches every datastore and disk associated with the volumes in the export group.
* For each volume in the export group, the backed datastore is unmounted and the associated disk is detached from
* the host.
*
* @param exportGroupId
* export group that contains volumes
* @param hostId
* host to attach and mount to
* @param vcenterId
* vcenter that the host belongs to
* @param vcenterDatacenter
* vcenter datacenter that the host belongs to
* @param stepId
* the id of the workflow step
*/
public void unmountAndDetach(URI exportGroupId, URI hostId, URI vCenterId, URI vcenterDatacenter, String stepId) {
WorkflowStepCompleter.stepExecuting(stepId);
try {
Host esxHost = _dbClient.queryObject(Host.class, hostId);
Vcenter vCenter = _dbClient.queryObject(Vcenter.class, vCenterId);
VcenterDataCenter vCenterDataCenter = _dbClient.queryObject(VcenterDataCenter.class, vcenterDatacenter);
ExportGroup exportGroup = _dbClient.queryObject(ExportGroup.class, exportGroupId);
VCenterAPI api = VcenterDiscoveryAdapter.createVCenterAPI(vCenter);
HostSystem hostSystem = api.findHostSystem(vCenterDataCenter.getLabel(), esxHost.getLabel());
if (hostSystem == null) {
_log.info("Not able to find host " + esxHost.getLabel() + " in vCenter. Unable to validate");
WorkflowStepCompleter.stepSucceded(stepId);
return;
}
HostStorageAPI storageAPI = new HostStorageAPI(hostSystem);
Map<String, Datastore> wwnDatastores = getWwnDatastoreMap(hostSystem);
if (exportGroup != null && exportGroup.getVolumes() != null) {
for (String volume : exportGroup.getVolumes().keySet()) {
BlockObject blockObject = BlockObject.fetch(_dbClient, URI.create(volume));
if (blockObject != null) {
Datastore datastore = getDatastoreByWwn(wwnDatastores, blockObject.getWWN());
if (datastore != null) {
if (VMwareUtils.isDatastoreMountedOnHost(datastore, hostSystem)) {
boolean storageIOControlEnabled = datastore.getIormConfiguration().isEnabled();
if (storageIOControlEnabled) {
setStorageIOControl(api, datastore, false);
}
_log.info("Unmount datastore " + datastore.getName() + " from host " + esxHost.getLabel());
storageAPI.unmountVmfsDatastore(datastore);
if (storageIOControlEnabled) {
setStorageIOControl(api, datastore, true);
}
} else {
_log.info("Datastore " + datastore.getName() + " is not mounted on host " + esxHost.getLabel() + ". Skipping unmounting of datastore.");
}
}
}
// VBDU TODO: COP-28459, If datastore doesn't match, why do we need to run DetachSCSILun() ?
// Test mechanism to invoke a failure. No-op on production systems.
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_030);
for (HostScsiDisk entry : storageAPI.listScsiDisks()) {
if (VolumeWWNUtils.wwnMatches(VMwareUtils.getDiskWwn(entry), blockObject.getWWN())) {
if (!VMwareUtils.isDiskOff(entry)) {
_log.info("Detach SCSI Lun " + entry.getCanonicalName() + " from host " + esxHost.getLabel());
storageAPI.detachScsiLun(entry);
} else {
_log.info("SCSI Lun " + entry.getCanonicalName() + " is not in a valid state to detach");
}
}
}
storageAPI.refreshStorage();
// Test mechanism to invoke a failure. No-op on production systems.
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_031);
}
}
WorkflowStepCompleter.stepSucceded(stepId);
} catch (Exception ex) {
_log.error(ex.getMessage(), ex);
WorkflowStepCompleter.stepFailed(stepId, DeviceControllerException.errors.jobFailed(ex));
}
}
use of com.iwave.ext.vmware.HostStorageAPI in project coprhd-controller by CoprHD.
the class FindLunsBackingDatastore method executeTask.
@Override
public Set<String> executeTask() throws Exception {
List<HostScsiDisk> disks = new HostStorageAPI(host).listDisks(datastore);
Set<String> luns = Sets.newHashSet();
for (HostScsiDisk disk : disks) {
if (!validateCanonicalPrefix(disk.getCanonicalName())) {
logError("FindLunsBackingDatastore.failure.invalidprefix", disk.getCanonicalName());
}
String volumeWwn = VMwareUtils.getDiskWwn(disk);
if (StringUtils.isNotBlank(volumeWwn)) {
luns.add(volumeWwn);
}
}
return luns;
}
Aggregations