Bug 807851 - Need to document "examples" directory for Config Server
Summary: Need to document "examples" directory for Config Server
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: CloudForms Cloud Engine
Classification: Retired
Component: Documentation
Version: 1.0.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
Assignee: Dan Macpherson
QA Contact: wes hayutin
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-03-28 22:20 UTC by Greg Blomquist
Modified: 2012-06-07 06:22 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-06-07 06:22:26 UTC
Embargoed:


Attachments (Terms of Use)

Description Greg Blomquist 2012-03-28 22:20:23 UTC
Description of problem:

We just added a new feature for https://bugzilla.redhat.com/show_bug.cgi?id=807473.  It adds a new directory called "examples" to all config servers accessible at:

https://<config_server_url>/examples

The first example being delivered will be a deployable that launches a single guest and connects it back to a Katello server.

Information should be added to the Aeolus Config Server documentation to expose this new directory to users.

Comment 2 Greg Blomquist 2012-04-12 13:41:43 UTC
Final version of the katello register deployable:

https://github.com/aeolusproject/audrey/blob/1.0/configserver/examples/katello-register.xml

Comment 4 wes hayutin 2012-04-17 17:33:30 UTC
[root@cloudEngine-audrey yum.repos.d]# cd /usr/share/aeolus-configserver/examples
[root@cloudEngine-audrey examples]# ls
katello-register.xml
[root@cloudEngine-audrey examples]# cat katello-register.xml 
<?xml version="1.0"?>
<!--
Author: James Laska
Author: Greg Blomquist

Notes:
This deployable handles registering and subscribing a guest to content hosted by
Katello.  The launched guest must be able to access the katello server over the
available network.

Prerequisites:
  * a running katello server
  * a running conductor server
  * a running audrey config server, configured in conductor for a provider
    account
  * an image built from a template containing the aeolus-audrey-agent and
    katello-agent RPMs

Instructions:
  * replace the "FIXME" image id with the ID of the image containing
    aeolus-audrey-agent and katello-agent RPMs
  * import this application blueprint into conductor and launch
  * provide the correct launch time values for:
    - Import Beta Key
      - whether or not the rhel beta gpg key should be imported
    - Katello Host
      - the hostname where katello is running
    - Katello Port
      - the port where katello is listening
    - Katello Org
      - the configured katello org
    - Katello Env
      - the configured katello environment
    - Katello User
      - the katello username
    - Katello Pass
      - the katello password
    - Auto Subscribe
      - whether or not the guest should auto subscribe to katello
        - "True" or "False"
    - Activation Key
      - the activation key to use for subscribing to katello, or None
    * NOTE: "Auto Subscribe" and "Activation Key" are mutually exclusive;
      - if "Auto Subscribe" is True, then "Activation Key" should be None
      - if "Auto Subscribe" is False, then "Activation Key" should contain the
        activation key
  * finish launching the guest in conductor
