Search in sources :

Example 26 with IpInterface

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

the class IpInterfaceService method deactivateIpInterface.

/**
 * Deactivate an IP interface.
 *
 * @param id the URN of a ViPR IP interface
 * @prereq The IP interface must not have active exports
 * @brief Delete IP interface
 * @return OK if deactivation completed successfully
 * @throws DatabaseException
 */
@POST
@Path("/{id}/deactivate")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN })
public TaskResourceRep deactivateIpInterface(@PathParam("id") URI id) throws DatabaseException {
    IpInterface ipInterface = queryResource(id);
    ArgValidator.checkEntity(ipInterface, id, isIdEmbeddedInURL(id));
    if (ipInterface.getIsManualCreation() != null && !ipInterface.getIsManualCreation()) {
        throw APIException.badRequests.ipInterfaceNotCreatedManuallyAndCannotBeDeleted();
    }
    String taskId = UUID.randomUUID().toString();
    Operation op = _dbClient.createTaskOpStatus(IpInterface.class, ipInterface.getId(), taskId, ResourceOperationTypeEnum.DELETE_HOST_IPINTERFACE);
    // Clean up File Export if host is in use
    if (ComputeSystemHelper.isHostIpInterfacesInUse(_dbClient, Collections.singletonList(ipInterface.getIpAddress()), ipInterface.getHost())) {
        ComputeSystemController controller = getController(ComputeSystemController.class, null);
        controller.removeIpInterfaceFromFileShare(ipInterface.getHost(), ipInterface.getId(), taskId);
    } else {
        _dbClient.ready(IpInterface.class, ipInterface.getId(), taskId);
        _dbClient.markForDeletion(ipInterface);
    }
    auditOp(OperationTypeEnum.DELETE_HOST_IPINTERFACE, true, null, ipInterface.auditParameters());
    return toTask(ipInterface, taskId, op);
}
Also used : MapIpInterface(com.emc.storageos.api.mapper.functions.MapIpInterface) IpInterface(com.emc.storageos.db.client.model.IpInterface) ComputeSystemController(com.emc.storageos.computesystemcontroller.ComputeSystemController) Operation(com.emc.storageos.db.client.model.Operation) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 27 with IpInterface

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

the class NetworkService method getIpInterfaces.

/**
 * This call returns a list of all IpInterfaces associated
 * with the Network end points.
 *
 * @param id the URN of a ViPR network
 * @brief List IP interfaces
 * @return IpInterfaceList
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
@Path("/{id}/ip-interfaces")
public IpInterfaceList getIpInterfaces(@PathParam("id") URI id) {
    IpInterfaceList registeredIpInterfaces = new IpInterfaceList();
    ArgValidator.checkFieldUriType(id, Network.class, "id");
    Network tzone = queryResource(id);
    if (StorageProtocol.Transport.IP.name().equalsIgnoreCase(tzone.getTransportType())) {
        StringSet endpts = tzone.retrieveEndpoints();
        Iterator<String> endptsIter = endpts.iterator();
        URIQueryResultList resultsList = new URIQueryResultList();
        while (endptsIter.hasNext()) {
            String endpt = endptsIter.next();
            _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getIpInterfaceIpAddressConstraint(endpt.toUpperCase()), resultsList);
            Iterator<URI> resultsIter = resultsList.iterator();
            while (resultsIter.hasNext()) {
                IpInterface ipInterface = _dbClient.queryObject(IpInterface.class, resultsIter.next());
                if (ipInterface != null) {
                    registeredIpInterfaces.getIpInterfaces().add(toNamedRelatedResource(ipInterface, ipInterface.getLabel()));
                }
            }
        }
    }
    return registeredIpInterfaces;
}
Also used : IpInterface(com.emc.storageos.db.client.model.IpInterface) IpInterfaceList(com.emc.storageos.model.host.IpInterfaceList) Network(com.emc.storageos.db.client.model.Network) MapNetwork(com.emc.storageos.api.mapper.functions.MapNetwork) StringSet(com.emc.storageos.db.client.model.StringSet) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

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