Examples of ServiceInstance


Examples of com.vmware.vim25.mo.ServiceInstance

    String urlStr = clp.get_option("url");
    String username = clp.get_option("username");
    String password = clp.get_option("password");
    String hostname = clp.get_option("hostname");

    ServiceInstance si = new ServiceInstance(new URL(urlStr),
        username, password, true);
    HostSystem host = (HostSystem) new InventoryNavigator(si
        .getRootFolder()).searchManagedEntity("HostSystem",
        hostname);

    if (host == null) {
      System.out.println("Host cannot be found");
View Full Code Here

Examples of com.vmware.vim25.mo.ServiceInstance

    String username = args[1];
    String password = args[2];

    System.out.println("Connecting to " + urlStr + " as " + username);

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

    System.out.println("info---" + si.getAboutInfo().getFullName());

    // Displays all the Events with Full Formatted message
    try
    {
      EventManager _eventManager = si.getEventManager();
      EventFilterSpec eventFilter = new EventFilterSpec();

      EventHistoryCollector history = _eventManager
          .createCollectorForEvents(eventFilter);
      Event[] events = history.getLatestPage();

      System.out.println("Events In the latestPage are : ");
      for (int i = 0; i < events.length; i++)
      {
        Event anEvent = events[i];
        System.out.println("Event: " + anEvent.getClass().getName()
            + "  FullFormattedMessage: "
            + anEvent.getFullFormattedMessage());
      }
    } catch (Exception e)
    {
      System.out.println("Caught Exception : " + " Name : "
          + e.getClass().getName() + " Message : " + e.getMessage()
          + " Trace : ");
      e.printStackTrace();
    }

    si.getServerConnection().logout();

  }
View Full Code Here

Examples of com.vmware.vim25.mo.ServiceInstance

      System.out.println("Usage: java RealtimePerfMonitor "
        + "<url> <username> <password> <vmname>");
      return;
    }

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

    String vmname = args[3];
    ManagedEntity vm = 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();

    // find out the refresh rate for the virtual machine
    PerfProviderSummary pps = perfMgr.queryPerfProviderSummary(vm);
    int refreshRate = pps.getRefreshRate().intValue();
View Full Code Here

Examples of com.vmware.vim25.mo.ServiceInstance

      System.out.println("Usage: java SetHostTime " +
            "<url> <username> <password> <hostname>");
      return;
    }

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

    String hostname = args[3];
    Folder rootFolder = si.getRootFolder();
    HostSystem host = null;
    host = (HostSystem) new InventoryNavigator(
        rootFolder).searchManagedEntity("HostSystem", hostname);

    if(host==null)
    {
      System.out.println("Cannot find the host:" + hostname);
      si.getServerConnection().logout();
      return;
    }
    HostDateTimeSystem hdts = host.getHostDateTimeSystem();
   
    HostDateTimeInfo info = hdts.getDateTimeInfo();

    System.out.println("The NTP Servers:");
    HostNtpConfig cfg = info.getNtpConfig();
    String[] svrs = cfg.getServer();
    for(int i=0; svrs!=null && i<svrs.length; i++)
    {
      System.out.println("Server["+i+"]:" + svrs[i]);
    }
   
    System.out.println("\nCurrent Time Zone:");
    HostDateTimeSystemTimeZone tz = info.getTimeZone();
    System.out.println("Key:" + tz.getKey());
    System.out.println("Name:" + tz.getName());
    // the GMT offset is in seconds.
    // for example, America/Los_Angeles, -28800
    System.out.println("GmtOffset:" + tz.getGmtOffset());
    System.out.println("Description:" + tz.getDescription());
   
    Calendar curTime = si.currentTime();
    System.out.println("\nCurrent time:" + curTime.getTime());
    //roll back one hour
    curTime.roll(Calendar.HOUR, false);
    hdts.updateDateTime(curTime);
   
    curTime = si.currentTime();
    System.out.println("Current time (after):"
        + curTime.getTime());

    // reset the time
    curTime.roll(Calendar.HOUR, true);
    hdts.updateDateTime(curTime);
   
    si.getServerConnection().logout();
  }
View Full Code Here

Examples of com.vmware.vim25.mo.ServiceInstance

      System.out.println("Usage: java GetMultiPerf "
        + "<url> <username> <password> <vmname>");
      return;
    }

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

    Calendar startTime = (Calendar) curTime.clone();
    startTime.roll(Calendar.DATE, -4);
    System.out.println("start:" + startTime.getTime());
    qSpec.setStartTime(startTime);
   
    Calendar endTime = (Calendar) curTime.clone();
    endTime.roll(Calendar.DATE, -3);
    System.out.println("end:" + endTime.getTime());
    qSpec.setEndTime(endTime);
   
    PerfCompositeMetric pv = perfMgr.queryPerfComposite(qSpec);
    if(pv != null)
    {
      printPerfMetric(pv.getEntity());
      PerfEntityMetricBase[] pembs = pv.getChildEntity();
      for(int i=0; pembs!=null && i< pembs.length; i++)
      {
        printPerfMetric(pembs[i]);
      }
    }
    si.getServerConnection().logout();
  }
View Full Code Here

Examples of com.vmware.vim25.mo.ServiceInstance

      System.out.println("Usage: java PrintPerfMgr "
        + "<url> <username> <password>");
      return;
    }

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

    PerformanceManager perfMgr = si.getPerformanceManager();

    System.out.println("***Print All Descriptions:");
    PerformanceDescription pd = perfMgr.getDescription();
    printPerfDescription(pd);

    System.out.println("\n***Print All Historical Intervals:");
    PerfInterval[] pis = perfMgr.getHistoricalInterval();
    printPerfIntervals(pis);
   
    System.out.println("\n***Print All Perf Counters:");
    PerfCounterInfo[] pcis = perfMgr.getPerfCounter();
    printPerfCounters(pcis);
   
    si.getServerConnection().logout();
  }
View Full Code Here

Examples of com.vmware.vim25.mo.ServiceInstance

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

Examples of com.vmware.vim25.mo.ServiceInstance

      System.out.println("Usage: java TaskHistoryMonitor "
        + "<url> <username> <password>");
      return;
    }
    
    ServiceInstance si = new ServiceInstance(
      new URL(args[0]), args[1], args[2], true);
    
    TaskManager taskMgr = si.getTaskManager();

    if(taskMgr!=null)
    {
      Folder root = si.getRootFolder();
      TaskFilterSpec tfs = createTaskFilterSpec(root);
      TaskHistoryCollector thc =
          taskMgr.createCollectorForTasks(tfs);
     
      // Note: 10 <= pagesize <= 62
      thc.setCollectorPageSize(15);

      System.out.println("Tasks in latestPage:");
      TaskInfo[] tis = thc.getLatestPage();
      printTaskInfos(tis);

      System.out.println("\nAll tasks:");
      int total = 0;
     
      while(true)
      {
        tis= thc.readNextTasks(50);
        if(tis==null)
        {
          break;
        }
        total += tis.length;
        printTaskInfos(tis);
      }
      System.out.println("\nTotal number " +
          "of tasks retrieved:" + total);
      thc.destroyCollector();
    }
    si.getServerConnection().logout();
  }
View Full Code Here

Examples of com.vmware.vim25.mo.ServiceInstance

      CommandLineParser clp = new CommandLineParser(new OptionSpec[]{}, args);
       String urlStr = clp.get_option("url");
        String username = clp.get_option("username");
      String password = clp.get_option("password");

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

    String sessionStr = si.getServerConnection().getSessionStr();
   
    System.out.println("sessionStr=" + sessionStr);

    Thread.sleep(30*60*1000);
   
    si.getServerConnection().logout();
  }
 
View Full Code Here

Examples of com.vmware.vim25.mo.ServiceInstance

      System.out.println("Usage: java PrintTaskManager "
        + "<url> <username> <password>");
      return;
    }

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

    int maxCollector = taskMgr.getMaxCollector();
    System.out.println("Maximum number of collectors to " +
        "retrive historical tasks: " + maxCollector);
   
    System.out.println("\nTask description:");
    TaskDescription td = taskMgr.getDescriptioin();
    printTaskDescription(td);
   
    System.out.println("\nRecent tasks:");
    Task[] recentTasks = taskMgr.getRecentTasks();
    for(int i=0; recentTasks!=null && i<recentTasks.length; i++)
    {
      TaskInfo ti = recentTasks[i].getTaskInfo();
      System.out.println("\nName:" + ti.getName());
      System.out.println("Key:" + ti.getKey());
      System.out.println("State:" + ti.getState());
    }
    si.getServerConnection().logout();
  }
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.