Search in sources :

Example 1 with VMWareException

use of com.iwave.ext.vmware.VMWareException in project coprhd-controller by CoprHD.

the class MountDatastore method tryExecute.

@Override
protected Void tryExecute() {
    final String dataStoreName = datastore.getName();
    for (HostFileSystemMountInfo mount : new HostStorageAPI(host).getStorageSystem().getFileSystemVolumeInfo().getMountInfo()) {
        if (mount != null) {
            HostFileSystemVolume mountVolume = mount.getVolume();
            if (mountVolume == null) {
                warn("No volume attached to mount : " + mount.getMountInfo().getPath());
                continue;
            }
            if (mount.getVolume() != null && mount.getVolume() instanceof HostVmfsVolume && dataStoreName.equals(mount.getVolume().getName())) {
                HostVmfsVolume volume = (HostVmfsVolume) mountVolume;
                String vmfsUuid = volume.getUuid();
                info("Mounting volume : " + vmfsUuid);
                try {
                    new HostStorageAPI(host).getStorageSystem().mountVmfsVolume(vmfsUuid);
                } catch (RemoteException e) {
                    throw new VMWareException(e);
                }
            }
        }
    }
    return null;
}
Also used : HostVmfsVolume(com.vmware.vim25.HostVmfsVolume) HostFileSystemVolume(com.vmware.vim25.HostFileSystemVolume) RemoteException(java.rmi.RemoteException) HostStorageAPI(com.iwave.ext.vmware.HostStorageAPI) HostFileSystemMountInfo(com.vmware.vim25.HostFileSystemMountInfo) VMWareException(com.iwave.ext.vmware.VMWareException)

Example 2 with VMWareException

use of com.iwave.ext.vmware.VMWareException in project coprhd-controller by CoprHD.

the class FindDatastore method tryExecute.

@Override
protected Datastore tryExecute() {
    debug("Executing: %s", getDetail());
    Datastore datastore = vcenter.findDatastore(datacenterName, datastoreName);
    if (datastore == null) {
        throw new VMWareException(String.format("Unable to find datastore %s in datacenter %s", datastoreName, datacenterName));
    }
    return datastore;
}
Also used : Datastore(com.vmware.vim25.mo.Datastore) VMWareException(com.iwave.ext.vmware.VMWareException)

Example 3 with VMWareException

use of com.iwave.ext.vmware.VMWareException 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;
}
Also used : HostVmfsVolume(com.vmware.vim25.HostVmfsVolume) HostFileSystemVolume(com.vmware.vim25.HostFileSystemVolume) RemoteException(java.rmi.RemoteException) HostStorageAPI(com.iwave.ext.vmware.HostStorageAPI) HostFileSystemMountInfo(com.vmware.vim25.HostFileSystemMountInfo) VMWareException(com.iwave.ext.vmware.VMWareException)

Aggregations

VMWareException (com.iwave.ext.vmware.VMWareException)3 HostStorageAPI (com.iwave.ext.vmware.HostStorageAPI)2 HostFileSystemMountInfo (com.vmware.vim25.HostFileSystemMountInfo)2 HostFileSystemVolume (com.vmware.vim25.HostFileSystemVolume)2 HostVmfsVolume (com.vmware.vim25.HostVmfsVolume)2 RemoteException (java.rmi.RemoteException)2 Datastore (com.vmware.vim25.mo.Datastore)1