Search in sources :

Example 1 with Repo

use of de.cinovo.cloudconductor.api.model.Repo in project cloudconductor-agent-redhat by cinovo.

the class RepoHandler method run.

/**
 * @throws ExecutionError an error occurred during the execution
 */
public void run() throws ExecutionError {
    RepoHandler.LOGGER.debug("Start RepoHandler");
    Set<Repo> repos;
    try {
        repos = ServerCom.getRepos();
    } catch (CloudConductorException e) {
        throw new ExecutionError("Error getting repositories for template: ", e);
    }
    RepoHandler.LOGGER.debug("Update " + repos.size() + " yum repos...");
    Set<String> repoNames = new HashSet<>();
    for (Repo repo : repos) {
        try {
            repoNames.add(repo.getName());
            FileHelper.writeYumRepo(repo);
        } catch (IOException e) {
            throw new ExecutionError("Error writing yum repo for '" + repo.getName() + "': ", e);
        }
    }
    AgentState.info().setRepos(repoNames);
    RepoHandler.LOGGER.debug("Finished RepoHandler");
}
Also used : CloudConductorException(de.cinovo.cloudconductor.api.lib.exceptions.CloudConductorException) ExecutionError(de.cinovo.cloudconductor.agent.exceptions.ExecutionError) Repo(de.cinovo.cloudconductor.api.model.Repo) IOException(java.io.IOException) HashSet(java.util.HashSet)

Aggregations

ExecutionError (de.cinovo.cloudconductor.agent.exceptions.ExecutionError)1 CloudConductorException (de.cinovo.cloudconductor.api.lib.exceptions.CloudConductorException)1 Repo (de.cinovo.cloudconductor.api.model.Repo)1 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1