Exemplo n.º 1
0
    def __init__(self):
        self.uuid = uuid.uuid4()
        sid = str(self.uuid)

        '''
        Creating the two stores
        
        afos://...  Actual State Store
        In this store you can find all the actual data of the node, this store is written by
        plugins and by the fogagent for update the store after a request.
        All other nodes can read or observe only this store.
        
        
        dfos://... Desidered State Store
        In this store other nodes write the command/request, all plugins and the agent observe this store,
        in a way that they can react to a desidered state
        
        '''


        self.droot = "dfos://<sys-id>"
        self.dhome = str("dfos://<sys-id>/%s" % sid)
        self.dstore = DStore(sid, self.droot, self.dhome, 1024)

        self.aroot = "afos://<sys-id>"
        self.ahome = str("afos://<sys-id>/%s" % sid)
        self.astore = DStore(sid, self.aroot, self.ahome, 1024)

        self.nodes = {}
Exemplo n.º 2
0
    def __init__(self):
        self.uuid = uuid.uuid4()
        sid = str(self.uuid)

        self.droot = "dfos://<sys-id>"
        self.dhome = str("dfos://<sys-id>/%s" % sid)
        self.dstore = DStore(sid, self.droot, self.dhome, 1024)

        self.aroot = "afos://<sys-id>"
        self.ahome = str("afos://<sys-id>/%s" % sid)
        self.astore = DStore(sid, self.aroot, self.ahome, 1024)

        self.nodes = {}
Exemplo n.º 3
0
def test_miss(sid, root, home):

    sroot = 'afos://{}'.format(root)
    shome = 'afos://{}/{}'.format(root, home)

    store = DStore(sid, sroot, home, 1024)

    uri_prefix = 'afos://{0}/{1}-{2}'.format(root, home, sid)
    id = 100 + int(sid)
    val = {
        'id': id,
        'kind': 'info',
        'value': 'am a store afos://{0}/{1}-{2}!'.format(root, home, sid)
    }
    store.put(uri_prefix, json.dumps(val))

    test_uri = uri_prefix + '/savia'
    tid = 200 + int(sid)
    tval = {'id': tid, 'value': 'A Test URI'}
    store.put(test_uri, json.dumps(tval))

    dval = {'pasticceria': '{0}-Cannoli!'.format(sid)}
    store.dput(test_uri, json.dumps(dval))

    delta_tag = '#rosticceria={0}-Arancini!'.format(sid)
    test_uri = test_uri + delta_tag
    store.dput(test_uri)

    print('Store written, press a key to continue')
    input()
    # local get
    v = store.get(uri_prefix)
    vt = store.get(test_uri)
    print('=========> store[{0}] = {1}'.format(uri_prefix, v))
    print('=========> store[{0}] = {1}'.format(test_uri, vt))
    print('\nStore get exectured, press a key to continue')
    input()
    # try get that need resolving
    for id in store.discovered_stores:
        uri = 'afos://{0}/{1}-{2}/savia'.format(root, home, id)
        v = store.get(uri)
        print('=========> store[{0}] = {1}'.format(uri, v))

    print('\nStore remote get exectured, press a key to continue')
    input()
    # try to get them in a single shot -- locally:

    uri = 'afos://{0}/*'.format(root, home)
    vs = store.getAll(uri)
    print('=========> store[{0}] = {1}'.format(uri, vs))

    print('\nStore local get-all exectured, press a key to continue')
    input()

    vs = store.resolveAll(uri)
    print('=========> store[{0}] = {1}'.format(uri, vs))

    print('\nStore remote resolve-all exectured, press a key to continue')
    input()
Exemplo n.º 4
0
 def __init__(self):
     self.uuid = uuid.uuid4()
     sid = str(self.uuid)
     self.root = "fos://<sys-id>"
     self.home = str("fos://<sys-id>/{}".format(sid))
     self.nodes = {}
     # Notice that a node may have multiple caches, but here we are
     # giving the same id to the nodew and the cache
     self.store = DStore(sid, self.root, self.home, 1024)
Exemplo n.º 5
0
    def __init__(self):
        self.uuid = uuid.uuid4()
        sid = (self.uuid)


        # Desidered Store. containing the desidered state
        self.droot = 'dfos://<sys-id>'
        self.dhome = 'dfos://<sys-id>/{}'.format(sid)
        self.dstore = DStore(sid, self.droot, self.dhome, 1024)

        # Actual Store, containing the Actual State
        self.aroot = 'afos://<sys-id>'
        self.ahome = 'afos://<sys-id>/{}'.format(sid)
        self.astore = DStore(sid, self.aroot, self.ahome, 1024)

        self.nodes = {}

        self.populateNodeInformation()
Exemplo n.º 6
0
    def __init__(self):
        self.auuid = 'a1'
        self.duuid = 'd1'
        self.nuuid = '1'

        # Desidered Store. containing the desidered state
        self.droot = "dfos://<sys-id>"
        self.dhome = str("dfos://<sys-id>/%s" % self.nuuid)
        self.dstore = DStore(self.duuid, self.droot, self.dhome, 1024)

        # Actual Store, containing the Actual State
        self.aroot = "afos://<sys-id>"
        self.ahome = str("afos://<sys-id>/%s" % self.nuuid)
        self.astore = DStore(self.auuid, self.aroot, self.ahome, 1024)

        print("Actual Store Id = {0}".format(self.astore.store_id))
        print("Desired Store Id = {0}".format(self.dstore.store_id))
        self.nodes = {}

        self.populateNodeInformation()
Exemplo n.º 7
0
def test_miss(sid, root, home):

    sroot = 'fos://{0}'.format(root)
    shome= 'fos://{0}-{1}'.format(root, home)

    store = DStore(sid, sroot, home, 1024)

    uri_prefix = 'fos://{0}/{1}-{2}'.format(root, home, sid)
    id = 100 + int(sid)
    val = {'id': id, 'kind': 'info', 'value': 'am a store fos://{0}/{1}-{2}!'.format(root, home, sid)}
    store.put(uri_prefix, json.dumps(val))

    test_uri = uri_prefix+'/savia'
    tid = 200 + int(sid)
    tval = {'id': tid, 'value': 'A Test URI'}
    store.put(test_uri, json.dumps(tval))


    dval = {'pasticceria': '{0}-Cannoli!'.format(sid)}
    store.dput(test_uri, json.dumps(dval))

    delta_tag = '#rosticceria={0}-Arancini!'.format(sid)
    test_uri = test_uri+delta_tag
    store.dput(test_uri)

    test_uri = uri_prefix + '/savia'
    store.observe(test_uri, my_observer)

    print('Store written, press a key to continue')
    input()

    for id in store.discovered_stores:
        uri = 'fos://{0}/{1}-{2}/savia'.format(root, home, id)
        store.remove(uri)
        #print('=========> store[{0}] = {1}'.format(uri, v))

    input()