当前位置: 首页>>代码示例>>Java>>正文


Java VLAN类代码示例

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


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

示例1: getComputeResourceOfNetwork

import org.dasein.cloud.network.VLAN; //导入依赖的package包/类
private List<String> getComputeResourceOfNetwork(@Nonnull String networkId) throws CloudException, InternalException {
    APITrace.begin(provider, "getNetworkComputeResourceID");
    try {
        Networks services = provider.getNetworkServices().getVlanSupport();
        VLAN vlan = services.getVlan(networkId);
        int length = Integer.parseInt(vlan.getTag("numComputeIds"));
        List<String> list = new ArrayList<String>();
        for (int i = 0; i<length; i++) {
           String tag = "computeResourceID"+i;
           list.add(vlan.getTag(tag));
        }
        return list;

    }
    finally {
        APITrace.end();
    }
}
 
开发者ID:greese,项目名称:dasein-cloud-virtustream,代码行数:19,代码来源:VirtualMachines.java

示例2: getVlan

import org.dasein.cloud.network.VLAN; //导入依赖的package包/类
@Override
public VLAN getVlan(@Nonnull String vlanId) throws CloudException, InternalException {
    APITrace.begin(provider, GET_NETWORK);
    try {
        try {
            VirtustreamMethod method = new VirtustreamMethod(provider);
            String obj = method.getString("/Network/"+vlanId+"?$filter=IsRemoved eq false", GET_NETWORK);
            if (obj != null && obj.length() > 0) {
                JSONObject json = new JSONObject(obj);
                VLAN vlan = toVlan(json);
                if (vlan != null){
                    return vlan;
                }
            }
        }
        catch (JSONException e) {
            logger.error(e);
            throw new InternalException("Unable to parse JSONObject "+e.getMessage());
        }
        return null;
    }
    finally {
        APITrace.end();
    }
}
 
开发者ID:greese,项目名称:dasein-cloud-virtustream,代码行数:26,代码来源:Networks.java

示例3: createVlan

import org.dasein.cloud.network.VLAN; //导入依赖的package包/类
@Override
@Nonnull
public VLAN createVlan(@Nonnull VlanCreateOptions options) throws CloudException, InternalException {

	Network network = new Network();

	network.setResourceName(options.getName());
	network.setNetworkType(NetworkType.PUBLIC);
	network.setClusterUUID(getProvider().getContext().getRegionId());
	network.setVdcUUID(FCOProviderUtils.getDefaultVDC(userService, network.getClusterUUID(), getProvider().getContext().getAccountNumber()));

	try{
		Job job = userService.createNetwork(network, null);
		userService.waitForJob(job.getResourceUUID(), true);

		return createVLANFromNetwork(userService, (Network) FCOProviderUtils.getResource(userService, job.getItemUUID(), ResourceType.NETWORK, true), options.getCidr());
	}catch (ExtilityException e){
		throw new CloudException(e);
	}
}
 
开发者ID:greese,项目名称:dasein-cloud-flexiant,代码行数:21,代码来源:FCOVLANSupport.java

示例4: listVlans

import org.dasein.cloud.network.VLAN; //导入依赖的package包/类
@Override
public Iterable<VLAN> listVlans() throws CloudException, InternalException {
	List<VLAN> vlans = new ArrayList<VLAN>();
	SearchFilter filter = new SearchFilter();
	FilterCondition fc = new FilterCondition();
	fc.setCondition(Condition.IS_EQUAL_TO);
	fc.setField("networkType");
	fc.getValue().add(NetworkType.PUBLIC.name());
	filter.getFilterConditions().add(fc);
	try{
		ListResult result = FCOProviderUtils.listWithChildren(userService, filter, ResourceType.NETWORK);
		if(result == null || result.getList() == null){
			return vlans;
		}
		for(Object obj : result.getList()){
			vlans.add(createVLANFromNetwork(userService, (Network) obj, null));
		}
	}catch (ExtilityException e){
		throw new CloudException(e);
	}
	return vlans;
}
 
开发者ID:greese,项目名称:dasein-cloud-flexiant,代码行数:23,代码来源:FCOVLANSupport.java

示例5: setUp

import org.dasein.cloud.network.VLAN; //导入依赖的package包/类
@Before
public void setUp() throws CloudException, InternalException {
    super.setUp();

    new NonStrictExpectations() {{
        computeServices.getImageSupport(); result = imageSupport;

        MachineImage vhdImage = MachineImage.getInstance(VHD_1_OWNER, REGION, VHD_1_ID, ImageClass.MACHINE,
                MachineImageState.ACTIVE, VHD_1_NAME, VHD_1_DESCRIPTION, Architecture.I64, Platform.WINDOWS);
        vhdImage.setTag("type", "vhd");
        imageSupport.getImage(VHD_1_ID); result = vhdImage;

        MachineImage templateImage = MachineImage.getInstance(TPL_1_OWNER, REGION, TPL_1_ID, ImageClass.MACHINE,
                MachineImageState.ACTIVE, TPL_1_NAME, TPL_1_DESCRIPTION, Architecture.I64, Platform.WINDOWS);
        templateImage.setTag("type", "template");
        imageSupport.getImage(TPL_1_ID); result = templateImage;

        imageSupport.getImage(anyString); result = null;

        VLAN vlan = new VLAN();
        vlan.setProviderVlanId(VM_1_NETWORK_ID);
        vlan.setName(VM_1_NETWORK_NAME);
        networkSupport.getVlan(VM_1_NETWORK_ID); result = vlan;
        networkSupport.getVlan(anyString); result = null;
    }};

    azurePackVirtualMachineSupport = new AzurePackVirtualMachineSupport(azurePackCloudMock);
}
 
