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


Java ServiceInstance.getRootFolder方法代码示例

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


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

示例1: migrateVM

import com.vmware.vim25.mo.ServiceInstance; //导入方法依赖的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.ServiceInstance; //导入方法依赖的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.ServiceInstance; //导入方法依赖的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: connect

import com.vmware.vim25.mo.ServiceInstance; //导入方法依赖的package包/类
private void connect() {

        if (configuration != null && configuration.getConfigYml() != null) {
            Map<String, ?> config = configuration.getConfigYml();
            String host = (String) config.get("host");
            String username = (String) config.get("username");
            String password = getPassword(config);

            String url = "https://" + host + "/sdk";
            try {
                ServiceInstance serviceInstance = new ServiceInstance(new URL(url), username, password, true);
                rootFolder = serviceInstance.getRootFolder();
            } catch (Exception e) {
                logger.error("Unable to connect to the host [" + host + "]", e);
                throw new RuntimeException("Unable to connect to the host [" + host + "]", e);
            }
            logger.info("Connection to: " + url + " Successful");
        }
    }
 
开发者ID:Appdynamics,项目名称:vmware-vsphere-monitoring-extension,代码行数:20,代码来源:VMWareMonitor.java

示例5: inventoryNavigator

import com.vmware.vim25.mo.ServiceInstance; //导入方法依赖的package包/类
@Bean
@ConditionalOnProperty("vsphere.host")
InventoryNavigator inventoryNavigator(@Value("${vsphere.host}") String host,
        @Value("${vsphere.username}") String username,
        @Value("${vsphere.password}") String password) throws MalformedURLException,
        RemoteException {
    URL url = new URL(String.format("https://%s/sdk", host));
    ServiceInstance serviceInstance = new ServiceInstance(url, username, password, true);
    return new InventoryNavigator(serviceInstance.getRootFolder());
}
 
开发者ID:newrelic,项目名称:newrelic-pcf-drain,代码行数:11,代码来源:MonitoringConfiguration.java

示例6: main

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

示例7: main

import com.vmware.vim25.mo.ServiceInstance; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
  ServiceInstance si = new ServiceInstance(new URL("http://10.20.143.205/sdk"), "root", "password", true); 
  Folder rootFolder = si.getRootFolder();
  ManagedEntity[] vms = new InventoryNavigator(rootFolder).searchManagedEntities("VirtualMachine");
  ManagedEntity[] hosts = new InventoryNavigator(rootFolder).searchManagedEntities("HostSystem");

  CacheInstance vicf = new CacheInstance(si);
  vicf.watch(vms, new String[] {"name", "runtime.powerState", "summary"});
  vicf.watch(hosts, new String[] {"name", "summary"});
  vicf.start();

  //check if the caching is ready to use; otherwise wait
  while(!vicf.isReady()) 
  {
  	Thread.sleep(1000);
  }
  
  Thread[] vrs = new VimReader[2];

  for(int i=0; i<vrs.length; i++)
  {
    vrs[i] = new VimReader("Thread " + i, vicf, vms, hosts);
    vrs[i].start();
  }
  
  for(int i=0; i<vrs.length; i++)
  {
    vrs[i].join();
  }
  si.getServerConnection().logout();
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:33,代码来源:CacheFrameworkSample.java

示例8: main

import com.vmware.vim25.mo.ServiceInstance; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
  if(args.length!=3)
  {
    System.out.println("Usage: java CimTicket <url> " +
    		"<username> <password>");
    return;
  }
  String urlStr = args[0];
  String username = args[1];
  String password = args[2];

  ServiceInstance si = new ServiceInstance(new URL(urlStr),
      username, password, true);
  Folder rootFolder = si.getRootFolder();

  HostSystem host = (HostSystem) new InventoryNavigator(
      rootFolder).searchManagedEntities("HostSystem")[0];

  System.out.println(host.getName());
  HostServiceTicket ticket = host.acquireCimServicesTicket();
  System.out.println("\nHost Name:" + ticket.getHost());
  System.out.println("sessionId=" + ticket.getSessionId());
  System.out.println("sslThumpprint=" 
      + ticket.getSslThumbprint());
  System.out.println("serviceVersion=" 
      + ticket.getServiceVersion());
  System.out.println("service=" + ticket.getService());
  System.out.println("port=" + ticket.getPort());

  retrieveCimInfo(urlStr, ticket.getSessionId());

  si.getServerConnection().logout();
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:35,代码来源:CimTicket.java

示例9: create

import com.vmware.vim25.mo.ServiceInstance; //导入方法依赖的package包/类
@Override
public InventoryNavigator create() throws IOException {
    ServiceInstance serviceInstance = new ServiceInstance(this.url, this.username, this.password, true);
    return new InventoryNavigator(serviceInstance.getRootFolder());
}
 
开发者ID:strepsirrhini-army,项目名称:chaos-lemur,代码行数:6,代码来源:StandardInventoryNavigatorFactory.java

示例10: main

