本文整理汇总了Java中com.vmware.vim25.DistributedVirtualSwitchPortConnection.setPortgroupKey方法的典型用法代码示例。如果您正苦于以下问题:Java DistributedVirtualSwitchPortConnection.setPortgroupKey方法的具体用法?Java DistributedVirtualSwitchPortConnection.setPortgroupKey怎么用?Java DistributedVirtualSwitchPortConnection.setPortgroupKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vmware.vim25.DistributedVirtualSwitchPortConnection
的用法示例。
在下文中一共展示了DistributedVirtualSwitchPortConnection.setPortgroupKey方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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);
}
示例4: 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;
}