Active IQ Unified Manager Discussions
Active IQ Unified Manager Discussions
I’m working on my first WFA development project and have ran into a hurdle I can’t seem to jump over. I ‘m looking for the way to take a location a user specifies and turn it into a local cluster name. From there I’ll be selecting an aggregate to create a new volume in for a new VMware datastore.
I created the short bit of code below to translate datacenter location to the correct site cluster name as a couple sites have multiple cluster but only one for VMware. My issue is feeding this newly assigned cluster name into the rest of the workflow so it uses the $ClusterName variable specified below throughout the workflow. I’m not necessarily looking for a complete solution but rather the general way to make this work.
param (
[parameter(Mandatory=$false, HelpMessage="Datacenter Location")]
[string]$DCLocation,
[parameter(Mandatory=$false, HelpMessage="Name of Cluster")]
[string]$ClusterName
)
if ($DCLocation = 'Valley Forge')
{$ClusterName = 'Amazon'}
elseif ($DCLocation = 'Denver')
{$ClusterName = 'Phoenix'}
elseif ($DCLocation = 'Ft. Worth')
{$ClusterName = 'Griffin'}
Hi knorman,
If the version of WFA that you are using is 2.2, you can make use of the powershell commandlets Add-WfaWorkflowParameter and Get-WfaWorkflowParameter. These will help you to add a parameter in one of the commands, which can then be accessed in any of the commands that follow.
You will have add "ClusterName" as a parameter in the command where you are translating the DCLocation to ClusterName in the following manner:
$ParameterName = "ClusterName"
$ParameterValue = $ClusterName
Add-WfaWorkflowParameter -Name $ParameterName -Value $ParameterValue
You can then get this parameter in the other command codes in the following way:
$ParameterName = "ClusterName"
$val = Get-WfaWorkflowParameter -Name $ParameterName
Note: You will not be able to access $ClusterName in other places in the workflow such as filters/loops. This variable will be scoped at command level only.
Hi Norman,
What you are really trying to do is resource selection based on location of the user who invoke the workflow.
For this you you will somehow need do a mapping of the location to user to resource. In such situation we generally recommend to use playground database to do such persistent mapping.
Other way is
Solution Courtesy, Shailaja
Regards
adai
Greetings,
There was a previous conversation that included something that would solve your problem with a function. With a function you can create this sort of hash map.
def regionMap(region) {
return ['Americas' : 'am', 'EMEA' : 'em', 'APAC' : 'ap', 'Switzerland' : 'ch', 'Singapore' : 'sn', 'Hong Kong' : 'hk'].get(region);
}
def locationMap(location) {
return ['Singapore':'sg','Tokyo':'tk','Sydney':'sy','Hong Kong':'hk','New York':'ny','London':'ln','Pune':'pn','Mumbai':'mu','Jakarta':'jk','Seoul':'se','Bangkok':'bk','Shanghai':'sh','Kuala Lumpur':'kl','Beijing':'bj','Taipei':'tp','Bangalore':'bg','Atlanta':'at','Boston':'bs','Buenos Aires':'ba','Calgary':'cg','Cayman Islands':'ci','Chicago':'cc','Dallas':'da','Houston':'hs','Las Angeles':'la','Mexico':'mx','Miami':'mi','Philadelphia':'ph','Raleigh':'ra','San Francisco':'sf','Toronto':'to','West Palm Beach':'wp','Paris':'pa','Dubai':'du','Doha':'do','Dublin':'db','Poland':'po','Madrid':'md','Milan':'ml','Turkey':'tu'].get(location);
}
To call it in your workflow you can simply use
(String)(regionMap($region)
volumeName
if ( $workflowMethod == 'Specified' ) { return ($INPUT_Volume) } else { return 'v' + (String)(regionMap($region)) + (String)(businessUnitMap($bu)) + (String)(useCaseMap($useCase)) }
vfilerName
if ( $workflowMethod == 'Specified' ) { return ($INPUT_VfilerName) } else { return 'vf' + (String)(regionMap($region)) + (String)(businessUnitMap($bu)) + (String)(useCaseMap($useCase)) + (String)(environmentMap($env)) }
In the workflow setup, I would add 2 CONSTANTS, 1 is the LOCATION and another is the CLUSTER. Both have a string separated by commas ( they are an array ).
LOCATION = "location1,location2,location3,location4"
CLUSTER = "cluster1,cluster4,cluster1,cluster1"
Then with a function we could get an index number of the location and place then place the cluster in a variable ( CLUSTER ) we could use to list the aggregates.
If working with a CSV file is not a problem ( to have a new datasource you could use in your SQL queries within the user inputs ), here is a 5min video that explains how to do it :