[英]How access native provider API with Jclouds 1.7
Using JClouds, up to version 1.6.x it was possible to access to the native EC2 provider API by using the following idiom: 使用JClouds(最高版本1.6.x),可以使用以下惯用法访问本机EC2提供程序API:
AWSEC2Client ec2Client = AWSEC2Client.class.cast(context.getProviderSpecificContext().getApi());
Actually, I copied from the documentation page: http://jclouds.apache.org/guides/aws/ 实际上,我是从文档页面复制的: http : //jclouds.apache.org/guides/aws/
It turns out that in the latest release this method has been removed. 事实证明,在最新版本中,此方法已被删除。 Is there an alternative method/way to access to the provider specific features (security groups, key-pairs, etc)? 是否存在访问提供商特定功能(安全组,密钥对等)的替代方法/方式?
Unwrapping the API from the ComputeServiceContext 从ComputeServiceContext解开API
ComputeServiceContext context = ContextBuilder.newBuilder("aws-ec2")
.credentials("accessKey", "secretAccessKey")
.buildView(ComputeServiceContext.class);
ComputeService computeService = context.getComputeService();
AWSEC2Api ec2Api = context.unwrapApi(AWSEC2Api.class);
Building the API directly 直接构建API
AWSEC2Api ec2Api = ContextBuilder.newBuilder("aws-ec2")
.credentials("accessKey", "secretAccessKey")
.buildApi(AWSEC2Api.class);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.