<?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>The Penguin and The Python</title>
	<atom:link href="http://penguinpython.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://penguinpython.com/blog</link>
	<description>A Python and Linux Blog</description>
	<lastBuildDate>Mon, 01 Aug 2011 02:06:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>400% DNS Speedup</title>
		<link>http://penguinpython.com/blog/2011/07/400-dns-speedup/</link>
		<comments>http://penguinpython.com/blog/2011/07/400-dns-speedup/#comments</comments>
		<pubDate>Mon, 01 Aug 2011 01:49:01 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://penguinpython.com/blog/?p=53</guid>
		<description><![CDATA[When I placed my server at QuadraNet, they gave me two IP addresses for resolving DNS. I dutifully placed both of them in my resolv.conf file, and thought nothing more of it. That is until they had problems resolving a &#8230; <a href="http://penguinpython.com/blog/2011/07/400-dns-speedup/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When I placed my server at QuadraNet, they gave me two IP addresses for resolving DNS.  I dutifully placed both of them in my resolv.conf file, and thought nothing more of it.</p>
<p>That is until they had problems resolving a name or two. I remembered long ago trying <a href="http://code.google.com/p/namebench/">namebench</a> on a home computer, and I wondered how it would fare on my server.</p>
<p>The answer is: it worked amazingly well. Namebench found me two new DNS servers, the fastest of which is 408.9% faster than the ones QuadraNet provided me with. I&#8217;m guessing that both of the faster public DNS servers it found for me are physically in the same building as QuadraNet, but I could be wrong. Anyway, the exciting thing is just how much faster they are!</p>
<p>It&#8217;s important to remember that resolv.conf allows you to specify up to three nameservers. By default it goes through the list, from first to last, to resolve a hostname. If a server can&#8217;t tell you the name or times out, your system will automatically move on to the next nameserver.</p>
<p>So you really should have three nameservers in your resolv.conf list.</p>
]]></content:encoded>
			<wfw:commentRss>http://penguinpython.com/blog/2011/07/400-dns-speedup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upgrading to Ubuntu 11.04 on Rackspace</title>
		<link>http://penguinpython.com/blog/2011/05/upgrading-ubuntu-rackspace/</link>
		<comments>http://penguinpython.com/blog/2011/05/upgrading-ubuntu-rackspace/#comments</comments>
		<pubDate>Tue, 31 May 2011 04:27:09 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Fabric]]></category>
		<category><![CDATA[Rackspace]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://penguinpython.com/blog/?p=17</guid>
		<description><![CDATA[Currently, in addition to running my own hardware, I use both the Amazon and Rackspace clouds. Rackspace unfortunately hasn&#8217;t added new images in a while. Therefore, in order to run Ubuntu 11.04 (Natty) I had to start with 10.10 (Maverick). &#8230; <a href="http://penguinpython.com/blog/2011/05/upgrading-ubuntu-rackspace/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Currently, in addition to running my own hardware, I use both the Amazon and Rackspace clouds. <a href="http://penguinpython.com/blog/2011/05/rackspace-cloud-trailing/">Rackspace unfortunately hasn&#8217;t added new images</a> in a  while. Therefore, in order to run Ubuntu 11.04 (Natty) I had to start with 10.10 (Maverick).</p>
<p><a href="http://www.ubuntu.com/download/ubuntu/upgrade">Ubuntu&#8217;s upgrade instructions</a> are pretty clear. In fact, of the three steps given only two are necessary:</p>
<ul>
<li>sudo apt-get install update-manager-core </li>
<li>sudo do-release-upgrade</li>
</ul>
<p>As long as you start with Ubuntu 10.10, Prompt is already set to normal, so there is no need to edit any files.</p>
<p>These two commands are easy enough to execute, but you have to confirm many steps. That&#8217;s okay if you only have to do the upgrade once. But I&#8217;m constantly bringing up and taking down servers, so the whole process needed to be automated.</p>
<p>Installing the update-manager-core can be easily automated:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">apt-get install --assume-yes update-manager-core</div></div>
<p>It&#8217;s the do-release-upgrade part that is harder to automate. There are two types of prompts presented when you do the upgrade. The first ones come from the upgrade program itself, the others come from the dpkg/apt subsystem.</p>
<p>You can quiet all of the dpkg messages by calling do-release-upgrade like this:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">DEBIAN_FRONTEND=noninteractive /usr/bin/do-release-upgrade</div></div>
<p>But that unfortunately won&#8217;t stop all the messages that you need to confirm.</p>
<p>My next thought was to combine that with the program &#8220;yes&#8221;, a small unix tool which outputs the string &#8220;y&#8221; over and over.</p>
<p>So we&#8217;d have something like:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">yes | DEBIAN_FRONTEND=noninteractive /usr/bin/do-release-upgrade</div></div>
<p>But unfortunately that doesn&#8217;t work, instead the program complains: &#8220;Must be connected to a terminal.&#8221;</p>
<p>So finally I had to put together this little <a href="http://www.noah.org/wiki/pexpect">expect</a> program in Python.</p>
<div class="codecolorer-container python default" 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/python</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">import</span> pexpect<br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span><br />
<br />
child <span style="color: #66cc66;">=</span> pexpect.<span style="color: black;">spawn</span><span style="color: black;">&#40;</span><br />
&nbsp; &nbsp; <span style="color: #483d8b;">'''/bin/bash -c &quot;DEBIAN_FRONTEND=noninteractive /usr/bin/do-release-upgrade&quot;'''</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; timeout <span style="color: #66cc66;">=</span> <span style="color: #ff4500;">10</span> * <span style="color: #ff4500;">60</span> &nbsp;<span style="color: #808080; font-style: italic;"># 10 minutes</span><br />
&nbsp; &nbsp; <span style="color: black;">&#41;</span><br />
child.<span style="color: black;">logfile</span> <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">stdout</span><br />
<br />
child.<span style="color: black;">expect</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'''Continue running under SSH?.*Continue <span style="color: #000099; font-weight: bold;">\[</span>yN<span style="color: #000099; font-weight: bold;">\]</span>'''</span><span style="color: black;">&#41;</span><br />
child.<span style="color: black;">sendline</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'y'</span><span style="color: black;">&#41;</span><br />
<br />
child.<span style="color: black;">expect</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'''If you run a firewall.*To continue please press <span style="color: #000099; font-weight: bold;">\[</span>ENTER<span style="color: #000099; font-weight: bold;">\]</span>'''</span><span style="color: black;">&#41;</span><br />
child.<span style="color: black;">sendline</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">''</span><span style="color: black;">&#41;</span><br />
<br />
child.<span style="color: black;">expect</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'''Fetching and installing the upgrade.*Continue <span style="color: #000099; font-weight: bold;">\[</span>yN<span style="color: #000099; font-weight: bold;">\]</span> &nbsp;Details <span style="color: #000099; font-weight: bold;">\[</span>d<span style="color: #000099; font-weight: bold;">\]</span>'''</span><span style="color: black;">&#41;</span><br />
child.<span style="color: black;">sendline</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'y'</span><span style="color: black;">&#41;</span><br />
<br />
child.<span style="color: black;">expect</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'''Remove obsolete packages?.*Continue <span style="color: #000099; font-weight: bold;">\[</span>yN<span style="color: #000099; font-weight: bold;">\]</span> &nbsp;Details <span style="color: #000099; font-weight: bold;">\[</span>d<span style="color: #000099; font-weight: bold;">\]</span>'''</span><span style="color: black;">&#41;</span><br />
child.<span style="color: black;">sendline</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'y'</span><span style="color: black;">&#41;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># We prefer to do our own rebooting</span><br />
child.<span style="color: black;">expect</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'''If you select 'y' the system will be restarted.*Continue <span style="color: #000099; font-weight: bold;">\[</span>yN<span style="color: #000099; font-weight: bold;">\]</span>'''</span><span style="color: black;">&#41;</span><br />
child.<span style="color: black;">sendline</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'N'</span><span style="color: black;">&#41;</span></div></div>
<p>Save the above file with the name &#8220;upgrade_release.py&#8221;.  You can then run it directly. Or, if you use <a href="http://www.nongnu.org/fab/">fabric</a> to manage the creation of all of your new servers, you can add it to your fabfile like so:</p>
<div class="codecolorer-container python default" 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: #ff7700;font-weight:bold;">def</span> upgrade_dist<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; output <span style="color: #66cc66;">=</span> run<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;lsb_release -r&quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; version <span style="color: #66cc66;">=</span> output.<span style="color: black;">partition</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;:&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span>.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> version <span style="color: #66cc66;">==</span> <span style="color: #483d8b;">&quot;10.10&quot;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Going to upgrade Ubuntu...&quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; sudo<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;aptitude install --assume-yes update-manager-core python-pexpect&quot;</span><span style="color: black;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; put<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;fabfile/upgrade_release.py&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot;/tmp&quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; sudo<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;/usr/bin/python /tmp/upgrade_release.py&quot;</span><span style="color: black;">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Done upgrading Ubuntu - Need to sleep while rebooting&quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; reboot<span style="color: black;">&#40;</span><span style="color: #ff4500;">60</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;"># Line below necessary because of ssh caching bug in fabric</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; fabric.<span style="color: black;">state</span>.<span style="color: black;">connections</span> <span style="color: #66cc66;">=</span> fabric.<span style="color: black;">state</span>.<span style="color: black;">HostConnectionCache</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Not going to upgrade Ubuntu&quot;</span><span style="color: black;">&#41;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://penguinpython.com/blog/2011/05/upgrading-ubuntu-rackspace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rackspace Cloud Trailing</title>
		<link>http://penguinpython.com/blog/2011/05/rackspace-cloud-trailing/</link>
		<comments>http://penguinpython.com/blog/2011/05/rackspace-cloud-trailing/#comments</comments>
		<pubDate>Fri, 27 May 2011 13:25:06 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Rackspace]]></category>

		<guid isPermaLink="false">http://penguinpython.com/blog/?p=1</guid>
		<description><![CDATA[Rackspace Cloud seems to be getting more and more behind these days.  Most of the Linux distributions they offer are out of date. Debian 6.0 (Squeeze) was released February 6, 2011. Rackspace only offers Debian 5. CentOS is at 5.6, &#8230; <a href="http://penguinpython.com/blog/2011/05/rackspace-cloud-trailing/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Rackspace Cloud seems to be getting more and more behind these days.  Most of the Linux distributions they offer are out of date.</p>
<p>Debian 6.0 (Squeeze) was released February 6, 2011. Rackspace only offers Debian 5.</p>
<p>CentOS is at 5.6, Rackspace offers only 5.4 and 5.5.</p>
<p>RedHat Enterprise Linux 6.1 is out &#8211; Rackspace offers  only 5.4 and 5.5.</p>
<p>Fedora is at version 15 &#8211; but Rackspace offers only Fedora 14.</p>
<p>Oracle Linux is at version 6 &#8211; Rackspace offers R5U4 and R5U3.</p>
<p>Ubuntu is on 11.04 &#8211; but the latest Rackspace offers is 10.10.</p>
<p>Gentoo and Arch are both current &#8211; but they can&#8217;t be more than 3% of the Linux market combined.</p>
<p>I had an online chat with their support department. From what I can piece together from that chat and this <a href="http://www.rackspace.com/cloud/blog/2011/04/21/update-the-future-path-of-rackspace%E2%80%99s-public-cloud-products/">Rackspace blog entry</a>, Rackspace is apparently waiting until after they switch to Citrix XenServer to start offering new releases.</p>
<p>You can, of course, install any of these earlier releases and then upgrade them.  But that takes time and is a bit of a pain. Current customers will probably be willing to do this.</p>
<p>But I imagine there are lots of new customers every day trying out the &#8220;cloud&#8221; for the first time.  And those who are using the current release of their favorite distribution &#8211; upon seeing that Rackspace doesn&#8217;t offer it &#8211; will probably turn to Amazon and never look back.</p>
<p>Which is a shame, because Rackspace has a lot of great features: in particular they offer great support and it&#8217;s incredibly easy to get started with them.</p>
<p>But they need to offer the latest versions of all the major Linux releases.</p>
<p>In my next post I&#8217;ll show you how you can use Python to automate updating Ubuntu 10.10 (Maverick) to 11.04 (Natty).</p>
]]></content:encoded>
			<wfw:commentRss>http://penguinpython.com/blog/2011/05/rackspace-cloud-trailing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

