Search in sources :

Example 6 with Cluster

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

the class VcenterDiscoveryAdapter method setInitiatorHost.

/**
 * Sets properties pertaining to the {@link Initiator}
 *
 * @param initiator {@link Initiator}
 * @param host {@link Host}
 */
protected void setInitiatorHost(Initiator initiator, Host host) {
    setHostInterfaceRegistrationStatus(initiator, host);
    initiator.setHost(host.getId());
    initiator.setHostName(host.getHostName());
    Cluster cluster = getCluster(host);
    initiator.setClusterName(cluster != null ? cluster.getLabel() : "");
}
Also used : Cluster(com.emc.storageos.db.client.model.Cluster)

Example 7 with Cluster

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

the class WindowsHostDiscoveryAdapter method updateClusterName.

private void updateClusterName(URI clusterId, String name) {
    Cluster cluster = dbClient.queryObject(Cluster.class, clusterId);
    if (cluster != null) {
        cluster.setLabel(name);
        dbClient.updateObject(cluster);
        ComputeSystemHelper.updateInitiatorClusterName(dbClient, clusterId);
    }
}
Also used : Cluster(com.emc.storageos.db.client.model.Cluster)

Example 8 with Cluster

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

the class DataSourceFactory method createExportMaskDataSource.

/**
 * Creates a datasource used for export operations
 *
 * @param configName - name of the config for which the export datasource should be created
 * @param hostName - host name
 * @param clusterName - cluster name
 * @param storageSystem - storage system instance
 * @return a data source populated with the properties needed
 */
public DataSource createExportMaskDataSource(String configName, String hostName, String clusterName, StorageSystem storageSystem) {
    // for host, get the object because the name may query for host type
    Host host = getHostByName(hostName);
    // for cluster, just create an in-memory object, cluster has no other attributes
    Cluster cluster = new Cluster();
    if (!Strings.isNullOrEmpty(clusterName)) {
        cluster.setLabel(clusterName);
    }
    return createExportMaskDataSource(configName, host, cluster, storageSystem);
}
Also used : Cluster(com.emc.storageos.db.client.model.Cluster) Host(com.emc.storageos.db.client.model.Host)

Example 9 with Cluster

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

the class HostService method provisionBareMetalHosts.

/**
 * Provision bare metal hosts by taking compute elements from the compute
 * virtual pool.
 *
 * @param param
 *            parameter for multiple host creation
 * @brief Provision bare metal hosts
 * @return TaskResourceRep (asynchronous call)
 * @throws DatabaseException
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/provision-bare-metal")
public TaskList provisionBareMetalHosts(ProvisionBareMetalHostsParam param) throws DatabaseException {
    ComputeVirtualPool cvp = _dbClient.queryObject(ComputeVirtualPool.class, param.getComputeVpool());
    ArgValidator.checkEntity(cvp, param.getComputeVpool(), false);
    VirtualArray varray = _dbClient.queryObject(VirtualArray.class, param.getVarray());
    ArgValidator.checkEntity(varray, param.getVarray(), false);
    TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, param.getTenant());
    ArgValidator.checkEntity(tenant, param.getTenant(), false);
    if (!NullColumnValueGetter.isNullURI(param.getCluster())) {
        Cluster cluster = _dbClient.queryObject(Cluster.class, param.getCluster());
        ArgValidator.checkEntity(cluster, param.getCluster(), false);
    }
    _log.debug("checking if CVP is accessible");
    _permissionsHelper.checkTenantHasAccessToComputeVirtualPool(tenant.getId(), cvp);
    validateHostNames(param);
    InterProcessLock lock = lockBladeReservation();
    List<String> ceList = null;
    try {
        ceList = takeComputeElementsFromPool(cvp, param.getHostNames().size(), varray, param.getCluster());
    } catch (Exception e) {
        _log.error("unable to takeComputeElementsFromPool", e);
        throw e;
    } finally {
        unlockBladeReservation(lock);
    }
    Set<Host> hosts = new HashSet<Host>();
    for (int i = 0; i < param.getHostNames().size(); i++) {
        Host host = populateHost(tenant, param.getHostNames().get(i), ceList.get(i), param.getCluster(), cvp.getId());
        hosts.add(host);
        _dbClient.createObject(host);
    }
    return createHostTasks(hosts, param.getComputeVpool(), param.getVarray());
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) Cluster(com.emc.storageos.db.client.model.Cluster) InterProcessLock(org.apache.curator.framework.recipes.locks.InterProcessLock) Host(com.emc.storageos.db.client.model.Host) ComputeVirtualPool(com.emc.storageos.db.client.model.ComputeVirtualPool) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) HashSet(java.util.HashSet) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 10 with Cluster

use of com.emc.storageos.db.client.model.Cluster 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

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