本文整理汇总了Java中org.openstack4j.model.compute.Flavor类的典型用法代码示例。如果您正苦于以下问题:Java Flavor类的具体用法?Java Flavor怎么用?Java Flavor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Flavor类属于org.openstack4j.model.compute包,在下文中一共展示了Flavor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verifyFlavors
import org.openstack4j.model.compute.Flavor; //导入依赖的package包/类
private void verifyFlavors(OSClient osClient, Iterable<Group> instanceGroups) {
List<? extends Flavor> flavors = osClient.compute().flavors().list();
Set<String> notFoundFlavors = new HashSet<>();
for (Group instanceGroup : instanceGroups) {
String instanceType = instanceGroup.getReferenceInstanceConfiguration().getTemplate().getFlavor();
boolean found = false;
for (Flavor flavor : flavors) {
if (flavor.getName().equalsIgnoreCase(instanceType)) {
found = true;
break;
}
}
if (!found) {
notFoundFlavors.add(instanceType);
}
}
if (!notFoundFlavors.isEmpty()) {
throw new CloudConnectorException(String.format("Not found flavors: %s", notFoundFlavors));
}
}
示例2: testVirtualMachines
import org.openstack4j.model.compute.Flavor; //导入依赖的package包/类
@Test
public void testVirtualMachines() {
CloudCredential cloudCredential = new CloudCredential(0L, "name");
OSClient osClient = mock(OSClient.class);
String regionName = "region1";
Set<String> regionsFromOpenStack = Sets.newHashSet(regionName);
List<AvailabilityZone> availabilityZones = newArrayList(new AvailabilityZone("zone1"));
Flavor flavor8GB = flavor(8192);
when(openStackClient.createOSClient(cloudCredential)).thenReturn(osClient);
when(openStackClient.getRegion(cloudCredential)).thenReturn(regionsFromOpenStack);
when(openStackClient.getZones(osClient, regionName)).thenReturn(availabilityZones);
when(openStackClient.getFlavors(osClient)).thenReturn(newArrayList(flavor8GB));
CloudVmTypes actual = underTest.virtualMachines(cloudCredential, null, null);
Assert.assertEquals(1, actual.getCloudVmResponses().get("zone1").size());
Assert.assertEquals(1, actual.getDefaultCloudVmResponses().size());
Assert.assertEquals("8.0", actual.getCloudVmResponses().get("zone1").iterator().next().getMetaData().getProperties().get("Memory"));
Assert.assertNotNull(actual.getDefaultCloudVmResponses().get(regionName));
}
示例3: createFlavor
import org.openstack4j.model.compute.Flavor; //导入依赖的package包/类
public String createFlavor(String region, String id, String flavorName, int diskInGb, int ramInMB, int cpus) {
getOs().useRegion(region);
Flavor flavor = getOs().compute().flavors().create(
Builders.flavor().disk(diskInGb).ram(ramInMB).vcpus(cpus).name(flavorName).id(id).build()
);
return flavor.getId();
}
示例4: listflavor
import org.openstack4j.model.compute.Flavor; //导入依赖的package包/类
public static List<? extends Flavor> listflavor() throws Exception{
OSClient os=Osp4jSession.getOspSession();
FlavorService flavorService = os.compute().flavors();
List<? extends Flavor> flavorList = flavorService.list();
printFlavorsDetails(flavorList);
return flavorList;
}
示例5: bootdefault
import org.openstack4j.model.compute.Flavor; //导入依赖的package包/类
public static String bootdefault(String imageId, String name) throws Exception {
imageId=CommonAPI.takeFromMemory(GlanceKey.IMAGE_ID, imageId);
Flavor flavor=getFlavor(50, 2048, 1);
Network network=NeutronAPI.createNetDefault(name);
String serverId = boot(imageId, flavor.getId(),network.getId(),name,false);
return serverId;
}
示例6: bootvolumedefault
import org.openstack4j.model.compute.Flavor; //导入依赖的package包/类
public static String bootvolumedefault(String volumeId, String name) throws Exception {
volumeId=CommonAPI.takeFromMemory(CinderKey.VOLUME_ID, volumeId);
Flavor flavor=getFlavor(50, 2048, 1);
Network network=NeutronAPI.createNetDefault(name);
String serverId = boot(volumeId, flavor.getId(),network.getId(),name,true);
return serverId;
}
示例7: getFlavor
import org.openstack4j.model.compute.Flavor; //导入依赖的package包/类
public static Flavor getFlavor(int edisk, int eram , int evcpu) throws Exception{
List<? extends Flavor> flavors=listflavor();
for(Flavor flavor : flavors){
int disk=flavor.getDisk();
int ram=flavor.getRam();
int vcpu=flavor.getVcpus();
if(disk==edisk && ram == eram && evcpu==vcpu)
return flavor;
}
return null;
}
示例8: printFlavorsDetails
import org.openstack4j.model.compute.Flavor; //导入依赖的package包/类
public static void printFlavorsDetails(List<? extends Flavor> flavors){
TableBuilder tb=getTableBuilder("Flavor");
for (final Flavor flavor : flavors) {
addFlavorRow(tb, flavor);
}
System.out.println(tb.toString());
System.out.println("TOTAL RECORDS: "+tb.totalrecords());
}
示例9: getFlavorId
import org.openstack4j.model.compute.Flavor; //导入依赖的package包/类
public String getFlavorId(String flavorNameOrId) {
Flavor flavor = client.compute().flavors().get(flavorNameOrId);
if(flavor == null) {
for(Flavor someFlavor : client.compute().flavors().list()) {
if(someFlavor.getName().equals(flavorNameOrId))
return someFlavor.getId();
}
throw new RuntimeException("Failed to find flavor by name " + flavorNameOrId);
}
else {
LOG.warn("Failed to find flavor by ID " + flavorNameOrId);
return flavorNameOrId;
}
}
示例10: getFlavorByName
import org.openstack4j.model.compute.Flavor; //导入依赖的package包/类
public static Flavor getFlavorByName(OSClient os, String name) throws OpenstackException {
List<? extends Flavor> flavors = os.compute().flavors().list();
for (Flavor flavor : flavors) {
if (flavor.getName().equals(name))
return flavor;
}
throw new OpenstackException("flavour " + name + " not found");
}
示例11: FlavorInRegion
import org.openstack4j.model.compute.Flavor; //导入依赖的package包/类
public FlavorInRegion(Flavor delegate, Location region) {
checkNotNull(delegate, "delegate is null");
checkNotNull(region, "region is null");
this.delegate = delegate;
this.region = region;
regionScopedId = IdScopeByLocations.from(region.id(), delegate.getId()).getIdWithLocation();
}
示例12: getFlavorId
import org.openstack4j.model.compute.Flavor; //导入依赖的package包/类
/**
* Returns the flavor identifier that corresponds to the specified flavor
* name.
*
* @return
* @throws NotFoundException
* If the specified flavor name doesn't exist.
* @throws ResponseException
* On communication errors.
*/
private String getFlavorId() throws NotFoundException, ResponseException {
List<Flavor> flavors = new ListSizesRequest(getClientFactory()).call();
for (Flavor flavor : flavors) {
if (flavor.getName().equals(this.flavorName)) {
return flavor.getId();
}
}
throw new NotFoundException(String.format("no flavor with name \"%s\" exists in region \"%s\"", this.flavorName,
getApiAccessConfig().getRegion()));
}
示例13: main
import org.openstack4j.model.compute.Flavor; //导入依赖的package包/类
public static void main(String[] args) {
try {
List<Flavor> flavors = new ListSizesRequest(new OSClientFactory(DriverConfigLoader.loadDefault())).call();
LOG.info("{} server flavor(s) found", flavors.size());
for (Flavor flavor : flavors) {
LOG.info("flavor: {}", flavor);
}
} catch (Exception e) {
LOG.error("error type: {}", e.getClass().getName());
LOG.error("error: {}", e.getMessage());
}
}
示例14: getFlavorId
import org.openstack4j.model.compute.Flavor; //导入依赖的package包/类
private String getFlavorId(OSClient osClient, String flavorName) {
List<? extends Flavor> flavors = osClient.compute().flavors().list();
for (Flavor flavor : flavors) {
if (flavor.getName().equals(flavorName)) {
return flavor.getId();
}
}
return null;
}
示例15: collectVmTypes
import org.openstack4j.model.compute.Flavor; //导入依赖的package包/类
private Set<VmType> collectVmTypes(OSClient osClient) {
Set<VmType> types = new HashSet<>();
for (Flavor flavor : openStackClient.getFlavors(osClient)) {
VmTypeMeta.VmTypeMetaBuilder builder = VmTypeMeta.VmTypeMetaBuilder.builder()
.withCpuAndMemory(flavor.getVcpus(), flavor.getRam());
for (VolumeParameterType volumeParameterType : values()) {
switch (volumeParameterType) {
case MAGNETIC:
builder.withMagneticConfig(volumeParameterConfig(MAGNETIC));
break;
case SSD:
builder.withSsdConfig(null);
break;
case EPHEMERAL:
builder.withEphemeralConfig(null);
break;
case ST1:
builder.withSt1Config(null);
break;
case AUTO_ATTACHED:
builder.withAutoAttachedConfig(null);
break;
default:
break;
}
}
VmType vmType = VmType.vmTypeWithMeta(flavor.getName(), builder.create(), true);
types.add(vmType);
}
LOGGER.info("openstack collect vm types result: {}", types);
return types;
}