Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NSCSPolicy .get method fails #91

Open
ryaner opened this issue Jun 15, 2015 · 3 comments
Open

NSCSPolicy .get method fails #91

ryaner opened this issue Jun 15, 2015 · 3 comments

Comments

@ryaner
Copy link

ryaner commented Jun 15, 2015

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]'
@favoretti
Copy link
Contributor

Hey,

Sorry for taking this long. Which NS version is it? Also, you're welcome to submit a PR for this one, or otherwise pull the latest version, I believe we might have fixed that already.

V

@marcosartori
Copy link
Contributor

so its probably cos I am a little thick so bear with me.

I must say I have no ability with python at all, but I can cut and paste
stuff a lot until it works!!!

so what I want is to use nsnitrycmd to add a server then add a service
group and lbvserver then bind them all together, I can't see thats
implemented, so I can submit a pull on the add server bit (as I have done
that already)

or you can tell me I am an idiot and its already there and you do it like
this (again using nsnitrocmd.py)

thanks for getting back to me btw

On Fri, Oct 9, 2015 at 12:16 PM, Vladimir Lazarenko <
notifications@github.com> wrote:

Hey,

Sorry for taking this long. Which NS version is it? Also, you're welcome
to submit a PR for this one, or otherwise pull the latest version, I
believe we might have fixed that already.

V


Reply to this email directly or view it on GitHub
https://github.com/favoretti/nsnitro/issues/91#issuecomment-146836686.

@marcosartori
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants