本文整理汇总了Java中com.amazonaws.services.ec2.model.InstanceState.setCode方法的典型用法代码示例。如果您正苦于以下问题:Java InstanceState.setCode方法的具体用法?Java InstanceState.setCode怎么用?Java InstanceState.setCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.ec2.model.InstanceState
的用法示例。
在下文中一共展示了InstanceState.setCode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startInstances
import com.amazonaws.services.ec2.model.InstanceState; //导入方法依赖的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;
}
示例2: stopInstances
import com.amazonaws.services.ec2.model.InstanceState; //导入方法依赖的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;
}
示例3: terminateInstances
import com.amazonaws.services.ec2.model.InstanceState; //导入方法依赖的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;
}
示例4: convertObject
import com.amazonaws.services.ec2.model.InstanceState; //导入方法依赖的package包/类
@Override
protected InstanceStateChange convertObject(TerminatingInstanceDescription from) {
InstanceStateChange to = new InstanceStateChange();
to.setInstanceId(from.getInstanceId());
InstanceState previousState = new InstanceState();
previousState.setCode(from.getPreviousStateCode());
previousState.setName(from.getPreviousState());
to.setPreviousState(previousState);
InstanceState currentState = new InstanceState();
currentState.setCode(from.getShutdownStateCode());
currentState.setName(from.getShutdownState());
to.setCurrentState(currentState);
return to;
}
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:19,代码来源:InstanceStateChangeTerminateConverter.java
示例5: returnInstanceStatus
import com.amazonaws.services.ec2.model.InstanceState; //导入方法依赖的package包/类
private List<InstanceStatus> returnInstanceStatus(int start, int end) {
List<InstanceStatus> instanceStatuses = new ArrayList<>();
for (int i = start; i < end; i++) {
InstanceStatus instanceStatus = new InstanceStatus();
InstanceState instanceState = new InstanceState();
instanceState.setCode(16);
instanceStatus.setInstanceState(instanceState);
instanceStatus.setInstanceId(Integer.toString(i));
instanceStatuses.add(instanceStatus);
}
return instanceStatuses;
}
示例6: convertObject
import com.amazonaws.services.ec2.model.InstanceState; //导入方法依赖的package包/类
@Override
protected Instance convertObject(com.xerox.amazonws.ec2.ReservationDescription.Instance from) {
Instance to = new Instance();
to.setInstanceId(from.getInstanceId());
to.setImageId(from.getImageId());
InstanceState state = new InstanceState();
state.setCode(from.getStateCode());
state.setName(from.getState());
to.setState(state);
to.setPrivateDnsName(from.getPrivateDnsName());
to.setPublicDnsName(from.getDnsName());
to.setStateTransitionReason(from.getReason());
to.setKeyName(from.getKeyName());
to.setAmiLaunchIndex(null);
to.setProductCodes(null);
to.setInstanceType(from.getInstanceType().name());
to.setLaunchTime(from.getLaunchTime().getTime());
Placement placement = new Placement();
placement.setAvailabilityZone(from.getAvailabilityZone());
placement.setGroupName(null); // 未実装
to.setPlacement(placement);
to.setKernelId(from.getKernelId());
to.setRamdiskId(from.getRamdiskId());
to.setPlatform(from.getPlatform());
Monitoring monitoring = new Monitoring();
monitoring.setState(Boolean.toString(from.isMonitoring()));
to.setMonitoring(monitoring);
// 未実装
to.setSubnetId(null);
to.setVpcId(null);
to.setPrivateIpAddress(null);
to.setPublicIpAddress(null);
to.setStateReason(null);
//to.setArchitecture(null);
to.setRootDeviceName(null);
to.setRootDeviceName(null);
to.setBlockDeviceMappings(null);
//to.setVirtualizationType(null);
//to.setInstanceLifecycle(null);
to.setSpotInstanceRequestId(null);
//to.setLicense(null);
to.setClientToken(null);
to.setTags(null);
return to;
}