-->
<deployable name="Katello-Register">
  <description>This is a sample deployment that registers and subscribes to
  content hosted by katello.</description>
  <assemblies>
    <assembly name="client" hwp="hwp1">
      <image id="FIXME" />
      <services>
        <service name="GPG_KEY_IMPORT">
          <executable>
            <contents><![CDATA[#!/bin/bash

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
echo ${AUDREY_VAR_GPG_KEY_IMPORT_IMPORT_BETA_KEY:=False}
if [[ $AUDREY_VAR_GPG_KEY_IMPORT_IMPORT_BETA_KEY == [Tt][Rr][Uu][Ee] ]]; then
  rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta
fi
            ]]></contents>
          </executable>
          <parameters>
            <parameter name="IMPORT_BETA_KEY" type="scalar">
              <value>True</value>
            </parameter>
          </parameters>
        </service>
        <service name="RHEL_PRODUCT_CERT">
          <executable>
            <contents><![CDATA[#!/usr/bin/python
import os
import re
import sys
import subprocess
import shutil
from ConfigParser import ConfigParser
from string import Template

def s_format(s, dct):
    if hasattr(s, 'format'):
        return s.format(**dct)
    else:
        # convert python-2.6 format to something 2.4 can handle
        return Template(re.sub(r'{([^}]+)}', '$\\1', s)).substitute(dct)

def run(cmd):
    if isinstance(cmd, str):
        cmd = cmd.split()
    p_open = subprocess.Popen(cmd,
                    stdout=subprocess.PIPE,
                    stderr=subprocess.STDOUT)
    (stdout, stderr) = p_open.communicate()
    if p_open.returncode != 0:
        print "Error: command failed (%s) - %s" % (p_open.returncode, stdout)
        sys.exit(p_open.returncode)
    return stdout

def is_ec2_deployment():
    '''Returns boolean True of False to indicate whether the current system is
       an ec2 image'''
    # Disable any rhui repos on ec2 hosts
    if os.path.isfile('/etc/yum.repos.d/redhat-rhui.repo'):
        cmd = s_format('yum-config-manager --disable rhui-*', os.environ)
        run(cmd)

    cmd = 'curl --silent http://169.254.169.254/latest/dynamic/instance-identity/document'
    return subprocess.call(cmd.split()) == 0

os.chdir('/var/audrey/tooling/user/RHEL_PRODUCT_CERT')

# If running as an ec2 deployment, and no product cert is defined ... create one
if is_ec2_deployment() and not os.path.isfile('/etc/pki/product/69.pem') and os.path.isfile('69.pem'):
    if not os.path.isdir('/etc/pki/product'):
        os.mkdir('/etc/pki/product')
    shutil.copy('69.pem', '/etc/pki/product/69.pem')]]></contents>
          </executable>
          <files>
            <file>
              <contents filename="69.pem"><![CDATA[
-----BEGIN CERTIFICATE-----
MIIGDTCCA/WgAwIBAgIJALDxRLt/tUszMA0GCSqGSIb3DQEBBQUAMIGuMQswCQYD
VQQGEwJVUzEXMBUGA1UECAwOTm9ydGggQ2Fyb2xpbmExFjAUBgNVBAoMDVJlZCBI
YXQsIEluYy4xGDAWBgNVBAsMD1JlZCBIYXQgTmV0d29yazEuMCwGA1UEAwwlUmVk
IEhhdCBFbnRpdGxlbWVudCBQcm9kdWN0IEF1dGhvcml0eTEkMCIGCSqGSIb3DQEJ
ARYVY2Etc3VwcG9ydEByZWRoYXQuY29tMB4XDTExMTEwODE1NDYyNFoXDTMxMTEw
MzE1NDYyNFowRDFCMEAGA1UEAww5UmVkIEhhdCBQcm9kdWN0IElEIFsyMGM3MWU4
Ni1iZjA4LTRlZjYtYTAxYS1lYzQ0MDRkNzIyODZdMIICIjANBgkqhkiG9w0BAQEF
AAOCAg8AMIICCgKCAgEAxj9J04z+Ezdyx1U33kFftLv0ntNS1BSeuhoZLDhs18yk
sepG7hXXtHh2CMFfLZmTjAyL9i1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e8sB
niCqWaGWXq/cG6+KSQkADvxQXqBLIf/BG7zXnjeg7CwfDItWdca1fJBLh3WZTAdc
d90Jhn5IUqwPWf6nupuyAFcxLcMHvn+7/x6sbUz7sdNJfUx/WnU52OqsuM/03wqn
b449m8INeGCoa7yZdSQlcnH6UWLeKnrnhk/81Rrv265Q044dxzUA+aMJPn0ZFXIj
76ot5agNeCEtZyKWptOR7to6gQutD4It8siqR2L2TK8eNcFxJVFSuenMjScoppJo
WsK6OXGdxJA2PLpSSm0vJtFrLdjt3NnoMXHTi7HmldC1HLMLGEg/QNDdesdZcLBE
AI2X5TrH/24IpBKtT+y/lImchb9INSsFJa29SSCrTFKLOc8aGvlb4nidHhRgFOzO
fT34E8euLKc0d3pznxL/W8M/JsLF7abe3pijcvY0wGp9LHit2qeCJMWWdv6OKZMK
8DbQo0gvmAQZGuMI459xDTA=
-----END CERTIFICATE-----
            ]]></contents>
            </file>
         </files>
        </service>
        <service name="KATELLO_REGISTER">
          <executable>
            <contents><![CDATA[#!/usr/bin/python

import os
import sys
import re
import subprocess
import shutil
from ConfigParser import ConfigParser
from string import Template

def s_format(s, dct):
    if hasattr(s, 'format'):
        return s.format(**dct)
    else:
        # convert python-2.6 format to something 2.4 can handle
        return Template(re.sub(r'{([^}]+)}', '$\\1', s)).substitute(dct)


def run(cmd):
    if isinstance(cmd, str):
        cmd = cmd.split()
    p_open = subprocess.Popen(cmd,
                    stdout=subprocess.PIPE,
                    stderr=subprocess.STDOUT)
    (stdout, stderr) = p_open.communicate()
    if p_open.returncode != 0:
        print "Error: command failed (%s) - %s" % (p_open.returncode, stdout)
        sys.exit(p_open.returncode)
    return stdout


def subscription_manager_version():
    sm_rpm_ver = run('rpm -q --queryformat %{VERSION} subscription-manager')
    sm_ver_maj, sm_ver_min, sm_ver_rest = sm_rpm_ver.split(".", 2)
    return int(sm_ver_maj), int(sm_ver_min)


def audrey_var(name, default=None):
    return os.environ.get("AUDREY_VAR_KATELLO_REGISTER_%s" % name, default)


def setup_releasever():
    fp = open("/etc/yum/vars/releasever", "r+")
    fp.write(audrey_var("RELEASEVER"))
    fp.close()


def register_katello_command():
    org = audrey_var("KATELLO_ORG")
    activation_key = audrey_var("ACTIVATION_KEY", "").strip()
    auto_subscribe = audrey_var("AUTO_SUBSCRIBE", "false").lower() == "true"
    username = audrey_var("KATELLO_USER")
    password = audrey_var("KATELLO_PASS")
    kat_env = audrey_var("KATELLO_ENV")
    sm_ver_maj, sm_ver_min = subscription_manager_version()

    cmd = "subscription-manager register --force"
    cmd += " --org=%s" % org

    if sm_ver_maj <= 0:
        if sm_ver_min < 96:
            if auto_subscribe:
                cmd += " --username=%s --password=%s" % (username, password)
                cmd += " --autosubscribe"
            elif activation_key != "" and sm_ver_min >= 95:
                cmd += " --activationkey=%s" % activation_key
            else:
                pass # determine and print error condition to stdout
        else:
            if auto_subscribe:
                cmd += " --username=%s --password=%s" % (username, password)
                cmd += " --env=%s" % kat_env
                cmd += " --autosubscribe"
            elif activation_key != "":
                cmd += " --activationkey=%s" % activation_key
            else:
                pass # determine and print error condition to stdout
    return cmd

# If requested, customize the yum $releasever
if not audrey_var("RELEASEVER", "Default").lower() in ["", "default"]:
    setup_releasever()

# FIXME - Installing using yum on a system with no enabled repos will remove
# product cert. Until bug#806457 is fixed, install using the 'rpm' command.
# cmd = "yum -y install %s" % cert_rpm
cert_rpm = s_format("http://{AUDREY_VAR_KATELLO_REGISTER_KATELLO_HOST}/pub/candlepin-cert-consumer-{AUDREY_VAR_KATELLO_REGISTER_KATELLO_HOST}-1.0-1.noarch.rpm", os.environ)
cmd = "rpm -ivh %s" % cert_rpm
run(cmd)

cmd = register_katello_command()
print run(cmd)]]>
            </contents>
          </executable>
          <parameters>
            <parameter name="KATELLO_HOST" type="scalar">
              <value></value>
            </parameter>
            <parameter name="KATELLO_PORT" type="scalar">
              <value></value>
            </parameter>
            <parameter name="KATELLO_ORG" type="scalar">
              <value></value>
            </parameter>
            <parameter name="KATELLO_ENV" type="scalar">
              <value></value>
            </parameter>
            <parameter name="KATELLO_USER" type="scalar">
              <value></value>
            </parameter>
            <parameter name="KATELLO_PASS" type="password">
              <value></value>
            </parameter>
            <parameter name="RELEASEVER" type="scalar">
              <value>Default</value>
            </parameter>
            <parameter name="AUTO_SUBSCRIBE" type="scalar">
              <value>True</value>
            </parameter>
            <parameter name="ACTIVATION_KEY" type="scalar">
              <value>None</value>
            </parameter>
          </parameters>
        </service>
      </services>
    </assembly>
  </assemblies>
</deployable>

[root@cloudEngine-audrey examples]# rpm -qa | grep aeolus
aeolus-rhevm_config_server-0.3.1-0.el6.noarch
aeolus-configserver-0.4.7-1.el6.noarch
[root@cloudEngine-audrey examples]#

Comment 5 Lana Brindley 2012-06-07 06:22:26 UTC
Document is now available on docs.redhat.com. Please raise a new bug for any further issues.

LKB


Note You need to log in before you can comment on or make changes to this bug.