Sample: create a change request
The following example shows how to create a change request in Python version 2.6.
Note: Before using this example, replace the username, password, and ticket source values with your own values.
You may have to remove some manual line breaks.
import ssl
from suds.client import Client
AlgoSecServer=10.20.6.88'
AlgoSecUser='user'
AlgoSecPasswd='password'
TicketSource='125.125.22.11'
TicketDest='10.0.0.0/8'
# Action - 0 for drop, 1 for allow
TicketAction='0'
TicketService='*'
ActionStr = 'Allow'
ActionStr = 'Allow' if TicketAction == '1' else 'Drop'
# bypass ssl verification - needed only if using self-signed certificates
(demo machine, etc.)
#ssl._create_default_https_context = ssl._create_unverified_context
# ALGOSEC AFF WSDL is availble here 'https://AFFIP/WebServices/FireFlow.wsdl'
AFF_WSDL = 'https://%s/WebServices/FireFlow.wsdl' % AlgoSecServer
# Setup client
client = Client(AFF_WSDL)
try:
# Authenticate
authenticate = client.service.authenticate(username=AlgoSecUser,
password=AlgoSecPasswd)
# Create ticket and traffic lines objects
print "Creating change request with source <%s> destination <%s> service <%s> and
action <%s>" % (TicketSource, TicketDest, TicketService, ActionStr)
ticket = client.factory.create('ticket')
trafficLine = client.factory.create('trafficLine')
src = client.factory.create('trafficAddress')
src.address=TicketSource
trafficLine.trafficSource.append(src)
dst =client.factory.create('trafficAddress')
dst = client.factory.create('trafficAddress')
dst.address=TicketDest
trafficLine.trafficDestination.append(dst)
srv = client.factory.create('trafficService')
srv.service=TicketService
trafficLine.trafficService.append(srv)
trafficLine.action=TicketAction
ticket.trafficLines.append(trafficLine)
ticket.description='Demo Ticket'
ticket.requestor='[email protected]'
ticket.subject='%s Traffic from %s to %s' % (ActionStr, TicketSource, TicketDest)
except:
print "A problem occured"
# Actually create the ticket
try:
ticket_added = client.service.createTicket(sessionId=authenticate.sessionId,
ticket=ticket)
except:
print ticket_added.message
# Print success message and ticket URL
print ticket_added.message
print ticket_added.ticketDisplayURL