Uploaded image for project: 'jclouds'
  1. jclouds
  2. JCLOUDS-1351

AWS CentOS marketplace AMI misdetecting OS type

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.2
    • Fix Version/s: 2.1.0, 2.0.3
    • Component/s: jclouds-compute
    • Labels:

      Description

      When jclouds encounters an official CentOS Linux AMI from the AWS Marketplace, it detects the operating system as "unrecognized".

      To reproduce, set the jclouds.ec2.ami-query / jclouds.ec2.cc-ami-query properties to search the AWS Marketplace for CentOS images. Example: owner-id=679593333241;state=available;image-type=machine;root-device-type=ebs;architecture=x86_64;virtualization-type=hvm;name=CentOS Linux *

      jclouds will discover from AWS AMIs such as this one:

      <item>
          <imageId>ami-061b1560</imageId>
          <imageLocation>aws-marketplace/CentOS Linux 7 x86_64 HVM EBS 1704_01-b7ee8a69-ee97-4a49-9e68-afaee216db2e-ami-d52f5bc3.4</imageLocation>
          <imageState>available</imageState>
          <imageOwnerId>679593333241</imageOwnerId>
          <isPublic>true</isPublic>
          <productCodes>
              <item>
                  <productCode>aw0evgkw8e5c1q413zgy5pjce</productCode>
                  <type>marketplace</type>
              </item>
          </productCodes>
          <architecture>x86_64</architecture>
          <imageType>machine</imageType>
          <imageOwnerAlias>aws-marketplace</imageOwnerAlias>
          <name>CentOS Linux 7 x86_64 HVM EBS 1704_01-b7ee8a69-ee97-4a49-9e68-afaee216db2e-ami-d52f5bc3.4</name>
          <description>CentOS Linux 7 x86_64 HVM EBS 1704_01</description>
          <rootDeviceType>ebs</rootDeviceType>
          <rootDeviceName>/dev/sda1</rootDeviceName>
          <blockDeviceMapping>
              <item>
                  <deviceName>/dev/sda1</deviceName>
                  <ebs>
                      <snapshotId>snap-00f18f3f6413c7879</snapshotId>
                      <volumeSize>8</volumeSize>
                      <deleteOnTermination>false</deleteOnTermination>
                  </ebs>
              </item>
          </blockDeviceMapping>
          <virtualizationType>hvm</virtualizationType>
          <hypervisor>xen</hypervisor>
      </item>
      

      While parsing this, execution will end up here: https://github.com/jclouds/jclouds/blob/574c7fc3c1234037608c8daf96375673265e904f/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java#L141

         public static org.jclouds.compute.domain.OsFamily parseOsFamilyOrUnrecognized(String in) {
            org.jclouds.compute.domain.OsFamily myOs = null;
            for (org.jclouds.compute.domain.OsFamily os : org.jclouds.compute.domain.OsFamily.values()) {
               if (in.toLowerCase().replaceAll("\\s", "").indexOf(os.toString()) != -1) {
                  myOs = os;
               }
            }
            return myOs != null ? myOs : OsFamily.UNRECOGNIZED;
         }
      

      This enumerates over the known OS names to see if there's a match in the AMI name. The string CentOS Linux 7 x86_64 HVM EBS 1704_01-b7ee8a69-ee97-4a49-9e68-afaee216db2e-ami-d52f5bc3.4 contains matches two enum values: CENTOS and LINUX. It seems that the alphabetically-last value is the one that is selected, so that this method returns LINUX and not CENTOS.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              rdowner Richard Downer
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: