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

Java IPVersionType类代码示例

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

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



IPVersionType类属于org.openstack4j.model.network包,在下文中一共展示了IPVersionType类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: run

import org.openstack4j.model.network.IPVersionType; //导入依赖的package包/类
@Override
protected void run(JavaSamplerContext context) throws Exception {
	String networkName = OpenstackUtil.generateName();
	String subnetName = OpenstackUtil.generateName();

	log.debug("creating network " + networkName);
	Network network = os.networking().network()
			.create(Builders.network().name(networkName).tenantId(tenant.getId()).build());

	log.debug("creating subnet " + subnetName);
	Subnet subnet = os
			.networking()
			.subnet()
			.create(Builders.subnet().name(subnetName).networkId(network.getId()).tenantId(tenant.getId())
					.ipVersion(IPVersionType.V4).cidr("192.168.0.0/24").build());

	subnet = os.networking().subnet().get(subnet.getId());

	log.debug("deleting subnet " + subnetName);
	logIfError(os.networking().subnet().delete(subnet.getId()));

	log.debug("deleting network " + networkName);
	logIfError(os.networking().network().delete(network.getId()));
}
 
开发者ID:savoirfairelinux,项目名称:jmeter-openstack,代码行数:25,代码来源:NeutronSampler.java


示例2: build

import org.openstack4j.model.network.IPVersionType; //导入依赖的package包/类
@Override
public CloudResource build(OpenStackContext context, AuthenticatedContext auth, Network network, Security security, CloudResource resource)
        throws Exception {
    try {
        NeutronNetworkView neutronView = new NeutronNetworkView(network);
        String subnetId = neutronView.isExistingSubnet() ? neutronView.getCustomSubnetId() : context.getParameter(SUBNET_ID, String.class);
        if (!neutronView.isExistingSubnet()) {
            OSClient osClient = createOSClient(auth);
            NeutronNetworkView networkView = new NeutronNetworkView(network);
            Subnet subnet = Builders.subnet().name(resource.getName())
                    .networkId(context.getParameter(OpenStackConstants.NETWORK_ID, String.class))
                    .tenantId(context.getStringParameter(OpenStackConstants.TENANT_ID))
                    .ipVersion(IPVersionType.V4)
                    .cidr(networkView.getSubnetCIDR())
                    .enableDHCP(true)
                    .build();
            subnetId = osClient.networking().subnet().create(subnet).getId();
        }
        context.putParameter(SUBNET_ID, subnetId);
        return createPersistedResource(resource, subnetId);
    } catch (OS4JException ex) {
        throw new OpenStackResourceException("Subnet creation failed", resourceType(), resource.getName(), ex);
    }
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:25,代码来源:OpenStackSubnetResourceBuilder.java


示例3: createSubnet

import org.openstack4j.model.network.IPVersionType; //导入依赖的package包/类
public static Subnet createSubnet(String networkId, String subnetName, String cidrBlock) throws Exception {
	if(isValidCidr(cidrBlock)){
     networkId=CommonAPI.takeFromMemory(NeutronKey.NEUTRON_NETWORKID, networkId);
     Subnet subnet = Builders.subnet().name(subnetName + "_shellSubnet_"+new Date()).networkId(networkId).ipVersion(IPVersionType.V4).cidr(cidrBlock).enableDHCP(true).build();
     subnet = Osp4jSession.getOspSession().networking().subnet().create(subnet);
     CommonAPI.addToMemory(NeutronKey.NEUTRON_SUBNETID, subnet.getId());
     return subnet != null ? subnet : null;
	}else{
		throw new Exception("Invalid CIDR block");
	}
}
 
开发者ID:vinodborole,项目名称:openstack4j-shell,代码行数:12,代码来源:NeutronAPI.java


示例4: createSubnet

import org.openstack4j.model.network.IPVersionType; //导入依赖的package包/类
@Override
public Object createSubnet(String subnetName, String networkName, String subnetCIDR, int ipVersion) {
	String networkId = null;
	Subnet subnet = null;
	try {
		// get network id
		for(Network network : os.networking().network().list()) {
			if(network.getName().equals(networkName)) {
				networkId = network.getId();
			}
		}

		if(networkId != null) {
			subnet = os.networking().subnet().create(Builders.subnet()
					.enableDHCP(true)
					.name(subnetName)
					.networkId(networkId)
					.ipVersion(IPVersionType.valueOf(ipVersion))
					.cidr(subnetCIDR)
					.build());
			logger.info("Created a subnet : " + subnetName + " for network [ " + networkName + "]");
		} else {
			logger.error("Failed to create subnet because network [ " + networkName + "] is not found!");
		}
	} catch( Exception ex ) {
		ex.printStackTrace();
		// TODO: Check with the team on how to handle exceptions.
		logger.error("Failed to create subnet: " + subnetName + ". Exception: " + ex.getMessage(), ex);
	}
	return subnet;
}
 
开发者ID:apache,项目名称:airavata,代码行数:32,代码来源:OpenstackIntfImpl.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java ResettableIterator类代码示例发布时间:2022-05-22
下一篇:
Java WireFeedInput类代码示例发布时间: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