04-14-2017 08:31 AM - edited 03-01-2019 05:12 AM
Hello,
I'm having some troubling creating and adding Tags to MO's.
I'm following the example given on "http://cobra.readthedocs.io/en/latest/api-ref/request.html#tag-request" and get this error message:
File "./tags_request_test.py", line 17, in <module>
modir.commit(tags)
File "/home/user/anaconda2/lib/python2.7/site-packages/acicobra-2.1_2e-py2.7.egg/cobra/mit/access.py", line 56, in commit
if configObject.getRootMo() is None:
AttributeError: 'TagsRequest' object has no attribute 'getRootMo'
Can somebody help me out here?
And another note, remotely related to this:
The "data" attribute for TagsRequest seems to be returning empty data and not the JSON data for the request.
http://cobra.readthedocs.io/en/latest/_modules/cobra/mit/request.html#TagsRequest
Solved! Go to Solution.
04-16-2017 06:51 AM
Hi, Dirk Feldhaus.
I get the same error. There is a difference between acicobra-2.x_xx-py2.7.egg and GitHub. The source code with egg has 'if configObject.getRootMo() is none', but the code on GitHub does not. I think it is the cause.
By the way, can you use acitoolkit instead of cobra?
def commit(self, configObject, sync_wait_timeout=None):
"""
Short-form commit operation for a configRequest
"""
if configObject.getRootMo() is None:
raise CommitError(0, "No mos in config request")
# If a sync_wait_timeout is specified, then we call the post_sync_wait
# method of the accessImpl, otherwise call post method
if sync_wait_timeout:
return self._accessImpl.post_sync_wait(configObject, timeout=sync_wait_timeout)
else:
return self._accessImpl.post(configObject)
def commit(self, configObject):
"""Commit operation for a request object.
Commit a change on the APIC or fabric node.
Args:
configObject (cobra.mit.request.AbstractRequest): The configuration
request to commit
Returns:
str: The response as a string
Raises:
CommitError: If no MOs have been added to the config request
"""
try:
rsp = self._session.post(configObject)
return self.__parseResponse(rsp)
except RestError as ex:
self.__parseError(ex.reason, CommitError, ex.httpCode)
04-16-2017 06:51 AM
Hi, Dirk Feldhaus.
I get the same error. There is a difference between acicobra-2.x_xx-py2.7.egg and GitHub. The source code with egg has 'if configObject.getRootMo() is none', but the code on GitHub does not. I think it is the cause.
By the way, can you use acitoolkit instead of cobra?
def commit(self, configObject, sync_wait_timeout=None):
"""
Short-form commit operation for a configRequest
"""
if configObject.getRootMo() is None:
raise CommitError(0, "No mos in config request")
# If a sync_wait_timeout is specified, then we call the post_sync_wait
# method of the accessImpl, otherwise call post method
if sync_wait_timeout:
return self._accessImpl.post_sync_wait(configObject, timeout=sync_wait_timeout)
else:
return self._accessImpl.post(configObject)
def commit(self, configObject):
"""Commit operation for a request object.
Commit a change on the APIC or fabric node.
Args:
configObject (cobra.mit.request.AbstractRequest): The configuration
request to commit
Returns:
str: The response as a string
Raises:
CommitError: If no MOs have been added to the config request
"""
try:
rsp = self._session.post(configObject)
return self.__parseResponse(rsp)
except RestError as ex:
self.__parseError(ex.reason, CommitError, ex.httpCode)
04-21-2017 05:22 AM
Hello Sig Nine,
thanks for the reply. We recently upgraded our fabric to an newer version and I hoped that it is working better now, but unfortunately the same error came up again :-)
I haven't used acitoolkit so far but I'll take a look at it. I thought the SDK will give me more flexibility but probably the toolkit has all functions I need at the moment.
Dirk
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide