Search in sources :

Example 16 with Host

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);
}
Also used : ComputeSystemController(com.emc.storageos.computesystemcontroller.ComputeSystemController) Host(com.emc.storageos.db.client.model.Host) Operation(com.emc.storageos.db.client.model.Operation) 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 17 with Host

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);
}
Also used : IpInterface(com.emc.storageos.db.client.model.IpInterface) Host(com.emc.storageos.db.client.model.Host) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 18 with Host

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;
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) UnManagedVolumeList(com.emc.storageos.model.block.UnManagedVolumeList) Host(com.emc.storageos.db.client.model.Host) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 19 with Host

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);
}
Also used : UCSServiceProfile(com.emc.storageos.db.client.model.UCSServiceProfile) ComputeElement(com.emc.storageos.db.client.model.ComputeElement) Host(com.emc.storageos.db.client.model.Host) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 20 with Host

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);
}
Also used : Initiator(com.emc.storageos.db.client.model.Initiator) ComputeSystemController(com.emc.storageos.computesystemcontroller.ComputeSystemController) Cluster(com.emc.storageos.db.client.model.Cluster) Host(com.emc.storageos.db.client.model.Host) Operation(com.emc.storageos.db.client.model.Operation) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

Host (com.emc.storageos.db.client.model.Host)227 URI (java.net.URI)104 Initiator (com.emc.storageos.db.client.model.Initiator)52 ArrayList (java.util.ArrayList)49 HashMap (java.util.HashMap)38 Cluster (com.emc.storageos.db.client.model.Cluster)37 HashSet (java.util.HashSet)35 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)33 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)32 VcenterDataCenter (com.emc.storageos.db.client.model.VcenterDataCenter)26 ComputeElement (com.emc.storageos.db.client.model.ComputeElement)24 Volume (com.emc.storageos.db.client.model.Volume)20 Path (javax.ws.rs.Path)20 Produces (javax.ws.rs.Produces)20 Vcenter (com.emc.storageos.db.client.model.Vcenter)19 ComputeSystemControllerException (com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)18 ExportMask (com.emc.storageos.db.client.model.ExportMask)18 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)17 NamedURI (com.emc.storageos.db.client.model.NamedURI)16 StringSet (com.emc.storageos.db.client.model.StringSet)16