org.jclouds.Context.getId()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(10.6k)|赞(0)|评价(0)|浏览(106)

本文整理了Java中org.jclouds.Context.getId()方法的一些代码示例,展示了Context.getId()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.getId()方法的具体详情如下:
包路径:org.jclouds.Context
类名称:Context
方法名:getId

Context.getId介绍

暂无

代码示例

代码示例来源:origin: apache/jclouds

public static Module linkContext(Context context) {
 return linkContext(context.getId(), Suppliers.ofInstance(context));
}

代码示例来源:origin: com.amysta.jclouds/jclouds-core

public static Module linkContext(Context context) {
 return linkContext(context.getId(), Suppliers.ofInstance(context));
}

代码示例来源:origin: Nextdoor/bender

public static Module linkContext(Context context) {
 return linkContext(context.getId(), Suppliers.ofInstance(context));
}

代码示例来源:origin: org.apache.jclouds.karaf/commands

@Override
public void updateOnRemoved(BlobStore blobStore) {
 cache.removeAll(blobStore.getContext().unwrap().getId());
}

代码示例来源:origin: apache/jclouds

public static Module linkView(View view) {
 return linkView(view.unwrap().getId(), Suppliers.ofInstance(view));
}

代码示例来源:origin: com.amysta.jclouds/jclouds-core

public static Module linkView(View view) {
 return linkView(view.unwrap().getId(), Suppliers.ofInstance(view));
}

代码示例来源:origin: Nextdoor/bender

public static Module linkView(View view) {
 return linkView(view.unwrap().getId(), Suppliers.ofInstance(view));
}

代码示例来源:origin: org.apache.jclouds.karaf/commands

@Override
  public void updateOnRemoved(BlobStore blobStore) {
   for (String cacheKey : ServiceHelper.findCacheKeysForService(blobStore)) {
    cache.removeAll(blobStore.getContext().unwrap().getId());
   }
  }
}

代码示例来源:origin: org.apache.jclouds.karaf/commands

protected void printComputeApis(Iterable<ApiMetadata> apis, List<ComputeService> computeServices, String indent,
    PrintStream out) {
 out.println(String.format(PROVIDERFORMAT, "[id]", "[type]", "[service]"));
 for (ApiMetadata api : apis) {
  StringBuilder sb = new StringBuilder();
  sb.append("[ ");
   for (ComputeService computeService : computeServices) {
    String contextName = (String) computeService.getContext().unwrap().getName();
    if (computeService.getContext().unwrap().getId().equals(api.getId()) && contextName != null) {
     sb.append(contextName).append(" ");
    }
   }
  sb.append("]");
   out.println(String.format(PROVIDERFORMAT, api.getId(), "compute", sb.toString()));
 }
}

代码示例来源:origin: org.apache.jclouds.karaf/commands

protected void printBlobStoreApis(Iterable<ApiMetadata> apis, List<BlobStore> blobStores, String indent,
    PrintStream out) {
 out.println(String.format(PROVIDERFORMAT, "[id]", "[type]", "[service]"));
 for (ApiMetadata api : apis) {
   StringBuilder sb = new StringBuilder();
   sb.append("[ ");
   for (BlobStore blobStore : blobStores) {
    String contextName = (String) blobStore.getContext().unwrap().getName();
    if (blobStore.getContext().unwrap().getId().equals(api.getId())) {
     sb.append(contextName).append(" ");
    }
   }
   sb.append("]");
   out.println(String.format(PROVIDERFORMAT, api.getId(), "blobstore", sb.toString()));
 }
}

代码示例来源:origin: org.apache.jclouds.karaf/commands

protected void printComputeProviders(Iterable<ProviderMetadata> providers, List<ComputeService> computeServices,
    String indent, PrintStream out) {
 out.println(String.format(PROVIDERFORMAT, "[id]", "[type]", "[service]"));
 for (ProviderMetadata provider : providers) {
   StringBuilder sb = new StringBuilder();
   sb.append("[ ");
   for (ComputeService computeService : computeServices) {
    String contextName = (String) computeService.getContext().unwrap().getName();
    if (computeService.getContext().unwrap().getId().equals(provider.getId()) && contextName != null) {
      sb.append(contextName).append(" ");
    }
   }
   sb.append("]");
   out.println(String.format(PROVIDERFORMAT, provider.getId(), "compute", sb.toString()));
 }
}

