Selecting a datastore in the script

PowerShell script exchange

Selecting a datastore in the script

Veeam Logoby dcd62 » Mon Mar 23, 2015 3:25 pm

I'm very new to Powershell scripting and this is my project using PS. I found a script online to automate the creation of replication jobs.
I made changes to the script so I can import a csv file that lists the VM name, source/dest vCenter server, destination ESX host and start time for the initial replication. Many of the vm's will be moving to the same cluster. I added these lines to query the ESX host shared luns, sort them by freespace and set $Datastore to the lun with the most free space..

This works fine but my problem is that the jobs won't actually start until the evening so when I run the script to schedule the jobs, it will always pick the one lun with the most freespace and it doesn't take into consideration what has been scheduled for that night. I'm trying to automate as many steps as possible and would rather not have to enter each datastore name in the csv.
Any ideas on how to handle this? What do other folks do?


$DRClusterMaxSize = Get-VBRServer -Name $DRHost | Find-VBRViDatastore | Where {($_.Name -notlike $LUNEXCL1 -and $_.Name -notlike $LUNEXCL2 -and $_.Name -notlike $LUNEXCL3)} | Sort-Object FreeSpace -descending

$Datastore = $DRClusterMaxSize.Name[0]
dcd62
Enthusiast
 
Posts: 29
Liked: 4 times
Joined: Wed Aug 20, 2014 1:00 pm

Re: Selecting a datastore in the script

Veeam Logoby v.Eremin » Tue Mar 24, 2015 11:47 am

This works fine but my problem is that the jobs won't actually start until the evening so when I run the script to schedule the jobs, it will always pick the one lun with the most freespace and it doesn't take into consideration what has been scheduled for that night.

Not sure whether I got your question correctly. Not only do you want to pick a datastore with the most free space on it, but also you're willing to make script project how much space will be consumed by upcoming jobs and pick up the appropriate datastore in accordance, right?
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 969 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Selecting a datastore in the script

Veeam Logoby dcd62 » Wed Mar 25, 2015 3:15 pm

Yes. so this process would work fine if I'm scheduling a couple at a time. Then at night, the initial replication would begin and actually use the space on the datastore. Then the next day I go to schedule a couple more and the script could accurately determine how much free space is available. But we maybe scripting many jobs during the day and since the replication doesn't begin until the evening, we could possibly overcommit a datastore because there's no way for the script to determine what has already been scheduled. Thanks!
dcd62
Enthusiast
 
Posts: 29
Liked: 4 times
Joined: Wed Aug 20, 2014 1:00 pm

Re: Selecting a datastore in the script

Veeam Logoby v.Eremin » Thu Mar 26, 2015 11:57 am

That for sure would require some more advanced logic on analyzing historical information, defining a pattern, and making projections. But I'm wondering why you need to create replication jobs on daily (or even more frequent) basis?
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 969 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Selecting a datastore in the script

Veeam Logoby dcd62 » Thu Mar 26, 2015 3:17 pm

I just thought I'd throw it out there to see if anyone had any ideas. We are using Veeam for datacenter migration and ESX end of life projects where we are moving many vm's from site to site. It'll just take a little planning, which we are already doing now.Thanks
dcd62
Enthusiast
 
Posts: 29
Liked: 4 times
Joined: Wed Aug 20, 2014 1:00 pm

Re: Selecting a datastore in the script

Veeam Logoby v.Eremin » Thu Mar 26, 2015 3:41 pm

If I were you, I wouldn't implement some complex logic inside PS script in order to project the least used datastore.

Since migration is more like one-time procedure, I would split my infrastructure into chunks (say, 30-50 VMs per one replication job), find the best datastore in terms of free space, specify it for the first replication job, execute the job, wait till it's finished, find the best datastore in terms of free space, specify it for the second job, etc.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 969 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Selecting a datastore in the script

Veeam Logoby dcd62 » Mon Mar 30, 2015 5:15 pm

ok, thanks for your input.
dcd62
Enthusiast
 
Posts: 29
Liked: 4 times
Joined: Wed Aug 20, 2014 1:00 pm

Re: Selecting a datastore in the script

Veeam Logoby v.Eremin » Tue Mar 31, 2015 11:10 am

You're welcome. If you come across an issue with scripting, feel free to ask for assistance. Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 969 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Selecting a datastore in the script

Veeam Logoby dcd62 » Tue Apr 14, 2015 8:12 pm 1 person likes this post

Thanks, I certainly will. I'm still learning this stuff.
dcd62
Enthusiast
 
Posts: 29
Liked: 4 times
Joined: Wed Aug 20, 2014 1:00 pm


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 6 guests