Java 类com.amazonaws.services.elasticbeanstalk.model.CreateEnvironmentRequest 实例源码

项目:cloudml    文件:BeanstalkConnector.java   
public void createEnvironment(String applicationName, String domainName, String envName, String stackName) {
    CreateEnvironmentRequest cr = new CreateEnvironmentRequest();
    cr.setApplicationName(applicationName);
    cr.setEnvironmentName(envName);
    String stack = findSolutionStack(stackName);
    if (!stack.equals("")) {
        cr.setSolutionStackName(stack);
        CheckDNSAvailabilityResult r = checkDNS(domainName);
        if (r.isAvailable()) {
            cr.setCNAMEPrefix(domainName);
            CreateEnvironmentResult res = beanstalkClient.createEnvironment(cr);
            journal.log(Level.INFO, ">> Status of the environment creation: " + res.toString());
        } else {
            journal.log(Level.INFO, ">> Status of the environment creation: Domain Name already existing");
        }
    } else {
        journal.log(Level.INFO, ">> Status of the environment creation: This type of stack does not exist!");
    }
}
项目:cloudml    文件:BeanstalkConnector.java   
public String createEnvironmentWithWar(String applicationName, String domainName, String envName, String stackName, int minRam, String warFile, String versionLabel) {
    String endPoint="";
    prepareWar(new File(warFile), versionLabel, applicationName);
    CreateEnvironmentRequest cr = new CreateEnvironmentRequest();

    cr.setApplicationName(applicationName);
    cr.setEnvironmentName(envName);
    cr.setVersionLabel(versionLabel);
    String stack = findSolutionStack(stackName);
    if (!stack.equals("")) {
        cr.setSolutionStackName(stack);
        CheckDNSAvailabilityResult r = checkDNS(domainName);
        if (r.isAvailable()) {
            cr.setCNAMEPrefix(domainName);
            CreateEnvironmentResult res = beanstalkClient.createEnvironment(cr);
            endPoint=res.getEndpointURL();
            journal.log(Level.INFO, ">> Status of the environment creation: " + res.toString());
        } else {
            journal.log(Level.INFO, ">> Status of the environment creation: Domain Name already existing");
        }
    } else {
        journal.log(Level.INFO, ">> Status of the environment creation: This type of stack does not exist!");
    }
    return endPoint;
}
项目:jcabi-beanstalk-maven-plugin    文件:Application.java   
/**
 * Create candidate environment.
 * @param version Version to deploy
 * @param template EBT configuration template
 * @return The environment
 */
public Environment candidate(@NotNull final Version version,
    @NotNull final String template) {
    final CreateEnvironmentRequest request = this.suggest();
    Logger.info(
        this,
        "Suggested candidate environment name is '%s' with '%s' CNAME",
        request.getEnvironmentName(),
        request.getCNAMEPrefix()
    );
    final CreateEnvironmentResult res = this.client.createEnvironment(
        request
            .withApplicationName(this.name)
            .withVersionLabel(version.label())
            .withTemplateName(template)
    );
    Logger.info(
        this,
        // @checkstyle LineLength (1 line)
        "Candidate environment '%s/%s/%s' created at CNAME '%s' (status:%s, health:%s)",
        res.getApplicationName(), res.getEnvironmentName(),
        res.getEnvironmentId(), res.getCNAME(),
        res.getStatus(), res.getHealth()
    );
    return new Environment(this.client, res.getEnvironmentId());
}
项目:jcabi-beanstalk-maven-plugin    文件:Application.java   
/**
 * Suggest new candidate environment CNAME (and at the same time it will
 * be used as a name of environment).
 * @return The environment create request with data inside
 */
