use of com.emc.storageos.db.client.model.Host in project coprhd-controller by CoprHD.
the class HostService method updateBootVolume.
/**
* Updates the hosts boot volume Id
*
* @param id the URN of host
* @param hostUpdateParam
* @brief Update the host boot volume
* @return the task.
*/
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN })
@Path("/{id}/update-boot-volume")
public TaskResourceRep updateBootVolume(@PathParam("id") URI id, HostUpdateParam param) {
Host host = queryObject(Host.class, id, true);
boolean hasPendingTasks = hostHasPendingTasks(id);
boolean updateSanBootTargets = param.getUpdateSanBootTargets();
if (hasPendingTasks) {
throw APIException.badRequests.cannotUpdateHost("another operation is in progress for this host");
}
auditOp(OperationTypeEnum.UPDATE_HOST_BOOT_VOLUME, true, null, host.auditParameters());
String taskId = UUID.randomUUID().toString();
ComputeSystemController controller = getController(ComputeSystemController.class, null);
Operation op = _dbClient.createTaskOpStatus(Host.class, id, taskId, ResourceOperationTypeEnum.UPDATE_HOST_BOOT_VOLUME);
// The volume being set as the boot volume should be exported to the host and should not be exported to any other initiators.
// The controller call invoked below validates that before setting the volume as the boot volume.
controller.setHostBootVolume(host.getId(), param.getBootVolume(), updateSanBootTargets, taskId);
return toTask(host, taskId, op);
}
use of com.emc.storageos.db.client.model.Host in project coprhd-controller by CoprHD.
the class HostService method createIpInterface.
/**
* Creates a new ip interface for a host.
*
* @param id
* the URN of a ViPR Host
* @param createParam
* the details of the interfaces
* @brief Create host interface IP
* @return the details of the host interface, including its id and link,
* when creation completes successfully.
* @throws DatabaseException
* when a database error occurs
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN })
@Path("/{id}/ip-interfaces")
public IpInterfaceRestRep createIpInterface(@PathParam("id") URI id, IpInterfaceCreateParam createParam) throws DatabaseException {
Host host = queryObject(Host.class, id, true);
validateIpInterfaceData(createParam, null);
IpInterface ipInterface = new IpInterface();
ipInterface.setHost(host.getId());
ipInterface.setId(URIUtil.createId(IpInterface.class));
populateIpInterface(createParam, ipInterface);
_dbClient.createObject(ipInterface);
auditOp(OperationTypeEnum.CREATE_HOST_IPINTERFACE, true, null, ipInterface.auditParameters());
return map(ipInterface);
}
use of com.emc.storageos.db.client.model.Host in project coprhd-controller by CoprHD.
the class HostService method getUnmanagedVolumes.
/**
* Gets the UnManagedVolumes exposed to a Host.
*
* @param id
* the URI of a ViPR Host
* @brief List unmanaged volumes exposed to a host
* @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 {
Host host = queryObject(Host.class, id, false);
// check the user permissions
verifyAuthorizedInTenantOrg(host.getTenant(), getUserFromContext());
// get the unmanaged volumes
List<UnManagedVolume> unmanagedVolumes = VolumeIngestionUtil.findUnManagedVolumesForHost(id, _dbClient, _coordinator);
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.Host in project coprhd-controller by CoprHD.
the class HostService method getHost.
/**
* Gets the information for one host.
*
* @param id
* the URN of a ViPR Host
* @brief Show host
* @return All the non-null attributes of the host.
* @throws DatabaseException
* when a DB error occurs.
*/
@GET
@Path("/{id}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public HostRestRep getHost(@PathParam("id") URI id) throws DatabaseException {
Host host = queryObject(Host.class, id, false);
// check the user permissions
verifyAuthorizedInTenantOrg(host.getTenant(), getUserFromContext());
ComputeElement computeElement = null;
UCSServiceProfile serviceProfile = null;
ComputeSystem computeSystem = null;
if (!NullColumnValueGetter.isNullURI(host.getComputeElement())) {
computeElement = queryObject(ComputeElement.class, host.getComputeElement(), false);
}
if (!NullColumnValueGetter.isNullURI(host.getServiceProfile())) {
serviceProfile = queryObject(UCSServiceProfile.class, host.getServiceProfile(), false);
}
if (serviceProfile != null) {
computeSystem = queryObject(ComputeSystem.class, serviceProfile.getComputeSystem(), false);
} else if (computeElement != null) {
computeSystem = queryObject(ComputeSystem.class, computeElement.getComputeSystem(), false);
}
return map(host, computeElement, serviceProfile, computeSystem);
}
use of com.emc.storageos.db.client.model.Host in project coprhd-controller by CoprHD.
the class HostService method createInitiator.
/**
* Creates a new initiator for a host.
*
* @param id
* the URN of a ViPR Host
* @param createParam
* the details of the initiator
* @brief Create host initiator
* @return the details of the host initiator when creation
* is successfully.
* @throws DatabaseException
* when a database error occurs.
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN })
@Path("/{id}/initiators")
public TaskResourceRep createInitiator(@PathParam("id") URI id, InitiatorCreateParam createParam) throws DatabaseException {
Host host = queryObject(Host.class, id, true);
Cluster cluster = null;
validateInitiatorData(createParam, null);
// create and populate the initiator
Initiator initiator = new Initiator();
initiator.setHost(id);
initiator.setHostName(host.getHostName());
if (!NullColumnValueGetter.isNullURI(host.getCluster())) {
cluster = queryObject(Cluster.class, host.getCluster(), false);
initiator.setClusterName(cluster.getLabel());
}
initiator.setId(URIUtil.createId(Initiator.class));
populateInitiator(initiator, createParam);
_dbClient.createObject(initiator);
String taskId = UUID.randomUUID().toString();
Operation op = _dbClient.createTaskOpStatus(Initiator.class, initiator.getId(), taskId, ResourceOperationTypeEnum.ADD_HOST_INITIATOR);
// if host in use. update export with new initiator
if (ComputeSystemHelper.isHostInUse(_dbClient, host.getId())) {
ComputeSystemController controller = getController(ComputeSystemController.class, null);
controller.addInitiatorsToExport(initiator.getHost(), Arrays.asList(initiator.getId()), taskId);
} else {
// No updates were necessary, so we can close out the task.
_dbClient.ready(Initiator.class, initiator.getId(), taskId);
}
auditOp(OperationTypeEnum.CREATE_HOST_INITIATOR, true, null, initiator.auditParameters());
return toTask(initiator, taskId, op);
}
Aggregations