import com.vmware.vim25.mo.ServiceInstance; //导入方法依赖的package包/类
public static void main(String [] args) throws Exception
 {
   if(args.length != 4)
   {
     System.out.println("Usage: java CreateScheduledTasks " 
    + "<url> <username> <password> <vmname>");
  return;
   }
   
   ServiceInstance si = new ServiceInstance(
              new URL(args[0]), args[1], args[2], true);
   Folder rootFolder = si.getRootFolder();
   
   InventoryNavigator inv = new InventoryNavigator(rootFolder);
   String vmname = args[3];
   VirtualMachine vm = (VirtualMachine)inv.searchManagedEntity(
           "VirtualMachine", vmname);
if(vm==null)
{
  System.out.println("Cannot find the VM " + vmname 
    + "\nExisting...");
  si.getServerConnection().logout();
  return;
}

   ScheduledTaskManager stm = si.getScheduledTaskManager();
   if(stm!=null)
   {
     //to save space, we just check one name here
     if(taskNameExists(stm, "ViMaster_OneTime"))
     {
       si.getServerConnection().logout();
       return;
     }
     
     // Note: the time should be fetched from server,
     // just to make sure it's synchronized.
     ScheduledTaskSpec oneSpec = createOneTimeSchedulerSpec(
         "ViMaster_OneTime", si.currentTime());
     
     ScheduledTaskSpec weekSpec = createWeeklySchedulerSpec(
         "ViMaster_Weekly");

     ScheduledTask st = stm.createScheduledTask(vm, oneSpec);
     ScheduledTask st1 = stm.createScheduledTask(vm, weekSpec);
  // sleep two minutes before deleting 
  // the one time scheduled task.
     // An one time scheduled task has not to be deleted after
     // it's run. It can be run any time again by calling the 
     // runScheduledTask() method.
     Thread.sleep(2*60*1000);
     st.removeScheduledTask();
   }
   else
   {
     System.out.println("SchduledTaskManager is not "
       + "available on this target.");
   }
   
si.getServerConnection().logout();
  }
 
开发者ID:Juniper,项目名称:vijava,代码行数:62,代码来源:CreateScheduledTasks.java

示例11: main

import com.vmware.vim25.mo.ServiceInstance; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception 
{     
  if(args.length!=6)
  {
    System.out.println("Usage: java VmNicOp <url> " +
          "<username> <password> <vmname> <op> <name>");
    System.out.println("op - add|remove");
    System.out.println("name - NIC name when remove; " +
    		"Network name when add");
    System.exit(0);
  }
  String vmname = args[3];
  String op = args[4];
  String name = args[5];
 
  ServiceInstance si = new ServiceInstance(
      new URL(args[0]), args[1], args[2], true);

  Folder rootFolder = si.getRootFolder();
  VirtualMachine vm = (VirtualMachine) new InventoryNavigator(
    rootFolder).searchManagedEntity("VirtualMachine", vmname);

  if(vm==null)
  {
    System.out.println("No VM " + vmname + " found");
    si.getServerConnection().logout();
    return;
  }
  
  VirtualMachineConfigSpec vmConfigSpec = 
    new VirtualMachineConfigSpec();
  
  
  VirtualDeviceConfigSpec nicSpec = 
    getNICDeviceConfigSpec(vm, op, name);
  
  String result = null;
  if(nicSpec!=null)
  {
    vmConfigSpec.setDeviceChange(
        new VirtualDeviceConfigSpec []{nicSpec});
    Task task = vm.reconfigVM_Task(vmConfigSpec);
    result = task.waitForMe();
  }

  if(result==Task.SUCCESS)
  {
    System.out.println("Done with NIC for VM:" + vmname);
  }
  else
  {
    System.out.println("Failed with NIC for VM:" + vmname);
  }
  
  si.getServerConnection().logout();
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:57,代码来源:VmNicOp.java

示例12: main

import com.vmware.vim25.mo.ServiceInstance; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
  if(args.length!=5)
  {
    System.out.println("Usage: java CloneVM <url> " +
    "<username> <password> <vmname> <clonename>");
    System.exit(0);
  }

  String vmname = args[3];
  String cloneName = args[4];

  ServiceInstance si = new ServiceInstance(
      new URL(args[0]), args[1], args[2], true);

  Folder rootFolder = si.getRootFolder();
  VirtualMachine vm = (VirtualMachine) new InventoryNavigator(
      rootFolder).searchManagedEntity(
          "VirtualMachine", vmname);

  if(vm==null)
  {
    System.out.println("No VM " + vmname + " found");
    si.getServerConnection().logout();
    return;
  }

  VirtualMachineCloneSpec cloneSpec = 
    new VirtualMachineCloneSpec();
  cloneSpec.setLocation(new VirtualMachineRelocateSpec());
  cloneSpec.setPowerOn(false);
  cloneSpec.setTemplate(false);

  Task task = vm.cloneVM_Task((Folder) vm.getParent(), 
      cloneName, cloneSpec);
  System.out.println("Launching the VM clone task. " +
  		"Please wait ...");

  String status = task.waitForMe();
  if(status==Task.SUCCESS)
  {
    System.out.println("VM got cloned successfully.");
  }
  else
  {
    System.out.println("Failure -: VM cannot be cloned");
  }
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:49,代码来源:CloneVM.java

示例13: main

import com.vmware.vim25.mo.ServiceInstance; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
  if(args.length!=5)
  {
    System.out.println("Usage: java MigrateVM <url> " +
    "<username> <password> <vmname> <newhost>");
    System.exit(0);
  }

  String vmname = args[3];
  String newHostName = args[4];

  ServiceInstance si = new ServiceInstance(
      new URL(args[0]), args[1], args[2], true);

  Folder rootFolder = si.getRootFolder();
  VirtualMachine vm = (VirtualMachine) new InventoryNavigator(
      rootFolder).searchManagedEntity(
          "VirtualMachine", vmname);
  HostSystem newHost = (HostSystem) new InventoryNavigator(
      rootFolder).searchManagedEntity(
          "HostSystem", newHostName);
  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)
  {
    System.out.println("CPU/software NOT compatible. Exit.");
    si.getServerConnection().logout();
    return;
  }
  
  Task task = vm.migrateVM_Task(cr.getResourcePool(), newHost,
      VirtualMachineMovePriority.highPriority, 
      VirtualMachinePowerState.poweredOn);

  if(task.waitForMe()==Task.SUCCESS)
  {
    System.out.println("VMotioned!");
  }
  else
  {
    System.out.println("VMotion failed!");
    TaskInfo info = task.getTaskInfo();
    System.out.println(info.getError().getFault());
  }
  si.getServerConnection().logout();
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:54,代码来源:MigrateVM.java

