Created
October 10, 2012 17:35
-
-
Save etoews/3867123 to your computer and use it in GitHub Desktop.
jclouds workshop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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