Search in sources :

Example 1 with AthenzService

use of com.yahoo.config.provision.AthenzService in project vespa by vespa-engine.

the class DeploymentSpecXmlReader method read.

/**
 * Reads a deployment spec from XML
 */
public DeploymentSpec read(String xmlForm) {
    List<Step> steps = new ArrayList<>();
    Optional<String> globalServiceId = Optional.empty();
    Element root = XML.getDocument(xmlForm).getDocumentElement();
    if (validate)
        validateTagOrder(root);
    for (Element environmentTag : XML.getChildren(root)) {
        if (!isEnvironmentName(environmentTag.getTagName()))
            continue;
        Environment environment = Environment.from(environmentTag.getTagName());
        if (environment == Environment.prod) {
            for (Element stepTag : XML.getChildren(environmentTag)) {
                Optional<AthenzService> athenzService = stringAttribute("athenz-service", environmentTag).map(AthenzService::from);
                if (stepTag.getTagName().equals("delay")) {
                    steps.add(new Delay(Duration.ofSeconds(longAttribute("hours", stepTag) * 60 * 60 + longAttribute("minutes", stepTag) * 60 + longAttribute("seconds", stepTag))));
                } else if (stepTag.getTagName().equals("parallel")) {
                    List<DeclaredZone> zones = new ArrayList<>();
                    for (Element regionTag : XML.getChildren(stepTag)) {
                        zones.add(readDeclaredZone(environment, athenzService, regionTag));
                    }
                    steps.add(new ParallelZones(zones));
                } else {
                    // a region: deploy step
                    steps.add(readDeclaredZone(environment, athenzService, stepTag));
                }
            }
        } else {
            steps.add(new DeclaredZone(environment));
        }
        if (environment == Environment.prod)
            globalServiceId = readGlobalServiceId(environmentTag);
        else if (readGlobalServiceId(environmentTag).isPresent())
            throw new IllegalArgumentException("Attribute 'global-service-id' is only valid on 'prod' tag.");
    }
    Optional<AthenzDomain> athenzDomain = stringAttribute("athenz-domain", root).map(AthenzDomain::from);
    Optional<AthenzService> athenzService = stringAttribute("athenz-service", root).map(AthenzService::from);
    return new DeploymentSpec(globalServiceId, readUpgradePolicy(root), readChangeBlockers(root), steps, xmlForm, athenzDomain, athenzService);
}
Also used : AthenzService(com.yahoo.config.provision.AthenzService) AthenzDomain(com.yahoo.config.provision.AthenzDomain) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) Step(com.yahoo.config.application.api.DeploymentSpec.Step) DeclaredZone(com.yahoo.config.application.api.DeploymentSpec.DeclaredZone) Delay(com.yahoo.config.application.api.DeploymentSpec.Delay) ParallelZones(com.yahoo.config.application.api.DeploymentSpec.ParallelZones) DeploymentSpec(com.yahoo.config.application.api.DeploymentSpec) Environment(com.yahoo.config.provision.Environment) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with AthenzService

use of com.yahoo.config.provision.AthenzService in project vespa by vespa-engine.

the class ContainerModelBuilder method addIdentityProvider.

private void addIdentityProvider(ContainerCluster cluster, List<ConfigServerSpec> configServerSpecs, HostName loadBalancerName, Zone zone, DeploymentSpec spec) {
    spec.athenzDomain().ifPresent(domain -> {
        AthenzService service = spec.athenzService(zone.environment(), zone.region()).orElseThrow(() -> new RuntimeException("Missing Athenz service configuration"));
        IdentityProvider identityProvider = new IdentityProvider(domain, service, getLoadBalancerName(loadBalancerName, configServerSpecs));
        cluster.addComponent(identityProvider);
        cluster.getContainers().forEach(container -> {
            container.setProp("identity.domain", domain.value());
            container.setProp("identity.service", service.value());
        });
    });
}
Also used : AthenzService(com.yahoo.config.provision.AthenzService) IdentityProvider(com.yahoo.vespa.model.container.IdentityProvider)

Aggregations

AthenzService (com.yahoo.config.provision.AthenzService)2 DeploymentSpec (com.yahoo.config.application.api.DeploymentSpec)1 DeclaredZone (com.yahoo.config.application.api.DeploymentSpec.DeclaredZone)1 Delay (com.yahoo.config.application.api.DeploymentSpec.Delay)1 ParallelZones (com.yahoo.config.application.api.DeploymentSpec.ParallelZones)1 Step (com.yahoo.config.application.api.DeploymentSpec.Step)1 AthenzDomain (com.yahoo.config.provision.AthenzDomain)1 Environment (com.yahoo.config.provision.Environment)1 IdentityProvider (com.yahoo.vespa.model.container.IdentityProvider)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Element (org.w3c.dom.Element)1