Package com.vmware.vim25.mo

Examples of com.vmware.vim25.mo.ServiceInstance


    String diskMode = "persistent";
    String datastoreName = "storage1 (2)";
    String netName = "VM Network";
    String nicName = "Network Adapter 1";
   
    ServiceInstance si = new ServiceInstance(
        new URL(args[0]), args[1], args[2], true);

    Folder rootFolder = si.getRootFolder();
   
    Datacenter dc = (Datacenter) new InventoryNavigator(
        rootFolder).searchManagedEntity("Datacenter", dcName);
    ResourcePool rp = (ResourcePool) new InventoryNavigator(
        dc).searchManagedEntities("ResourcePool")[0];
View Full Code Here


    }

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

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

      System.exit(0);
    }
    String vmname = args[3];
    String op = 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();
   
View Full Code Here

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

    }

    String vmname = args[3];
    String op = 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;
    }

    if("reboot".equalsIgnoreCase(op))
    {
      vm.rebootGuest();
      System.out.println(vmname + " guest OS rebooted");
    }
    else if("poweron".equalsIgnoreCase(op))
    {
      Task task = vm.powerOnVM_Task(null);
      if(task.waitForMe()==Task.SUCCESS)
      {
        System.out.println(vmname + " powered on");
      }
    }
    else if("poweroff".equalsIgnoreCase(op))
    {
      Task task = vm.powerOffVM_Task();
      if(task.waitForMe()==Task.SUCCESS)
      {
        System.out.println(vmname + " powered off");
      }
    }
    else if("reset".equalsIgnoreCase(op))
    {
      Task task = vm.resetVM_Task();
      if(task.waitForMe()==Task.SUCCESS)
      {
        System.out.println(vmname + " reset");
      }
    }
    else if("standby".equalsIgnoreCase(op))
    {
      vm.standbyGuest();
      System.out.println(vmname + " guest OS stoodby");
    }
    else if("suspend".equalsIgnoreCase(op))
    {
      Task task = vm.suspendVM_Task();
      if(task.waitForMe()==Task.SUCCESS)
      {
        System.out.println(vmname + " suspended");
      }
    }
    else if("shutdown".equalsIgnoreCase(op))
    {
      Task task = vm.suspendVM_Task();
      if(task.waitForMe()==Task.SUCCESS)
      {
        System.out.println(vmname + " suspended");
      }
    }
    else
    {
      System.out.println("Invalid operation. Exiting...");
    }
    si.getServerConnection().logout();
  }
View Full Code Here

      System.exit(0);
    }
    String vmname = args[3];
    String op = 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();
   
View Full Code Here

        this.contrailDvSwitchName   = contrailDvsName;
    }
   
    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



  public void connect() throws RemoteException, MalformedURLException {

    si = new ServiceInstance(
        new URL(vsphereUrl), vsphereUsername, vspherePassword, true);
   
 
    rootFolder = si.getRootFolder();
View Full Code Here

            vmsnap = getSnapshotInTree(snapName);
            if (vmsnap == null) { return false; }
        }

        try {
            Task task = null;
            switch (type) {
            case CREATE:
                task = vm_.createSnapshot_Task(snapName, null, false, false);
                break;
            case DELETE:
                task = vmsnap.removeSnapshot_Task(true);
                break;
            case REVERT:
                task = vmsnap.revertToSnapshot_Task(null, true);
                break;
            default:
                throw new Exception("Snapshot TaskType is wrong.");
            }
            assert task != null;
            String ret = task.waitForTask();
            if (ret.equals("success")) {
                logger_.info(messageInSuccess);
                return true;
            } else {
                logger_.info(messageInFailure);
View Full Code Here

TOP

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

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.