SRDF SRA – Python script for masking functionality

Back in March we offered customers a way to generate the EmcSrdfSraTestFailoverConfig.xml file for the SRDF SRA test failover functionality when using the vCenter Appliance (VCSA). You can read all about that here. Recently we had a customer request to enhance the script to add the ability to create the EmcSrdfSraDeviceMaskingControl.xml file and our developer Sam went to work. For those who have not taken advantage of this feature, what it does is allows the user to withhold presenting the snap/clone targets to the recovery site before running a test failover. This can be advantageous if you are approaching the device limit for an ESXi host which was fairly common with larger customers before vSphere 6.5 and the 512 limit. The python script, with the proper syntax, will generate both of these xml files at once which you can then copy to the appropriate directory on the recovery site.

Because of the new functionality the file has been renamed to It now can take one of two parameters:  failover or maskinginfo.

Using the failover flag will generate the EmcSrdfSraTestFailoverConfig.xml file (existing functionality) while the maskinginfo flag will generate both the EmcSrdfSraTestFailoverConfig.xml file and the EmcSrdfSraDeviceMaskingControl.xml file.

The masking feature works this way:  The script will do much of what it does for failover – first it needs to figure out what R2 devices are being used. Once this is complete it will check for all same-sized devices (not replicated) on the recovery array which are not presented to a host. (The devices could, however, be in a storage group so it is important to review what the script produces for targets.) When it has paired both devices, it will generate the masking file which will contain the targets to be masked and the failover file which will pair those targets with the R2s. Since it is not possible for the script to know what storage group you want to use for masking, it will use the R2 storage group in the masking file. Feel free to change it if desired. Also be aware that the script will include all devices together in the file. If you have multiple protection groups and wish to separate the targets into different storage groups, you will need to change the file to add the other storage group(s).

Good things to know, aka caveats

  • The script is use at your own risk. I explained this thoroughly in the original post but it bears repeating so you don’t try to open a support case. Issues should be filed on GitHub.
  • The script is basic, covering a simple two-site configuration. As I noted in the other post, if you have a more complicated environment you will need to modify the python script to suit your needs.
  • When using the masking capability, the script will not include any TDEV targets that are in replication relationships. This includes TimeFinder. The reason this is important is if I use the python script to generate my masking and failover files and then run a test failover with the default global options, the snapshot that is created is not terminated after the test (global option <TerminateCopySessions>No</TerminateCopySessions>). This means if I re-run the python script, those devices previously used will not be available even though they are not presented to the host. As most customers will just re-use the existing XML files it is not a problem but if you want to be sure the devices are available for future use then change the global option TerminateCopySessions to Yes.


So this is more of a hint than troubleshooting. As I mentioned the script looks at all replication on the vCenter. If you only use SRM for some datastores, the script will not know. It will still try to generate targets for all R2s. In such cases the script is bound to fail indicating it cannot find enough targets to satisfy the R2s. There are 2 ways that you could resolve this. First you could simply add a bunch of TDEV targets so the script succeeds. The other, easier option is to run the script with the –debug flag. When this flag is used the script dumps all the pairing information it was able to discover. Take this example below. I ran the following command against an environment I know did not have enough TDEVs:

python –usage=failover –debug

Now despite the script failing, note in the red box how debug shows me the R2s it could pair. I can now manually generate my failover file. Yes, manual is no fun but the script did the majority of the work for me.

Many thanks to Sam Gass who had to make time to do this while re-writing VSI. I only do the testing, troubleshooting and help a bit with designing. Sam does all the heavy lifting.


11 thoughts on “SRDF SRA – Python script for masking functionality

Add yours

  1. Hi Drew,

    Thanks for the script. I am getting an error while running the script. please find the errors below.

    Traceback (most recent call last):
    file “”, line 425, in
    File “”, line 382, in main
    vsphere_content – parse_vsphere_content(vsphere_conn, debug)
    File “”, line 46, in parse_vsphere_content
    for host in
    AttributeError: “vim.folder’ object has no attribute ‘host’

    Thanks for the advance help.

    1. Can you re-run the script with the –debug flag and post here. Also please include the vCenter and SMI-S versions.

      1. Thanks for your respond, Still i am getting an same error and i am using Windows vCenter 6.0 update 1 and SIM-S 8.2. installed Python 2.7 and imported all the required Python modules. Please confirm this will work on Windows vcenter and Windows Python versions.

  2. Yes, Windows is fine. Based on the error it seems to indicate your vCenter has no ESXi hosts. What does the vCenter structure look like?

    1. I have 20 more ESXi hosts is running on that vcenter and structure look like Datacenter -> Folder -> Cluster -> Hosts

  3. OK that’s probably the issue. The API we use is unforgiving and we had to start with an initial structure which I don’t believe accounted for a folder at the top of the stack. We’ll have to make some adjustments to the script. I’ll update here when there is a new version – just a reminder the developer does this on his own time. If is a quick fix perhaps we can test it by the end of the day, a more complicated issue would take a couple days.

      1. There is now an updated script you can pull off GitHub which will work in your environment. Should be up there shortly.

    1. You have to pass a flag to it – there is a readme.txt on GitHub. For your case you would do: python maskinginfo

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Website Powered by

Up ↑

%d bloggers like this: