A footnote on the format of the property list: you can also use XML property lists, but they tend to be more verbose. You can also easily convert a property list to XML format using the
plutil command. To convert the
batch.plist file, for example, you simply issue the following command:
drew pbook: plutil -convert xml1 batch.plist
This replaces the contents of the
batch.plist file with the XML below, which contains exactly the same information.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>jobSpecification</key> <dict> <key>applicationIdentifier</key> <string>com.apple.xgrid.cli</string> <key>inputFiles</key> <dict/> <key>name</key> <string>Sleepy Calendar</string> <key>submissionIdentifier</key> <string>abc</string> <key>taskSpecifications</key> <dict> <key>0</key> <dict> <key>arguments</key> <array> <string>3</string> <string>2005</string> </array> <key>command</key> <string>/usr/bin/cal</string> </dict> <key>1</key> <dict> <key>arguments</key> <array> <string>20</string> </array> <key>command</key> <string>/bin/sleep</string> </dict> <key>hi</key> <dict> <key>arguments</key> <array> <string>Hi Mom!</string> </array> <key>command</key> <string>/bin/echo</string> </dict> </dict> </dict> </dict> </plist>
Setting Up a Secure Xgrid
To this point we have largely ignored the issue of security. If this doesn't bother you, you can happily skip this section. But if it does worry you, it is possible to use password authentification with the Xgrid controller supplied in the client version of Tiger, although Apple hasn't gone out of its way to make it easy to configure. The problem is, there isn't any straightforward means of entering the controller's passwords.
A controller has two passwords: one for agents, and one for clients. These passwords need to be stored in a special format in the files
/etc/xgrid/controller/client-password, but you'll probably find these files are missing from your file system. Luckily, Brian Granger discovered a simple way to create these files, and posted his solution to the Xgrid mailing list, so what follows is thanks to Brian.
The controller password files may not exist on Mac OS X client, but the agent files do. You create them whenever you enter a password in the Xgrid configuration pane of System Preferences. So the trick to getting password files for the controller is simply to copy the ones created for the agent.
The first thing you have to do is set a password for your agent. You do this like so:
- Open the Sharing pane in System Preferences.
- Select the Services tab, and then the Xgrid row of the table view.
- Press the Configure... button.
- Select the Password authentication method from the pop-up button, and enter a password.
- Click the OK button.
There should be a file containing the agent password at the path
/etc/xgrid/agent/controller-password. The file is called
controller-password because it is the password used to authenticate the agent to a controller.
Now that you have a correctly formatted password file, you can simply copy it to the correct path for the controller passwords, like so:
sudo cp /etc/xgrid/agent/controller-password \ /etc/xgrid/controller/agent-password sudo cp /etc/xgrid/agent/controller-password \ /etc/xgrid/controller/client-password
(Note that you have to be an administrator to do this; you will be prompted for your account password.) The controller now has one password file to authenticate the agent, and one to authenticate the client. In this case, the passwords are all the same, because we simply copied the same file for each. If you want different passwords, you could change the agent password in the System Preferences multiple times, and after each change, copy the password file, but for most a single password will suffice.
At this point you have to edit the property list of the controller so that it uses password authentication. Open the file
/Library/Preferences/com.apple.xgrid.controller.plist, and change the entries for the
ClientAuthentication keys to
Password, rather than
None. It should end up looking something like this:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>AgentAuthentication</key> <string>Password</string> <key>ClientAuthentication</key> <string>Password</string> </dict> </plist>
With all the configuration complete, all you have to do is restart the agent and controller. For the agent, you can either open the System Preferences Sharing pane and stop and start the Xgrid agent, or you can enter the following command:
drew pbook: sudo xgridctl a restart
For the controller, you can enter this:
drew pbook: sudo xgridctl c restart
To test that everything went according to plan, try submitting one of the
xgrid jobs above, using the
-p option to provide the controller password.
If you find all of this tiresome, you might like to try Ed Baskerville's XgridLite tool, which was mentioned earlier. It can do it all at the touch of a button.
Until Next Time...
That completes our introduction to setting up Xgrid, and using the command-line
xgrid tool. Next time, we will leave Terminal and take a look at the Cocoa API to Xgrid. To spice things up a bit, we will draw on a couple of other Tiger technologies--Automator and Core Image--to build an Xgrid-enabled, image-processing tool. See you then.
Return to the Mac DevCenter