Commit 6d23d542 authored by Marcello Golfieri's avatar Marcello Golfieri
Browse files

more debug logging, parameterized base_url, suppressed verify=false option for requests

parent be979ee0
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ It has been developed by Stanford Research Computing for our HPC cluster account

# Python Version
Python 2.6 or 2.7 are fully supported.
Python 3.x support still beta

# Third Party Libraries and Dependencies
The following library is required:
@@ -19,6 +20,10 @@ Marcello Golfieri
```
python wgcli.py
```
e.g. to run in UAT space:
```
./wgcli.py --wg_cert ~/work/secrets/workgroup/iedo_workgroup_api_dev.crt --wg_cert_key ~/work/secrets/workgroup/iedo_workgroup_api_dev.key --base_url=https://aswsuat.stanford.edu/mais/workgroupsvc/v1
```
# Testing
```
cd tests/
+10 −2
Original line number Diff line number Diff line
@@ -62,11 +62,18 @@ workgroup.remove_admin_workgroup(admin_workgroup)

__author__ = 'sthiell@stanford.edu (Stephane Thiell)'

import requests
import os, sys, requests, logging
from textwrap import dedent
import xml.etree.ElementTree as ET
from xml.parsers.expat import ExpatError

import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
logging.basicConfig(
    stream=sys.stdout,
    level=os.environ.get("LOGLEVEL", "INFO"),
    format="%(levelname)s %(message)s",
)
logger = logging.getLogger(__name__)

DEFAULT_BASE_URL = "https://workgroupsvc.stanford.edu/v1"

@@ -408,6 +415,7 @@ class SUWorkgroupManager(object):

    def _check_response(self, response):
        """Check HTTP response"""
        logger.debug("Response: {}".format(response.text))
        code = response.status_code
        errmsg = ''
        try:
+11 −1
Original line number Diff line number Diff line
@@ -86,9 +86,19 @@ def main():
        help="Workgroup Manager API Key",
        default="certs/xstream.key",
    )
    parser.add_argument(
        "--base_url",
        action="store",
        dest="base_url",
        help="Workgroup Manager base API URL. e.g. specify  https://aswsuat.stanford.edu/mais/workgroupsvc/v1 to use UAT",
        default="https://workgroupsvc.stanford.edu/v1",
    )
    args = parser.parse_args()

    manager = SUWorkgroupManager(cert=args.wg_cert, cert_key=args.wg_cert_key)
    # UAT/DEV url:
    #   https://aswsuat.stanford.edu/mais/workgroupsvc/v1/workgroups

    manager = SUWorkgroupManager(base_url=args.base_url, cert=args.wg_cert, cert_key=args.wg_cert_key)

    print(
        """######################################