Search in sources :

Example 11 with Cluster

use of com.emc.storageos.db.client.model.Cluster in project coprhd-controller by CoprHD.

the class ActionableEventExecutor method hostClusterChangeDetails.

/**
 * Get details for the hostClusterChange method
 * NOTE: In order to maintain backwards compatibility, do not change the signature of this method.
 *
 * @param hostId the host that is moving clusters
 * @param clusterId the cluster the host is moving to
 * @param isVcenter if true, vcenter api operations will be executed against the host to detach/unmount and attach/mount disks and
 *            datastores
 * @param vCenterDataCenterId the datacenter to assign the host to
 * @return list of event details
 */
// Invoked using reflection for the event framework
@SuppressWarnings("unused")
public List<String> hostClusterChangeDetails(URI hostId, URI clusterId, URI vCenterDataCenterId, boolean isVcenter) {
    List<String> result = Lists.newArrayList();
    Host host = _dbClient.queryObject(Host.class, hostId);
    if (host == null) {
        return Lists.newArrayList("Host has been deleted");
    }
    URI oldClusterURI = host.getCluster();
    Cluster oldCluster = null;
    if (!NullColumnValueGetter.isNullURI(oldClusterURI)) {
        oldCluster = _dbClient.queryObject(Cluster.class, oldClusterURI);
    }
    Cluster newCluster = null;
    if (!NullColumnValueGetter.isNullURI(clusterId)) {
        newCluster = _dbClient.queryObject(Cluster.class, clusterId);
    }
    if (newCluster != null && oldCluster != null) {
        result.add(ComputeSystemDialogProperties.getMessage("ComputeSystem.hostClusterChangeDetails", host.getLabel(), oldCluster.getLabel(), newCluster.getLabel()));
    } else if (newCluster == null && oldCluster != null) {
        result.add(ComputeSystemDialogProperties.getMessage("ComputeSystem.hostClusterChangeDetailsRemovedFromCluster", host.getLabel(), oldCluster.getLabel()));
    } else if (newCluster != null && oldCluster == null) {
        result.add(ComputeSystemDialogProperties.getMessage("ComputeSystem.hostClusterChangeDetailsAddedToCluster", host.getLabel(), newCluster.getLabel()));
    }
    if (!NullColumnValueGetter.isNullURI(oldClusterURI) && NullColumnValueGetter.isNullURI(clusterId) && ComputeSystemHelper.isClusterInExport(_dbClient, oldClusterURI)) {
        List<ExportGroup> exportGroups = ComputeSystemControllerImpl.getSharedExports(_dbClient, oldClusterURI);
        for (ExportGroup export : exportGroups) {
            if (export != null) {
                List<BlockObjectDetails> affectedVolumes = getBlockObjectDetails(hostId, export.getVolumes());
                result.addAll(getVolumeDetails(affectedVolumes, false));
            }
        }
    } else if (NullColumnValueGetter.isNullURI(oldClusterURI) && !NullColumnValueGetter.isNullURI(clusterId) && ComputeSystemHelper.isClusterInExport(_dbClient, clusterId)) {
        // Non-clustered host being added to a cluster
        List<ExportGroup> exportGroups = ComputeSystemControllerImpl.getSharedExports(_dbClient, clusterId);
        for (ExportGroup eg : exportGroups) {
            List<BlockObjectDetails> affectedVolumes = getBlockObjectDetails(hostId, eg.getVolumes());
            result.addAll(getVolumeDetails(affectedVolumes, true));
        }
    } else if (!NullColumnValueGetter.isNullURI(oldClusterURI) && !NullColumnValueGetter.isNullURI(clusterId) && !oldClusterURI.equals(clusterId) && (ComputeSystemHelper.isClusterInExport(_dbClient, oldClusterURI) || ComputeSystemHelper.isClusterInExport(_dbClient, clusterId))) {
        // Clustered host being moved to another cluster
        List<ExportGroup> exportGroups = ComputeSystemControllerImpl.getSharedExports(_dbClient, oldClusterURI);
        for (ExportGroup export : exportGroups) {
            if (export != null) {
                List<BlockObjectDetails> affectedVolumes = getBlockObjectDetails(hostId, export.getVolumes());
                result.addAll(getVolumeDetails(affectedVolumes, false));
            }
        }
        exportGroups = ComputeSystemControllerImpl.getSharedExports(_dbClient, clusterId);
        for (ExportGroup eg : exportGroups) {
            List<BlockObjectDetails> affectedVolumes = getBlockObjectDetails(hostId, eg.getVolumes());
            result.addAll(getVolumeDetails(affectedVolumes, true));
        }
    }
    return result;
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) Cluster(com.emc.storageos.db.client.model.Cluster) Host(com.emc.storageos.db.client.model.Host) List(java.util.List) URI(java.net.URI)

Example 12 with Cluster

use of com.emc.storageos.db.client.model.Cluster in project coprhd-controller by CoprHD.

the class ClusterService method getCluster.

/**
 * Shows the information for one cluster.
 *
 * @param id the URN of a ViPR cluster
 * @prereq none
 * @brief Show cluster
 * @return All the non-null attributes of the cluster.
 * @throws DatabaseException when a DB error occurs.
 */
@GET
@Path("/{id}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public ClusterRestRep getCluster(@PathParam("id") URI id) throws DatabaseException {
    Cluster cluster = queryObject(Cluster.class, id, false);
    // check the user permissions
    verifyAuthorizedInTenantOrg(cluster.getTenant(), getUserFromContext());
    return map(cluster);
}
Also used : MapCluster(com.emc.storageos.api.mapper.functions.MapCluster) Cluster(com.emc.storageos.db.client.model.Cluster) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 13 with Cluster

