Deleting serviceGroups
Opened this issue · 12 comments
I wrote this piece of code to delete an existing serviceGroup:
def delete_resource(self):
try:
nsb = NSBaseResource()
nsb.resourcetype = 'serviceGroup'
nsb.set_action('delete')
nsb.set_options({'name':'Test-SG-192.168.8.140'})
nsb.delete_resource(self.nitro)
print "resource deleted"
print nsb.get_name() + ":" + nsb.get_state()
except nsnitro.nsutil.NSNitroError,e:
print e.message
it throws me an error saying
"Invalid argument [name]
"
i noticed that NSBaseResource.delete_resource calls delete_get_args and appends the options. The NS 9.3 documentation doesn't mention args at all... is it there for 9.2 compatibility?? it fails on NS 9.3 with error Invalid argument..
i guess it's because serviceGroup does not classify as BaseResource and needs to be treated differently??
Yep, serviceGroup will need to be implemented as a standalone object, same as service, etc.
Man.. that sounds ugly/clumsy..... I really need to find time to understand the complete nitro api and see if i can simplify this..
I took some time to dive into the API on the side of netscaler itself and java code, as I didn't understand why it was this clumsy in the first place. The reason is very simple: API on the side of the LB self doesn't have virtually any error checking :) It's all guarded/done in the code. Considering that our Python API is not officially supported, I guess this will be the best course of action - just replicate, say, java side of things. Otherwise should they change something again, time spent into debugging how to fix it just won't be worth it :)
I just added NSServiceGroup class, can you test if it works for you?
And this particular error came up because name attribute is called differently in the API, it's called 'servicegroupname'. But I've created a complete wrapper for you, without documenting getters/setters just yet. I'll first read up on properties in python, before typing lots of code for nothing, maybe I'll just refactor whole thing altogether.
Hi, yeah the create servicegroup thing works fine... but delete doesn't.. i patched and put in a pull request
I figured out why it doesn't work. I'll merge your pull request to get tests running and then refactor stuff to work properly.
They have a custom get_object_name() in each object, that's why it works in java, for instance.
Why it doesn't work is indeed because name is no always 'name', but as in case of servicegroup - 'servicegroupname'.
Ok, I just pushed a commit that fixes this issue in a semi-proper way :)
Yep.. it works.. just went through the changes....still i think NetScaler must man up and provide more standard apis :-)
Well, we are getting there, right? :) Basically that's why I said in my readme, I'll add those classes on a need-to-have basis :) Otherwise there are about 770 config and 150 stat classes... :P
Oh.. you work for NetScaler?? I had no idea..:-).. By the way i am trying to create servicegroupbindings and lbvserver bindings today....
You have lbvserver bindings already, only not to the servicegroup, but to a service.
And no, I don't work for Netscaler, I meant that you and me are on the right track for Python library :) I work for eBay :)