示例#1
0
    def generate_images(self, pixmaps):
        """
        Generate the images list and store the images to copy

        :param dict pixmaps: A dict of converted pixmaps from the old topology
        :return: A list of images
        :rtype: list
        """
        new_images = []

        for image in pixmaps:
            tmp_image = {}
            for img_item in pixmaps[image]:
                if img_item == 'path':
                    path = os.path.join('images',
                                        os.path.basename(
                                            pixmaps[image][img_item]))
                    tmp_image['path'] = fix_path(path)
                    self.images.append(pixmaps[image][img_item])
                else:
                    tmp_image[img_item] = pixmaps[image][img_item]

            new_images.append(tmp_image)

        return new_images
示例#2
0
    def generate_images(self, pixmaps):
        """
        Generate the images list and store the images to copy

        :param dict pixmaps: A dict of converted pixmaps from the old topology
        :return: A list of images
        :rtype: list
        """
        new_images = []

        for image in pixmaps:
            tmp_image = {}
            for img_item in pixmaps[image]:
                if img_item == 'path':
                    path = os.path.join('images',
                                        os.path.basename(
                                            pixmaps[image][img_item]))
                    tmp_image['path'] = fix_path(path)
                    self.images.append(pixmaps[image][img_item])
                else:
                    tmp_image[img_item] = pixmaps[image][img_item]

            new_images.append(tmp_image)

        return new_images
示例#3
0
    def test_fix_path_unix(self):
        res = utils.fix_path('configs/R1.cfg')

        if sys.platform == 'win32':
            exp_res = 'configs\\R1.cfg'
        else:
            exp_res = 'configs/R1.cfg'

        self.assertEqual(res, exp_res)
示例#4
0
    def add_device_items(self, item, device):
        """
        Add the various items from the device to the node

        :param str item: item key
        :param dict device: dictionary containing items
        """
        if item in ('aux', 'console'):
            self.node['properties'][item] = device[item]
        elif item.startswith('slot'):
            if self.device_info['model'] == 'c7200':
                if item != 'slot0':
                    self.node['properties'][item] = device[item]
            else:
                self.node['properties'][item] = device[item]
        elif item == 'connections':
            self.connections = device[item]
        elif INTERFACE_RE.search(item) or VBQ_INT_RE.search(item):
            self.interfaces.append({'from': item, 'to': device[item]})
        elif NUMBER_RE.search(item):
            if self.device_info['type'] == 'EthernetSwitch':
                self.calc_ethsw_port(item, device[item])
            elif self.device_info['type'] == 'FrameRelaySwitch':
                self.calc_frsw_port(item, device[item])
        elif MAPINT_RE.search(item):
            self.add_mapping((item, device[item]))
        elif item == 'cnfg':
            new_config = os.path.join(
                'configs', 'i%s_startup-config.cfg' % self.node['id'])
            self.node['properties']['startup_config'] = new_config

            self.config.append({
                'old': fix_path(device[item]),
                'new': new_config
            })
        elif item.startswith('wic'):
            self.add_wic(item, device[item])
        elif item == 'symbol':
            self.set_symbol(device[item])
        elif item == 'nics':
            self.node['properties']['adapters'] = device[item]
        elif item == 'image':
            self.node['properties']['vmname'] = device[item]
        elif item == 'vbox_id':
            self.node['vbox_id'] = device[item]
示例#5
0
    def add_device_items(self, item, device):
        """
        Add the various items from the device to the node

        :param str item: item key
        :param dict device: dictionary containing items
        """
        if item in ('aux', 'console'):
            self.node['properties'][item] = device[item]
        elif item.startswith('slot'):
            if self.device_info['model'] == 'c7200':
                if item != 'slot0':
                    self.node['properties'][item] = device[item]
            else:
                self.node['properties'][item] = device[item]
        elif item == 'connections':
            self.connections = device[item]
        elif INTERFACE_RE.search(item) or VBQ_INT_RE.search(item):
            self.interfaces.append({'from': item,
                                    'to': device[item]})
        elif NUMBER_RE.search(item):
            if self.device_info['type'] == 'EthernetSwitch':
                self.calc_ethsw_port(item, device[item])
            elif self.device_info['type'] == 'FrameRelaySwitch':
                self.calc_frsw_port(item, device[item])
        elif MAPINT_RE.search(item):
            self.add_mapping((item, device[item]))
        elif item == 'cnfg':
            new_config = os.path.join('configs', 'i%s_startup-config.cfg' %
                                      self.node['id'])
            self.node['properties']['startup_config'] = new_config

            self.config.append({'old': fix_path(device[item]),
                                'new': new_config})
        elif item.startswith('wic'):
            self.add_wic(item, device[item])
        elif item == 'symbol':
            self.set_symbol(device[item])
        elif item == 'nics':
            self.node['properties']['adapters'] = device[item]
        elif item == 'image':
            self.node['properties']['vmname'] = device[item]
        elif item == 'vbox_id':
            self.node['vbox_id'] = device[item]
示例#6
0
    def add_device_items(self, item, device):
        """
        Add the various items from the device to the node

        :param str item: item key
        :param dict device: dictionary containing items
        """
        if item in ("aux", "console"):
            self.node["properties"][item] = device[item]
        elif item.startswith("slot"):
            if self.device_info["model"] == "c7200":
                if item != "slot0":
                    self.node["properties"][item] = device[item]
            else:
                self.node["properties"][item] = device[item]
        elif item == "connections":
            self.connections = device[item]
        elif INTERFACE_RE.search(item) or VBQ_INT_RE.search(item):
            self.interfaces.append({"from": item, "to": device[item]})
        elif NUMBER_RE.search(item):
            if self.device_info["type"] == "EthernetSwitch":
                self.calc_ethsw_port(item, device[item])
            elif self.device_info["type"] == "FrameRelaySwitch":
                self.calc_frsw_port(item, device[item])
        elif MAPINT_RE.search(item):
            self.add_mapping((item, device[item]))
        elif item == "cnfg":
            new_config = os.path.join("configs", "i%s_startup-config.cfg" % self.node["id"])
            self.node["properties"]["startup_config"] = new_config

            self.config.append({"old": fix_path(device[item]), "new": new_config})
        elif item.startswith("wic"):
            self.add_wic(item, device[item])
        elif item == "symbol":
            self.set_symbol(device[item])
        elif item == "nics":
            self.node["properties"]["adapters"] = device[item]
        elif item == "image":
            self.node["properties"]["vmname"] = device[item]
        elif item == "vbox_id" or item == "qemu_id":
            self.node[item] = device[item]
示例#7
0
 def test_fix_path_unix(self):
     res = utils.fix_path('configs/R1.cfg')
     self.assertEqual(res, 'configs/R1.cfg')