#!/usr/bin/env /opt/gvenv/venv_csui/bin/python3 # -*- coding: utf-8 -*- import requests import base64 import socket from library.vault.client import clientV HOSTNAME = socket.getfqdn() IS_DEV = ('.dev.' in HOSTNAME) IS_ACC = ('.acc.' in HOSTNAME) IS_PRODUCTION = (not IS_DEV and not IS_ACC) # User Input http_proxy = 'http://x50l002:x52503@vip-proxy-l4s.snmc.cec.eu.int:8012' #TODO -> necessary check via ini files the enviorment - create a specofic ini file for that username = 'DIGIT-WS-SNET-SMART' namespace_used = "EC/DIGIT_C4_SNET_ADMIN-ACC" base_url = "https://digituat.service-now.com/api/emdig/v1/itsm" vault_url = "https://sam-hcavault.cec.eu.int" if IS_DEV: print('IS DEV') engine = "dev" role_id_read = '3d20c565-ae1f-25dc-ba39-f17f20beb18e' secret_approle_read = '50cf5e80-e509-708c-707a-29c127714bc5' elif IS_ACC : print('IS ACC') engine = "acc" role_id_read = 'a516f820-6f9f-d963-9807-2aef7aeb3612' secret_approle_read = '37dfe79f-33f7-2fde-c412-86c43d7bbe50' else : print('IS PROD') namespace_used = "EC/DIGIT_C4_SNET_ADMIN-PROD" base_url = "https://digit.service-now.com/api/emdig/v1/itsm" vault_url = "https://sam-hcpvault.cec.eu.int" engine = 'prod' #Approle approle-prod-csui-change-mgmt role_id_read = 'd6717ad9-75db-37f2-363d-50f21a52408a' secret_approle_read = 'f13d0bbb-03ce-d470-27b3-8f606f3e86bf' #password = clientV.getPasswordByAppRole("apps-kv/"+engine+"/SNOW", vault_url, namespace_used, role_id_read, secret_approle_read) password = "+Xg76;CwCr4TgBCs" credentials = f"{username}:{password}" encoded_credentials = base64.b64encode(credentials.encode("utf-8")).decode("utf-8") authorization = f"Basic {encoded_credentials}" # End User Input