LabBuilder icon indicating copy to clipboard operation
LabBuilder copied to clipboard

Add support for Building a Lab using Cidney

Open PlagueHO opened this issue 8 years ago • 5 comments

This will enable building VMs in Parallel using Runspaces.

https://github.com/Cidney/Cidney

PlagueHO avatar Mar 16 '16 22:03 PlagueHO

This should be straight forward. I haven't spent much time looking at your stuff yet but from the readme file it should go something like this. This is the most simpliest:

Pipeline: MyLab {
    Stage: BuildLab 
    {
        Install-Lab -ConfigPath 'c:\MyLab\Configuration.xml'
    }
    Stage: StartLab {
        Get-Lab -ConfigPath 'c:\MyLab\Configuration.xml' | Start-Lab
    }
}

This doesn't benefit from any parallel tasks. If you have commands that break down the Install-Lab part into separate tasks you can put those into Do: blocks.

But since you are reading from a config file and processing that maybe it would be better to add support inside your code to handle the various parallel steps.

Like: Download isos, setting up switches, adapters, building vms etc

RobertKozak avatar Mar 17 '16 11:03 RobertKozak

@RobertKozak - thanks for commenting :+1:

I was thinking of implementing the Do: inside the Initialize-LabVM,Initialize-LabSwitch,Initialize-LabTemplate and Initialize-LabTemplateVHD functions and the Pipeline: and Stage: being added to the Install-Lab function. This is where the largest amount of work happens and seems to be the best place to parallelize.

So I was thinking of wrapping the content of the main loop in Initialize-LabVM (and other Initialize-Lab* fucntions) in a:

Do: {
}

block. E.g. at this point: https://github.com/PlagueHO/LabBuilder/blob/dev/LabBuilder/LabBuilder.psm1#L3157

    foreach ($VM in $VMs)
    {
        Do: {
            if ($Name -and ($VM.Name -notin $Name))
            {
                # A names list was passed but this VM wasn't included
                continue
            } # if
            .....
       }
  } # foreach

Something like that.

Would something like that work do you think? I'll try and put aside some time to look at this this weekend (I'm studying for an MS Exam at the moment so haven't been able to spend as much time as I'd like on LabBuilder).

Thanks again for pointing me at your project and for the help :D:

PlagueHO avatar Mar 17 '16 21:03 PlagueHO

That will work if you want to break apart your code into smaller tasks and use Cidney to run it. If you want to keep the Install-lab cmdlet functionality it would be better to add code inside of your project to handle the parallel steps. You can use PoshRsJobs or Invoke-command -asJob or use runspaces. The hardest part of using these things is that the runspace is usually a different scope so modules, functions and variables are not there and you need to keep them there. I am still trying a few techniques to find the right way of handling this behind the scenes so it is transparent.

RobertKozak avatar Mar 17 '16 22:03 RobertKozak

Lets chat about this after your exam.

RobertKozak avatar Mar 17 '16 22:03 RobertKozak

@RobertKozak - inside Install-Lab it actually calls out to smaller tasks so it technically is already broken down :+1:

Anyway, thanks, we'll chat after I hopefully pass. Cheers!

PlagueHO avatar Mar 17 '16 23:03 PlagueHO