Software Development Kit (SDK) and API Discussions

cDOT API modify volume

STORAGE_CIT
3,518 Views

Hi,

 

i´m just trying to modify a cdot volume with the API call volume-modify-iter.

I will change the export policy from the volume.

 

Here is the perl code:

 

my ($cluster,$vserver,$volname) = (@_);
    #$cluster = 'demchdcc01n';
    my $server = cluster_connect($cluster);
    $server->set_vserver($vserver);

    my $in = NaElement->new("volume-modify-iter");
    my $in_query = NaElement->new("query");
    my $in_attr = NaElement->new("attributes");

    my $in_sh = NaElement->new("volume-snapshot-attributes");
    my $in_ex = NaElement->new("volume-export-attributes");
    my $in_id= NaElement->new("volume-id-attributes");

    $in_sh->child_add_string("snapshot-policy", "none");
    $in_ex->child_add_string("policy", $volname);
    $in_id->child_add_string("name", $volname);

    $in->child_add($in_query);
    $in->child_add($in_attr);

    $in_query->child_add($in_id);

    $in_attr->child_add($in_sh);

    print Dumper($in);

    my $out = $server->invoke_elem($in);

    if ($out->results_status() eq "failed"){
          print($out->results_reason());
          print("\n");
          #exit (-2);
        }
        else{
          print "modified volume: /$volname\n";
        }

 

 

When i run the script, i got this error: Unexpected type name: volume-snapshot-attributes

We are running Cluster Mode 8.2.3

 

Does anybody have a idea where the error is?

 

Many thanks in advanced!

 

 

 

3 REPLIES 3

asulliva
3,497 Views

Some of the objects are being modified after they are added as children.  I'm not sure if they are passed by reference or not...if not, then they might not be getting the right values.  I've reordered the script, you might see if it helps:

 

my ($cluster,$vserver,$volname) = (@_);

#$cluster = 'demchdcc01n';
my $server = cluster_connect($cluster);
$server->set_vserver($vserver);

# not used?
#my $in_ex = NaElement->new("volume-export-attributes");
#$in_ex->child_add_string("policy", $volname);

# create the query to specify which volume(s) to modify
my $in_query = NaElement->new("query");
my $in_id = NaElement->new("volume-id-attributes");
$in_id->child_add_string("name", $volname);
$in_query->child_add($in_id);

# specify the attributes to modify and their new value
my $in_attr = NaElement->new("attributes");
my $in_sh = NaElement->new("volume-snapshot-attributes");
$in_sh->child_add_string("snapshot-policy", "none");
$in_attr->child_add($in_sh);

# associate with the ZAPI
my $in = NaElement->new("volume-modify-iter");
$in->child_add($in_query);
$in->child_add($in_attr);

print Dumper($in);

# execute
my $out = $server->invoke_elem($in);

if ($out->results_status() eq "failed"){
	print($out->results_reason());
	print("\n");
	#exit (-2);
} else {
	print "modified volume: /$volname\n";
}
If this post resolved your issue, please help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

STORAGE_CIT
3,461 Views

Hi,

 

i just tried the reordered script. I got the same error: Unexpected type name: volume-snapshot-attributes. 😞

 

The SKD Help to the API call volume-modify-iter is not very helpful!

 

STORAGE_CIT
3,455 Views

Hi,

 

i could solve the problem by myself. I found a valid vol modify perl script in the wfa server.

Now it works fine.

 

my ($cluster,$vserver,$volname,$snappol,$exportpol) = (@_);
    my $server = cluster_connect($cluster);
    $server->set_vserver($vserver);

    my %input = (
        'query' => { 'volume-attributes' => {'volume-id-attributes' => {'name'=> $volname}}}

            );

    my $volume = $server->volume_get_iter(%input);
    #print Dumper($volume);

    if ( $volume ->{'num-records'} eq 0)
        {
        #Volume doesn't exists. Fail now
        exit "Volume $volname not found on Storage Virtual Machine $vserver";
        }

    if (defined $snappol){
        #my $check_value = 1;
        $input {'attributes'} {'volume-attributes' } {'volume-snapshot-attributes' } = {'snapshot-policy' => $snappol};
    }

    if (defined $exportpol){
        #my$check_value = 1;
        $input {'attributes'} {'volume-attributes' } {'volume-export-attributes' } = {'policy' => $exportpol};
    }

    my $out = $server->volume_modify_iter(%input);

    #print Dumper($out);

    if ($out ->{'num-failed'} > 0){
       print $out->{'failure-list'}->{'volume-modify-iter-info'}->[0]->{'error-message'};
       print("\n");
       #exit (-2);
    }
    else{
       print "modified volume: /$volname\n";
    }

 

 

Public