Active IQ Unified Manager Discussions

Populate a variable based on results from query

dblackwe
4,124 Views

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
4,045 Views

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
4,085 Views

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
4,062 Views

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
4,046 Views

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.

dblackwe
3,990 Views

This was exactly it.  Thanks

Public