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