Ejemplo n.º 1
0
    def test_extract_ephemeral_image_params_with_no_metadata(self):
        path, osystem, arch, subarch, release, label = self._make_path()

        # Patch OperatingSystemRegistry to return a fixed list of
        # values.
        purpose1 = factory.make_name("purpose")
        purpose2 = factory.make_name("purpose")
        xi_purpose = "ephemeral"
        xi_path = factory.make_name("xi_path")
        xi_type = factory.make_name("xi_type")
        purposes = [purpose1, purpose2, xi_purpose]
        self._patch_osystem_registry(purposes,
                                     xinstall_params=(xi_path, xi_type))

        params = extract_image_params(path, "")

        self.assertItemsEqual(
            [
                {
                    "osystem": osystem,
                    "architecture": arch,
                    "subarchitecture": subarch,
                    "release": release,
                    "label": label,
                    "purpose": purpose1,
                    "xinstall_path": "",
                    "xinstall_type": "",
                },
                {
                    "osystem": osystem,
                    "architecture": arch,
                    "subarchitecture": subarch,
                    "release": release,
                    "label": label,
                    "purpose": purpose2,
                    "xinstall_path": "",
                    "xinstall_type": "",
                },
                {
                    "osystem": osystem,
                    "architecture": arch,
                    "subarchitecture": subarch,
                    "release": release,
                    "label": label,
                    "purpose": xi_purpose,
                    "xinstall_path": xi_path,
                    "xinstall_type": xi_type,
                },
            ],
            params,
        )
Ejemplo n.º 2
0
    def test_extract_image_params_with_bootloader(self):
        bootloader_type = factory.make_name("bootloader_type")
        arch = factory.make_name("arch")
        path = ('bootloader', bootloader_type, arch)

        params = extract_image_params(path, "")

        self.assertItemsEqual([
            {
                "osystem": "bootloader",
                "architecture": arch,
                "subarchitecture": "generic",
                "release": bootloader_type,
                "label": "*",
                "purpose": BOOT_IMAGE_PURPOSE.BOOTLOADER,
                "xinstall_path": '',
                "xinstall_type": '',
            },
        ], params)
Ejemplo n.º 3
0
    def test_extract_ephemeral_image_params_with_metadata(self):
        path, osystem, arch, subarch, release, label = self._make_path()

        # Patch OperatingSystemRegistry to return a fixed list of
        # values.
        purpose1 = factory.make_name("purpose")
        purpose2 = factory.make_name("purpose")
        xi_purpose = "ephemeral"
        xi_path = factory.make_name("xi_path")
        xi_type = factory.make_name("xi_type")
        purposes = [purpose1, purpose2, xi_purpose]
        self._patch_osystem_registry(purposes,
                                     xinstall_params=(xi_path, xi_type))

        # Create some maas.meta content.
        image = ImageSpec(os=osystem,
                          arch=arch,
                          subarch=subarch,
                          kflavor='generic',
                          release=release,
                          label=label)
        image_resource = dict(subarches=factory.make_name("subarches"))
        mapping = BootImageMapping()
        mapping.setdefault(image, image_resource)
        maas_meta = mapping.dump_json()

        params = extract_image_params(path, maas_meta)

        self.assertItemsEqual([
            {
                "osystem": osystem,
                "architecture": arch,
                "subarchitecture": subarch,
                "release": release,
                "label": label,
                "purpose": purpose1,
                "xinstall_path": '',
                "xinstall_type": '',
                "supported_subarches": image_resource["subarches"],
            },
            {
                "osystem": osystem,
                "architecture": arch,
                "subarchitecture": subarch,
                "release": release,
                "label": label,
                "purpose": purpose2,
                "xinstall_path": '',
                "xinstall_type": '',
                "supported_subarches": image_resource["subarches"],
            },
            {
                "osystem": osystem,
                "architecture": arch,
                "subarchitecture": subarch,
                "release": release,
                "label": label,
                "purpose": xi_purpose,
                "xinstall_path": xi_path,
                "xinstall_type": xi_type,
                "supported_subarches": image_resource["subarches"],
            },
        ], params)