本文整理汇总了Java中com.vmware.vim25.VirtualEthernetCardNetworkBackingInfo.setDeviceName方法的典型用法代码示例。如果您正苦于以下问题:Java VirtualEthernetCardNetworkBackingInfo.setDeviceName方法的具体用法?Java VirtualEthernetCardNetworkBackingInfo.setDeviceName怎么用?Java VirtualEthernetCardNetworkBackingInfo.setDeviceName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vmware.vim25.VirtualEthernetCardNetworkBackingInfo
的用法示例。
在下文中一共展示了VirtualEthernetCardNetworkBackingInfo.setDeviceName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: replaceNetworkAdapter
import com.vmware.vim25.VirtualEthernetCardNetworkBackingInfo; //导入方法依赖的package包/类
private static void replaceNetworkAdapter(
VirtualMachineConfigSpec vmConfigSpec, VirtualDevice oldNIC,
ManagedObjectReference newNetworkRef, String newNetworkName)
throws Exception {
logger.debug("new network: " + newNetworkName);
VirtualEthernetCardNetworkBackingInfo nicBacking = new VirtualEthernetCardNetworkBackingInfo();
nicBacking.setDeviceName(newNetworkName);
nicBacking.setNetwork(newNetworkRef);
nicBacking.setUseAutoDetect(true);
oldNIC.setBacking(nicBacking);
VirtualDeviceConnectInfo info = new VirtualDeviceConnectInfo();
info.setConnected(true);
info.setStartConnected(true);
info.setAllowGuestControl(true);
oldNIC.setConnectable(info);
// oldNIC.getConnectable().setConnected(true);
// oldNIC.getConnectable().setStartConnected(true);
VirtualDeviceConfigSpec vmDeviceSpec = new VirtualDeviceConfigSpec();
vmDeviceSpec.setOperation(VirtualDeviceConfigSpecOperation.EDIT);
vmDeviceSpec.setDevice(oldNIC);
vmConfigSpec.getDeviceChange().add(vmDeviceSpec);
}
示例2: editEthernetCards
import com.vmware.vim25.VirtualEthernetCardNetworkBackingInfo; //导入方法依赖的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;
}
示例3: createNicSpec
import com.vmware.vim25.VirtualEthernetCardNetworkBackingInfo; //导入方法依赖的package包/类
static VirtualDeviceConfigSpec createNicSpec(String netName,
String nicName) throws Exception
{
VirtualDeviceConfigSpec nicSpec =
new VirtualDeviceConfigSpec();
nicSpec.setOperation(VirtualDeviceConfigSpecOperation.add);
VirtualEthernetCard nic = new VirtualPCNet32();
VirtualEthernetCardNetworkBackingInfo nicBacking =
new VirtualEthernetCardNetworkBackingInfo();
nicBacking.setDeviceName(netName);
Description info = new Description();
info.setLabel(nicName);
info.setSummary(netName);
nic.setDeviceInfo(info);
// type: "generated", "manual", "assigned" by VC
nic.setAddressType("generated");
nic.setBacking(nicBacking);
nic.setKey(0);
nicSpec.setDevice(nic);
return nicSpec;
}
示例4: prepareNicDevice
import com.vmware.vim25.VirtualEthernetCardNetworkBackingInfo; //导入方法依赖的package包/类
public static VirtualDevice prepareNicDevice(VirtualMachineMO vmMo, ManagedObjectReference morNetwork, VirtualEthernetCardType deviceType, String portGroupName,
String macAddress, int contextNumber, boolean connected, boolean connectOnStart) throws Exception {
VirtualEthernetCard nic = createVirtualEthernetCard(deviceType);
VirtualEthernetCardNetworkBackingInfo nicBacking = new VirtualEthernetCardNetworkBackingInfo();
nicBacking.setDeviceName(portGroupName);
nicBacking.setNetwork(morNetwork);
nic.setBacking(nicBacking);
nic.setAddressType("Manual");
nic.setConnectable(getVirtualDeviceConnectInfo(connected, connectOnStart));
nic.setMacAddress(macAddress);
nic.setKey(-contextNumber);
return nic;
}
示例5: getStandardNetworkBackingInfo
import com.vmware.vim25.VirtualEthernetCardNetworkBackingInfo; //导入方法依赖的package包/类
/**
* Backing info for existing network
*/
private static VirtualEthernetCardNetworkBackingInfo getStandardNetworkBackingInfo(
String name) {
VirtualEthernetCardNetworkBackingInfo backing = new VirtualEthernetCardNetworkBackingInfo();
backing.setDeviceName(name);
return backing;
}
示例6: getEth
import com.vmware.vim25.VirtualEthernetCardNetworkBackingInfo; //导入方法依赖的package包/类
private VirtualEthernetCard getEth(String fileName, String addressType, Integer key) {
VirtualEthernetCardNetworkBackingInfo nicBacking = new VirtualEthernetCardNetworkBackingInfo();
nicBacking.setDeviceName(fileName);
VirtualEthernetCard nic = new VirtualPCNet32();
nic.setBacking(nicBacking);
nic.setAddressType(addressType);
nic.setKey(key);
return nic;
}
示例7: getNICDeviceConfigSpec
import com.vmware.vim25.VirtualEthernetCardNetworkBackingInfo; //导入方法依赖的package包/类
static VirtualDeviceConfigSpec getNICDeviceConfigSpec(
VirtualMachine vm, String op, String name)
throws Exception
{
VirtualDeviceConfigSpec nicSpec =
new VirtualDeviceConfigSpec();
VirtualMachineConfigInfo vmConfigInfo = vm.getConfig();
if("add".equalsIgnoreCase(op)
&& doesNetworkNameExist(vm, name))
{
nicSpec.setOperation(VirtualDeviceConfigSpecOperation.add);
VirtualEthernetCard nic = new VirtualPCNet32();
VirtualEthernetCardNetworkBackingInfo nicBacking =
new VirtualEthernetCardNetworkBackingInfo();
nicBacking.setDeviceName(name);
nic.setAddressType("generated");
nic.setBacking(nicBacking);
nic.setKey(4);
nicSpec.setDevice(nic);
return nicSpec;
}
else if("remove".equalsIgnoreCase(op))
{
VirtualDevice [] vds =
vmConfigInfo.getHardware().getDevice();
nicSpec.setOperation(
VirtualDeviceConfigSpecOperation.remove);
for(int i=0;i<vds.length;i++)
{
if((vds[i] instanceof VirtualEthernetCard) &&
(vds[i].getDeviceInfo().getLabel().equalsIgnoreCase(
name)))
{
nicSpec.setDevice(vds[i]);
return nicSpec;
}
}
}
return null;
}
示例8: updateNicDevice
import com.vmware.vim25.VirtualEthernetCardNetworkBackingInfo; //导入方法依赖的package包/类
public static void updateNicDevice(VirtualDevice nic, ManagedObjectReference morNetwork, String portGroupName) throws Exception {
VirtualEthernetCardNetworkBackingInfo nicBacking = new VirtualEthernetCardNetworkBackingInfo();
nicBacking.setDeviceName(portGroupName);
nicBacking.setNetwork(morNetwork);
nic.setBacking(nicBacking);
}
示例9: plugPublicNic
import com.vmware.vim25.VirtualEthernetCardNetworkBackingInfo; //导入方法依赖的package包/类
private void plugPublicNic(VirtualMachineMO vmMo, final String vlanId, final IpAddressTO ipAddressTO) throws Exception {
// TODO : probably need to set traffic shaping
Pair<ManagedObjectReference, String> networkInfo = null;
VirtualSwitchType vSwitchType = VirtualSwitchType.StandardVirtualSwitch;
if (_publicTrafficInfo != null) {
vSwitchType = _publicTrafficInfo.getVirtualSwitchType();
}
/** FIXME We have no clue which network this nic is on and that means that we can't figure out the BroadcastDomainType
* so we assume that it's VLAN for now
*/
if (VirtualSwitchType.StandardVirtualSwitch == vSwitchType) {
networkInfo = HypervisorHostHelper.prepareNetwork(_publicTrafficInfo.getVirtualSwitchName(),
"cloud.public", vmMo.getRunningHost(), vlanId, ipAddressTO.getNetworkRate(), null,
_opsTimeout, true, BroadcastDomainType.Vlan, null, null);
} else {
networkInfo =
HypervisorHostHelper.prepareNetwork(_publicTrafficInfo.getVirtualSwitchName(), "cloud.public", vmMo.getRunningHost(), vlanId, null, ipAddressTO.getNetworkRate(), null,
_opsTimeout, vSwitchType, _portsPerDvPortGroup, null, false, BroadcastDomainType.Vlan, _vsmCredentials, null);
}
int nicIndex = allocPublicNicIndex(vmMo);
try {
VirtualDevice[] nicDevices = vmMo.getNicDevices();
VirtualEthernetCard device = (VirtualEthernetCard)nicDevices[nicIndex];
if (VirtualSwitchType.StandardVirtualSwitch == vSwitchType) {
VirtualEthernetCardNetworkBackingInfo nicBacking = new VirtualEthernetCardNetworkBackingInfo();
nicBacking.setDeviceName(networkInfo.second());
nicBacking.setNetwork(networkInfo.first());
device.setBacking(nicBacking);
} else {
HostMO hostMo = vmMo.getRunningHost();
DatacenterMO dataCenterMo = new DatacenterMO(hostMo.getContext(), hostMo.getHyperHostDatacenter());
device.setBacking(dataCenterMo.getDvPortBackingInfo(networkInfo));
}
VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec();
//VirtualDeviceConfigSpec[] deviceConfigSpecArray = new VirtualDeviceConfigSpec[1];
VirtualDeviceConfigSpec deviceConfigSpec = new VirtualDeviceConfigSpec();
deviceConfigSpec.setDevice(device);
deviceConfigSpec.setOperation(VirtualDeviceConfigSpecOperation.EDIT);
vmConfigSpec.getDeviceChange().add(deviceConfigSpec);
if (!vmMo.configureVm(vmConfigSpec)) {
throw new Exception("Failed to configure devices when plugPublicNic");
}
} catch (Exception e) {
// restore allocation mask in case of exceptions
String nicMasksStr = vmMo.getCustomFieldValue(CustomFieldConstants.CLOUD_NIC_MASK);
int nicMasks = Integer.parseInt(nicMasksStr);
nicMasks &= ~(1 << nicIndex);
vmMo.setCustomFieldValue(CustomFieldConstants.CLOUD_NIC_MASK, String.valueOf(nicMasks));
throw e;
}
}