Microsoft Virtualization Discussions

SnapShot Status in Perl

heindeldba
3,070 Views

I am writing a Perl script to automate attaching a SnapManager SnapShot as a drive on a server.

I have most of the command working, but I need to confirm the snapshot is not currently in use by SnapMirror.

Based on the code below, how do I get the SnapShot status?

my $result = $s->invoke("snapshot-list-info", volume => $Volume);
if ($result->results_errno != 0) {
  print "\nError Code: " . $result->results_errno . " - " . $result->results_reason() . "\n";
  return (-1);
}
my $snapshotlist = $result->child_get("snapshots");
if (!defined($snapshotlist) || ($snapshotlist eq "")) {
  printf("No snapshots on volume %s\n\n", $parent_vol_name);
  return (-1);
}
my @snapshots = $snapshotlist->children_get();
my $tmp = 0;
my $snapshot;
my $snap;
foreach my $ss (@snapshots) {
  $MName = $ss->child_get_string("name");
  $MTime = $ss->child_get_int("access-time", 0);
  $MStatus = $ss->child_get_string("state");  ######### this is the value I am not able to get
}

Thank You,

Michael

1 ACCEPTED SOLUTION

ryanc
3,070 Views

Michael:

I think you are looking for the 'busy' child element of snapshot-info.

$MStatus = $ss->child_get_string("busy");

The raw results back from ONTAP look like this:

<snapshot-info>
        <name>hourly.0</name>
        <access-time>1297717253</access-time>
        <total>2836</total>
        <cumulative-total>2836</cumulative-total>
        <dependency/>
        <busy>false</busy>
        <cumulative-percentage-of-used-blocks>0</cumulative-percentage-of-used-blocks>
        <percentage-of-used-blocks>0</percentage-of-used-blocks>
        <cumulative-percentage-of-total-blocks>0</cumulative-percentage-of-total-blocks>
        <percentage-of-total-blocks>0</percentage-of-total-blocks>
</snapshot-info>

-ryan

View solution in original post

2 REPLIES 2

ryanc
3,071 Views

Michael:

I think you are looking for the 'busy' child element of snapshot-info.

$MStatus = $ss->child_get_string("busy");

The raw results back from ONTAP look like this:

<snapshot-info>
        <name>hourly.0</name>
        <access-time>1297717253</access-time>
        <total>2836</total>
        <cumulative-total>2836</cumulative-total>
        <dependency/>
        <busy>false</busy>
        <cumulative-percentage-of-used-blocks>0</cumulative-percentage-of-used-blocks>
        <percentage-of-used-blocks>0</percentage-of-used-blocks>
        <cumulative-percentage-of-total-blocks>0</cumulative-percentage-of-total-blocks>
        <percentage-of-total-blocks>0</percentage-of-total-blocks>
</snapshot-info>

-ryan

heindeldba
3,070 Views

Thank you Ryan.

Through trial and error I was able to figure out that I needed to use "busy" last night.  Thank you for the quick reply and sample output.

Michael

Public