cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
838
Views
10
Helpful
2
Replies

Create Tags using Cobra on APIC 2.1(2e)

Dirk Feldhaus
Level 1
Level 1

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

1 Accepted Solution

Accepted Solutions

Sig Nine
Level 1
Level 1

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?

acicobra-2.2_1o-py2.7.egg (/cobra/mit/access.py", line 56, in commit):

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)

GitHub (line 80, in commit):

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)

View solution in original post

2 Replies 2

Sig Nine
Level 1
Level 1

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?

acicobra-2.2_1o-py2.7.egg (/cobra/mit/access.py", line 56, in commit):

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)

GitHub (line 80, in commit):

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)

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

Save 25% on Day-2 Operations Add-On License