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