Example #1
0
    def postupgrade(self, tools, address):
        print 'eigend postupgrade'

        if tools.major_version() != 1:
            return

        n2 = tools.get_root(address).get_node(2)
        old_plugins = logic.parse_termlist(
            n2.get_data().as_dict_lookup('agents').as_string())
        good_plugins = set()
        good_plugins.add(guid.split(address)[0])

        for old_term in old_plugins:
            good_address = old_term.args[0]
            good_plugins.add(guid.split(good_address)[0])

        for actual_address in tools.get_agents():
            actual_guid, guid_tail = guid.split(actual_address)
            if actual_guid not in good_plugins and guid_tail != 'rig':
                a = tools.get_agent(actual_address)
                if a and a.get_type() == 0:
                    tools.delete_agent(actual_address)
                    print 'pruned bad agent', actual_address

        return upgrade_plugins_v1(tools, address)
Example #2
0
    def get_subsystems(self,agent):
        (id1,id2) = guid.split(agent)
        ss = []

        for a in self.__mapping.keys():
            if a == agent:
                continue

            (aid1,aid2) = guid.split(a)

            if aid1==id1:
                ss.append(a)

        return ss
Example #3
0
def __getfullname(snap, cache, address):
    (id, path) = paths.breakid_list(address)

    if id in cache:
        return paths.makeid_list(cache[id], *path)

    agent = snap.get_agent_address(0, id, False)
    if not agent.isvalid():
        agent = snap.get_agent_address(1, id, False)
        if not agent.isvalid():
            cache[id] = id
            return paths.makeid_list(id, *path)

    root = agent.get_root()
    sig = root.get_data().as_string().split(':')
    parent_name = None

    if guid.isguid(address) and len(sig) > 3:
        parent = __findroot(snap, guid.split(address)[0])
        parent_name = __getfullname(snap, cache, parent)

    node = Node(root, id, ())
    name = node.getname()

    if parent_name:
        name = parent_name + ' ' + name

    cache[id] = name
    return paths.makeid_list(name, *path)
Example #4
0
    def __init__(self, snap):
        self.__snap = snap
        self.__scratch = {}
        self.__ccache = None
        self.__registry = Registry()
        self.__mapping = build_mapping(snap, self.__registry)

        self.mapping = {}
        for (k, (os, m)) in self.__mapping.iteritems():
            self.mapping[k] = (os, m.signature())

        self.roots = {}
        for i in range(0, snap.agent_count()):
            agent = snap.get_agent_index(i)
            address = agent.get_address()
            root = agent.get_root()

            if agent.get_type() > 1 or not root.get_data().is_string():
                continue

            sig = root.get_data().as_string().split(':')
            if guid.isguid(address) and len(sig) == 3:
                root = guid.split(address)[0]
                self.roots[root] = address

        self.subsystems = {}
        for i in range(0, snap.agent_count()):
            agent = snap.get_agent_index(i)
            address = agent.get_address()
            root = agent.get_root()

            if agent.get_type() > 1 or not root.get_data().is_string():
                continue

            sig = root.get_data().as_string().split(':')
            if guid.isguid(address) and len(sig) > 3:
                root = guid.split(address)[0]
                parent = self.roots.get(root)
                if parent:
                    self.subsystems.setdefault(parent, []).append(address)
Example #5
0
def __findroot(snap, base):
    for i in range(0, snap.agent_count()):
        agent = snap.get_agent_index(i)
        address = agent.get_address()
        root = agent.get_root()

        if agent.get_type() > 1 or not root.get_data().is_string():
            continue

        sig = root.get_data().as_string().split(':')
        if guid.isguid(address) and len(sig) == 3:
            root = guid.split(address)[0]
            if root == base:
                return address

    return base
Example #6
0
 def __ssname(self, id):
     (myid, mypath) = guid.split(self.id())
     nid = ('%s/%s%s' % (myid, id, mypath))[:26]
     return '<%s>' % nid