Search in sources :

Example 1 with IpInterface

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());
    }
}
Also used : IpInterface(com.emc.storageos.db.client.model.IpInterface) AuditLogManager(com.emc.storageos.security.audit.AuditLogManager) Host(com.emc.storageos.db.client.model.Host) ComputeImageJob(com.emc.storageos.db.client.model.ComputeImageJob) ComputeImage(com.emc.storageos.db.client.model.ComputeImage)

Example 2 with IpInterface

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();
}
Also used : MapIpInterface(com.emc.storageos.api.mapper.functions.MapIpInterface) IpInterface(com.emc.storageos.db.client.model.IpInterface) Host(com.emc.storageos.db.client.model.Host)

Example 3 with IpInterface

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));
}
Also used : MapIpInterface(com.emc.storageos.api.mapper.functions.MapIpInterface) IpInterface(com.emc.storageos.db.client.model.IpInterface) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 4 with IpInterface

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);
}
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 5 with 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;
}
Also used : FileShareExport(com.emc.storageos.volumecontroller.FileShareExport) IpInterface(com.emc.storageos.db.client.model.IpInterface) FileExport(com.emc.storageos.db.client.model.FileExport) FileShare(com.emc.storageos.db.client.model.FileShare) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

IpInterface (com.emc.storageos.db.client.model.IpInterface)27 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)7 URI (java.net.URI)7 Path (javax.ws.rs.Path)7 Produces (javax.ws.rs.Produces)7 MapIpInterface (com.emc.storageos.api.mapper.functions.MapIpInterface)6 Host (com.emc.storageos.db.client.model.Host)6 POST (javax.ws.rs.POST)4 Initiator (com.emc.storageos.db.client.model.Initiator)3 IPInterface (com.iwave.ext.linux.model.IPInterface)3 ArrayList (java.util.ArrayList)3 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 FileExport (com.emc.storageos.db.client.model.FileExport)2 Consumes (javax.ws.rs.Consumes)2 GET (javax.ws.rs.GET)2 AixSystem (com.emc.aix.AixSystem)1 HpuxSystem (com.emc.hpux.HpuxSystem)1 MapNetwork (com.emc.storageos.api.mapper.functions.MapNetwork)1 ComputeSystemController (com.emc.storageos.computesystemcontroller.ComputeSystemController)1 DbClient (com.emc.storageos.db.client.DbClient)1