@@ -0,0 +1,1731 @@
+package org.ovirt.engine.core.bll.host.provider.foreman;%0A%0Aimport java.net.InetAddress;%0Aimport java.net.UnknownHostException;%0Aimport java.util.List;%0A%0Aimport javax.inject.Inject;%0A%0Aimport org.ovirt.engine.core.bll.host.provider.HostProviderProxy;%0Aimport org.ovirt.engine.core.bll.provider.ProviderProxyFactory;%0Aimport org.ovirt.engine.core.common.businessentities.Provider;%0Aimport org.ovirt.engine.core.common.businessentities.ProviderType;%0Aimport org.ovirt.engine.core.dal.dbbroker.DbFacade;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Apublic class SystemProviderFinder %7B%0A%0A    private static Logger log = LoggerFactory.getLogger(SystemProviderFinder.class);%0A    private String systemHostName;%0A%0A    @Inject%0A    private DbFacade dbFacade;%0A%0A    public HostProviderProxy findSystemProvider() %7B%0A        systemHostName = resolveSystemHostName();%0A        if (systemHostName == null) %7B%0A            return null;%0A        %7D%0A%0A        List%3CProvider%3C?%3E%3E hostProviders = dbFacade.getProviderDao().getAllByType(ProviderType.FOREMAN);%0A        HostProviderProxy proxy = null;%0A        for (Provider%3C?%3E provider : hostProviders) %7B%0A            proxy = (HostProviderProxy) ProviderProxyFactory.getInstance().create(provider);%0A            if (proxy.findContentHost(systemHostName) != null) %7B%0A                return proxy;%0A            %7D%0A        %7D%0A%0A        return null;%0A    %7D%0A%0A    public String getSystemHostName() %7B%0A        return systemHostName;%0A    %7D%0A%0A    private String resolveSystemHostName() %7B%0A        try %7B%0A            return InetAddress.getLocalHost().getHostName();%0A        %7D catch (UnknownHostException e) %7B%0A            log.error(%22Failed to resolve hostname for the ovir-engine server%22, e);%0A            return null;%0A        %7D%0A    %7D%0A%7D%0A

Add SystemProviderFinder