functions/Menus/ShowRealtimeMenu.ps1
<#
.SYNOPSIS Shows product menu .DESCRIPTION ShowRealtimeMenu .INPUTS ShowRealtimeMenu - The name of ShowRealtimeMenu .OUTPUTS None .EXAMPLE ShowRealtimeMenu .EXAMPLE ShowRealtimeMenu #> $here = Split-Path -Parent $MyInvocation.MyCommand.Path function ShowRealtimeMenu() { [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string] $baseUrl , [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string] $namespace , [Parameter(Mandatory = $true)] [bool] $local , [bool] $isAzure = $true ) Write-Verbose 'ShowRealtimeMenu: Starting' $userinput = "" while ($userinput -ne "q") { Write-Host "================ $namespace menu ================" Write-Host "------ Install -------" Write-Host "1: Install $namespace" Write-Host "------ Status --------" Write-Host "2: Show status of $namespace" Write-Host "3: Show web site urls" Write-Host "4: Show $namespace passwords" Write-Host "5: Show $namespace detailed status" Write-Host "6: Show $namespace logs" Write-Host "7: Show urls to download client certificates" # Write-Host "8: Show DNS entries for /etc/hosts" Write-Host "9: Troubleshoot Ingresses" Write-Host "11: Show commands to SSH to $namespace containers" Write-Host "13: Show command to run Fabric.Realtime tester" Write-Host "------ Delete data --------" Write-Host "12: Delete all data in $namespace" Write-Host "------ Testers --------" Write-Host "31: Test interface engine" Write-Host "32: Install Certificate on this machine (Needs Run As Administrator)" Write-Host "-----------" Write-Host "q: Go back to main menu" $userinput = Read-Host "Please make a selection" switch ($userinput) { '1' { $packageUrl = $globals.realtimePackageUrl if ($local) { $packageUrl = "$here\..\..\..\helm.realtime\fabricrealtime" Write-Host "Loading package from $packageUrl" } $namespace = "fabricrealtime" $VerbosePreference = 'Continue' CreateSecretsForStack -namespace $namespace -Verbose if ($isAzure) { InstallProductInAzure -namespace $namespace -packageUrl $packageUrl -local $local -Verbose } else { CreateOnPremStorage -namespace $namespace InstallStackInKubernetes ` -namespace $namespace ` -package $namespace ` -packageUrl $packageUrl ` -isOnPrem $true } } '2' { kubectl get 'deployments,pods,services,ingress,secrets,persistentvolumeclaims,persistentvolumes,nodes' --namespace=$namespace -o wide } '3' { if ($namespace -eq "fabricrealtime") { $certhostname = $(ReadSecretValue certhostname $namespace) Write-Host "Send HL7 to Mirth: server=${certhostname} port=6661" Write-Host "Rabbitmq Queue: server=${certhostname} port=5671" $rabbitmqpassword = $(ReadSecretPassword rabbitmqmgmtuipassword $namespace) Write-Host "RabbitMq Mgmt UI is at: http://${certhostname}/rabbitmq/ user: admin password: $rabbitmqpassword" Write-Host "Mirth Mgmt UI is at: http://${certhostname}/mirth/ user: admin password:admin" } elseif ($namespace -eq "fabricnlp") { $loadBalancerIP = kubectl get svc traefik-ingress-service-public -n kube-system -o jsonpath='{.status.loadBalancer.ingress[].ip}' --ignore-not-found=true $loadBalancerInternalIP = kubectl get svc traefik-ingress-service-internal -n kube-system -o jsonpath='{.status.loadBalancer.ingress[].ip}' --ignore-not-found=true if ([string]::IsNullOrWhiteSpace($loadBalancerIP)) { $loadBalancerIP = $loadBalancerInternalIP } $customerid = ReadSecretValue -secretname customerid $customerid = $customerid.ToLower().Trim() # Invoke-WebRequest -useb -Headers @{"Host" = "nlp.$customerid.healthcatalyst.net"} -Uri http://$loadBalancerIP/nlpweb | Select-Object -Expand Content Write-Host "To test out the NLP services, open Git Bash and run:" Write-Host "curl -L --verbose --header 'Host: solr.$customerid.healthcatalyst.net' 'http://$loadBalancerInternalIP/solr' -k" Write-Host "curl -L --verbose --header 'Host: $customerid.healthcatalyst.net' 'http://$loadBalancerInternalIP/external' -k" Write-Host "curl -L --verbose --header 'Host: nlp.$customerid.healthcatalyst.net' 'http://$loadBalancerIP/nlpweb' -k" Write-Host "curl -L --verbose --header 'Host: nlpjobs.$customerid.healthcatalyst.net' 'http://$loadBalancerIP/nlp' -k" Write-Host "If you didn't setup DNS, add the following entries in your c:\windows\system32\drivers\etc\hosts file to access the urls from your browser" Write-Host "$loadBalancerInternalIP solr.$customerid.healthcatalyst.net" Write-Host "$loadBalancerIP nlp.$customerid.healthcatalyst.net" Write-Host "$loadBalancerIP nlpjobs.$customerid.healthcatalyst.net" Write-Host "$loadBalancerInternalIP $customerid.healthcatalyst.net" # clear Google DNS cache: http://www.redsome.com/flush-clear-dns-cache-google-chrome-browser/ Write-Host "Launching http://$loadBalancerInternalIP/external in the web browser" Start-Process -FilePath "http://$loadBalancerInternalIP/external"; Write-Host "Launching http://$loadBalancerInternalIP/solr in the web browser" Start-Process -FilePath "http://$loadBalancerInternalIP/solr"; Write-Host "Launching http://$loadBalancerIP/nlpweb in the web browser" Start-Process -FilePath "http://$loadBalancerIP/nlpweb"; } } '4' { if ($namespace -eq "fabricrealtime") { $secrets = $(kubectl get secrets -n $namespace -o jsonpath="{.items[?(@.type=='Opaque')].metadata.name}") Write-Host "All secrets in $namespace : $secrets" WriteSecretPasswordToOutput -namespace $namespace -secretname "mysqlrootpassword" WriteSecretPasswordToOutput -namespace $namespace -secretname "mysqlpassword" WriteSecretValueToOutput -namespace $namespace -secretname "certhostname" WriteSecretPasswordToOutput -namespace $namespace -secretname "certpassword" WriteSecretPasswordToOutput -namespace $namespace -secretname "rabbitmqmgmtuipassword" } elseif ($namespace -eq "fabricnlp") { $secrets = $(kubectl get secrets -n $namespace -o jsonpath="{.items[?(@.type=='Opaque')].metadata.name}") Write-Host "All secrets in $namespace : $secrets" WriteSecretPasswordToOutput -namespace $namespace -secretname "mysqlrootpassword" WriteSecretPasswordToOutput -namespace $namespace -secretname "mysqlpassword" WriteSecretPasswordToOutput -namespace $namespace -secretname "smtprelaypassword" WriteSecretValueToOutput -namespace $namespace -secretname "jobserver-external-url" WriteSecretValueToOutput -namespace $namespace -secretname "nlpweb-external-url" } } '5' { ShowStatusOfAllPodsInNameSpace "$namespace" } '6' { ShowLogsOfAllPodsInNameSpace "$namespace" } '7' { $certhostname = $(ReadSecretValue certhostname $namespace) $certpassword = $(ReadSecretPassword certpassword $namespace) $url = "http://${certhostname}/certificates/client/fabricrabbitmquser_client_cert.p12" Write-Host "Download the client certificate:" Write-Host "$url" Write-Host "Double-click and install in Local Machine. password: $certpassword" Write-Host "Open Certificate Management, right click on cert and give everyone access to key" $url = "http://${certhostname}/certificates/client/fabric_ca_cert.p12" Write-Host "Optional: Download the CA certificate:" Write-Host "$url" Write-Host "Double-click and install in Local Machine. password: $certpassword" } # '8' { # Write-Host "If you didn't setup DNS, add the following entries in your c:\windows\system32\drivers\etc\hosts file to access the urls from your browser" # $loadBalancerIP = $(dig +short myip.opendns.com "@resolver1.opendns.com") # $certhostname = $(ReadSecretValue certhostname $namespace) # Write-Host "$loadBalancerIP $certhostname" # } '9' { TroubleshootIngress "$namespace" } '11' { ShowSSHCommandsToContainers -namespace $namespace } '12' { Write-Warning "This will delete all data in this namespace and clear out any secrets" Do { $confirmation = Read-Host "Do you want to continue? (y/n)"} while ([string]::IsNullOrWhiteSpace($confirmation)) $isAzure = $true if ($confirmation -eq "y") { DeleteHelmPackage -package $namespace -Verbose if($isAzure){ DeleteNamespaceAndData -namespace "$namespace" -isAzure $isAzure -Verbose } else { CleanOutNamespace -namespace $namespace if ($isAzure) { DeleteAzureStorage -namespace $namespace } else { DeleteOnPremStorage -namespace $namespace } DeleteAllSecretsInNamespace -namespace $namespace -Verbose } } } '13' { RunRealtimeTester -baseUrl $baseUrl } '31' { $loadBalancerInfo = $(GetLoadBalancerIPs) $loadBalancerInternalIP = $loadBalancerInfo.InternalIP # Test-TcpPort -InterfaceEngineHost $($loadBalancerInfo.ExternalIP) -port 3307 Test-TcpPort -InterfaceEngineHost $($loadBalancerInfo.ExternalIP) -port 6661 Test-SendingHL7 -InterfaceEngineHost $($loadBalancerInfo.ExternalIP) } '32' { $loadBalancerInfo = $(GetLoadBalancerIPs) $result = $(Test-DownloadCertificate -CertificateHost $($loadBalancerInfo.ExternalIP)) $certpassword = $(ReadSecretPassword certpassword $namespace) Install-Certificate -certdata $($result.CertData) -certpass "$certpassword" } 'q' { return } } $userinput = Read-Host -Prompt "Press Enter to continue or q to go back to top menu" if ($userinput -eq "q") { return } [Console]::ResetColor() Clear-Host } Write-Verbose 'ShowRealtimeMenu: Done' } Export-ModuleMember -Function 'ShowRealtimeMenu' |