本文整理汇总了Java中org.jclouds.googlecomputeengine.GoogleComputeEngineApi类的典型用法代码示例。如果您正苦于以下问题:Java GoogleComputeEngineApi类的具体用法?Java GoogleComputeEngineApi怎么用?Java GoogleComputeEngineApi使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GoogleComputeEngineApi类属于org.jclouds.googlecomputeengine包,在下文中一共展示了GoogleComputeEngineApi类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: GceContext
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; //导入依赖的package包/类
public GceContext(Credentials credentials) {
ComputeServiceContext context = ContextBuilder.newBuilder("google-compute-engine")
.modules(Arrays.asList(
new SshjSshClientModule(),
new EnterpriseConfigurationModule(),
new SLF4JLoggingModule()))
.credentials(credentials.identity, credentials.credential)
.buildView(ComputeServiceContext.class);
computeService = context.getComputeService();
gceApi = context.unwrapApi(GoogleComputeEngineApi.class);
fireWallApi = gceApi.firewalls();
networkApi = gceApi.networks();
routeApi = gceApi.routes();
this.credentials = credentials;
}
示例2: validateCredentials
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; //导入依赖的package包/类
/**
*
* @param credentials
* @return
* @throws InvalidCredentialsException
*/
public static GceContext validateCredentials(Credentials credentials) throws InvalidCredentialsException {
try {
GceContext context = new GceContext(credentials);
GoogleComputeEngineApi gceApi = context.getGceApi();
String projectName = gceApi.project().get().name();
context.setProjectName(projectName);
logger.info(String.format("Sucessfully Authenticated to project %s", projectName));
return context;
} catch (AuthorizationException e) {
throw new InvalidCredentialsException("accountid:" + credentials.identity, e);
}
}
示例3: getGCEApi
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; //导入依赖的package包/类
private GoogleComputeEngineApi getGCEApi() {
IaasProvider iaasInfo = getIaasProvider();
ComputeServiceContext context = iaasInfo.getComputeService().getContext();
GoogleComputeEngineApi api = context.unwrapApi(GoogleComputeEngineApi.class);
return api;
}
示例4: getGceApi
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; //导入依赖的package包/类
public GoogleComputeEngineApi getGceApi() {
return gceApi;
}
示例5: DeleteStartupScript
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; //导入依赖的package包/类
public static void DeleteStartupScript(GoogleComputeEngineApi googleApi){
Metadata metadata = googleApi.project().get().commonInstanceMetadata();
metadata.remove("startup-script");
googleApi.project().setCommonInstanceMetadata(metadata);
}
示例6: createGoogleComputeEngineApi
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; //导入依赖的package包/类
private static GoogleComputeEngineApi createGoogleComputeEngineApi(String identity, String credential){
ContextBuilder contextBuilder = ContextBuilder.newBuilder(GoogleComputeEngineProviderMetadata.builder().build())
.credentials(identity, credential);
Injector injector = contextBuilder.buildInjector();
return injector.getInstance(GoogleComputeEngineApi.class);
}