clones are now booting, but without networking

This commit is contained in:
David Ribeiro Alves 2012-03-05 04:40:22 +00:00
parent 2e1f1e5da8
commit cf02e7dcaf
2 changed files with 8 additions and 18 deletions

View File

@ -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()
@ -120,22 +121,15 @@ public class CloneAndRegisterMachineFromIMachineIfNotAlreadyExists implements
progress.waitForCompletion(-1); progress.waitForCompletion(-1);
logger.debug("clone done"); logger.debug("clone done");
// registering // registering
manager.get().getVBox().registerMachine(clonedMachine); manager.get().getVBox().registerMachine(clonedMachine);
// Bridged#
// for (NetworkInterfaceCard nic : cloneSpec.getNetworkSpec().getNetworkInterfaceCards()){
// ensureBridgedNetworkingIsAppliedToMachine(clonedMachine.getName(), nic);
// }
// Networking
for (NetworkInterfaceCard networkInterfaceCard : networkSpec.getNetworkInterfaceCards()) {
new AttachNicToMachine(vmSpec.getVmName(), machineUtils).apply(networkInterfaceCard);
}
return clonedMachine; return clonedMachine;
} }
private void ensureBridgedNetworkingIsAppliedToMachine(String vmName,
NetworkInterfaceCard nic) {
machineUtils.writeLockMachineAndApply(vmName,
new AttachBridgedAdapterToMachine(nic));
}
} }

View File

@ -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)