]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Add 32-bit tdls for Fedora 16,17 jeos (gold and cfntools)
authorJeff Peeler <jpeeler@redhat.com>
Thu, 12 Apr 2012 00:56:45 +0000 (20:56 -0400)
committerJeff Peeler <jpeeler@redhat.com>
Thu, 12 Apr 2012 00:56:45 +0000 (20:56 -0400)
fixes #26

Note that the templates have been adjusted and the naming of the 32-bit
versions to i386 instead of i686. The install really is i686, but making
the arch match what is listed in the install ISO seems less confusing.

Signed-off-by: Jeff Peeler <jpeeler@redhat.com>
Although the 32-bit version of Fedora (and others) ISOs are labeled with i386,

bin/heat
heat/engine/resources.py
heat/jeos/F16-i386-cfntools-jeos.tdl [new file with mode: 0644]
heat/jeos/F16-i386-gold-jeos.tdl [new file with mode: 0644]
heat/jeos/F17-i386-cfntools-jeos.tdl [new file with mode: 0644]
heat/jeos/F17-i386-gold-jeos.tdl [new file with mode: 0644]
templates/WordPress_2_Instances.template
templates/WordPress_2_Instances_With_EBS_Volume.template
templates/WordPress_Single_Instance.template
templates/WordPress_Single_Instance_With_EBS_Volume.template
templates/WordPress_Single_Instance_cfntools.template

index 9bc81710b5f0b734efc832277f0db75c9fa99e24..7c547301c7314b66406f851c734aa210cb84ff90 100755 (executable)
--- a/bin/heat
+++ b/bin/heat
@@ -17,6 +17,7 @@ import time
 import json
 import base64
 import libxml2
+import re
 
 from urlparse import urlparse
 # If ../heat/__init__.py exists, add ../ to Python search path, so that
@@ -249,34 +250,35 @@ def jeos_create(options, arguments):
     arch = arguments.pop(0)
     instance_type = arguments.pop(0)
 
-    if not arch in ['x86_64', 'i686']:
+    arches = ('x86_64', 'i386', 'amd64')
+    arches_str = " | ".join(arches)
+    instance_types = ('gold', 'cfntools')
+    instances_str = " | ".join(instance_types)
+
+    if not arch in arches:
         print 'arch %s not supported' % arch
-        print 'try: x86_64 or i686'
+        print 'try: heat jeos_create %s [ %s ]' % (distro, arches_str)
         sys.exit(1)
 
-    if not instance_type in ('gold', 'cfntools'):
+    if not instance_type in instance_types:
         print 'A JEOS instance type of %s not supported' % instance_type
-        print 'try: gold or cfntools'
+        print 'try: heat jeos_create %s %s [ %s ]' % (distro, arch, instances_str)
         sys.exit(1)
 
-    iso = None
-    if distro == 'F16':
-        iso = '/var/lib/libvirt/images/Fedora-16-x86_64-DVD.iso'
-    elif distro == 'F15':
-        iso = '/var/lib/libvirt/images/Fedora-15-x86_64-DVD.iso'
-    elif distro == 'F17':
-        iso = '/var/lib/libvirt/images/Fedora-17-x86_64-DVD.iso'
+    fedora_match = re.match('F(1[6-7])', distro)
+    if fedora_match:
+        version = fedora_match.group(1)
+        iso = '/var/lib/libvirt/images/Fedora-%s-%s-DVD.iso' % (version, arch)
     elif distro == 'U10':
-        iso = '/var/lib/libvirt/images/ubuntu-10.04.3-server-amd64.iso'
+        iso = '/var/lib/libvirt/images/ubuntu-10.04.3-server-%s.iso' % arch
     else:
         print 'distro %s not supported' % distro
-        print 'try: F15, F16, F17 or U10'
+        print 'try: F16, F17 or U10'
         sys.exit(1)
 
-    if iso:
-        if not os.access(iso, os.R_OK):
-            print '*** %s does not exist.' % (iso)
-            sys.exit(1)
+    if not os.access(iso, os.R_OK):
+        print '*** %s does not exist.' % (iso)
+        sys.exit(1)
 
     tdl_path = '%s%s-%s-%s-jeos.tdl' % (jeos_path, distro, arch, instance_type)
 
index f84734b0bbd6a171cb62a8f562bd40cfe23a9740..8b94492bfc6fd1cc1f84624e4e874444619d9cb0 100644 (file)
@@ -392,6 +392,7 @@ class Instance(Resource):
                 image_id = o.id
 
         if image_id is None:
+            print "Image %s was not found in glance" % image_name
             raise exception.ImageNotFound(image_name=image_name)
 
         flavor_list = self.nova().flavors.list()
diff --git a/heat/jeos/F16-i386-cfntools-jeos.tdl b/heat/jeos/F16-i386-cfntools-jeos.tdl
new file mode 100644 (file)
index 0000000..656a741
--- /dev/null
@@ -0,0 +1,61 @@
+<template>
+  <name>F16-i386-cfntools-jeos</name>
+  <os>
+    <name>Fedora</name>
+    <version>16</version>
+    <arch>i386</arch>
+    <install type='iso'>
+      <iso>file:/var/lib/libvirt/images/Fedora-16-i386-DVD.iso</iso>
+    </install>
+    <rootpw>password</rootpw>
+  </os>
+  <description>Fedora 16</description>
+  <commands>
+    <command name='commands'>
+yum -y update --skip-broken;yum -y install cloud-init;cat >> /etc/rc.d/rc.local &lt;&lt; EOF;chmod +x /etc/rc.d/rc.local
+#!/bin/bash
+setenforce 0
+while true; do
+gdbus introspect --system --dest org.freedesktop.NetworkManager --object-path /org/freedesktop/NetworkManager/Devices/0 | grep "State = 100"
+if [ \$? -eq 0 ]
+then
+break
+fi
+sleep 1
+done
+
+if [ ! -d /root/.ssh ]; then
+  mkdir -p /root/.ssh
+  chmod 700 /root/.ssh
+fi
+# Fetch public key using HTTP
+ATTEMPTS=10
+while [ ! -f /root/.ssh/authorized_keys ]; do
+    curl -f http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key > /tmp/aws-key 2>/dev/null
+    if [ \$? -eq 0 ]; then
+        cat /tmp/aws-key >> /root/.ssh/authorized_keys
+        chmod 0600 /root/.ssh/authorized_keys
+        restorecon /root/.ssh/authorized_keys
+        rm -f /tmp/aws-key
+        echo "Successfully retrieved AWS public key from instance metadata"
+    else
+        FAILED=\$((\$FAILED + 1))
+        if [ \$FAILED -ge \$ATTEMPTS ]; then
+            echo "Failed to retrieve AWS public key after \$FAILED attempts, quitting"
+            break
+        fi
+        echo "Could not retrieve AWS public key (attempt #\$FAILED/\$ATTEMPTS), retrying in 5 seconds..."
+        sleep 5
+    fi
+done
+chmod +x /opt/aws/bin/cfn-*
+EOF
+    </command>
+  </commands>
+  <files>
+    <file name='/opt/aws/bin/cfn-init'  type='base64'></file>
+    <file name='/opt/aws/bin/cfn-hup'  type='base64'></file>
+    <file name='/opt/aws/bin/cfn-signal'  type='base64'></file>
+  </files>
+</template>
diff --git a/heat/jeos/F16-i386-gold-jeos.tdl b/heat/jeos/F16-i386-gold-jeos.tdl
new file mode 100644 (file)
index 0000000..1856485
--- /dev/null
@@ -0,0 +1,61 @@
+<template>
+  <name>F16-i386-gold-jeos</name>
+  <os>
+    <name>Fedora</name>
+    <version>16</version>
+    <arch>i386</arch>
+    <install type='iso'>
+      <iso>file:/var/lib/libvirt/images/Fedora-16-i386-DVD.iso</iso>
+    </install>
+    <rootpw>password</rootpw>
+  </os>
+  <description>Fedora 16</description>
+  <commands>
+    <command name='commands'>
+rm -f /etc/yum.repos.d/fedora-updates*;yum -y install cloud-init;cat >> /etc/rc.d/rc.local &lt;&lt; EOF;chmod +x /etc/rc.d/rc.local
+#!/bin/bash
+setenforce 0
+while true; do
+gdbus introspect --system --dest org.freedesktop.NetworkManager --object-path /org/freedesktop/NetworkManager/Devices/0 | grep "State = 100"
+if [ \$? -eq 0 ]
+then
+break
+fi
+sleep 1
+done
+
+if [ ! -d /root/.ssh ]; then
+  mkdir -p /root/.ssh
+  chmod 700 /root/.ssh
+fi
+# Fetch public key using HTTP
+ATTEMPTS=10
+while [ ! -f /root/.ssh/authorized_keys ]; do
+    curl -f http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key > /tmp/aws-key 2>/dev/null
+    if [ \$? -eq 0 ]; then
+        cat /tmp/aws-key >> /root/.ssh/authorized_keys
+        chmod 0600 /root/.ssh/authorized_keys
+        restorecon /root/.ssh/authorized_keys
+        rm -f /tmp/aws-key
+        echo "Successfully retrieved AWS public key from instance metadata"
+    else
+        FAILED=\$((\$FAILED + 1))
+        if [ \$FAILED -ge \$ATTEMPTS ]; then
+            echo "Failed to retrieve AWS public key after \$FAILED attempts, quitting"
+            break
+        fi
+        echo "Could not retrieve AWS public key (attempt #\$FAILED/\$ATTEMPTS), retrying in 5 seconds..."
+        sleep 5
+    fi
+done
+while [ ! -f /var/lib/cloud/instance/user-data.txt ]; do
+        sleep 1
+done
+base64 -d /var/lib/cloud/instance/user-data.txt > /tmp/startup
+chmod +x /tmp/startup
+/tmp/startup
+EOF
+    </command>
+  </commands>
+</template>
diff --git a/heat/jeos/F17-i386-cfntools-jeos.tdl b/heat/jeos/F17-i386-cfntools-jeos.tdl
new file mode 100644 (file)
index 0000000..78310a9
--- /dev/null
@@ -0,0 +1,61 @@
+<template>
+  <name>F17-i386-cfntools-jeos</name>
+  <os>
+    <name>Fedora</name>
+    <version>17</version>
+    <arch>i386</arch>
+    <install type='iso'>
+      <iso>file:/var/lib/libvirt/images/Fedora-17-i386-DVD.iso</iso>
+    </install>
+    <rootpw>password</rootpw>
+  </os>
+  <description>Fedora 17</description>
+  <commands>
+    <command name='commands'>
+yum -y update --skip-broken;yum -y install cloud-init;cat >> /etc/rc.d/rc.local &lt;&lt; EOF;chmod +x /etc/rc.d/rc.local
+#!/bin/bash
+setenforce 0
+while true; do
+gdbus introspect --system --dest org.freedesktop.NetworkManager --object-path /org/freedesktop/NetworkManager/Devices/0 | grep "State = 100"
+if [ \$? -eq 0 ]
+then
+break
+fi
+sleep 1
+done
+
+if [ ! -d /root/.ssh ]; then
+  mkdir -p /root/.ssh
+  chmod 700 /root/.ssh
+fi
+# Fetch public key using HTTP
+ATTEMPTS=10
+while [ ! -f /root/.ssh/authorized_keys ]; do
+    curl -f http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key > /tmp/aws-key 2>/dev/null
+    if [ \$? -eq 0 ]; then
+        cat /tmp/aws-key >> /root/.ssh/authorized_keys
+        chmod 0600 /root/.ssh/authorized_keys
+        restorecon /root/.ssh/authorized_keys
+        rm -f /tmp/aws-key
+        echo "Successfully retrieved AWS public key from instance metadata"
+    else
+        FAILED=\$((\$FAILED + 1))
+        if [ \$FAILED -ge \$ATTEMPTS ]; then
+            echo "Failed to retrieve AWS public key after \$FAILED attempts, quitting"
+            break
+        fi
+        echo "Could not retrieve AWS public key (attempt #\$FAILED/\$ATTEMPTS), retrying in 5 seconds..."
+        sleep 5
+    fi
+done
+chmod +x /opt/aws/bin/cfn-*
+EOF
+    </command>
+  </commands>
+  <files>
+    <file name='/opt/aws/bin/cfn-init'  type='base64'></file>
+    <file name='/opt/aws/bin/cfn-hup'  type='base64'></file>
+    <file name='/opt/aws/bin/cfn-signal'  type='base64'></file>
+  </files>
+</template>
diff --git a/heat/jeos/F17-i386-gold-jeos.tdl b/heat/jeos/F17-i386-gold-jeos.tdl
new file mode 100644 (file)
index 0000000..13c14b8
--- /dev/null
@@ -0,0 +1,61 @@
+<template>
+  <name>F17-i386-gold-jeos</name>
+  <os>
+    <name>Fedora</name>
+    <version>17</version>
+    <arch>i386</arch>
+    <install type='iso'>
+      <iso>file:/var/lib/libvirt/images/Fedora-17-i386-DVD.iso</iso>
+    </install>
+    <rootpw>password</rootpw>
+  </os>
+  <description>Fedora 17</description>
+  <commands>
+    <command name='commands'>
+rm -f /etc/yum.repos.d/fedora-updates*;yum -y install cloud-init;cat >> /etc/rc.d/rc.local &lt;&lt; EOF;chmod +x /etc/rc.d/rc.local
+#!/bin/bash
+setenforce 0
+while true; do
+gdbus introspect --system --dest org.freedesktop.NetworkManager --object-path /org/freedesktop/NetworkManager/Devices/0 | grep "State = 100"
+if [ \$? -eq 0 ]
+then
+break
+fi
+sleep 1
+done
+
+if [ ! -d /root/.ssh ]; then
+  mkdir -p /root/.ssh
+  chmod 700 /root/.ssh
+fi
+# Fetch public key using HTTP
+ATTEMPTS=10
+while [ ! -f /root/.ssh/authorized_keys ]; do
+    curl -f http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key > /tmp/aws-key 2>/dev/null
+    if [ \$? -eq 0 ]; then
+        cat /tmp/aws-key >> /root/.ssh/authorized_keys
+        chmod 0600 /root/.ssh/authorized_keys
+        restorecon /root/.ssh/authorized_keys
+        rm -f /tmp/aws-key
+        echo "Successfully retrieved AWS public key from instance metadata"
+    else
+        FAILED=\$((\$FAILED + 1))
+        if [ \$FAILED -ge \$ATTEMPTS ]; then
+            echo "Failed to retrieve AWS public key after \$FAILED attempts, quitting"
+            break
+        fi
+        echo "Could not retrieve AWS public key (attempt #\$FAILED/\$ATTEMPTS), retrying in 5 seconds..."
+        sleep 5
+    fi
+done
+while [ ! -f /var/lib/cloud/instance/user-data.txt ]; do
+        sleep 1
+done
+base64 -d /var/lib/cloud/instance/user-data.txt > /tmp/startup
+chmod +x /tmp/startup
+/tmp/startup
+EOF
+    </command>
+  </commands>
+</template>
index bd031c3a9ea6c87166d87c84f9bd1ec17fec7c7f..1f5fe37234b2352a5e9e0e86daa5deb82ac15f4a 100644 (file)
       "cc1.4xlarge" : { "Arch" : "64" }
     },
     "DistroArch2AMI": {
-      "F16"      : { "32" : "F16-i686", "64" : "F16-x86_64-gold" },
-      "F17"      : { "32" : "F17-i686", "64" : "F17-x86_64-gold" },
-      "U10"      : { "32" : "U10-i686", "64" : "U10-x86_64-gold" },
-      "RHEL-6.1" : { "32" : "rhel61-i686", "64" : "rhel61-x86_64-gold" },
-      "RHEL-6.2" : { "32" : "rhel62-i686", "64" : "rhel62-x86_64-gold" },
-      "RHEL-6.3" : { "32" : "rhel63-i686", "64" : "rhel63-x86_64-gold" }
+      "F16"      : { "32" : "F16-i386-gold", "64" : "F16-x86_64-gold" },
+      "F17"      : { "32" : "F17-i386-gold", "64" : "F17-x86_64-gold" },
+      "U10"      : { "32" : "U10-i386-gold", "64" : "U10-x86_64-gold" },
+      "RHEL-6.1" : { "32" : "rhel61-i386-gold", "64" : "rhel61-x86_64-gold" },
+      "RHEL-6.2" : { "32" : "rhel62-i386-gold", "64" : "rhel62-x86_64-gold" },
+      "RHEL-6.3" : { "32" : "rhel63-i386-gold", "64" : "rhel63-x86_64-gold" }
     }
   },
 
index 8401d072569721721bb93f4737a2db174346f25b..986bec2044163aab91ecdfef0ad4d04ff6dcc39b 100644 (file)
       "cc1.4xlarge" : { "Arch" : "64" }
     },
     "DistroArch2AMI": {
-      "F16"      : { "32" : "F16-i686", "64" : "F16-x86_64-gold" },
-      "F17"      : { "32" : "F17-i686", "64" : "F17-x86_64-gold" },
-      "U10"      : { "32" : "U10-i686", "64" : "U10-x86_64-gold" },
-      "RHEL-6.1" : { "32" : "rhel61-i686", "64" : "rhel61-x86_64-gold" },
-      "RHEL-6.2" : { "32" : "rhel62-i686", "64" : "rhel62-x86_64-gold" },
-      "RHEL-6.3" : { "32" : "rhel63-i686", "64" : "rhel63-x86_64-gold" }
+      "F16"      : { "32" : "F16-i386-gold", "64" : "F16-x86_64-gold" },
+      "F17"      : { "32" : "F17-i386-gold", "64" : "F17-x86_64-gold" },
+      "U10"      : { "32" : "U10-i386-gold", "64" : "U10-x86_64-gold" },
+      "RHEL-6.1" : { "32" : "rhel61-i386-gold", "64" : "rhel61-x86_64-gold" },
+      "RHEL-6.2" : { "32" : "rhel62-i386-gold", "64" : "rhel62-x86_64-gold" },
+      "RHEL-6.3" : { "32" : "rhel63-i386-gold", "64" : "rhel63-x86_64-gold" }
     }
   },
 
index 2102c969c679190e383483a0c8e4c5267cc8fa63..b3d06afecf6e99ee9d8d212e8d9ce94c51584058 100644 (file)
       "cc1.4xlarge" : { "Arch" : "64" }
     },
     "DistroArch2AMI": {
-      "F16"      : { "32" : "F16-i686", "64" : "F16-x86_64-gold" },
-      "F17"      : { "32" : "F17-i686", "64" : "F17-x86_64-gold" },
-      "U10"      : { "32" : "U10-i686", "64" : "U10-x86_64-gold" },
-      "RHEL-6.1" : { "32" : "rhel61-i686", "64" : "rhel61-x86_64-gold" },
-      "RHEL-6.2" : { "32" : "rhel62-i686", "64" : "rhel62-x86_64-gold" },
-      "RHEL-6.3" : { "32" : "rhel63-i686", "64" : "rhel63-x86_64-gold" }
+      "F16"      : { "32" : "F16-i386-gold", "64" : "F16-x86_64-gold" },
+      "F17"      : { "32" : "F17-i386-gold", "64" : "F17-x86_64-gold" },
+      "U10"      : { "32" : "U10-i386-gold", "64" : "U10-x86_64-gold" },
+      "RHEL-6.1" : { "32" : "rhel61-i386-gold", "64" : "rhel61-x86_64-gold" },
+      "RHEL-6.2" : { "32" : "rhel62-i386-gold", "64" : "rhel62-x86_64-gold" },
+      "RHEL-6.3" : { "32" : "rhel63-i386-gold", "64" : "rhel63-x86_64-gold" }
     }
   },
 
