• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Flavor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.openstack4j.model.compute.Flavor的典型用法代码示例。如果您正苦于以下问题:Java Flavor类的具体用法?Java Flavor怎么用?Java Flavor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Flavor类属于org.openstack4j.model.compute包,在下文中一共展示了Flavor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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));
    }
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:22,代码来源:OpenStackSetup.java


示例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));

}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:24,代码来源:OpenStackPlatformResourcesTest.java


示例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();
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:8,代码来源:Openstack4JNova.java


示例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;
}
 
开发者ID:vinodborole,项目名称:openstack4j-shell,代码行数:8,代码来源:NovaAPI.java


示例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;
}
 
开发者ID:vinodborole,项目名称:openstack4j-shell,代码行数:8,代码来源:NovaAPI.java


示例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;
}
 
开发者ID:vinodborole,项目名称:openstack4j-shell,代码行数:8,代码来源:NovaAPI.java


示例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;
}
 
开发者ID:vinodborole,项目名称:openstack4j-shell,代码行数:12,代码来源:NovaAPI.java


示例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());
}
 
开发者ID:vinodborole,项目名称:openstack4j-shell,代码行数:9,代码来源:NovaAPI.java


示例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;
    }
}
 
开发者ID:gocd-contrib,项目名称:openstack-elastic-agent,代码行数:15,代码来源:OpenstackClientWrapper.java


示例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");
}
 
开发者ID:savoirfairelinux,项目名称:jmeter-openstack,代码行数:9,代码来源:OpenstackUtil.java


示例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();
  }
 
开发者ID:cloudiator,项目名称:sword,代码行数:10,代码来源:FlavorInRegion.java


示例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()));
}
 
开发者ID:elastisys,项目名称:scale.cloudpool,代码行数:21,代码来源:CreateServerRequest.java


示例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());
    }
}
 
开发者ID:elastisys,项目名称:scale.cloudpool,代码行数:13,代码来源:ListSizesMain.java


示例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;
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:10,代码来源:OpenStackInstanceBuilder.java


示例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;
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:33,代码来源:OpenStackPlatformResources.java


示例16: executeTransaction

import org.openstack4j.model.compute.Flavor; //导入依赖的package包/类
@Override
public void executeTransaction(EntityManager em) throws Exception {
    this.tg = new TaskGraph();

    VirtualSystem vs = em.find(VirtualSystem.class, this.vs.getId(),
            LockModeType.PESSIMISTIC_WRITE);

    log.info("Checking VS" + vs.getName() + " has the corresponding flavor");

    ApplianceSoftwareVersion applianceSoftwareVersion = vs.getApplianceSoftwareVersion();

    String expectedFlavorName = Joiner.on("-").join(applianceSoftwareVersion.getAppliance().getModel(),
            applianceSoftwareVersion.getApplianceSoftwareVersion(), vs.getName(),
            applianceSoftwareVersion.getImageUrl());

    try (Openstack4JNova nova = new Openstack4JNova(this.osEndPoint)) {
        Set<OsFlavorReference> flavorReferences = vs.getOsFlavorReference();
        boolean createFlavor = true;

        for (Iterator<OsFlavorReference> iterator = flavorReferences.iterator(); iterator.hasNext(); ) {
            OsFlavorReference flavorReference = iterator.next();
            if (flavorReference.getRegion().equals(this.region)) {
                Flavor flavor = nova.getFlavorById(flavorReference.getRegion(), flavorReference.getFlavorRefId());
                if (flavor == null) {
                    iterator.remove();
                    OSCEntityManager.delete(em, flavorReference, this.txBroadcastUtil);
                } else if (!flavor.getName().equals(expectedFlavorName)) {
                    // Assume flavor name is changed, means the version is upgraded since flavor name contains version
                    // information. Delete existing flavor and create new flavor.
                    this.tg.addTask(this.deleteFlavor.create(this.region, flavorReference, this.osEndPoint));
                } else {
                    createFlavor = false;
                }
            }
        }
        if (createFlavor) {
            this.tg.appendTask(this.createFlavorTask.create(vs, this.region, expectedFlavorName, applianceSoftwareVersion,
                    this.osEndPoint));
        }
    }

    OSCEntityManager.update(em, vs, this.txBroadcastUtil);
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:44,代码来源:FlavorCheckMetaTask.java


示例17: getFlavorById

import org.openstack4j.model.compute.Flavor; //导入依赖的package包/类
public Flavor getFlavorById(String region, String id) {
    getOs().useRegion(region);
    return getOs().compute().flavors().get(id);
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:5,代码来源:Openstack4JNova.java


示例18: getFlavors

import org.openstack4j.model.compute.Flavor; //导入依赖的package包/类
public List<? extends Flavor> getFlavors() {
	return client().compute().flavors().list();
}
 
开发者ID:evoila,项目名称:cfsummiteu2017,代码行数:4,代码来源:NovaFluent.java


示例19: printFlavorDetails

import org.openstack4j.model.compute.Flavor; //导入依赖的package包/类
public static void printFlavorDetails(Flavor flavor){
    TableBuilder tb=getTableBuilder("Flavor");
    addFlavorRow(tb, flavor);
    System.out.println(tb.toString());
    System.out.println("TOTAL RECORDS: "+tb.totalrecords());
}
 
开发者ID:vinodborole,项目名称:openstack4j-shell,代码行数:7,代码来源:NovaAPI.java


示例20: addFlavorRow

import org.openstack4j.model.compute.Flavor; //导入依赖的package包/类
private static void addFlavorRow(TableBuilder tb, Flavor flavor){
    tb.addRow(flavor.getId(),String.valueOf(flavor.getDisk()),String.valueOf(flavor.getRam()),String.valueOf(flavor.getVcpus()),flavor.getName());
}
 
开发者ID:vinodborole,项目名称:openstack4j-shell,代码行数:4,代码来源:NovaAPI.java



注:本文中的org.openstack4j.model.compute.Flavor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BasicDataSourceFactory类代码示例发布时间:2022-05-22
下一篇:
Java Loader类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap