Ejemplo n.º 1
0
        if cpt == 5:
            break
        print "  - %s - %s " % (i['hostname'], i['city'])
        cpt += 1
    print "    (only 5 first displayed)"


def print_result(result):
    cpt = 0
    for i in result:
        if cpt == 5:
            break
        print_slice(i)
        cpt += 1
    print "(only 5 first displayed)"
    print "============================="


from manifold.core.router import THRouter
from manifold.core.router import Query

# Instantiate a TopHat router
with THRouter() as router:
    result = router.forward(Query(*query))  #, execute=False)
    if result:
        print ""
        print "=== RESULT ==="
        print_result(result)
        print "--------------"
        print ""
Ejemplo n.º 2
0
#!/usr/bin/env python
# -*- coding:utf-8 */

import sys
import xmlrpclib

query = ('get', 'metadata:table', [], {}, [], 'latest')

from manifold.core.router import Router
from manifold.core.router import Query

# Instantiate a TopHat router
with Router() as router:
    result = router.forward(Query(*query), execute=True)
    #print result
    if result['code'] == 0:
        for x in result['result']:
            #print x
            print x['table']
            for c in x['column'][0:5]:
                print "  - %s" % c['column']
Ejemplo n.º 3
0
#!/usr/bin/env python
# -*- coding:utf-8 */

from manifold.core.router import Query, Router

query1 = Query(action='get',
               object='local:platform',
               filters=[],
               params=None,
               fields=['platform', 'platform_longname'])
query2 = Query(action='get', object='local:user')
query3 = Query(action='get', object='local:account')

update = Query(action='update',
               object='local:platform',
               params={'platform_longname': 'PlanetLab Europe testbed'},
               filters=[['platform', '=', '''ple''']],
               fields=['platform', 'platform_longname'])

# Instantiate a TopHat router
with Router() as router:
    try:
        for q in [query1, query2, query3, update, query1]:
            print "=== Query: %s ===" % q
            result = router.forward(q)
            print result
    except Exception, e:
        print "Exception", e
Ejemplo n.º 4
0
#!/usr/bin/env python
# -*- coding:utf-8 */

from manifold.core.router import Query, Router

q = Query(action='get', object='local:platform', filters=[], params=None, fields=['platform', 'platform_longname'])

# Update(object, filters, params, fields, callback)
query = Query(action='update', object='local:platform', params={['platform_description', '=', 'test']}, filters=[['platform','=','ple']])

# Instantiate a TopHat router
with Router() as router:
    try:
        print "=== Query: %s ===" % query
        result = router.forward(query)
        print result

        print "=== Query: %s ===" % q
        result = router.forward(q)
        print result

        #for r in result:
            
    except Exception, e:
        print "Exception", e
Ejemplo n.º 5
0
#!/usr/bin/env python
# -*- coding:utf-8 */

import sys
import xmlrpclib

from manifold.core.router import THRouter
from manifold.core.router import Query

query = ('get', 'slice', [['slice_hrn', '=', 'ple.upmc.agent']], {},
         ['slice_hrn', 'resource.hostname'])

# Instantiate a TopHat router
with THRouter() as router:
    user = router.authenticate({
        'AuthMethod': 'password',
        'Username': '******',
        'AuthString': 'demo'
    })
    result = router.forward(Query(*query), user=user)
    slice = result[0]
    del slice['resource']
    print slice