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

Merge back from main to dev #18

Merged
merged 20 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
5 changes: 3 additions & 2 deletions plugins/module_utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
URL_SERVICE_INCIDENT = 'https://launchpad.support.sap.com/services/odata/incidentws'
URL_SERVICE_USER_ADMIN = 'https://launchpad.support.sap.com/services/odata/useradminsrv'
URL_SOFTWARE_DOWNLOAD = 'https://softwaredownloads.sap.com'
# Maintainance Planner
URL_MAINTAINANCE_PLANNER = 'https://maintenanceplanner.cfapps.eu10.hana.ondemand.com'
# Maintenance Planner
URL_MAINTENANCE_PLANNER = 'https://maintenanceplanner.cfapps.eu10.hana.ondemand.com'
URL_SYSTEMS_PROVISIONING = 'https://launchpad.support.sap.com/services/odata/i7p/odata/bkey'
URL_USERAPPS = 'https://userapps.support.sap.com/sap/support/mp/index.html'
URL_USERAPP_MP_SERVICE = 'https://userapps.support.sap.com/sap/support/mnp/services'
URL_LEGACY_MP_API = 'https://tech.support.sap.com/sap/support/mnp/services'
Expand Down
5 changes: 1 addition & 4 deletions plugins/module_utils/sap_api_common.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8

import logging
import re
from urllib.parse import urlparse
Expand Down Expand Up @@ -37,7 +34,7 @@ def _request(url, **kwargs):
if 'allow_redirects' not in kwargs:
kwargs['allow_redirects'] = True

method = 'POST' if kwargs.get('data') else 'GET'
method = 'POST' if kwargs.get('data') or kwargs.get('json') else 'GET'
res = https_session.request(method, url, **kwargs)
res.raise_for_status()

Expand Down
3 changes: 0 additions & 3 deletions plugins/module_utils/sap_id_sso.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/usr/bin/env python3
# coding: utf-8

import json
import logging
import re
Expand Down
13 changes: 4 additions & 9 deletions plugins/module_utils/sap_launchpad_maintenance_planner_runner.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#!/user/bin/env python3
# coding: utf-8

import os
import pathlib
import re
import time
Expand All @@ -11,11 +7,10 @@
from bs4 import BeautifulSoup
from lxml import etree
from requests.auth import HTTPBasicAuth
from requests.sessions import session

from . import constants as C
from .sap_api_common import _request, https_session
from .sap_id_sso import _get_sso_endpoint_meta, sap_sso_login
from .sap_id_sso import _get_sso_endpoint_meta

_MP_XSRF_TOKEN = None
_MP_TRANSACTIONS = None
Expand All @@ -24,7 +19,7 @@
def auth_maintenance_planner():
# Clear mp relevant cookies for avoiding unexpected responses.
_clear_mp_cookies('maintenanceplanner')
res = _request(C.URL_MAINTAINANCE_PLANNER)
res = _request(C.URL_MAINTENANCE_PLANNER)
sig_re = re.compile('signature=(.*?);path=\/";location="(.*)"')
signature, redirect = re.search(sig_re, res.text).groups()

Expand All @@ -35,7 +30,7 @@ def auth_maintenance_planner():
'locationAfterLogin': '%2F'
}

MP_DOMAIN = C.URL_MAINTAINANCE_PLANNER.replace('https://', '')
MP_DOMAIN = C.URL_MAINTENANCE_PLANNER.replace('https://', '')
for k, v in mp_cookies.items():
https_session.cookies.set(k, v, domain=MP_DOMAIN, path='/')

Expand Down Expand Up @@ -68,7 +63,7 @@ def auth_userapps():


def get_mp_user_details():
url = urljoin(C.URL_MAINTAINANCE_PLANNER,
url = urljoin(C.URL_MAINTENANCE_PLANNER,
'/MCP/MPHomePageController/getUserDetailsDisplay')
params = {'_': int(time.time() * 1000)}
user = _request(url, params=params).json()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#!/user/bin/env python3
# coding: utf-8

from . import constants as C
from .sap_api_common import _request
from .sap_id_sso import sap_sso_login


def get_software_catalog():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/user/bin/env python3
# coding: utf-8

import hashlib
import json
import logging
Expand All @@ -12,7 +9,7 @@

from . import constants as C
from .sap_api_common import _request, https_session
from .sap_id_sso import _get_sso_endpoint_meta, sap_sso_login
from .sap_id_sso import _get_sso_endpoint_meta

logger = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from . import constants as C
from .sap_api_common import _request
from .sap_id_sso import sap_sso_login


def search_software_fuzzy(query, max=None, csv_filename=None):
Expand Down
Loading