示例#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') or instance.startswith('qemu'):

                if instance.startswith('qemu') and \
                        'qemupath' in old_top[instance]:
                    topo.add_qemu_path(instance)

                for device in EXTRA_CONF:
                    try:
                        if isinstance(old_top[instance][device], dict):
                            topo.add_conf_item(instance, device)
                            old_top[instance].pop(device)
                    except KeyError:
                        pass

            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 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') or instance.startswith('qemu'):

                if instance.startswith('qemu') and \
                        'qemupath' in old_top[instance]:
                    topo.add_qemu_path(instance)

                for device in EXTRA_CONF:
                    try:
                        if isinstance(old_top[instance][device], dict):
                            topo.add_conf_item(instance, device)
                            old_top[instance].pop(device)
                    except KeyError:
                        pass

            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