开发者ID:dasein-cloud,项目名称:dasein-cloud-azurepack,代码行数:29,代码来源:AzurePackVirtualMachineSupportTest.java

示例6: listVlans

import org.dasein.cloud.network.VLAN; //导入依赖的package包/类
@Nonnull
@Override
public Iterable<VLAN> listVlans() throws CloudException, InternalException {
    APITrace.begin(provider, LIST_VLANS);
    try {
        try {
            VirtustreamMethod method = new VirtustreamMethod(provider);
            ArrayList<VLAN> list = new ArrayList<VLAN>();
            String obj = method.getString("/Network?$filter=IsRemoved eq false", LIST_VLAN_STATUS);
            if (obj != null && obj.length() > 0) {
                JSONArray json = new JSONArray(obj);
                for (int i=0; i<json.length(); i++) {
                    JSONObject node = json.getJSONObject(i);

                    VLAN vlan = toVlan(node);
                    if (vlan != null) {
                        list.add(vlan);
                    }
                }
            }
            return list;
        }
        catch (JSONException e) {
            logger.error(e);
            throw new InternalException("Unable to parse JSONObject "+e.getMessage());
        }
    }
    finally {
        APITrace.end();
    }
}
 
开发者ID:greese,项目名称:dasein-cloud-virtustream,代码行数:32,代码来源:Networks.java

示例7: getVlan

import org.dasein.cloud.network.VLAN; //导入依赖的package包/类
@Override
public VLAN getVlan(String providerVlanId) throws CloudException, InternalException {
	if(!FCOProviderUtils.isSet(providerVlanId)){
		throw new InternalException("VLAN id was not valid");
	}

	try{
		return createVLANFromNetwork(userService, (Network) FCOProviderUtils.getResource(userService, providerVlanId, ResourceType.NETWORK, true), null);
	}catch (ExtilityException e){
		throw new CloudException(e);
	}
}
 
开发者ID:greese,项目名称:dasein-cloud-flexiant,代码行数:13,代码来源:FCOVLANSupport.java

示例8: createVLANFromNetwork

import org.dasein.cloud.network.VLAN; //导入依赖的package包/类
private static VLAN createVLANFromNetwork(UserService userService, Network network, String cidrFromCreate) {
	if(network == null){
		return null;
	}

	VLAN vlan = new VLAN();
	vlan.setName(network.getResourceName());
	vlan.setNetworkType(network.getNetworkType().name());
	vlan.setProviderDataCenterId(network.getVdcUUID());
	vlan.setProviderOwnerId(network.getCustomerUUID());
	vlan.setProviderRegionId(network.getClusterUUID());
	vlan.setProviderVlanId(network.getResourceUUID());
	vlan.setSupportedTraffic(IPVersion.IPV4, IPVersion.IPV6);
	if(FCOProviderUtils.isSet(cidrFromCreate)){
		vlan.setCidr(cidrFromCreate);
	}else if(network.getSubnets().size() > 0){
		com.extl.jade.user.Subnet subnet = network.getSubnets().get(0);
		vlan.setCidr(subnet.getDefaultGatewayAddress());
	}else{
		// If the network has no subnets we still need to specify a CIDR
		vlan.setCidr("28", "127.0.0.1"); // TODO : if network does not have subnet, should we throw exception?
	}

	vlan.setCurrentState(getVlanStateFromResourceState(network.getResourceState()));
	List<String> servers = listServerIds(userService, network.getResourceUUID());
	String[] array = new String[servers.size()];
	vlan.setDnsServers(listServerIds(userService, network.getResourceUUID()).toArray(array));
	vlan.setDescription("Network : " + network.getResourceName());

	return vlan;
}
 
开发者ID:greese,项目名称:dasein-cloud-flexiant,代码行数:32,代码来源:FCOVLANSupport.java

示例9: launch

