Package org.virtualbox_4_2

Examples of org.virtualbox_4_2.VirtualBoxManager


  
   private NodeMetadataBuilder getIpAddresses(IMachine vm, NodeMetadataBuilder nodeMetadataBuilder) {
      List<String> publicIpAddresses = Lists.newArrayList();
      List<String> privateIpAddresses = Lists.newArrayList();
      for(long slot = 0; slot < 4; slot ++) {
         INetworkAdapter adapter = vm.getNetworkAdapter(slot);
         if(adapter != null) {
            if (adapter.getAttachmentType() == NetworkAttachmentType.NAT) {
               String hostIP = adapter.getNATEngine().getHostIP();
               if(!hostIP.isEmpty())
                  publicIpAddresses.add(hostIP);
               for (String nameProtocolnumberAddressInboudportGuestTargetport : adapter.getNATEngine().getRedirects()) {
                  Iterable<String> stuff = Splitter.on(',').split(nameProtocolnumberAddressInboudportGuestTargetport);
                  String protocolNumber = Iterables.get(stuff, 1);
                  String hostAddress = Iterables.get(stuff, 2);
                  String inboundPort = Iterables.get(stuff, 3);
                  String targetPort = Iterables.get(stuff, 5);
                  if ("1".equals(protocolNumber) && "22".equals(targetPort)) {
                     int inPort = Integer.parseInt(inboundPort);
                     publicIpAddresses.add(hostAddress);
                     nodeMetadataBuilder.loginPort(inPort);
                  }
               }
            } else if (adapter.getAttachmentType() == NetworkAttachmentType.Bridged) {
               String clientIpAddress = networkUtils.getIpAddressFromNicSlot(vm.getName(), adapter.getSlot());
               privateIpAddresses.add(clientIpAddress);

            } else if (adapter.getAttachmentType() == NetworkAttachmentType.HostOnly) {
               String clientIpAddress = networkUtils.getValidHostOnlyIpFromVm(vm.getName());            
               publicIpAddresses.add(clientIpAddress);
            }
         }
      }
View Full Code Here


        this.networkInterfaceCard = networkInterfaceCard;
   }

   @Override
   public Void apply(IMachine machine) {
      INetworkAdapter iNetworkAdapter = machine.getNetworkAdapter(networkInterfaceCard.getSlot());
      iNetworkAdapter.setAttachmentType(Bridged);
      iNetworkAdapter.setMACAddress(networkInterfaceCard.getNetworkAdapter().getMacAddress());
      iNetworkAdapter.setBridgedInterface(networkInterfaceCard.getHostInterfaceName());
      iNetworkAdapter.setEnabled(networkInterfaceCard.isEnabled());
      machine.saveSettings();
      return null;
   }
View Full Code Here

      this.networkInterfaceCard = networkInterfaceCard;
   }

   @Override
   public Void apply(IMachine machine) {
      INetworkAdapter iNetworkAdapter = machine.getNetworkAdapter(networkInterfaceCard.getSlot());
      iNetworkAdapter.setAttachmentType(NetworkAttachmentType.HostOnly);
      iNetworkAdapter.setMACAddress(networkInterfaceCard.getNetworkAdapter().getMacAddress());
      iNetworkAdapter.setHostOnlyInterface(networkInterfaceCard.getHostInterfaceName());
      iNetworkAdapter.setEnabled(networkInterfaceCard.isEnabled());
      machine.saveSettings();
      return null;
   }
View Full Code Here

      VirtualBoxManager manager = createNiceMock(VirtualBoxManager.class);
      IMachine machine = createMock(IMachine.class);
      IVirtualBox vBox = createMock(IVirtualBox.class);
      ISession session = createMock(ISession.class);
      IConsole console = createNiceMock(IConsole.class);
      IProgress progress = createNiceMock(IProgress.class);
      ISnapshot snapshot = createNiceMock(ISnapshot.class);
      expect(machine.getCurrentSnapshot()).andReturn(snapshot).anyTimes();
      expect(machine.getState()).andReturn(MachineState.PoweredOff).anyTimes();

      expect(manager.openMachineSession(machine)).andReturn(session);

      expect(session.getConsole()).andReturn(console);
      expect(console.takeSnapshot(snapshotName, snapshotDesc)).andReturn(
            progress);
      expect(progress.getCompleted()).andReturn(true);

      session.unlockMachine();
      replay(manager, machine, vBox, session, console, progress);

      new TakeSnapshotIfNotAlreadyAttached(Suppliers.ofInstance(manager), snapshotName, snapshotDesc, Logger.CONSOLE)
