Search in sources :

Example 16 with IpInterface

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

the class ComputeSystemHelper method getIpInterfaceEndpoints.

/**
 * A utility function that return a list of ip endpoints for a given host. Used
 * to mre efficiently check for host ip interfaces in use.
 *
 * @param hostId the host URI
 * @return list of ip endpoints for a given host
 */
public static List<String> getIpInterfaceEndpoints(DbClient dbClient, URI hostId) {
    List<IpInterface> ipInterfaces = CustomQueryUtility.queryActiveResourcesByConstraint(dbClient, IpInterface.class, ContainmentConstraint.Factory.getContainedObjectsConstraint(hostId, IpInterface.class, "host"));
    List<String> endpoints = new ArrayList<String>();
    for (IpInterface ipInterface : ipInterfaces) {
        endpoints.add(ipInterface.getIpAddress());
    }
    return endpoints;
}
Also used : IpInterface(com.emc.storageos.db.client.model.IpInterface) ArrayList(java.util.ArrayList)

Example 17 with IpInterface

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

the class ComputeSystemHelper method queryIpInterfaces.

/**
 * Returns the IP interface of a given host after it validates that the IP interface
 * exists, and belongs to the parent host.
 *
 * @param hostId the parent host URI
 * @param initiatorId the initiator URI
 * @param checkInactive when set to true, the function will also validates
 *            that the initiator is active.
 * @return the host initiator
 */
public static List<IpInterface> queryIpInterfaces(DbClient dbClient, URI id) {
    List<IpInterface> ipInterfaces = new ArrayList<IpInterface>();
    URIQueryResultList ipInterfaceUris = new URIQueryResultList();
    dbClient.queryByConstraint(ContainmentConstraint.Factory.getContainedObjectsConstraint(id, IpInterface.class, "host"), ipInterfaceUris);
    if (ipInterfaceUris.iterator().hasNext()) {
        for (URI ipInterfaceUri : ipInterfaceUris) {
            IpInterface ipInterface = dbClient.queryObject(IpInterface.class, ipInterfaceUri);
            if (ipInterface != null && !ipInterface.getInactive()) {
                ipInterfaces.add(ipInterface);
            }
        }
    }
    return ipInterfaces;
}
Also used : IpInterface(com.emc.storageos.db.client.model.IpInterface) ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 18 with IpInterface

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

the class ComputeSystemHelper method doDeactivateHost.

/**
 * Utility function to recursively deactivate all the hosts interfaces
 *
 * @param host the host to deactivate
 */
public static void doDeactivateHost(DbClient dbClient, Host host) {
    List<IpInterface> hostInterfaces = queryIpInterfaces(dbClient, host.getId());
    for (IpInterface hostInterface : hostInterfaces) {
        hostInterface.setRegistrationStatus(RegistrationStatus.UNREGISTERED.toString());
        dbClient.markForDeletion(hostInterface);
        EventUtils.deleteResourceEvents(dbClient, hostInterface.getId());
    }
    List<Initiator> initiators = queryInitiators(dbClient, host.getId());
    for (Initiator initiator : initiators) {
        initiator.setRegistrationStatus(RegistrationStatus.UNREGISTERED.toString());
        dbClient.markForDeletion(initiator);
        EventUtils.deleteResourceEvents(dbClient, initiator.getId());
    }
    host.setRegistrationStatus(RegistrationStatus.UNREGISTERED.toString());
    host.setProvisioningStatus(Host.ProvisioningJobStatus.COMPLETE.toString());
    dbClient.persistObject(host);
    _log.info("marking host for deletion: {} {}", host.getLabel(), host.getId());
    dbClient.markForDeletion(host);
    EventUtils.deleteResourceEvents(dbClient, host.getId());
}
Also used : IpInterface(com.emc.storageos.db.client.model.IpInterface) Initiator(com.emc.storageos.db.client.model.Initiator)

Example 19 with IpInterface

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

the class AbstractDiscoveryAdapter method updateManuallyCreatedInterfaces.

/**
 * Updates IP interfaces by setting isManualCreation value to true if the value is null.
 * Handles the newly added isManualCreation field to IPInterface by assuming that null values
 * are true. During next discovery, any discovered interfaces will have isManualCreation
 * value set to false.
 *
 * @param ipInterfaces
 *            list of IP interfaces
 */
protected void updateManuallyCreatedInterfaces(Iterable<IpInterface> ipInterfaces) {
    for (IpInterface ipInterface : ipInterfaces) {
        if (ipInterface.getIsManualCreation() == null) {
            ipInterface.setIsManualCreation(true);
            modelClient.save(ipInterface);
        }
    }
}
Also used : IpInterface(com.emc.storageos.db.client.model.IpInterface)

Example 20 with IpInterface

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

the class AbstractDiscoveryAdapter method removeIpInterfaces.

protected void removeIpInterfaces(Iterable<IpInterface> ipInterfaces) {
    for (IpInterface ipInterface : ipInterfaces) {
        ipInterface.setHost(NullColumnValueGetter.getNullURI());
        ipInterface.setInactive(true);
        save(ipInterface);
    }
}
Also used : IpInterface(com.emc.storageos.db.client.model.IpInterface)

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