use of com.netflix.spinnaker.halyard.deploy.services.v1.GenerateService.ResolvedConfiguration in project halyard by spinnaker.
the class LocalDebianServiceProvider method getInstallCommand.
@Override
public String getInstallCommand(DeploymentDetails deploymentDetails, GenerateService.ResolvedConfiguration resolvedConfiguration, Map<String, String> installCommands) {
Map<String, Object> bindings = new HashMap<>();
List<SpinnakerService.Type> serviceTypes = new ArrayList<>(installCommands.keySet()).stream().map(SpinnakerService.Type::fromCanonicalName).collect(Collectors.toList());
List<String> upstartNames = getLocalServices(serviceTypes).stream().filter(i -> resolvedConfiguration.getServiceSettings(i.getService()).getEnabled()).map(i -> ((LocalDebianService) i).getUpstartServiceName()).filter(Objects::nonNull).collect(Collectors.toList());
List<String> systemdServiceConfigs = upstartNames.stream().map(n -> n + ".service").collect(Collectors.toList());
List<String> serviceInstalls = serviceTypes.stream().map(t -> installCommands.get(t.getCanonicalName())).collect(Collectors.toList());
TemplatedResource resource = new StringReplaceJarResource("/debian/init.sh");
bindings.put("services", Strings.join(upstartNames, " "));
bindings.put("systemd-service-configs", Strings.join(systemdServiceConfigs, " "));
String upstartInit = resource.setBindings(bindings).toString();
BillOfMaterials.ArtifactSources artifactSources = artifactService.getArtifactSources(deploymentDetails.getDeploymentName());
resource = new StringReplaceJarResource("/debian/install.sh");
bindings = new HashMap<>();
bindings.put("prepare-environment", "true");
bindings.put("install-redis", "true");
bindings.put("debian-repository", artifactSourcesConfig.mergeWithBomSources(artifactSources).getDebianRepository());
bindings.put("install-commands", String.join("\n", serviceInstalls));
bindings.put("service-action", "restart");
bindings.put("upstart-init", upstartInit);
return resource.setBindings(bindings).toString();
}
use of com.netflix.spinnaker.halyard.deploy.services.v1.GenerateService.ResolvedConfiguration in project halyard by spinnaker.
the class LocalDeployer method deploy.
@Override
public RemoteAction deploy(LocalServiceProvider serviceProvider, DeploymentDetails deploymentDetails, GenerateService.ResolvedConfiguration resolvedConfiguration, List<SpinnakerService.Type> serviceTypes) {
List<LocalService> enabledServices = serviceProvider.getLocalServices(serviceTypes).stream().filter(i -> resolvedConfiguration.getServiceSettings(i.getService()).getEnabled()).collect(Collectors.toList());
Map<String, String> installCommands = enabledServices.stream().filter(i -> !resolvedConfiguration.getServiceSettings(i.getService()).getSkipLifeCycleManagement()).reduce(new HashMap<>(), (commands, installable) -> {
String command = String.join("\n", installable.installArtifactCommand(deploymentDetails), installable.stageProfilesCommand(deploymentDetails, resolvedConfiguration));
commands.put(installable.getService().getCanonicalName(), command);
return commands;
}, (m1, m2) -> {
m1.putAll(m2);
return m1;
});
String installCommand = serviceProvider.getInstallCommand(deploymentDetails, resolvedConfiguration, installCommands);
RemoteAction result = new RemoteAction();
result.setAutoRun(true);
result.setScript(installCommand);
return result;
}
use of com.netflix.spinnaker.halyard.deploy.services.v1.GenerateService.ResolvedConfiguration in project halyard by spinnaker.
the class DeployService method deploy.
public RemoteAction deploy(String deploymentName, List<DeployOption> deployOptions, List<String> serviceNames) {
DeploymentConfiguration deploymentConfiguration = deploymentService.getDeploymentConfiguration(deploymentName);
SpinnakerServiceProvider<DeploymentDetails> serviceProvider = serviceProviderFactory.create(deploymentConfiguration);
List<SpinnakerService.Type> serviceTypes = serviceNames.stream().map(SpinnakerService.Type::fromCanonicalName).collect(Collectors.toList());
if (serviceTypes.isEmpty()) {
serviceTypes = serviceProvider.getServices().stream().map(SpinnakerService::getType).collect(Collectors.toList());
}
ResolvedConfiguration resolvedConfiguration;
if (deployOptions.contains(DeployOption.OMIT_CONFIG)) {
resolvedConfiguration = generateService.generateConfig(deploymentName, Collections.emptyList());
} else {
resolvedConfiguration = generateService.generateConfig(deploymentName, serviceTypes);
}
Path serviceSettingsPath = halconfigDirectoryStructure.getServiceSettingsPath(deploymentName);
configParser.atomicWrite(serviceSettingsPath, resolvedConfiguration.getRuntimeSettings());
Path serviceProfilesPath = halconfigDirectoryStructure.getServiceProfilesPath(deploymentName);
configParser.atomicWrite(serviceProfilesPath, resolvedConfiguration.getServiceProfiles());
Deployer deployer = getDeployer(deploymentConfiguration);
DeploymentDetails deploymentDetails = getDeploymentDetails(deploymentConfiguration);
RemoteAction action = deployer.deploy(serviceProvider, deploymentDetails, resolvedConfiguration, serviceTypes);
halconfigParser.backupConfig();
if (deployOptions.contains(DeployOption.FLUSH_INFRASTRUCTURE_CACHES)) {
deployer.flushInfrastructureCaches(serviceProvider, deploymentDetails, resolvedConfiguration.getRuntimeSettings());
}
if (!action.getScript().isEmpty()) {
action.commitScript(halconfigDirectoryStructure.getInstallScriptPath(deploymentName));
}
return action;
}
use of com.netflix.spinnaker.halyard.deploy.services.v1.GenerateService.ResolvedConfiguration in project halyard by spinnaker.
the class LocalGitServiceProvider method getInstallCommand.
@Override
public String getInstallCommand(DeploymentDetails deploymentDetails, GenerateService.ResolvedConfiguration resolvedConfiguration, Map<String, String> installCommands) {
Map<String, Object> bindings;
List<SpinnakerService.Type> serviceTypes = new ArrayList<>(installCommands.keySet()).stream().map(SpinnakerService.Type::fromCanonicalName).collect(Collectors.toList());
List<String> serviceInstalls = serviceTypes.stream().map(t -> installCommands.get(t.getCanonicalName())).collect(Collectors.toList());
TemplatedResource resource = new StringReplaceJarResource("/git/install.sh");
bindings = new HashMap<>();
bindings.put("install-commands", String.join("\n", serviceInstalls));
return resource.setBindings(bindings).toString();
}
use of com.netflix.spinnaker.halyard.deploy.services.v1.GenerateService.ResolvedConfiguration in project halyard by spinnaker.
the class BakeDeployer method deploy.
@Override
public RemoteAction deploy(BakeServiceProvider serviceProvider, DeploymentDetails deploymentDetails, GenerateService.ResolvedConfiguration resolvedConfiguration, List<SpinnakerService.Type> serviceTypes) {
List<BakeService> enabledServices = serviceProvider.getPrioritizedBakeableServices(serviceTypes).stream().filter(i -> resolvedConfiguration.getServiceSettings(i.getService()).getEnabled()).collect(Collectors.toList());
Map<String, String> installCommands = enabledServices.stream().reduce(new HashMap<>(), (commands, installable) -> {
String command = String.join("\n", installable.installArtifactCommand(deploymentDetails), installable.stageStartupScripts(deploymentDetails, resolvedConfiguration));
commands.put(installable.getService().getCanonicalName(), command);
return commands;
}, (m1, m2) -> {
m1.putAll(m2);
return m1;
});
String startupCommand = String.join("\n", enabledServices.stream().map(BakeService::getStartupCommand).filter(Objects::nonNull).collect(Collectors.toList()));
String installCommand = serviceProvider.getInstallCommand(deploymentDetails, resolvedConfiguration, installCommands, startupCommand);
RemoteAction result = new RemoteAction();
result.setAutoRun(true);
result.setScript(installCommand);
return result;
}
Aggregations