• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java InstanceStateName类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.amazonaws.services.ec2.model.InstanceStateName的典型用法代码示例。如果您正苦于以下问题:Java InstanceStateName类的具体用法?Java InstanceStateName怎么用?Java InstanceStateName使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



InstanceStateName类属于com.amazonaws.services.ec2.model包,在下文中一共展示了InstanceStateName类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: startInstances

import com.amazonaws.services.ec2.model.InstanceStateName; //导入依赖的package包/类
@Override
public StartInstancesResult startInstances(StartInstancesRequest startInstancesRequest) {
    StartInstancesResult result = new StartInstancesResult();
    if (startInstancesRequest.getInstanceIds().get(0).equals("test-1")) {
        Collection<InstanceStateChange> coll = new ArrayList<InstanceStateChange>();
        InstanceStateChange sc = new InstanceStateChange();
        InstanceState previousState = new InstanceState();
        previousState.setCode(80);
        previousState.setName(InstanceStateName.Stopped);
        InstanceState newState = new InstanceState();
        newState.setCode(16);
        newState.setName(InstanceStateName.Running);
        sc.setPreviousState(previousState);
        sc.setCurrentState(newState);
        sc.setInstanceId("test-1");
        coll.add(sc);
        result.setStartingInstances(coll);
    } else {
        throw new AmazonServiceException("The image-id doesn't exists");
    }
    return result;       
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:AmazonEC2ClientMock.java


示例2: stopInstances

import com.amazonaws.services.ec2.model.InstanceStateName; //导入依赖的package包/类
@Override
public StopInstancesResult stopInstances(StopInstancesRequest stopInstancesRequest) {
    StopInstancesResult result = new StopInstancesResult();
    if (stopInstancesRequest.getInstanceIds().get(0).equals("test-1")) {
        Collection<InstanceStateChange> coll = new ArrayList<InstanceStateChange>();
        InstanceStateChange sc = new InstanceStateChange();
        InstanceState previousState = new InstanceState();
        previousState.setCode(80);
        previousState.setName(InstanceStateName.Running);
        InstanceState newState = new InstanceState();
        newState.setCode(16);
        newState.setName(InstanceStateName.Stopped);
        sc.setPreviousState(previousState);
        sc.setCurrentState(newState);
        sc.setInstanceId("test-1");
        coll.add(sc);
        result.setStoppingInstances(coll);
    } else {
        throw new AmazonServiceException("The image-id doesn't exists");
    }
    return result;        
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:AmazonEC2ClientMock.java


示例3: terminateInstances

import com.amazonaws.services.ec2.model.InstanceStateName; //导入依赖的package包/类
@Override
public TerminateInstancesResult terminateInstances(TerminateInstancesRequest terminateInstancesRequest) {
    TerminateInstancesResult result = new TerminateInstancesResult();
    if (terminateInstancesRequest.getInstanceIds().contains("test-1")) {
        Collection<InstanceStateChange> coll = new ArrayList<InstanceStateChange>();
        InstanceStateChange sc = new InstanceStateChange();
        InstanceState previousState = new InstanceState();
        previousState.setCode(80);
        previousState.setName(InstanceStateName.Running);
        InstanceState newState = new InstanceState();
        newState.setCode(16);
        newState.setName(InstanceStateName.Terminated);
        sc.setPreviousState(previousState);
        sc.setCurrentState(newState);
        sc.setInstanceId("test-1");
        coll.add(sc);
        result.setTerminatingInstances(coll);
    } else {
        throw new AmazonServiceException("The image-id doesn't exists");
    }
    return result;    
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:AmazonEC2ClientMock.java


示例4: createState

import com.amazonaws.services.ec2.model.InstanceStateName; //导入依赖的package包/类
private static InstanceState createState(com.amazonaws.services.ec2.model.InstanceStateName instanceState) {
    switch (instanceState) {
        case Pending:
            return InstanceState.QUEUED;
        default:
        case Running:
            return InstanceState.LAUNCHED;
        case ShuttingDown:
            return InstanceState.SHUTTING_DOWN;
        case Terminated:
            return InstanceState.DELETING;
        case Stopping:
            return InstanceState.SUSPENDING;
        case Stopped:
            return InstanceState.SUSPENDED;
    }
}
 
开发者ID:meridor,项目名称:perspective-backend,代码行数:18,代码来源:ListInstancesOperation.java


示例5: testStartInstance

import com.amazonaws.services.ec2.model.InstanceStateName; //导入依赖的package包/类
@Test
public void testStartInstance() {

	final DescribeInstanceStatusRequest describeInstanceStatusRequest = new DescribeInstanceStatusRequest().withIncludeAllInstances(true).withInstanceIds(INSTANCE_ID);
	final DescribeInstanceStatusResult describeInstanceStatusResult = new DescribeInstanceStatusResult().withInstanceStatuses(new InstanceStatus().withInstanceState(new InstanceState().withName(InstanceStateName.Stopped)));

	final StartInstancesRequest startInstancesRequest = new StartInstancesRequest().withInstanceIds(INSTANCE_ID);
	final StartInstancesResult startInstancesResult = new StartInstancesResult().withStartingInstances(new InstanceStateChange().withCurrentState(new InstanceState().withName(InstanceStateName.Running)));

	Mockito.doReturn(describeInstanceStatusResult).when(amazonEC2Client).describeInstanceStatus(describeInstanceStatusRequest);
	Mockito.doReturn(startInstancesResult).when(amazonEC2Client).startInstances(startInstancesRequest);

	amazonEC2Service.startInstance(INSTANCE_ID);

	final InOrder inOrder = Mockito.inOrder(amazonEC2Client);
	inOrder.verify(amazonEC2Client).describeInstanceStatus(describeInstanceStatusRequest);
	inOrder.verify(amazonEC2Client).startInstances(startInstancesRequest);
}
 
开发者ID:Sylvain-Bugat,项目名称:aws-ec2-start-stop-tools,代码行数:19,代码来源:AmazonEC2ServiceTest.java


示例6: testStopInstanceStopping

import com.amazonaws.services.ec2.model.InstanceStateName; //导入依赖的package包/类
@Test
public void testStopInstanceStopping() {

	final DescribeInstanceStatusRequest describeInstanceStatusRequest = new DescribeInstanceStatusRequest().withIncludeAllInstances(true).withInstanceIds(INSTANCE_ID);
	final DescribeInstanceStatusResult describeInstanceStatusResult = new DescribeInstanceStatusResult().withInstanceStatuses(new InstanceStatus().withInstanceState(new InstanceState().withName(InstanceStateName.Running)));

	final StopInstancesRequest stopInstancesRequest = new StopInstancesRequest().withInstanceIds(INSTANCE_ID);
	final StopInstancesResult stopInstancesResult = new StopInstancesResult().withStoppingInstances(new InstanceStateChange().withCurrentState(new InstanceState().withName(InstanceStateName.Stopping)));

	Mockito.doReturn(describeInstanceStatusResult).when(amazonEC2Client).describeInstanceStatus(describeInstanceStatusRequest);
	Mockito.doReturn(stopInstancesResult).when(amazonEC2Client).stopInstances(stopInstancesRequest);

	amazonEC2Service.stopInstance(INSTANCE_ID);

	final InOrder inOrder = Mockito.inOrder(amazonEC2Client);
	inOrder.verify(amazonEC2Client).describeInstanceStatus(describeInstanceStatusRequest);
	inOrder.verify(amazonEC2Client).stopInstances(stopInstancesRequest);
}
 
开发者ID:Sylvain-Bugat,项目名称:aws-ec2-start-stop-tools,代码行数:19,代码来源:AmazonEC2ServiceTest.java


示例7: testStopInstanceStopped

import com.amazonaws.services.ec2.model.InstanceStateName; //导入依赖的package包/类
@Test
public void testStopInstanceStopped() {

	final DescribeInstanceStatusRequest describeInstanceStatusRequest = new DescribeInstanceStatusRequest().withIncludeAllInstances(true).withInstanceIds(INSTANCE_ID);
	final DescribeInstanceStatusResult describeInstanceStatusResult = new DescribeInstanceStatusResult().withInstanceStatuses(new InstanceStatus().withInstanceState(new InstanceState().withName(InstanceStateName.Running)));

	final StopInstancesRequest stopInstancesRequest = new StopInstancesRequest().withInstanceIds(INSTANCE_ID);
	final StopInstancesResult stopInstancesResult = new StopInstancesResult().withStoppingInstances(new InstanceStateChange().withCurrentState(new InstanceState().withName(InstanceStateName.Stopped)));

	Mockito.doReturn(describeInstanceStatusResult).when(amazonEC2Client).describeInstanceStatus(describeInstanceStatusRequest);
	Mockito.doReturn(stopInstancesResult).when(amazonEC2Client).stopInstances(stopInstancesRequest);

	amazonEC2Service.stopInstance(INSTANCE_ID);

	final InOrder inOrder = Mockito.inOrder(amazonEC2Client);
	inOrder.verify(amazonEC2Client).describeInstanceStatus(describeInstanceStatusRequest);
	inOrder.verify(amazonEC2Client).stopInstances(stopInstancesRequest);
}
 
开发者ID:Sylvain-Bugat,项目名称:aws-ec2-start-stop-tools,代码行数:19,代码来源:AmazonEC2ServiceTest.java


示例8: terminateInstances

import com.amazonaws.services.ec2.model.InstanceStateName; //导入依赖的package包/类
@Override
public TerminateInstancesResult terminateInstances(List<String> instanceIds)
        throws NotFoundException, AmazonClientException {
    TerminateInstancesResult result = new TerminateInstancesResult();
    for (String instanceId : instanceIds) {
        if (!this.instances.containsKey(instanceId)) {
            throw new AmazonServiceException(String.format(
                    "The instance ID '%s' does not exist " + "(Service: AmazonEC2; Status Code: 400; Error Code: "
                            + "InvalidInstanceID.NotFound;" + " Request ID: 12a2ebaf-c480-4998-95fb-6d47b4393e00)",
                    instanceId));
        }
        this.instances.remove(instanceId);

        result.withTerminatingInstances(new InstanceStateChange().withInstanceId(instanceId)
                .withCurrentState(new InstanceState().withName(InstanceStateName.ShuttingDown)));

    }
    return result;
}
 
开发者ID:elastisys,项目名称:scale.cloudpool,代码行数:20,代码来源:FakeSpotClient.java


示例9: testConversionOfCancelledRequestWithRunningInstance

import com.amazonaws.services.ec2.model.InstanceStateName; //导入依赖的package包/类
/**
 * Conversion of request that has been cancelled but with an instance that
 * is still running.
 */
@Test
public void testConversionOfCancelledRequestWithRunningInstance() {
    InstancePairedSpotRequest cancelledRequest = new InstancePairedSpotRequest(
            SpotTestUtil.spotRequest("sir-1", "cancelled", "i-1"),
            SpotTestUtil.instance("i-1", InstanceStateName.Running, "sir-1"));

    Machine machine = InstancePairedSpotRequestToMachine.convert(cancelledRequest);
    assertThat(machine.getId(), is("sir-1"));
    assertThat(machine.getMachineState(), is(MachineState.TERMINATED));
    assertThat(machine.getCloudProvider(), is(CloudProviders.AWS_SPOT));
    assertThat(machine.getRegion(), is("us-east-1"));
    assertThat(machine.getMachineSize(), is("m1.medium"));
    assertThat(machine.getMembershipStatus(), is(MembershipStatus.defaultStatus()));
    assertThat(machine.getLaunchTime(), is(FrozenTime.now()));
    assertThat(machine.getServiceState(), is(ServiceState.UNKNOWN));
    assertThat(machine.getPublicIps(), is(list()));
    assertThat(machine.getPrivateIps(), is(list()));
    assertThat(machine.getMetadata(), is(JsonUtils.toJson(cancelledRequest)));
}
 
开发者ID:elastisys,项目名称:scale.cloudpool,代码行数:24,代码来源:TestInstancePairedSpotRequestToMachine.java


示例10: convertCompleteInstance

import com.amazonaws.services.ec2.model.InstanceStateName; //导入依赖的package包/类
@Test
public void convertCompleteInstance() {
    DateTime launchTime = UtcTime.now();
    Instance instance = new Instance().withInstanceId("i-1")
            .withState(new InstanceState().withName(InstanceStateName.Running)).withPublicIpAddress("1.2.3.4")
            .withPrivateIpAddress("1.2.3.5").withInstanceType(InstanceType.M1Small)
            .withLaunchTime(launchTime.toDate())
            .withMonitoring(new Monitoring().withState(MonitoringState.Disabled)).withHypervisor(HypervisorType.Xen)
            .withPlacement(new Placement("us-east-1c"));

    Machine machine = convert(instance);
    assertThat(machine.getId(), is(instance.getInstanceId()));
    assertThat(machine.getLaunchTime(), is(launchTime));
    assertThat(machine.getMachineState(), is(MachineState.RUNNING));
    assertThat(machine.getCloudProvider(), is(CloudProviders.AWS_EC2));
    assertThat(machine.getRegion(), is("us-east-1"));
    assertThat(machine.getMachineSize(), is("m1.small"));
    assertThat(machine.getMembershipStatus(), is(MembershipStatus.defaultStatus()));
    assertThat(machine.getServiceState(), is(ServiceState.UNKNOWN));
    assertThat(machine.getPublicIps().size(), is(1));
    assertThat(machine.getPublicIps().get(0), is(instance.getPublicIpAddress()));
    assertThat(machine.getPrivateIps().size(), is(1));
    assertThat(machine.getPrivateIps().get(0), is(instance.getPrivateIpAddress()));
    assertThat(machine.getMetadata(), is(JsonUtils.toJson(instance)));
}
 
开发者ID:elastisys,项目名称:scale.cloudpool,代码行数:26,代码来源:TestInstanceToMachine.java


示例11: convertInstanceMissingPublicIp

import com.amazonaws.services.ec2.model.InstanceStateName; //导入依赖的package包/类
@Test
public void convertInstanceMissingPublicIp() {
    DateTime launchTime = UtcTime.now();

    Instance instance = new Instance().withInstanceId("i-1")
            .withState(new InstanceState().withName(InstanceStateName.Running)).withPrivateIpAddress("1.2.3.5")
            .withInstanceType(InstanceType.M1Small).withLaunchTime(launchTime.toDate())
            .withMonitoring(new Monitoring().withState(MonitoringState.Disabled)).withHypervisor(HypervisorType.Xen)
            .withPlacement(new Placement("us-east-1a"));

    Machine machine = convert(instance);
    assertThat(machine.getId(), is(instance.getInstanceId()));
    assertThat(machine.getCloudProvider(), is(CloudProviders.AWS_EC2));
    assertThat(machine.getRegion(), is("us-east-1"));
    assertThat(machine.getMachineSize(), is("m1.small"));
    assertThat(machine.getLaunchTime(), is(launchTime));
    assertThat(machine.getMachineState(), is(MachineState.RUNNING));
    assertThat(machine.getMembershipStatus(), is(MembershipStatus.defaultStatus()));
    assertThat(machine.getServiceState(), is(ServiceState.UNKNOWN));
    assertThat(machine.getPublicIps().size(), is(0));
    assertThat(machine.getPrivateIps().size(), is(1));
    assertThat(machine.getPrivateIps().get(0), is(instance.getPrivateIpAddress()));
    assertThat(machine.getMetadata(), is(JsonUtils.toJson(instance)));
}
 
开发者ID:elastisys,项目名称:scale.cloudpool,代码行数:25,代码来源:TestInstanceToMachine.java


示例12: convertInstanceMissingPrivateIp

import com.amazonaws.services.ec2.model.InstanceStateName; //导入依赖的package包/类
@Test
public void convertInstanceMissingPrivateIp() {
    DateTime launchTime = UtcTime.now();
    Instance instance = new Instance().withInstanceId("i-1")
            .withState(new InstanceState().withName(InstanceStateName.Running)).withPublicIpAddress("1.2.3.4")
            .withInstanceType(InstanceType.M1Medium).withLaunchTime(launchTime.toDate())
            .withMonitoring(new Monitoring().withState(MonitoringState.Disabled)).withHypervisor(HypervisorType.Xen)
            .withPlacement(new Placement("us-east-1b"));

    Machine machine = convert(instance);
    assertThat(machine.getId(), is(instance.getInstanceId()));
    assertThat(machine.getCloudProvider(), is(CloudProviders.AWS_EC2));
    assertThat(machine.getRegion(), is("us-east-1"));
    assertThat(machine.getMachineSize(), is("m1.medium"));
    assertThat(machine.getLaunchTime(), is(launchTime));
    assertThat(machine.getMachineState(), is(MachineState.RUNNING));
    assertThat(machine.getMembershipStatus(), is(MembershipStatus.defaultStatus()));
    assertThat(machine.getServiceState(), is(ServiceState.UNKNOWN));
    assertThat(machine.getPublicIps().size(), is(1));
    assertThat(machine.getPublicIps().get(0), is(instance.getPublicIpAddress()));
    assertThat(machine.getPrivateIps().size(), is(0));
    assertThat(machine.getMetadata(), is(JsonUtils.toJson(instance)));
}
 
开发者ID:elastisys,项目名称:scale.cloudpool,代码行数:24,代码来源:TestInstanceToMachine.java


示例13: convertSpotInstance

import com.amazonaws.services.ec2.model.InstanceStateName; //导入依赖的package包/类
/**
 * A converted spot instance {@link Machine} should have a cloud provider
 * value of {@link CloudProviders#AWS_SPOT} to distinguish it from a regular
 * EC2 on-demand instance.
 */
@Test
public void convertSpotInstance() {
    // convert on-demand instance: cloud provider should be AWS_EC2
    Instance onDemandInstance = new Instance().withInstanceId("i-1").withInstanceType(InstanceType.M1Medium)
            .withState(new InstanceState().withName(InstanceStateName.Running))
            .withPlacement(new Placement("us-east-1b"));
    Machine onDemandMachine = convert(onDemandInstance);
    assertThat(onDemandMachine.getCloudProvider(), is(CloudProviders.AWS_EC2));

    // convert spot instance: cloud provider should be AWS_EC2
    Instance spotInstance = new Instance().withInstanceId("i-1").withInstanceType(InstanceType.M1Medium)
            .withState(new InstanceState().withName(InstanceStateName.Running)).withSpotInstanceRequestId("sir-123")
            .withPlacement(new Placement("us-east-1b"));
    Machine spotMachine = convert(spotInstance);
    assertThat(spotMachine.getCloudProvider(), is(CloudProviders.AWS_SPOT));
}
 
开发者ID:elastisys,项目名称:scale.cloudpool,代码行数:22,代码来源:TestInstanceToMachine.java


示例14: convert

import com.amazonaws.services.ec2.model.InstanceStateName; //导入依赖的package包/类
/**
 * Converts the ec2 instance to a turbine instance.
 * @param ec2 EC2 instance.
 * @return Turbine instance.
 */
public com.netflix.turbine.discovery.Instance convert(final Instance ec2) {
    final boolean state = InstanceStateName.fromValue(
        ec2.getState().getName()
    ) == InstanceStateName.Running;
    return new com.netflix.turbine.discovery.Instance(
        ec2.getPrivateIpAddress(), this.cluster, state
    );
}
 
开发者ID:ContaAzul,项目名称:turbine-ec2,代码行数:14,代码来源:EC2ToTurbineInstance.java


示例15: convertsRunningInstances

import com.amazonaws.services.ec2.model.InstanceStateName; //导入依赖的package包/类
/**
 * {@link EC2ToTurbineInstance} can convert a running ec2 instance into
 * a turbine instance.
 */
@Test
public void convertsRunningInstances() {
    final String ip = "172.13.131.215";
    final String cluster = "blah";
    final Instance ec2 = new Instance()
        .withPrivateIpAddress(ip)
        .withState(new InstanceState().withName(InstanceStateName.Running));
    Assertions.assertThat(new EC2ToTurbineInstance(cluster).convert(ec2))
        .isNotNull()
        .matches(instance -> instance.getHostname().equals(ip))
        .matches(com.netflix.turbine.discovery.Instance::isUp);
}
 
开发者ID:ContaAzul,项目名称:turbine-ec2,代码行数:17,代码来源:EC2ToTurbineInstanceTest.java


示例16: convertsRunningInstancesWithInvalidName

import com.amazonaws.services.ec2.model.InstanceStateName; //导入依赖的package包/类
/**
 * {@link EC2ToTurbineInstance} can convert a running ec2 instance into
 * a turbine instance with an invalid name as address.
 */
@Test
public void convertsRunningInstancesWithInvalidName() {
    final String ip = "172.13.131.215";
    final String name = "asdasdasdasdasda";
    final String cluster = "blah";
    final Instance ec2 = new Instance()
            .withPrivateIpAddress(ip)
            .withTags(new Tag("Name", name))
            .withState(new InstanceState().withName(InstanceStateName.Running));
    Assertions.assertThat(new EC2ToTurbineInstance(cluster).convert(ec2))
            .isNotNull()
            .matches(instance -> instance.getHostname().equals(ip))
            .matches(com.netflix.turbine.discovery.Instance::isUp);
}
 
开发者ID:ContaAzul,项目名称:turbine-ec2,代码行数:19,代码来源:EC2ToTurbineInstanceTest.java


示例17: convertsNonRunningInstances

import com.amazonaws.services.ec2.model.InstanceStateName; //导入依赖的package包/类
/**
 * {@link EC2ToTurbineInstance} can convert a non running ec2 instance into
 * a turbine instance.
 */
@Test
public void convertsNonRunningInstances() {
    final String ip = "177.12.43.123";
    final String cluster = "blah";
    final Instance ec2 = new Instance()
        .withPrivateIpAddress(ip)
        .withState(new InstanceState().withName(InstanceStateName.Pending));
    Assertions.assertThat(new EC2ToTurbineInstance(cluster).convert(ec2))
        .isNotNull()
        .matches(instance -> instance.getHostname().equals(ip))
        .matches(instance -> !instance.isUp());
}
 
开发者ID:ContaAzul,项目名称:turbine-ec2,代码行数:17,代码来源:EC2ToTurbineInstanceTest.java


示例18: waitUntilInstanceHasStarted

import com.amazonaws.services.ec2.model.InstanceStateName; //导入依赖的package包/类
/**
 * Waits until the instance has entered a running state.
 *
 * @param ec2InstanceId the EC2 instance id
 * @return true if the instance has entered a running state, false if the instance is shutting down/terminated or
 * the function has timed out waiting for the instance to enter one of these two states.
 */
private boolean waitUntilInstanceHasStarted(String ec2InstanceId) throws InterruptedException {
  // TODO: Add a timeout to this loop.
  while (true) {
    try {
      DescribeInstanceStatusResult result = client.describeInstanceStatus(
          new DescribeInstanceStatusRequest()
              .withIncludeAllInstances(true)
              .withInstanceIds(ec2InstanceId)
      );
      for (InstanceStatus status : result.getInstanceStatuses()) {
        InstanceStateName currentState =
            InstanceStateName.fromValue(status.getInstanceState().getName());

        if (ec2InstanceId.equals(status.getInstanceId())) {
          if (currentState.equals(InstanceStateName.Terminated) ||
              currentState.equals(InstanceStateName.ShuttingDown)) {
            LOG.error("Instance {} has unexpectedly terminated", ec2InstanceId);
            return false;
          } else if (!currentState.equals(InstanceStateName.Pending)) {
            return true;
          }
        }
      }
    } catch (AmazonServiceException e) {
      if (!INVALID_INSTANCE_ID_NOT_FOUND.equals(e.getErrorCode())) {
        AWSExceptions.propagate(e);
      }
    }
    TimeUnit.SECONDS.sleep(5);
  }
}
 
开发者ID:cloudera,项目名称:director-aws-plugin,代码行数:39,代码来源:EC2Provider.java


示例19: createInstance

import com.amazonaws.services.ec2.model.InstanceStateName; //导入依赖的package包/类
private Instance createInstance(Cloud cloud, String region, com.amazonaws.services.ec2.model.Instance rawInstance) {
        Instance instance = new Instance();
        String realId = String.valueOf(rawInstance.getInstanceId());
        String instanceId = idGenerator.getInstanceId(cloud, realId);
        instance.setId(instanceId);
        instance.setRealId(realId);
        instance.setName(rawInstance.getInstanceId()); //TODO: check this!
        instance.setFqdn(rawInstance.getPublicDnsName());
        instance.setCloudId(cloud.getId());
        instance.setCloudType(CloudType.AWS);

        ZonedDateTime created = ZonedDateTime.ofInstant(
                rawInstance.getLaunchTime().toInstant(),
                ZoneId.systemDefault()
        );
        instance.setCreated(created);
        InstanceStateName instanceStateName = InstanceStateName.fromValue(rawInstance.getState().getName());
        instance.setState(createState(instanceStateName));
        instance.setTimestamp(created);

        instance.setIsLocked(false);

        MetadataMap metadata = new MetadataMap();
        metadata.put(MetadataKey.REGION, region);

        //TODO: console output for AWS is a screenshot!
//        metadata.put(MetadataKey.CONSOLE_URL, getConsoleUrl(instance.getId()));
        instance.setMetadata(metadata);

        return instance;
    }
 
开发者ID:meridor,项目名称:perspective-backend,代码行数:32,代码来源:ListInstancesOperation.java


示例20: countCurrentEC2Slaves

import com.amazonaws.services.ec2.model.InstanceStateName; //导入依赖的package包/类
/**
 * Counts the number of instances in EC2 currently running that are using
 * the specifed image.
 *
 * @param ami If AMI is left null, then all instances are counted.
 * <p>
 * This includes those instances that may be started outside Hudson.
 */
public int countCurrentEC2Slaves(String ami) throws AmazonClientException {
    int n = 0;
    for (Reservation r : connect().describeInstances().getReservations()) {
        for (Instance i : r.getInstances()) {
            if (isEc2ProvisionedSlave(i, ami)) {
                InstanceStateName stateName = InstanceStateName.fromValue(i.getState().getName());
                if (stateName == InstanceStateName.Pending || stateName == InstanceStateName.Running) {
                    n++;
                }
            }
        }
    }
    return n;
}
 
开发者ID:hudson3-plugins,项目名称:ec2-plugin,代码行数:23,代码来源:EC2Cloud.java



注:本文中的com.amazonaws.services.ec2.model.InstanceStateName类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Layout类代码示例发布时间:2022-05-21
下一篇:
Java CommonTreeAdaptor类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap