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