-
- Enthusiast
- Posts: 39
- Liked: 4 times
- Joined: Aug 20, 2014 1:00 pm
- Contact:
Selecting a datastore in the script
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]
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]
-
- Product Manager
- Posts: 20413
- Liked: 2301 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Selecting a datastore in the script
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?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.
-
- Enthusiast
- Posts: 39
- Liked: 4 times
- Joined: Aug 20, 2014 1:00 pm
- Contact:
Re: Selecting a datastore in the script
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!
-
- Product Manager
- Posts: 20413
- Liked: 2301 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Selecting a datastore in the script
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?
-
- Enthusiast
- Posts: 39
- Liked: 4 times
- Joined: Aug 20, 2014 1:00 pm
- Contact:
Re: Selecting a datastore in the script
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
-
- Product Manager
- Posts: 20413
- Liked: 2301 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Selecting a datastore in the script
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.
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.
-
- Enthusiast
- Posts: 39
- Liked: 4 times
- Joined: Aug 20, 2014 1:00 pm
- Contact:
Re: Selecting a datastore in the script
ok, thanks for your input.
-
- Product Manager
- Posts: 20413
- Liked: 2301 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Selecting a datastore in the script
You're welcome. If you come across an issue with scripting, feel free to ask for assistance. Thanks.
-
- Enthusiast
- Posts: 39
- Liked: 4 times
- Joined: Aug 20, 2014 1:00 pm
- Contact:
Re: Selecting a datastore in the script
Thanks, I certainly will. I'm still learning this stuff.
Who is online
Users browsing this forum: Semrush [Bot] and 22 guests