Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename surf backend host option to base_url #92

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
2 changes: 1 addition & 1 deletion src/supa/nrm/backends/surf.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
host=http://localhost:8888
base_url=http://localhost:8888
oauth2_active=False
oidc_url=https://connect.test.surfconext.nl/oidc/token
oidc_user=UNKNOWN
Expand Down
18 changes: 9 additions & 9 deletions src/supa/nrm/backends/surf.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class BackendSettings(BaseSettings):
See also: the ``src/supa/nrm/backends/surf.env`` file
"""

host: str = "http://localhost"
base_url: str = "http://localhost"
oauth2_active: bool = False
oidc_url: str = ""
oidc_user: str = ""
Expand Down Expand Up @@ -72,7 +72,7 @@ def _retrieve_access_token(self) -> str:
raise NsiException(GenericRmError, str(http_err)) from http_err
else:
access_token = token.json()["access_token"]
self.log.debug("workflow credentials", access_token=access_token, host=self.backend_settings.host)
self.log.debug("workflow credentials", access_token=access_token, base_url=self.backend_settings.base_url)
return access_token

def _workflow_create(self, src_port_id: str, src_vlan: int, dst_port_id: str, dst_vlan: int, bandwidth: int) -> Any:
Expand All @@ -96,7 +96,7 @@ def _workflow_create(self, src_port_id: str, src_vlan: int, dst_port_id: str, ds
self.log.debug("create workflow payload", payload=dumps(json))
try:
result = post(
f"{self.backend_settings.host}/api/processes/{self.backend_settings.create_workflow_name}",
f"{self.backend_settings.base_url}/api/processes/{self.backend_settings.create_workflow_name}",
headers={"Authorization": f"bearer {access_token}", "Content-Type": "application/json"},
json=json,
)
Expand All @@ -120,7 +120,7 @@ def _workflow_terminate(self, subscription_id: str) -> Any:
access_token = self._retrieve_access_token()
try:
result = post(
f"{self.backend_settings.host}/api/processes/{self.backend_settings.terminate_workflow_name}",
f"{self.backend_settings.base_url}/api/processes/{self.backend_settings.terminate_workflow_name}",
headers={
"Authorization": f"bearer {access_token}",
"Content-Type": "application/json",
Expand All @@ -144,7 +144,7 @@ def _add_note(self, connection_id: UUID, subscription_id: str) -> Any:
try:
self.log.debug("adding connection id to note of subscription")
result = post(
f"{self.backend_settings.host}/api/processes/modify_note",
f"{self.backend_settings.base_url}/api/processes/modify_note",
headers={
"Authorization": f"bearer {access_token}",
"Content-Type": "application/json",
Expand All @@ -169,7 +169,7 @@ def _get_process_info(self, process_id: str) -> Any:
access_token = self._retrieve_access_token()
try:
process = get(
f"{self.backend_settings.host}/api/processes/{process_id}",
f"{self.backend_settings.base_url}/api/processes/{process_id}",
headers={"Authorization": f"bearer {access_token}"},
)
except ConnectionError as con_err:
Expand All @@ -193,7 +193,7 @@ def _wait_for_completion(self, process_id: str) -> None:
def _get_subscription_id(self, process_id: str) -> str:
access_token = self._retrieve_access_token()
process = get(
f"{self.backend_settings.host}/api/processes/{process_id}",
f"{self.backend_settings.base_url}/api/processes/{process_id}",
headers={"Authorization": f"bearer {access_token}"},
)
self.log.debug("process status", process_status=process.json()["status"])
Expand All @@ -202,7 +202,7 @@ def _get_subscription_id(self, process_id: str) -> str:
def _get_nsi_stp_subscriptions(self) -> Any:
access_token = self._retrieve_access_token()
nsi_stp_subscriptions = get(
f"{self.backend_settings.host}/api/subscriptions/?filter=status,active,tag,NSISTP-NSISTPNL",
f"{self.backend_settings.base_url}/api/subscriptions/?filter=status,active,tag,NSISTP-NSISTPNL",
headers={"Authorization": f"bearer {access_token}"},
)
if nsi_stp_subscriptions.status_code != 200:
Expand All @@ -219,7 +219,7 @@ def _get_topology(self) -> List[STP]:
ports: List[STP] = []
for nsi_stp_sub in self._get_nsi_stp_subscriptions():
nsi_stp_dm = get(
f"{self.backend_settings.host}/api/subscriptions/domain-model/{nsi_stp_sub['subscription_id']}",
f"{self.backend_settings.base_url}/api/subscriptions/domain-model/{nsi_stp_sub['subscription_id']}",
headers={"Authorization": f"bearer {access_token}"},
)
if nsi_stp_dm.status_code != 200:
Expand Down
Loading