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


Java Folder类代码示例

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


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

示例1: migrateVM

import com.vmware.vim25.mo.Folder; //导入依赖的package包/类
private static boolean migrateVM(String targetVMName, String newHostName,
    boolean tryAnotherVM, boolean tryAnotherHost) throws Exception {
  ServiceInstance si = new ServiceInstance(new URL(url), username, password,
      true);

  try {
    Folder rootFolder = si.getRootFolder();
    HostSystem newHost = (HostSystem)new InventoryNavigator(rootFolder)
        .searchManagedEntity("HostSystem", newHostName);
    
    return migrateVM(si, rootFolder, newHost, targetVMName, newHostName,
        tryAnotherVM, tryAnotherHost);
  } finally {
    si.getServerConnection().logout();
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:17,代码来源:VIJavaUtil.java

示例2: doMigrateVM

import com.vmware.vim25.mo.Folder; //导入依赖的package包/类
private static synchronized boolean doMigrateVM(String targetVMName,
    String newHostName) throws Exception {
  ServiceInstance si = new ServiceInstance(new URL(url), username, password,
      true);
  try {
    Folder rootFolder = si.getRootFolder();
    InventoryNavigator in = new InventoryNavigator(rootFolder);
    HostSystem newHost = (HostSystem)in.searchManagedEntity("HostSystem",
        newHostName);
    if (newHost == null) {
      throw new TestException("Could not find host " + newHostName + " as a target host for vMotion.");
    }

    return migrateVM(si, rootFolder, newHost, targetVMName, newHostName);

  } finally {
    si.getServerConnection().logout();
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:20,代码来源:VIJavaUtil.java

示例3: HydraTask_migrateNetDownVM

import com.vmware.vim25.mo.Folder; //导入依赖的package包/类
public static void HydraTask_migrateNetDownVM() throws Exception {
  SharedMap sMap = VMotionBB.getBB().getSharedMap();

  Boolean bool = (Boolean)sMap.get("connectionDropped");
  if (bool == null || !bool) {
    return;
  }

  initializeParams();
  if (!validateParams()) {
    return;
  }

  ServiceInstance si = new ServiceInstance(new URL(url), username, password,
      true);

  try {
    Folder rootFolder = si.getRootFolder();
    HostSystem newHost = (HostSystem)new InventoryNavigator(rootFolder)
        .searchManagedEntity("HostSystem", hostNames[0]);
    migrateVM(si, rootFolder, newHost, vmNames[0], hostNames[0], false, false);
  } finally {
    si.getServerConnection().logout();
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:26,代码来源:VIJavaUtil.java

示例4: tryFindResourcePool

import com.vmware.vim25.mo.Folder; //导入依赖的package包/类
private Optional<ResourcePool> tryFindResourcePool(Folder folder, String hostname) {
   Iterable<ResourcePool> resourcePools = ImmutableSet.<ResourcePool>of();
   try {
      ManagedEntity[] resourcePoolEntities = new InventoryNavigator(folder).searchManagedEntities("ResourcePool");
      resourcePools = Iterables.transform(Arrays.asList(resourcePoolEntities), new Function<ManagedEntity, ResourcePool>() {
         public ResourcePool apply(ManagedEntity input) {
            return (ResourcePool) input;
         }
      });
      Optional<ResourcePool> optionalResourcePool = Iterables.tryFind(resourcePools, VSpherePredicate.isResourcePoolOf(hostname));
      return optionalResourcePool;
   } catch (Exception e) {
      logger.error("Problem in finding a valid resource pool", e);
   }
   return Optional.absent();
}
 
开发者ID:igreenfield,项目名称:jcloud-vsphere,代码行数:17,代码来源:VSphereComputeServiceAdapter.java

示例5: populateMetrics

import com.vmware.vim25.mo.Folder; //导入依赖的package包/类
private void populateMetrics(Folder rootFolder, List<Map<String, Object>> hostConfigs, Map<Pattern, String> replacers, Integer hostThreads, Integer vmThreads) {

        List<ManagedEntity> hostEntities = getHostMachines(rootFolder, hostConfigs);

        if (logger.isDebugEnabled()) {
            logger.debug("Found " + hostEntities.size() + " hosts");
            StringBuilder sb = new StringBuilder();
            for (ManagedEntity managedEntity : hostEntities) {
                if (sb.length() > 0) {
                    sb.append(",");
                }
                sb.append(managedEntity.getName());
            }
            logger.debug("Host machines [ " + sb.toString() + " ]");
        }

        HostMetricCollector hostMetricCollector = new HostMetricCollector(configuration.getMetricWriter(), configuration.getMetricPrefix(), hostEntities, hostConfigs, replacers, hostThreads, vmThreads);
        hostMetricCollector.execute();
    }
 
开发者ID:Appdynamics,项目名称:vmware-vsphere-monitoring-extension,代码行数:20,代码来源:VMWareMonitor.java

示例6: getHostMachines

import com.vmware.vim25.mo.Folder; //导入依赖的package包/类
private List<ManagedEntity> getHostMachines(Folder rootFolder, List<Map<String, Object>> hostConfigs) {
    List<ManagedEntity> hostEntities = new ArrayList<ManagedEntity>();

    for (Map<String, Object> hostConfig : hostConfigs) {
        String hostName = (String) hostConfig.get("host");
        try {
            if ("*".equals(hostName)) {
                hostEntities = Arrays.asList(new InventoryNavigator(rootFolder).searchManagedEntities("HostSystem"));
            } else {
                ManagedEntity hostSystem = new InventoryNavigator(rootFolder).searchManagedEntity("HostSystem", hostName);
                if (hostSystem != null) {
                    hostEntities.add(hostSystem);
                } else {
                    logger.error("Could not find Host with name " + hostName);
                }
            }
        } catch (InvalidProperty invalidProperty) {
            logger.error("Unable to get the host details", invalidProperty);
        } catch (RuntimeFault runtimeFault) {
            logger.error("Unable to get the host details", runtimeFault);
        } catch (RemoteException e) {
            logger.error("Unable to get the host details", e);
        }
    }
    return hostEntities;
}
 
开发者ID:Appdynamics,项目名称:vmware-vsphere-monitoring-extension,代码行数:27,代码来源:VMWareMonitor.java

示例7: dummyVMotion

import com.vmware.vim25.mo.Folder; //导入依赖的package包/类
private static void dummyVMotion(ServiceInstance si, Folder rootFolder,
    HostSystem newHost, String targetVMName, String newHostName) {
  log("Selected host [vm] for vMotion: " + newHostName + " [" + targetVMName
      + "]");
  try {Thread.sleep(120000);} catch(InterruptedException ir) {}
  log("vMotion of " + targetVMName + " to " + newHostName
      + " completed");
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:9,代码来源:VMotionTrigger.java

示例8: migrateVM

import com.vmware.vim25.mo.Folder; //导入依赖的package包/类
private static boolean migrateVM(ServiceInstance si, Folder rootFolder,
    HostSystem newHost, String targetVMName, String newHostName)
    throws Exception {

  log("Selected host [vm] for vMotion: " + newHostName + " [" + targetVMName
      + "]");
  VirtualMachine vm = (VirtualMachine)new InventoryNavigator(rootFolder)
      .searchManagedEntity("VirtualMachine", targetVMName);
  if (vm == null) {
    log(WARNING, "Could not resolve VM " + targetVMName + ", vMotion of this VM cannot be performed.");
    return false;
  }

  ComputeResource cr = (ComputeResource)newHost.getParent();

  String[] checks = new String[] { "cpu", "software" };
  HostVMotionCompatibility[] vmcs = si.queryVMotionCompatibility(vm,
      new HostSystem[] { newHost }, checks);

  String[] comps = vmcs[0].getCompatibility();
  if (checks.length != comps.length) {
    log(WARNING, "CPU/software NOT compatible, vMotion failed.");
    return false;
  }

  long start = System.currentTimeMillis();
  Task task = vm.migrateVM_Task(cr.getResourcePool(), newHost,
      VirtualMachineMovePriority.highPriority,
      VirtualMachinePowerState.poweredOn);
  if (task.waitForMe() == Task.SUCCESS) {
    long end = System.currentTimeMillis();
    log("vMotion of " + targetVMName + " to " + newHostName
        + " completed in " + (end - start) + "ms. Task result: "
        + task.getTaskInfo().getResult());
    return true;
  } else {
    TaskInfo info = task.getTaskInfo();
    log(WARNING, "vMotion of " + targetVMName + " to " + newHostName
        + " failed. Error details: " + info.getError().getFault());
    return false;
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:43,代码来源:VMotionTrigger.java

示例9: validateVMNotOnHost

import com.vmware.vim25.mo.Folder; //导入依赖的package包/类
private static boolean validateVMNotOnHost(ServiceInstance si,
    Folder rootFolder, HostSystem newHost, String vmName, String hostName)
    throws Exception {
  VirtualMachine[] vms = newHost.getVms();
  for (VirtualMachine vmac : vms) {
    if (vmac.getName().equals(vmName)) {
      Log.getLogWriter().info(
          vmName + " is already running on target host " + hostName
              + ". Selecting another pair...");
      return false;
    }
  }
  return true;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:15,代码来源:VIJavaUtil.java

示例10: main

import com.vmware.vim25.mo.Folder; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    ServiceInstance si = new ServiceInstance(new URL(
            "https://10.120.30.40/sdk"), "[email protected]",
            "Administrator!23", true);
    // Get the rootFolder
    Folder rootFolder = si.getRootFolder();

    // Get all the hosts in the vCenter server
    ManagedEntity[] hosts = new InventoryNavigator(rootFolder)
            .searchManagedEntities("HostSystem");

    if (hosts == null) {
        System.out.println("Host not found on vCenter");
        si.getServerConnection().logout();
        return;
    }

    // Map to store the datastore name as key and its UUID as the value
    Map< String , String> vmfsdatastoreUUIDs = new HashMap< String , String>();

    // Map to store host as key and all of its datastores as the value
    Map< ManagedEntity , Datastore[]> hostDatastores = new HashMap< ManagedEntity , Datastore[]>();
    for (ManagedEntity hostSystem : hosts) {
        HostDatastoreBrowser hdb = ((HostSystem) hostSystem)
                .getDatastoreBrowser();
        Datastore[] ds = hdb.getDatastores();
        hostDatastores.put(hostSystem, ds);
    }

    System.out.println("Hosts and all of its associated datastores");
    for (Map.Entry < ManagedEntity , Datastore[]> datastores : hostDatastores
            .entrySet()) {
        System.out.println("");
        System.out.print("[" + datastores.getKey().getName() + "::");
        for (Datastore datastore : datastores.getValue()) {
            System.out.print(datastore.getName() + ",");
            DatastoreInfo dsinfo = datastore.getInfo();
            if (dsinfo instanceof VmfsDatastoreInfo) {
                VmfsDatastoreInfo vdinfo = (VmfsDatastoreInfo) dsinfo;
                vmfsdatastoreUUIDs.put(datastore.getName(), vdinfo
                        .getVmfs().getUuid());
            }

        }
        System.out.print("]");
    }
    System.out.println(" ");
    System.out.println("Datastore and its UUID");
    for (Map.Entry< String , String> dsuuid : vmfsdatastoreUUIDs.entrySet()) {
        System.out.println("[" + dsuuid.getKey() + "::" + dsuuid.getValue()
                + "]");
    }
    si.getServerConnection().logout();

}
 
开发者ID:vThinkBeyondVM,项目名称:vThinkBVM-scripts,代码行数:56,代码来源:findVMFSUUIDs.java

示例11: listNodes

import com.vmware.vim25.mo.Folder; //导入依赖的package包/类
private Iterable<VirtualMachine> listNodes(VSphereServiceInstance instance) {
   Iterable<VirtualMachine> vms = ImmutableSet.of();
   try {
      Folder nodesFolder = instance.getInstance().getRootFolder();
      ManagedEntity[] managedEntities = new InventoryNavigator(nodesFolder).searchManagedEntities("VirtualMachine");
      vms = Iterables.transform(Arrays.asList(managedEntities), new Function<ManagedEntity, VirtualMachine>() {
         public VirtualMachine apply(ManagedEntity input) {
            return (VirtualMachine) input;
         }
      });
   } catch (Throwable e) {
      logger.error("Can't find vm", e);
   }
   return vms;
}
 
开发者ID:igreenfield,项目名称:jcloud-vsphere,代码行数:16,代码来源:VSphereComputeServiceAdapter.java

示例12: listNodesByIds

import com.vmware.vim25.mo.Folder; //导入依赖的package包/类
@Override
   public Iterable<VirtualMachine> listNodesByIds(Iterable<String> ids) {

      Iterable<VirtualMachine> vms = ImmutableSet.of();
      try (VSphereServiceInstance instance = serviceInstance.get();) {
         Folder nodesFolder = instance.getInstance().getRootFolder();
         List<List<String>> list = new ArrayList<List<String>>();
         Iterator<String> idsIterator = ids.iterator();

         while (idsIterator.hasNext()) {
            list.add(Lists.newArrayList("VirtualMachine", idsIterator.next()));
         }

         String[][] typeInfo = ListsUtils.ListToArray(list);

         ManagedEntity[] managedEntities = new InventoryNavigator(nodesFolder).searchManagedEntities(
                 typeInfo, true);
         vms = Iterables.transform(Arrays.asList(managedEntities), new Function<ManagedEntity, VirtualMachine>() {
            public VirtualMachine apply(ManagedEntity input) {
               return (VirtualMachine) input;
            }
         });
      } catch (Throwable e) {
         logger.error("Can't find vms ", e);
      }
      return vms;


//      Iterable<VirtualMachine> nodes = listNodes();
//      Iterable<VirtualMachine> selectedNodes = Iterables.filter(nodes, VSpherePredicate.isNodeIdInList(ids));
//      return selectedNodes;
   }
 
开发者ID:igreenfield,项目名称:jcloud-vsphere,代码行数:33,代码来源:VSphereComputeServiceAdapter.java

示例13: cloneMaster

import com.vmware.vim25.mo.Folder; //导入依赖的package包/类
private VirtualMachine cloneMaster(VirtualMachine master, String tag, String name, VirtualMachineCloneSpec cloneSpec, String folderName) {

      VirtualMachine cloned = null;
      try {
         FolderNameToFolderManagedEntity toFolderManagedEntity = new FolderNameToFolderManagedEntity(serviceInstance, master);
         Folder folder = toFolderManagedEntity.apply(folderName);
         Task task = master.cloneVM_Task(folder, name, cloneSpec);
         String result = task.waitForTask();
         if (result.equals(Task.SUCCESS)) {
            logger.trace("<< after clone search for VM with name: " + name);
            Retryer<VirtualMachine> retryer = RetryerBuilder.<VirtualMachine>newBuilder()
                    .retryIfResult(Predicates.<VirtualMachine>isNull())
                    .withStopStrategy(StopStrategies.stopAfterAttempt(5))
                    .retryIfException().withWaitStrategy(WaitStrategies.fixedWait(1, TimeUnit.SECONDS))
                    .build();
            cloned = retryer.call(new GetVirtualMachineCallable(name, folder, serviceInstance.get().getInstance().getRootFolder()));
         } else {
            String errorMessage = task.getTaskInfo().getError().getLocalizedMessage();
            logger.error(errorMessage);
         }
      } catch (Exception e) {
         if (e instanceof NoPermission){
            NoPermission noPermission = (NoPermission)e;
            logger.error("NoPermission: " + noPermission.getPrivilegeId());
         }
         logger.error("Can't clone vm: " + e.toString(), e);
         propagate(e);
      }
      if (cloned == null)
         logger.error("<< Failed to get cloned VM. " + name);
      return checkNotNull(cloned, "cloned");
   }
 
开发者ID:igreenfield,项目名称:jcloud-vsphere,代码行数:33,代码来源:VSphereComputeServiceAdapter.java

示例14: getVMwareTemplate

import com.vmware.vim25.mo.Folder; //导入依赖的package包/类
private VirtualMachine getVMwareTemplate(String imageName, Folder rootFolder) {
   VirtualMachine image = null;
   try {
      VirtualMachine node = getVM(imageName, rootFolder);
      if (VSpherePredicate.isTemplatePredicate.apply(node))
         image = node;
   } catch (Exception e) {
      logger.error("cannot find an image called " + imageName, e);
      propagate(e);
   }
   return checkNotNull(image, "image with name " + imageName + " not found.");
}
 
开发者ID:igreenfield,项目名称:jcloud-vsphere,代码行数:13,代码来源:VSphereComputeServiceAdapter.java

示例15: apply

import com.vmware.vim25.mo.Folder; //导入依赖的package包/类
@Override
public Folder apply(final String folderName) {
   try {
      if (Strings.isNullOrEmpty(folderName))
         return (Folder) master.getParent();
      VSphereServiceInstance instance = serviceInstance.get();
      ManagedEntity entity = new InventoryNavigator(instance.getInstance().getRootFolder()).searchManagedEntity("Folder", folderName);
      return (Folder) entity;
   } catch (Exception e) {
      logger.error("Problem in finding a valid Folder with name " + folderName, e);
   }
   return (Folder) master.getParent();
}
 
开发者ID:igreenfield,项目名称:jcloud-vsphere,代码行数:14,代码来源:FolderNameToFolderManagedEntity.java


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