--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/2bd829bd-983e-4898-abc2-b2288e41774c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
ansible-ucs brihopki$ ansible-playbook callhome.yml -vvv
Using /Users/brihopki/ansible-ucs/ansible.cfg as config file
PLAYBOOK: callhome.yml *********************************************************
1 plays in callhome.yml
PLAY [ucs] *********************************************************************
TASK [Login 14.17.106.164] *****************************************************
task path: /Users/brihopki/ansible-ucs/callhome.yml:7
Using module file /Users/brihopki/ansible-ucs/library/ucs_login.py
<ucspe> ESTABLISH LOCAL CONNECTION FOR USER: brihopki
<ucspe> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1483965963.97-212442284630795 `" && echo ansible-tmp-1483965963.97-212442284630795="` echo $HOME/.ansible/tmp/ansible-tmp-1483965963.97-212442284630795 `" ) && sleep 0'
<ucspe> PUT /var/folders/nb/1422r72n7qz_gq0knfzd6n200000gn/T/tmpEoezdU TO /Users/brihopki/.ansible/tmp/ansible-tmp-1483965963.97-212442284630795/ucs_login.py
<ucspe> EXEC /bin/sh -c 'chmod u+x /Users/brihopki/.ansible/tmp/ansible-tmp-1483965963.97-212442284630795/ /Users/brihopki/.ansible/tmp/ansible-tmp-1483965963.97-212442284630795/ucs_login.py && sleep 0'
<ucspe> EXEC /bin/sh -c '/usr/bin/python /Users/brihopki/.ansible/tmp/ansible-tmp-1483965963.97-212442284630795/ucs_login.py; rm -rf "/Users/brihopki/.ansible/tmp/ansible-tmp-1483965963.97-212442284630795/" > /dev/null 2>&1 && sleep 0'
ok: [ucspe] => {
"changed": false,
"cookie": "1483965469/94631f41-341b-402c-827d-12b24e7707af",
"handle": "{\n \"_UcsHandle__commit_buf\": {}, \n \"_UcsSession__domains\": \"org-root\", \n \"_UcsSession__refresh_period\": 600, \n \"_UcsSession__name\": \"\", \n \"_UcsSession__evt_channel\": \"noencssl\", \n \"_UcsSession__uri\": \"https://14.17.106.164:443\", \n \"py/object\": \"ucsmsdk.ucshandle.UcsHandle\", \n \"_UcsSession__ip\": \"14.17.106.164\", \n \"_UcsSession__priv\": \"aaa,admin,ext-lan-config,ext-lan-policy,ext-lan-qos,ext-lan-security,ext-san-config,ext-san-policy,ext-san-security,fault,operations,pod-config,pod-policy,pod-qos,pod-security,read-only\", \n \"_UcsSession__last_update_time\": \"Mon Jan 9 07:46:04 2017\", \n \"_UcsHandle__commit_buf_tagged\": {}, \n \"_UcsSession__virtual_ipv4_address\": \"14.17.106.164\", \n \"_UcsSession__force\": false, \n \"_UcsHandle__threaded\": false, \n \"_UcsSession__ucs\": \"UCSPE-14-17-106-164\", \n \"_UcsSession__version\": {\n \"py/object\": \"ucsmsdk.ucscoremeta.UcsVersion\", \n \"_UcsVersion__major\": \"3\", \n \"_UcsVersion__patch\": \"c\", \n \"_UcsVersion__mr\": \"2\", \n \"_UcsVersion__version\": \"3.0(2c)\", \n \"_UcsVersion__minor\": \"0\"\n }, \n \"_UcsSession__dump_xml\": false, \n \"_UcsSession__channel\": \"noencssl\", \n \"_UcsSession__session_id\": \"\", \n \"_UcsSession__redirect\": false, \n \"_UcsSession__cookie\": \"1483965469/94631f41-341b-402c-827d-12b24e7707af\", \n \"_UcsSession__proxy\": null, \n \"_UcsSession__refresh_timer\": null, \n \"_UcsSession__password\": \"ucspe\", \n \"_UcsSession__driver\": {\n \"py/object\": \"ucsmsdk.ucsdriver.UcsDriver\", \n \"_UcsDriver__handlers\": [\n {\n \"py/type\": \"ucsmsdk.ucsdriver.SmartRedirectHandler\"\n }, \n {\n \"py/type\": \"ucsmsdk.ucsdriver.TLS1Handler\"\n }\n ], \n \"_UcsDriver__headers\": {}, \n \"_UcsDriver__redirect_uri\": null, \n \"_UcsDriver__proxy\": null\n }, \n \"_UcsSession__username\": \"ucspe\"\n}",
"invocation": {
"module_args": {
"ip": "14.17.106.164",
"password": "ucspe",
"username": "ucspe"
},
"module_name": "ucs_login"
},
"logged_in": true
}
TASK [Logout 14.17.106.164] ****************************************************
task path: /Users/brihopki/ansible-ucs/callhome.yml:14
Using module file /Users/brihopki/ansible-ucs/library/ucs_logout.py
<ucspe> ESTABLISH LOCAL CONNECTION FOR USER: brihopki
<ucspe> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1483965965.23-176363209450610 `" && echo ansible-tmp-1483965965.23-176363209450610="` echo $HOME/.ansible/tmp/ansible-tmp-1483965965.23-176363209450610 `" ) && sleep 0'
<ucspe> PUT /var/folders/nb/1422r72n7qz_gq0knfzd6n200000gn/T/tmp39d_hb TO /Users/brihopki/.ansible/tmp/ansible-tmp-1483965965.23-176363209450610/ucs_logout.py
<ucspe> EXEC /bin/sh -c 'chmod u+x /Users/brihopki/.ansible/tmp/ansible-tmp-1483965965.23-176363209450610/ /Users/brihopki/.ansible/tmp/ansible-tmp-1483965965.23-176363209450610/ucs_logout.py && sleep 0'
<ucspe> EXEC /bin/sh -c '/usr/bin/python /Users/brihopki/.ansible/tmp/ansible-tmp-1483965965.23-176363209450610/ucs_logout.py; rm -rf "/Users/brihopki/.ansible/tmp/ansible-tmp-1483965965.23-176363209450610/" > /dev/null 2>&1 && sleep 0'
fatal: [ucspe]: FAILED! => {
"changed": false,
"failed": true,
"invocation": {
"module_args": {
"handle": "{'_UcsHandle__commit_buf': {}, '_UcsSession__domains': 'org-root', '_UcsSession__refresh_period': 600, '_UcsSession__name': '', '_UcsSession__evt_channel': 'noencssl', '_UcsSession__uri': 'https://14.17.106.164:443', 'py/object': 'ucsmsdk.ucshandle.UcsHandle', '_UcsSession__ip': '14.17.106.164', '_UcsSession__priv': 'aaa,admin,ext-lan-config,ext-lan-policy,ext-lan-qos,ext-lan-security,ext-san-config,ext-san-policy,ext-san-security,fault,operations,pod-config,pod-policy,pod-qos,pod-security,read-only', '_UcsSession__last_update_time': 'Mon Jan 9 07:46:04 2017', '_UcsHandle__commit_buf_tagged': {}, '_UcsSession__virtual_ipv4_address': '14.17.106.164', '_UcsSession__force': False, '_UcsHandle__threaded': False, '_UcsSession__ucs': 'UCSPE-14-17-106-164', '_UcsSession__version': {'py/object': 'ucsmsdk.ucscoremeta.UcsVersion', '_UcsVersion__major': '3', '_UcsVersion__patch': 'c', '_UcsVersion__mr': '2', '_UcsVersion__version': '3.0(2c)', '_UcsVersion__minor': '0'}, '_UcsSession__dump_xml': False, '_UcsSession__channel': 'noencssl', '_UcsSession__session_id': '', '_UcsSession__redirect': False, '_UcsSession__cookie': '1483965469/94631f41-341b-402c-827d-12b24e7707af', '_UcsSession__proxy': None, '_UcsSession__refresh_timer': None, '_UcsSession__password': 'ucspe', '_UcsSession__driver': {'py/object': 'ucsmsdk.ucsdriver.UcsDriver', '_UcsDriver__handlers': [{'py/type': 'ucsmsdk.ucsdriver.SmartRedirectHandler'}, {'py/type': 'ucsmsdk.ucsdriver.TLS1Handler'}], '_UcsDriver__proxy': None, '_UcsDriver__redirect_uri': None, '_UcsDriver__headers': {}}, '_UcsSession__username': 'ucspe'}"
},
"module_name": "ucs_logout"
},
"msg": "'str' object has no attribute 'logout'"
}
to retry, use: --limit @/Users/brihopki/ansible-ucs/callhome.retry
PLAY RECAP *********************************************************************
ucspe : ok=1 changed=0 unreachable=0 failed=1
The current code in the logout script is this:
#!/usr/bin/python
# -*- mode: python -*-
from ucsmsdk.ucshandle import UcsHandle
import json
import jsonpickle
def ucs_logout(module):
handle = module.params.get('handle')
results = {}
ucs_handle = handle
try:
ucs_handle.logout()
results['logged_out'] = True
except Exception as e:
#module.fail_json(msg="logout failed")
module.fail_json(msg = str(e))
return results
def main():
module = AnsibleModule(
argument_spec = dict(
handle = dict(required=True)
)
)
results = ucs_logout(module)
module.exit_json(**results)
from ansible.module_utils.basic import *
if __name__ == '__main__':
main()