Search in sources :

Example 1 with PackageStateChanges

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

the class PackageHandler method run.

/**
 * @throws ExecutionError an error occurred during execution
 */
public void run() throws ExecutionError {
    PackageHandler.LOGGER.debug("Start PackageHandler");
    // report installed packages
    PackageStateChanges packageChanges = this.reportInstalledPackages();
    Set<String> repos = AgentState.info().getRepos();
    if (!repos.isEmpty()) {
        String repoNames = String.join(",", repos);
        PackageHandler.LOGGER.debug("Execute changes on repos {}", repoNames);
        // executed package changes for each repository
        List<PackageVersion> toDelete = packageChanges.getToErase();
        PackageHandler.LOGGER.debug("Delete: {}", toDelete.toString());
        List<PackageVersion> toInstall = packageChanges.getToInstall();
        PackageHandler.LOGGER.debug("Install: {}", toInstall.toString());
        List<PackageVersion> toUpdate = packageChanges.getToUpdate();
        PackageHandler.LOGGER.debug("Update: {}", toUpdate.toString());
        ScriptExecutor pkgHandler = ScriptExecutor.generatePackageHandler(repoNames, toDelete, toInstall, toUpdate);
        pkgHandler.execute();
        // re-report installed packages
        this.reportInstalledPackages();
    } else {
        PackageHandler.LOGGER.info("No repos in template");
    }
    PackageHandler.LOGGER.debug("Finished PackageHandler");
}
Also used : PackageStateChanges(de.cinovo.cloudconductor.api.model.PackageStateChanges) PackageVersion(de.cinovo.cloudconductor.api.model.PackageVersion) ScriptExecutor(de.cinovo.cloudconductor.agent.executors.ScriptExecutor)

Aggregations

ScriptExecutor (de.cinovo.cloudconductor.agent.executors.ScriptExecutor)1 PackageStateChanges (de.cinovo.cloudconductor.api.model.PackageStateChanges)1 PackageVersion (de.cinovo.cloudconductor.api.model.PackageVersion)1