Python web services (SOAP) with Suds module help

#!/usr/bin/python

import logging
import suds
from suds.wsse import *
import sys
import readline

logging.getLogger("suds.client").setLevel(logging.CRITICAL)
url = "http://firescopetest:8048/services/FireScopeConfigurationWebService/v1?wsdl"
token = UsernameToken("webservices", "password")
security = Security()
security.tokens.append(token)

client = suds.client.Client(url)
client.set_options(wsse = security)

def ci():

        ci = raw_input("Enter your CI name: ")
        ip = raw_input("Enter the IP address of your CI: ")
        ci = ci.strip()
        ip = ip.strip()
        response = client.service.createConfigurationItems(ci, "MONITOR", True, ip)
        print "Done!"


def template():

        template = raw_input("Enter your template name: ")
        ci = raw_input("Enter your CI name: ")
        template = template.strip()
        ci = ci.strip()
        response = client.service.linkTemplate(template, ci, "CREATE_OR_UPDATE")
        print "Done!"


print "What would you like to do
1. Create a new CI?
2. Link a CI to Template?"

answer = raw_input()

if answer == "1":
    ci()
elif answer == "2":
    template()
else:
    print "Wrong answer try again"


I am creating a short script to automate creation in our monitoring platform Firescope.

In this script i want to be able to create some variables with user input and use them in the suds client service. Does anybody have experience with python and suds. The variables appear not be passing through correctly even after being converted to strings with strip. Its only the first function ci that is not working the template function is working fine. So the variables are being passed through there. But the IP variable in the first function is number this could be causing problems…? Im no web services expert this is my first time using them.

PDF version of Firescope webservices - Linky

Any help with this would be great.

Thanks
William

If anybody is interested i got this working. But i went way off on a tangent while doing it! I started using Qt and built a tiny little GUI for adding CI’s into our monitoring platform. If you want to see the script then head over to my github i have it there.

https://github.com/william20111/firescopeweb

You can see the script there. I sorted the variables in suds and set it up on a simple little form. I actually plan to continue to expand the GUI as Firescope add more features to their web services. I will hopefully add the ability to add templates onto the CI’s when they are created. Currently its very limited. Really all that is useful just now is the ability to create CI’s and apply templates. Hopefully this improves in the future.

Thanks
William