當前位置: 首頁>>代碼示例>>Java>>正文


Java GoogleComputeEngineApi類代碼示例

本文整理匯總了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;
}
 
開發者ID:karamelchef,項目名稱:karamel,代碼行數:16,代碼來源:GceContext.java

示例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);
  }
}
 
開發者ID:karamelchef,項目名稱:karamel,代碼行數:19,代碼來源:GceLauncher.java

示例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;
}
 
開發者ID:apache,項目名稱:stratos,代碼行數:8,代碼來源:GCEIaas.java

示例4: getGceApi

import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; //導入依賴的package包/類
public GoogleComputeEngineApi getGceApi() {
  return gceApi;
}
 
開發者ID:karamelchef,項目名稱:karamel,代碼行數:4,代碼來源:GceContext.java

示例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);
}
 
開發者ID:jclouds,項目名稱:jclouds-examples,代碼行數:6,代碼來源:MainApp.java

示例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);
}
 
開發者ID:jclouds,項目名稱:jclouds-examples,代碼行數:7,代碼來源:MainApp.java


注:本文中的org.jclouds.googlecomputeengine.GoogleComputeEngineApi類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。