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


Java VirtualMachine类代码示例

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


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

示例1: createCustomizationAdapterMappings

import com.vmware.vim25.mo.VirtualMachine; //导入依赖的package包/类
protected List<CustomizationAdapterMapping> createCustomizationAdapterMappings(
        VmwareProcessClient vmwareProcessClient, VirtualMachine machine) {

    List<CustomizationAdapterMapping> nicSettingMap = new ArrayList<CustomizationAdapterMapping>();

    // VirtualEthernetCardを取得
    VirtualMachineConfigInfo configInfo = machine.getConfig();
    for (VirtualDevice device : configInfo.getHardware().getDevice()) {
        if (device instanceof VirtualEthernetCard) {
            VirtualEthernetCard virtualEthernetCard = VirtualEthernetCard.class.cast(device);
            CustomizationAdapterMapping mapping = new CustomizationAdapterMapping();
            CustomizationIPSettings settings = new CustomizationIPSettings();

            // すべてのNICをDHCPにする
            CustomizationDhcpIpGenerator dhcpIp = new CustomizationDhcpIpGenerator();
            settings.setIp(dhcpIp);

            mapping.setMacAddress(virtualEthernetCard.getMacAddress());
            mapping.setAdapter(settings);
            nicSettingMap.add(mapping);
        }
    }

    return nicSettingMap;
}
 
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:26,代码来源:VmwareCustomizeProcess.java

示例2: findVMNotOnHost

import com.vmware.vim25.mo.VirtualMachine; //导入依赖的package包/类
private static String findVMNotOnHost(HostSystem host) throws RemoteException {
  VirtualMachine[] hostVMs = host.getVms();
  boolean foundMatch = false;
  String targetVM = null;
  for (String vmName : vmNames) {
    for (VirtualMachine vm : hostVMs) {
      if (vmName.equals(vm.getName())) {
        foundMatch = true;
        break;
      }
    }
    if (!foundMatch) {
      targetVM = vmName;
      break;
    }
    foundMatch = false;
  }
  return targetVM;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:20,代码来源:VIJavaUtil.java

示例3: destroyNode

import com.vmware.vim25.mo.VirtualMachine; //导入依赖的package包/类
@Override
public void destroyNode(String vmName) {
   try (VSphereServiceInstance instance = serviceInstance.get();) {
      VirtualMachine virtualMachine = getVM(vmName, instance.getInstance().getRootFolder());
      Task powerOffTask = virtualMachine.powerOffVM_Task();
      if (powerOffTask.waitForTask().equals(Task.SUCCESS))
         logger.debug(String.format("VM %s powered off", vmName));
      else
         logger.debug(String.format("VM %s could not be powered off", vmName));

      Task destroyTask = virtualMachine.destroy_Task();
      if (destroyTask.waitForTask().equals(Task.SUCCESS))
         logger.debug(String.format("VM %s destroyed", vmName));
      else
         logger.debug(String.format("VM %s could not be destroyed", vmName));
   } catch (Exception e) {
      logger.error("Can't destroy vm " + vmName, e);
      Throwables.propagateIfPossible(e);
   }
}
 
开发者ID:igreenfield,项目名称:jcloud-vsphere,代码行数:21,代码来源:VSphereComputeServiceAdapter.java

示例4: resumeNode

import com.vmware.vim25.mo.VirtualMachine; //导入依赖的package包/类
@Override
public void resumeNode(String vmName) {
   VirtualMachine virtualMachine = getNode(vmName);

   if (virtualMachine.getRuntime().getPowerState().equals(VirtualMachinePowerState.poweredOff)) {
      try {
         Task task = virtualMachine.powerOnVM_Task(null);
         if (task.waitForTask().equals(Task.SUCCESS))
            logger.debug(virtualMachine.getName() + " resumed");
      } catch (Exception e) {
         logger.error("Can't resume vm " + vmName, e);
         propagate(e);
      }

   } else
      logger.debug(vmName + " can't be resumed");
}
 
开发者ID:igreenfield,项目名称:jcloud-vsphere,代码行数:18,代码来源:VSphereComputeServiceAdapter.java

示例5: load

import com.vmware.vim25.mo.VirtualMachine; //导入依赖的package包/类
@Override
public Optional<VirtualMachine> load(String vmName) {
   Optional<VirtualMachine> results = Optional.absent();
   try (VSphereServiceInstance instance = serviceInstance.get();) {
      VirtualMachine vm = (VirtualMachine) new InventoryNavigator(instance.getInstance().getRootFolder()).searchManagedEntity("VirtualMachine", vmName);
      if (VSpherePredicate.isTemplatePredicate.apply(vm)) {
         results = Optional.of(vm);
      }
   } catch (Exception e) {
      logger.error("Can't find template " + vmName, e);
      Throwables.propagateIfPossible(e);

   }

   return results;
}
 
开发者ID:igreenfield,项目名称:jcloud-vsphere,代码行数:17,代码来源:VSphereTemplateLoader.java

示例6: getCurrentSnapshotOrCreate

import com.vmware.vim25.mo.VirtualMachine; //导入依赖的package包/类
private VirtualMachineSnapshot getCurrentSnapshotOrCreate(String snapshotName, String snapshotDescription,
                                                          VirtualMachine master) throws InvalidName, VmConfigFault, SnapshotFault, TaskInProgress, FileFault,
        InvalidState, RuntimeFault, RemoteException {
   if (master.getSnapshot() == null) {
      Task task = master.createSnapshot_Task(snapshotName, snapshotDescription, false, false);
      try {
         if (task.waitForTask().equals(Task.SUCCESS)) {
            logger.debug(String.format("snapshot taken for '%s'", master.getName()));
         }
      } catch (Exception e) {
         logger.debug(String.format("Can't take snapshot for '%s'", master.getName()), e);
         throw propagate(e);
      }
   } else
      logger.debug(String.format("snapshot already available for '%s'", master.getName()));
   return master.getCurrentSnapShot();
}
 
开发者ID:igreenfield,项目名称:jcloud-vsphere,代码行数:18,代码来源:MasterToVirtualMachineCloneSpec.java

示例7: waitForStopped

import com.vmware.vim25.mo.VirtualMachine; //导入依赖的package包/类
public void waitForStopped(String machineName) {
    VirtualMachine machine = getVirtualMachine(machineName);

    // 停止判定処理
    while (true) {
        try {
            Thread.sleep(30 * 1000L);
        } catch (InterruptedException ignore) {
        }

        VirtualMachineRuntimeInfo runtimeInfo = machine.getRuntime();

        if (runtimeInfo.getPowerState() == VirtualMachinePowerState.poweredOff) {
            break;
        }
    }
}
 
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:18,代码来源:VmwareProcessClient.java

示例8: getSCSIController

import com.vmware.vim25.mo.VirtualMachine; //导入依赖的package包/类
protected VirtualSCSIController getSCSIController(VirtualMachine machine) {
    // 仮想マシンにあるSCSIコントローラのうち、BusNumberが0のものを取得する
    VirtualSCSIController scsiController = null;
    for (VirtualDevice device : machine.getConfig().getHardware().getDevice()) {
        if (device instanceof VirtualSCSIController) {
            VirtualSCSIController scsiController2 = VirtualSCSIController.class.cast(device);
            if (scsiController2.getBusNumber() == 0) {
                scsiController = scsiController2;
                break;
            }
        }
    }

    if (scsiController == null) {
        // SCSIコントローラが見つからない場合
        // TODO: SCSIコントローラを作る?
        throw new AutoException("EPROCESS-000517", 0);
    }

    return scsiController;
}
 
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:22,代码来源:VmwareProcessClient.java

示例9: getVirtualDisk

import com.vmware.vim25.mo.VirtualMachine; //导入依赖的package包/类
protected VirtualDisk getVirtualDisk(VirtualMachine machine, Integer scsiId) {
    // SCSIコントローラを取得
    VirtualSCSIController scsiController = getSCSIController(machine);

    // SCSIコントローラとSCSI IDが一致するディスクを取得
    VirtualDisk disk = null;
    for (VirtualDevice device : machine.getConfig().getHardware().getDevice()) {
        if (device instanceof VirtualDisk) {
            VirtualDisk tmpDisk = VirtualDisk.class.cast(device);
            if (tmpDisk.getControllerKey() != null && tmpDisk.getControllerKey().equals(scsiController.getKey())) {
                if (tmpDisk.getUnitNumber() != null && tmpDisk.getUnitNumber().equals(scsiId)) {
                    disk = tmpDisk;
                    break;
                }
            }
        }
    }

    if (disk == null) {
        // VirtualDiskが見つからない場合
        throw new AutoException("EPROCESS-000518", scsiId);
    }

    return disk;
}
 
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:26,代码来源:VmwareProcessClient.java

示例10: editEthernetCards

import com.vmware.vim25.mo.VirtualMachine; //导入依赖的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

示例11: getDVPortgroupInfo

import com.vmware.vim25.mo.VirtualMachine; //导入依赖的package包/类
public DistributedVirtualPortgroupInfo getDVPortgroupInfo(VirtualMachine machine, String networkName) {
    HostSystem host = new HostSystem(machine.getServerConnection(), machine.getRuntime().getHost());
    ComputeResource computeResource = (ComputeResource) host.getParent();
    EnvironmentBrowser envBrowser = computeResource.getEnvironmentBrowser();

    DistributedVirtualPortgroupInfo dvPortgroupInfo = null;
    try {
        ConfigTarget configTarget = envBrowser.queryConfigTarget(host);

        // 分散ポートグループの場合
        if (configTarget.getDistributedVirtualPortgroup() != null) {
            // 分散ポートグループ情報を取得
            dvPortgroupInfo = findDVPortgroupInfo(configTarget.getDistributedVirtualPortgroup(), networkName);
        }
    } catch (RemoteException e) {
        throw new RuntimeException(e);
    }

    return dvPortgroupInfo;
}
 
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:21,代码来源:VmwareNetworkProcess.java

示例12: updateCustomValue

import com.vmware.vim25.mo.VirtualMachine; //导入依赖的package包/类
/**
 * TODO: メソッドコメントを記述
 *
 * @param vmwareProcessClient
 * @param instanceNo
 */
public void updateCustomValue(VmwareProcessClient vmwareProcessClient, Long instanceNo) {
    // カスタムフィールドがない場合は作成
    CustomFieldDef customFieldDef = vmwareProcessClient.getCustomFieldDef(fieldUserName, VirtualMachine.class);
    if (customFieldDef == null) {
        vmwareProcessClient.addCustomFieldDef(fieldUserName, VirtualMachine.class);
    }

    VmwareInstance vmwareInstance = vmwareInstanceDao.read(instanceNo);
    Instance instance = instanceDao.read(instanceNo);
    Farm farm = farmDao.read(instance.getFarmNo());
    User user = userDao.read(farm.getUserNo());

    // カスタムフィールドの値を設定
    vmwareProcessClient.setCustomValue(vmwareInstance.getMachineName(), fieldUserName, user.getUsername());
}
 
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:22,代码来源:VmwareMachineProcess.java

示例13: doesNetworkNameExist

import com.vmware.vim25.mo.VirtualMachine; //导入依赖的package包/类
static boolean doesNetworkNameExist(VirtualMachine vm, 
    String netName) throws Exception 
{
  VirtualMachineRuntimeInfo vmRuntimeInfo = vm.getRuntime();
  EnvironmentBrowser envBrowser = vm.getEnvironmentBrowser();
  ManagedObjectReference hmor = vmRuntimeInfo.getHost();

  HostSystem host = new HostSystem(
      vm.getServerConnection(), hmor);
  ConfigTarget cfg = envBrowser.queryConfigTarget(host);
  VirtualMachineNetworkInfo[] nets = cfg.getNetwork();
  for (int i = 0; nets!=null && i < nets.length; i++) 
  {
    NetworkSummary netSummary = nets[i].getNetwork();
    if (netSummary.isAccessible() && 
        netSummary.getName().equalsIgnoreCase(netName)) 
    {
      return true;
    }
  }
  return false;
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:23,代码来源:VmNicOp.java

示例14: getSnapshotInTree

import com.vmware.vim25.mo.VirtualMachine; //导入依赖的package包/类
static VirtualMachineSnapshot getSnapshotInTree(
    VirtualMachine vm, String snapName)
{
  if (vm == null || snapName == null) 
  {
    return null;
  }

  VirtualMachineSnapshotTree[] snapTree = 
      vm.getSnapshot().getRootSnapshotList();
  if(snapTree!=null)
  {
    ManagedObjectReference mor = findSnapshotInTree(
        snapTree, snapName);
    if(mor!=null)
    {
      return new VirtualMachineSnapshot(
          vm.getServerConnection(), mor);
    }
  }
  return null;
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:23,代码来源:VMSnapshot.java

示例15: createRemoveDiskConfigSpec

import com.vmware.vim25.mo.VirtualMachine; //导入依赖的package包/类
static VirtualDeviceConfigSpec createRemoveDiskConfigSpec(
    VirtualMachine vm, String diskName) throws Exception
{
  VirtualDeviceConfigSpec diskSpec = new VirtualDeviceConfigSpec();      
  VirtualDisk disk = (VirtualDisk) findVirtualDevice(vm.getConfig(), diskName);
    
  if(disk != null)
  {
    diskSpec.setOperation(VirtualDeviceConfigSpecOperation.remove);           
    diskSpec.setFileOperation(VirtualDeviceConfigSpecFileOperation.destroy);           
    diskSpec.setDevice(disk);
    return diskSpec;
  }
  else 
  {
    System.out.println("No device found: " + diskName);
    return null;
  }
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:20,代码来源:VmDiskOp.java


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