Archive for October 2008

Adding SMF support to your debian package

Services in Nexenta are handled using solaris SMF. This makes it very easy to start and stop services; you dont have to worry about it’s dependency on other services, which is taken care of by SMF automatically. This cheetsheet lists how easy it is to use SMF.

dh_installsmf

dh_installsmf is one of Nexenta’s addition to Debian’s debhelper scripts. This makes it trivial to add SMF support in a debian package that installs a service at /etc/init.d/<service>

We’ll take a look at how we can add support to such a package.

XML Manifest file

The SMF framework requires a manifest file, which is an XML file, that provides information regarding the service. This information includes the services that this particular service depends on (or configurations files, etc).

It also lists the commands that need to be run to enable, disable the service, or to set various other parameters. The format of the manifest file is explained here.

The Blastwave package has a good collection of manifest files for various packages. Lets take a look at the manifest for apache2:

<?xml version=”1.0″?>
<!DOCTYPE service_bundle SYSTEM “/usr/share/lib/xml/dtd/service_bundle.dtd.1″>

<service_bundle type=”manifest” name=”apache2″>
<service name=”network/apache2″ type=”service” version=”4″>
<create_default_instance enabled=”false”/>
<single_instance/>

<!– First of all, if the config file is not present,
then we needn’t bother with anything else.  –>
<dependency name=”config-file” grouping=”require_all” restart_on=”none” type=”path”>
<service_fmri value=”file:///etc/apache2/apache2.conf”/>
</dependency>

<!– If there’s no network, then there’s no point in running –>
<dependency name=”loopback” grouping=”require_all” restart_on=”error” type=”service”>
<service_fmri value=”svc:/network/loopback:default”/>
</dependency>
<dependency name=”physical” grouping=”require_all” restart_on=”error” type=”service”>
<service_fmri value=”svc:/network/physical:default”/>
</dependency>
<dependency name=”fs-local” grouping=”require_all” restart_on=”none” type=”service”>
<service_fmri value=”svc:/system/filesystem/local”/>
</dependency>
<exec_method type=”method” name=”start” exec=”/lib/svc/method/apache2 start” timeout_seconds=”60″/>
<exec_method type=”method” name=”stop” exec=”/lib/svc/method/apache2 stop” timeout_seconds=”60″/>
<exec_method type=”method” name=”refresh” exec=”/lib/svc/method/apache2 refresh” timeout_seconds=”60″/>
<stability value=”Unstable”/>
<template>
<common_name>
<loctext xml:lang=”C”>Apache2 web server</loctext>
</common_name>
<documentation>
<manpage title=”apache2″ section=”7″/>
<doc_link name=”apache.org” uri=”http://httpd.apache.org/docs/2.0″/>
</documentation>
</template>
</service>
</service_bundle>

In the above file, we see that apache2 has defined the following dependencies:

  • The file /etc/apache2/apache2.conf
  • The network service (and the physical interface being up)
  • The local filesystem

It also defines three methods start, stop and refresh, which are commands for this particular service (start the webserver, stop the webserver, reload the webserver). They call a script /lib/svc/method/apache2, which brings us to dh_installsmf

debian/rules

The service script /lib/svc/method/&lt;package&gt; is generated by dh-installsmf, so when you create an SMF manifest file for Nexenta, make sure you call that file. dh_installsmf will create a script /lib/svc/method/&lt;package&gt; which is a wrapper over the /etc/init.d/&lt;package&gt; file.

So in our case the debian/rules file in the apache2 package will be modified as

[snip]

rm -f debian/apache2-utils/usr/share/doc/apache2-utils/NEWS.Debian
dh_installinit -a –no-start -r –name=apache2 — defaults 91 09
dh_installsmf –service apache2 –manifest debian/apache2.xml -papache2.2-common
dh_installcron -a -r –name=apache2
if [ "$(LSB_RELEASE)" = "Ubuntu" ]; then \
dh_strip -a; \
else \
dh_strip -a –dbg-package=apache2-dbg -Napache2-mpm-worker -Napache2-mpm-event -Napache2-mpm-prefork -Napache2-dbg; \
fi
dh_link -a
dh_compress -a
[snip]

