-
Notifications
You must be signed in to change notification settings - Fork 216
Virtualbox Image Store Design
Creation pipeline Consider ExecutionList or Functions.chain.. etc.
At the moment the CreateAndInstallVm function has too many responsabilities:
create the vm
install the guestAdditions
post-installation scripts
Maybe it could be better to have separated steps. Let’s identify those steps:
createAndInstallVm -> VM (NAT+PortForwarding) GuestAdditionsInstaller -> VM+GA (NAT+PortForwarding) PostInstallations -> MasterVM (VM+GA+cleanings and No NIC)
in PostInstallations there are a number of steps needed. At the moment I implemented:
cleanUpUdevIfNeeded: this is needed only for Ubuntu machine
but we definitely need:
detachAllNICs
detachAllISOs
cleanUpHostname
At this stage CloneMachineFromMaster will take care only to clone and to ensure Bridged NIC. Proposals I think we could move all the ensure* and detachAll* methods to machineUtils.
ensureNATadapterIsAttached should be ensureNATadapterIsAttachedToEth0 NetworkSpec desing we need to rethink about the NatAdapter and NetworkSpec.
We need to generalize a bit, cause not only NAT is interesting for us. Moreover NatAdapter contains only info to redirectRules (I think they could be a PortForwarding object)
Proposals In VmSpec we could specify the number of NIC that we want to have. NetworkSpec will specify the kind of adapter (NAT or Bridged) and the eventual PortForwarding rules. << ok so we know we will hit this, and then allow users to ask for it. ComputeAdapter options VirtualBoxComputeServiceAdapterLiveTest are not passing: basically because the default template doesn't match any image.
Proposal
listImages() return an empty collection. We need to ensure that at least the default master image is created before running CreateNodeWithGroupEncodedIntoNameThenStoreCredentials.
This should take care to look/create MasterVM and clone the machine
We could use a cache where we store (key, yaml description), where key simplify template matching i.e.: ‘ubuntu 11.04 server amd64’
CreateNodeWithGroupEncodedIntoNameThenStoreCredentials should:
createMasterIfNorAlreadyCreated() << this part handled by LoadingCache
cloneMaster() -> machine
machine.start()
loader LookupMasterFromBlobStoreContainerOrLazyCreate extends CacheLoader<IsoSpec, IMachine> {
IMachine apply (IsoSpec)
createMasterIfNorAlreadyCreated()
persist to blobstore images container w/blob named vm id
}
list implementation
BlobStore api directly:
@Provides
LoadingCache<IsoSpec, IMachine> provideImageCache(LookupMasterFromBlobStoreContainerOrLazyCreate loader, BlobStore blobstore, @Named(“something”) String containerForKnownImages){
cache = CacheBuilder.newBuilder().build(loader);
for (blob: blobstore.list(containerForKnownImages){
//try and if fail log and remove or ignore/mark bad, etc.
cache.getUnchecked(fromJson(blob.getPayload().getInput(), VBoxImage).getId());
return cache;
}
then.. in computeserviceadapter for listImages, we use BlobStore.list(_) (looks very much like Node from yaml in byon)
Otherwise can persist from Map<String,InputStream>, removing need to load BlobStore classes @Provides LoadingCache<IsoSpec, IMachine> provideImageCache(LookupMasterFromBlobStoreContainerOrLazyCreate loader, @Named(“vbox.image.container”) Map<String,InputStream> metaMap){ cache = CacheBuilder.newBuilder().build(loader); for (blob: metaMap.keySet()){ //try and if fail log and remove or ignore/mark bad, etc. cache.getUnchecked(fromJson(blob.getPayload().getInput(), VBoxImage).getId()); return cache; }