Search in sources :

Example 1 with NameIgnoreCaseFilter

use of com.emc.vipr.client.core.filters.NameIgnoreCaseFilter in project coprhd-controller by CoprHD.

the class ComputeUtils method getHostNamesByName.

/**
 * This method checks if the given host names already exist.
 * @param list of host names to check
 * @return list of host names in given list that already exist
 */
public static List<String> getHostNamesByName(ViPRCoreClient client, List<String> names) {
    List<String> hostNames = Lists.newArrayList();
    if (names == null) {
        return Collections.emptyList();
    }
    for (String hostName : names) {
        NameIgnoreCaseFilter<HostRestRep> filter = new NameIgnoreCaseFilter<HostRestRep>(hostName);
        List<HostRestRep> resp = client.hosts().getByTenant(getOrderTenant(), filter);
        for (HostRestRep hostRestRep : resp) {
            hostNames.add(hostRestRep.getHostName());
        }
    }
    return hostNames;
}
Also used : HostRestRep(com.emc.storageos.model.host.HostRestRep) NameIgnoreCaseFilter(com.emc.vipr.client.core.filters.NameIgnoreCaseFilter)

Aggregations

HostRestRep (com.emc.storageos.model.host.HostRestRep)1 NameIgnoreCaseFilter (com.emc.vipr.client.core.filters.NameIgnoreCaseFilter)1