import org.dasein.cloud.network.VLAN; //导入依赖的package包/类
@Nonnull
@Override
public VirtualMachine launch(@Nonnull VMLaunchOptions withLaunchOptions) throws CloudException, InternalException {
    MachineImage image = provider.getComputeServices().getImageSupport().getImage(withLaunchOptions.getMachineImageId());
    if(image == null)
        throw new InternalException("Invalid machine image id");

    VLAN vlan = null;
    if(withLaunchOptions.getVlanId() != null) {
        vlan = this.provider.getNetworkServices().getVlanSupport().getVlan(withLaunchOptions.getVlanId());
        if (vlan == null)
            throw new InternalException("Invalid vlan id provided");
    }

    String imageType = (String)image.getTag("type");
    if (imageType.equalsIgnoreCase("vhd") && "default".equalsIgnoreCase(withLaunchOptions.getStandardProductId()))
        throw new InternalException("Invalid product id for this type of image. Default product should be use only for templates");

    WAPVirtualMachineModel virtualMachineModel = new WAPVirtualMachineModel();
    virtualMachineModel.setName(withLaunchOptions.getFriendlyName());
    virtualMachineModel.setCloudId(provider.getContext().getRegionId());
    virtualMachineModel.setStampId(withLaunchOptions.getDataCenterId());

    if(imageType.equalsIgnoreCase("vhd")){
        virtualMachineModel.setVirtualHardDiskId(withLaunchOptions.getMachineImageId());
        virtualMachineModel.setHardwareProfileId(withLaunchOptions.getStandardProductId());
    } else {
        virtualMachineModel.setVmTemplateId(withLaunchOptions.getMachineImageId());
    }

    if(imageType.equalsIgnoreCase("template")) {
        if(image.getPlatform().isWindows() && withLaunchOptions.getWinProductSerialNum() != null) {
            virtualMachineModel.setProductKey(withLaunchOptions.getWinProductSerialNum());
        } else if (!image.getPlatform().isWindows() && withLaunchOptions.getBootstrapKey() != null) {
            virtualMachineModel.setLinuxAdministratorSSHKeyString(withLaunchOptions.getBootstrapKey());
        }

        if (withLaunchOptions.getBootstrapPassword() != null && withLaunchOptions.getBootstrapUser() != null) {
            virtualMachineModel.setLocalAdminPassword(withLaunchOptions.getBootstrapPassword());
            if (image.getPlatform().isWindows()) {
                virtualMachineModel.setLocalAdminUserName("administrator");
                //virtualMachineModel.setLocalAdminUserName((withLaunchOptions.getBootstrapUser() == null || withLaunchOptions.getBootstrapUser().trim().length() == 0 || withLaunchOptions.getBootstrapUser().equalsIgnoreCase("root") || withLaunchOptions.getBootstrapUser().equalsIgnoreCase("admin") || withLaunchOptions.getBootstrapUser().equalsIgnoreCase("administrator") ? "dasein" : withLaunchOptions.getBootstrapUser()));
            } else {
                virtualMachineModel.setLocalAdminUserName("root");
                //virtualMachineModel.setLocalAdminUserName((withLaunchOptions.getBootstrapUser() == null || withLaunchOptions.getBootstrapUser().trim().length() == 0 || withLaunchOptions.getBootstrapUser().equals("root") ? "dasein" : withLaunchOptions.getBootstrapUser()));
            }
        }
    }

    if (withLaunchOptions.getVlanId() != null) {
        ArrayList<WAPNewAdapterModel> adapters = new ArrayList<WAPNewAdapterModel>();
        WAPNewAdapterModel newAdapterModel = new WAPNewAdapterModel();
        newAdapterModel.setVmNetworkName(vlan.getName());
        adapters.add(newAdapterModel);
        virtualMachineModel.setNewVirtualNetworkAdapterInput(adapters);
    }

    HttpUriRequest createRequest = new AzurePackVMRequests(provider).createVirtualMachine(virtualMachineModel).build();
    VirtualMachine virtualMachine = new AzurePackRequester(provider, createRequest).withJsonProcessor(new DriverToCoreMapper<WAPVirtualMachineModel, VirtualMachine>() {
        @Override
        public VirtualMachine mapFrom(WAPVirtualMachineModel entity) {
            return virtualMachineFrom(entity);
        }
    }, WAPVirtualMachineModel.class).execute();

    waitForVMOperation("Creating", virtualMachine.getProviderVirtualMachineId(), virtualMachine.getProviderDataCenterId());
    start(virtualMachine.getProviderVirtualMachineId());

    virtualMachine.setRootUser(virtualMachineModel.getLocalAdminUserName());
    virtualMachine.setRootPassword(virtualMachineModel.getLocalAdminPassword());
    return virtualMachine;
}
 
开发者ID:dasein-cloud,项目名称:dasein-cloud-azurepack,代码行数:73,代码来源:AzurePackVirtualMachineSupport.java

示例10: listGateways

import org.dasein.cloud.network.VLAN; //导入依赖的package包/类
public RequestBuilder listGateways(VLAN vlan) throws InternalException {
    RequestBuilder requestBuilder = RequestBuilder.get();
    addCommonHeaders(requestBuilder);
    requestBuilder.setUri(getEncodedUri(String.format(LIST_NET_GATEWAYS, this.provider.getContext().getEndpoint(), this.provider.getContext().getAccountNumber(), vlan.getProviderVlanId(), vlan.getProviderDataCenterId())));
    return requestBuilder;
}
 
开发者ID:dasein-cloud,项目名称:dasein-cloud-azurepack,代码行数:7,代码来源:AzurePackNetworkRequests.java


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