<?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>boompty boomp</title>
	<atom:link href="http://blog.defunct.ca/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.defunct.ca</link>
	<description></description>
	<lastBuildDate>Wed, 09 May 2012 16:51:16 +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>pip uninstall broken on Debian Squeeze</title>
		<link>http://blog.defunct.ca/2012/05/09/pip-uninstall-broken-on-debian-squeeze/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=pip-uninstall-broken-on-debian-squeeze</link>
		<comments>http://blog.defunct.ca/2012/05/09/pip-uninstall-broken-on-debian-squeeze/#comments</comments>
		<pubDate>Wed, 09 May 2012 16:45:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://blog.defunct.ca/?p=540</guid>
		<description><![CDATA[I noticed that I was unable to uninstall python packages via pip (0.7.2-1) on a Debian Squeeze instance: root@diamondbuilder:~# pip freeze &#124; grep swift root@diamondbuilder:~# pip install swift Downloading/unpacking swift Downloading swift-1.4.8.tar.gz (421Kb): 421Kb downloaded Running setup.py egg_info for package swift Installing collected packages: swift Running setup.py install for swift changing mode of build/scripts-2.6/swift from [...]]]></description>
			<content:encoded><![CDATA[<p>I noticed that I was unable to uninstall python packages via pip (0.7.2-1) on a Debian Squeeze instance:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">root@diamondbuilder:~# pip freeze | grep swift
root@diamondbuilder:~# pip install swift
Downloading/unpacking swift
  Downloading swift-1.4.8.tar.gz (421Kb): 421Kb downloaded
  Running setup.py egg_info for package swift
Installing collected packages: swift
  Running setup.py install for swift
    changing mode of build/scripts-2.6/swift from 644 to 755
    changing mode of build/scripts-2.6/swift-account-audit from 644 to 755
    changing mode of build/scripts-2.6/swift-account-auditor from 644 to 755
    changing mode of build/scripts-2.6/swift-account-reaper from 644 to 755
    changing mode of build/scripts-2.6/swift-account-replicator from 644 to 755
    changing mode of build/scripts-2.6/swift-account-server from 644 to 755
    changing mode of build/scripts-2.6/swift-bench from 644 to 755
    changing mode of build/scripts-2.6/swift-container-auditor from 644 to 755
    changing mode of build/scripts-2.6/swift-container-replicator from 644 to 755
    changing mode of build/scripts-2.6/swift-container-server from 644 to 755
    changing mode of build/scripts-2.6/swift-container-sync from 644 to 755
    changing mode of build/scripts-2.6/swift-container-updater from 644 to 755
    changing mode of build/scripts-2.6/swift-dispersion-populate from 644 to 755
    changing mode of build/scripts-2.6/swift-dispersion-report from 644 to 755
    changing mode of build/scripts-2.6/swift-drive-audit from 644 to 755
    changing mode of build/scripts-2.6/swift-form-signature from 644 to 755
    changing mode of build/scripts-2.6/swift-get-nodes from 644 to 755
    changing mode of build/scripts-2.6/swift-init from 644 to 755
    changing mode of build/scripts-2.6/swift-object-auditor from 644 to 755
    changing mode of build/scripts-2.6/swift-object-expirer from 644 to 755
    changing mode of build/scripts-2.6/swift-object-info from 644 to 755
    changing mode of build/scripts-2.6/swift-object-replicator from 644 to 755
    changing mode of build/scripts-2.6/swift-object-server from 644 to 755
    changing mode of build/scripts-2.6/swift-object-updater from 644 to 755
    changing mode of build/scripts-2.6/swift-oldies from 644 to 755
    changing mode of build/scripts-2.6/swift-orphans from 644 to 755
    changing mode of build/scripts-2.6/swift-proxy-server from 644 to 755
    changing mode of build/scripts-2.6/swift-recon from 644 to 755
    changing mode of build/scripts-2.6/swift-recon-cron from 644 to 755
    changing mode of build/scripts-2.6/swift-ring-builder from 644 to 755
    changing mode of build/scripts-2.6/swift-temp-url from 644 to 755
    changing mode of /usr/local/bin/swift-account-audit to 755
    changing mode of /usr/local/bin/swift-object-expirer to 755
    changing mode of /usr/local/bin/swift-proxy-server to 755
    changing mode of /usr/local/bin/swift-container-replicator to 755
    changing mode of /usr/local/bin/swift-container-sync to 755
    changing mode of /usr/local/bin/swift-orphans to 755
    changing mode of /usr/local/bin/swift-get-nodes to 755
    changing mode of /usr/local/bin/swift-drive-audit to 755
    changing mode of /usr/local/bin/swift-dispersion-populate to 755
    changing mode of /usr/local/bin/swift-account-reaper to 755
    changing mode of /usr/local/bin/swift-object-replicator to 755
    changing mode of /usr/local/bin/swift-init to 755
    changing mode of /usr/local/bin/swift-dispersion-report to 755
    changing mode of /usr/local/bin/swift-oldies to 755
    changing mode of /usr/local/bin/swift-ring-builder to 755
    changing mode of /usr/local/bin/swift-form-signature to 755
    changing mode of /usr/local/bin/swift-container-server to 755
    changing mode of /usr/local/bin/swift-container-updater to 755
    changing mode of /usr/local/bin/swift-bench to 755
    changing mode of /usr/local/bin/swift-object-info to 755
    changing mode of /usr/local/bin/swift-recon to 755
    changing mode of /usr/local/bin/swift to 755
    changing mode of /usr/local/bin/swift-object-server to 755
    changing mode of /usr/local/bin/swift-object-updater to 755
    changing mode of /usr/local/bin/swift-container-auditor to 755
    changing mode of /usr/local/bin/swift-account-auditor to 755
    changing mode of /usr/local/bin/swift-account-server to 755
    changing mode of /usr/local/bin/swift-recon-cron to 755
    changing mode of /usr/local/bin/swift-object-auditor to 755
    changing mode of /usr/local/bin/swift-account-replicator to 755
    changing mode of /usr/local/bin/swift-temp-url to 755
Successfully installed swift
Cleaning up...
root@diamondbuilder:~# pip freeze | grep swift
swift==1.4.8
root@diamondbuilder:~# pip uninstall swift
Uninstalling swift:
Proceed (y/n)? y
  Successfully uninstalled swift
root@diamondbuilder:~# pip freeze | grep swift
swift==1.4.8
root@diamondbuilder:~#</pre></div></div>

<p>Fortunately, I found <a href="http://code-redefined.blogspot.co.uk/2011/03/uninstalling-pip-package-on-ubuntu-10.html">this</a> and <a href="https://github.com/pypa/pip/issues/6">this</a>, which indicates the issue lies w/ Debian&#8217;s python-setuptools (0.6.14-4).  Anyway, using that info, I did:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">root@diamondbuilder:~# cd /usr/local/lib/python2.6/dist-packages
root@diamondbuilder:/usr/local/lib/python2.6/dist-packages# mv swift-1.4.8.egg-info/ swift-1.4.8-py2.6.egg-info/
root@diamondbuilder:/usr/local/lib/python2.6/dist-packages# cd -
/root
root@diamondbuilder:~# pip uninstall swift
Uninstalling swift:
  /usr/local/bin/swift
  /usr/local/bin/swift-account-audit
  /usr/local/bin/swift-account-auditor
  /usr/local/bin/swift-account-reaper
  /usr/local/bin/swift-account-replicator
  /usr/local/bin/swift-account-server
  /usr/local/bin/swift-bench
  /usr/local/bin/swift-container-auditor
  /usr/local/bin/swift-container-replicator
  /usr/local/bin/swift-container-server
  /usr/local/bin/swift-container-sync
  /usr/local/bin/swift-container-updater
  /usr/local/bin/swift-dispersion-populate
  /usr/local/bin/swift-dispersion-report
  /usr/local/bin/swift-drive-audit
  /usr/local/bin/swift-form-signature
  /usr/local/bin/swift-get-nodes
  /usr/local/bin/swift-init
  /usr/local/bin/swift-object-auditor
  /usr/local/bin/swift-object-expirer
  /usr/local/bin/swift-object-info
  /usr/local/bin/swift-object-replicator
  /usr/local/bin/swift-object-server
  /usr/local/bin/swift-object-updater
  /usr/local/bin/swift-oldies
  /usr/local/bin/swift-orphans
  /usr/local/bin/swift-proxy-server
  /usr/local/bin/swift-recon
  /usr/local/bin/swift-recon-cron
  /usr/local/bin/swift-ring-builder
  /usr/local/bin/swift-temp-url
  /usr/local/lib/python2.6/dist-packages/swift
  /usr/local/lib/python2.6/dist-packages/swift-1.4.8-py2.6.egg-info
  /usr/local/lib/python2.6/dist-packages/test
Proceed (y/n)? y
  Successfully uninstalled swift
root@diamondbuilder:~# pip freeze | grep swift
root@diamondbuilder:~#</pre></div></div>

<p>I suppose I could have just cycled through /usr/local/lib/python2.6/dist-packages/swift-1.4.8.egg-info/installed-files.txt, removing files based off that, but I&#8217;m not familiar enough w/ python / pip to know if anything further would have been required.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.defunct.ca/2012/05/09/pip-uninstall-broken-on-debian-squeeze/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nagios servicedependency</title>
		<link>http://blog.defunct.ca/2012/05/09/nagios-servicedependency/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=nagios-servicedependency</link>
		<comments>http://blog.defunct.ca/2012/05/09/nagios-servicedependency/#comments</comments>
		<pubDate>Wed, 09 May 2012 12:16:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[nagios]]></category>

		<guid isPermaLink="false">http://blog.defunct.ca/?p=529</guid>
		<description><![CDATA[I&#8217;ve got a series of nodes which have 3 SNMP-based checks configured on them. I wanted 2 of these checks to depend on 1, so that we only get a single alert if snmpd goes down or if the node drops offline. To do this, I created a servicedependency like so: define servicedependency{ host_name nodeX [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve got a series of nodes which have 3 SNMP-based checks configured on them.  I wanted 2 of these checks to depend on 1, so that we only get a single alert if snmpd goes down or if the node drops offline.  To do this, I created a servicedependency like so:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">define servicedependency{
        host_name                       nodeX
        service_description             disk_usage
        dependent_service_description   load_avg_5m, swap_usage
        execution_failure_criteria      n
        notification_failure_criteria   u
}</pre></div></div>

<p>As you can see, load_avg_5m and swap_usage depend on disk_usage.  </p>
<p>With this configuration in place, I noticed that I was sometimes getting a notification for load_avg_5m, swap_usage and then disk_usage, since this was the order that these services were being checked.  Unfortunately, I couldn&#8217;t find a way to configure the order in which the services were checked, but fortunately did find the following <a href="http://nagios.sourceforge.net/docs/nagioscore/3/en/dependencies.html#hard_dependencies">here</a>:</p>
<p><em>&#8220;*One important thing to note is that by default, Nagios will use the most current hard state of the service(s) that is/are being depended upon when it does the dependeny checks. If you want Nagios to use the most current state of the services (regardless of whether its a soft or hard state), enable the soft_state_dependencies option.&#8221;</em></p>
<p>So, in my case, the current HARD state of disk_usage wasn&#8217;t UNKNOWN when the other checks failed, and therefore these services failed first and sent notifications. I&#8217;ve since set soft_state_dependencies=1 in /etc/nagios3/nagios.conf, and hope that this helps in reducing the amount of unnecessary notifications I get when there&#8217;s a node or snmpd outage.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.defunct.ca/2012/05/09/nagios-servicedependency/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fast and dirty install of Graphite on Debian Squeeze</title>
		<link>http://blog.defunct.ca/2012/01/23/fast-and-dirty-install-of-graphite-on-debian-squeeze/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=fast-and-dirty-install-of-graphite-on-debian-squeeze</link>
		<comments>http://blog.defunct.ca/2012/01/23/fast-and-dirty-install-of-graphite-on-debian-squeeze/#comments</comments>
		<pubDate>Mon, 23 Jan 2012 15:22:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.defunct.ca/?p=516</guid>
		<description><![CDATA[Please note that this is not a production-ready installation document! As the title suggests, this is a fast and dirty installation of Graphite for testing, and assumes you&#8217;re installing on a new virtual machine dedicated to Graphite. This will break stuff if you run on an existing server! These installation instructions are basically the steps [...]]]></description>
			<content:encoded><![CDATA[<p>Please note that this is not a production-ready installation document!  As the title suggests, this is a fast and dirty installation of Graphite for testing, and assumes you&#8217;re installing on a new virtual machine dedicated to Graphite.  This will break stuff if you run on an existing server!</p>
<p>These installation instructions are basically the steps from <a href="http://graphite.wikidot.com/installation" title="http://graphite.wikidot.com/installation">http://graphite.wikidot.com/installation</a>, with a few minor adjustments to work on Debian Squeeze.</p>
<p>First things first:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># cd /root
# apt-get update
# apt-get install bzr</pre></div></div>

<p>Once bzr&#8217;s installed, we can:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># bzr branch lp:graphite</pre></div></div>

<p>Install Whisper:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># cd graphite/whisper
# python setup.py install</pre></div></div>

<p>At the time of writing, Whisper can be installed from apt-get on Squeeze, but the version doesn&#8217;t match what we&#8217;ve pulled Launchpad.</p>
<p>Install Carbon:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># cd ../carbon
# python setup.py install</pre></div></div>

<p>Now we copy some sample configurations into place:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># cd /opt/graphite/conf
# cp carbon.conf.example carbon.conf
# cp storage-schemas.conf.example storage-schemas.conf</pre></div></div>

<p>Graphite depends on a number of other packages, and I&#8217;ve made every attempt to grab stuff from stock apt repos rather than building (unnecessarily) from source.  To see what&#8217;s missing, run:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">cd /root/graphite
python check-dependencies.py</pre></div></div>

<p>This should return something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># python check-dependencies.py
[FATAL] Unable to import the 'cairo' module, do you have pycairo installed for python 2.6.6?
[FATAL] Unable to import the 'django' module, do you have Django installed for python 2.6.6?
[FATAL] Unable to import the 'tagging' module, do you have django-tagging installed for python 2.6.6?
[WARNING] Unable to import Interface from zope.interface.
Without it, you will be unable to run carbon on this server.
[WARNING] Unable to import the 'mod_python' module, do you have mod_python installed for python 2.6.6?
mod_python is one of the most common ways to run graphite-web under apache.
Without mod_python you will still be able to use the built in development server; which is not
recommended for production use.
wsgi or other approaches for production scale use are also possible without mod_python
[WARNING]
Unable to import the 'memcache' module, do you have python-memcached installed for python 2.6.6?
This feature is not required but greatly improves performance.
&nbsp;
[WARNING]
Unable to import the 'ldap' module, do you have python-ldap installed for python 2.6.6?
Without python-ldap, you will not be able to use LDAP authentication in the graphite webapp.
&nbsp;
[WARNING]
Unable to import the 'twisted' package, do you have Twisted installed for python 2.6.6?
Without Twisted, you cannot run carbon on this server.
[WARNING]
Unable to import the 'txamqp' module, this is required if you want to use AMQP.
Note that txamqp requires python 2.5 or greater.
3 necessary dependencies not met. Graphite will not function until these dependencies are fulfilled.
6 optional dependencies not met. Please consider the warning messages before proceeding.</pre></div></div>

<p>Now, to get this stuff installed:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># apt-get install python-cairo
# apt-get install python-django-tagging
# apt-get install python-twisted
# apt-get install python-memcache
# apt-get install libapache2-mod-wsgi</pre></div></div>

<p>I don&#8217;t know enough about mod_python (which we&#8217;re supposed to install), but the sample vhost configuration below refers to mod_wsgi, so I installed that instead.</p>
<p>Now we configure Apache and modify the sample vhost configuration file provided:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># rm /etc/apache2/sites-enabled/000-default
# cp -a examples/example-graphite-vhost.conf /etc/apache2/sites-enabled/graphite
# cp -a conf/graphite.wsgi.example /opt/graphite/conf/graphite.wsgi
# sed -i s%&quot;@DJANGO_ROOT@/contrib/admin/media/&quot;%&quot;/usr/share/pyshared/django/contrib/admin/media/&quot;% /etc/apache2/sites-enabled/graphite
# sed -i 's%WSGISocketPrefix /etc/httpd/wsgi/%WSGISocketPrefix /var/run/apache2/wsgi%' /etc/apache2/sites-enabled/graphite</pre></div></div>

<p>Once done, go ahead and restart Apache:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># /etc/init.d/apache2 reload</pre></div></div>

<p>Finally:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># cd /opt/graphite/webapp/graphite
# python manage.py syncdb
# chown -R www-data:www-data /opt/graphite/storage/
# cd /opt/graphite/
# ./bin/carbon-cache.py start</pre></div></div>

<p>If that&#8217;s all worked, you should be able to pump data into Graphite:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># echo &quot;carbon.installation.test $RANDOM `date +%s`&quot; | nc -w 1 localhost 2003</pre></div></div>

<p>On the above, if I don&#8217;t pass -w 1 to nc, nc just sits there doing nothing.</p>
<p>Now, browsing your server&#8217;s http://x.x.x.x/ should load up the Graphite app and hopefully you can see a graph for the data you&#8217;ve sent in.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.defunct.ca/2012/01/23/fast-and-dirty-install-of-graphite-on-debian-squeeze/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using nova-network&#8217;s multi_host to remove SPOF</title>
		<link>http://blog.defunct.ca/2011/09/19/using-nova-networks-multi_host-to-remove-spof/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-nova-networks-multi_host-to-remove-spof</link>
		<comments>http://blog.defunct.ca/2011/09/19/using-nova-networks-multi_host-to-remove-spof/#comments</comments>
		<pubDate>Mon, 19 Sep 2011 21:32:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[OpenStack]]></category>

		<guid isPermaLink="false">http://blog.defunct.ca/?p=501</guid>
		<description><![CDATA[In http://blog.defunct.ca/2011/07/22/moving-nova-compute-to-a-separate-instance/, I was able to successfully move nova-compute to a separate instance. The only problem here is that the nova-compute instance used nova-network running on the controller, which introduced a single point of failure in our environment. If the controller dropped offline, the gateway for virtual machines running on the compute node would be [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://blog.defunct.ca/2011/07/22/moving-nova-compute-to-a-separate-instance/" title="http://blog.defunct.ca/2011/07/22/moving-nova-compute-to-a-separate-instance/">http://blog.defunct.ca/2011/07/22/moving-nova-compute-to-a-separate-instance/</a>, I was able to successfully move nova-compute to a separate instance.  The only problem here is that the nova-compute instance used nova-network running on the controller, which introduced a single point of failure in our environment.  If the controller dropped offline, the gateway for virtual machines running on the compute node would be inaccessible, meaning instances would not be able to access the outside world until the controller came back online.  </p>
<p>Fortunately, some improvements have been made to Nova as outlined in <a href="http://unchainyourbrain.com/openstack/13-networking-in-nova" title="http://unchainyourbrain.com/openstack/13-networking-in-nova">http://unchainyourbrain.com/openstack/13-networking-in-nova</a>.  Essentially, we can now run a nova-network on each compute node, which forces the compute node to be the gateway for instances running on it.  This means there&#8217;s no longer that dependency between the controller (or whatever runs nova-network) and virtual machines running on the compute node.  </p>
<p>To move to this configuration, I had to run the following on the compute nodes:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># apt-get install nova-network</pre></div></div>

<p>I then had to add the following configurations to the /etc/nova/nova.conf file on the compute nodes:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">--ec2_dmz_host=192.168.0.1
--multi_host</pre></div></div>

<p>Specifying &#8211;ec2_dmz_host=192.168.0.1 causes this iptables rule to get added:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">Chain nova-network-PREROUTING (1 references)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 DNAT       tcp  --  any    any     anywhere             169.254.169.254     tcp dpt:www to:192.168.0.1:8773</pre></div></div>

<p>&#8230; and this allows cloud-init on the Ubuntu instances to grab whatever it is they&#8217;re grabbing from the EC2 API running on the controller.  When the Ubuntu instances boot but can&#8217;t hit the EC2 API (I have 192.168.0.1 assigned to my controller, which runs the EC2 API), cloud-init seems to spin forever and the instances never really seems to boot.  If you uninstall cloud-init, the instances will boot, but configuration does not appear to be complete (ie. missing ssh keys in /etc/ssh/).  I tried using my controller&#8217;s public IP or the controller&#8217;s 10.176.65.54 address, but neither seemed to work.  The latter is understandable as the instance will not be able to hit 10.176.65.54 since it&#8217;s not attached to that network, but it was my understanding that it should be able to hit the external IP.</p>
<p>Anyway, I also removed this from /etc/nova/nova.conf on the compute nodes as we no longer have to route through the controller:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">--routing_source_ip=x.x.x.x</pre></div></div>

<p>For good measure:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># /etc/init.d/nova-compute restart
# /etc/init.d/nova-network restart</pre></div></div>

<p>Finally, I deleted my 192.168.0.0/24 on the controller and re-created it:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">nova-manage network create --fixed_range_v4=192.168.0.0/24 --num_networks=1 --network_size=256 --multi_host=T --label=test</pre></div></div>

<p>The key above is specifying the &#8211;multi_host=T.</p>
<p>This was more or less it.  Now when an instance is first started on a compute node, the compute node itself gets an IP assigned from the network above and that IP gets assigned to the bridge br100.  The instances on the host are then configured to use that IP as their gateway and traffic no longer gets routed through the controller.</p>
<p>One thing I noticed while working on this configuration was that my previous VPN connection didn&#8217;t permit multiple clients.  As such, I had to move my VPN server/clients to use tls-server and tls-client, which required a bit more work (see <a href="http://openvpn.net/index.php/open-source/documentation/howto.html#pki" title="http://openvpn.net/index.php/open-source/documentation/howto.html#pki">this</a> for more info).</p>
<p>My openvpn.server file:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">mode server
tls-server
dev tap
ifconfig 192.168.0.1 255.255.0.0
cert /etc/openvpn/controller.crt
key /etc/openvpn/controller.key
dh /usr/share/doc/openvpn/examples/easy-rsa/2.0/keys/dh1024.pem
ca /usr/share/doc/openvpn/examples/easy-rsa/2.0/keys/ca.crt
daemon</pre></div></div>

<p>&#8230; and openvpn.client for compute1:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">tls-client
remote 10.176.65.54
dev tap
cert /etc/openvpn/compute1.crt
key /etc/openvpn/compute1.key
ca /etc/openvpn/ca.crt
daemon
keepalive 10 60
up /etc/openvpn/openvpn.up
up-restart
script-security 2</pre></div></div>

<p>The /etc/openvpn/openvpn.up file contains:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">#!/bin/bash
&nbsp;
/sbin/ifconfig tap0 0.0.0.0 up
/usr/sbin/brctl addif br100 tap0
echo 0</pre></div></div>

<p>Unlike our original configuration, br100 is IPd automatically by nova-network, so we no longer need to set an IP when openvpn starts on the clients.  However, if the controller node (which subsequently runs the openvpn server) restarts, our clients cannot ping the 192.168.0.1 address even after the server comes back online.  By adding the keepalive and up/up-restart entries to the openvpn.client file, we can force openvpn to get HUPd if the connection drops (or the server reboots).</p>
<p>There&#8217;s still a bit of magic happening here, but hopefully I&#8217;ve captured enough of this configuration to reconstruct this setup if necessary.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.defunct.ca/2011/09/19/using-nova-networks-multi_host-to-remove-spof/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unable to console into Ubuntu 10.04 QEMU image</title>
		<link>http://blog.defunct.ca/2011/09/18/unable-to-console-into-ubuntu-10-04-qemu-image/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=unable-to-console-into-ubuntu-10-04-qemu-image</link>
		<comments>http://blog.defunct.ca/2011/09/18/unable-to-console-into-ubuntu-10-04-qemu-image/#comments</comments>
		<pubDate>Sun, 18 Sep 2011 00:01:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[OpenStack]]></category>

		<guid isPermaLink="false">http://blog.defunct.ca/?p=498</guid>
		<description><![CDATA[&#8230; turns out the image was missing /etc/init/ttyS0.conf: &#160; # ttyS0 - getty # # This service maintains a getty on ttyS0 from the point the system is # started until it is shut down again. &#160; start on stopped rc or RUNLEVEL=[2345] stop on runlevel [!2345] &#160; respawn exec /sbin/getty -8 38400 ttyS0 vt102 [...]]]></description>
			<content:encoded><![CDATA[<p>&#8230; turns out the image was missing /etc/init/ttyS0.conf:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">&nbsp;
# ttyS0 - getty
#
# This service maintains a getty on ttyS0 from the point the system is
# started until it is shut down again.
&nbsp;
start on stopped rc or RUNLEVEL=[2345]
stop on runlevel [!2345]
&nbsp;
respawn
exec /sbin/getty -8 38400 ttyS0 vt102</pre></div></div>

<p>Once I dropped that in there, I was able to console into the image.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.defunct.ca/2011/09/18/unable-to-console-into-ubuntu-10-04-qemu-image/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programmatically interfacing with novaclient</title>
		<link>http://blog.defunct.ca/2011/09/16/programmatically-interfacing-with-novaclient/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=programmatically-interfacing-with-novaclient</link>
		<comments>http://blog.defunct.ca/2011/09/16/programmatically-interfacing-with-novaclient/#comments</comments>
		<pubDate>Fri, 16 Sep 2011 11:02:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[OpenStack]]></category>

		<guid isPermaLink="false">http://blog.defunct.ca/?p=494</guid>
		<description><![CDATA[Guessing most people are aware of this, but documenting for my own knowledge. root@nova-cc:~# python Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53) [GCC 4.5.2] on linux2 Type &#34;help&#34;, &#34;copyright&#34;, &#34;credits&#34; or &#34;license&#34; for more information. &#62;&#62;&#62; from novaclient.v1_0 import client &#62;&#62;&#62; client = client.Client(USERNAME, API_KEY,PROJECT_ID [, AUTH_URL]) &#62;&#62;&#62; client.servers.list() [&#60;Server: Server 40&#62;, &#60;Server: Server 41&#62;, [...]]]></description>
			<content:encoded><![CDATA[<p>Guessing most people are aware of this, but documenting for my own knowledge.  <img src='http://blog.defunct.ca/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">root@nova-cc:~# python
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53)
[GCC 4.5.2] on linux2
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; from novaclient.v1_0 import client
&gt;&gt;&gt; client = client.Client(USERNAME, API_KEY,PROJECT_ID [, AUTH_URL])
&gt;&gt;&gt; client.servers.list()
[&lt;Server: Server 40&gt;, &lt;Server: Server 41&gt;, &lt;Server: Server 42&gt;, &lt;Server: Server 43&gt;, &lt;Server: Server 44&gt;, &lt;Server: Server 45&gt;, &lt;Server: Server 46&gt;]
&gt;&gt;&gt; for server in client.servers.list():
...     server.delete()
... 
&gt;&gt;&gt; client.servers.list()
[]
&gt;&gt;&gt;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.defunct.ca/2011/09/16/programmatically-interfacing-with-novaclient/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Running openstack-dashboard</title>
		<link>http://blog.defunct.ca/2011/08/02/running-openstack-dashboard/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=running-openstack-dashboard</link>
		<comments>http://blog.defunct.ca/2011/08/02/running-openstack-dashboard/#comments</comments>
		<pubDate>Tue, 02 Aug 2011 15:27:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[OpenStack]]></category>

		<guid isPermaLink="false">http://blog.defunct.ca/?p=483</guid>
		<description><![CDATA[The latest version of openstack-dashboard requires Keystone, and as I understand it this isn&#8217;t supported by the version of Nova I&#8217;m running (2011.3~d2-0ubuntu0~ppa1~natty1). Fortunately, I found this, which outlines how to use an older version of openstack-dashboard that does work without Keystone. # apt-get update # apt-get install bzr # cd /root # bzr branch [...]]]></description>
			<content:encoded><![CDATA[<p>The latest version of openstack-dashboard requires <a href="https://launchpad.net/keystone">Keystone</a>, and as I understand it this isn&#8217;t supported by the version of Nova I&#8217;m running (2011.3~d2-0ubuntu0~ppa1~natty1).  Fortunately, I found <a href="https://answers.launchpad.net/nova/+question/162549">this</a>, which outlines how to use an older version of openstack-dashboard that does work without Keystone.</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># apt-get update
# apt-get install bzr
# cd /root
# bzr branch lp:openstack-dashboard
# cd openstack-dashboard/
# bzr revert -r 46
# cd local
# cp -a local_settings.py.example local_settings.py</pre></div></div>

<p>You now need to configure local_settings.py with correct values for NOVA_DEFAULT_ENDPOINT, NOVA_DEFAULT_REGION, NOVA_ACCESS_KEY, NOVA_SECRET_KEY, NOVA_ADMIN_USER, NOVA_PROJECT.  Most of these values can be ripped out of novarc on your cloud controller.</p>
<p>Continue on with the installation:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># apt-get install -y python-setuptools
# easy_install virtualenv
# python tools/install_venv.py
# tools/with_venv.sh dashboard/manage.py syncdb</pre></div></div>

<p>When you run &#8220;dashboard/manage.py syncdb&#8221;, it&#8217;ll prompt you asking if you want to create a Django superuser (since none exist at this point).  I answered yes, entering a username that matched the value of NOVA_ADMIN_USER.  I initially tried creating a Django user with a different username, and upon logging into openstack-dashboard I failed to see my Nova project.
</pre>
<p>Lastly, go ahead and start up the server:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># tools/with_venv.sh dashboard/manage.py runserver 0.0.0.0:8000</pre></div></div>

<p>At this point, you should be able to access your dashboard on http://x.x.x.x:8000, replacing x.x.x.x with your openstack-dashboard server's IP.</p>
<p>If you run into any issues, refer to <a href="http://docs.openstack.org/bexar/openstack-compute/admin/content/ch06s02.html">this</a>, which contains valid information for this particular version of the dashboard.</p>
<p>Again, running with this old version of the dashboard isn't ideal, and you certainly don't want to run it as root, but hopefully this will point you in the right direction if you struggle to get the latest version to work with Nova.  My next task will to be to get a version of the dashboard and Nova which work together installed and operational.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.defunct.ca/2011/08/02/running-openstack-dashboard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Moving nova-compute to a separate instance</title>
		<link>http://blog.defunct.ca/2011/07/22/moving-nova-compute-to-a-separate-instance/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=moving-nova-compute-to-a-separate-instance</link>
		<comments>http://blog.defunct.ca/2011/07/22/moving-nova-compute-to-a-separate-instance/#comments</comments>
		<pubDate>Fri, 22 Jul 2011 21:50:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[OpenStack]]></category>

		<guid isPermaLink="false">http://blog.defunct.ca/?p=468</guid>
		<description><![CDATA[I want to quickly document how I accomplished this. Again, I used virtual machines (running Ubuntu Natty), but used public cloud server instances rather than private virtual machines. First things first. Here&#8217;s the eth1 (private network) addresses assigned to my cloud servers: nova-cc (our Nova cloud controller node): eth1: 10.176.65.54 nova-compute (our Nova compute note, [...]]]></description>
			<content:encoded><![CDATA[<p>I want to quickly document how I accomplished this.  Again, I used virtual machines (running Ubuntu Natty), but used public cloud server instances rather than private virtual machines.  </p>
<p>First things first.  Here&#8217;s the eth1 (private network) addresses assigned to my cloud servers:</p>
<p>nova-cc (our Nova cloud controller node):</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">eth1: 10.176.65.54</pre></div></div>

<p>nova-compute (our Nova compute note, which will run our instances (QEMU or UML):</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">eth1: 10.176.95.220</pre></div></div>

<p>Similar to previous posts, I went ahead and used 192.168.0.0/16 for Nova network as I didn&#8217;t have public IPs, nor did I want to interfere with the 10.176.64.0/18 network which is already used by this cloud provider.</p>
<p>On nova-cc, we need to install mysqld.  Nova defaults to using SQLite, which works great when everything is running off a single instance.  However, now that we&#8217;ve got another instance that needs to talk to nova-cc, we need a SQL server that it can connect to.</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># apt-get update
# apt-get install mysql-server</pre></div></div>

<p>Once installed, edit /etc/mysql/my.cnf and change this from:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">bind-address            = 127.0.0.1</pre></div></div>

<p>to:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">bind-address            = 10.176.65.54</pre></div></div>

<p>Finally, restart mysqld:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># service mysql restart</pre></div></div>

<p>Now hop into the mysql shell and create a database and user/password to connect with:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># mysql -u root
mysql&gt; CREATE DATABASE nova;
mysql&gt; GRANT ALL PRIVILEGES ON nova.* TO nova@10.176.65.54 IDENTIFIED BY 'somepasshere';
mysql&gt; GRANT ALL PRIVILEGES ON nova.* TO nova@10.176.95.220 IDENTIFIED BY 'somepasshere';</pre></div></div>

<p>On nova-compute, the only nova-related package you really need is nova-compute:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># apt-get -y install python-software-properties
# add-apt-repository ppa:nova-core/milestone
# apt-get update
# apt-get install nova-compute</pre></div></div>

<p>On both nova-cc and nova-compute:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># cat &gt;&gt; /etc/nova/nova.conf &lt;&lt; &quot;EOF&quot;
--sql_connection=mysql://somepasshere@10.176.65.54/nova
--image_service=nova.image.glance.GlanceImageService
--glance_api_servers=10.176.65.54:9292
--rabbit_host=10.176.65.54
EOF
# for SERVICE in `ls -1 /etc/init.d/nova*`; do service $SERVICE restart; done</pre></div></div>

<p>Now what we need to do is create our 192.68.0.0/16 network.  We&#8217;ll use OpenVPN to do this, and we&#8217;ll use the eth1 private network (10.176.64.0/18) to do this this.  Again, the idea here is to have a completely separate network which won&#8217;t interfere with what&#8217;s already out there.</p>
<p>On both:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># apt-get install openvpn</pre></div></div>

<p>On nova-cc:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># cd /etc/openvpn
# openvpn --genkey --secret openvpn.key
# scp openvpn.key root@10.176.95.220:/etc/openvpn
# cat &gt; /etc/openvpn/openvpn.server &lt;&lt; &quot;EOF&quot;
dev tap
ifconfig 192.168.0.1 255.255.255.0
secret /etc/openvpn/openvpn.key
daemon
EOF
# cat &gt; /etc/network/if-pre-up.d/00openvpn &lt;&lt; &quot;EOF&quot;
#!/bin/bash
&nbsp;
/usr/sbin/openvpn --config /etc/openvpn/openvpn.server
&nbsp;
exit 0
EOF
# chmod 755 /etc/network/if-pre-up.d/00openvpn</pre></div></div>

<p>On nova-compute:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># cat &gt; /etc/openvpn/openvpn.client &lt;&lt; &quot;EOF&quot;
remote 10.176.65.54
dev tap
ifconfig 192.168.0.3 255.255.255.0
secret /etc/openvpn/openvpn.key
daemon
EOF
# cat &gt; /etc/network/if-pre-up.d/00openvpn &lt;&lt; &quot;EOF&quot;
#!/bin/bash
&nbsp;
/usr/sbin/openvpn --config /etc/openvpn/openvpn.client
&nbsp;
/usr/sbin/brctl addbr br100
/usr/sbin/brctl addif br100 tap0
&nbsp;
/sbin/ifconfig tap0 0.0.0.0
/sbin/ifconfig br100 192.168.0.3
&nbsp;
exit 0
EOF
# chmod 755 /etc/network/if-pre-up.d/00openvpn</pre></div></div>

<p>Finally, on both nodes:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># echo &quot;--flat_interface=tap0&quot; &gt;&gt; /etc/nova/nova/.conf</pre></div></div>

<p>This causes nova-network to bridge into tap0.</p>
<p>Let&#8217;s recap what we&#8217;ve done.  On nova-cc, we&#8217;re configuring OpenVPN to act as a server.  We&#8217;re bringing tap0 up with IP 192.168.0.1/24 and the <em>/etc/network/if-pre-up.d/00openvpn</em> script ensures that the VPN server is started on on boot (specifically, before the other network devices are brought up).  On nova-compute, we configure OpenVPN as a client, and the <em>/etc/network/if-pre-up.d/00openvpn</em> script creates a bridge (br100), adds the tap0 interface to it, and then brings 192.168.0.3 up on br100.  If I recall correctly, the tap0 device doesn&#8217;t appear to be &#8220;up&#8221; until we ifconfig it, which is why we just set it to 0.0.0.0.  Don&#8217;t quote me on this though, as I can&#8217;t quite remember.  <img src='http://blog.defunct.ca/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>I know very little about bridging, but essentially a bridge &#8220;connects two or more different physical ethernets together to form one large (logical) ethernet&#8221; (taken from <em>/usr/share/doc/bridge-utils/HOWTO</em>), and this is precisely what we have done here.  We bridge the virtual interfaces for running instances (ie. vnet0) with tap0 (our VPN connection), which means that nova-cc can speak to instances running on nova-compute, and vice-versa.  This is also essential as dnsmasq (our DHCP server) runs on nova-cc (spawned by nova-network), and without this bridging in place our instances would not be able to have their networking configured automatically on boot by the DHCP server.</p>
<p>Also, the reason why we don&#8217;t have to explicitly configure br100 on nova-cc is because that runs nova-network, which handles the bridging automatically.  The only thing we did need to do on the nova-cc side is instruct nova-network on which device to bridge into (&#8211;flat_interface=tap0).  The last thing I&#8217;ll say here is that OpenVPN used device tun0 by default, but we have to use tap0 (a virtual Ethernet adapter) as brctl creates Ethernet bridges, and a tun device is a &#8220;virtual point-to-point&#8221; link (see <a href="http://openvpn.net/index.php/open-source/faq/75-general/305-what-is-the-difference-between-a-tun-device-and-a-tap-device.html">this</a> for a tad more info).</p>
<p>Go ahead and reboot each instance, one at a time, to ensure that everything comes up as expected.</p>
<p>Once back up, on nova-cc:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># mysql -u root nova
mysql&gt; SELECT * FROM fixed_ips WHERE id=4;
+---------------------+---------------------+------------+---------+----+-------------+------------+-------------+-----------+--------+----------+
| created_at          | updated_at          | deleted_at | deleted | id | address     | network_id | instance_id | allocated | leased | reserved |
+---------------------+---------------------+------------+---------+----+-------------+------------+-------------+-----------+--------+----------+
| 2011-07-22 16:21:35 | 2011-07-22 20:48:26 | NULL       |       0 |  4 | 192.168.0.3 |          1 |        NULL |         0 |      0 |        0 |
+---------------------+---------------------+------------+---------+----+-------------+------------+-------------+-----------+--------+----------+
1 row in set (0.00 sec)
&nbsp;
mysql&gt; UPDATE fixed_ips SET reserved=1 WHERE id=4 LIMIT 1;</pre></div></div>

<p>What we&#8217;re doing here is &#8220;reserving&#8221; 192.168.0.3 for the other end of the VPN link on nova-compute.  192.168.0.2 is already reserved, but I&#8217;m not sure if nova uses this or will use it for something at some point.  As such, just play it safe and reserve another available IP.</p>
<p>In theory, if you now launch an instance on nova-cc, it should build on nova-compute and the IP assigned should be accessible via nova-cc.  The instance on nova-compute will have a gateway of 192.168.0.1 (which is physically on nova-cc), which means that all traffic in and out of the instance will travel through nova-cc.  This also means that if nova-cc goes down, instances will not be able to communicate with the outside world (or potentially each other, though I&#8217;ve not tested myself).</p>
<p>That should be able it.  I&#8217;ve probably missed a few things, but the general gist should be here.  Also, I&#8217;m aware that there are no security best-practices implemented here, but the idea is to just get everything up and running as a proof of concept, and fine-tune later.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.defunct.ca/2011/07/22/moving-nova-compute-to-a-separate-instance/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Can&#8217;t ssh to UML instances when creating w/ valid keypair</title>
		<link>http://blog.defunct.ca/2011/07/14/cannot-ssh-to-uml-instances-when-creating-w-valid-keypair/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=cannot-ssh-to-uml-instances-when-creating-w-valid-keypair</link>
		<comments>http://blog.defunct.ca/2011/07/14/cannot-ssh-to-uml-instances-when-creating-w-valid-keypair/#comments</comments>
		<pubDate>Thu, 14 Jul 2011 22:13:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[OpenStack]]></category>

		<guid isPermaLink="false">http://blog.defunct.ca/?p=455</guid>
		<description><![CDATA[While creating UML instances on nova, I noticed I wasn&#8217;t able to ssh into my instances using the keypair I previously created. Looking at the logs on the nova-compute node, I saw: 2011-07-13 21:15:22,256 INFO nova.virt.libvirt_conn [-] instance instance-0000003d: injecting key into image 3 2011-07-13 21:15:22,256 DEBUG nova.utils [-] Running cmd (subprocess): sudo losetup --find [...]]]></description>
			<content:encoded><![CDATA[<p>While creating UML instances on nova, I noticed I wasn&#8217;t able to ssh into my instances using the keypair I previously created.  Looking at the logs on the nova-compute node, I saw:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">2011-07-13 21:15:22,256 INFO nova.virt.libvirt_conn [-] instance instance-0000003d: injecting key into image 3
2011-07-13 21:15:22,256 DEBUG nova.utils [-] Running cmd (subprocess): sudo losetup --find --show /var/lib/nova/instances/instance-0000003d/disk from (pid=838) execute /usr/lib/pymodules/python2.7/nova/utils.py:143
2011-07-13 21:15:22,424 DEBUG nova.utils [-] Running cmd (subprocess): sudo kpartx -a /dev/loop0 from (pid=838) execute /usr/lib/pymodules/python2.7/nova/utils.py:143
2011-07-13 21:15:22,509 DEBUG nova.utils [-] Running cmd (subprocess): sudo kpartx -d /dev/loop0 from (pid=838) execute /usr/lib/pymodules/python2.7/nova/utils.py:143
2011-07-13 21:15:22,563 DEBUG nova.utils [-] Running cmd (subprocess): sudo losetup --detach /dev/loop0 from (pid=838) execute /usr/lib/pymodules/python2.7/nova/utils.py:143
2011-07-13 21:15:22,604 WARNING nova.virt.libvirt_conn [-] instance instance-0000003d: ignoring error injecting data into image 3 (Mapped device was not found (we can only inject raw disk images): /dev/mapper/loop0p1)</pre></div></div>

<p>I tried running the kpartx commands above, but they didn&#8217;t return anything.  This was because the <a href="http://fs.devloop.org.uk/filesystems/CentOS-5.6/CentOS5.6-AMD64-root_fs.bz2">image</a> I was using had no partition table.  </p>
<p>To fix, I effectively created a new image and copied data from the original one.</p>
<p>To begin, create a spare file (see <a href="https://wiki.archlinux.org/index.php/Sparse_file">this</a> for more info):</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># cd /root
# dd if=/dev/zero of=CentOS5.6-AMD64-new-root_fs bs=1 count=0 seek=1024M</pre></div></div>

<p>Now, create a partition to span the entire disk (replace /dev/loop0 with whatever losetup returns):</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># losetup --show --find CentOS5.6-AMD64-new-root_fs
/dev/loop0
# fdisk /dev/loop0</pre></div></div>

<p>Now, use kpartx to make the partition visible to the host, and create a filesystem on that partition:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># parted
# kpartx -a /dev/loop0
# mke2fs -j /dev/mapper/loop0p1</pre></div></div>

<p>Mount the original image and copy data over:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># losetup --show --find CentOS5.6-AMD64-root_fs 
/dev/loop1
# mkdir /mnt/loop{0,1}
# mount /dev/mapper/loop0p1 /mnt/loop0
# mount /dev/loop1 /mnt/loop1
# cd /mnt/loop1
# rsync -a . /mnt/loop0</pre></div></div>

<p>Update the fstab on the new image (this is necessary as the partition layout has now changed):</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># cd /mnt/loop0/etc
# sed -i 's/ubda/ubda1/g' fstab
# cd /
# umount /mnt/loop{0,1}
# kpartx -d /dev/loop0
# losetup -d /dev/loop{0,1}</pre></div></div>

<p>Modify /etc/nova/libvirt.xml.template, changing this line from:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">&lt;root&gt;/dev/ubda&lt;/root&gt;</pre></div></div>

<p>to:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">&lt;root&gt;/dev/ubda1&lt;/root&gt;</pre></div></div>

<p>That should be about it.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.defunct.ca/2011/07/14/cannot-ssh-to-uml-instances-when-creating-w-valid-keypair/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using UML instances on OpenStack Nova</title>
		<link>http://blog.defunct.ca/2011/07/02/using-uml-instances-on-openstack-nova/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=using-uml-instances-on-openstack-nova</link>
		<comments>http://blog.defunct.ca/2011/07/02/using-uml-instances-on-openstack-nova/#comments</comments>
		<pubDate>Fri, 01 Jul 2011 23:58:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[OpenStack]]></category>

		<guid isPermaLink="false">http://blog.defunct.ca/?p=436</guid>
		<description><![CDATA[As mentioned in http://blog.defunct.ca/?p=411, I&#8217;m running OpenStack on a XenServer virtual machine and need to be able to use something like UML to run instances from within the VM. I had to hack a number of things in order to get this to work. First things first. Let&#8217;s get install user-mode-linux: # apt-get update # [...]]]></description>
			<content:encoded><![CDATA[<p>As mentioned in <a href="http://blog.defunct.ca/?p=411">http://blog.defunct.ca/?p=411</a>, I&#8217;m running OpenStack on a XenServer virtual machine and need to be able to use something like UML to run instances from within the VM.  I had to hack a number of things in order to get this to work.</p>
<p>First things first.  Let&#8217;s get install user-mode-linux:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># apt-get update
# apt-get install user-mode-linux</pre></div></div>

<p>Now, grab the CentOS 5.6 x86_64 image from <a href="http://fs.devloop.org.uk/">http://fs.devloop.org.uk/</a> (we&#8217;re using a 64-bit XenServer VM):</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># cd /root
# wget http://fs.devloop.org.uk/filesystems/CentOS-5.6/CentOS5.6-AMD64-root_fs.bz2
# bunzip2 CentOS5.6-AMD64-root_fs.bz2</pre></div></div>

<p>There is an image on <a href="http://wiki.openstack.org/Nova/UML">http://wiki.openstack.org/Nova/UML</a>, however I couldn&#8217;t get this image to boot properly.  As such, I opted for the CentOS 5.6 image above.</p>
<p>A few things within the image needed adjusting, so I:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># mkdir /mnt/image
# losetup --find --show CentOS5.6-AMD64-root_fs
/dev/loop0
# mount /dev/loop0 /mnt/image
# cp -a /usr/lib/uml/modules/2.6.35.1/ /mnt/image/lib/modules/
# chroot /mnt/image
# sed -i 's@LABEL=ROOT@/dev/ubda@g' /etc/fstab
# chkconfig network on
# exit
# umount /mnt/image
# losetup -d /dev/loop0</pre></div></div>

<p>Note that /usr/lib/uml/modules/2.6.35.1/ is provided by the user-mode-linux package on Ubuntu 10.10, so adjust accordingly to what you&#8217;re running.  Also, UML seems to use device /dev/ubda, so we modify /etc/fstab w/ that.</p>
<p>Now we can bundle up the image:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># cd /root
# euca-bundle-image -i CentOS5.6-AMD64-root_fs
# euca-upload-bundle -b uml-image-bucket -m /tmp/CentOS5.6-AMD64-root_fs.manifest.xml
# euca-register uml-image-bucket/CentOS5.6-AMD64-root_fs.manifest.xml</pre></div></div>

<p>Once that&#8217;s done, we remove this from /etc/nova/nova.conf:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">--libvirt_type=qemu</pre></div></div>

<p>&#8230; and add this:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">--libvirt_type=uml
--use_cow_images=false
--libvirt_xml_template=/etc/nova/libvirt.xml.template</pre></div></div>

<p>Since I&#8217;ve specified &#8211;libvirt_xml_template in /etc/nova/nova.conf, we need to now create that file:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># cp -a /usr/share/pyshared/nova/virt/libvirt.xml.template /etc/nova/libvirt.xml.template</pre></div></div>

<p>Now open up /etc/nova/libvirt.xml.template and remove the following:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">#if $getVar('vncserver_host', False)
        &lt;graphics type='vnc' port='-1' autoport='yes' keymap='en-us' listen='${vncserver_host}'/&gt;
#end if</pre></div></div>

<p>The reason for doing this is because it appears that we run into an issue similar to the one reported in <a href="https://bugs.launchpad.net/nova/+bug/749973">here</a>.  Update: I&#8217;ve since created a bug report for this UML issue <a href="https://bugs.launchpad.net/nova/+bug/805083">here</a>.</p>
<p>Now we can restart the nova-compute service and create an instance:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># service nova-compute restart
# euca-run-instances ami-778c501e -k mykey -t m1.tiny</pre></div></div>

<p>(replace ami-778c501e with your image name, which can be found by running euca-describe-images)</p>
<p>If your instance doesn&#8217;t go into a running state, have a look at the libvirt.xml file under /var/lib/nova/instances/####/ (replacing #### w/ your instance&#8217;s name, found by running euca-describe-instances), ensuring that there is no reference to the vnc stuff in there.  If there is, then the template hasn&#8217;t been updated or isn&#8217;t being used correctly.  Otherwise, your instance should be ssh-able, using the IP returned by euca-describe-instances.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.defunct.ca/2011/07/02/using-uml-instances-on-openstack-nova/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

