mirror of https://github.com/apache/jclouds.git
issue 384: small fixes to UnregisterMachine to destroy all the media attached, removed lzma lib, add memory to CreateAndInstallVmLiveTest
This commit is contained in:
parent
4e834c146d
commit
f3e8c617ec
|
@ -59,12 +59,6 @@
|
||||||
<artifactId>byon</artifactId>
|
<artifactId>byon</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.jponge</groupId>
|
|
||||||
<artifactId>lzma-java</artifactId>
|
|
||||||
<version>1.2</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>jetty-security</artifactId>
|
<artifactId>jetty-security</artifactId>
|
||||||
|
|
|
@ -20,18 +20,23 @@
|
||||||
package org.jclouds.virtualbox.functions.admin;
|
package org.jclouds.virtualbox.functions.admin;
|
||||||
|
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.virtualbox.domain.ErrorCode;
|
import org.jclouds.virtualbox.domain.ErrorCode;
|
||||||
import org.virtualbox_4_1.CleanupMode;
|
import org.virtualbox_4_1.CleanupMode;
|
||||||
import org.virtualbox_4_1.IMachine;
|
import org.virtualbox_4_1.IMachine;
|
||||||
|
import org.virtualbox_4_1.IMedium;
|
||||||
|
import org.virtualbox_4_1.IProgress;
|
||||||
import org.virtualbox_4_1.VBoxException;
|
import org.virtualbox_4_1.VBoxException;
|
||||||
import org.virtualbox_4_1.VirtualBoxManager;
|
import org.virtualbox_4_1.VirtualBoxManager;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import com.google.common.base.Function;
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.inject.Named;
|
|
||||||
|
|
||||||
public class UnregisterMachineIfExists implements Function<String, Void> {
|
public class UnregisterMachineIfExists implements Function<String, Void> {
|
||||||
|
|
||||||
|
@ -49,9 +54,11 @@ public class UnregisterMachineIfExists implements Function<String, Void> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void apply(@Nullable String vmName) {
|
public Void apply(@Nullable String vmName) {
|
||||||
|
List<IMedium> mediaToBeDeleted = null;
|
||||||
|
IMachine machine = null;
|
||||||
try {
|
try {
|
||||||
IMachine machine = manager.getVBox().findMachine(vmName);
|
machine = manager.getVBox().findMachine(vmName);
|
||||||
machine.unregister(mode);
|
mediaToBeDeleted = machine.unregister(mode);
|
||||||
} catch (VBoxException e) {
|
} catch (VBoxException e) {
|
||||||
ErrorCode errorCode = ErrorCode.valueOf(e);
|
ErrorCode errorCode = ErrorCode.valueOf(e);
|
||||||
switch (errorCode) {
|
switch (errorCode) {
|
||||||
|
@ -62,6 +69,16 @@ public class UnregisterMachineIfExists implements Function<String, Void> {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* deletion of all files is currently disabled on Windows/x64 to
|
||||||
|
prevent a crash
|
||||||
|
*/
|
||||||
|
try {
|
||||||
|
IProgress deletion = machine.delete(mediaToBeDeleted);
|
||||||
|
deletion.waitForCompletion(-1);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ public class CreateAndInstallVmLiveTest extends BaseVirtualBoxClientLiveTest {
|
||||||
.attachISO(0, 0, workingDir + "/ubuntu-11.04-server-i386.iso")
|
.attachISO(0, 0, workingDir + "/ubuntu-11.04-server-i386.iso")
|
||||||
.attachHardDisk(0, 1, workingDir + "/testadmin.vdi")
|
.attachHardDisk(0, 1, workingDir + "/testadmin.vdi")
|
||||||
.attachISO(1, 1, workingDir + "/VBoxGuestAdditions_4.1.2.iso").build();
|
.attachISO(1, 1, workingDir + "/VBoxGuestAdditions_4.1.2.iso").build();
|
||||||
VmSpec vmSpecification = VmSpec.builder().id(vmId).name(vmName).osTypeId(osTypeId)
|
VmSpec vmSpecification = VmSpec.builder().id(vmId).name(vmName).memoryMB(512).osTypeId(osTypeId)
|
||||||
.controller(ideController)
|
.controller(ideController)
|
||||||
.forceOverwrite(true)
|
.forceOverwrite(true)
|
||||||
.natNetworkAdapter(0, NatAdapter.builder().tcpRedirectRule("127.0.0.1", 2222, "", 22).build()).build();
|
.natNetworkAdapter(0, NatAdapter.builder().tcpRedirectRule("127.0.0.1", 2222, "", 22).build()).build();
|
||||||
|
|
Loading…
Reference in New Issue