use of com.vmware.photon.controller.model.adapters.awsadapter.AWSConstants.URI_PARAM_ENDPOINT in project photon-model by vmware.
the class AWSInstanceContext method getInstanceTypeInfo.
private DeferredResult<AWSInstanceContext> getInstanceTypeInfo(AWSInstanceContext context) {
String instanceType = context.child.description.instanceType;
if (instanceType == null) {
instanceType = context.child.description.name;
}
if (instanceType == null) {
String msg = String.format("AWS Instance type not specified for [%s] VM.", context.child.name);
return DeferredResult.failed(new IllegalStateException(msg));
}
URI instanceTypeServiceURI = UriUtils.buildUri(context.service.getHost(), AWSInstanceTypeService.SELF_LINK);
instanceTypeServiceURI = UriUtils.appendQueryParam(instanceTypeServiceURI, URI_PARAM_ENDPOINT, context.child.endpointLink);
instanceTypeServiceURI = UriUtils.appendQueryParam(instanceTypeServiceURI, URI_PARAM_INSTANCE_TYPE, instanceType);
Operation op = Operation.createGet(instanceTypeServiceURI).setReferer(context.service.getHost().getUri());
DeferredResult<InstanceType> dr = context.service.sendWithDeferredResult(op, InstanceType.class);
return dr.thenAccept(type -> {
context.instanceTypeInfo = type;
}).handle((all, err) -> {
if (err != null) {
String msg = String.format("Error getting instance-type info for [%s] VM. Reason [%s]", context.child.name, err.getMessage());
throw new IllegalStateException(msg, err);
}
return context;
});
}
Aggregations