The –service argument gives the name of the service, the –manifest points to the manifest file and -p tells it which package the smf changes go into. This is basically the package that provides the /etc/init.d/&lt;package&gt; file.

And that is how we generate SMFed debian packages.

Toulouse

Had a wonderful short trip in Toulouse. It was a short trip and great to see the enthusiasm in the opensolaris community.

I’ll probably do a longer post a little later, for now heres a link to the presentation I made for you to peruse.

Goodbye, Toulouse!

Mumbai diary

I was in Mumbai the last two days for a Visa interview (I’ll be speaking at the GUSES conference). Below are a few notes in no particular order:

Gateway of India, Mumbai

  • Friendly people
  • Very few touristy spots
  • The Churchgate to Chaupati walk (and those tetrahedral shaped stones along the sea) is beautiful
  • Tall buildings
  • Good bus service
  • Crowded trains
  • Travel is cheaper than Bangalore
  • Food is a tad more expensive
  • Traffic woes like Bangalore
  • Chaupati beach has good chats and a great view
  • People actually voluntarily formed a queue at the bus stop. Now thats a new one.
  • Men and women use the same door to enter vehicles, and happily sit together.. no stupid 33% rules. this was nice to see.
  • Feels good to speak in fluent Hindi than awkward Kannada (I’m ashamed I haven’t learned Kannada better)
  • Gateway of India is not the India Gate.
  • It looks just like in pictures.
  • I’m called ‘Seth
  • The National Museum of Modern art is worth checking out if you’re in the area. (And so is the Salar Jang Museum In Hyderabad.. the Veiled Rebecca is as good as it is said to be). Check these out if you’re in the area.

Also

  • How cool is it to fly a few meters above clouds?! This happened on the way to Mumbai, and we were at the cloud altitude for around 5 minutes. Most passengers were busy reading or sleeping and I couldn’t believe it. The view outside was magnificent (and it doesn’t get boring after a few times). Just wonder.. a 100 years ago, people would have given an arm and a leg for a chance to fly above the clouds.
  • And if that wasn’t enough, the return trip was at night over a thunderstorm. Seeing lightning from above is an experience not to be missed :) Of course, most of the other folks were sleeping/eating.

Thats it. Overall Mumbai gets a thumbs up.

Nexenta and GUI

I’ve been asked this question multiple times by mail and other forums, and it also pops up quite frequently on IRC. Does Nexenta have a GUI?

The Nexenta desktop

The Nexenta desktop

Short answer

Yes, but not by default.

Long answer

Nexenta started off as a clone of ubuntu with a Solaris kernel. These versions were quite popular and got a whole lot of users. However, maintaining and supporting a large selection of packages that go into a desktop was impossible for the developers.

This was when the focus of Nexenta changed from a desktop to a core platform. The idea is to build a solid core, and allow developers to build on top of this. Thus the Nexenta Core platform was born, also sortly and lovingly called NCP. NCP provides all the packages from Ubuntu’s main repository. The NCP cd builds do not include any WM.

However –theres always a however ;) — older repositories do contain Gnome and KDE and XFCE packages. So to get a GUI environment, you’ll have to manually install those packages. This repositoy is the unstable elatte repository. The following line in your /etc/apt/sources.list should get you the packages.

deb http://www.nexenta.org/apt-gnusolaris elatte-unstable main contrib non-free

Going ahead..

All this talk is for the NCP1 (codename elatte) release. NCP2 is currently in alpha stage. Our plan for this release is to populate the repository completely with all GUI packages, so a desktop is only an apt-get install gnome-desktop away.

We cannot include this by default is because we wont be able to maintain it ourselves. We have fuzzy plans for a GUI version in the long term, but nothing concrete. We are looking for developers and enthusiasts to build distributions on top of NCP, and have various variants. So come join the community and be the Linux Mint to our Ubuntu. The nexenta-builder package is where you start.

Join us on IRC #nexenta@irc.freenode.net. You can also take a look at my 2 part development introduction to Nexenta here and here.