Search in sources :

Example 1 with VcenterObjectConnectionException

use of com.emc.storageos.vcentercontroller.exceptions.VcenterObjectConnectionException in project coprhd-controller by CoprHD.

the class VcenterControllerImpl method exitMaintenanceMode.

@Override
public void exitMaintenanceMode(URI datacenterUri, URI clusterUri, URI hostUri) throws InternalException {
    VcenterApiClient vcenterApiClient = null;
    try {
        Host host = _dbClient.queryObject(Host.class, hostUri);
        VcenterDataCenter vcenterDataCenter = _dbClient.queryObject(VcenterDataCenter.class, datacenterUri);
        Cluster cluster = _dbClient.queryObject(Cluster.class, clusterUri);
        Vcenter vcenter = _dbClient.queryObject(Vcenter.class, vcenterDataCenter.getVcenter());
        _log.info("Request to exit maintenance mode for " + vcenter.getLabel() + "/" + vcenterDataCenter.getLabel() + "/" + cluster.getLabel() + "/" + host.getHostName());
        vcenterApiClient = new VcenterApiClient(_coordinator.getPropertyInfo());
        vcenterApiClient.setup(vcenter.getIpAddress(), vcenter.getUsername(), vcenter.getPassword(), vcenter.getPortNumber());
        vcenterApiClient.exitMaintenanceMode(vcenterDataCenter.getLabel(), cluster.getExternalId(), host.getHostName());
    } catch (VcenterObjectConnectionException e) {
        throw VcenterControllerException.exceptions.objectConnectionException(e.getLocalizedMessage(), e);
    } catch (VcenterObjectNotFoundException e) {
        throw VcenterControllerException.exceptions.objectNotFoundException(e.getLocalizedMessage(), e);
    } catch (VcenterServerConnectionException e) {
        throw VcenterControllerException.exceptions.serverConnectionException(e.getLocalizedMessage(), e);
    } catch (Exception e) {
        _log.error("exitMaintenanceMode exception " + e);
        throw VcenterControllerException.exceptions.unexpectedException(e.getLocalizedMessage(), e);
    } finally {
        if (vcenterApiClient != null) {
            vcenterApiClient.destroy();
        }
    }
}
Also used : Vcenter(com.emc.storageos.db.client.model.Vcenter) VcenterServerConnectionException(com.emc.storageos.vcentercontroller.exceptions.VcenterServerConnectionException) VcenterObjectNotFoundException(com.emc.storageos.vcentercontroller.exceptions.VcenterObjectNotFoundException) VcenterApiClient(com.emc.storageos.vcentercontroller.VcenterApiClient) VcenterObjectConnectionException(com.emc.storageos.vcentercontroller.exceptions.VcenterObjectConnectionException) Cluster(com.emc.storageos.db.client.model.Cluster) Host(com.emc.storageos.db.client.model.Host) VcenterDataCenter(com.emc.storageos.db.client.model.VcenterDataCenter) VcenterServerConnectionException(com.emc.storageos.vcentercontroller.exceptions.VcenterServerConnectionException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) VcenterObjectConnectionException(com.emc.storageos.vcentercontroller.exceptions.VcenterObjectConnectionException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) VcenterObjectNotFoundException(com.emc.storageos.vcentercontroller.exceptions.VcenterObjectNotFoundException) VcenterControllerException(com.emc.storageos.vcentercontroller.exceptions.VcenterControllerException)

Example 2 with VcenterObjectConnectionException

use of com.emc.storageos.vcentercontroller.exceptions.VcenterObjectConnectionException in project coprhd-controller by CoprHD.

the class VcenterControllerImpl method removeVcenterCluster.

