Effective December 3, NetApp adopts Microsoft’s Business-to-Customer (B2C) identity management to simplify and provide secure access to NetApp resources.
For accounts that did not pre-register (prior to Dec 3), access to your NetApp data may take up to 1 hour as your legacy NSS ID is synchronized to the new B2C identity.
To learn more, read the FAQ and watch the video.
Need assistance? Complete this form and select “Registration Issue” as the Feedback Category.

Microsoft Virtualization Discussions

SnapShot Status in Perl

heindeldba

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

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

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

heindeldba

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

Announcements
NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.

NetApp Insights to Action
I2A Banner
Public