use of com.emc.storageos.db.client.model.IpInterface in project coprhd-controller by CoprHD.
the class OsInstallCompleter method complete.
@Override
protected void complete(DbClient dbClient, Status status, ServiceCoded coded) throws DeviceControllerException {
log.info("OsInstallCompleter.complete {} {}", status.name(), coded);
Host host = dbClient.queryObject(Host.class, getId());
ComputeImageJob job = dbClient.queryObject(ComputeImageJob.class, jobId);
AuditLogManager auditMgr = AuditLogManagerFactory.getAuditLogManager();
if (status == Status.ready && job.getJobStatus().equals(JobStatus.SUCCESS.name())) {
// set host type based on image type
ComputeImage image = dbClient.queryObject(ComputeImage.class, job.getComputeImageId());
if (image.getImageType().equals(ComputeImage.ImageType.esx.name())) {
host.setType(Host.HostType.Esx.name());
host.setOsVersion(image.getOsVersion());
} else if (image.getImageType().equals(ComputeImage.ImageType.linux.name())) {
host.setType(Host.HostType.Linux.name());
host.setOsVersion(String.format("%s %s", image.getOsName(), image.getOsVersion()));
}
/*
* Create the IpInterface that represents the IpAddress that's
* supposed to come on the ESX Management Network (for ESX
* installations)
*/
IpInterface ipInterface = new IpInterface();
ipInterface.setHost(host.getId());
ipInterface.setId(URIUtil.createId(IpInterface.class));
ipInterface.setIpAddress(job.getHostIp());
ipInterface.setLabel(job.getHostName());
ipInterface.setNetmask(job.getNetmask());
ipInterface.setProtocol(HostInterface.Protocol.IPV4.toString());
ipInterface.setRegistrationStatus(DiscoveredDataObject.RegistrationStatus.REGISTERED.toString());
dbClient.createObject(ipInterface);
/*
* End create IpInterface. Consider making this a seperate method.
*/
host.setCompatibilityStatus(CompatibilityStatus.COMPATIBLE.name());
host.setProvisioningStatus(ProvisioningJobStatus.COMPLETE.toString());
dbClient.persistObject(host);
dbClient.ready(Host.class, getId(), getOpId());
auditMgr.recordAuditLog(null, null, serviceType, OperationTypeEnum.INSTALL_COMPUTE_IMAGE, System.currentTimeMillis(), AuditLogManager.AUDITLOG_SUCCESS, AuditLogManager.AUDITOP_END, host.getId(), job.getId());
} else {
host.setProvisioningStatus(ProvisioningJobStatus.ERROR.toString());
dbClient.persistObject(host);
job.setJobStatus(JobStatus.FAILED.name());
dbClient.persistObject(job);
dbClient.error(Host.class, getId(), getOpId(), coded);
auditMgr.recordAuditLog(null, null, serviceType, OperationTypeEnum.INSTALL_COMPUTE_IMAGE, System.currentTimeMillis(), AuditLogManager.AUDITLOG_FAILURE, AuditLogManager.AUDITOP_END, host.getId(), job.getId());
}
}
use of com.emc.storageos.db.client.model.IpInterface in project coprhd-controller by CoprHD.
the class IpInterfaceService method getTenantOwner.
@Override
protected URI getTenantOwner(URI id) {
IpInterface ipInterface = queryObject(IpInterface.class, id, false);
Host host = queryObject(Host.class, ipInterface.getHost(), false);
return host.getTenant();
}
use of com.emc.storageos.db.client.model.IpInterface in project coprhd-controller by CoprHD.
the class IpInterfaceService method updateIpInterface.
/**
* Update a host IP interface.
*
* @param id the URN of a ViPR IP interface
* @param updateParam the parameter containing the new attributes
* @prereq none
* @brief Update IP interface
* @return the details of the updated host interface.
* @throws DatabaseException when a DB error occurs
*/
@PUT
@Path("/{id}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN })
public IpInterfaceRestRep updateIpInterface(@PathParam("id") URI id, IpInterfaceUpdateParam updateParam) throws DatabaseException {
IpInterface ipInterface = queryObject(IpInterface.class, id, true);
_hostService.validateIpInterfaceData(updateParam, ipInterface);
_hostService.populateIpInterface(updateParam, ipInterface);
_dbClient.persistObject(ipInterface);
auditOp(OperationTypeEnum.UPDATE_HOST_IPINTERFACE, true, null, ipInterface.auditParameters());
return map(queryObject(IpInterface.class, id, false));
}
use of com.emc.storageos.db.client.model.IpInterface 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.IpInterface in project coprhd-controller by CoprHD.
the class ComputeSystemControllerImpl method addStepsForIpInterfaceFileShares.
public String addStepsForIpInterfaceFileShares(Workflow workflow, String waitFor, URI hostId, URI ipId) {
List<FileShare> fileShares = ComputeSystemHelper.getFileSharesByHost(_dbClient, hostId);
IpInterface ipinterface = _dbClient.queryObject(IpInterface.class, ipId);
List<String> endpoints = Arrays.asList(ipinterface.getIpAddress());
for (FileShare fileShare : fileShares) {
if (fileShare != null && fileShare.getFsExports() != null) {
for (FileExport fileExport : fileShare.getFsExports().values()) {
if (fileExport != null && fileExport.getClients() != null) {
if (fileExportContainsEndpoint(fileExport, endpoints)) {
StorageSystem device = _dbClient.queryObject(StorageSystem.class, fileShare.getStorageDevice());
List<String> clients = fileExport.getClients();
clients.removeAll(endpoints);
fileExport.setStoragePort(fileShare.getStoragePort().toString());
FileShareExport export = new FileShareExport(clients, fileExport.getSecurityType(), fileExport.getPermissions(), fileExport.getRootUserMapping(), fileExport.getProtocol(), fileExport.getStoragePortName(), fileExport.getStoragePort(), fileExport.getPath(), fileExport.getMountPath(), "", "");
if (clients.isEmpty()) {
_log.info("Unexporting file share " + fileShare.getId());
waitFor = workflow.createStep(UNEXPORT_FILESHARE_STEP, String.format("Unexport fileshare %s", fileShare.getId()), waitFor, fileShare.getId(), fileShare.getId().toString(), this.getClass(), unexportFileShareMethod(device.getId(), device.getSystemType(), fileShare.getId(), export), null, null);
} else {
_log.info("Updating export for file share " + fileShare.getId());
waitFor = workflow.createStep(UPDATE_FILESHARE_EXPORT_STEP, String.format("Update fileshare export %s", fileShare.getId()), waitFor, fileShare.getId(), fileShare.getId().toString(), this.getClass(), updateFileShareMethod(device.getId(), device.getSystemType(), fileShare.getId(), export), null, null);
}
}
}
}
}
}
return waitFor;
}
Aggregations