private CreateEnvironmentRequest suggest() {
    final CreateEnvironmentRequest request = new CreateEnvironmentRequest();
    while (true) {
        if (!this.occupied(this.name)) {
            request.withCNAMEPrefix(this.name);
            break;
        }
        if (this.hasPrimary()) {
            request.withCNAMEPrefix(this.makeup());
            break;
        }
        Logger.info(this, "Waiting for '%s' CNAME", this.name);
    }
    while (true) {
        final String ename = this.random();
        if (!this.exists(ename)) {
            request.withEnvironmentName(ename).withDescription(ename);
            Logger.info(this, "Using '%s' as env name", ename);
            break;
        }
    }
    return request;
}
项目:aws-ant-tasks    文件:CreateBeanstalkEnvironmentTask.java   
public void execute() {
    checkParams();
    AWSElasticBeanstalkClient client = getOrCreateClient(AWSElasticBeanstalkClient.class);
    CreateEnvironmentRequest eRequest = new CreateEnvironmentRequest(
            applicationName, environmentName)
            .withDescription(environmentDescription)
            .withVersionLabel(versionLabel)
            .withSolutionStackName(solutionStackName);
    if (!(tierName == null || tierType == null || tierVersion == null)) {
        eRequest.setTier(new EnvironmentTier().withName(tierName)
                .withType(tierType).withVersion(tierVersion));
    }

    if (cnamePrefix != null) {
        CheckDNSAvailabilityResult dnsResult = client
                .checkDNSAvailability(new CheckDNSAvailabilityRequest(
                        cnamePrefix));
        if (!dnsResult.isAvailable()) {
            throw new BuildException("The specified CNAME " + cnamePrefix
                    + " was not available");
        }
        eRequest.setCNAMEPrefix(cnamePrefix);
    }
    List<ConfigurationOptionSetting> optionSettings = new LinkedList<ConfigurationOptionSetting>();
    for (Setting setting : settings) {
        optionSettings.add(new ConfigurationOptionSetting(setting
                .getNamespace(), setting.getOptionName(), setting
                .getValue()));
    }
    if (optionSettings.size() > 0) {
        eRequest.setOptionSettings(optionSettings);
    }
    System.out.println("Creating environment " + environmentName + "...");
    String cNAME = "";
    try {
        CreateEnvironmentResult result = client.createEnvironment(eRequest);
        if ((cNAME = result.getCNAME()) == null) {
            System.out
                    .println("Create environment request submitted. The environment configuration does not support a CNAME.");
        } else {
            System.out
                    .println("Create environment request submitted. When the environment is finished launching, your deployment will be available at "
                            + cNAME);
        }
    } catch (Exception e) {
        throw new BuildException(
                "Exception while attempting to create environment: "
                        + e.getMessage(), e);
    }

}
项目:jcabi-beanstalk-maven-plugin    文件:ApplicationTest.java   
/**
 * Application can create a new environment.
 * @throws Exception If something is wrong
 */
@Test
public void createsNewEnvironment() throws Exception {
    final String name = "some-app-name";
    final String template = "some-template";
    final Version version = Mockito.mock(Version.class);
    final AWSElasticBeanstalk ebt = Mockito.mock(AWSElasticBeanstalk.class);
    Mockito.doReturn(
        new CheckDNSAvailabilityResult().withAvailable(true)
    ).when(ebt)
        .checkDNSAvailability(
            Mockito.any(CheckDNSAvailabilityRequest.class)
        );
    Mockito.doReturn(
        new CreateEnvironmentResult()
            .withApplicationName(name)
            .withEnvironmentId("f4g5h6j7")
            .withEnvironmentName(name)
    ).when(ebt)
        .createEnvironment(
            Mockito.any(CreateEnvironmentRequest.class)
        );
    Mockito.doReturn(
        new DescribeConfigurationSettingsResult().withConfigurationSettings(
            new ArrayList<ConfigurationSettingsDescription>(0)
        )
    ).when(ebt)
        .describeConfigurationSettings(
            Mockito.any(DescribeConfigurationSettingsRequest.class)
        );
    Mockito.doReturn(
        new DescribeEnvironmentsResult().withEnvironments(
            Arrays.asList(
                new EnvironmentDescription()
                    .withCNAME("")
                    .withEnvironmentName("some-env")
                    .withEnvironmentId("a1b2c3d4")
                    .withStatus("Ready")
            )
        )
    ).when(ebt)
        .describeEnvironments(
            Mockito.any(DescribeEnvironmentsRequest.class)
        );
    Mockito.doReturn(new TerminateEnvironmentResult())
        .when(ebt)
        .terminateEnvironment(
            Mockito.any(TerminateEnvironmentRequest.class)
        );
    final Application app = new Application(ebt, name);
    app.clean(false);
    MatcherAssert.assertThat(
        app.candidate(version, template),
        Matchers.notNullValue()
    );
}