Package org.virtualbox_4_2

Examples of org.virtualbox_4_2.IHostNetworkInterface


      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);
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);
      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();
      expect(session.getConsole()).andReturn(console);
      expect(console.takeSnapshot(snapshotName, snapshotDesc)).andReturn(
            progress);

      session.unlockMachine();
      replay(manager, machine, vBox, session, console, progress);
View Full Code Here

      if (nodeState == null)
         nodeState = Status.UNRECOGNIZED;
      nodeMetadataBuilder.status(nodeState);
      nodeMetadataBuilder = getIpAddresses(vm, nodeMetadataBuilder);
     
      IGuestOSType guestOSType = virtualboxManager.get().getVBox().getGuestOSType(vm.getOSTypeId());
      OsFamily family = parseOsFamilyOrUnrecognized(guestOSType.getDescription());
      String version = parseVersionOrReturnEmptyString(family, guestOSType.getDescription(), osVersionMap);
      OperatingSystem os = OperatingSystem.builder().description(guestOSType.getDescription()).family(family)
               .version(version).is64Bit(guestOSType.getIs64Bit()).build();
      nodeMetadataBuilder.operatingSystem(os);

      String guestOsUser = vm.getExtraData(GUEST_OS_USER);
      String guestOsPassword = vm.getExtraData(GUEST_OS_PASSWORD);
      nodeMetadataBuilder.credentials(LoginCredentials.builder()
View Full Code Here

         NetworkInterfaceCard hostOnlyIfaceCard) {
      return NetworkSpec.builder().addNIC(hostOnlyIfaceCard).addNIC(natIfaceCard).build();
   }

   public String getHostOnlyIfOrCreate() {
      IHostNetworkInterface availableHostInterfaceIf = returnExistingHostNetworkInterfaceWithDHCPenabledOrNull(manager
            .get().getVBox().getHost().getNetworkInterfaces());
      if (availableHostInterfaceIf == null) {
         final String hostOnlyIfName = createHostOnlyIf();
         assignDHCPtoHostOnlyInterface(hostOnlyIfName);
         return hostOnlyIfName;
      } else {
         return availableHostInterfaceIf.getName();
      }
   }
View Full Code Here

   }

   private void assignDHCPtoHostOnlyInterface(final String hostOnlyIfName) {
      List<IHostNetworkInterface> availableNetworkInterfaces = manager.get().getVBox().getHost().getNetworkInterfaces();

      IHostNetworkInterface iHostNetworkInterfaceWithHostOnlyIfName = Iterables.getOnlyElement(Iterables.filter(
            availableNetworkInterfaces, new Predicate<IHostNetworkInterface>() {

               @Override
               public boolean apply(IHostNetworkInterface iHostNetworkInterface) {
                  return iHostNetworkInterface.getName().equals(hostOnlyIfName);
               }
            }));

      String hostOnlyIfIpAddress = iHostNetworkInterfaceWithHostOnlyIfName.getIPAddress();
      String dhcpIpAddress = hostOnlyIfIpAddress.substring(0, hostOnlyIfIpAddress.lastIndexOf(".")) + ".254";
      String dhcpNetmask = "255.255.255.0";
      String dhcpLowerIp = hostOnlyIfIpAddress.substring(0, hostOnlyIfIpAddress.lastIndexOf(".")) + ".2";
      String dhcpUpperIp = hostOnlyIfIpAddress.substring(0, hostOnlyIfIpAddress.lastIndexOf(".")) + ".253";
      NodeMetadata hostNodeMetadata = getHostNodeMetadata();
View Full Code Here

         NetworkInterfaceCard hostOnlyIfaceCard) {
      return NetworkSpec.builder().addNIC(hostOnlyIfaceCard).addNIC(natIfaceCard).build();
   }

   public String getHostOnlyIfOrCreate() {
      IHostNetworkInterface availableHostInterfaceIf = returnExistingHostNetworkInterfaceWithDHCPenabledOrNull(manager
            .get().getVBox().getHost().getNetworkInterfaces());
      if (availableHostInterfaceIf == null) {
         final String hostOnlyIfName = createHostOnlyIf();
         assignDHCPtoHostOnlyInterface(hostOnlyIfName);
         return hostOnlyIfName;
      } else {
         return availableHostInterfaceIf.getName();
      }
   }
View Full Code Here

   }

   private void assignDHCPtoHostOnlyInterface(final String hostOnlyIfName) {
      List<IHostNetworkInterface> availableNetworkInterfaces = manager.get().getVBox().getHost().getNetworkInterfaces();

      IHostNetworkInterface iHostNetworkInterfaceWithHostOnlyIfName = Iterables.getOnlyElement(Iterables.filter(
            availableNetworkInterfaces, new Predicate<IHostNetworkInterface>() {

               @Override
               public boolean apply(IHostNetworkInterface iHostNetworkInterface) {
                  return iHostNetworkInterface.getName().equals(hostOnlyIfName);
               }
            }));

      String hostOnlyIfIpAddress = iHostNetworkInterfaceWithHostOnlyIfName.getIPAddress();
      String dhcpIpAddress = hostOnlyIfIpAddress.substring(0, hostOnlyIfIpAddress.lastIndexOf(".")) + ".254";
      String dhcpNetmask = "255.255.255.0";
      String dhcpLowerIp = hostOnlyIfIpAddress.substring(0, hostOnlyIfIpAddress.lastIndexOf(".")) + ".2";
      String dhcpUpperIp = hostOnlyIfIpAddress.substring(0, hostOnlyIfIpAddress.lastIndexOf(".")) + ".253";
      NodeMetadata hostNodeMetadata = getHostNodeMetadata();
View Full Code Here

   public void testDoNothingIfAlreadyTakenSnapshot() throws Exception {
      String snapshotName = "snap";
      String snapshotDesc = "snapDesc";

      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);
      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();
      expect(session.getConsole()).andReturn(console);
      expect(console.takeSnapshot(snapshotName, snapshotDesc)).andReturn(
            progress);

      session.unlockMachine();
View Full Code Here

@Test(groups = "unit", testName = "AddIDEControllerIfNotExistsTest")
public class AddIDEControllerIfNotExistsTest {

   @Test
   public void testFine() throws Exception {
      IMachine vm = createMock(IMachine.class);

      String controllerName = "IDE Controller";
      StorageController storageController = StorageController.builder().bus(StorageBus.IDE).name(controllerName).build();

      expect(vm.addStorageController(controllerName, StorageBus.IDE)).andReturn(
              createNiceMock(IStorageController.class));
      vm.saveSettings();

      replay(vm);

      new AddIDEControllerIfNotExists(storageController).apply(vm);
View Full Code Here

      verify(vm);
   }

   @Test
   public void testAcceptableException() throws Exception {
      IMachine vm = createMock(IMachine.class);

      String controllerName = "IDE Controller";
      StorageController storageController = StorageController.builder().bus(StorageBus.IDE).name(controllerName).build();

      expect(vm.addStorageController(controllerName, StorageBus.IDE)).andThrow(
              new VBoxException(createNiceMock(Throwable.class),
                      "VirtualBox error: Storage controller named 'IDE Controller' already exists (0x80BB000C)"));

      replay(vm);
View Full Code Here

TOP

Related Classes of org.virtualbox_4_2.IHostNetworkInterface

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.