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.

Active IQ Unified Manager Discussions

Populate a variable based on results from query

dblackwe

So, IHAC who has a long naming convention.  They include alot of short names for things.  I have all my querys for getting cluster, and aggr, and svm, but they want to use abbreviated names in the volume name for those. i.e. cluster1 = cl1_, cluster1 = cl2_ etc etc.

 

Beyond having dozens of copies of each command and using if statements to run them or not run them, is there a more straight forward way of achieving this?

 

1 ACCEPTED SOLUTION

sinhaa

This is easier than the earlier:

===

function returnShortName_copy(inputStr)
{


if( inputStr == "Computer1")
{
return "bob";
}
else if (inputStr == "Computer2")
{
return "fred";
}
else
{
return inputStr;
}

 

}

=======

 

sinhaa

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

View solution in original post

4 REPLIES 4

sinhaa

If the customer has ( and they need to ) a consistent naming rule to obtain the short-names then this can be achieved using fucntions.

 

Full names: cluster1, cluster2

Short Naming rule: the first 2 letters of the name and the last suffix and an underscore

So abbrevated names as you said will be: cl1_ , cl2_

 

I can write a fuction to obtain the short-form names for this naming rule.

===

 

function returnShortName(inputStr)
{
int len = inputStr.length();
len--;
return inputStr.substring(0,2) + inputStr.substring(len) + "_"
}

 

===

 

Create a function with the above code and in your parameters for create volume, volume name field can call something like: returnShortName("cluster1") + "vol01"

So my volume name will be cl1_vol01. If you want add your Vserver too, just do it.

 

sinhaa  

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

dblackwe

Sinhaa,

 

That is very helpful.  

 

Could you show me what a function would look like that does a complete replace?  A bunch of if statements.

 

if $clusterName == Cluster1{

$clusShort=bob

}elsif $clusterName == Cluster2{

$clusShort=fred

}

 

David

sinhaa

This is easier than the earlier:

===

function returnShortName_copy(inputStr)
{


if( inputStr == "Computer1")
{
return "bob";
}
else if (inputStr == "Computer2")
{
return "fred";
}
else
{
return inputStr;
}

 

}

=======

 

sinhaa

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

View solution in original post

dblackwe

This was exactly it.  Thanks

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