Skip to content

Instantly share code, notes, and snippets.

@etoews
Created October 10, 2012 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save etoews/3867123 to your computer and use it in GitHub Desktop.
Save etoews/3867123 to your computer and use it in GitHub Desktop.
jclouds workshop
private void detectExtensions() {
for (ComputeService computeService: computeServices) {
try {
RestContext<NovaApi, NovaAsyncApi> nova = computeService.getContext().unwrap();
Set<String> zones = nova.getApi().getConfiguredZones();
String zone = Iterables.getFirst(zones, null);
String provider = computeService.getContext().toString().contains("rackspace") ? "Rackspace" : "HP";
Optional<? extends SecurityGroupApi> securityGroupExt =
nova.getApi().getSecurityGroupExtensionForZone(zone);
System.out.println("Provider: " + provider);
System.out.println(" Security Group Support: " + securityGroupExt.isPresent());
if (securityGroupExt.isPresent()) {
SecurityGroupApi securityGroupApi = securityGroupExt.get();
for (SecurityGroup securityGroup: securityGroupApi.list()) {
System.out.println(" Security Group: " + securityGroup.getName());
}
}
}
catch (Throwable e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment