Example #1
0
def create_emu():
    '''
    Create emulation by POSTing xml with required parameters
    '''

    response.set_header('Content-Type', 'application/vnd.bonfire+xml')
    response.set_header('Accept', '*/*')
    response.set_header('Allow', 'GET, HEAD, POST')

    #http://10.55.164.232:8050/emulations

    xml_stream = request.files.data
    xml_stream_body = request.body.read()
    xml_stream_body = urllib.unquote(xml_stream_body).decode('utf8')
    xml_stream_body = xml_stream_body.replace(unicode("+"), unicode(" "))
    searchString = "&runifOverloaded="
    searchIndex = xml_stream_body.rfind(searchString)
    runIfOverloaded = False
    if (searchIndex > 0):
        runIfOverloadedChar = xml_stream_body[searchIndex + len(searchString)]
        xml_stream_body = xml_stream_body[4:searchIndex]
        if (runIfOverloadedChar.upper() == "Y"):
            runIfOverloaded = True

    if xml_stream:
        #print "File data detected:\n",xml_stream
        return xml_stream
        try:
            (emulationName, emulationType, emulationLog, emulationLogFrequency,
             resourceTypeEmulation, startTimeEmu, stopTimeEmu, distroList,
             xmlData, MQproducerValues) = XmlParser.xmlFileParser(
                 xml_stream, runIfOverloaded)
            if ("Re-send with force (-f)" in distroList[0]):
                response.status = 500
                ET.register_namespace("test", "http://127.0.0.1/cocoma")
                emuError = ET.Element('Force-Errors')
                emuError = ET.Element('Force-Errors', {
                    'xmlns': 'http://127.0.0.1/cocoma',
                    'href': '/emulations/'
                })
                for forceError in distroList:
                    forceErrorXML = ET.SubElement(emuError, "error")
                    forceErrorXML.text = str(forceError)
                return prettify(emuError)
        except Exception, e:
            print e
            if str(e).find("no attribute 'getElementsByTagName'"
                           ) > 0:  #Return if supplied XML is bad
                e = "Supplied xml is malformed, check thoroughly for errors"
            response.status = 500
            emuError = ET.Element('error')
            emuError.text = str(e)
            return prettify(emuError)
Example #2
0
def get_logs_list():
    """
    Show "emulation" and "system"
    """
    response.set_header('Content-Type', 'application/vnd.bonfire+xml')
    response.set_header('Accept', '*/*')
    response.set_header('Allow', 'GET, HEAD')
    ET.register_namespace("test", "http://127.0.0.1/cocoma")

    logs = ET.Element('logs', {'href': '/logs'})
    lk = ET.SubElement(
        logs, 'link', {
            'rel': 'emulations',
            'href': '/logs/emulations',
            'type': 'application/vnd.bonfire+xml'
        })
    lk = ET.SubElement(
        logs, 'link', {
            'rel': 'system',
            'href': '/logs/system',
            'type': 'application/vnd.bonfire+xml'
        })
    #lk = ET.SubElement(logs, 'link', {'rel':'system', 'href':'/', 'type':'application/vnd.bonfire+xml'})

    return prettify(logs)
Example #3
0
def show_all_results():
    '''
    Show summary of emulations results
    '''
    #curl -k -i http://10.55.164.232:8050/distributions/linear
    
    ET.register_namespace("test", "http://127.0.0.1/cocoma")
    response.set_header('Content-Type', 'application/vnd.bonfire+xml')
    response.set_header('Accept', '*/*')
    response.set_header('Allow', 'GET, HEAD') 
    emuList=Library.getEmulationList("all")
    
    #root element
    resultsCollection = ET.Element('collection', { 'xmlns':'http://127.0.0.1/cocoma','href':'/results'})
    items =ET.SubElement(resultsCollection,'items', { 'offset':'0','total':str(len(emuList))})
        
        
    for elem in emuList :
        failedRunsInfo=elem["failedRunsInfo"]
        
        
        #print "---->\nID: "+str(elem["ID"])+"\nName: "+str(elem["Name"])+"\nState: "+str(elem["State"])+"\nTotal Runs: "+str(elem["runsTotal"])+"\nExecuted Runs: "+str(elem["runsExecuted"])+"\nFailed Runs: "+str(len(failedRunsInfo))
        
        emuResults = ET.SubElement(items,'results', { 'href':'/results/'+str(elem["Name"]),'failedRuns':str(len(failedRunsInfo)),'name':str(elem["Name"]),'state':str(elem["State"])})


        
    
    #<link href="/" rel="parent" type="application/vnd.cocoma+xml"/>
    lk = ET.SubElement(resultsCollection, 'link', {'rel':'parent', 'href':'/', 'type':'application/vnd.bonfire+xml'})
    
    

    return prettify(resultsCollection)   
Example #4
0
def get_tests():
    '''
    List all available tests in the "/tests" folder
    '''
    
    ET.register_namespace("test", "http://127.0.0.1/cocoma")
    response.set_header('Content-Type', 'application/vnd.bonfire+xml')
    response.set_header('Accept', '*/*')
    response.set_header('Allow', 'GET, HEAD, POST')     
    
    testsList=Library.listTests("all")
    #print "testsList",testsList
    '''
    XML namespaces are used for providing uniquely named elements and attributes in an XML document.
    '''

    #building the XML we will return
    tests = ET.Element('collection', { 'xmlns':'http://127.0.0.1/cocoma','href':'/tests'})
    #<items offset="0" total="2">
    items =ET.SubElement(tests,'items', { 'offset':'0','total':str(len(testsList))})
    
    #<distribution href="/emulations/1" name="Emu1"/>
    
    for elem in testsList :
        test = ET.SubElement(items,'test', { 'href':'/tests/'+str(elem),'name':str(elem)})
        
        
    
    #<link href="/" rel="parent" type="application/vnd.cocoma+xml"/>
    lk = ET.SubElement(tests, 'link', {'rel':'parent', 'href':'/', 'type':'application/vnd.bonfire+xml'})
    
    
    

    return prettify(tests)
Example #5
0
def show_test(name=""):
    '''
    List particular test by name in the "/tests" folder
    '''
    #curl -k -i http://10.55.164.232:8050/distributions/linear
    
    ET.register_namespace("test", "http://127.0.0.1/cocoma")
    response.set_header('Content-Type', 'application/vnd.bonfire+xml')
    response.set_header('Accept', '*/*')
    response.set_header('Allow', 'GET, HEAD') 
    
    try:
        filename=open(HOMEPATH+"/tests/"+name,'r')
        #print "filename to show: ",filename
        xmlFileContent = filename.read()
        filename.close()
        #xmlFileContent=XmlParser.xmlReader(filename)
        
        #DistributionManager.listTests(name)
        
        testXml = ET.Element('test', { 'xmlns':'http://127.0.0.1/cocoma','href':'/tests/'+str(name)})
        
        #xmlContent=ET.SubElement(testXml,)
        
    
        lk0 = ET.SubElement(testXml, 'link', {'rel':'parent', 'href':'/', 'type':'application/vnd.bonfire+xml'})
        #<link href="/emulations" rel="parent" type="application/vnd.cocoma+xml"/>
        lk0 = ET.SubElement(testXml, 'link', {'rel':'parent', 'href':'/distributions', 'type':'application/vnd.bonfire+xml'})
    
    
        return prettify(ET.fromstring(xmlFileContent))
    
    except Exception, e:
        response.status = 404
        return "<error>"+str(e)+"</error>"
Example #6
0
def get_emulators():
    '''
    Display list of emulators
    '''
    ET.register_namespace("test", "http://127.0.0.1/cocoma")
    response.set_header('Content-Type', 'application/vnd.bonfire+xml')
    response.set_header('Accept', '*/*')
    response.set_header('Allow', 'GET, HEAD')     
    
    emuList=Library.listEmulators("all")
    #print "emulist",emuList
    '''
    XML namespaces are used for providing uniquely named elements and attributes in an XML document.
    '''
     
    #building the XML we will return
    emulators = ET.Element('collection', { 'xmlns':'http://127.0.0.1/cocoma','href':'/emulators'})
    #<items offset="0" total="2">
    items =ET.SubElement(emulators,'items', { 'offset':'0','total':str(len(emuList))})
    
    #<emulator href="/emulations/1" name="Emu1"/>
    
    for elem in emuList :
        emulator = ET.SubElement(items,'emulator', { 'href':'/emulators/'+str(elem),'name':str(elem)})
        
    #<link href="/" rel="parent" type="application/vnd.cocoma+xml"/>
    lk = ET.SubElement(emulators, 'link', {'rel':'parent', 'href':'/', 'type':'application/vnd.bonfire+xml'})
    
  
    return prettify(emulators)
Example #7
0
    def jobsToXML(jobList, currentJobList,
                  totalJobs):  #Converts job lists to xml foramt
        ET.register_namespace("jobs", "http://127.0.0.1/cocoma")
        response.set_header('Content-Type', 'application/vnd.bonfire+xml')
        response.set_header('Accept', '*/*')
        response.set_header('Allow', 'GET')

        jobXmlRoot = ET.Element('collection', {
            'xmlns': 'http://127.0.0.1/cocoma',
            'href': '/jobs'
        })
        jobCollection = ET.SubElement(jobXmlRoot, 'items', {
            'offset': '0',
            'total': str(totalJobs)
        })
        for job in jobList:
            jobXML = ET.SubElement(jobCollection, "Job")
            jobXML.text = job
        if len(currentJobList) > 0:
            for currentJob in currentJobList:
                currentJobXML = ET.SubElement(jobCollection,
                                              "currentlyRunningJob")
                currentJobXML.text = str(currentJob)
        lk = ET.SubElement(jobXmlRoot, 'link', {
            'rel': 'parent',
            'href': '/',
            'type': 'application/vnd.bonfire+xml'
        })
        return prettify(jobXmlRoot)
Example #8
0
def get_emu_logs_list():
 
    ET.register_namespace("emulationLog", "http://127.0.0.1/cocoma")
    response.set_header('Content-Type', 'application/vnd.bonfire+xml')
    response.set_header('Accept', '*/*')
    response.set_header('Allow', 'GET, HEAD')     
    
    os.chdir(HOMEPATH+"/logs/")
    fileLogList = glob.glob("*-res_*-*-*:*:*.csv")
    '''
    XML namespaces are used for providing uniquely named elements and attributes in an XML document. 
    '''

    #building the XML we will return
    emulationLog = ET.Element('collection', { 'xmlns':'http://127.0.0.1/cocoma','href':'/logs/emulations'})
    #<items offset="0" total="2">
    items =ET.SubElement(emulationLog,'items', { 'offset':'0','total':str(len(fileLogList))})
    
    #<distribution href="/emulations/1" name="Emu1"/>
    print fileLogList
    for elem in fileLogList :
        test = ET.SubElement(items,'emulationLog', { 'href':'/logs/emulations/'+str(elem)[:-28],'name':str(elem)[:-28]})
        
        
    
    #<link href="/" rel="parent" type="application/vnd.cocoma+xml"/>
    lk = ET.SubElement(emulationLog, 'link', {'rel':'parent', 'href':'/', 'type':'application/vnd.bonfire+xml'})
    lk = ET.SubElement(emulationLog, 'link', {'rel':'parent', 'href':'/logs', 'type':'application/vnd.bonfire+xml'})
    
    
    

    return prettify(emulationLog)
