<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Soumplis&#039; Personal Web Site &#187; Spacewalk</title>
	<atom:link href="http://www.soumplis.com/category/linux/spacewalk/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.soumplis.com</link>
	<description>Soumplis Alexandros Personal Web Site</description>
	<lastBuildDate>Mon, 16 Jan 2012 23:16:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Spacewalk Channel Creation</title>
		<link>http://www.soumplis.com/2010/06/09/spacewalk-channel-creation/</link>
		<comments>http://www.soumplis.com/2010/06/09/spacewalk-channel-creation/#comments</comments>
		<pubDate>Wed, 09 Jun 2010 12:42:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Spacewalk]]></category>

		<guid isPermaLink="false">http://www.soumplis.com/?p=77</guid>
		<description><![CDATA[After a long time watching closely the evolution of Spacewalk (you know, the open source Redhat Satellite server), I decided to move on to its version 1.0. I have a working installation with more than 40 clients since version 0.2 and I followed all upgrades until version 0.8. At some time there I decided to [...]]]></description>
			<content:encoded><![CDATA[<p>After a long time watching closely the evolution of Spacewalk (you know, the open source Redhat Satellite server), I decided to move on to its version 1.0. I have a working installation with more than 40 clients since version 0.2 and I followed all upgrades until version 0.8. At some time there I decided to wait for version 1.0 to move to a new server with adequate resources to handle the load. I must admit that I had a secret hope of not installing Oracle again.</p>
<p>I proceeded to the installation as per the spacewalk instructions and everything went smoothly. The I wanted to create my software channel. The plan is to create a Base channel of every  CentOS and Redhat Update release  and then have additional repos as child channels for each. This created a need for almost 20 channels with tens of clicks and repeated input. Ok, I can&#8217;t do it&#8230; I am not a Windows admin thus I hate anything that has to be completed with more than 2-3 clicks&#8230; Time for scripting!</p>
<p>I have downloaded the extended_create_channel.py from <a href="https://fedorahosted.org/spacewalk/wiki/UploadFedoraContent" target="_blank">Spacewalk Wiki</a> in order to use it in a simple bash script. For my disappointment it created channels without essential data such as the GPG keys and Yum Repositories information. It was high time for me to refresh my python to extend the script. The script is here and I believe is quite self explained.</p>
<div class="codecolorer-container python blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span><br />
<span style="color: #808080; font-style: italic;">#</span><br />
<span style="color: #808080; font-style: italic;"># Copyright (c) 2008 Red Hat, Inc.</span><br />
<span style="color: #808080; font-style: italic;">#</span><br />
<span style="color: #808080; font-style: italic;"># This software is licensed to you under the GNU General Public License,</span><br />
<span style="color: #808080; font-style: italic;"># version 2 (GPLv2). There is NO WARRANTY for this software, express or</span><br />
<span style="color: #808080; font-style: italic;"># implied, including the implied warranties of MERCHANTABILITY or FITNESS</span><br />
<span style="color: #808080; font-style: italic;"># FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2</span><br />
<span style="color: #808080; font-style: italic;"># along with this software; if not, see</span><br />
<span style="color: #808080; font-style: italic;"># http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.</span><br />
<span style="color: #808080; font-style: italic;">#</span><br />
<span style="color: #808080; font-style: italic;"># Red Hat trademarks are not licensed under GPLv2. No permission is</span><br />
<span style="color: #808080; font-style: italic;"># granted to use or replicate Red Hat trademarks that are incorporated</span><br />
<span style="color: #808080; font-style: italic;"># in this software or its documentation.</span><br />
<span style="color: #808080; font-style: italic;">#</span><br />
<span style="color: #808080; font-style: italic;"># Note: Alexandros Soumplis - 09 June 2010</span><br />
<span style="color: #808080; font-style: italic;"># Changes: * Support for GPG info definition</span><br />
<span style="color: #808080; font-style: italic;"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Support for Yum Repositories definition</span><br />
<span style="color: #808080; font-style: italic;"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Support for Checksum Type definition</span><br />
<span style="color: #808080; font-style: italic;"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Command Line Arguments Error Handling</span><br />
<span style="color: #808080; font-style: italic;"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Comments and beautification of code</span><br />
<span style="color: #808080; font-style: italic;">#</span><br />
<span style="color: #808080; font-style: italic;"># Note: by JonW 3/7/08</span><br />
<span style="color: #808080; font-style: italic;"># I have extended the original script to include arch and parent channels</span><br />
<span style="color: #808080; font-style: italic;"># to allow child channels to be created by this script.</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">struct</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">xmlrpclib</span><br />
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">optparse</span> <span style="color: #ff7700;font-weight:bold;">import</span> OptionParser<br />
<br />
<span style="color: #808080; font-style: italic;"># options parsing</span><br />
usage <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">&quot;%prog [options]&quot;</span><br />
<br />
<span style="color: #dc143c;">parser</span> <span style="color: #66cc66;">=</span> OptionParser<span style="color: black;">&#40;</span>usage<span style="color: #66cc66;">=</span>usage<span style="color: #66cc66;">,</span> description<span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#41;</span><br />
<span style="color: #dc143c;">parser</span>.<span style="color: black;">add_option</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;--user&quot;</span><span style="color: #66cc66;">,</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dest<span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;user&quot;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">help</span><span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;Spacewalk user with administrative privileges&quot;</span><span style="color: black;">&#41;</span><br />
<span style="color: #dc143c;">parser</span>.<span style="color: black;">add_option</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;--password&quot;</span><span style="color: #66cc66;">,</span> &nbsp; &nbsp; &nbsp; &nbsp; dest<span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;password&quot;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">help</span><span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;Spacewalk password&quot;</span><span style="color: black;">&#41;</span><br />
<span style="color: #dc143c;">parser</span>.<span style="color: black;">add_option</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;--host&quot;</span><span style="color: #66cc66;">,</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dest<span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;host&quot;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">help</span><span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;Spacewalk hostname&quot;</span><span style="color: black;">&#41;</span><br />
<span style="color: #dc143c;">parser</span>.<span style="color: black;">add_option</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;--label&quot;</span><span style="color: #66cc66;">,</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dest<span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;label&quot;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">help</span><span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;Channel label&quot;</span><span style="color: black;">&#41;</span><br />
<span style="color: #dc143c;">parser</span>.<span style="color: black;">add_option</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;--name&quot;</span><span style="color: #66cc66;">,</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dest<span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;name&quot;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">help</span><span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;Channel name&quot;</span><span style="color: black;">&#41;</span><br />
<span style="color: #dc143c;">parser</span>.<span style="color: black;">add_option</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;--summary&quot;</span><span style="color: #66cc66;">,</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dest<span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;summary&quot;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">help</span><span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;Channel summary&quot;</span><span style="color: black;">&#41;</span><br />
<span style="color: #dc143c;">parser</span>.<span style="color: black;">add_option</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;--parent&quot;</span><span style="color: #66cc66;">,</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dest<span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;parent&quot;</span><span style="color: #66cc66;">,</span> default<span style="color: #66cc66;">=</span><span style="color: #483d8b;">''</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">help</span><span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;Parent channel label&quot;</span><span style="color: black;">&#41;</span><br />
<span style="color: #dc143c;">parser</span>.<span style="color: black;">add_option</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;--arch&quot;</span><span style="color: #66cc66;">,</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dest<span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;arch&quot;</span><span style="color: #66cc66;">,</span> default<span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;channel-ia32&quot;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">help</span><span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;Channel architecture (channel-x86_64, channel-ia32, channel-ia64)&quot;</span><span style="color: black;">&#41;</span><br />
<span style="color: #dc143c;">parser</span>.<span style="color: black;">add_option</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;--gpgurl&quot;</span><span style="color: #66cc66;">,</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dest<span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;gpgurl&quot;</span><span style="color: #66cc66;">,</span> default<span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5&quot;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">help</span><span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;GPG Key Url&quot;</span><span style="color: black;">&#41;</span><br />
<span style="color: #dc143c;">parser</span>.<span style="color: black;">add_option</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;--gpgid&quot;</span><span style="color: #66cc66;">,</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dest<span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;gpgid&quot;</span><span style="color: #66cc66;">,</span> default<span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;E8562897&quot;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">help</span><span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;GPG Key ID&quot;</span><span style="color: black;">&#41;</span><br />
<span style="color: #dc143c;">parser</span>.<span style="color: black;">add_option</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;--gpgfinger&quot;</span><span style="color: #66cc66;">,</span> &nbsp; &nbsp; &nbsp; &nbsp;dest<span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;gpgfinger&quot;</span><span style="color: #66cc66;">,</span> default<span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;473D 66D5 2122 71FD 51CC 17B1 A8A4 47DC E856 2897&quot;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">help</span><span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;GPG Fingerprint&quot;</span><span style="color: black;">&#41;</span><br />
<span style="color: #dc143c;">parser</span>.<span style="color: black;">add_option</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;--checksumType&quot;</span><span style="color: #66cc66;">,</span> &nbsp; &nbsp; dest<span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;checksumType&quot;</span><span style="color: #66cc66;">,</span> default<span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;sha1&quot;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">help</span><span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;Yum Repository Checksum Type&quot;</span><span style="color: black;">&#41;</span><br />
<span style="color: #dc143c;">parser</span>.<span style="color: black;">add_option</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;--yumurl&quot;</span><span style="color: #66cc66;">,</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dest<span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;yumurl&quot;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">help</span><span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;Yum Repository URL&quot;</span><span style="color: black;">&#41;</span><br />
<span style="color: #dc143c;">parser</span>.<span style="color: black;">add_option</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;--yumlabel&quot;</span><span style="color: #66cc66;">,</span> &nbsp; &nbsp; &nbsp; &nbsp; dest<span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;yumlabel&quot;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">help</span><span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;Yum Repository Label&quot;</span><span style="color: black;">&#41;</span><br />
<span style="color: #dc143c;">parser</span>.<span style="color: black;">add_option</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;--yumsync&quot;</span><span style="color: #66cc66;">,</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dest<span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;yumsync&quot;</span><span style="color: #66cc66;">,</span> default<span style="color: #66cc66;">=</span><span style="color: #008000;">True</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">help</span><span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;Yum Repository Sync&quot;</span><span style="color: black;">&#41;</span><br />
<span style="color: #dc143c;">parser</span>.<span style="color: black;">add_option</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;--debug&quot;</span><span style="color: #66cc66;">,</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dest<span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;debug&quot;</span><span style="color: #66cc66;">,</span> default<span style="color: #66cc66;">=</span><span style="color: #008000;">False</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">help</span><span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;Enable debug output&quot;</span><span style="color: black;">&#41;</span><br />
<br />
<span style="color: black;">&#40;</span>options<span style="color: #66cc66;">,</span> terms<span style="color: black;">&#41;</span> <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">parser</span>.<span style="color: black;">parse_args</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Check the mandatory options have been defined</span><br />
mandatories <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;user&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot;password&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot;host&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot;label&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot;name&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot;summary&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot;yumurl&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot;yumlabel&quot;</span><span style="color: black;">&#93;</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> m <span style="color: #ff7700;font-weight:bold;">in</span> mandatories:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> options.<span style="color: #0000cd;">__dict__</span><span style="color: black;">&#91;</span>m<span style="color: black;">&#93;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Required option --%s is missing<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> % m<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #dc143c;">parser</span>.<span style="color: black;">print_help</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #dc143c;">parser</span>.<span style="color: black;">exit</span><span style="color: black;">&#40;</span>-<span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span><br />
<br />
<br />
SPACEWALK_URL <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">&quot;http://%s/rpc/api&quot;</span> % options.<span style="color: black;">host</span><br />
client <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">xmlrpclib</span>.<span style="color: black;">Server</span><span style="color: black;">&#40;</span>SPACEWALK_URL<span style="color: #66cc66;">,</span> verbose<span style="color: #66cc66;">=</span><span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Login to spacewalk server</span><br />
<span style="color: #ff7700;font-weight:bold;">def</span> login<span style="color: black;">&#40;</span>name <span style="color: #66cc66;">=</span> options.<span style="color: #dc143c;">user</span><span style="color: #66cc66;">,</span> password <span style="color: #66cc66;">=</span> options.<span style="color: black;">password</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> client.<span style="color: black;">auth</span>.<span style="color: black;">login</span><span style="color: black;">&#40;</span>name<span style="color: #66cc66;">,</span> password<span style="color: black;">&#41;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Logout from spacewalk server</span><br />
<span style="color: #ff7700;font-weight:bold;">def</span> logout<span style="color: black;">&#40;</span>key<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; client.<span style="color: black;">auth</span>.<span style="color: black;">logout</span><span style="color: black;">&#40;</span>key<span style="color: black;">&#41;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Define the gpgKey value</span><br />
<span style="color: #ff7700;font-weight:bold;">def</span> gpgKey<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; gpgKey <span style="color: #66cc66;">=</span> <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; gpgKey<span style="color: black;">&#91;</span><span style="color: #483d8b;">'url'</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">=</span> options.<span style="color: black;">gpgurl</span><br />
&nbsp; &nbsp; gpgKey<span style="color: black;">&#91;</span><span style="color: #483d8b;">'id'</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">=</span> options.<span style="color: black;">gpgid</span><br />
&nbsp; &nbsp; gpgKey<span style="color: black;">&#91;</span><span style="color: #483d8b;">'fingerprint'</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">=</span> options.<span style="color: black;">gpgfinger</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> gpgKey<br />
<br />
<span style="color: #808080; font-style: italic;"># Define Yum Repository options</span><br />
<span style="color: #ff7700;font-weight:bold;">def</span> yumrepo<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; yum <span style="color: #66cc66;">=</span> <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; yum<span style="color: black;">&#91;</span><span style="color: #483d8b;">'url'</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">=</span> options.<span style="color: black;">yumurl</span><br />
&nbsp; &nbsp; yum<span style="color: black;">&#91;</span><span style="color: #483d8b;">'label'</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">=</span> options.<span style="color: black;">yumlabel</span><br />
&nbsp; &nbsp; yum<span style="color: black;">&#91;</span><span style="color: #483d8b;">'sync'</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #008000;">bool</span><span style="color: black;">&#40;</span>options.<span style="color: black;">yumsync</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> yum<br />
<br />
<span style="color: #808080; font-style: italic;"># Create the software channels</span><br />
<span style="color: #ff7700;font-weight:bold;">def</span> create<span style="color: black;">&#40;</span>key<span style="color: #66cc66;">,</span> label<span style="color: #66cc66;">,</span> name<span style="color: #66cc66;">,</span> summary<span style="color: #66cc66;">,</span> arch <span style="color: #66cc66;">=</span> options.<span style="color: black;">arch</span><span style="color: #66cc66;">,</span> parent <span style="color: #66cc66;">=</span> options.<span style="color: black;">parent</span><span style="color: #66cc66;">,</span> checksumType <span style="color: #66cc66;">=</span> options.<span style="color: black;">checksumType</span><span style="color: #66cc66;">,</span> gpg <span style="color: #66cc66;">=</span> gpgKey<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span> yum <span style="color: #66cc66;">=</span> yumrepo<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> <span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> client.<span style="color: black;">channel</span>.<span style="color: black;">software</span>.<span style="color: black;">create</span><span style="color: black;">&#40;</span>key<span style="color: #66cc66;">,</span> label<span style="color: #66cc66;">,</span> name<span style="color: #66cc66;">,</span> summary<span style="color: #66cc66;">,</span> arch<span style="color: #66cc66;">,</span> parent<span style="color: #66cc66;">,</span> checksumType<span style="color: #66cc66;">,</span> gpg<span style="color: #66cc66;">,</span> yum<span style="color: black;">&#41;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">def</span> main<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; key <span style="color: #66cc66;">=</span> login<span style="color: black;">&#40;</span>options.<span style="color: #dc143c;">user</span><span style="color: #66cc66;">,</span>options.<span style="color: black;">password</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; create<span style="color: black;">&#40;</span>key<span style="color: #66cc66;">,</span> label <span style="color: #66cc66;">=</span> options.<span style="color: black;">label</span><span style="color: #66cc66;">,</span> name <span style="color: #66cc66;">=</span> options.<span style="color: black;">name</span><span style="color: #66cc66;">,</span> summary <span style="color: #66cc66;">=</span> options.<span style="color: black;">summary</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; logout<span style="color: black;">&#40;</span>key<span style="color: black;">&#41;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ <span style="color: #66cc66;">==</span> <span style="color: #483d8b;">&quot;__main__&quot;</span>:<br />
&nbsp; &nbsp; main<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.soumplis.com/2010/06/09/spacewalk-channel-creation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spacewalk Update Adventures</title>
		<link>http://www.soumplis.com/2010/02/09/spacewalk-update-adventures/</link>
		<comments>http://www.soumplis.com/2010/02/09/spacewalk-update-adventures/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 15:18:06 +0000</pubDate>
		<dc:creator>asou</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Spacewalk]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[tablespace]]></category>
		<category><![CDATA[upgrade]]></category>

		<guid isPermaLink="false">http://www.soumplis.com/?p=41</guid>
		<description><![CDATA[Today I decided to update my Spacewalk server to the latest version (0.8 on today&#8217;s nightly build). In case you have never heard of Spacewalk before, &#8220;Spacewalk is an open source (GPLv2) Linux systems management solution. It is the upstream community project from which the Red Hat Network Satellite product is derived&#8221;. Personally I use [...]]]></description>
			<content:encoded><![CDATA[<p>Today I decided to update my Spacewalk server to the latest version (0.8 on today&#8217;s nightly build). In case you have never heard of Spacewalk before, <a href="http://www.redhat.com/spacewalk/" target="_blank">&#8220;Spacewalk is an open source (GPLv2) Linux systems management solution. It is the upstream community project from which the Red Hat Network Satellite product is derived&#8221;</a>. Personally I use it as a central update server for all my CentOS server (more than 40 systems at the moment). I follow spacewalk since version 0.2, so one can easy understand that this is my sixth update and I have not faced any serious issues until now. The only problem is the fact that Spacewalk scripts take for granted the fact that the Apache server running on the spacewalk server does not serve any other sites. Unfortunately this is not my case so I have to reconfigure apache all the time after a spacewalk upgrade and I have to notice that in every single update the required changes are different!</p>
<p>This time things were not so easy as Oracle was not friendly! I followed the documented procedure and while the schema upgrade I received the following error:</p>
<pre>SQL&gt; update rhnPackageFile p
2     set checksum_id = lookup_checksum('md5', md5);
update rhnPackageFile p
       *
ERROR at line 1:
ORA-30036: unable to extend segment by 8 in undo tablespace 'UNDO'</pre>
<p>It was obvious a problem with the UNDO tablespace hitting its extend limit. I verified that I had enough hard disk space available and then I executed the sqlplus utility to verify that the tablespace has hit its limit.</p>
<pre>SQL&gt; select file_name, bytes, autoextensible, maxbytes
from dba_data_files where tablespace_name='UNDO';

FILE_NAME
----------------------------------------------------------------------
BYTES AUT   MAXBYTES
---------- --- ----------
/usr/lib/oracle/xe/oradata/XE/undo.dbf
524288000 YES  524288000</pre>
<p>Then I extend it genersouly!</p>
<pre>SQL&gt; alter database datafile '/usr/lib/oracle/xe/oradata/XE/undo.dbf'
autoextend on next 100m maxsize 2000m;

Database altered.

SQL&gt; select file_name, bytes, autoextensible, maxbytes
from dba_data_files where tablespace_name='UNDO';

FILE_NAME
----------------------------------------------------------------------
BYTES AUT   MAXBYTES
---------- --- ----------
/usr/lib/oracle/xe/oradata/XE/undo.dbf
524288000 YES 2097152000</pre>
<p>Unfortunately I could not use any more the automated script <em>spacewalk-schema-upgrade </em>in order to complete the schema upgrade. The solution was again to use the sqlplus utility and execute all sql scripts against the database. To do that I wrote the following bash script:</p>
<pre>#!/bin/bash
cd /etc/sysconfig/rhn/schema-upgrade/
cd spacewalk-schema-0.7-to-spacewalk-schema-0.8/</pre>
<pre>for sqlscript in `ls -1`
do
echo "****"
echo "Executing script $sqlscript"
echo "****"
sqlplus dbuser/dbpass &lt;&lt;EOF
@$sqlscript;
EOF
done</pre>
<p>I carefully noticed the output of the script for errors. As expected the first scripts, which have already been executed, displayed several warnings and errors but after the script <em>012-2-rhnPackageFile-data.sql</em> which initialy failed, everything went smoothly!</p>
<p><span style="color: #ff0000;"><strong>UPDATE:</strong></span><br />
Later I have found that I had to manually update the rhnVersionInfo table in order for new spacewalk upgrades to work. From a shell execute the command:</p>
<pre>rpm -q spacewalk-schema</pre>
<p>and you will get something like &#8220;spacewalk-schema-0.8.9-1.el5.noarch.rpm&#8221;. Then login to sqlplus interface and execute the following query (alter accordingly to fit your enviroment):</p>
<pre>SQL&gt; INSERT INTO rhnVersionInfo 
( label, name_id, evr_id, created, modified )
VALUES ('schema', lookup_package_name('spacewalk-schema'),
lookup_evr(null, '0.8.9', '1.el5' ), sysdate, sysdate );</pre>
<pre>SQL&gt; COMMIT;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.soumplis.com/2010/02/09/spacewalk-update-adventures/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

