Beispiel #1
0
    def canonicalize(cls, name):
        """Canonicalize the architecture name

        :param name: architecture name to canonicalize

        :returns: a canonical architecture name
        """

        if name is None:
            return None

        newname = name.lower()

        if newname in ("i386", "i486", "i586"):
            newname = cls.I686

        # Xen mistake from Icehouse or earlier
        if newname in ("x86_32", "x86_32p"):
            newname = cls.I686

        if newname == "amd64":
            newname = cls.X86_64

        if not cls.is_valid(newname):
            raise exception.InvalidArchitectureName(arch=name)

        return newname
Beispiel #2
0
def canonicalize(name):
    """Canonicalize the architecture name

    :param name: architecture name to canonicalize

    :returns: a canonical architecture name
    """

    if name is None:
        return None

    newname = name.lower()

    if newname in ("i386", "i486", "i586"):
        newname = I686

    # Xen mistake from Icehouse or earlier
    if newname in ("x86_32", "x86_32p"):
        newname = I686

    if newname == "amd64":
        newname = X86_64

    # zy: add new architectures
    if newname in ("armv7", "armv7l", "armhf"):
        newname = ARMV7
    # zy this arch is too old we take in armv7l to try

    if newname in "armvel":
        newname = ARMV6

    if newname in ("arm64", "aarch64"):
        newname = AARCH64

    if newname in "ppc":
        newname = PPC

    if newname in ("ppc64", ):
        newname = PPC64

    if newname in "sparc":
        newname = SPARC

    if newname in "mips":
        newname = MIPS

    if newname in "mips64el":
        newname = MIPS64EL

    if not is_valid(newname):
        raise exception.InvalidArchitectureName(arch=name)

    return newname
def canonicalize(name):
    """Canonicalize the architecture name

    :param name: architecture name to canonicalize

    :returns: a canonical architecture name
    """

    if name is None:
        return None

    newname = name.lower()

    if newname in ("i386", "i486", "i586"):
        newname = I686

    if not is_valid(newname):
        raise exception.InvalidArchitectureName(arch=name)

    return newname
Beispiel #4
0
    def _s3_parse_manifest(self, context, metadata, manifest):
        manifest = etree.fromstring(manifest)
        image_format = 'ami'

        try:
            kernel_id = manifest.find('machine_configuration/kernel_id').text
            if kernel_id == 'true':
                image_format = 'aki'
                kernel_id = None
        except Exception:
            kernel_id = None

        try:
            ramdisk_id = manifest.find('machine_configuration/ramdisk_id').text
            if ramdisk_id == 'true':
                image_format = 'ari'
                ramdisk_id = None
        except Exception:
            ramdisk_id = None

        try:
            guestarch = manifest.find(
                'machine_configuration/architecture').text
        except Exception:
            guestarch = arch.X86_64

        if not arch.is_valid(guestarch):
            raise exception.InvalidArchitectureName(arch=guestarch)

        # NOTE(yamahata):
        # EC2 ec2-budlne-image --block-device-mapping accepts
        # <virtual name>=<device name> where
        # virtual name = {ami, root, swap, ephemeral<N>}
        #                where N is no negative integer
        # device name = the device name seen by guest kernel.
        # They are converted into
        # block_device_mapping/mapping/{virtual, device}
        #
        # Do NOT confuse this with ec2-register's block device mapping
        # argument.
        mappings = []
        try:
            block_device_mapping = manifest.findall('machine_configuration/'
                                                    'block_device_mapping/'
                                                    'mapping')
            for bdm in block_device_mapping:
                mappings.append({'virtual': bdm.find('virtual').text,
                                 'device': bdm.find('device').text})
        except Exception:
            mappings = []

        properties = metadata['properties']
        properties['architecture'] = guestarch

        def _translate_dependent_image_id(image_key, image_id):
            image_uuid = ec2utils.ec2_id_to_glance_id(context, image_id)
            properties[image_key] = image_uuid

        if kernel_id:
            _translate_dependent_image_id('kernel_id', kernel_id)

        if ramdisk_id:
            _translate_dependent_image_id('ramdisk_id', ramdisk_id)

        if mappings:
            properties['mappings'] = mappings

        metadata.update({'disk_format': image_format,
                         'container_format': image_format,
                         'status': 'queued',
                         'is_public': False,
                         'properties': properties})
        metadata['properties']['image_state'] = 'pending'

        # TODO(bcwaldon): right now, this removes user-defined ids.
        # We need to re-enable this.
        metadata.pop('id', None)

        image = self.service.create(context, metadata)

        # extract the new uuid and generate an int id to present back to user
        image_uuid = image['id']
        image['id'] = ec2utils.glance_id_to_id(context, image_uuid)

        # return image_uuid so the caller can still make use of image_service
        return manifest, image, image_uuid