Example #9
0
def create_emu():
    '''
    Create emulation by POSTing xml with required parameters
    '''
    
    response.set_header('Content-Type', 'application/vnd.bonfire+xml')
    response.set_header('Accept', '*/*')
    response.set_header('Allow', 'GET, HEAD, POST')
    
    #http://10.55.164.232:8050/emulations
    
    xml_stream =request.files.data
    xml_stream_body =request.body.read()
    xml_stream_body=urllib.unquote(xml_stream_body).decode('utf8')
    xml_stream_body = xml_stream_body.replace(unicode("+"), unicode(" "))
    searchString = "&runifOverloaded="
    searchIndex = xml_stream_body.rfind(searchString)
    runIfOverloaded = False
    if (searchIndex > 0):
        runIfOverloadedChar = xml_stream_body[searchIndex+len(searchString)]
        xml_stream_body = xml_stream_body [4:searchIndex]
        if (runIfOverloadedChar.upper() == "Y"):
            runIfOverloaded = True

    if xml_stream:
        #print "File data detected:\n",xml_stream
        return xml_stream
        try:
            (emulationName,emulationType,emulationLog,emulationLogFrequency, resourceTypeEmulation, startTimeEmu,stopTimeEmu, distroList,xmlData, MQproducerValues) = XmlParser.xmlFileParser(xml_stream, runIfOverloaded)
            if ("Re-send with force (-f)" in distroList[0]):
                response.status = 500
                ET.register_namespace("test", "http://127.0.0.1/cocoma")
                emuError = ET.Element('Force-Errors')
                emuError = ET.Element('Force-Errors', { 'xmlns':'http://127.0.0.1/cocoma','href':'/emulations/'})
                for forceError in distroList:
                    forceErrorXML = ET.SubElement(emuError, "error")
                    forceErrorXML.text = str(forceError)
                return prettify(emuError)
        except Exception,e:
            print e
            if str(e).find("no attribute 'getElementsByTagName'") > 0: #Return if supplied XML is bad
                e = "Supplied xml is malformed, check thoroughly for errors"
            response.status = 500
            emuError=ET.Element('error')
            emuError.text = str(e)
            return prettify(emuError)
Example #10
0
def get_root():
    '''
    Shows list of resources available at root location
    '''
    #curl -k -i http://10.55.164.232:8050/
    response.set_header('Content-Type', 'application/vnd.bonfire+xml')
    response.set_header('Accept', '*/*')
    response.set_header('Allow', 'GET, HEAD')
    ET.register_namespace("test", "http://127.0.0.1/cocoma")

    root = ET.Element('root', {'href': '/'})
    ver = ET.SubElement(root, 'version')
    ver.text = '0.1.1'
    ts = ET.SubElement(root, 'timestamp')
    ts.text = str(time.time())
    lk = ET.SubElement(
        root, 'link', {
            'rel': 'emulations',
            'href': '/emulations',
            'type': 'application/vnd.bonfire+xml'
        })
    lk = ET.SubElement(
        root, 'link', {
            'rel': 'emulators',
            'href': '/emulators',
            'type': 'application/vnd.bonfire+xml'
        })
    lk = ET.SubElement(
        root, 'link', {
            'rel': 'distributions',
            'href': '/distributions',
            'type': 'application/vnd.bonfire+xml'
        })
    lk = ET.SubElement(root, 'link', {
        'rel': 'tests',
        'href': '/tests',
        'type': 'application/vnd.bonfire+xml'
    })
    lk = ET.SubElement(
        root, 'link', {
            'rel': 'results',
            'href': '/results',
            'type': 'application/vnd.bonfire+xml'
        })
    lk = ET.SubElement(root, 'link', {
        'rel': 'logs',
        'href': '/logs',
        'type': 'application/vnd.bonfire+xml'
    })
    lk = ET.SubElement(root, 'link', {
        'rel': 'jobs',
        'href': '/jobs',
        'type': 'application/vnd.bonfire+xml'
    })

    return prettify(root)
Example #11
0
 def jobsToXML (jobList, currentJobList, totalJobs): #Converts job lists to xml foramt
     ET.register_namespace("jobs", "http://127.0.0.1/cocoma")
     response.set_header('Content-Type', 'application/vnd.bonfire+xml')
     response.set_header('Accept', '*/*')
     response.set_header('Allow', 'GET')
     
     jobXmlRoot = ET.Element('collection', { 'xmlns':'http://127.0.0.1/cocoma','href':'/jobs'})
     jobCollection = ET.SubElement(jobXmlRoot, 'items', {'offset':'0','total':str(totalJobs)})
     for job in jobList:
         jobXML = ET.SubElement(jobCollection, "Job")
         jobXML.text = job
     if len(currentJobList) > 0:
         for currentJob in currentJobList:
             currentJobXML = ET.SubElement(jobCollection, "currentlyRunningJob")
             currentJobXML.text = str(currentJob)
     lk = ET.SubElement(jobXmlRoot, 'link', {'rel':'parent', 'href':'/', 'type':'application/vnd.bonfire+xml'})
     return prettify(jobXmlRoot)
Example #12
0
def get_logs_list():
    """
    Show "emulation" and "system"
    """    
    response.set_header('Content-Type', 'application/vnd.bonfire+xml')
    response.set_header('Accept', '*/*')
    response.set_header('Allow', 'GET, HEAD') 
    ET.register_namespace("test", "http://127.0.0.1/cocoma")
    
    logs = ET.Element('logs', { 'href':'/logs'})
    lk = ET.SubElement(logs, 'link', {'rel':'emulations', 'href':'/logs/emulations', 'type':'application/vnd.bonfire+xml'})
    lk = ET.SubElement(logs, 'link', {'rel':'system', 'href':'/logs/system', 'type':'application/vnd.bonfire+xml'})
    #lk = ET.SubElement(logs, 'link', {'rel':'system', 'href':'/', 'type':'application/vnd.bonfire+xml'})

    

    return prettify(logs)
Example #13
0
def show_test(name=""):
    '''
    List particular test by name in the "/tests" folder
    '''
    #curl -k -i http://10.55.164.232:8050/distributions/linear

    ET.register_namespace("test", "http://127.0.0.1/cocoma")
    response.set_header('Content-Type', 'application/vnd.bonfire+xml')
    response.set_header('Accept', '*/*')
    response.set_header('Allow', 'GET, HEAD')

    try:
        filename = open(HOMEPATH + "/tests/" + name, 'r')
        #print "filename to show: ",filename
        xmlFileContent = filename.read()
        filename.close()
        #xmlFileContent=XmlParser.xmlReader(filename)

        #DistributionManager.listTests(name)

        testXml = ET.Element('test', {
            'xmlns': 'http://127.0.0.1/cocoma',
            'href': '/tests/' + str(name)
        })

        #xmlContent=ET.SubElement(testXml,)

        lk0 = ET.SubElement(testXml, 'link', {
            'rel': 'parent',
            'href': '/',
            'type': 'application/vnd.bonfire+xml'
        })
        #<link href="/emulations" rel="parent" type="application/vnd.cocoma+xml"/>
        lk0 = ET.SubElement(
            testXml, 'link', {
                'rel': 'parent',
                'href': '/distributions',
                'type': 'application/vnd.bonfire+xml'
            })

        return prettify(ET.fromstring(xmlFileContent))

    except Exception, e:
        response.status = 404
        return "<error>" + str(e) + "</error>"
Example #14
0
def get_emulations():
    '''
    Displays list of emulations that were created/scheduled
    '''

    response.set_header('Allow', 'GET, HEAD, POST')
    response.set_header('Accept', '*/*')
    emuList = Library.getEmulationList("all")
    response.set_header('Content-Type', 'application/vnd.bonfire+xml')
    '''
    XML namespaces are used for providing uniquely named elements and attributes in an XML document.
    '''

    ET.register_namespace("test", "http://127.0.0.1/cocoma")

    #building the XML we will return
    emulations = ET.Element('collection', {
        'xmlns': 'http://127.0.0.1/cocoma',
        'href': '/emulations'
    })
    #<items offset="0" total="2">
    items = ET.SubElement(emulations, 'items', {
        'offset': '0',
        'total': str(len(emuList))
    })

    #<emulator href="/emulations/1" name="Emu1"/>

    for elem in emuList:
        emulation = ET.SubElement(
            items, 'emulation', {
                'href': '/emulations/' + str(elem["Name"]),
                'id': str(elem["ID"]),
                'name': str(elem["Name"]),
                'state': str(elem["State"])
            })

    #<link href="/" rel="parent" type="application/vnd.cocoma+xml"/>
    lk = ET.SubElement(emulations, 'link', {
        'rel': 'parent',
        'href': '/',
        'type': 'application/vnd.bonfire+xml'
    })

    return prettify(emulations)
Example #15
0
def get_emu_logs_list():

    ET.register_namespace("emulationLog", "http://127.0.0.1/cocoma")
    response.set_header('Content-Type', 'application/vnd.bonfire+xml')
    response.set_header('Accept', '*/*')
    response.set_header('Allow', 'GET, HEAD')

    os.chdir(HOMEPATH + "/logs/")
    fileLogList = glob.glob("*-res_*-*-*:*:*.csv")
    '''
    XML namespaces are used for providing uniquely named elements and attributes in an XML document. 
    '''

    #building the XML we will return
    emulationLog = ET.Element('collection', {
        'xmlns': 'http://127.0.0.1/cocoma',
        'href': '/logs/emulations'
    })
    #<items offset="0" total="2">
    items = ET.SubElement(emulationLog, 'items', {
        'offset': '0',
        'total': str(len(fileLogList))
    })

    #<distribution href="/emulations/1" name="Emu1"/>
    print fileLogList
    for elem in fileLogList:
        test = ET.SubElement(items, 'emulationLog', {
            'href': '/logs/emulations/' + str(elem)[:-28],
            'name': str(elem)[:-28]
        })

    #<link href="/" rel="parent" type="application/vnd.cocoma+xml"/>
    lk = ET.SubElement(emulationLog, 'link', {
        'rel': 'parent',
        'href': '/',
        'type': 'application/vnd.bonfire+xml'
    })
    lk = ET.SubElement(emulationLog, 'link', {
        'rel': 'parent',
        'href': '/logs',
        'type': 'application/vnd.bonfire+xml'
    })

    return prettify(emulationLog)
Example #16
0
def get_tests():
    '''
    List all available tests in the "/tests" folder
    '''

    ET.register_namespace("test", "http://127.0.0.1/cocoma")
    response.set_header('Content-Type', 'application/vnd.bonfire+xml')
    response.set_header('Accept', '*/*')
    response.set_header('Allow', 'GET, HEAD, POST')

    testsList = Library.listTests("all")
    #print "testsList",testsList
    '''
    XML namespaces are used for providing uniquely named elements and attributes in an XML document.
    '''

    #building the XML we will return
    tests = ET.Element('collection', {
        'xmlns': 'http://127.0.0.1/cocoma',
        'href': '/tests'
    })
    #<items offset="0" total="2">
    items = ET.SubElement(tests, 'items', {
        'offset': '0',
        'total': str(len(testsList))
    })

    #<distribution href="/emulations/1" name="Emu1"/>

    for elem in testsList:
        test = ET.SubElement(items, 'test', {
            'href': '/tests/' + str(elem),
            'name': str(elem)
        })

    #<link href="/" rel="parent" type="application/vnd.cocoma+xml"/>
    lk = ET.SubElement(tests, 'link', {
        'rel': 'parent',
        'href': '/',
        'type': 'application/vnd.bonfire+xml'
    })

    return prettify(tests)
