I have been spending a fair amount of time learning Python, and have come across a couple of cool online resources. If you are interested in learning Python but don’t want to buy a book, these (and lots of time writing code) resources are really all you need to become a Python guru:
Python documentation: http://docs.python.org/
Python tutorial: http://www.alan-g.me.uk/
Mozilla team tutorials: http://groups.google.com/group/mozqa-team-python-learning
Various Python tutorials:http://www.awaretek.com/tutorials.html
Dive into Python book: http://diveintopython.org/toc/index.html
I use the ISC DHCP server to manage IP allocations at home, and to provide the pxegrub handoff location to new systems I’m building. Since my DHCP server has become rather important, I wanted to install it to a file system that was mirrored. To figure out how to do this, I read through the ISC DHCP Makefiles (BIND 4.X uses autoconf, which allows you to set the installation destination with the –prefix option). This led me to the Makefile.conf file, which contains settings that override the global defaults. These overrides include the bin, man and lib directories, and the directory to look for the configuration file. After a minute or two with vi, I added the desired installation destination and proceeded to compile the server. This worked like a charm, and the settings I used are listed below for reference:
$ pwd
/home/matty/dhcp-3.1.2
$ more Makefile.conf
## Defaults...
SCRIPT = none
USERBINDIR = /bits/software/apps/dhcp-3.1.2/bin
BINDIR = /bits/software/apps/dhcp-3.1.2/sbin
CLIENTBINDIR=/bits/software/apps/dhcp-3.1.2/sbin
ADMMANDIR = /bits/software/apps/dhcp-3.1.2/man/cat8
ADMMANEXT = .0
FFMANDIR = /bits/software/apps/dhcp-3.1.0/man/cat5
FFMANEXT = .0
LIBMANDIR = /bits/software/apps/dhcp-3.1.0/man/cat3
LIBMANEXT = .0
USRMANDIR = /bits/software/apps/dhcp-3.1.0/man/cat1
Now you may be asking me why /bits/software/dhcp-3.1.0? Well, bits is a mirrored ZFS pool, and the software in /bits/software/apps is linked into [bin|man|sbin|lib] directories with the incredibly awesome stow package.
I configured a jumpstart server this weekend in my home lab, and needed to enable tftp to allow clients to fetch pxegrub and the Solaris kernel. To enable the tftp service, I uncommented the tftp service in /etc/inetd.conf and ran inetconv. It later dawned on me that I needed to update the directory tftp serves files from, so I needed to adjust the tftp entry and re-run inetconv. This resulted in the following error:
$ grep tftp /etc/inetd.conf
# TFTPD - tftp server (primarily used for booting)
tftp dgram udp6 wait root /usr/sbin/in.tftpd in.tftpd -s /bits/provisioning/boot
$ inetconv
inetconv: Notice: Service manifest for tftp already generated as /var/svc/manifest/network/tftp-udp6.xml, skipped
The fix for this was simple, and required me to run inetconv with the “-f” (force update) option to force an update:
$ inetconv -f
tftp -> /var/svc/manifest/network/tftp-udp6.xml
Importing tftp-udp6.xml ...Done
That did the trick, and my lab machines are now building via the network.
I’ve supported Solaris NFS servers for as long as I can remember. The typical drill I follow to get a server up and running is:
1. Work with a developer / app support to determine how much space is needed.
2. Provision space on the server.
3. Enabled the NFS server processes.
4. Edit the /etc/dfs/sharetab file to share out the file system I provisioned.
5. Update clients with the new mount information.
With recent opensolaris builds, step 4 has changed slightly. The new way to add NFS shares is through the sharemgr utility, which allows you to create share groups (i.e., these are groupings of similar network shares) and shares, add and remove properties to these shares, and enable and disable shares. To create a new share group, the sharemgr utility can be run with the “create” option, the protocol (NFS or SMB) to associate with this share, and the name of the share:
$ sharemgr create -P nfs build
Once a share group is created, you can use the “list” subcommand to view the group’s properties:
$ sharemgr list -v
default enabled nfs
zfs enabled
build enabled nfs
To add one or more shares to a group, you can run the sharemgr utility with the “add-share” subcommand, the directory to share out, and an optional description to associate with the share:
$ sharemgr add-share -s /bits/provisioning -d "Build infrastructure"
build**
To view shares, you can run sharemgr with the “show” option:
$ sharemgr show -v
default zfs build /bits/provisioning “Build infrastructure”
Now assuming you don’t want the world to be able to access the share, you will most likely want to configure some type of security to limit who can access it. To limit the list of clients that can access shares in the build group to the 192.168.1.0/24 network, you can run sharemgr with the “set” option, the protocol, the properties to set, and the share group to attach these properties to:
$ sharemgr set -P nfs -p anon=0,ro=@192.168.1.0/24 build
To view the properties, the sharemgr utility can once again be run with the “show” subcommand:
$ sharemgr show -vp
default nfs=() zfs build nfs=(anon="0,ro=@192.168.1.0/24”) /bits/provisioning “Build infrastructure”
While a bit more complex than using echo to send a string to /ec/dfs/dfstab, the real utility comes into play when you are configuring SMB shares. Once I get around to testing out the opensolaris CIFS server, I will add a follow up post detailing how to use sharemgr to share out CIFS shares.
I recently converted from bc to Python for basic calculations, and I like the fact that I can do basic arithmetic from the Python interpreter:
$ python
>>> 5.0 / 3.0
1.6666666666666667
One thing that bugged me about this was the fact that I had to add a decimal point to the input values to get a fraction as a result. While reading through one of my Python books, I came across the future module’s division feature:
$ python
>>> 5 / 3
1
>>> from __future__ import division
>>> 5 / 3
1.6666666666666667
This allow fractional values to be displayed by default, which is exactly what I’m looking for. I have been spending a bunch of time learning Ruby and Python, and so far I am really digging these languages.