代码示例来源:origin: org.apache.jclouds.karaf/commands

protected void printBlobStoreProviders(Iterable<ProviderMetadata> providers, List<BlobStore> blobStores,
    String indent, PrintStream out) {
 out.println(String.format(PROVIDERFORMAT, "[id]", "[type]", "[service]"));
 for (ProviderMetadata provider : providers) {
  StringBuilder sb = new StringBuilder();
  sb.append("[ ");
   for (BlobStore blobStore : blobStores) {
    String contextName = (String) blobStore.getContext().unwrap().getName();
    if (blobStore.getContext().unwrap().getId().equals(provider.getId())) {
      sb.append(contextName).append(" ");
    }
   }
   sb.append("]");
   out.println(String.format(PROVIDERFORMAT, provider.getId(), "blobstore", sb.toString()));
 }
}

代码示例来源:origin: io.fabric8/fabric-core-agent-jclouds

@Override
public int complete(String buffer, int cursor, List<String> candidates) {
 delegate.getStrings().clear();
 if (computeServices != null && !computeServices.isEmpty()) {
  for(ComputeService computeService:computeServices) {
   delegate.getStrings().add(computeService.getContext().unwrap().getId());
  }
 }
 return delegate.complete(buffer, cursor, candidates);
}

代码示例来源:origin: org.apache.jclouds.karaf/commands

@Override
  protected Object doExecute() throws Exception {
   BlobStore blobStore = getBlobStore();

   for (String container : containerNames) {
     blobStore.deleteContainer(container);
     cacheProvider.getProviderCacheForType("container").remove(blobStore.getContext().unwrap().getId(),
         container);
   }
   return null;
  }
}

代码示例来源:origin: org.apache.jclouds.karaf/commands

@Override
  protected Object doExecute() throws Exception {
   BlobStore blobStore = getBlobStore();
   for (String blobName : blobNames) {
     blobStore.removeBlob(container, blobName);
     cacheProvider.getProviderCacheForType("blob").remove(blobStore.getContext().unwrap().getId(),
         blobName);
   }
   return null;
  }
}

代码示例来源:origin: org.apache.jclouds.karaf/commands