Example #17
0
def show_all_results():
    '''
    Show summary of emulations results
    '''
    #curl -k -i http://10.55.164.232:8050/distributions/linear

    ET.register_namespace("test", "http://127.0.0.1/cocoma")
    response.set_header('Content-Type', 'application/vnd.bonfire+xml')
    response.set_header('Accept', '*/*')
    response.set_header('Allow', 'GET, HEAD')
    emuList = Library.getEmulationList("all")

    #root element
    resultsCollection = ET.Element('collection', {
        'xmlns': 'http://127.0.0.1/cocoma',
        'href': '/results'
    })
    items = ET.SubElement(resultsCollection, 'items', {
        'offset': '0',
        'total': str(len(emuList))
    })

    for elem in emuList:
        failedRunsInfo = elem["failedRunsInfo"]

        #print "---->\nID: "+str(elem["ID"])+"\nName: "+str(elem["Name"])+"\nState: "+str(elem["State"])+"\nTotal Runs: "+str(elem["runsTotal"])+"\nExecuted Runs: "+str(elem["runsExecuted"])+"\nFailed Runs: "+str(len(failedRunsInfo))

        emuResults = ET.SubElement(
            items, 'results', {
                'href': '/results/' + str(elem["Name"]),
                'failedRuns': str(len(failedRunsInfo)),
                'name': str(elem["Name"]),
                'state': str(elem["State"])
            })

    #<link href="/" rel="parent" type="application/vnd.cocoma+xml"/>
    lk = ET.SubElement(resultsCollection, 'link', {
        'rel': 'parent',
        'href': '/',
        'type': 'application/vnd.bonfire+xml'
    })

    return prettify(resultsCollection)
Example #18
0
def get_root():
    '''
    Shows list of resources available at root location
    '''
    #curl -k -i http://10.55.164.232:8050/
    response.set_header('Content-Type', 'application/vnd.bonfire+xml')
    response.set_header('Accept', '*/*')
    response.set_header('Allow', 'GET, HEAD') 
    ET.register_namespace("test", "http://127.0.0.1/cocoma")
    
    root = ET.Element('root', { 'href':'/'})
    ver = ET.SubElement(root, 'version')
    ver.text = '0.1.1'
    ts = ET.SubElement(root, 'timestamp')
    ts.text = str(time.time())
    lk = ET.SubElement(root, 'link', {'rel':'emulations', 'href':'/emulations', 'type':'application/vnd.bonfire+xml'})
    lk = ET.SubElement(root, 'link', {'rel':'emulators', 'href':'/emulators', 'type':'application/vnd.bonfire+xml'})
    lk = ET.SubElement(root, 'link', {'rel':'distributions', 'href':'/distributions', 'type':'application/vnd.bonfire+xml'})
    lk = ET.SubElement(root, 'link', {'rel':'tests', 'href':'/tests', 'type':'application/vnd.bonfire+xml'})
    lk = ET.SubElement(root, 'link', {'rel':'results', 'href':'/results', 'type':'application/vnd.bonfire+xml'})
    lk = ET.SubElement(root, 'link', {'rel':'logs', 'href':'/logs', 'type':'application/vnd.bonfire+xml'})
    lk = ET.SubElement(root, 'link', {'rel':'jobs', 'href':'/jobs', 'type':'application/vnd.bonfire+xml'})

    return prettify(root)
Example #19
0
    #<link href="/" rel="parent" type="application/vnd.cocoma+xml"/>
    lk0 = ET.SubElement(emulation, 'link', {
        'rel': 'parent',
        'href': '/',
        'type': 'application/vnd.bonfire+xml'
    })
    #<link href="/emulations" rel="parent" type="application/vnd.cocoma+xml"/>
    lk0 = ET.SubElement(
        emulation, 'link', {
            'rel': 'parent',
            'href': '/emulations',
            'type': 'application/vnd.bonfire+xml'
        })

    return prettify(emulation)


@route('/emulators/', method='GET')
@route('/emulators', method='GET')
def get_emulators():
    '''
    Display list of emulators
    '''
    ET.register_namespace("test", "http://127.0.0.1/cocoma")
    response.set_header('Content-Type', 'application/vnd.bonfire+xml')
    response.set_header('Accept', '*/*')
    response.set_header('Allow', 'GET, HEAD')

    emuList = Library.listEmulators("all")
    #print "emulist",emuList
Example #20
0
def get_emulator(name=""):
    '''
    Display emulator by name
    '''
    
    ET.register_namespace("test", "http://127.0.0.1/cocoma")
    response.set_header('Content-Type', 'application/vnd.bonfire+xml')
    response.set_header('Accept', '*/*')
    response.set_header('Allow', 'GET, HEAD')
        
        
             
        
        
    try:
        helpMod=Library.loadEmulatorHelp(name)
        argMod=Library.loadEmulatorArgNames(name)
    
        emulatorXml = ET.Element('emulator', { 'xmlns':'http://127.0.0.1/cocoma','href':'/emulators/'+str(name)})
    
        emulatorInfoXml=ET.SubElement(emulatorXml,'info')
        emulatorHelpXml=ET.SubElement(emulatorInfoXml,'help')
        emulatorHelpXml.text = str(helpMod())
        
        emulatorResourcesListXml=ET.SubElement(emulatorInfoXml,'resources')
        
        #get list of resources
        resList=argMod()
        
        #get arguments for every resource { "mem":[startLoad,stopLoad,malloc]}, "io":[...]}
        for resource in resList:
            argNames=argMod(resource)
            
            #<mem>
            emulatorResourceXml=ET.SubElement(emulatorResourcesListXml,resource)
            #<startLoad>
            #{"startload":{"upperBound":100,"lowerBound":0},"stopload":{"upperBound":100,"lowerBound":0}}
            for args in argNames:
                emulatorArgsXml=ET.SubElement(emulatorResourceXml,args)
                
                #<upperBound>
                emulatorUpperBound=ET.SubElement(emulatorArgsXml,"upperBound")
                
                emulatorUpperBound.text = str(argNames[args]["upperBound"])
                
                emulatorLowerBound=ET.SubElement(emulatorArgsXml,"lowerBound")
                emulatorLowerBound.text = str(argNames[args]["lowerBound"])
                
                if not (argNames[args].has_key("argHelp")):
                    argNames[args]["argHelp"] = "No help Available"
                emuArgHelp=ET.SubElement(emulatorArgsXml,"argHelp")
                emuArgHelp.text = str(argNames[args]["argHelp"])
    

        lk0 = ET.SubElement(emulatorXml, 'link', {'rel':'parent', 'href':'/', 'type':'application/vnd.bonfire+xml'})
        #<link href="/emulations" rel="parent" type="application/vnd.cocoma+xml"/>
        lk0 = ET.SubElement(emulatorXml, 'link', {'rel':'parent', 'href':'/emulators', 'type':'application/vnd.bonfire+xml'})
    
    
        return prettify(emulatorXml)
    
    except Exception, e:
        response.status = 404
        return "<error>"+str(e)+"</error>"    
Example #21
0
def get_distribution(name=""):
    '''
    Display distribution by name
    
    
    #example return
    <info>
        <help>Linear distribution takes in start and stop load parameters and gradually increasing resource workload. Can be used with CPU,MEM,IO,NET resource types.</help>
        <resources>
            <mem>
                <startLoad>
                    <upperBound>1</upperBound>
                    <lowerBound>2</lowerBound>
                </startLoad>
                
                <stopLoad>
                    <upperBound>1</upperBound>
                    <lowerBound>2</lowerBound>
                </stopLoad>                
            </mem>
            <io>
            ...
            </io>
        </resources>
    </info>
    '''

    #curl -k -i http://10.55.164.232:8050/distributions/linear

    ET.register_namespace("test", "http://127.0.0.1/cocoma")
    response.set_header('Content-Type', 'application/vnd.bonfire+xml')
    response.set_header('Accept', '*/*')
    response.set_header('Allow', 'GET, HEAD')

    try:
        helpMod = Library.loadDistributionHelp(name)
        argMod = Library.loadDistributionArgNames(name)

        distributionXml = ET.Element(
            'distribution', {
                'xmlns': 'http://127.0.0.1/cocoma',
                'href': '/distributions/' + str(name)
            })

        distroInfoXml = ET.SubElement(distributionXml, 'info')
        distroHelpXml = ET.SubElement(distroInfoXml, 'help')
        distroHelpXml.text = str(helpMod())

        distroResourcesListXml = ET.SubElement(distroInfoXml, 'resources')

        #get list of resources
        resList = argMod()

        #get arguments for every resource { "mem":[startLoad,stopLoad,malloc]}, "io":[...]}
        for resource in resList:
            argNames = argMod(resource)

            #<mem>
            distroResourceXml = ET.SubElement(distroResourcesListXml, resource)
            #<startLoad>
            #{"startload":{"upperBound":100,"lowerBound":0},"stopload":{"upperBound":100,"lowerBound":0}}
            for args in argNames:
                distroArgsXml = ET.SubElement(distroResourceXml, args)

                #<upperBound>
                distroUpperBound = ET.SubElement(distroArgsXml, "upperBound")

                distroUpperBound.text = str(argNames[args]["upperBound"])

                distroLowerBound = ET.SubElement(distroArgsXml, "lowerBound")
                distroLowerBound.text = str(argNames[args]["lowerBound"])

                if not (argNames[args].has_key("argHelp")):
                    argNames[args]["argHelp"] = "No help Available :'("
                distroArgHelp = ET.SubElement(distroArgsXml, "argHelp")
                distroArgHelp.text = str(argNames[args]["argHelp"])


#                if (argNames[args].has_key("argHelp")):
#                    distroArgHelp.text = str(argNames[args]["argHelp"])
#                else:
#                    distroArgHelp.text = str("No help Available :(")

        lk0 = ET.SubElement(distributionXml, 'link', {
            'rel': 'parent',
            'href': '/',
            'type': 'application/vnd.bonfire+xml'
        })
        lk0 = ET.SubElement(
            distributionXml, 'link', {
                'rel': 'parent',
                'href': '/distributions',
                'type': 'application/vnd.bonfire+xml'
            })

        return prettify(distributionXml)

    except Exception, e:
        response.status = 404
        return "<error>" + str(e) + "</error>"
Example #22
0
def get_emulator(name=""):
    '''
    Display emulator by name
    '''

    ET.register_namespace("test", "http://127.0.0.1/cocoma")
    response.set_header('Content-Type', 'application/vnd.bonfire+xml')
    response.set_header('Accept', '*/*')
    response.set_header('Allow', 'GET, HEAD')

    try:
        helpMod = Library.loadEmulatorHelp(name)
        argMod = Library.loadEmulatorArgNames(name)

        emulatorXml = ET.Element('emulator', {
            'xmlns': 'http://127.0.0.1/cocoma',
            'href': '/emulators/' + str(name)
        })

        emulatorInfoXml = ET.SubElement(emulatorXml, 'info')
        emulatorHelpXml = ET.SubElement(emulatorInfoXml, 'help')
        emulatorHelpXml.text = str(helpMod())

        emulatorResourcesListXml = ET.SubElement(emulatorInfoXml, 'resources')

        #get list of resources
        resList = argMod()

        #get arguments for every resource { "mem":[startLoad,stopLoad,malloc]}, "io":[...]}
        for resource in resList:
            argNames = argMod(resource)

            #<mem>
            emulatorResourceXml = ET.SubElement(emulatorResourcesListXml,
                                                resource)
            #<startLoad>
            #{"startload":{"upperBound":100,"lowerBound":0},"stopload":{"upperBound":100,"lowerBound":0}}
            for args in argNames:
                emulatorArgsXml = ET.SubElement(emulatorResourceXml, args)

                #<upperBound>
                emulatorUpperBound = ET.SubElement(emulatorArgsXml,
                                                   "upperBound")

                emulatorUpperBound.text = str(argNames[args]["upperBound"])

                emulatorLowerBound = ET.SubElement(emulatorArgsXml,
                                                   "lowerBound")
                emulatorLowerBound.text = str(argNames[args]["lowerBound"])

                if not (argNames[args].has_key("argHelp")):
                    argNames[args]["argHelp"] = "No help Available"
                emuArgHelp = ET.SubElement(emulatorArgsXml, "argHelp")
                emuArgHelp.text = str(argNames[args]["argHelp"])

        lk0 = ET.SubElement(emulatorXml, 'link', {
            'rel': 'parent',
            'href': '/',
            'type': 'application/vnd.bonfire+xml'
        })
        #<link href="/emulations" rel="parent" type="application/vnd.cocoma+xml"/>
        lk0 = ET.SubElement(
            emulatorXml, 'link', {
                'rel': 'parent',
                'href': '/emulators',
                'type': 'application/vnd.bonfire+xml'
            })

        return prettify(emulatorXml)

    except Exception, e:
        response.status = 404
        return "<error>" + str(e) + "</error>"