示例14: main

import com.vmware.vim25.mo.ServiceInstance; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception 
{     
  if(args.length!=6)
  {
    System.out.println("Usage: java VmAllocateResource <url> " +
          "<username> <password> <vmname> <device> <value>");
    System.out.println("device - cpu|memory");
    System.out.println("value: high|low|normal|numeric value");
    System.exit(0);
  }

  String vmname = args[3];
  String deviceType = args[4];
  String value = args[5];
  
  ServiceInstance si = new ServiceInstance(
      new URL(args[0]), args[1], args[2], true);

  Folder rootFolder = si.getRootFolder();
  VirtualMachine vm = (VirtualMachine) new InventoryNavigator(
    rootFolder).searchManagedEntity("VirtualMachine", vmname);

  if(vm==null)
  {
    System.out.println("No VM " + vmname + " found");
    si.getServerConnection().logout();
    return;
  }
  
  VirtualMachineConfigSpec vmConfigSpec = 
    new VirtualMachineConfigSpec();
  
  if("memory".equalsIgnoreCase(deviceType)) 
  {
    System.out.println("Reconfig memory for VM: " + vmname);
    vmConfigSpec.setMemoryAllocation(getShares(value));          
  }
  else if("cpu".equalsIgnoreCase(deviceType)) 
  {
    System.out.println("Reconfig CPU for VM:  " + vmname);       
    vmConfigSpec.setCpuAllocation(getShares(value));
  }
  else
  {
    System.out.println("Incorrect option for " + vmname);
  }

  Task task = vm.reconfigVM_Task(vmConfigSpec);
  task.waitForMe();
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:51,代码来源:VmAllocateResource.java

示例15: main

import com.vmware.vim25.mo.ServiceInstance; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception 
{     
  if(args.length!=5)
  {
    System.out.println("Usage: java RemoveVmDisk <url> " +
          "<username> <password> <vmname> <diskname>");
    System.exit(0);
  }
  String vmname = args[3];
  String diskName = args[4];
 
  ServiceInstance si = new ServiceInstance(
      new URL(args[0]), args[1], args[2], true);

  Folder rootFolder = si.getRootFolder();
  VirtualMachine vm = (VirtualMachine) new InventoryNavigator(
    rootFolder).searchManagedEntity("VirtualMachine", vmname);

  if(vm==null)
  {
    System.out.println("No VM " + vmname + " found");
    si.getServerConnection().logout();
    return;
  }
  
  VirtualMachineConfigSpec vmConfigSpec = 
      new VirtualMachineConfigSpec();

  VirtualDeviceConfigSpec vdiskSpec = 
      createRemoveDiskConfigSpec(vm.getConfig(), diskName);
  vmConfigSpec.setDeviceChange(
      new VirtualDeviceConfigSpec[]{vdiskSpec} );
  Task task = vm.reconfigVM_Task(vmConfigSpec);
  
  if(task.waitForMe()==Task.SUCCESS)
  {
    System.out.println("Disk removed.");
  }
  else
  {
    System.out.println("Error while removing disk");
  }
  
  si.getServerConnection().logout();
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:46,代码来源:RemoveVmDisk.java


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