Package com.vmware.vim25.mo

Examples of com.vmware.vim25.mo.VirtualMachine


    /**
     * Gets the named VirtualMachine.
     */
    public VirtualMachine getVirtualMachineById(String instanceId) throws RemoteException {
        InventoryNavigator inventoryNavigator = getInventoryNavigator();
        VirtualMachine virtualMachine = (VirtualMachine) inventoryNavigator.searchManagedEntity(
                VIRTUAL_MACHINE_TYPE_NAME, instanceId);

        return virtualMachine;
    }
View Full Code Here


     */
    public void terminateInstance(String instanceId) {
        try {
            connection.connect();

            VirtualMachine virtualMachine = connection.getVirtualMachineById(instanceId);
            this.terminationStrategy.terminate(virtualMachine);
        } catch (RemoteException e) {
            throw new AmazonServiceException("cannot destroy & recreate " + instanceId, e);
        } finally {
            connection.disconnect();
View Full Code Here

     String datacenterName= clp.get_option("DatacenterName");

     try
     {
       ServiceInstance si = new ServiceInstance(new URL(urlStr), username, password, true);
       VirtualMachine vm = (VirtualMachine) si.getSearchIndex().findByInventoryPath(vmPath);
       Datacenter dc = (Datacenter) si.getSearchIndex().findByInventoryPath(datacenterName);
      
       if(vm==null || dc ==null)
       {
         System.out.println("VirtualMachine or Datacenter path is NOT correct. Pls double check. ");
         return;
       }
       Folder vmFolder = dc.getVmFolder();
 
       VirtualMachineCloneSpec cloneSpec = new VirtualMachineCloneSpec();
       cloneSpec.setLocation(new VirtualMachineRelocateSpec());
       cloneSpec.setPowerOn(false);
       cloneSpec.setTemplate(false);

       Task task = vm.cloneVM_Task(vmFolder, cloneName, cloneSpec);
       System.out.println("Launching the VM clone task. It might take a while. Please wait for the result ...");
      
       String status =   task.waitForMe();
       if(status==Task.SUCCESS)
       {
View Full Code Here

   
    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;
    }

    if("create".equalsIgnoreCase(op))
    {
      Task task = vm.createSnapshot_Task(
          snapshotname, desc, false, false);
      if(task.waitForMe()==Task.SUCCESS)
      {
        System.out.println("Snapshot was created.");
      }
    }
    else if("list".equalsIgnoreCase(op))
    {
      listSnapshots(vm);
    }
    else if(op.equalsIgnoreCase("revert"))
    {
      VirtualMachineSnapshot vmsnap = getSnapshotInTree(
          vm, snapshotname);
      if(vmsnap!=null)
      {
        Task task = vmsnap.revertToSnapshot_Task(null);
        if(task.waitForMe()==Task.SUCCESS)
        {
          System.out.println("Reverted to snapshot:"
              + snapshotname);
        }
      }
    }
    else if(op.equalsIgnoreCase("removeall"))
    {
      Task task = vm.removeAllSnapshots_Task();     
      if(task.waitForMe()== Task.SUCCESS)
      {
        System.out.println("Removed all snapshots");
      }
    }
View Full Code Here

  public static void main(String[] args) throws Exception
  {
    String vmName = "Rawc1.2_Win7x32bit_Target";

    ServiceInstance si = new ServiceInstance(new URL("https://8.8.8.8/sdk"), "administrator", "vmware", true);
    VirtualMachine vm = (VirtualMachine) new InventoryNavigator(si.getRootFolder()).searchManagedEntity("VirtualMachine", vmName);

    VirtualMachineDeviceManager vmdm = new VirtualMachineDeviceManager(vm);

    vmdm.createNetworkAdapter(VirtualNetworkAdapterType.VirtualE1000, "dvPortGroup", "00:50:56:00:12:14", true, true);
   
View Full Code Here

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

    String vmname = args[3];
    VirtualMachine vm = (VirtualMachine) new InventoryNavigator(
      si.getRootFolder()).searchManagedEntity(
        "VirtualMachine", vmname);

    if(vm == null)
    {
      System.out.println("Virtual Machine " + vmname
          + " cannot be found.");
      si.getServerConnection().logout();
      return;
    }

    PerformanceManager perfMgr = si.getPerformanceManager();

    int perfInterval = 1800; // 30 minutes for PastWeek
   
    // retrieve all the available perf metrics for vm
    PerfMetricId[] pmis = perfMgr.queryAvailablePerfMetric(
        vm, null, null, perfInterval);
   
    Calendar curTime = si.currentTime();
   
    PerfQuerySpec qSpec = new PerfQuerySpec();
    qSpec.setEntity(vm.getRuntime().getHost());
    //metricIDs must be provided, or InvalidArgumentFault
    qSpec.setMetricId(pmis);
    qSpec.setFormat("normal"); //optional since it's default
    qSpec.setIntervalId(perfInterval);
View Full Code Here

    rai2.setShares(si2);
    vmcs2.setCpuAllocation(rai2);
   
    ManagedObjectReference vm1_mor = createMOR("VirtualMachine", vm1_oid);
    ManagedObjectReference vm2_mor = createMOR("VirtualMachine", vm2_oid);
    VirtualMachine vm1 = (VirtualMachine) MorUtil.createExactManagedEntity(si.getServerConnection(), vm1_mor);
    VirtualMachine vm2 = (VirtualMachine) MorUtil.createExactManagedEntity(si.getServerConnection(), vm2_mor);
   
    // make a web service call to set the configuration.
    vm1.reconfigVM_Task(vmcs1);
    vm2.reconfigVM_Task(vmcs2);     

    // log out from web service
    si.getServerConnection().logout();
    System.out.println("Done with setting VM CPU shares.");
  }
View Full Code Here

                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...");
View Full Code Here

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

    String vmname = args[3];
    InventoryNavigator inv = new InventoryNavigator(
        si.getRootFolder());
    VirtualMachine vm = (VirtualMachine)inv.searchManagedEntity(
            "VirtualMachine", vmname);
    if(vm==null)
    {
      System.out.println("Cannot find the VM " + vmname
        + "\nExisting...");
View Full Code Here

    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();
View Full Code Here

TOP

Related Classes of com.vmware.vim25.mo.VirtualMachine

Copyright © 2018 www.massapicom. 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.