private IMachine getVmWithGuestAdditionsInstalled() { MasterSpec masterSpecForTest = super.getMasterSpecForTest(); try { Injector injector = view.utils().injector(); return injector.getInstance(CreateAndInstallVm.class).apply(masterSpecForTest); } catch (IllegalStateException e) { // already created return manager.get().getVBox().findMachine(masterSpecForTest.getVmSpec().getVmId()); } }
private IMachine cloneFromMaster() { IMachine source = getVmWithGuestAdditionsInstalled(); CloneSpec cloneSpec = CloneSpec.builder() .vm(machineSpec.getVmSpec()) .network(machineSpec.getNetworkSpec()) .master(source) .linked(true) .build(); return new CloneAndRegisterMachineFromIMachineIfNotAlreadyExists( manager, workingDir, machineUtils) .apply(cloneSpec); }
@Override @BeforeClass(groups = "live") public void setupContext() { super.setupContext(); instanceName = VIRTUALBOX_IMAGE_PREFIX + CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, getClass().getSimpleName()); StorageController ideController = StorageController.builder() .name("IDE Controller") .bus(StorageBus.IDE) .attachISO(0, 0, operatingSystemIso) .attachHardDisk( HardDisk.builder() .diskpath(adminDisk(instanceName)) .controllerPort(0) .deviceSlot(1) .autoDelete(true) .build()) .attachISO(1, 1, guestAdditionsIso) .build(); VmSpec instanceVmSpec = VmSpec.builder() .id(instanceName) .name(instanceName) .osTypeId("") .memoryMB(512) .cleanUpMode(CleanupMode.Full) .controller(ideController) .forceOverwrite(true) .build(); Injector injector = view.utils().injector(); Function<String, String> configProperties = injector.getInstance(ValueOfConfigurationKeyOrNull.class); IsoSpec isoSpec = IsoSpec.builder() .sourcePath(operatingSystemIso) .installationScript( configProperties .apply(VIRTUALBOX_INSTALLATION_KEY_SEQUENCE) .replace("HOSTNAME", instanceVmSpec.getVmName())) .build(); NetworkAdapter networkAdapter = NetworkAdapter.builder() .networkAttachmentType(NetworkAttachmentType.NAT) .tcpRedirectRule("127.0.0.1", 2222, "", 22) .build(); NetworkInterfaceCard networkInterfaceCard = NetworkInterfaceCard.builder().addNetworkAdapter(networkAdapter).build(); NetworkSpec networkSpec = NetworkSpec.builder().addNIC(networkInterfaceCard).build(); machineSpec = MasterSpec.builder().iso(isoSpec).vm(instanceVmSpec).network(networkSpec).build(); }