本文整理汇总了Java中com.vmware.vim25.DistributedVirtualSwitchPortConnection类的典型用法代码示例。如果您正苦于以下问题:Java DistributedVirtualSwitchPortConnection类的具体用法?Java DistributedVirtualSwitchPortConnection怎么用?Java DistributedVirtualSwitchPortConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DistributedVirtualSwitchPortConnection类属于com.vmware.vim25包,在下文中一共展示了DistributedVirtualSwitchPortConnection类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testGetDvsPortBackingInfoWithUUID
import com.vmware.vim25.DistributedVirtualSwitchPortConnection; //导入依赖的package包/类
@Test
public void testGetDvsPortBackingInfoWithUUID() {
this.subnet = new SubnetState();
this.subnet.customProperties = new HashMap<>();
this.subnet.customProperties.put(DvsProperties.DVS_UUID, UUID.randomUUID().toString());
this.subnet.customProperties.put(DvsProperties.PORT_GROUP_KEY, UUID.randomUUID().toString());
VirtualDeviceBackingInfo deviceBackingInfo = NetworkDeviceBackingFactory
.getNetworkDeviceBackingInfo(this.subnet);
assertTrue(deviceBackingInfo instanceof
VirtualEthernetCardDistributedVirtualPortBackingInfo);
VirtualEthernetCardDistributedVirtualPortBackingInfo distributedVirtualPortBackingInfo =
(VirtualEthernetCardDistributedVirtualPortBackingInfo) deviceBackingInfo;
DistributedVirtualSwitchPortConnection port = distributedVirtualPortBackingInfo.getPort();
assertNotNull(port);
assertEquals(this.subnet.customProperties.get(DvsProperties.DVS_UUID),
port.getSwitchUuid());
assertEquals(this.subnet.customProperties.get(DvsProperties.PORT_GROUP_KEY),
port.getPortgroupKey());
}
开发者ID:vmware,项目名称:photon-model,代码行数:26,代码来源:NetworkDeviceBackingFactoryTest.java
示例2: editEthernetCards
import com.vmware.vim25.DistributedVirtualSwitchPortConnection; //导入依赖的package包/类
protected VirtualEthernetCard editEthernetCards(VirtualMachine machine, String networkName) {
// ネットワークアダプタ E1000を使用する
VirtualEthernetCard ethernetCard = new VirtualE1000();
// 分散ポートグループ情報取得
DistributedVirtualPortgroupInfo dvPortgroupInfo = getDVPortgroupInfo(machine, networkName);
if (dvPortgroupInfo != null) {
// 分散ポートグループの場合
VirtualEthernetCardDistributedVirtualPortBackingInfo nicBacking = new VirtualEthernetCardDistributedVirtualPortBackingInfo();
nicBacking.setPort(new DistributedVirtualSwitchPortConnection());
nicBacking.getPort().setPortgroupKey(dvPortgroupInfo.getPortgroupKey());
nicBacking.getPort().setSwitchUuid(dvPortgroupInfo.getSwitchUuid());
ethernetCard.setBacking(nicBacking);
} else {
// 標準ポートグループの場合
VirtualEthernetCardNetworkBackingInfo backingInfo = new VirtualEthernetCardNetworkBackingInfo();
backingInfo.setDeviceName(networkName);
ethernetCard.setBacking(backingInfo);
}
return ethernetCard;
}
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:24,代码来源:VmwareNetworkProcess.java
示例3: prepareDvNicDevice
import com.vmware.vim25.DistributedVirtualSwitchPortConnection; //导入依赖的package包/类
public static VirtualDevice prepareDvNicDevice(VirtualMachineMO vmMo, ManagedObjectReference morNetwork, VirtualEthernetCardType deviceType, String dvPortGroupName,
String dvSwitchUuid, String macAddress, int contextNumber, boolean connected, boolean connectOnStart) throws Exception {
VirtualEthernetCard nic = createVirtualEthernetCard(deviceType);
final VirtualEthernetCardDistributedVirtualPortBackingInfo dvPortBacking = new VirtualEthernetCardDistributedVirtualPortBackingInfo();
final DistributedVirtualSwitchPortConnection dvPortConnection = new DistributedVirtualSwitchPortConnection();
dvPortConnection.setSwitchUuid(dvSwitchUuid);
dvPortConnection.setPortgroupKey(morNetwork.getValue());
dvPortBacking.setPort(dvPortConnection);
nic.setBacking(dvPortBacking);
nic.setAddressType("Manual");
nic.setConnectable(getVirtualDeviceConnectInfo(connected, connectOnStart));
nic.setMacAddress(macAddress);
nic.setKey(-contextNumber);
return nic;
}
开发者ID:apache,项目名称:cloudstack,代码行数:20,代码来源:VmwareHelper.java
示例4: testGetDvsPortBackingInfoWithPortGroupKey
import com.vmware.vim25.DistributedVirtualSwitchPortConnection; //导入依赖的package包/类
/**
* NSX-V test case when only port group key is present
*
* Exception as
*/
@Test(expected = IllegalArgumentException.class)
public void testGetDvsPortBackingInfoWithPortGroupKey() {
this.subnet = new SubnetState();
this.subnet.customProperties = new HashMap<>();
List<String> portGroupIds = new ArrayList<>();
portGroupIds.add(UUID.randomUUID().toString());
portGroupIds.add(UUID.randomUUID().toString());
this.subnet.customProperties.put(DvsProperties.PORT_GROUP_KEY, Utils.toJson(portGroupIds));
// will throw NPE here as the querytargetrequest is null
VirtualDeviceBackingInfo deviceBackingInfo = NetworkDeviceBackingFactory
.getNetworkDeviceBackingInfo(this.subnet);
assertTrue(deviceBackingInfo instanceof
VirtualEthernetCardDistributedVirtualPortBackingInfo);
VirtualEthernetCardDistributedVirtualPortBackingInfo distributedVirtualPortBackingInfo =
(VirtualEthernetCardDistributedVirtualPortBackingInfo) deviceBackingInfo;
DistributedVirtualSwitchPortConnection port = distributedVirtualPortBackingInfo.getPort();
assertNotNull(port);
// TODO: mock get DVS switch call to vSphere and match the result
// for now we are just using the expected exception as without UUID the backing info
// cannot be set.
assertNull(port.getSwitchUuid());
assertEquals(this.subnet.customProperties.get(DvsProperties.PORT_GROUP_KEY),
port.getPortgroupKey());
}
开发者ID:vmware,项目名称:photon-model,代码行数:39,代码来源:NetworkDeviceBackingFactoryTest.java
示例5: getDvPortBackingInfo
import com.vmware.vim25.DistributedVirtualSwitchPortConnection; //导入依赖的package包/类
public VirtualEthernetCardDistributedVirtualPortBackingInfo getDvPortBackingInfo(Pair<ManagedObjectReference, String> networkInfo) throws Exception {
assert (networkInfo != null);
assert (networkInfo.first() != null && networkInfo.first().getType().equalsIgnoreCase("DistributedVirtualPortgroup"));
final VirtualEthernetCardDistributedVirtualPortBackingInfo dvPortBacking = new VirtualEthernetCardDistributedVirtualPortBackingInfo();
final DistributedVirtualSwitchPortConnection dvPortConnection = new DistributedVirtualSwitchPortConnection();
ManagedObjectReference dvsMor = getDvSwitchMor(networkInfo.first());
String dvSwitchUuid = getDvSwitchUuid(dvsMor);
dvPortConnection.setSwitchUuid(dvSwitchUuid);
dvPortConnection.setPortgroupKey(networkInfo.first().getValue());
dvPortBacking.setPort(dvPortConnection);
System.out.println("Plugging NIC device into network " + networkInfo.second() + " backed by dvSwitch: " + dvSwitchUuid);
return dvPortBacking;
}
开发者ID:apache,项目名称:cloudstack,代码行数:14,代码来源:DatacenterMO.java
示例6: getDvPortGroupName
import com.vmware.vim25.DistributedVirtualSwitchPortConnection; //导入依赖的package包/类
public String getDvPortGroupName(VirtualEthernetCard nic) throws Exception {
VirtualEthernetCardDistributedVirtualPortBackingInfo dvpBackingInfo = (VirtualEthernetCardDistributedVirtualPortBackingInfo)nic.getBacking();
DistributedVirtualSwitchPortConnection dvsPort = dvpBackingInfo.getPort();
String dvPortGroupKey = dvsPort.getPortgroupKey();
ManagedObjectReference dvPortGroupMor = new ManagedObjectReference();
dvPortGroupMor.setValue(dvPortGroupKey);
dvPortGroupMor.setType("DistributedVirtualPortgroup");
return (String)_context.getVimClient().getDynamicProperty(dvPortGroupMor, "name");
}
开发者ID:apache,项目名称:cloudstack,代码行数:10,代码来源:VirtualMachineMO.java
示例7: updateDvNicDevice
import com.vmware.vim25.DistributedVirtualSwitchPortConnection; //导入依赖的package包/类
public static void updateDvNicDevice(VirtualDevice nic, ManagedObjectReference morNetwork, String dvSwitchUuid) throws Exception {
final VirtualEthernetCardDistributedVirtualPortBackingInfo dvPortBacking = new VirtualEthernetCardDistributedVirtualPortBackingInfo();
final DistributedVirtualSwitchPortConnection dvPortConnection = new DistributedVirtualSwitchPortConnection();
dvPortConnection.setSwitchUuid(dvSwitchUuid);
dvPortConnection.setPortgroupKey(morNetwork.getValue());
dvPortBacking.setPort(dvPortConnection);
nic.setBacking(dvPortBacking);
}
开发者ID:apache,项目名称:cloudstack,代码行数:10,代码来源:VmwareHelper.java
示例8: getDistributedPortBackingInfo
import com.vmware.vim25.DistributedVirtualSwitchPortConnection; //导入依赖的package包/类
/**
* Backing info for distributed virtual switch port or portgroup
*/
private static VirtualEthernetCardDistributedVirtualPortBackingInfo getDistributedPortBackingInfo(
CustomProperties props, QueryConfigTargetRequest queryConfigTargetRequest) {
DistributedVirtualSwitchPortConnection port = new DistributedVirtualSwitchPortConnection();
String portGroupKey = props.getString(DvsProperties.PORT_GROUP_KEY);
String dvsUuid = props.getString(DvsProperties.DVS_UUID);
if (StringUtil.isNullOrEmpty(dvsUuid)) {
// NSX-V sets the value to a list of dvPortGroupsKeys as the logical switch is
// created in a transport zone which could be associated with multiple clusters.
// Hence dvPortGroup is created per cluster. The configTarget will filter based on
// the cluster where machine is being provisioned.
Type listType = new TypeToken<ArrayList<String>>(){}.getType();
final List<String> portGroupIds = Utils.fromJson(portGroupKey, listType);
// NSX-V doesn't have UUID information in its API response
DistributedVirtualPortgroupInfo info = null;
try {
ConfigTarget configTarget = queryConfigTargetRequest.getConfigTarget();
info = configTarget.getDistributedVirtualPortgroup()
.stream()
.filter(d -> {
return portGroupIds.contains(d.getPortgroupKey());
})
.findFirst()
.orElse(null);
} catch (Exception e) {
logger.error("getDistributedPortBackingInfo::Failed to get dvportgroup info.", e);
}
if (info == null) {
throw new IllegalArgumentException("getDistributedPortBackingInfo::The port group "
+ "information is not found for key: " + portGroupKey);
}
portGroupKey = info.getPortgroupKey();
dvsUuid = info.getSwitchUuid();
}
port.setPortgroupKey(portGroupKey);
port.setSwitchUuid(dvsUuid);
VirtualEthernetCardDistributedVirtualPortBackingInfo backing =
new VirtualEthernetCardDistributedVirtualPortBackingInfo();
backing.setPort(port);
return backing;
}
开发者ID:vmware,项目名称:photon-model,代码行数:54,代码来源:NetworkDeviceBackingFactory.java
注:本文中的com.vmware.vim25.DistributedVirtualSwitchPortConnection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论