Setting DNS primary at Scale


Another “Ask Rick” was posted on Tintri’s corporate blog.  This post covers setting the VMstore’s primary DNS for 100s of VMstores.  This was done for our IT department.

The main thrust of this article, is how to modify VMstore configuration information with the Appliance API.  The Data Transfer Objects (DTOs) are hierarchical.  Let’s start with the Request DTO, because the Appliance API is PUT with it in the HTTP body.

# Create the Request object with the Appliance DTO.
Request = \
{'typeId': '',
 'objectsWithNewValues': newAppliance,
 'propertiesToBeUpdated': ['dnsConfig']

As you can see, the objectsWithNewValues field is an Appliance object, and the propertiesToBeUpdated is the dnsConfig field in the Appliance DTO since DNS configuration is desired to be changed.

# Create the Appliance object wit the new ApplianceDns DTO.
newAppliance = \
{'typeId': '',
 'dnsConfig': newDnsInfo

Above we see the newAppliance object with the dnsConfig field only.  We don’t need the other Appliance fields since we are not modifying them.  The dnsConfig field contains the new DNS values we want to set.

# Create the ApplianceDns DTO.
newDnsInfo = \
{'typeId': '',
 'dnsPrimary': new_dns_primary,
 'dnsSecondary': new_dns_secondary

Both primary and secondary DNS values need to be present because the API is modifying dnsConfig as a whole.

After the DTOs are created and filled with the appropriate values, the Appliance API is invoked.

APPLIANCE_URL = "/v310/appliance/default"

r = tintri.api_put(server_name, url, Request, session_id)

This template will be useful for setting other values in the Appliance.

Please check out this week’s “Ask Rick” for more details.  As always, you can leave comments and questions here.


– Rick –


One comment

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 )

Google+ photo

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

Connecting to %s