Script to automate the affinity of the crib of DRS-groups

Hello

I am trying to automate the rules of affinity for the drs Group Manager. The idea is to let some virtual machines running on

assigned to the esx host (type 'Run VMs on Hosts' / 'Should run on hosts in the group').

Background: we have esx hosts in two data centers interconnected 10 giga with a metrocluster netapp on each site hosting the nfs exports. I created two groups of type "Host DRS Groups" (in datacenter esx host a go into one, hosts datacenter b go the other) and two groups of type 'Machine virtual DRS Groups' (virtual machines hosted on export nfs one go into one, while the virtual machines hosted on nfs export b go the other). In this way, we can prevent nfs/iscsi traffic across data centers.

Create the rules manually in a small cluster works. However with dozens of virtual machines in the other groups, there must be a way to automate the task and that it is regualary. I let powercli generate a list of VMS according to nfs export (hard location is either the field a or site b) then import the given in the Virtual Machine DRS group concerned.

Using get-drsrule-Cluster 'cluster ' | Export-CliXml does not display a details for groups of DRS HOST or Virtual Machine DRS. Is it possible to do it at all? I recon using set-drsrule let me import rules.

Any help / ideas is appreceated.

Concerning

Sascha

The current DrsRule cmdlets do not, all I know, allows you to work with groups of DRS.

As an alternative, you can use the ReconfigureComputeResource method that is available.

The script should look like this

$clusterName = "MyCluster"
$cluster = Get-Cluster -Name $clusterName

 $spec = New-Object VMware.Vim.ClusterConfigSpecEx
$groupVM = New-Object VMware.Vim.ClusterGroupSpec $groupVM.operation = "add" $groupVM.Info = New-Object VMware.Vim.ClusterVmGroup $groupVM.Info.Name = "Grouped VM" 

Get-VM -Name MyVM1* | %{
    $groupVM.Info.VM += $_.Extensiondata.MoRef
}
$spec.GroupSpec += $groupVM
$groupESX = New-Object VMware.Vim.ClusterGroupSpec $groupESX.operation = "add"$groupESX.Info = New-Object VMware.Vim.ClusterHostGroup$groupESX.Info.Name = "Grouped Host"

Get-VMHost -Name MyHost1* | %{
    $groupESX.Info.Host += $_.Extensiondata.MoRef
}
$spec.GroupSpec += $groupESX
$rule = New-Object VMware.Vim.ClusterRuleSpec$rule.operation = "add"$rule.info = New-Object VMware.Vim.ClusterVmHostRuleInfo$rule.info.enabled = $true$rule.info.name = "Test DRS group rule"$rule.info.mandatory = $true$rule.info.vmGroupName = "Grouped VM"$rule.info.affineHostGroupName = "Group Host"$spec.RulesSpec += $rule
$cluster.ExtensionData.ReconfigureComputeResource($spec,$true)

The script first creates 2 DRS groups. One with the VMs and one with the ESX(i) servers.

In the example, there all customers whose name starts with "MyVM1" for a group and all hosts whose name begins with "MyHost1" to the other group.

These 2 selections will of course be changed for your configuration. Let me know what selection rules you want to implement for virtual machines and hosts and I can update the script.

The script then creates a rule. Note that the rule specifies $true for the "required" property

This means that a virtual machine will not be powered on if the placement host does not match the rule.

The 2nd parameter to the ReconfigureComputeResource method allows you to specify if the changes defined in the $spec to add or not.

If it's not $true all your cluster settings, except for the groups and the rule will be deleted. So, attention!

Tags: VMware

Similar Questions

  • How to run 'Save as optimized' in a javascript script to automate the optimization of PDF.

    How to run 'Save as optimized' in a javascript script to automate the optimization of the pdf?

    In can't find if this function exists even in javascript, because the API reference is a dead link:

    DC Acrobat SDK Documentation

    This is the good link: Adobe - Adobe Acrobat SDK license agreement | Adobe Developer Connection

    But just to make you save time, you can not do with JS directly. You can probably trigger the menu item he does, but then you still need to interact with it manually.

  • Complex script to automate the Conversion of Images high resolution for the Web

    I use Actions in Photoshop (currently using CS4) all the time, but have never tapped into the scripting features, so please forgive me if these questions are obvious.

    The basic description of my project is simply creating web images in jpg format, among our library of high-resolution print images.

    We have a folder with a copy of all the images we need to convert. File types from TIF, PSD, EPS, and JPG.

    The challenges (for me) are:

    1. these images vary in orientation to be big or wide; I need the higher between dimensions, whether the height or the width, 400 pixels; and then I need to canvas has added to the other dimension to make the picture a perfect square of 400 x 400. I don't know how, or if I can, do PS choose the bigger dimensions, to 400 px.

    2. some of these images have clipping paths; I need to use these roads to clear the background in the pictures; the names of these masks are not the same in each image.

    Thus, the basic flow of the script would open the file; Set the maximum size to 400 px; Add a blank canvas to fill the other dimension and that also make 400px; use an image clipping path if it has one to erase the background of the image. Save for web in jpg format, adding "-400" at the end of the name of the file (but before the '.jpg'); size 115 value and save for web, by adding '-115' to the name. value size 80 and save for web, by adding '-80' to the name.

    A new version has been downloaded more than PS - Scripts Sean this now creates a record of each file selected with the name of "JPEG" and there the possibility to include subfolders.

  • Path to script and automate the vmkfstools command?

    Very long story short, running vSphere 5, I need a way to execute the command 'vmkfstools y 60' against my stores of data to recover free space on my table of Compellent SAN.

    This article explains the command and the object: http://kb.vmware.com/selfservice/microsites/search.do?language=en_US & cmd = displayKC & externalId = 2014849

    From one or more hosts, I so need to go into each VMFS data store and run the command "vmkfstools y XX" to reclaim space. Otherwise the Compellent table see SVMotion jobs and snapshots as "new entries" and never release the free space.

    To automate this, I would use PowerCLI and maybe just run the script as a scheduled my vSphere Server task.

    I understand also the VMA device can do this kind of stuff, but I don't understand how to automate/schedule tasks with it more I prefer using PowerCLI.

    Anyway, sorry for the question noob and thanks in advance. Any help is very appreciated!

    The problem is we use thin Volumes put into service on a Board of 3par, with T10 off Unmap (which is now the default) freeing up space by deleting a virtual machine or by a storage vmotion means space gets released to the VMWare/data store layer and can be reused by Vpshere but he is not recovered at the Array level , delivering a vmkfstools, writes a file in the data store removes it returns T10Unmap to the matrix, the 3par then and returns this space to the free pool. It works when we manually we just want until VMWare decide UNMAP turn automate it.

    Brett

  • Script to report the VMS in DRS automation level

    I'm having a difficult time to build a report that gives me the "Automation level" setting for each virtual machine in the infrastructure.  This setting is found in the DRS 'virtual machine' cluster setting options (see image).  I worked with the cmdlets get-drsrule and get-cluster command, but without success.  Anyone know where to find these data of via powershell?  Thank you.

    Hello

    The info is part of the VirtualMachine data:

    Get - VM | Select DrsAutomationLevel

    Kind regards

    Yasen

  • Automate the exchange of two images in the document.

    Good afternoon! A friend here can direct me to a nice script to automate the exchange of two images in the document, E.g.: when you select two layers A and B would look like this: picture A to picture B by changing the image B for the "Inversion of images' image and, if possible, keep the same report. Thank you!

    I found an old version that I changed and now it works with CS5 and CS6 lets hope it work in CC.

    Wikisend: free file-sharing service

  • Script to automatically replace the specific layers?

    Hello. I work for a small company and we frequently get client files I need to edit. Because of the way thay are formatted the layers always come with the same name/structure, but they still have a layer we need to replace. Go to a shared drive and manually place our desired element (a .pdf file if it is of importance) in the subset to continue with the file layer. Thus, for example, there will be a layer in the default file named layer 1, and this layer is Group 1 > Group > mask of clipping and Image.

    I know ideally we should simply fix the script that formats the layers, but for now is not possible. So what I would like to be able to do (assuming that it is still possible), is to have a script that we can run that automatically replaces the 'Image' file in these layers of subset, I spoke with a file to a location on a local computer (for example replace the 1 layer > Group 1 > Group > image.jpg with C:/example/example.pdf).

    I searched online and could not find anything, so I thought that I have turned to the community for help. Entries, suggestions or creative solutions would be greatly appreciated! And as always, thanks, everyone on these forums is usually very beautiful and impressive, so it's always nice to come here to help.

    Glad to see that you have accepted the challenge.

    Well, this should help you get started. Keep in mind, it is written in VB.NET then you will need to translate it is that you want in Javascript. At least you will have a model to begin with. This is just a quick hack for you to start with - you may need to change the layer you want the new image appears on, if it's important. In addition, it is assumed that you started with a plot point (image.jpg) and whether you want the new image to be incorporated. You will see the code tweak as you wish.

    Var app As Illustrator.Application = CreateObject ("Illustrator.Application")

    Dim aDoc as long as I. Document = app. ActiveDocument

    For each item in aDoc.RasterItems

    If the element. Name = "image.jpg" Then

    order of the day. Selected = True

    Dim newPlacedItem As AI. PlacedItem = aDoc.PlacedItems.Add

    newPlacedItem.File = "YourNewFilePathHere.pdf".

    newPlacedItem.Embed)

    order of the day. Delete()

    End If

    Next

    I hope this helps.

    -TT

  • Automate the installation (runInstaller send me questions in the script)...

    Then I tried to automate an installation of Oracle11gR2 and I am REALLY VERY close but need a bit of help.

    {Background :}
    I decided to try to automate the process by using head (which is a tool of devops). The question I spin is that when a script returns 0 Chief considers this piece done, but with runInstaller it returns 0 and continues to run after that. After the first head 0 return think its done and moves on the rest of the automatism (which fails b/c oracle is not installed).

    So the problem is the result of the runInstaller (when used in a script) I can manually trigger installation (with a responsefile in silent mode). And when it finishes installing fire chief to finish my installation.

    {Option}
    I was hoping someone might be able to direct me on how to put a wrapper around the oracle runInstaller script, then it will not return zero until the installer is really done with the installation.

    {Alternative}
    Change (or split) the runInstaller script so that it will work in a way I need to.

    I think people probably met similar problems even if they use another method other than Chief to automate/script installation.

    Is the '-waitforcompletion "flag is not enough for your application?

    http://docs.Oracle.com/CD/E11882_01/EM.112/e12255/c_oui_appendix.htm#BABDADJE

    HTH
    Srini

  • Script to automatically calculate answers to the questions of the option button?

    Hello

    Anyone know if its possible / how to write a script to automatically count the responses of the radio buttons?

    For example, I have a form with 14questions, where the answers are either "Yes" 'Unknown' and 'No' - I used for each question radio buttons.

    At the bottom of the form, I want it to be automatically calculate how much 'yes' 'unknown' and 'No' responses there. (ie. a text box that displays the number of 'Yes', another area of text that displays the number of 'No'... etc)

    Can someone help me with this?

    Thank you so much

    OK, for the text field that counts the groups of numbers with the Yes option radio button is selected, you can use code like:

    // Custom Calculate script for text field
    (function () {
    
        // Initialize counter
        var sum = 0;
    
        // Loop through the fields
        // and increment the counter for each Yes value
        for (var i = 1; i < 15; i += 1) {
            if (getField("Question " + i).value === "Yes") {
                sum += 1;
            }
        }
    
        // Set the value of this field to the sum
        event.value = sum;
    
    })();
    

    Do the same for other areas, but change the 'yes' in the code above to the appropriate string, either 'No' or 'Unknown'.

    It would make sense to convert this to a function in a script at the level of the document, something like:

    // Document-level function
    var radioButtonValueCount = function (sVal) {
    
        // Initialize counter
        var sum = 0;
    
        // Loop through the fields
        // and increment the counter for each sVal value
        for (var i = 1; i < 15; i += 1) {
            if (getField("Question " + i).value === sVal) {
                sum += 1;
            }
        }
    
        // Set the value of the field that called this function to the sum
        event.value = sum;
    
    }
    

    You would then call it like that in the case of calculating a text field that counts the number of selections of Yes:

    // Set this field to the number of Yes selections
    radioButtonValueCount("Yes");
    

    Do the same for Dummies and unknown fields.

  • Question in regards to the script for automatic filling check box

    Hello everyone.  First of all, let me say a big thank you to all the users, but also the admins of this forum.  As a user of LiveCycle newbie, I learned an incredible amount of research on the forum and reading of others.  Now, to my current question...

    I use a custom form created in LiveCycle ES 8.2 and wonder how to empower a checkbox to fill automatically (IE. 'on') based on a number entered in a numeric field by using a range of criteria.  To be more precise, I have (5) checkboxes that will be labeled as follows:

    Name: CheckBox1 < 500

    Name: CheckBox2 500-999

    Name: CheckBox3 1 000-1 499

    Name: CheckBox4 > 1 500

    Name: Checkbox5 no

    I don't want only a SINGLE checkbox auto fill based on a certain number I enter the numeric field (called "NumericField1").  For example, if I enter "889" number, I want only CheckBox2 AutoComplete in.  Not sure what script to use in the Script Editor for this.  Any help would be greatly appreciated.  Thank you very much in advance.

    MJ

    You are welcome. I added a second numeric field. NF1 is entered by the user option. NF2 is calculated field read-only to mimic your form. NF2 simply takes the value of nf1. I moved the logic of radio button in the radio button exclusion group calculate event to produce the results below. I think that's what you're after. The updated form is attached.

    Steve

  • Batch file or scripts to automate running the cache?

    Hello gurus,

    I'm new to OBIEE and trying to learn how to automate hides...

    I got to know that we can automate the cache for the purge by running a batch file or script... outside the purging of the cache by checking the time of persistent cache for individual objects.

    I also read the documentation for the purging of the cache as the use of the ODBC extension functions... such as SApurgeCacheByQuery, SApurgeCacheByTable, SApurgeCacheByDatabase, SApurgeAllCache... But how can we get these functions?

    Someone can explain on the automation of the cache or can someone give all kinds of web links or reference?

    Thanks in advance...

    Published by: user12269190 on April 30, 2010 14:35

    http://CatB.org/~ESR/FAQs/smart-questions.HTML#before

    First result when I search "obiee clear cache" on Google:

    http://obiee101.blogspot.com/2008/03/OBIEE-manage-cache-part-1.html

  • Script Automator for the DATE and TIME stamped record

    Hi all

    I'm not a scripter, but are in need of a DATE and time-STAMPED folder (or file) I would like to put on my desktop and have updated automatically so that I can use this tool to quickly see if a backup external (or internal) is current. probably I could also use it to quickly find out how /old/ a backup is.

    for now, I do this manually if I want to quickly verify that a backup works by creating a "date named folder" on the desktop - such as '-2016 03 26 "."» so I can quickly see if a backup I just ran ran.

    I have a lot of backups (internal, external, off site, etc.) and it would be super useful for me to have.

    I consider the name of the folder to be customizable (potentially) in case I need to change it, but a good default would be "-YEAR MONTH DAY" so that I could see easily when this backup has been but also I name my files in this way so they can appear in chronological order "."

    is anyone able to help me with something like that or suggest another forum for cross-post this?

    Thank you

    Jon

    Hello

    Create the the ""new folder " action, like this:"

    ---------------

    Drag and drop the 'Shell Script' variable in the "name:" field.

    --------------

    Double click on the variable in the "name:" field:

    Copy and paste this text in the field 'Script ':

    date "+%Y %m %d"
    
  • Script to change the line style in a graph report

    Hi all

    Is it possible to automate the formatting of (linestyle) of a plot of graph in a report?

    friend,

    Ben

    This code accesses a system of axis line style:

    Call GraphObjOpen("2D-Axis1")
    Call GraphObjOpen("2D-Axis1_Curve1")
    D2CurveLineType = "solid".
    Call GraphObjClose("2D-Axis1_Curve1")
    Call GraphObjClose("2D-Axis1")

    Please note that you must know the name of the Axis system and the curve you want to change and use the correct names in the GraphObj... commands.

    The best way to find these commands is via the function Ctrl-A in tiara.

    Valid entries for D2CurveLineType are:




























    End of script Terms of interface, explanation

    solid

    Line

    Dashboard & dott.

    Points and dashes

    1 dotted

    Dashes 1

    2 dotted

    2 dashes

    dotted line

    Dotted line

    I hope this helps.

    Otmar




























       
       
       
       
       
       

  • How to create a script to crop the channels included in the specific limits defined by me?

    Hello

    I am trying to automate the process of my channels, but as a first step, I need to crop the specific territory (all data at once).

    Kindly let me know orders of specific script that would help me to do the same.

    Shoot!

    Doesn't have this loop, a code more clean here are:

    Set Group = Data.Root.ActiveChannelGroup
    XChannel = Group.Channels set (1)
    P0 = 1
    P1 = PNo (XChannel, 0)
    P2 = PNo (XChannel, 20)
    PN = XChannel.Size
    Presets = Group.Channels
    If AP - P2 > 0 THEN call DataBlDel (channels, P2 + 1, PN - P2)
    IF - P0 P1 > 0 THEN call DataBlDel (channels, P0, P1 - P0)

    Brad

  • Automate the update of Windows Server R2 2012

    Hi all

    I am currently looking for a method to update automatically to our servers. Rather than use Windows update to install and reboot servers, I want to be able to automate the download and install the updates, but to impose when the server reboots automatically. I know that WSUS automatically installs updates but I don't think there is a way to control when the server should restart. Also apart from that, I know that servers come online without having to login to them manually. I think that the only way to go about this is with a script.

    Any help or insight is most appreciated. Thank you.

    It is a forum for specific consumers.

    You will find the Windows Server support in these forums: http://social.technet.microsoft.com/Forums/windowsserver/en-US/home

    You will find support for WSUS in this forum: http://social.technet.microsoft.com/Forums/windowsserver/en-US/home?forum=winserverwsus

Maybe you are looking for