@Override
public int complete(String buffer, int cursor, List<String> candidates) {
 try {
  if (displayProvidersWithoutService) {
   for (ProviderMetadata providerMetadata : Providers.viewableAs(TypeToken.of(ComputeServiceContext.class))) {
    delegate.getStrings().add(providerMetadata.getId());
   }
  } else if (computeServices != null) {
    for (ComputeService computeService : computeServices) {
      String id = computeService.getContext().unwrap().getId();
      if (Providers.withId(id) != null) {
       delegate.getStrings().add(computeService.getContext().unwrap().getId());
      }
    }
   }
 } catch (Exception ex) {
   // noop
 }
 return delegate.complete(buffer, cursor, candidates);
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-locations-jclouds

@Test
public void testAddPermissionsToNode() {
  IpPermission ssh = newPermission(22);
  IpPermission jmx = newPermission(31001);
  SecurityGroup sharedGroup = newGroup(customizer.getNameForSharedSecurityGroup());
  SecurityGroup group = newGroup("id");
  when(securityApi.listSecurityGroupsForNode(NODE_ID)).thenReturn(ImmutableSet.of(sharedGroup, group));
  SecurityGroup updatedSecurityGroup = newGroup("id", ImmutableSet.of(ssh, jmx));
  when(securityApi.addIpPermission(ssh, group)).thenReturn(updatedSecurityGroup);
  when(securityApi.addIpPermission(jmx, group)).thenReturn(updatedSecurityGroup);
  when(computeService.getContext().unwrap().getId()).thenReturn("aws-ec2");
  customizer.addPermissionsToLocation(jcloudsMachineLocation, ImmutableList.of(ssh, jmx));
  verify(securityApi, never()).createSecurityGroup(anyString(), any(Location.class));
  verify(securityApi, times(1)).addIpPermission(ssh, group);
  verify(securityApi, times(1)).addIpPermission(jmx, group);
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-locations-jclouds

@Test
public void testRemovePermissionsFromNode() {
  IpPermission ssh = newPermission(22);
  IpPermission jmx = newPermission(31001);
  SecurityGroup sharedGroup = newGroup(customizer.getNameForSharedSecurityGroup());
  SecurityGroup group = newGroup("id");
  when(securityApi.listSecurityGroupsForNode(NODE_ID)).thenReturn(ImmutableSet.of(sharedGroup, group));
  SecurityGroup updatedSecurityGroup = newGroup("id", ImmutableSet.of(ssh, jmx));
  when(securityApi.addIpPermission(ssh, group)).thenReturn(updatedSecurityGroup);
  when(securityApi.addIpPermission(jmx, group)).thenReturn(updatedSecurityGroup);
  when(computeService.getContext().unwrap().getId()).thenReturn("aws-ec2");
  customizer.addPermissionsToLocation(jcloudsMachineLocation, ImmutableList.of(ssh, jmx));
  customizer.removePermissionsFromLocation(jcloudsMachineLocation, ImmutableList.of(jmx));
  verify(securityApi, never()).removeIpPermission(ssh, group);
  verify(securityApi, times(1)).removeIpPermission(jmx, group);
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-locations-jclouds

@Test
public void testSecurityGroupsLoadedWhenAddingPermissionsToUncachedNode() {
  IpPermission ssh = newPermission(22);
  SecurityGroup sharedGroup = newGroup(customizer.getNameForSharedSecurityGroup());
  SecurityGroup uniqueGroup = newGroup("unique");
  when(securityApi.listSecurityGroupsForNode(NODE_ID)).thenReturn(ImmutableSet.of(sharedGroup, uniqueGroup));
  when(computeService.getContext().unwrap().getId()).thenReturn("aws-ec2");
  SecurityGroup updatedSecurityGroup = newGroup(uniqueGroup.getId(), ImmutableSet.of(ssh));
  when(securityApi.addIpPermission(ssh, sharedGroup)).thenReturn(updatedSecurityGroup);
  SecurityGroup updatedUniqueSecurityGroup = newGroup(uniqueGroup.getId(), ImmutableSet.of(ssh));
  when(securityApi.addIpPermission(ssh, updatedUniqueSecurityGroup)).thenReturn(updatedUniqueSecurityGroup);
  // Expect first call to list security groups on nodeId, second to use cached version
  customizer.addPermissionsToLocation(jcloudsMachineLocation, ImmutableSet.of(ssh));
  customizer.addPermissionsToLocation(jcloudsMachineLocation, ImmutableSet.of(ssh));
  verify(securityApi, times(1)).listSecurityGroupsForNode(NODE_ID);
  verify(securityApi, times(2)).addIpPermission(ssh, uniqueGroup);
  verify(securityApi, never()).addIpPermission(any(IpPermission.class), eq(sharedGroup));
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-locations-jclouds

@Test
public void testRemoveMultiplePermissionsFromNode() {
  IpPermission ssh = newPermission(22);
  IpPermission jmx = newPermission(31001);
  SecurityGroup sharedGroup = newGroup(customizer.getNameForSharedSecurityGroup());
  SecurityGroup group = newGroup("id");
  when(securityApi.listSecurityGroupsForNode(NODE_ID)).thenReturn(ImmutableSet.of(sharedGroup, group));
  SecurityGroup updatedSecurityGroup = newGroup("id", ImmutableSet.of(ssh, jmx));
  when(securityApi.addIpPermission(ssh, group)).thenReturn(updatedSecurityGroup);
  when(securityApi.addIpPermission(jmx, group)).thenReturn(updatedSecurityGroup);
  when(computeService.getContext().unwrap().getId()).thenReturn("aws-ec2");
  customizer.addPermissionsToLocation(jcloudsMachineLocation, ImmutableList.of(ssh, jmx));
  when(securityApi.removeIpPermission(ssh, group)).thenReturn(updatedSecurityGroup);
  when(securityApi.removeIpPermission(jmx, group)).thenReturn(updatedSecurityGroup);
  customizer.removePermissionsFromLocation(jcloudsMachineLocation, ImmutableList.of(ssh, jmx));
  verify(securityApi, times(1)).removeIpPermission(ssh, group);
  verify(securityApi, times(1)).removeIpPermission(jmx, group);
}

相关文章

微信公众号

最新文章

更多