1 Rookie

 • 

72 Posts

February 4th, 2021 11:00

Hi Ihami,

I haven't setup an environment yet to test but I did notice that the "Add host to Consistency Group" task uses a different url_username than the previous two tasks.  Perhaps that what is tripping up the authentication?

Thanks
Bryan

2 Posts

February 5th, 2021 05:00

Thanks for looking at this. I think the URL is ok. I have used in Postman and ran a test in this small python test script and it works. Pretty sure that is because I use the same session and it has all the cookie info. Not sure how I would emulate that in Ansible. 

# import requests module
import requests
import urllib3
import json

urllib3.disable_warnings()

# Making a get request
s = requests.Session()
loginurl = 'https://172.26.13.244/api/types/loginSessionInfo/instances'
headers = {'Content-Type': 'application/json','Accept': 'application/json','X-EMC-REST-CLIENT':'true'}
response = s.get(loginurl,headers=headers,auth=('xxx','xxx'),verify=False)


# print headers of response
headers['EMC-CSRF-TOKEN'] = response.headers['EMC-CSRF-TOKEN']

# Add host to Consistency Group
print (s)
payload = {

"addBlockHostAccess": [
    {
      "host": {
        "id": "Host_1"
      },
      "accessMask": 1
    }
  ]
}

url = 'https://172.26.13.244/api/instances/storageResource/res_1/action/modifyConsistencyGroup'

response = s.post(url,auth='xxx','xxx'),headers=headers,verify=False,data=json.dumps(payload))
No Events found!

Top