Skip to content

NSCSPolicy .get method fails #91

@ryaner

Description

@ryaner

The internal name is 'policyname' and this causes .get to fail on a key error.

Test code

nspolicy= NSCSPolicy()
nspolicy.set_policyname(rule_name)
policy = NSCSPolicy.get(nitro, nspolicy)
Traceback (most recent call last):
  File "./nstest.py", line 10, in <module>
    policy = NSCSPolicy.get(nitro, nspolicy)
  File "/usr/local/lib/python2.7/dist-packages/nsnitro/nsresources/nscspolicy.py", line 195, in get
    __cspolicy.get_resource(nitro)
  File "/usr/local/lib/python2.7/dist-packages/nsnitro/nsresources/nsbaseresource.py", line 70, in get_resource
    object_name if object_name else self.options['name'])
KeyError: 'name'

Changing the internal name in nscspolicy.py to 'name' to match other classes won't work as .add will then fail with an invalid argument error.

  File "nstest2.py", line 436, in add_cs_policy
    NSCSPolicy.add(self.nitro, nspolicy)
  File "/usr/local/lib/python2.7/dist-packages/nsnitro/nsresources/nscspolicy.py", line 220, in add
    return __cspolicy.add_resource(nitro)
  File "/usr/local/lib/python2.7/dist-packages/nsnitro/nsresources/nsbaseresource.py", line 81, in add_resource
    response = nitro.post(self.get_payload())
  File "/usr/local/lib/python2.7/dist-packages/nsnitro/nsnitro.py", line 82, in post
    return NSNitroResponse(response.read())
  File "/usr/local/lib/python2.7/dist-packages/nsnitro/nsutil.py", line 21, in __init__
    self.__parse_response()
  File "/usr/local/lib/python2.7/dist-packages/nsnitro/nsutil.py", line 35, in __parse_response
    self._raise_exception()
  File "/usr/local/lib/python2.7/dist-packages/nsnitro/nsutil.py", line 51, in _raise_exception
    raise exception_class(self.message, self.errorcode)
nsnitro.nsexceptions.nsexceptions.NSNitroNserrInval: u'Invalid argument [name]'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions