mirror of https://github.com/apache/jclouds.git
clones are now booting, but without networking
This commit is contained in:
parent
2e1f1e5da8
commit
cf02e7dcaf
|
@ -22,7 +22,6 @@ package org.jclouds.virtualbox.functions;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
@ -31,6 +30,7 @@ import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.virtualbox.config.VirtualBoxConstants;
|
import org.jclouds.virtualbox.config.VirtualBoxConstants;
|
||||||
import org.jclouds.virtualbox.domain.CloneSpec;
|
import org.jclouds.virtualbox.domain.CloneSpec;
|
||||||
import org.jclouds.virtualbox.domain.NetworkInterfaceCard;
|
import org.jclouds.virtualbox.domain.NetworkInterfaceCard;
|
||||||
|
import org.jclouds.virtualbox.domain.NetworkSpec;
|
||||||
import org.jclouds.virtualbox.domain.VmSpec;
|
import org.jclouds.virtualbox.domain.VmSpec;
|
||||||
import org.jclouds.virtualbox.util.MachineUtils;
|
import org.jclouds.virtualbox.util.MachineUtils;
|
||||||
import org.virtualbox_4_1.CloneMode;
|
import org.virtualbox_4_1.CloneMode;
|
||||||
|
@ -96,6 +96,7 @@ public class CloneAndRegisterMachineFromIMachineIfNotAlreadyExists implements
|
||||||
|
|
||||||
private IMachine cloneMachine(CloneSpec cloneSpec) {
|
private IMachine cloneMachine(CloneSpec cloneSpec) {
|
||||||
VmSpec vmSpec = cloneSpec.getVmSpec();
|
VmSpec vmSpec = cloneSpec.getVmSpec();
|
||||||
|
NetworkSpec networkSpec = cloneSpec.getNetworkSpec();
|
||||||
boolean isLinkedClone = cloneSpec.isLinked();
|
boolean isLinkedClone = cloneSpec.isLinked();
|
||||||
IMachine master = cloneSpec.getMaster();
|
IMachine master = cloneSpec.getMaster();
|
||||||
String settingsFile = manager.get().getVBox()
|
String settingsFile = manager.get().getVBox()
|
||||||
|
@ -124,18 +125,11 @@ public class CloneAndRegisterMachineFromIMachineIfNotAlreadyExists implements
|
||||||
// registering
|
// registering
|
||||||
manager.get().getVBox().registerMachine(clonedMachine);
|
manager.get().getVBox().registerMachine(clonedMachine);
|
||||||
|
|
||||||
// Bridged#
|
// Networking
|
||||||
// for (NetworkInterfaceCard nic : cloneSpec.getNetworkSpec().getNetworkInterfaceCards()){
|
for (NetworkInterfaceCard networkInterfaceCard : networkSpec.getNetworkInterfaceCards()) {
|
||||||
// ensureBridgedNetworkingIsAppliedToMachine(clonedMachine.getName(), nic);
|
new AttachNicToMachine(vmSpec.getVmName(), machineUtils).apply(networkInterfaceCard);
|
||||||
// }
|
}
|
||||||
|
|
||||||
return clonedMachine;
|
return clonedMachine;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ensureBridgedNetworkingIsAppliedToMachine(String vmName,
|
|
||||||
NetworkInterfaceCard nic) {
|
|
||||||
|
|
||||||
machineUtils.writeLockMachineAndApply(vmName,
|
|
||||||
new AttachBridgedAdapterToMachine(nic));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,13 +50,11 @@ public class NodeCreator implements Function<NodeSpec, NodeAndInitialCredentials
|
||||||
|
|
||||||
private final Supplier<VirtualBoxManager> manager;
|
private final Supplier<VirtualBoxManager> manager;
|
||||||
private final Function<CloneSpec, IMachine> cloner;
|
private final Function<CloneSpec, IMachine> cloner;
|
||||||
private MachineUtils machineUtils;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public NodeCreator(Supplier<VirtualBoxManager> manager, Function<CloneSpec, IMachine> cloner, MachineUtils machineUtils) {
|
public NodeCreator(Supplier<VirtualBoxManager> manager, Function<CloneSpec, IMachine> cloner, MachineUtils machineUtils) {
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
this.cloner = cloner;
|
this.cloner = cloner;
|
||||||
this.machineUtils = machineUtils;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -95,8 +93,6 @@ public class NodeCreator implements Function<NodeSpec, NodeAndInitialCredentials
|
||||||
|
|
||||||
IMachine cloned = cloner.apply(cloneSpec);
|
IMachine cloned = cloner.apply(cloneSpec);
|
||||||
|
|
||||||
new AttachNicToMachine(cloneName, machineUtils).apply(networkInterfaceCard);
|
|
||||||
|
|
||||||
new LaunchMachineIfNotAlreadyRunning(manager.get(), ExecutionType.GUI, "").apply(cloned);
|
new LaunchMachineIfNotAlreadyRunning(manager.get(), ExecutionType.GUI, "").apply(cloned);
|
||||||
|
|
||||||
// TODO get credentials from somewhere else (they are also HC in IMachineToSshClient)
|
// TODO get credentials from somewhere else (they are also HC in IMachineToSshClient)
|
||||||
|
|
Loading…
Reference in New Issue