Examples of InventoryNavigator


Examples of com.vmware.vim25.mo.InventoryNavigator

    public void Initialize() throws Exception {
        // Connect to VCenter
        serviceInstance = new ServiceInstance(new URL(vcenterUrl),
                vcenterUsername, vcenterPassword, true);
        rootFolder = serviceInstance.getRootFolder();
        inventoryNavigator = new InventoryNavigator(rootFolder);
        ipPoolManager = serviceInstance.getIpPoolManager();
    }
View Full Code Here

Examples of com.vmware.vim25.mo.InventoryNavigator

    rootFolder = si.getRootFolder();

  }

  public ArrayList<String> listHosts() throws InvalidProperty, RuntimeFault, RemoteException {
    ManagedEntity[] hosts= new InventoryNavigator(rootFolder).searchManagedEntities("HostSystem");

    ArrayList<String> hostList=new ArrayList<String>();
   
    for(int i=0; i<hosts.length; i++)
    {
View Full Code Here

Examples of com.vmware.vim25.mo.InventoryNavigator

   
  }
 
  public ArrayList<String> listDataCenters() throws InvalidProperty, RuntimeFault, RemoteException {

    ManagedEntity[] datacenters = new InventoryNavigator(rootFolder).searchManagedEntities("Datacenter");

    ArrayList<String> datacenterList=new ArrayList<String>();
   
   
    for(int i=0; i<datacenters.length; i++)
View Full Code Here

Examples of com.vmware.vim25.mo.InventoryNavigator

    return datacenterList;
  }

  public ArrayList<String> listClusters() throws InvalidProperty, RuntimeFault, RemoteException {

    ManagedEntity[] clusters = new InventoryNavigator(rootFolder).searchManagedEntities("ClusterComputeResource");

    ArrayList<String> clusterList=new ArrayList<String>();
   
    ClusterComputeResource a;
   
View Full Code Here

Examples of com.vmware.vim25.mo.InventoryNavigator

    return clusterList;
  }
 
  public ArrayList<String> listDataStores() throws InvalidProperty, RuntimeFault, RemoteException {

    ManagedEntity[] datacenters = new InventoryNavigator(rootFolder).searchManagedEntities("Datacenter");

    ArrayList<String> datastoreList=new ArrayList<String>();
   
    for(int i=0; i<datacenters.length; i++)
    {
View Full Code Here

Examples of com.vmware.vim25.mo.InventoryNavigator

  }

  public ArrayList<String> listResourcePools() throws InvalidProperty, RuntimeFault, RemoteException {

    ManagedEntity[] resourcepools = new InventoryNavigator(rootFolder).searchManagedEntities("ResourcePool");

    ArrayList<String> resourcePoolList=new ArrayList<String>();
   
    for(int i=0; i<resourcepools.length; i++)
    {
View Full Code Here

Examples of com.vmware.vim25.mo.InventoryNavigator

 
  public ArrayList<String> listNetworks() throws InvalidProperty, RuntimeFault, RemoteException {

    ManagedEntity[] datacenters =
      new InventoryNavigator(rootFolder).searchManagedEntities("Datacenter");
   
    ArrayList<String> networkList=new ArrayList<String>();

    for(int i=0; i<datacenters.length; i++)
    {
View Full Code Here

Examples of com.vmware.vim25.mo.InventoryNavigator

  public ArrayList<String> listVms() throws InvalidProperty, RuntimeFault, RemoteException  {

    ArrayList<String> vmList=new ArrayList<String>();
   
    ManagedEntity[] vms=new InventoryNavigator(rootFolder).searchManagedEntities("VirtualMachine");

    for(int i=0; i<vms.length; i++)
    {
      vmList.add(vms[i].getName());
    }
View Full Code Here

Examples of com.vmware.vim25.mo.InventoryNavigator

    return vmList;
  }
 
 
  public VirtualMachine findVmByName(String vmName) throws InvalidProperty, RuntimeFault, RemoteException {
    VirtualMachine existingVm = (VirtualMachine) new InventoryNavigator(rootFolder).searchManagedEntity("VirtualMachine",vmName);

    return existingVm;
  }
View Full Code Here

Examples of com.vmware.vim25.mo.InventoryNavigator

      String vmGuestOsId, VmDisk[] vmDisks,
      VmNic[] vmNics, String vmDataCenterName, String vmDataStoreName, String vmClusterName ) throws Exception {
    //  ManagedEntity[] mes = new InventoryNavigator(rootFolder).searchManagedEntities("VirtualMachine");

    System.out.println("Datacenter:"+vmDataCenterName);
    Datacenter dc = (Datacenter) new InventoryNavigator(rootFolder).searchManagedEntity("Datacenter", vmDataCenterName);

    //Now find the correct resourcepool to create the vm
    ManagedEntity[] resourcepools = new InventoryNavigator(rootFolder).searchManagedEntities("ResourcePool");

   
    ResourcePool rp = null;

    System.out.println("Cluster:"+vmClusterName);
   
    for(int i=0; i<resourcepools.length; i++)
    {
      ResourcePool resourcepool = (ResourcePool) resourcepools[i];
      if (resourcepools[i].getParent().getName().equals(vmClusterName)) {
        System.out.println("using cluster/resourcepool "+vmClusterName);
        rp= (ResourcePool)resourcepools[i];
      }
    }

    Folder vmFolder = dc.getVmFolder();

    // create vm config spec
    VirtualMachineConfigSpec vmSpec =
      new VirtualMachineConfigSpec();
    vmSpec.setName(vmName);
    vmSpec.setAnnotation("Created by JvsphereControl");
    vmSpec.setMemoryMB(vmMemorySize);
    vmSpec.setNumCPUs(vmCpuCount);
    vmSpec.setGuestId(vmGuestOsId);
   
    System.out.println("Vmname:"+vmName);
    System.out.println("Memorysize:"+vmMemorySize);
    System.out.println("GuestOsId:"+vmGuestOsId);

    //We create one scsi controller
    VirtualDeviceConfigSpec machineSpecs[]= new VirtualDeviceConfigSpec[vmNics.length+1+vmDisks.length];
    int cKey = 1000;
    VirtualDeviceConfigSpec scsiSpec = VsphereUtils.createScsiSpec(cKey);
    machineSpecs[0]=scsiSpec;
   
    // Associate the virtual disks with the scsi controller
    for (int i=0; i< vmDisks.length; i++) {
        VirtualDeviceConfigSpec diskSpec = VsphereUtils.createDiskSpec(
          vmDataStoreName, cKey, vmDisks[i].getSize(), vmDisks[i].getMode(),i);

        System.out.println("Disk Datastore:"+vmDataStoreName);
        System.out.println("Ckey:"+cKey);
        System.out.println("DiskSize:"+vmDisks[i].getSize());
        System.out.println("DiskMode:"+vmDisks[i].getMode());

      machineSpecs[i+1]=diskSpec;
     
    }
   
     
    //virtual network interfaces
    for (int i=0; i< vmNics.length; i++ ) {

      machineSpecs[vmDisks.length+1+i]= VsphereUtils.createNicSpec(
          vmNics[i].getName(), vmNics[i].getNetwork(),vmNics[i].isStartConnected(),vmNics[i].isConnected(),vmNics[i].getType());
          System.out.println("NicName:"+vmNics[i].getName());
          System.out.println("NicNetwork:"+vmNics[i].getNetwork());
          System.out.println("NicStartConnected:"+vmNics[i].isStartConnected());
          System.out.println("NicConnected:"+vmNics[i].isConnected());
          System.out.println("NicType:"+vmNics[i].getType());

    }  

    vmSpec.setDeviceChange(machineSpecs);

   
    // create vm file info for the vmx file
    VirtualMachineFileInfo vmfi = new VirtualMachineFileInfo();
    vmfi.setVmPathName("["+ vmDataStoreName +"]");
    System.out.println("Vm DatastoreName"+vmDataStoreName);

    vmSpec.setFiles(vmfi);

    // call the createVM_Task method on the vm folder
    // TOO: null, host ?
    Task task = vmFolder.createVM_Task(vmSpec, rp, null);
    String result= task.waitForTask();
    //    String result = task.waitForMe();  


    VirtualMachine newVm=null;

    if(result == Task.SUCCESS)
    {
      System.out.println("VM Created Sucessfully");

      //Search for it and start it if requested
      //TODO powerOnVM_Task (null) =!! null = host , maar was is die host?

      newVm = (VirtualMachine) new InventoryNavigator(rootFolder).searchManagedEntity("VirtualMachine",vmName);
    } else
    {
      System.out.println("VM could not be created. Error:");
      if (task.getTaskInfo() != null && task.getTaskInfo().getError() != null)
      {          
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.