Add VMS to DRS rule
I'm working on a script and a cmdlet PowerCLI already seems to be written for her. The script adds an existing virtual machine to an existing Rule DRS.
Here's the code for the cmdlet that I want to reproduce:
$spec = New-Object VMware.Vim.ClusterConfigSpecEx
$spec .groupSpec = New-Object VMware.Vim.ClusterGroupSpec[] (1)
$spec .groupSpec [0] = New-Object VMware.Vim.ClusterGroupSpec
$spec .operation .groupSpec [0] = "edit"
$spec .groupSpec [0] .info = $DrsGroup
$spec . info.vm .groupSpec [0] += $VM. ExtensionData.MoRef
$Cluster . ExtensionData.ReconfigureComputeResource_Task ($spec $true( )
To my knowledge, something along the following lines can be done to translate this in Perl:
1. create a ClusterGroupSpec object with the correct information. I don't here and am not sure how to add "info.vm" in ClusterGroupSpec in Perl.
My $cluster_group_spec = ClusterGroupSpec-> new (operation = > 'Edit', info = > $drs_rule_name)
2. pass this as an object of ClusterConfigSpecEx in rulesSpec
My $cluster_config_spec = ClusterConfigSpecEx-> new (rulesSpec = > [$cluster_group_spec]);
3 reconfigure with spec as $cluster_config_spec.
What I'm confused about is how to pass to info. VM of the PowerCLI. There is no member of the info or ClusterConfigInfo called "vm". How I would say the group specification which VM use?
Updated the title to be more informative (it is no longer just a 'translation', the thread now contains the answer to the title).
Adding/changing operations are for groups, but the contents of the group will be just changes to the low level table.
Take a look at the example attached script, I tested it and its work. Basically, the logic is the same, the difference is you change the group, but just add the moref vm virtual machine that you want to add to the group by simply sending an updated table of the vm morefs.
Perl addVm2DrsGroup.pl - server = pass 172.16.254.50--username=administrator@vlab--mot = * - cluster = CLU01 - drsgroup = group1 - vm = recovery-03
Tags: VMware
Similar Questions
-
We have a cluster with 5 guests esxi 4.1. Our web team has a collection of 10 virtual machines they would like to have at most 2 of their virtual machines running on the same host at any given time. Is this possible using the DRS rules?
I've set up two groups of hosts and virtual machines, a group of virtual machines 1-5 and another 6-10 guests then 1-2 and 3-4 (leaving a 5 hosts on groups, but I guess I could just add it to the second group to keep them together...) I then set up for VM 1-5 could only run 1-2 hosts and VMs 6-10 may only work on 3-4. This does not have the requirement to have only 2 virtual machines on a host at a time.
Any suggestions?
Thank you
Assuming you entered controll activated with a threshold of 20% then none.
As the DRS rules are 'should' rather than 'having '. Which means that if the host ESXi01 fails, then WEB01 and WEB02 will work on any other host, when this host is repaired or get back online, DRS will migrate them back to her.
-
Hello
We are currently using DRS for the distribution of Windows VMs on specific hosts in our groups. These hosts are grouped into a "Windows Hosts licensed" DRS group in each cluster.
For our license management, I need to declare the current number of hosts (and host) attributed to these groups of DRS each month.
As the environment is more and more bigger I want to automate this task by using a regular report.
How can I get a list of relevant hosts including physical processors per cluster and a total number of CPU?
We use vSphere 5.1 and PowerCLI does not seem to offer much for DRS-groups out of the box.
I just need to know how to get the list hosts, I can do anything around this (adding PSModule, connection to vVenter, report by mail, etc.) by myself
Any help appreciated.
Hi Daniel,.
right, PowerCLI does not offer a large part of the box.
But there is a module, you can import:
http://www.lucd.info/2015/01/22/drsrule-DRS-rules-and-groups-module/
Who should help ;-)
Tim
-
Hello! I use Affinity DRS rules at present with DRS groups etc. My question is if it is possible for a little more advanced with the DRS group management? Is it possible to group together (for example tag)-based VM rather than manually? So ideally, I could go to a stage where I can score a large number of virtual machines in a certain way (tag/etc. naming convention) and make them part of a group of DRS.
The goal is to link a large number of virtual machines to hosts for licensing reasons, so I don't know that this has been done before. Obviously a separate group would work but not the most effective use of resources. I am looking for a type of soft partitioning almost (with software!)
Any ideas or suggestions would be greatly appreciated as always!
Thanks and greetings
Steve
A way to do would be to put the virtual machines selected on specific storage and storage only serve to a specific host within the cluster - in this way you would not need to affinity of all rules, and the VMs system would remain "limited" for guests who 'see' storage...
-
DRS Rule for Host affinity check names of datatore that they match to the hosts
DRSRules - list of host affinity rules
Host affinity rules
Cluster
Activated
Name
Solidarity
VM
Host of the rule
Running
Cluster-SA1
True Cluster2-SA1-VMsHosts Fake SMV - SA1 SA1 sa1_host3 Cluster-SB2
True
CLUSTER1-SB2-VMsHosts
Fake
SMV - SB2
SB2
sb2_host2
This module of vCheck will show me if one of my virtual machines are not running according to the rules, but I want to look deeper.
DRS Rule for Host affinity check names of datatore that they match to the hosts
Our guests all start with three characters make the difference between SiteA1 and SiteB1, that is sa1host1 sa1host2... sa1host9 and sb2host1, sb2host2, sb2host9, etc.
Our warehouses are the names "sa1_exch01", "sa1_sql_01", sa1_data_01"for all data stores that are found on the Site1. While the warehouses of data named 'sb2_exch01', 'sb2_sql_01', sb2_data_01' for all data stores that are found on the Site2.
Can help you with a script that will check all virtual machines on the hosts on Site1 and report those who have warehouses of data does begin with 'sa1' and similarly all virtual machines on the hosts on the Site2 but give report of those who have warehouses of data that do not begin with "sb2.
See you soon
KC
Try something like this
$vms = Get-View -ViewType VirtualMachine -Property Name,Datastore,"Runtime.Host" foreach($vm in $vms){ $esx = Get-View $vm.Runtime.Host -Property Name $ds = Get-View $vm.Datastore -Property Name if($ds | where {$_.Name.Substring(0,3) -notmatch $esx.Name.Substring(0,3)}){ $vm | Select Name, @{N="Site";E={if($esx.Name.Substring(0,3) -eq "sa1"){"SiteA1"}else{"SiteB1"}}}, @{N="Host";E={$esx.Name.Split('.')[0]}}, @{N="DS";E={[string]::Join(',',($ds | %{$_.Name}))}} }}
It should list all the virtual machines that do not follow the rule.
-
How to get a list of the DRS rules and their virtual machines.
If I try the following, I get no output. (PowerShell 2, vCenter & ESXi 5.1, PowerCLI 5.1 Release 1)
()get-cluster ). ExtensionData.ConfigurationEx.group |? {$_.vm}or
()get-cluster ). ExtensionData.ConfigurationEx.group
I know that I have a DRS rule because when I try the following I am able to see it in Object Explorer in PowerGUI and I created it just in the Web Client.
$Clusters = Get-Cluster
The problem is that you have DRS groups who do not have vms - possibly accommodate groups of DRS. If you want only vms something like this should work and does not give the error:
foreach ($cluster (get-cluster)) {}
write-host "$($cluster.name)".
foreach ($drsGroup in $cluster. ExtensionData.ConfigurationEx.group) {}
write-host "$($drsGroup.name)".
{foreach ($vm to $drsGroup.vm)}
If {($vm)
$vmname = (get-vm-id $vm) .name
write-host "$vmname".
}
}
}
ECHO «»
}
If you want to get the VMhosts and the VirtualMachines then try this:
foreach ($cluster (get-cluster)) {}
write-host "$($cluster.name)".
foreach ($drsGroup in $cluster. ExtensionData.ConfigurationEx.group) {}
write-host "$($drsGroup.name)".
write-host "VMHosts".
{foreach ($vmhost to $drsGroup.host)}
If {($vmhost)
$esx = (get-vmhost-id $vmhost) .name
write-host "$esx".
}
}
ECHO «»
write-host "Virtual Machines".
{foreach ($vm to $drsGroup.vm)}
If {($vm)
$vmname = (get-vm-id $vm) .name
write-host "$vmname".
}
}
ECHO «»
}
ECHO «»
}
-
DRS Rule - separate virtual machines
I have a DRS rule to separate the 2 virtual machines, but when I vmotion two virtual machines on the same host, it allows him to do. Why is this?
I need to separate VMs on separate hosts at all times
OK, I had the level of automation to manual, so he won't move the virtual machine. Once I changed it to automatic, its moved the VM on the host.
-
Is it possible to assign the DRS rules to Resource Pools instead of creating groups of DRS and adding to the DRS group VMs and then creating a rule
I ask this question because of a problem that I currently have
I am far from being an expert as you'll see soon and back to the use of support groups
If it I'll give you my scenario
I have 4 ESX host in my test group
2 hosts are connected to zFCP
And all 4 are connected to independent contractors
I have a resorce pool call FC and another called ISCSI
We constantly evolve around VM between these 2 pools
The highest availability VM remains on the rest on ISCSI FC
I would like to create a rule that States if a virtual machine is in the RP FC then he must reside on host A and B, and if it resides on ISCSI it can reside on any host
I realize that there is still other issues involved here as data themselves warehouses
but it is another matter that he owns the rights
We migrate VMs and the data store when we leave the virtual machine to another RP 1
If the rule would be always true
I would like to hear from you
on this topic
for now I just use rules and groups of DRS
Thank youI don't think this is possible from the point of view of rule affinity DRS, as he has no relationship with resources or VM disk pools. This seems to be a single-use resource pools.
You could probably do with a set of scripts PowerCLI who would check two resource pools and ensure that the virtual machines to the breast have their records on the correct data store and if not do a svMotion.
-
Buenas.
BONE benefits a dudas conjunto sober rules of antiafinidad of DRS (config that allows separate the run of maquinas office on different hosts). Creo that son of interesting debate:
- Message how're este sistema? ES decir, imaginad what configuramos so many rules of antiafinidad than what we do are separate todas las maquinas office. In caso of Quebec el DRS required mover alguna Máquina virtual por performance motivated, sucederá what? ¿movera maquinas office? Do not weary movera porque dicen than deben estar entraba rules?
An example:
Host 1
VM1
VM2
Host 2
VM3
VM4
Tenemos back antiafinidad of DRS rules that:
(1) VM1 y VM3 deben estar in hosts separately.
(2) VM2 y VM4 deben estar in hosts separately.
Por servicio motivated the VM1 begins a CPU of mucha consuming, as el Host1 is absolutamente saturado tanta. El host 2 esta trabajando con VM3 y VM4 y tiene capacidad suficiente para Máquinas Office hold. Máquina ¿Drs movera alguna en este caso, las violando rules of antiafinidad?
- How actuara ante HA? Me refiero, if case el example del 1 host anterior, ¿HA intentara arrancar in el sus las Host2 VM (VM1 y VM2)? Do not las arrancara porque exists the rule of antiafinidad? ¿Las arrancara violando rules?
Gracias y a greeting.
Buenas, segun VMware in el segundo caso if what VM, violando las las arrancarian rules of antiafinidad, there is prima el servicio in detrimento del cumplimiento rules.
Esto modificarse mediante una opcion advanced del HA can, donde indicamos Québec haga caso a DRS rules.
As has the cuestion of primera, correcto're tal y como is ha planteado.
Saludos.
-
DRS-rule of Type 'Run VMs on Hosts' power
If I try to turn off a rule with A_ (automated) beginning with
$rules = get-Cluster-name $cluster | Get-DrsRule-name ' A_. "
{foreach ($rule in $rules)
Game-DrsRule-rule $rule - active: $false - confirm: $false}
I get the error
Set-DrsRule: 01.02.2011 10:04:29 Set-DrsRule not initialized: vim. VirtualMachine vm []
C:\Program Files (x 86) \VMware\Infrastructure\vSphere PowerCLI\Scripts\DPM_test.ps1:91 char: 22
+ Set DrsRule < < < < - rule $rule - enabled: $false - confirm: $false
+ CategoryInfo: NotSpecified: (:)) [game-DrsRule], InvalidRequest)
+ FullyQualifiedErrorId: Client20_MoServiceImpl_Invoke_ViError, VMware.VimAutomation.ViCore.Cmdlets.Commands.SetDrsRuleBut this type of rule has no direct connection to a virtual machine? Who can help?
Best regards
This should do the trick
$clusterName = "MyCluster" $cluster = Get-Cluster -Name $clusterName $rules = Get-DrsRule -Name "A_*" -Cluster $cluster if($rules){ $spec =New-Object VMware.Vim.ClusterConfigSpec foreach($rule in $rules) { $RulesSpec = New-Object VMware.Vim.ClusterRuleSpec $RulesSpec.Info = $rule.ExtensionData $RulesSpec.Info.Enabled = $false $RulesSpec.Operation = "edit" $spec.rulesSpec += $RulesSpec } $cluster.ExtensionData.ReconfigureCluster($spec,$true) }
-
Error in creation of the DRS rules affinity
Hello
I have questions tests create DRS affinity / anti-affinities (VcClusterAffinityRuleSpec / VcClusterAntiAffinityRuleSpec) rules of vCO. The error I get is "not initialized: vim." VirtualMachine vm [] (Workflow: Affinity Test / Create Rule (item2) #45)'to 'reconfigureComputeResource_Task'. I searched all day and have not been able to find any resolution code or for example to get past this. Here is my code snippet.
Thank you, any help is appreciated!
*****************************
* att_vmArray - VirtualMachine array with 2 VM
* att_CCR - ClusterComputeResource
*****************************
var affSpec = new VcClusterAffinityRuleSpec();
affSpec.enabled = true;
affSpec.name = "Test 01 rule."
affSpec.userCreated = true;
affSpec.vm = att_vmArray;
var clusterRuleSpec = new Array (new VcClusterRuleSpec());
clusterRuleSpec [0] = new VcClusterRuleSpec()
.operation clusterRuleSpec [0] = VcArrayUpdateOperation.add;
clusterRuleSpec [0] .info = affSpec;spec var = new VcClusterConfigSpecEx();
spec.rulesSpec = clusterRuleSpec;att_CCR.reconfigureComputeResource_Task (spec, true)
Unfortunately, this is a known bug that has been fixed, but it would be released in the next version coming out soon. In addition, a fix would be released in vCO4.1 update 2 coming in the begging of T4. In the meantime, we can work with you to find a solution to this issue.
Thank youIgor. -
List the contents of a cluster VM group in a DRS Rule
Hello
I'm looking for a script that lists the contents of a cluster VM Group in a rule of DRS.
Example: we have a single cluster vmware 'CL-TEST' DRS 2 'GP1 and GP2' groups that contain several virtual machines.
We want to export the content of each group of DRS in an excel file.
Any idea?
Thank you
Concerning
Take a look to get a list of virtual machine is in a group of virtual machine DRS
-
Looking for a way to create an automated and large number of DRS rules.
For example, I have a lot of machines named like this;
Fs001a
Fs001b
I need to create AntiAffinity rules to keep the 'a' and 'b' machines on separate hosts.
The created rule should be like "Fs001" and both machines.
New-DrsRule-development of Cluster-name Fs001 - KeepTogether $false VM - Fs001a, Fs001b
Any help/direction with powercli script that can do this would be greatly appreciated. I don't know how to handle the name match in powershell. It's something I want to run as a scheduled task to avoid human error in the rules missed or incorrect.
Try like this
Get-VM -Name *[ab] |Group-Object -Property {$_ -match "(?
.*)[a|b]"; $Matches["name"]} | where {$_.Count -eq 2} | %{ New-DrsRule -Cluster Development -Name $_.Values[0][1] -KeepTogether $false -VM $_.Group} Only when the script detects 2 identical names (one ends with one and the other with b), he creates a rule of DRS
-
In vSphere, you can right-click on a Cluster, click on "change settings > DRS Group Manager > (select a group), change" and view the list of virtual machines that are in the cluster.
I'm looking to get this list even with the SDK... I was hunting for a way to do it but cannot find where in the API it is perhaps, the ideas of how I could get the list?
Happy to provide the code so far, but it's just a simple cluster-related statistics and information; anything related to the issue.
It is nestled in ClusterConfigInfoEx data.
So you get your clusters and then look at what follows-
$cluster-> {configurationEx}-> {Group}
There are two types of groups, host and the Vm. You can then check the type of groups of MV and the list of members. You may also look at $cluster-> {configurationEx}-> {rule} if you want to see if its a rule group refines or disaffine.
-
If you use the new 'vm to host' rules 4.1, you can for example select the VM in Vm-Group-1 MUST be running on host-group-2. Here "should" is sweeter than "needs", as in it will work on other hosts, but my question is when this is allowed?
In case of failure, or is it in the case of resources approve? In other words, if, for example, hosts in Host-groups-2 run 100% cpu all of them, DRS will pass a VM "should" to another host?
It is in the case of resources approve because HA is not aware of the preferential rules. VMware vSphere 4.1 HA and DRS technical deepdive, page 137.
Best regards, Robert
Maybe you are looking for
-
Is iCloud photo library space use doubled if I use Photos and iPhoto apps?
IPhotos and Photos apps right now: If an image appears at the same time it be transferred twice (with the help of double the amount of space) in iCloud storage space?
-
Satellite A200-1If - drive external HARD after a while is "unknown device".
Hello! I have such a problem: I work with my external case alu Toshiba 3.5 HDD 500 GB and after awhile of copy of the files in the laptop it disappears and appears this luckily device recognized.Can it be caused by not enough power in the USB port? T
-
My iphone is lost memory?
Yesterday, I discovered that my iphone had "no memory left" when it should be 14 concerts on the left. I have an iphone 32 GB 5. I went in the storage settings, calculated the total space my apps were taking (including photos, videos, etc.). I have a
-
How to scan of 4500 want the iPad
I purchased a 4500 desire and a mini iPad. I am able to print from the ipad to envy, but impossible to find all the instructions for scanning of a document on the envy and save it on the iPad. The user guide has only instructions for windows or mac
-
Can this unit be upgraded from Windows XP to Windows 7?