index 829119d9dd6dc5fcf7d963cc6f14078121b7b635..f14141d280dc303a5de45d5996919a1e84b98374 100644 (file)
       "cc1.4xlarge" : { "Arch" : "64" }
     },
     "DistroArch2AMI": {
-      "F16"      : { "32" : "F16-i686", "64" : "F16-x86_64-gold" },
-      "F17"      : { "32" : "F17-i686", "64" : "F17-x86_64-gold" },
-      "U10"      : { "32" : "U10-i686", "64" : "U10-x86_64-gold" },
-      "RHEL-6.1" : { "32" : "rhel61-i686", "64" : "rhel61-x86_64-gold" },
-      "RHEL-6.2" : { "32" : "rhel62-i686", "64" : "rhel62-x86_64-gold" },
-      "RHEL-6.3" : { "32" : "rhel63-i686", "64" : "rhel63-x86_64-gold" }
+      "F16"      : { "32" : "F16-i386-gold", "64" : "F16-x86_64-gold" },
+      "F17"      : { "32" : "F17-i386-gold", "64" : "F17-x86_64-gold" },
+      "U10"      : { "32" : "U10-i386-gold", "64" : "U10-x86_64-gold" },
+      "RHEL-6.1" : { "32" : "rhel61-i386-gold", "64" : "rhel61-x86_64-gold" },
+      "RHEL-6.2" : { "32" : "rhel62-i386-gold", "64" : "rhel62-x86_64-gold" },
+      "RHEL-6.3" : { "32" : "rhel63-i386-gold", "64" : "rhel63-x86_64-gold" }
     }
   },
 
