From 2180c28ff83d190d20487840cac672bf27655dbc Mon Sep 17 00:00:00 2001 From: Nick Buonarota Date: Wed, 6 Feb 2019 14:07:08 -0500 Subject: [PATCH 1/2] Change var "all_nodes" to "response" --- xCAT-server/xCAT-wsapi/xcatws-test.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xCAT-server/xCAT-wsapi/xcatws-test.py b/xCAT-server/xCAT-wsapi/xcatws-test.py index 7fa06322a..723f152ad 100755 --- a/xCAT-server/xCAT-wsapi/xcatws-test.py +++ b/xCAT-server/xCAT-wsapi/xcatws-test.py @@ -77,20 +77,20 @@ except Exception as e: # # Send a request to get all nodes, passing in user and password # -all_nodes = requests.get(get_all_nodes + "?userName=" + username + "&userPW=" + password, verify=False) +response = requests.get(get_all_nodes + "?userName=" + username + "&userPW=" + password, verify=False) # Display returned data print "List of all nodes extracted with userid and password:" -print all_nodes.content +print response.content # # Send a request to get all nodes, passing in a token # user_data = {'userName': username,'userPW': password} token = requests.post(get_token, verify=False, headers={'Content-Type': 'application/json'}, data=json.dumps(user_data)) -all_nodes = requests.get(get_all_nodes, verify=False, headers={'X-Auth-Token': token.json()['token']['id']}) +response = requests.get(get_all_nodes, verify=False, headers={'X-Auth-Token': token.json()['token']['id']}) # Display returned data print "List of all nodes extracted with authentication token:" -print all_nodes.content +print response.content sys.exit(0) From 89ae21a719cc80657ba252a49bc046731727020a Mon Sep 17 00:00:00 2001 From: Nick Buonarota Date: Wed, 6 Feb 2019 14:09:42 -0500 Subject: [PATCH 2/2] change accessed attribute from content to text - content is "Content of the response, in bytes." - python is smart enough to print this - might be clearer to use "text" for someone new looking at this example. --- xCAT-server/xCAT-wsapi/xcatws-test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-server/xCAT-wsapi/xcatws-test.py b/xCAT-server/xCAT-wsapi/xcatws-test.py index 723f152ad..2f37126cf 100755 --- a/xCAT-server/xCAT-wsapi/xcatws-test.py +++ b/xCAT-server/xCAT-wsapi/xcatws-test.py @@ -81,7 +81,7 @@ response = requests.get(get_all_nodes + "?userName=" + username + "&userPW=" + p # Display returned data print "List of all nodes extracted with userid and password:" -print response.content +print response.text # # Send a request to get all nodes, passing in a token # @@ -91,6 +91,6 @@ response = requests.get(get_all_nodes, verify=False, headers={'X-Auth-Token': to # Display returned data print "List of all nodes extracted with authentication token:" -print response.content +print response.text sys.exit(0)