use of com.emc.storageos.db.client.model.Cluster in project coprhd-controller by CoprHD.

the class ClusterService method updateCluster.

/**
 * Updates one or more of the cluster attributes.
 *
 * @param id the URN of a ViPR cluster
 * @param updateParam the parameter that has the attributes to be
 *            updated.
 * @prereq none
 * @brief Update cluster attributes
 * @return the representation of the updated cluster.
 */
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN })
@Path("/{id}")
public ClusterRestRep updateCluster(@PathParam("id") URI id, ClusterUpdateParam updateParam, @DefaultValue("true") @QueryParam("update-exports") boolean updateExports) {
    // update the cluster
    Cluster cluster = queryObject(Cluster.class, id, true);
    validateClusterData(updateParam, cluster.getTenant(), cluster, _dbClient);
    populateCluster(updateParam, cluster);
    _dbClient.persistObject(cluster);
    if (!Strings.isNullOrEmpty(updateParam.findName())) {
        ComputeSystemHelper.updateInitiatorClusterName(_dbClient, cluster.getId());
    }
    auditOp(OperationTypeEnum.UPDATE_CLUSTER, true, null, cluster.auditParameters());
    return map(queryObject(Cluster.class, id, false));
}
Also used : MapCluster(com.emc.storageos.api.mapper.functions.MapCluster) Cluster(com.emc.storageos.db.client.model.Cluster) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 14 with Cluster

use of com.emc.storageos.db.client.model.Cluster in project coprhd-controller by CoprHD.

the class ClusterService method getUnmanagedVolumes.

/**
 * Gets the UnManagedVolumes exposed to a Cluster.
 *
 * @param id the URI of a ViPR Cluster
 * @brief List unmanaged volumes exposed to a cluster
 * @return a list of UnManagedVolumes exposed to this host
 * @throws DatabaseException when a database error occurs
 */
@GET
@Path("/{id}/unmanaged-volumes")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public UnManagedVolumeList getUnmanagedVolumes(@PathParam("id") URI id) throws DatabaseException {
    Cluster cluster = queryObject(Cluster.class, id, false);
    // check the user permissions
    verifyAuthorizedInTenantOrg(cluster.getTenant(), getUserFromContext());
    // get the unmanaged volumes
    List<UnManagedVolume> unmanagedVolumes = VolumeIngestionUtil.findUnManagedVolumesForCluster(id, _dbClient);
    UnManagedVolumeList list = new UnManagedVolumeList();
    for (UnManagedVolume volume : unmanagedVolumes) {
        list.getUnManagedVolumes().add(toRelatedResource(ResourceTypeEnum.UNMANAGED_VOLUMES, volume.getId()));
    }
    return list;
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) UnManagedVolumeList(com.emc.storageos.model.block.UnManagedVolumeList) MapCluster(com.emc.storageos.api.mapper.functions.MapCluster) Cluster(com.emc.storageos.db.client.model.Cluster) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 15 with Cluster

use of com.emc.storageos.db.client.model.Cluster in project coprhd-controller by CoprHD.

the class ClusterService method getClusterVblockHosts.

/**
 * List the vblock hosts of a cluster.
 *
 * @param id the URN of a ViPR cluster
 * @brief List vblock hosts for a cluster
 * @return The list of vblock hosts in the cluster.
 * @throws DatabaseException when a DB error occurs.
 */
@GET
@Path("/{id}/vblock-hosts")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public HostList getClusterVblockHosts(@PathParam("id") URI id) throws DatabaseException {
    Cluster cluster = queryObject(Cluster.class, id, true);
    // check the user permissions
    verifyAuthorizedInTenantOrg(cluster.getTenant(), getUserFromContext());
    HostList list = new HostList();
    list.setHosts(map(ResourceTypeEnum.HOST, getVblockHostsFromCluster(id)));
    return list;
}
Also used : MapCluster(com.emc.storageos.api.mapper.functions.MapCluster) Cluster(com.emc.storageos.db.client.model.Cluster) HostList(com.emc.storageos.model.host.HostList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

Cluster (com.emc.storageos.db.client.model.Cluster)67 Host (com.emc.storageos.db.client.model.Host)38 URI (java.net.URI)26 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)20 VcenterDataCenter (com.emc.storageos.db.client.model.VcenterDataCenter)19 Initiator (com.emc.storageos.db.client.model.Initiator)15 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)15 Path (javax.ws.rs.Path)14 Produces (javax.ws.rs.Produces)14 VcenterControllerException (com.emc.storageos.vcentercontroller.exceptions.VcenterControllerException)13 VcenterObjectConnectionException (com.emc.storageos.vcentercontroller.exceptions.VcenterObjectConnectionException)13 VcenterObjectNotFoundException (com.emc.storageos.vcentercontroller.exceptions.VcenterObjectNotFoundException)13 ArrayList (java.util.ArrayList)13 Vcenter (com.emc.storageos.db.client.model.Vcenter)12 VcenterServerConnectionException (com.emc.storageos.vcentercontroller.exceptions.VcenterServerConnectionException)11 HashSet (java.util.HashSet)9 MapCluster (com.emc.storageos.api.mapper.functions.MapCluster)8 VcenterApiClient (com.emc.storageos.vcentercontroller.VcenterApiClient)8 GET (javax.ws.rs.GET)8 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)6