@Override
public void removeVcenterCluster(URI datacenterUri, URI clusterUri) throws InternalException {
    VcenterApiClient vcenterApiClient = null;
    try {
        VcenterDataCenter vcenterDataCenter = _dbClient.queryObject(VcenterDataCenter.class, datacenterUri);
        Cluster cluster = _dbClient.queryObject(Cluster.class, clusterUri);
        Vcenter vcenter = _dbClient.queryObject(Vcenter.class, vcenterDataCenter.getVcenter());
        _log.info("Request to remove cluster " + vcenter.getLabel() + "/" + vcenterDataCenter.getLabel() + "/" + cluster.getLabel());
        vcenterApiClient = new VcenterApiClient(_coordinator.getPropertyInfo());
        vcenterApiClient.setup(vcenter.getIpAddress(), vcenter.getUsername(), vcenter.getPassword(), vcenter.getPortNumber());
        vcenterApiClient.removeCluster(vcenterDataCenter.getLabel(), cluster.getExternalId());
    } catch (VcenterObjectConnectionException e) {
        throw VcenterControllerException.exceptions.objectConnectionException(e.getLocalizedMessage(), e);
    } catch (VcenterObjectNotFoundException e) {
        throw VcenterControllerException.exceptions.objectNotFoundException(e.getLocalizedMessage(), e);
    } catch (VcenterServerConnectionException e) {
        throw VcenterControllerException.exceptions.serverConnectionException(e.getLocalizedMessage(), e);
    } catch (Exception e) {
        _log.error("removeVcenterCluster exception " + e);
        throw VcenterControllerException.exceptions.unexpectedException(e.getLocalizedMessage(), e);
    } finally {
        if (vcenterApiClient != null) {
            vcenterApiClient.destroy();
        }
    }
}
Also used : Vcenter(com.emc.storageos.db.client.model.Vcenter) VcenterServerConnectionException(com.emc.storageos.vcentercontroller.exceptions.VcenterServerConnectionException) VcenterObjectNotFoundException(com.emc.storageos.vcentercontroller.exceptions.VcenterObjectNotFoundException) VcenterApiClient(com.emc.storageos.vcentercontroller.VcenterApiClient) VcenterObjectConnectionException(com.emc.storageos.vcentercontroller.exceptions.VcenterObjectConnectionException) Cluster(com.emc.storageos.db.client.model.Cluster) VcenterDataCenter(com.emc.storageos.db.client.model.VcenterDataCenter) VcenterServerConnectionException(com.emc.storageos.vcentercontroller.exceptions.VcenterServerConnectionException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) VcenterObjectConnectionException(com.emc.storageos.vcentercontroller.exceptions.VcenterObjectConnectionException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) VcenterObjectNotFoundException(com.emc.storageos.vcentercontroller.exceptions.VcenterObjectNotFoundException) VcenterControllerException(com.emc.storageos.vcentercontroller.exceptions.VcenterControllerException)

Example 3 with VcenterObjectConnectionException

use of com.emc.storageos.vcentercontroller.exceptions.VcenterObjectConnectionException in project coprhd-controller by CoprHD.

the class VcenterApiClient method checkHostConnectedPoweredOn.

public void checkHostConnectedPoweredOn(String datacenterName, String clusterNameOrMoRef, String hostname) throws VcenterSystemException, VcenterObjectNotFoundException, VcenterObjectConnectionException {
    try {
        _log.info("Request to check connected and powered on for host " + hostname + " in datacenter " + datacenterName + " cluster " + clusterNameOrMoRef);
        HostSystem hostSystem = (HostSystem) createManagedEntityMap(datacenterName, clusterNameOrMoRef, hostname, true).get(// checkHostConnectedPoweredOn is performed in this call
        "HostSystem");
    } catch (VcenterSystemException | VcenterObjectNotFoundException | VcenterObjectConnectionException e) {
        throw e;
    } catch (Exception e) {
        _log.error("checkHostConnectedPoweredOn exception " + e);
        throw new VcenterSystemException(e.getLocalizedMessage());
    }
}
Also used : VcenterObjectNotFoundException(com.emc.storageos.vcentercontroller.exceptions.VcenterObjectNotFoundException) VcenterObjectConnectionException(com.emc.storageos.vcentercontroller.exceptions.VcenterObjectConnectionException) HostSystem(com.vmware.vim25.mo.HostSystem) VcenterSystemException(com.emc.storageos.vcentercontroller.exceptions.VcenterSystemException) VcenterSystemException(com.emc.storageos.vcentercontroller.exceptions.VcenterSystemException) VcenterServerConnectionException(com.emc.storageos.vcentercontroller.exceptions.VcenterServerConnectionException) VcenterObjectConnectionException(com.emc.storageos.vcentercontroller.exceptions.VcenterObjectConnectionException) VcenterObjectNotFoundException(com.emc.storageos.vcentercontroller.exceptions.VcenterObjectNotFoundException)

Example 4 with VcenterObjectConnectionException

use of com.emc.storageos.vcentercontroller.exceptions.VcenterObjectConnectionException in project coprhd-controller by CoprHD.

the class VcenterApiClient method enterMaintenanceMode.

public void enterMaintenanceMode(String datacenterName, String clusterNameOrMoRef, String hostname) throws VcenterSystemException, VcenterObjectNotFoundException, VcenterObjectConnectionException {
    try {
        _log.info("Request to enter maintenance mode for host " + hostname + " in datacenter " + datacenterName + " cluster " + clusterNameOrMoRef);
        enterMaintenanceModeHost((HostSystem) createManagedEntityMap(datacenterName, clusterNameOrMoRef, hostname, true).get("HostSystem"));
    } catch (VcenterSystemException | VcenterObjectNotFoundException | VcenterObjectConnectionException e) {
        throw e;
    } catch (Exception e) {
        _log.error("enterMaintenanceMode exception " + e);
        throw new VcenterSystemException(e.getLocalizedMessage());
    }
}
Also used : VcenterObjectNotFoundException(com.emc.storageos.vcentercontroller.exceptions.VcenterObjectNotFoundException) VcenterObjectConnectionException(com.emc.storageos.vcentercontroller.exceptions.VcenterObjectConnectionException) VcenterSystemException(com.emc.storageos.vcentercontroller.exceptions.VcenterSystemException) VcenterSystemException(com.emc.storageos.vcentercontroller.exceptions.VcenterSystemException) VcenterServerConnectionException(com.emc.storageos.vcentercontroller.exceptions.VcenterServerConnectionException) VcenterObjectConnectionException(com.emc.storageos.vcentercontroller.exceptions.VcenterObjectConnectionException) VcenterObjectNotFoundException(com.emc.storageos.vcentercontroller.exceptions.VcenterObjectNotFoundException)

Example 5 with VcenterObjectConnectionException

use of com.emc.storageos.vcentercontroller.exceptions.VcenterObjectConnectionException in project coprhd-controller by CoprHD.

the class VcenterApiClient method removeCluster.

public void removeCluster(String datacenterName, String clusterNameOrMoRef) throws VcenterSystemException, VcenterObjectNotFoundException, VcenterObjectConnectionException {
    try {
        _log.info("Request to remove cluster in datacenter " + datacenterName + " cluster " + clusterNameOrMoRef);
        try {
            ClusterComputeResource clusterComputeResource = (ClusterComputeResource) createManagedEntityMap(datacenterName, clusterNameOrMoRef, null, false).get("ClusterComputeResource");
            String clusterName = clusterComputeResource.getName();
            _log.info("Attempt to delete cluster " + clusterName);
            // Remove
            Integer clusterOperationTimeout = Integer.parseInt(propertyInfo.getProperty("vcenter_operation_timeout"));
            VcenterTaskMonitor taskMonitor = new VcenterTaskMonitor(clusterOperationTimeout);
            Task deleteClusterTask = clusterComputeResource.destroy_Task();
            // call blocks
            VcenterTaskMonitor.TaskStatus taskStatus = taskMonitor.monitor(deleteClusterTask);
            if (taskStatus == VcenterTaskMonitor.TaskStatus.SUCCESS) {
                _log.info("Delete cluster " + clusterName + " task succeeded");
            } else if (taskStatus == VcenterTaskMonitor.TaskStatus.ERROR) {
                String errorMessage = "Delete cluster " + clusterName + " task failed - " + taskMonitor.errorDescription;
                _log.error(errorMessage);
                throw new VcenterSystemException(errorMessage);
            } else if (taskStatus == VcenterTaskMonitor.TaskStatus.TIMED_OUT) {
                _log.error("Delete cluster " + clusterName + " task timed out at " + taskMonitor.progressPercent);
                throw new VcenterSystemException("Delete cluster " + clusterName + " task timed out at " + taskMonitor.progressPercent);
            } else {
                // Should not execute - Just here in case someone ever added a new state so we catch it
                _log.error("Unknown task status encountered tracking delete cluster " + taskStatus);
                throw new VcenterSystemException("Unknown task status encountered tracking delete cluster " + taskStatus);
            }
        } catch (VcenterObjectNotFoundException e) {
            _log.info("Cluster not found thus no delete necessary");
        }
    } catch (VcenterSystemException | VcenterObjectNotFoundException | VcenterObjectConnectionException e) {
        throw e;
    } catch (Exception e) {
        _log.error("Exception removing cluster: " + e);
        throw new VcenterSystemException(e.getLocalizedMessage());
    }
}
Also used : Task(com.vmware.vim25.mo.Task) VcenterObjectNotFoundException(com.emc.storageos.vcentercontroller.exceptions.VcenterObjectNotFoundException) ClusterComputeResource(com.vmware.vim25.mo.ClusterComputeResource) VcenterObjectConnectionException(com.emc.storageos.vcentercontroller.exceptions.VcenterObjectConnectionException) VcenterSystemException(com.emc.storageos.vcentercontroller.exceptions.VcenterSystemException) VcenterSystemException(com.emc.storageos.vcentercontroller.exceptions.VcenterSystemException) VcenterServerConnectionException(com.emc.storageos.vcentercontroller.exceptions.VcenterServerConnectionException) VcenterObjectConnectionException(com.emc.storageos.vcentercontroller.exceptions.VcenterObjectConnectionException) VcenterObjectNotFoundException(com.emc.storageos.vcentercontroller.exceptions.VcenterObjectNotFoundException)

Aggregations

VcenterObjectConnectionException (com.emc.storageos.vcentercontroller.exceptions.VcenterObjectConnectionException)18 VcenterObjectNotFoundException (com.emc.storageos.vcentercontroller.exceptions.VcenterObjectNotFoundException)18 VcenterServerConnectionException (com.emc.storageos.vcentercontroller.exceptions.VcenterServerConnectionException)16 VcenterSystemException (com.emc.storageos.vcentercontroller.exceptions.VcenterSystemException)11 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)7 VcenterControllerException (com.emc.storageos.vcentercontroller.exceptions.VcenterControllerException)7 HostSystem (com.vmware.vim25.mo.HostSystem)7 Host (com.emc.storageos.db.client.model.Host)6 Cluster (com.emc.storageos.db.client.model.Cluster)5 Vcenter (com.emc.storageos.db.client.model.Vcenter)5 VcenterDataCenter (com.emc.storageos.db.client.model.VcenterDataCenter)5 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)5 VcenterApiClient (com.emc.storageos.vcentercontroller.VcenterApiClient)5 ClusterComputeResource (com.vmware.vim25.mo.ClusterComputeResource)4 Task (com.vmware.vim25.mo.Task)3 ComputeSystemControllerException (com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)2 ImageServerControllerException (com.emc.storageos.imageservercontroller.exceptions.ImageServerControllerException)2 ServiceCoded (com.emc.storageos.svcs.errorhandling.model.ServiceCoded)2 HostScsiDisk (com.vmware.vim25.HostScsiDisk)2 HostStorageDeviceInfo (com.vmware.vim25.HostStorageDeviceInfo)2