View Full Code Here

      IMachine machine = createMock(IMachine.class);
      IVirtualBox vBox = createMock(IVirtualBox.class);
      ISession session = createMock(ISession.class);
      IConsole console = createNiceMock(IConsole.class);

      IProgress progress = createNiceMock(IProgress.class);
      expect(progress.getCompleted()).andReturn(true);
      expect(machine.getCurrentSnapshot()).andReturn(null).anyTimes();
      expect(manager.openMachineSession(machine)).andReturn(session);
      expect(machine.getState()).andReturn(MachineState.PoweredOff).anyTimes();

      expect(machine.getName()).andReturn("machine").anyTimes();
View Full Code Here

      MachineUtils machineUtils = createMock(MachineUtils.class);

      IMachine machine = createMock(IMachine.class);
      IVirtualBox vBox = createMock(IVirtualBox.class);
      IMedium medium = createMock(IMedium.class);
      IProgress progress = createNiceMock(IProgress.class);

      StringBuilder errorBuilder = new StringBuilder();
      errorBuilder.append("org.virtualbox_4_2.VBoxException: VirtualBox error: ");
      errorBuilder.append("Could not find file for the medium ");
      errorBuilder.append("'/Users/johndoe/jclouds-virtualbox-test/testadmin.vdi' (0x80BB0001)");
View Full Code Here

      IMachine machine = createMock(IMachine.class);
      IVirtualBox vBox = createMock(IVirtualBox.class);
      IMedium medium = createMock(IMedium.class);
      IMedium newHardDisk = createMock(IMedium.class);
      IProgress progress = createNiceMock(IProgress.class);

      expect(manager.getVBox()).andReturn(vBox).anyTimes();
      expect(vBox.openMedium(adminDiskPath, DeviceType.HardDisk, AccessMode.ReadWrite, false)).andReturn(medium);

      expect(medium.deleteStorage()).andReturn(progress);
View Full Code Here

      IMachine machine = createMock(IMachine.class);
      IVirtualBox vBox = createMock(IVirtualBox.class);
      IMedium medium = createMock(IMedium.class);

      IMedium newHardDisk = createMock(IMedium.class);
      IProgress progress = createNiceMock(IProgress.class);

      expect(manager.getVBox()).andReturn(vBox).anyTimes();
      expect(vBox.openMedium(adminDiskPath, DeviceType.HardDisk, AccessMode.ReadWrite, false)).andReturn(medium);

      String oldMachineId = "a1e03931-29f3-4370-ada3-9547b1009212";
View Full Code Here

      IMachine machine = createMock(IMachine.class);
      IVirtualBox vBox = createMock(IVirtualBox.class);
      IMedium medium = createMock(IMedium.class);
      IMedium newHardDisk = createMock(IMedium.class);
      IProgress progress = createNiceMock(IProgress.class);

      expect(manager.getVBox()).andReturn(vBox).anyTimes();
      expect(vBox.openMedium(adminDiskPath, DeviceType.HardDisk, AccessMode.ReadWrite, false)).andReturn(medium);

      replay(manager, machine, vBox, medium, newHardDisk, progress, machineUtils);
View Full Code Here

      MachineUtils machineUtils = createMock(MachineUtils.class);

      IMachine machine = createMock(IMachine.class);
      IVirtualBox vBox = createMock(IVirtualBox.class);
      IMedium medium = createMock(IMedium.class);
      IProgress progress = createNiceMock(IProgress.class);

      String errorMessage = "VirtualBox error: Some other VBox error";

      expect(manager.getVBox()).andReturn(vBox).anyTimes();
View Full Code Here

TOP

Related Classes of org.virtualbox_4_2.VirtualBoxManager

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.