Examples of ServiceInstance


Examples of com.twitter.thrift.ServiceInstance

    assertEquals(Optional.<HostAndPort>absent(), leaderRedirector.getRedirect());
  }

  @Test
  public void testBadServiceInstance() {
    ServiceInstance badLocal = new ServiceInstance()
        .setAdditionalEndpoints(ImmutableMap.of("foo", new Endpoint("localhost", 500)));

    publishSchedulers(ImmutableSet.of(badLocal));

    assertEquals(Optional.<HostAndPort>absent(), leaderRedirector.getRedirect());
View Full Code Here

Examples of com.twitter.thrift.ServiceInstance

    ClientResponse response = get(path);
    assertEquals(expectedStatus.getStatusCode(), response.getStatus());
  }

  private void setLeadingScheduler(String host, int port) {
    ServiceInstance instance = new ServiceInstance()
        .setAdditionalEndpoints(ImmutableMap.of("http", new Endpoint(host, port)));
    schedulerWatcher.getValue().onChange(ImmutableSet.of(instance));
  }
View Full Code Here

Examples of com.twitter.thrift.ServiceInstance

  public void monitor() throws MonitorException {
    schedulers.watch(new SchedulerMonitor());
  }

  private Optional<HostAndPort> getLeaderHttp() {
    ServiceInstance leadingScheduler = leader.get();
    if (leadingScheduler == null) {
      return Optional.absent();
    }

    if (leadingScheduler.isSetAdditionalEndpoints()) {
      Endpoint leaderHttp = leadingScheduler.getAdditionalEndpoints().get(HTTP_PORT_NAME);
      if (leaderHttp != null && leaderHttp.isSetHost() && leaderHttp.isSetPort()) {
        return Optional.of(HostAndPort.fromParts(leaderHttp.getHost(), leaderHttp.getPort()));
      }
    }
View Full Code Here

Examples of com.vmware.vim.binding.vim.ServiceInstance

      SessionManager sm = null;
      try {
         ManagedObjectReference svcRef = new ManagedObjectReference();
         svcRef.setType("ServiceInstance");
         svcRef.setValue("ServiceInstance");
         ServiceInstance si = client.createStub(ServiceInstance.class, svcRef);
         sm = client.createStub(SessionManager.class,
               si.getContent().getSessionManager());
         sm.loginExtensionByCertificate(extKey, "en");
         String ticket = sm.acquireSessionTicket(null);
         logger.info("got session ticket using extension");
         return ticket;
      } catch (Exception e) {
View Full Code Here

Examples of com.vmware.vim.binding.vim.ServiceInstance

         ManagedObjectReference svcRef = new ManagedObjectReference();
         svcRef.setType("ServiceInstance");
         svcRef.setValue("ServiceInstance");

         ServiceInstance instance =
               vmomiClient.createStub(ServiceInstance.class, svcRef);
         ServiceInstanceContent instanceContent = instance.retrieveContent();
         SessionManager sessionManager =
               vmomiClient.createStub(SessionManager.class,
                     instanceContent.getSessionManager());

         sessionManager.login(name, password, sessionManager.getDefaultLocale());
View Full Code Here

Examples of com.vmware.vim25.mo.ServiceInstance

     */
    public void connect()
        throws Exception
    {
        logger_.info(String.format("connecting to %s...", url_));
    si_ = new ServiceInstance
            (new URL(url_), username_, password_, true);
    rootFolder_ = si_.getRootFolder();
        logger_.info("connected");
    }
View Full Code Here

Examples of com.vmware.vim25.mo.ServiceInstance

    /** connect to the service if not already connected. */
    public void connect() throws AmazonServiceException {
        try {
            if (service == null) {
                service = new ServiceInstance(new URL(url), username, password, true);
            }
        } catch (RemoteException e) {
            throw new AmazonServiceException("cannot connect to VSphere", e);
        } catch (MalformedURLException e) {
            throw new AmazonServiceException("cannot connect to VSphere", e);
View Full Code Here

Examples of com.vmware.vim25.mo.ServiceInstance

     String vmPath = clp.get_option("vmPath");
     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;
View Full Code Here

Examples of com.vmware.vim25.mo.ServiceInstance

    //please change the following three depending your op
    String snapshotname = "test";
    String desc = "A description for sample snapshot";
    boolean removechild = true;
   
    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");
      }
    }
    else if(op.equalsIgnoreCase("remove"))
    {
      VirtualMachineSnapshot vmsnap = getSnapshotInTree(
          vm, snapshotname);
      if(vmsnap!=null)
      {
        Task task = vmsnap.removeSnapshot_Task(removechild);
        if(task.waitForMe()==Task.SUCCESS)
        {
          System.out.println("Removed snapshot:" + snapshotname);
        }
      }
    }
    else
    {
      System.out.println("Invalid operation");
      return;
    }
    si.getServerConnection().logout();
  }
View Full Code Here

Examples of com.vmware.vim25.mo.ServiceInstance

{
  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);
   
//  vmdm.createNetworkAdapter(VirtualNetworkAdapterType.VirtualVmxnet3, null, "VM Network", true, false);
//  vmdm.createNewHardDisk(2048, VirtualDiskType.thin, VirtualDiskMode.persistent);
//  vmdm.addHardDisk("[psorl-iscsi01] tobin-win7-a/Rawc1.2_Win7x32bit_Target.vmdk", VirtualDiskMode.persistent);
   
//  vmdm.createNewHardDrive(1000, VirtualDiskType.flatMonolithic, VirtualDiskMode.persistent, false, false, null);
//  vmdm.createNewHardDrive(1000, VirtualDiskType.flatMonolithic, VirtualDiskMode.persistent, false, false, null);
   
//  List<VirtualDevice> devs = new ArrayList<VirtualDevice>();
//  devs.add( vmdm.findHardDisk("Hard disk 2"));
//  devs.add( vmdm.findHardDisk("Hard disk 3"));
//  devs.add( vmdm.findHardDisk("Hard disk 4"));
//  devs.add( vmdm.findHardDisk("Hard disk 5"));
//   
//  // CAUTION: the second parameter is true, and remove disk files in datastore.
//    vmdm.removeDevices(devs, true);

    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.