index b9cd87700090d69339b2a9296592690338bef5f2..895f0d7042736303b2c57b82ed6e93b64c099c7d 100644 (file)
       "cc1.4xlarge" : { "Arch" : "64" }
     },
     "DistroArch2AMI": {
-      "F16"      : { "32" : "F16-i686", "64" : "F16-x86_64-cfntools" },
-      "F17"      : { "32" : "F17-i686", "64" : "F17-x86_64-cfntools" },
-      "U10"      : { "32" : "U10-i686", "64" : "U10-x86_64-cfntools" },
-      "RHEL-6.1" : { "32" : "rhel61-i686", "64" : "rhel61-x86_64-cfntools" },
-      "RHEL-6.2" : { "32" : "rhel62-i686", "64" : "rhel62-x86_64-cfntools" },
-      "RHEL-6.3" : { "32" : "rhel63-i686", "64" : "rhel63-x86_64-cfntools" }
+      "F16"      : { "32" : "F16-i386-cfntools", "64" : "F16-x86_64-cfntools" },
+      "F17"      : { "32" : "F17-i386-cfntools", "64" : "F17-x86_64-cfntools" },
+      "U10"      : { "32" : "U10-i386-cfntools", "64" : "U10-x86_64-cfntools" },
+      "RHEL-6.1" : { "32" : "rhel61-i386-cfntools", "64" : "rhel61-x86_64-cfntools" },
+      "RHEL-6.2" : { "32" : "rhel62-i386-cfntools", "64" : "rhel62-x86_64-cfntools" },
+      "RHEL-6.3" : { "32" : "rhel63-i386-cfntools", "64" : "rhel63-x86_64-cfntools" }
     }
   },