/**
   * Default pre-start hooks.
   *
   * <p>Can be extended by subclasses if needed.
   */
  protected void preStartCustom(MachineLocation machine) {
    ConfigToAttributes.apply(entity());

    // Opportunity to block startup until other dependent components are available
    Object val = entity().getConfig(SoftwareProcess.START_LATCH);
    if (val != null)
      log.debug("{} finished waiting for start-latch {}; continuing...", entity(), val);
  }
Пример #2
0
  @Override
  public void init() {
    super.init();

    ConfigToAttributes.apply(this, DOCKER_HOST);
    ConfigToAttributes.apply(this, DOCKER_REGISTRY_PORT);

    DockerHost host = (DockerHost) sensors().get(DOCKER_HOST);
    String installDir = host.sensors().get(SoftwareProcess.INSTALL_DIR);
    SshMachineLocation sshMachine = host.getDynamicLocation().getMachine();
    String sshMachineInstallDir = getSSHMachineInstallDir();

    config()
        .set(
            DockerAttributes.DOCKER_PORT_BINDINGS,
            MutableMap.of(sensors().get(DOCKER_REGISTRY_PORT), 5000));
    config()
        .set(
            DockerAttributes.DOCKER_HOST_VOLUME_MAPPING,
            MutableMap.of(Os.mergePaths(installDir, "certs"), "/certs"));

    sshMachine.installTo(
        ImmutableMap.of(SshTool.PROP_PERMISSIONS.getName(), "0755"),
        SCRIPT_LOCATION,
        Os.mergePaths(sshMachineInstallDir, CREATE_CERTS_SCRIPT_NAME));
    sshMachine.installTo(
        config().get(DockerInfrastructure.DOCKER_CA_CERTIFICATE_PATH),
        Os.mergePaths(sshMachineInstallDir, "ca-cert.pem"));
    sshMachine.installTo(
        config().get(DockerInfrastructure.DOCKER_CA_KEY_PATH),
        Os.mergePaths(sshMachineInstallDir, "ca-key.pem"));

    int result =
        sshMachine.execCommands(
            "installCerts",
            ImmutableList.of(
                BashCommands.sudo(
                    String.format(
                        "%s %s %s",
                        Os.mergePaths(sshMachineInstallDir, CREATE_CERTS_SCRIPT_NAME),
                        host.sensors().get(Attributes.ADDRESS),
                        sshMachineInstallDir))));
    if (result != 0) {
      throw new IllegalStateException("Could not create certificates for docker registry");
    }
  }
Пример #3
0
  @Override
  public void init() {
    super.init();

    ConfigToAttributes.apply(this, MESOS_SLAVE_ID);

    EnricherSpec<?> serviceUp =
        Enrichers.builder()
            .propagating(ImmutableMap.of(SLAVE_ACTIVE, SERVICE_UP))
            .from(this)
            .build();
    enrichers().add(serviceUp);
  }
Пример #4
0
 @Override
 public void init() {
   sensors().set(Attributes.HOSTNAME, "localhost");
   sensors()
       .set(
           UsesJmx.JMX_PORT,
           LocalhostMachineProvisioningLocation.obtainPort(
               PortRanges.fromString(
                   // just doing "40123+" was not enough to avoid collisions (on 40125),
                   // observed on jenkins, not sure why but
                   // maybe something else had a UDP connection we weren't detected,
                   // or the static lock our localhost uses was being bypassed;
                   // this should improve things (2016-01)
                   NetworkingTestUtils.randomPortAround(40000) + "+")));
   // only supports no-agent, at the moment
   config().set(UsesJmx.JMX_AGENT_MODE, JmxAgentModes.NONE);
   sensors().set(UsesJmx.RMI_REGISTRY_PORT, -1); // -1 means to use the JMX_PORT only
   ConfigToAttributes.apply(this, UsesJmx.JMX_CONTEXT);
 }