Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

cf login if cf space creation is skipped #381

Merged
merged 1 commit into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions libs/python/helperCommandExecution.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def login_cf(btpUsecase):
command = "cf login -a '" + cfApiEndpoint + "' -o '" + org + "' --sso"
pipe = True
else:
password = escapePassword(password)

command = "cf login -a '" + cfApiEndpoint + "' -o '" + org + "' -u '" + \
myemail + "' -p '" + password + "'"
runShellCommandFlex(btpUsecase, command, "INFO", "Logging-in to your CF environment in the org >" +
Expand All @@ -45,8 +47,6 @@ def login_btp(btpUsecase):
globalaccount = btpUsecase.globalaccount
btpCliRegion = btpUsecase.btpcliapihostregion

password = escapePassword(password)

command = "btp login --url 'https://cpcli.cf." + btpCliRegion + \
".hana.ondemand.com' --subdomain '" + globalaccount + "'"
if btpUsecase.loginmethod == "sso":
Expand All @@ -55,6 +55,9 @@ def login_btp(btpUsecase):
runShellCommandFlex(btpUsecase, command, "INFO", message, True, True)
fetchEmailAddressFromBtpConfigFile(btpUsecase)
else:

password = escapePassword(password)

message = "Logging-in to your global account with subdomain ID >" + \
str(globalaccount) + "< for your user >" + str(myemail) + "<"
command = command + " --user '" + \
Expand Down
5 changes: 5 additions & 0 deletions libs/python/helperRolesAndUsers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from libs.python.helperCommandExecution import runCommandAndGetJsonResult, runShellCommandFlex, runShellCommand
from libs.python.helperCommandExecution import login_cf
from libs.python.helperJson import getJsonFromFile
import logging

Expand Down Expand Up @@ -264,6 +265,10 @@ def assignUsersToEnvironments(btpUsecase):
if environments:
for environment in environments:
if environment.name == "cloudfoundry":
# Make sure that you are logged in to the CF API
if btpUsecase.skipcfspacecreation is True:
login_cf(btpUsecase)

org = btpUsecase.org
cfspacename = btpUsecase.cfspacename

Expand Down