Example #23
0
def get_distribution(name=""):
    '''
    Display distribution by name
    
    
    #example return
    <info>
        <help>Linear distribution takes in start and stop load parameters and gradually increasing resource workload. Can be used with CPU,MEM,IO,NET resource types.</help>
        <resources>
            <mem>
                <startLoad>
                    <upperBound>1</upperBound>
                    <lowerBound>2</lowerBound>
                </startLoad>
                
                <stopLoad>
                    <upperBound>1</upperBound>
                    <lowerBound>2</lowerBound>
                </stopLoad>                
            </mem>
            <io>
            ...
            </io>
        </resources>
    </info>
    '''
    
    #curl -k -i http://10.55.164.232:8050/distributions/linear
    
    ET.register_namespace("test", "http://127.0.0.1/cocoma")
    response.set_header('Content-Type', 'application/vnd.bonfire+xml')
    response.set_header('Accept', '*/*')
    response.set_header('Allow', 'GET, HEAD') 
    
    try:
        helpMod=Library.loadDistributionHelp(name)
        argMod=Library.loadDistributionArgNames(name)
    
        distributionXml = ET.Element('distribution', { 'xmlns':'http://127.0.0.1/cocoma','href':'/distributions/'+str(name)})
    
        distroInfoXml=ET.SubElement(distributionXml,'info')
        distroHelpXml=ET.SubElement(distroInfoXml,'help')
        distroHelpXml.text = str(helpMod())
        
        distroResourcesListXml=ET.SubElement(distroInfoXml,'resources')
        
        #get list of resources
        resList=argMod()
        
        #get arguments for every resource { "mem":[startLoad,stopLoad,malloc]}, "io":[...]}
        for resource in resList:
            argNames=argMod(resource)
            
            #<mem>
            distroResourceXml=ET.SubElement(distroResourcesListXml,resource)
            #<startLoad>
            #{"startload":{"upperBound":100,"lowerBound":0},"stopload":{"upperBound":100,"lowerBound":0}}
            for args in argNames:
                distroArgsXml=ET.SubElement(distroResourceXml,args)
                
                #<upperBound>
                distroUpperBound=ET.SubElement(distroArgsXml,"upperBound")
                
                distroUpperBound.text = str(argNames[args]["upperBound"])
                
                distroLowerBound=ET.SubElement(distroArgsXml,"lowerBound")
                distroLowerBound.text = str(argNames[args]["lowerBound"])
                
                if not (argNames[args].has_key("argHelp")):
                    argNames[args]["argHelp"] = "No help Available :'("
                distroArgHelp=ET.SubElement(distroArgsXml,"argHelp")
                distroArgHelp.text = str(argNames[args]["argHelp"])
                
#                if (argNames[args].has_key("argHelp")):
#                    distroArgHelp.text = str(argNames[args]["argHelp"])
#                else:
#                    distroArgHelp.text = str("No help Available :(")
    
        lk0 = ET.SubElement(distributionXml, 'link', {'rel':'parent', 'href':'/', 'type':'application/vnd.bonfire+xml'})
        lk0 = ET.SubElement(distributionXml, 'link', {'rel':'parent', 'href':'/distributions', 'type':'application/vnd.bonfire+xml'})
    
    
        return prettify(distributionXml)
    
    except Exception, e:
        response.status = 404
        return "<error>"+str(e)+"</error>"
Example #24
0
def show_results(name=""):
    '''
    Show emulation results. The amount of total runs and the amount of failed runs.
    '''
    
    #curl -k -i http://10.55.164.232:8050/distributions/linear
    
    ET.register_namespace("test", "http://127.0.0.1/cocoma")
    response.set_header('Content-Type', 'application/vnd.bonfire+xml')
    response.set_header('Accept', '*/*')
    response.set_header('Allow', 'GET, HEAD') 
    
    
    try:    
        emuList=Library.getEmulationList(name)
        
        
        for elem in emuList :
            failedRunsInfo=elem["failedRunsInfo"]
            
            resultsEmulation = ET.Element('results', { 'xmlns':'http://127.0.0.1/cocoma','href':'/results/'+str(elem["Name"])})
            
            emuName= ET.SubElement(resultsEmulation,'emulationName')
            emuName.text = str(elem["Name"])
            
            totalRuns= ET.SubElement(resultsEmulation,'totalRuns')
            totalRuns.text=str(elem["runsTotal"])
            
            executedRuns=ET.SubElement(resultsEmulation,'executedRuns')
            executedRuns.text=str(elem["runsExecuted"])
            
            failedRuns=ET.SubElement(resultsEmulation,'failedRuns')
            
            #checking if emulation was already executed
            if str(elem["State"]) == "inactive":
                totalFailedRuns = int(elem["runsTotal"])-int(elem["runsExecuted"])
                failedRuns.text=str(totalFailedRuns)
            else:
                failedRuns.text=str(len(failedRunsInfo))
            
            
            
            emuState= ET.SubElement(resultsEmulation,'emuState')
            emuState.text=str(elem["State"])
            
            if failedRunsInfo:
            
                failedRunsDetails= ET.SubElement(resultsEmulation,'failedRunsDetails')
            
                #print "###Failed Runs Info###"
                for Runs in failedRunsInfo:
                    runNo= ET.SubElement(failedRunsDetails,'runNo',{'runNo':str(Runs["runNo"])})
                    #runNo.text=str(Runs["runNo"])
                    
                    distributionID= ET.SubElement(runNo,'distributionID')
                    distributionID.text=str(Runs["distributionID"])
                                   
                    distributionName= ET.SubElement(runNo,'distributionName')
                    distributionName.text=str(Runs["distributionName"])
                    
                    stressValue= ET.SubElement(runNo,'stressValue')
                    stressValue.text=str(Runs["stressValue"])
                    
                    message= ET.SubElement(runNo,'message')
                    message.text=str(Runs["message"])
                    
                    #print "#\nRun No: ", Runs["runNo"]
                    #print "Distribution ID: ",Runs["distributionID"]
                    #print "Distribution Name: ",Runs["distributionName"]
                    
                    #print "Stress Value: ", Runs["stressValue"]
                    #print "Error Message: ", Runs["message"]
        
            return prettify(resultsEmulation)
        
            
    except Exception,e:
        response.status = 400
        print "\nEmulation ID:"+str(name)+" not found.\nError:"+str(e)
        return "<error>Emulation ID:"+str(name)+" not found.\nError:"+str(e)+"</error>"
