Example #1
0
def createBGPV4Neighbor(child,
                        IntfRef,
                        NeighborAddress,
                        BfdEnable=False,
                        PeerGroup='',
                        MultiHopTTL=0,
                        LocalAS='',
                        KeepaliveTime=0,
                        AddPathsRx=False,
                        UpdateSource='',
                        RouteReflectorClient=False,
                        MaxPrefixesRestartTimer=0,
                        Description='',
                        MultiHopEnable=False,
                        AuthPassword='',
                        RouteReflectorClusterId=0,
                        AdjRIBOutFilter='',
                        MaxPrefixesDisconnect=False,
                        PeerAS='',
                        AddPathsMaxTx=0,
                        AdjRIBInFilter='',
                        MaxPrefixes=0,
                        MaxPrefixesThresholdPct=80,
                        BfdSessionParam='default',
                        NextHopSelf=False,
                        Disabled=False,
                        HoldTime=0,
                        ConnectRetryTime=0):
    exe = Execute()
    config = """curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"PeerAS":"%s", "NeighborAddress":"%s", "IfIndex":0,"RouteReflectorClusterId":0, "MultiHopTTL":0,"ConnectRetryTime":60,"HoldTime":180,"KeepaliveTime":60,"AddPathsMaxTx":0}' 'http://localhost:8080/public/v1/config/BGPv4Neighbor'""" % (
        PeerAS, NeighborAddress)
    print 'command sent'
    exe.executeCmd(child, config)
    return child
Example #2
0
def BGPglobal(child, AS_Num, RouterId):

    exe = Execute()
    config = """curl -X PATCH "Content-Type: application/json" -d '{"ASNum":"%s","RouterId":"%s"}' http://localhost:8080/public/v1/config/BGPGlobal""" % (
        AS_Num, RouterId)
    exe.executeCmd(child, config)
    print "Global BGP Configuration Done"
    return child
Example #3
0
def configureIP(RouterInst,Interface,IP_address):
	#This method will configure IP address
		flushBuffer(1,RouterInst)
		RouterInst.sendcontrol('m')
		RouterInst.expect(['/w+@.*/#',pexpect.EOF,pexpect.TIMEOUT],timeout=3)
		config = """curl -H "Content-Type: application/json" -d '{"IpAddr": "%s", "IntfRef": "%s"}' http://localhost:8080/public/v1/config/IPv4Intf""" % (IP_address,Interface)
		Exe = Execute()
		Exe.executeCmd(RouterInst,config)
		return RouterInst
Example #4
0
class S(BaseHTTPRequestHandler):
    def initialize(self):
        self.exec = Execute()

    def _set_response(self):
        self.send_response(200)
        self.send_header('Content-type', 'application/json')
        self.end_headers()

    def do_GET(self):
        logging.info("GET request,\nPath: %s\nHeaders:\n%s\n", str(self.path),
                     str(self.headers))
        self._set_response()
        self.wfile.write("GET request for {}".format(
            self.path).encode('utf-8'))

    def do_POST(self):
        try:
            content_length = int(self.headers['Content-Length'])
            query = self.rfile.read(content_length)
            decoded_query = query.decode('utf-8')
            houses = self.exec.execute(decoded_query)
            if not houses:
                houses = "no houses returned"
            self._set_response()
            houses_encode = str(houses).encode('utf-8')
            self.wfile.write(houses_encode)
        except Exception as ex:
            self._set_response()
            self.wfile.write("error in getting houses 1".encode('utf-8'),
                             str(ex))
Example #5
0
def test():
    isKeep = True
    dstFileName = None

    argsLen = len(sys.argv)
    if argsLen < 2:
        sys.exit()

    if argsLen >= 3:
        if sys.argv[2].startswith('-nk'):
            isKeep = False
        if argsLen > 3:
            dstFileName = sys.argv[3]

    srcFile = File(sys.argv[1], isKeep, dstFileName)
    srcFile.parse()

    exe = Execute(srcFile.dstFileName)
    exe.run()
Example #6
0
    def __init__(self, data):
        """
    Initialise the resource
    """
        Execute.__init__(self)
        if isinstance(data, OvtDB):
            self.ovtDB = data
            return

        if data == None:
            return

        (_testrun, identifier, data) = data
        self.testrun = _testrun
        self.logdir = None
        if 'versionedactionid' in identifier:
            self.userclaimid = None
            self.versionedactionid = identifier['versionedactionid']
        else:
            self.versionedactionid = None
            self.userclaimid = identifier['userclaimid']
            if 'logdir' in identifier:
                self.logdir = identifier['logdir']

        # Accumulate errors so that they can be retrieved if required
        self.errors = ""

        self.proccount = 0
        self.archiveMode = False

        self.attributes = data['attributes']
        self.requestedattributes = data['requested']
        self.name = data['name']
        self.hostname = data['hostname']
        self.resourceid = data['resourceid']
        self.type = data['type']
        self.typeid = data['typeid']
        self.localpath = None
        self.logpath = None
        self.umask = 007
Example #7
0
    def run(self, flag, inputFile=''):
        self.executableFileName = ''
        self.command = self.generateCommand(
            flag
        )  # the compiler will be selected according to supplied source file
        if self.command != 'Command not found!':
            exe = './' + self.executableFileName
            if inputFile:
                exe = exe + '< ' + inputFile
            e = Execute().run(exe)
            return [e]

            #	End of Part
        else:
            return ['Command not found!']
Example #8
0
class Action(Execute):
    """
  Abstract class used to implement all actions. The minimum that a derived
  class must implement is the :py:meth:`~.Action.run` method. The
  :py:meth:`~.Action.archive` method should be overridden when derived
  files are stored outside the working area. The
  :py:meth:`~.Action.formatResults` method should be overridden for
  customised results formatting in email notifications.
  """

    debug_verbose = 0

    def __init__(self, (_testrun, _versionedactionid, _testrunactionid,
                        actionid)):
        """
    Set up the environment for running this action for the given testrun
    """
        Execute.__init__(self)
        self.testrun = _testrun
        self.versionedactionid = _versionedactionid
        self.testrunactionid = _testrunactionid
        self.localpath = None
        self.logpath = None
        self.logtestrunpath = None
        self.sharedpath = None
        self.sharedtestrunpath = None
        self.actionid = actionid
        self.concurrency = 1
        self.multiresults = {}

        # Grab the config for this action
        self.config = self.testrun.getConfig(self.versionedactionid)
        # Get the version string
        self.version = self.testrun.getVersion(self.versionedactionid)
        # Find out if this is a testsuite
        self.testsuiteid = self.testrun.getTestsuite(actionid)
        self.submissionid = None
Example #9
0
 def initialize(self):
     self.exec = Execute()
Example #10
0
def checkBGPRoute(child):
    exe = Execute()
    config = """curl -i -H "Content-Type: application/json" "http://localhost:8080/public/v1/state/BGPv4Routes"""
    exe.executeCmd(child, config)
    print " BGP Route Set in routing table"
    return
Example #11
0
def checkIPV4Route(child):
    exe = Execute()
    config = """curl  -H "Accept: application/json" "http://localhost:8080/public/v1/state/IPv4Routes" | python -m json.tool"""
    Execute.executeCmd(child, config)
    print "Route Set in IPv4 table"
    return
Example #12
0
def checkAllBGPNeighbors(child):
    exe = Execute()
    config = """curl -H "Accept: application/json" "http://localhost:8080/public/v1/state/BGPv4Neighbors" | python -m json.tool"""
    exe.executeCmd(child, config)
    print "BGP neighbor set "
    return child