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;
}
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);
}
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));
}
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;
}
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;
}
Aggregations