use of org.jclouds.compute.domain.Hardware in project legacy-jclouds-examples by jclouds.
the class CreateServer method getHardware.
/**
* This method uses the generic ComputeService.listHardwareProfiles() to find the hardware profile.
*
* @return The Hardware with 512 MB of RAM
*/
private Hardware getHardware() {
System.out.println("Hardware Profiles (Flavors)");
Set<? extends Hardware> profiles = compute.listHardwareProfiles();
Hardware result = null;
for (Hardware profile : profiles) {
System.out.println(" " + profile);
if (profile.getRam() == 512) {
result = profile;
}
}
if (result == null) {
System.err.println("Flavor with 512 MB of RAM not found. Using first flavor found.");
result = profiles.iterator().next();
}
return result;
}
use of org.jclouds.compute.domain.Hardware in project camel by apache.
the class JcloudsSpringComputeTest method testListHardware.
@Test
public void testListHardware() throws InterruptedException {
result.expectedMessageCount(1);
template.sendBodyAndHeader("direct:start", null, JcloudsConstants.OPERATION, JcloudsConstants.LIST_HARDWARE);
result.assertIsSatisfied();
List<Exchange> exchanges = result.getExchanges();
if (exchanges != null && !exchanges.isEmpty()) {
for (Exchange exchange : exchanges) {
Set<?> hardwares = exchange.getIn().getBody(Set.class);
assertTrue(hardwares.size() > 0);
for (Object obj : hardwares) {
assertTrue(obj instanceof Hardware);
}
}
}
}