Example #25
0
def show_results(name=""):
    '''
    Show emulation results. The amount of total runs and the amount of failed runs.
    '''

    #curl -k -i http://10.55.164.232:8050/distributions/linear

    ET.register_namespace("test", "http://127.0.0.1/cocoma")
    response.set_header('Content-Type', 'application/vnd.bonfire+xml')
    response.set_header('Accept', '*/*')
    response.set_header('Allow', 'GET, HEAD')

    try:
        emuList = Library.getEmulationList(name)

        for elem in emuList:
            failedRunsInfo = elem["failedRunsInfo"]

            resultsEmulation = ET.Element(
                'results', {
                    'xmlns': 'http://127.0.0.1/cocoma',
                    'href': '/results/' + str(elem["Name"])
                })

            emuName = ET.SubElement(resultsEmulation, 'emulationName')
            emuName.text = str(elem["Name"])

            totalRuns = ET.SubElement(resultsEmulation, 'totalRuns')
            totalRuns.text = str(elem["runsTotal"])

            executedRuns = ET.SubElement(resultsEmulation, 'executedRuns')
            executedRuns.text = str(elem["runsExecuted"])

            failedRuns = ET.SubElement(resultsEmulation, 'failedRuns')

            #checking if emulation was already executed
            if str(elem["State"]) == "inactive":
                totalFailedRuns = int(elem["runsTotal"]) - int(
                    elem["runsExecuted"])
                failedRuns.text = str(totalFailedRuns)
            else:
                failedRuns.text = str(len(failedRunsInfo))

            emuState = ET.SubElement(resultsEmulation, 'emuState')
            emuState.text = str(elem["State"])

            if failedRunsInfo:

                failedRunsDetails = ET.SubElement(resultsEmulation,
                                                  'failedRunsDetails')

                #print "###Failed Runs Info###"
                for Runs in failedRunsInfo:
                    runNo = ET.SubElement(failedRunsDetails, 'runNo',
                                          {'runNo': str(Runs["runNo"])})
                    #runNo.text=str(Runs["runNo"])

                    distributionID = ET.SubElement(runNo, 'distributionID')
                    distributionID.text = str(Runs["distributionID"])

                    distributionName = ET.SubElement(runNo, 'distributionName')
                    distributionName.text = str(Runs["distributionName"])

                    stressValue = ET.SubElement(runNo, 'stressValue')
                    stressValue.text = str(Runs["stressValue"])

                    message = ET.SubElement(runNo, 'message')
                    message.text = str(Runs["message"])

                    #print "#\nRun No: ", Runs["runNo"]
                    #print "Distribution ID: ",Runs["distributionID"]
                    #print "Distribution Name: ",Runs["distributionName"]

                    #print "Stress Value: ", Runs["stressValue"]
                    #print "Error Message: ", Runs["message"]

            return prettify(resultsEmulation)

    except Exception, e:
        response.status = 400
        print "\nEmulation ID:" + str(name) + " not found.\nError:" + str(e)
        return "<error>Emulation ID:" + str(
            name) + " not found.\nError:" + str(e) + "</error>"
Example #26
0
    hostXML.text=str(host)  

    topicXML= ET.SubElement(mqXML,'topic')
    topicXML.text=str(topic)  


    #<xmlData>xml body content</xmlData>
    #xmlDataXml =ET.SubElement(emulation,'xmlData')
    #xmlDataXml.text = str(xmlData)

    #<link href="/" rel="parent" type="application/vnd.cocoma+xml"/>
    lk0 = ET.SubElement(emulation, 'link', {'rel':'parent', 'href':'/', 'type':'application/vnd.bonfire+xml'})
    #<link href="/emulations" rel="parent" type="application/vnd.cocoma+xml"/>
    lk0 = ET.SubElement(emulation, 'link', {'rel':'parent', 'href':'/emulations', 'type':'application/vnd.bonfire+xml'})
    
    return prettify(emulation)    

@route('/emulators/', method='GET')
@route('/emulators', method='GET')
def get_emulators():
    '''
    Display list of emulators
    '''
    ET.register_namespace("test", "http://127.0.0.1/cocoma")
    response.set_header('Content-Type', 'application/vnd.bonfire+xml')
    response.set_header('Accept', '*/*')
    response.set_header('Allow', 'GET, HEAD')     
    
    emuList=Library.listEmulators("all")
    #print "emulist",emuList
    '''