HPE Morpheus Enterprise
1855052 Members
2667 Online
104109 Solutions
New Discussion

How can I find out the actual Tenant and read the Customer Number?

 
SOLVED
Go to solution
Nunnemann
Advisor

How can I find out the actual Tenant and read the Customer Number?

We are running a Master Tenant and several Sub Tenants. All tenants are created with the Advanced Options of Account Number, Account Name and Customer Number. We need this information very early in a Provisiong Workflow - Configuration Phase to set a Hostname based on the Customer Number for the Spec.

We are running a Powershell script in that Workflow and read the Customer Number with a Rest API call on the endpoint “/api/accounts&name=customerName”. Unfortunately, we only found out how to fill the variable customerName manually before the script runs - that is, we put in the appropriate Tenant Name from case to case depending on the Tenant where we are logged in…

We could not figure out how to read the actual Tenant Name where we are logged into automatically. Within “Edit Task” of the Powershell script we saw variables like <%=tenant%> or <%=account%>, but we could not manage to deliver output from those.

Is there any way to find out the Tenant Name where I am actually logged in and read the Customer Number, both automatically in a script?

Any idea or help is greatly appreciated!

Thank you,
Kai

8 REPLIES 8
Ollie-Phillips
HPE Pro

Re: How can I find out the actual Tenant and read the Customer Number?

Hi Kai. It looks like accountNumber is available as a pre-provision var for instance and host naming, so could a hostname policy help, or at least give you the data and you then mutate it?

https://docs.morpheusdata.com/en/latest/troubleshooting/Variables_Examples.html?highlight=variables#pre-provision-vars

I’m sure I’ve missed some of the nuance, but just wanted to flag that, in case you haven’t seen the resource.



I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo
Nunnemann
Advisor

Re: How can I find out the actual Tenant and read the Customer Number?

Hi Chris,

I have tested the code lines within my environment and it works out fine! Hence, this is also a solution to the question - or like the music group U2 would say: Even Better Then The Real Thing.

Thank you,
Kai

Nunnemann
Advisor

Re: How can I find out the actual Tenant and read the Customer Number?

Hello Ollie,
hello Deepti,

Thank you for your very quick response. I will check this out and come back here to mark it as solution as early as I got it managed. I know, you already point in the right direction …

Thank you,
Kai

dgaharwar
Trusted Contributor

Re: How can I find out the actual Tenant and read the Customer Number?

accountName, accountNumber and customerNumber, all three are available as pre-provision vars.

Ollie-Phillips
HPE Pro
Solution

Re: How can I find out the actual Tenant and read the Customer Number?

What I had in mind, was using a naming policy, and then parsing it from the spec in the config phase

For example in Python, printing the morpheus object I see there is both hostName and computedHostName with the policy implemented.

print(morpheus)

Gives me this:

{
   "spec":{
      "hostName":"${customerNumber}-${cloudName.toLowerCase()}-${instance.instanceContext.toLowerCase()}-${groupCode}-${type.toLowerCase()}-${sequence+100} ",
      "computedHostName":"99999-vmware-1-dev-all-clouds-ubuntu-102-",

    ....
    }
}

The aim would be to strip the customerNumber from the computed hostname and use as required.

Like, you I can’t see a way to get customerNumber, accountNumber, or accountName independently of using them in a naming policy.



I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo
Nunnemann
Advisor

Re: How can I find out the actual Tenant and read the Customer Number?

Hi again,

I have managed to use the variables ${accountName} or ${customerNumber} within an Instance Naming Policy - but I cannot find a way to put the same or similar variables in a Powershell script and use it in the Configuration Phase of a Provisioning Workflow.

Since this script is a two line script like the following, can you try to get it running:

$customerName = ${accountName}
Write-Output ("Customer Name: " + $customerName)

The script like above runs without any accountName filled …

cbunge
HPE Pro

Re: How can I find out the actual Tenant and read the Customer Number?

I agree, it would be nice as a readily available variable. How I’ve used this in PowerShell:

$morphUrl = "<%=morpheus.applianceUrl%>"
$morphToken  = "<%=morpheus.apiAccessToken%>"
$morphTenant = "<%=accountId%>"
$headers=@{}
$headers.Add("accept", "application/json")
$headers.Add("authorization", "Bearer $morphToken")

#Print Customer Number
((Invoke-WebRequest -Uri "$($morphUrl)api/accounts/$morphTenant" -Method GET -Headers $headers).content | ConvertFrom-Json).account.customerNumber
Nunnemann
Advisor

Re: How can I find out the actual Tenant and read the Customer Number?

Hi Ollie,

I see your answer as solution, since one could use this way to extract the customerNumber in a script now and move on in the same script … Thank you.

Although I am also thinking about raising an idea in the appropriate section of this forum to find any easier way to read the information of accountName, accountNumber and customerNumber from anywhere at any time, since these values are really independent of any other component like an Instance, App, Cloud, …

Thank you,
Kai