示例#1
0
    def process_topology(self, old_top):
        """
        Processes the sections returned by get_instances

        :param ConfigObj old_top: old topology as processed by
                                  :py:meth:`read_topology`
        :returns: tuple of dicts containing hypervisors, devices and artwork
        :rtype: tuple
        """
        sections = self.get_sections(old_top)
        topo = LegacyTopology(sections, old_top)

        for instance in sorted(sections):

            if instance.startswith('vbox') \
                    and isinstance(old_top[instance]['VBoxDevice'], dict):
                topo.add_conf_item(instance, 'VBoxDevice')
                old_top[instance].pop('VBoxDevice')

            for item in sorted(old_top[instance]):
                if isinstance(old_top[instance][item], dict):
                    if item in MODEL_TRANSFORM:
                        # A configuration item (topo.conf)
                        topo.add_conf_item(instance, item)
                    elif instance == 'GNS3-DATA' and \
                            (item.startswith('SHAPE')
                             or item.startswith('NOTE')
                             or item.startswith('PIXMAP')):
                        # Item is an artwork item e.g. shapes and notes from
                        # GNS3-DATA
                        topo.add_artwork_item(instance, item)
                    else:
                        # It must be a physical item (topo.devices)
                        topo.add_physical_item(instance, item)
        return topo.topology
示例#2
0
 def setUp(self):
     conf = ConfigObj()
     conf['127.0.0.1:7200'] = {'3725': {'image': 'c3725.image',
                                        'ram': 128,
                                        'x': None,
                                        'y': None},
                               'ROUTER R1': {'cnfg': 'configs/R1.cfg',
                                             'console': 2101,
                                             'aux': 2501,
                                             'model': None}}
     self.app = LegacyTopology([], conf)