Simulating your Clustered ONTAP Environment: Part 1 - Cron Schedules and Snapshot Policies


When a systems gone production, and there’s things you still want to test against that environment, but you can’t because it’s now got live business critical data on, and users are using it; there’s nothing quite as nice as setting up your lab systems to as closely simulate the environment as possible.

- Setting up Clustered Data ONTAP Simulators is very simple and I’ve done many posts on this already (like here).
- Setting up the admin and node type SVMs is also relatively straight forward (names, aggregates, LIFs, ...)
Note: If you’ve already got a lab, you can use "hostname" to rename the clusters, "node rename" to rename the nodes, "aggr rename" to rename the aggregates...
- Setting up the data SVMs is similarly pretty straight forward using “vserver setup”, and you can go into as much detail as you like regards getting the options equivalents set to your liking.
Note: If you had existing SVMs you want rid of, blow them away with my SVM Destroyer. If you want to tidy up pre-existing Cron Schedules, Snapshot Policies, SnapMirror Policies it’s just ::>

set -confirmations off
snapmirror policy delete *
snapshot policy delete *
cron delete *

Note: Default entries don’t get deleted!

Building up the Lab Environment post SVM Build

Note: Some of the ideas below could also be used to synchronize real-world cluster configs...

Before obtaining outputs, we run ::>

set -privilege admin # The formulas below work for output from admin level
set -confirmations off
set -showallfields true
set -showseparator "#"

1) Cron Schedules

On your real environment, get the output of the following command, and copy and paste this into Excel using the ‘Text Import Wizard’ and # as a delimiter ::>

cron show

Then construct the following cron create command using Excel and Concatenate:

cron create -name {text} -month {cron_month} -dayofweek {cron_dayofweek} -day {cron_dayofmonth} -hour {cron_hour} -minute {cron_minute}

And here’s the magic Excel formula which goes in a completely empty column after the output, and we simply drag down/fill so we have a command for every row of input (ignoring output headers):

=CONCATENATE("cron create -name ","""",A3,""""," -month ","""",B3,""""," -dayofweek ","""",C3,""""," -day ","""",D3,""""," -hour ","""",E3,""""," -minute ","""",F3,"""" )

And copy and paste the commands in via PuTTY!

2) Snapshot Policies

On your real environment, get the output of the following command, and copy and paste this into Excel using the ‘Text Import Wizard’ and # and comma as delimiters ::>

snapshot policy show

Then construct the following snapshot policy create command using Excel and Concatenate:

snapshot policy create -vserver {vserver name} -policy {snapshot policy} -enabled {true|false} -comment {text} -schedule1 {text} -count1 {0..255} -prefix1 {text} -snapmirror-label1 {text} -schedule2 {text} -count2 {0..255} -prefix2 {text} -snapmirror-label2 {text} -schedule3 {text} -count3 {0..255} -prefix3 {text} -snapmirror-label3 {text} -schedule4 {text} -count4 {0..255} -prefix4 {text} -snapmirror-label4 {text} -schedule5 {text} -count5 {0..255} -prefix5 {text} -snapmirror-label5 {text}

The Excel for this is much more complicated, but it’s perfectly do-able (remember we’ve used two delimiters this time). The difficulty is because a Snapshot policy can have from 1 to 5 schedules (except the default none which has 0), and the output of ‘snapshot policy show’, separates the settings for the various schedules with commas within output elements (best to take a look at the output to understand this!). We have 6 formulas for 6 columns, 5 to work out the schedules (for if number of schedules = 1, 2, 3, 4, 5), and the sixth to bring it all together.

Column AA formula (for 1 schedule):

=IF(E3=1,CONCATENATE(" -schedule1 ","""",F3,""""," -count1 ","""",G3,""""," -prefix1 ","""",H3,""""," -snapmirror-label1 ","""",I3,""""),"")

Column AB formula (for 2 schedules):

=IF(E3=2,CONCATENATE(" -schedule1 ","""",F3,""""," -schedule2 ","""",G3,""""," -count1 ","""",H3,""""," -count2 ","""",I3,""""," -prefix1 ","""",J3,""""," -prefix2 ","""",K3,""""," -snapmirror-label1 ","""",L3,""""," -snapmirror-label2 ","""",M3,""""),"")

Column AC formula (for 3 schedules):

=IF(E3=3,CONCATENATE(" -schedule1 ","""",F3,""""," -schedule2 ","""",G3,""""," -schedule3 ","""",H3,""""," -count1 ","""",I3,""""," -count2 ","""",J3,""""," -count3 ","""",K3,""""," -prefix1 ","""",L3,""""," -prefix2 ","""",M3,""""," -prefix3 ","""",N3,""""," -snapmirror-label1 ","""",O3,""""," -snapmirror-label2 ","""",P3,""""," -snapmirror-label3 ","""",Q3,""""),"")

Column AD formula (for 4 schedules):

=IF(E3=4,CONCATENATE(" -schedule1 ","""",F3,""""," -schedule2 ","""",G3,""""," -schedule3 ","""",H3,""""," -schedule4 ","""",I3,""""," -count1 ","""",J3,""""," -count2 ","""",K3,""""," -count3 ","""",L3,""""," -count4 ","""",M3,""""," -prefix1 ","""",N3,""""," -prefix2 ","""",O3,""""," -prefix3 ","""",P3,""""," -prefix4 ","""",Q3,""""," -snapmirror-label1 ","""",R3,""""," -snapmirror-label2 ","""",S3,""""," -snapmirror-label3 ","""",T3,""""," -snapmirror-label4 ","""",U3,""""),"")

Column AE formula (for 5 schedules):

=IF(E3=5,CONCATENATE(" -schedule1 ","""",F3,""""," -schedule2 ","""",G3,""""," -schedule3 ","""",H3,""""," -schedule4 ","""",I3,""""," -schedule5 ","""",J3,""""," -count1 ","""",K3,""""," -count2 ","""",L3,""""," -count3 ","""",M3,""""," -count4 ","""",N3,""""," -count5 ","""",O3,""""," -prefix1 ","""",P3,""""," -prefix2 ","""",Q3,""""," -prefix3 ","""",R3,""""," -prefix4 ","""",S3,""""," -prefix5 ","""",T3,""""," -snapmirror-label1 ","""",U3,""""," -snapmirror-label2 ","""",V3,""""," -snapmirror-label3 ","""",W3,""""," -snapmirror-label4 ","""",X3,""""," -snapmirror-label5 ","""",Y3,""""),"")

Column AF formula (bringing it all together):

=CONCATENATE("snapshot policy create -vserver ","""",A3,""""," -policy ","""",B3,""""," -enabled ","""",C3,"""",AA3,AB3,AC3,AD3,AE3)