Skip to content
This repository was archived by the owner on Mar 25, 2018. It is now read-only.

Commit ac0e5f5

Browse files
committed
added support for vbox 4.2.6;
added hostname support; added generic md5 support; dralves`s comments addressed adrian`s comments addressed dralver`s comments addressed second round of comments addressed fix CreateAndRegisterMachineFromIsoIfNotAlreadyExistsLiveTest formatting swept check* updated jclouds-sshj pom.xml with latest bouncycastle version
1 parent b8b258d commit ac0e5f5

File tree

104 files changed

+1486
-1365
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+1486
-1365
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ bin/
1515
TAGS
1616
.metadata/
1717
atlassian-ide-plugin.xml
18+
.DS_Store

drivers/sshj/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@
5656
</properties>
5757

5858
<dependencies>
59+
<!-- until sshj will update to latest bouncycastle 1.47 -->
60+
<dependency>
61+
<groupId>org.bouncycastle</groupId>
62+
<artifactId>bcpkix-jdk15on</artifactId>
63+
<version>1.47</version>
64+
</dependency>
5965
<dependency>
6066
<groupId>org.jclouds</groupId>
6167
<artifactId>jclouds-compute</artifactId>

labs/virtualbox/.DS_Store

6 KB
Binary file not shown.

labs/virtualbox/pom.xml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@
3535
<packaging>bundle</packaging>
3636

3737
<properties>
38+
<virtualbox.version>4.2.6</virtualbox.version>
3839
<test.virtualbox.endpoint>http://localhost:18083/</test.virtualbox.endpoint>
39-
<test.virtualbox.api-version>4.1.4</test.virtualbox.api-version>
40-
<test.virtualbox.build-version>4.1.20r80170</test.virtualbox.build-version>
40+
<test.virtualbox.api-version>4.2.6</test.virtualbox.api-version>
41+
<test.virtualbox.build-version>${virtualbox.version}</test.virtualbox.build-version>
4142
<test.virtualbox.identity>${user.name}</test.virtualbox.identity>
4243
<test.virtualbox.credential>CHANGE_ME</test.virtualbox.credential>
4344
<test.virtualbox.template>osFamily=UBUNTU,osVersionMatches=12.04.1,os64Bit=true,osArchMatches=amd64,loginUser=toor:password,authenticateSudo=true</test.virtualbox.template>
@@ -49,7 +50,7 @@
4950
*
5051
</jclouds.osgi.import>
5152
</properties>
52-
53+
5354
<dependencies>
5455
<dependency>
5556
<groupId>org.jclouds</groupId>
@@ -59,7 +60,7 @@
5960
<dependency>
6061
<groupId>org.virtualbox</groupId>
6162
<artifactId>vboxjws</artifactId>
62-
<version>${test.virtualbox.api-version}</version>
63+
<version>${virtualbox.version}</version>
6364
</dependency>
6465
<dependency>
6566
<groupId>org.jclouds.api</groupId>
@@ -86,6 +87,11 @@
8687
<artifactId>jclouds-slf4j</artifactId>
8788
<version>${project.version}</version>
8889
</dependency>
90+
<dependency>
91+
<groupId>ch.qos.logback</groupId>
92+
<artifactId>logback-classic</artifactId>
93+
<scope>test</scope>
94+
</dependency>
8995
<dependency>
9096
<groupId>org.jclouds</groupId>
9197
<artifactId>jclouds-core</artifactId>
@@ -100,11 +106,6 @@
100106
<type>test-jar</type>
101107
<scope>test</scope>
102108
</dependency>
103-
<dependency>
104-
<groupId>ch.qos.logback</groupId>
105-
<artifactId>logback-classic</artifactId>
106-
<scope>test</scope>
107-
</dependency>
108109
<dependency>
109110
<groupId>org.testng</groupId>
110111
<artifactId>testng</artifactId>

labs/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBox.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
package org.jclouds.virtualbox;
2121

22-
import org.virtualbox_4_1.VirtualBoxManager;
22+
import org.virtualbox_4_2.VirtualBoxManager;
2323

2424
public class VirtualBox {
2525

labs/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBoxApiMetadata.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@
2020

2121
import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE;
2222
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_DEFAULT_DIR;
23+
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_GUEST_MEMORY;
2324
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_IMAGES_DESCRIPTOR;
2425
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_INSTALLATION_KEY_SEQUENCE;
2526
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_PRECONFIGURATION_URL;
2627
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_WORKINGDIR;
27-
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_GUEST_MEMORY;
28-
2928

3029
import java.io.File;
3130
import java.net.URI;
@@ -65,23 +64,24 @@ public static Properties defaultProperties() {
6564

6665
properties.put(VIRTUALBOX_INSTALLATION_KEY_SEQUENCE, "<Esc><Esc><Enter> "
6766
+ "/install/vmlinuz noapic preseed/url=PRECONFIGURATION_URL "
68-
+ "debian-installer=en_US auto locale=en_US kbd-chooser/method=us " + "hostname=" + "HOSTNAME "
67+
+ "debian-installer=en_US auto locale=en_US kbd-chooser/method=us "
68+
+ "hostname=" + "HOSTNAME "
6969
+ "fb=false debconf/frontend=noninteractive "
70-
+ "keyboard-configuration/layout=USA keyboard-configuration/variant=USA console-setup/ask_detect=false "
70+
+ "console-setup/ask_detect=false keyboard-configuration/layoutcode=us "
7171
+ "initrd=/install/initrd.gz -- <Enter>");
7272

7373
String workingDir = System.getProperty("test.virtualbox.workingDir", VIRTUALBOX_DEFAULT_DIR);
7474
properties.put(VIRTUALBOX_WORKINGDIR, workingDir);
7575

76-
String ram = System.getProperty(VIRTUALBOX_GUEST_MEMORY, "1024");
76+
String ram = System.getProperty(VIRTUALBOX_GUEST_MEMORY, "512");
7777
properties.put(VIRTUALBOX_GUEST_MEMORY, ram);
7878

7979
String yamlDescriptor = System.getProperty("test.virtualbox.image.descriptor.yaml", VIRTUALBOX_WORKINGDIR
8080
+ File.separator + "images.yaml");
8181

8282
properties.put(VIRTUALBOX_IMAGES_DESCRIPTOR, yamlDescriptor);
8383
properties.put(VIRTUALBOX_PRECONFIGURATION_URL, "http://10.0.2.2:23232/preseed.cfg");
84-
properties.setProperty(TEMPLATE, "osFamily=UBUNTU,osVersionMatches=12.04.1,os64Bit=true,osArchMatches=amd64");
84+
properties.setProperty(TEMPLATE, "osFamily=UBUNTU,osVersionMatches=12.04.1,os64Bit=true,osArchMatches=amd64");
8585
return properties;
8686
}
8787

@@ -96,10 +96,9 @@ protected Builder() {
9696
.defaultIdentity(System.getProperty("user.name"))
9797
.defaultCredential("CHANGE_ME")
9898
.defaultEndpoint("http://localhost:18083/")
99-
.documentation(URI.create("https://github.com/jclouds/jclouds/tree/master/apis/byon"))
100-
// later version not in maven, yet
101-
.version("4.1.4")
102-
.buildVersion("4.1.8r75467")
99+
.documentation(URI.create("https://github.com/jclouds/jclouds/tree/master/labs/virtualbox"))
100+
.version("4.2.4")
101+
.buildVersion("4.2.4")
103102
.defaultProperties(VirtualBoxApiMetadata.defaultProperties())
104103
.view(ComputeServiceContext.class)
105104
.defaultModules(ImmutableSet.<Class<? extends Module>>of(HardcodeLocalhostAsNodeMetadataSupplier.class, VirtualBoxComputeServiceContextModule.class));

labs/virtualbox/src/main/java/org/jclouds/virtualbox/compute/LoadMachineFromVirtualBox.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131

3232
import org.jclouds.byon.Node;
3333
import org.jclouds.compute.domain.OsFamily;
34-
import org.virtualbox_4_1.IGuestOSType;
35-
import org.virtualbox_4_1.IMachine;
36-
import org.virtualbox_4_1.VirtualBoxManager;
34+
import org.virtualbox_4_2.IGuestOSType;
35+
import org.virtualbox_4_2.IMachine;
36+
import org.virtualbox_4_2.VirtualBoxManager;
3737

3838
import com.google.common.base.Function;
3939
import com.google.common.cache.CacheLoader;

labs/virtualbox/src/main/java/org/jclouds/virtualbox/compute/VirtualBoxComputeServiceAdapter.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@
4747
import org.jclouds.virtualbox.domain.YamlImage;
4848
import org.jclouds.virtualbox.functions.admin.UnregisterMachineIfExistsAndForceDeleteItsMedia;
4949
import org.jclouds.virtualbox.util.MachineController;
50-
import org.virtualbox_4_1.IMachine;
51-
import org.virtualbox_4_1.IProgress;
52-
import org.virtualbox_4_1.ISession;
53-
import org.virtualbox_4_1.MachineState;
54-
import org.virtualbox_4_1.VBoxException;
55-
import org.virtualbox_4_1.VirtualBoxManager;
50+
import org.virtualbox_4_2.IMachine;
51+
import org.virtualbox_4_2.IProgress;
52+
import org.virtualbox_4_2.ISession;
53+
import org.virtualbox_4_2.MachineState;
54+
import org.virtualbox_4_2.VBoxException;
55+
import org.virtualbox_4_2.VirtualBoxManager;
5656

5757
import com.google.common.base.Function;
5858
import com.google.common.base.Predicate;
@@ -90,7 +90,7 @@ public VirtualBoxComputeServiceAdapter(Supplier<VirtualBoxManager> manager,
9090
Function<NodeSpec, NodeAndInitialCredentials<IMachine>> cloneCreator,
9191
Function<IMachine, Image> imachineToImage,
9292
MachineController machineController) {
93-
this.manager = checkNotNull(manager, "manager");
93+
this.manager = checkNotNull(manager, "virtualbox manager can't be null");
9494
this.imagesToYamlImages = imagesMapper.get();
9595
this.mastersLoader = mastersLoader;
9696
this.cloneCreator = cloneCreator;
@@ -254,10 +254,10 @@ private void powerDownMachine(IMachine machine) {
254254
logger.debug("vm was already powered down: ", machine.getId());
255255
return;
256256
}
257-
logger.debug("powering down vm: %s", machine.getName());
257+
logger.debug("<< powering down vm(%s)", machine.getName());
258258
machineController.ensureMachineHasPowerDown(machine.getName());
259259
} catch (Exception e) {
260-
logger.error(e, "problem in powering down the %s", machine.getName());
260+
logger.error(e, "problem in powering down vm(%s)", machine.getName());
261261
throw Throwables.propagate(e);
262262
}
263263
}

labs/virtualbox/src/main/java/org/jclouds/virtualbox/compute/extensions/VirtualBoxImageExtension.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,18 @@
4747
import org.jclouds.virtualbox.functions.TakeSnapshotIfNotAlreadyAttached;
4848
import org.jclouds.virtualbox.functions.admin.UnregisterMachineIfExistsAndDeleteItsMedia;
4949
import org.jclouds.virtualbox.util.MachineUtils;
50-
import org.virtualbox_4_1.CloneMode;
51-
import org.virtualbox_4_1.CloneOptions;
52-
import org.virtualbox_4_1.IMachine;
53-
import org.virtualbox_4_1.IProgress;
54-
import org.virtualbox_4_1.ISnapshot;
55-
import org.virtualbox_4_1.VirtualBoxManager;
50+
import org.virtualbox_4_2.CloneMode;
51+
import org.virtualbox_4_2.CloneOptions;
52+
import org.virtualbox_4_2.IMachine;
53+
import org.virtualbox_4_2.IProgress;
54+
import org.virtualbox_4_2.ISnapshot;
55+
import org.virtualbox_4_2.VirtualBoxManager;
5656

5757
import com.google.common.base.Function;
5858
import com.google.common.base.Optional;
5959
import com.google.common.base.Predicate;
6060
import com.google.common.base.Supplier;
61+
import com.google.common.collect.ImmutableList;
6162
import com.google.common.collect.Iterables;
6263
import com.google.common.collect.Lists;
6364
import com.google.common.util.concurrent.Futures;
@@ -118,9 +119,12 @@ public ListenableFuture<Image> createImage(ImageTemplate template) {
118119

119120
IMachine source = manager.get().getVBox().findMachine(cloneTemplate.getSourceNodeId());
120121

121-
String settingsFile = manager.get().getVBox().composeMachineFilename(template.getName(), workingDir);
122+
String flags = "";
123+
List<String> groups = ImmutableList.of();
124+
String group = "";
125+
String settingsFile = manager.get().getVBox().composeMachineFilename(template.getName(), group , flags , workingDir);
122126
IMachine clonedMachine = manager.get().getVBox()
123-
.createMachine(settingsFile, template.getName(), source.getOSTypeId(), template.getName(), true);
127+
.createMachine(settingsFile, template.getName(), groups, source.getOSTypeId(), flags);
124128

125129
List<CloneOptions> options = Lists.newArrayList();
126130
if (isLinkedClone)
@@ -136,7 +140,7 @@ public ListenableFuture<Image> createImage(ImageTemplate template) {
136140
IProgress progress = currentSnapshot.getMachine().cloneTo(clonedMachine, CloneMode.MachineState, options);
137141
progress.waitForCompletion(-1);
138142

139-
logger.debug(String.format("Machine %s is cloned correctly", clonedMachine.getName()));
143+
logger.debug(String.format("<< master(%s) is cloned correctly to vm(%s)", source.getName(), clonedMachine.getName()));
140144

141145
// registering
142146
manager.get().getVBox().registerMachine(clonedMachine);

labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@
6262
import org.jclouds.virtualbox.functions.admin.PreseedCfgServer;
6363
import org.jclouds.virtualbox.functions.admin.StartVBoxIfNotAlreadyRunning;
6464
import org.jclouds.virtualbox.predicates.SshResponds;
65-
import org.virtualbox_4_1.IMachine;
66-
import org.virtualbox_4_1.LockType;
67-
import org.virtualbox_4_1.MachineState;
68-
import org.virtualbox_4_1.VirtualBoxManager;
65+
import org.virtualbox_4_2.IMachine;
66+
import org.virtualbox_4_2.LockType;
67+
import org.virtualbox_4_2.MachineState;
68+
import org.virtualbox_4_2.VirtualBoxManager;
6969

7070
import com.google.common.annotations.VisibleForTesting;
7171
import com.google.common.base.Function;
@@ -104,15 +104,15 @@ protected void configure() {
104104
bind(new TypeLiteral<Function<IMachine, Image>>() {
105105
}).to(IMachineToImage.class);
106106
bind(new TypeLiteral<CacheLoader<IsoSpec, URI>>() {
107-
}).to((Class) PreseedCfgServer.class);
107+
}).to(Class.class.cast(PreseedCfgServer.class));
108108
bind(new TypeLiteral<Function<URI, File>>() {
109-
}).to((Class) FileDownloadFromURI.class);
109+
}).to(Class.class.cast(FileDownloadFromURI.class));
110110

111111
bind(new TypeLiteral<Supplier<VirtualBoxManager>>() {
112-
}).to((Class) StartVBoxIfNotAlreadyRunning.class);
112+
}).to(Class.class.cast(StartVBoxIfNotAlreadyRunning.class));
113113
// the yaml config to image mapper
114114
bind(new TypeLiteral<Supplier<Map<Image, YamlImage>>>() {
115-
}).to((Class) ImagesToYamlImagesFromYamlDescriptor.class);
115+
}).to(Class.class.cast(ImagesToYamlImagesFromYamlDescriptor.class));
116116
// the yaml config provider
117117
bind(YamlImagesFromFileConfig.class);
118118

@@ -126,15 +126,15 @@ protected void configure() {
126126

127127
// the master creating function
128128
bind(new TypeLiteral<Function<MasterSpec, IMachine>>() {
129-
}).to((Class) CreateAndInstallVm.class);
129+
}).to(Class.class.cast(CreateAndInstallVm.class));
130130
// the machine cloning function
131131
bind(new TypeLiteral<Function<NodeSpec, NodeAndInitialCredentials<IMachine>>>() {
132-
}).to((Class) NodeCreator.class);
132+
}).to(Class.class.cast(NodeCreator.class));
133133
bind(new TypeLiteral<Function<CloneSpec, IMachine>>() {
134-
}).to((Class) CloneAndRegisterMachineFromIMachineIfNotAlreadyExists.class);
134+
}).to(Class.class.cast(CloneAndRegisterMachineFromIMachineIfNotAlreadyExists.class));
135135
// the jetty server provider
136136
bind(new TypeLiteral<Server>() {
137-
}).to((Class) PreseedCfgServer.class).asEagerSingleton();
137+
}).to(Class.class.cast(PreseedCfgServer.class)).asEagerSingleton();
138138

139139
bind(new TypeLiteral<Function<IMachine, SshClient>>() {
140140
}).to(IMachineToSshClient.class);

labs/virtualbox/src/main/java/org/jclouds/virtualbox/domain/BridgedIf.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,15 @@ public BridgedIf build() {
115115
public BridgedIf(String name, String guid, String dhcp, String ipAddress,
116116
String networkMask, String ipv6Address, String iv6NetworkMask,
117117
String mediumType, String status) {
118-
this.name = checkNotNull(name, "bridgedIf name");
118+
this.name = checkNotNull(name, "bridgedIf name can't be null");
119119
this.guid = guid;
120120
this.dhcp = dhcp;
121-
this.ipAddress = checkNotNull(ipAddress, "bridgedIf ipAddress");
121+
this.ipAddress = checkNotNull(ipAddress, "bridgedIf ipAddress can't be null");
122122
this.networkMask = networkMask;
123123
this.ipv6Address = ipv6Address;
124124
this.ipv6NetworkMask = iv6NetworkMask;
125125
this.mediumType = mediumType;
126-
this.status = checkNotNull(status, "bridgedIf status");
126+
this.status = checkNotNull(status, "bridgedIf status can't be null");
127127
}
128128

129129
public String getName() {

labs/virtualbox/src/main/java/org/jclouds/virtualbox/domain/CloneSpec.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import static com.google.common.base.Preconditions.checkNotNull;
2323

24-
import org.virtualbox_4_1.IMachine;
24+
import org.virtualbox_4_2.IMachine;
2525

2626
import com.google.common.base.Objects;
2727

@@ -74,12 +74,9 @@ public CloneSpec build() {
7474
}
7575

7676
public CloneSpec(VmSpec vmSpec, NetworkSpec networkSpec, IMachine master, boolean isLinked) {
77-
checkNotNull(vmSpec, "vmSpec");
78-
checkNotNull(networkSpec, "networkSpec");
79-
checkNotNull(master, "master");
80-
this.vmSpec = vmSpec;
81-
this.networkSpec = networkSpec;
82-
this.master = master;
77+
this.vmSpec = checkNotNull(vmSpec, "vmSpec can't be null");
78+
this.networkSpec = checkNotNull(networkSpec, "networkSpec can't be null");
79+
this.master = checkNotNull(master, "master can't be null");
8380
this.isLinked = isLinked;
8481
}
8582

labs/virtualbox/src/main/java/org/jclouds/virtualbox/domain/DeviceDetails.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import static com.google.common.base.Preconditions.checkNotNull;
2323

24-
import org.virtualbox_4_1.DeviceType;
24+
import org.virtualbox_4_2.DeviceType;
2525

2626
import com.google.common.base.Objects;
2727

@@ -43,10 +43,9 @@ public class DeviceDetails {
4343
private final DeviceType deviceType;
4444

4545
public DeviceDetails(int port, int deviceSlot, DeviceType deviceType) {
46-
checkNotNull(deviceType, "deviceType");
4746
this.port = port;
4847
this.deviceSlot = deviceSlot;
49-
this.deviceType = deviceType;
48+
this.deviceType = checkNotNull(deviceType, "deviceType can't be null");
5049
}
5150

5251
public int getPort() {
@@ -87,7 +86,7 @@ public Builder deviceSlot(int slot) {
8786
}
8887

8988
public DeviceDetails build() {
90-
checkNotNull(deviceType, "deviceType");
89+
checkNotNull(deviceType, "deviceType can't be null");
9190
return new DeviceDetails(port, deviceSlot, deviceType);
9291
}
9392
}

labs/virtualbox/src/main/java/org/jclouds/virtualbox/domain/ErrorCode.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121

2222
import java.util.Map;
2323

24-
import org.virtualbox_4_1.VBoxException;
25-
import org.virtualbox_4_1.jaxws.RuntimeFaultMsg;
24+
import org.virtualbox_4_2.VBoxException;
25+
import org.virtualbox_4_2.jaxws.RuntimeFaultMsg;
2626

2727
import com.google.common.collect.ImmutableMap;
2828

@@ -76,7 +76,7 @@ public enum ErrorCode {
7676
this.code = code;
7777
}
7878

79-
private static final Map<Long, ErrorCode> TABLE;
79+
private final static Map<Long, ErrorCode> TABLE;
8080
static {
8181
ImmutableMap.Builder<Long, ErrorCode> builder = ImmutableMap.builder();
8282
for (ErrorCode errorCode : ErrorCode.values()) {

0 commit comments

Comments
 (0)