Package com.vmware.vim25.mo

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


    }
    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

      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

      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

      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

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

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

    ServiceInstance si = new ServiceInstance(
            new URL(args[0]), args[1], args[2], true);
    HostLocalAccountManager hlam = si.getAccountManager();
    if(hlam==null)
    {
      System.out.println("This sample works ONLY with ESX. "
          + "Please try it again.");
    }

    //create a new POSIX account
    HostPosixAccountSpec has = new HostPosixAccountSpec();
    has.setId("vimaster");
    has.setDescription("The POSIX account for VI Master");
    has.setPassword("password");
    has.setShellAccess(true);
    hlam.createUser(has);

    //create a new group called masters
    HostAccountSpec grpSpec = new HostAccountSpec();
    grpSpec.setId("masters");
    // DON'T CALL the following two lines! NOT supported.
    // grpSpec.setDescription("The Group for VI Masters");
    // grpSpec.setPassword("grppass");
    hlam.createGroup(grpSpec);

    //assign the new user to the new group
    hlam.assignUserToGroup("vimaster", "masters");
   
    //let's check their existence
    UserDirectory ud = si.getUserDirectory();
    UserSearchResult[] usrs = ud.retrieveUserGroups(
          null, // only local machine is searched
          "master", // search string 
          null, null,
          false, //not exact match for the search
          true, // include users
          true // include groups
          );
    // print out the results
    for(int i=0; usrs!=null && i < usrs.length; i++)
    {
      System.out.println("\n===============================");
      System.out.println("Full name: " + usrs[i].getFullName());
      System.out.println("IsGroup:" + usrs[i].isGroup());
      System.out.println("Principal: " + usrs[i].getPrincipal());
    }
   
    //delete the new user and group
    //Note: you have to delete the user before delete the group
    hlam.removeUser("vimaster");
    hlam.removeGroup("masters");
   
    si.getServerConnection().logout();
  }
View Full Code Here

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

    UserDirectory ud = si.getUserDirectory();
   
    //print out the domain names
    String[] domains = ud.getDomainList();
    System.out.println("domains:" + domains);
    for(int i=0; domains!=null && i<domains.length; i++)
    {
      System.out.println("Domain:" + domains[i]);
    }
   
    UserSearchResult[] usrs = ud.retrieveUserGroups(
          null, // only local machine is searched
          "", // blank means matching all 
          "users", null, // all the groups
          false, //not exact match for the search
          true, // include users
          false // include groups
          );
   
    // print out the results
    for(int i=0; usrs!=null && i < usrs.length; i++)
    {
      System.out.println("===============================");
      System.out.println("Full name: " + usrs[i].getFullName());
      System.out.println("IsGroup:" + usrs[i].isGroup());
      System.out.println("Principal: " + usrs[i].getPrincipal());
    }

    si.getServerConnection().logout();
  }
View Full Code Here

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

    AuthorizationManager am = si.getAuthorizationManager();
    AuthorizationDescription ad = am.getDescription();
   
    System.out.println("Descriptions of all privileges:");
    printDescriptions(ad.getPrivilege());

    System.out.println("Descriptions of all privilege groups:");
    printDescriptions( ad.getPrivilegeGroup());

    System.out.println("List of all privileges with details:");
    printPrivileges(am.getPrivilegeList());
   
    System.out.println("List of all the roles with details:");
    printRoles(am.getRoleList());
   
    si.getServerConnection().logout();
  }
View Full Code Here

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

    AuthorizationManager am = si.getAuthorizationManager();
   
    int roleId = am.addAuthorizationRole("master1",
        new String[] { "System.View", "System.Read",
        "System.Anonymous", "Global.LogEvent" } );
   
    //even if you just want to rename the role, you
    // still need to provide full list of privileges
    am.updateAuthorizationRole(roleId, "master",
        new String[] { "System.View", "System.Read",
        "System.Anonymous", "Global.LogEvent",
        "Global.Diagnostics", "Folder.Create"} );
   
    System.out.println("The new role ID: " + roleId);
   
    Permission perm = new Permission();
    perm.setGroup(false); // false for user, true for group
    perm.setPrincipal("vimaster"); // the vimaster must exist
    perm.setPropagate(true); // propagate down the hierarchy
    perm.setRoleId(roleId);
   
    am.setEntityPermissions( si.getRootFolder(),
        new Permission[] {perm} );
   
    Permission[] ps = am.retrieveEntityPermissions(
        si.getRootFolder(), false);
   
    System.out.println("print the permissions on root:");
    printPermissions(ps);
   
    si.getServerConnection().logout();
  }
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.