VMWare on Ubuntu Linux with bridged network to XP

23 August 2007

XP on Linux

I run Ubuntu on my main machine, but needed Windows for a project for one of my clients. I installed the free VMWare Server from the Ubuntu commercial repository and installed Windows XP Pro on a virtual machine.

VMWare networking modes

There are three different networking modes in VMWare to give the virtual machine network access:

Host-only
A private network between the host and VM. The VM can’t be accessed by other machines on the network.
NAT
The VM shares the IP address of the host.
Bridged
The VM has its own IP address and can be accessed by the host and other machines on the network as if it was a separate box.

I wanted to keep my virtual Windows box as isolated as possible for security reasons – Windows boxes get compromised so easily. I used bridged networking to give the virtual machine its own IP address and blocked outgoing Internet access for that machine on my router firewall.

Networking problems with Samba/SMB

I wanted to share files between the Linux host and the Windows virtual machine. I used Samba on Linux to share some directories then tried to connect to them from the Windows VM. It couldn’t connect and just timed out without a helpful error message.

After messing with Samba for a while and reading the VMWare Samba docs I was no further forward. I tried using IE on Windows to connect to the web server on my Linux box. No dice. It timed out as well.

It’s the network card settings

I read some discussion in the VMWare forums about similar problems using bridged networking, but working fine with NAT.

This led to the answer on Launchpad – the problem was the network card. Apparently some network cards optimise by discarding packets they have already seen. Because the networking is effectively between two machines on the same network card, some of the data was getting lost.

The solution is to disable these settings on the Ethernet card using:

ethtool -K eth0 sg off rx off tx off

or

ethtool -K eth0 sg off rx off tx off tso off

depending on the settings supported by your network card.

I ran this command and it worked immediately. Note that when you reboot you will need to issue this command again. You could add it to /etc/rc.local or similar to have it issued automatically.

Filed under: Linux,VMWare — Scott @ 1:18 pm

Edit inline with ImageField or FileField in Django admin

22 August 2007

Django admin lets you edit related model objects “inline”. For example when editing a Recipe you can add/eding a group of Ingredient models.

Core fields for edit_inline

The related model being edited inline must specify one or more “core” fields using core=True. If the core fields are filled in, the related model is added. If the core fields are empty, the related model is removed.

This works great for normal objects with CharFields, etc, but not so well if you want to have images or files uploaded using inline editing. If the only core field is a FileField or ImageField, you’ll get strange behaviour like the file/image being removed when you edit an existing model in the admin.

Using inline editing with ImageField or FileField

In a recent project I wanted to have an item with title and description and zero or more photos. The Photo model just has an ImageField. To make it easy to edit, I wanted the photos set to edit_inline.

Here’s my first attempt:

class Item(models.Model):
    title = models.CharField(max_length=100)
    description = models.TextField()

    class Admin:
        pass

class Photo(models.Model):
    item = models.ForeignKey(Item, related_name='photos', edit_inline=models.STACKED)
    image = models.ImageField(blank=False, upload_to='items', core=True)

Notice that the ImageField in Photo has core=True to make it a core field.

This worked ok in the Django admin interface for adding a Photo to a new Item, but if I edited that Item, the Photo would be deleted.

This is a known issue (see Ticket #2534), but it’s marked as “pending design decision” and may be ignored for now since the Django admin is being rewritten to use newforms.

In the meantime I needed a workaround.

Workaround using a different core field

Instead of having the ImageField as a core field, we need something else. If you’ve got some other natural data, such as a caption, that would work fine.

In my case, I didn’t want to add any other fields to the interface, so I went with a BooleanField that is not editable.

Here’s the revised Photo model:

class Photo(models.Model):
    item = models.ForeignKey(Item, related_name='photos', edit_inline=models.STACKED)
    image = models.ImageField(blank=False, upload_to='items')
    keep = models.BooleanField(default=True, editable=False, core=True)

    def save(self):
        # Don't save if there is no image (since core field is always set).
        if not self.id and not self.image:
            return
        super(Photo, self).save()

The keep field has been added and set to be core instead of the image field. Since there is a core field and it’s not empty, the main Item model can be edited without the Photo models being deleted.

Don’t save the empties

The core field always has a value which means the Photo model is told to save even when its ImageField is empty. To prevent creating these empty objects, the Photo model overrides save() and checks if an image was uploaded to the ImageField. If not, it returns without saving.

The remaining issue is that you can’t delete a Photo using the Django admin interface. You can replace the image, but will need some other method for deleting. For me this isn’t a big problem, so the workaround solved the problem for now.

Note that this is just a workaround to the problem which hopefully will be fixed in Django at some point in the future. Ideally, the admin interface would properly handle having an ImageField or FileField as the only core field of the related model and optionally put a “remove” checkbox in the UI to allow removing the image/file.

Filed under: Django — Scott @ 3:08 pm

Replacing door seal on Hoover WDM-130 Washing Machine

19 August 2007

I recently replaced the rubber door gasket on a Hoover washer dryer. It’s the first time I’ve done any repairs on a washing machine and I didn’t find much information online. I haven’t read the Haynes Washing Machine Manual but it might have more information.

I worked on a Hoover WDM-130, but the procedure will likely be the same for other Hoover and Candy washing machines and possibly other makes.

Mouldy door seal and brown marks on clothes

The door seal, also know as door gasket, is the rubber that goes between the drum and the door and allows the drum to bounce around without any water escaping. It has lots of folds and these can get mouldy, start to smell and possibly leave stains on clothes.

There’s some good advice from UK Whitegoods on how to prevent it happening, such as leaving the door open to allow the seal to dry and doing a monthly “service wash” (run it through empty at a high temperature).

Once the door seal has mould, it’s difficult to get rid of. My washing machine was leaving brown marks on clothes after they had been through a wash, so I had to do something about it.

Replacing the door seal is not super difficult, but it’s quite awkward to get to. If you’re fairly handy and have suitable tools, you should be ok.

Replacement rubber gasket

I bought a replacement door seal from UK Whitegoods (part number 91620118 – Candy Hoover Door Seal). It was a good price and delivered quickly. The part looks green in their picture, but it is grey as you’d expect!

Tools you will need

  • 7 mm socket
  • 7 mm spanner
  • 10 mm socket
  • 13 mm socket (maybe)
  • long T-bar handle for 7 mm socket (about 30 cm long) – or other way of turning it (I used a screwdriver)

If you don’t already have the tools, you might consider the Draper socket set and Draper spanner set.

Getting inside the Hoover washing machine

Remember to disconnect the electricity from the washer dryer before opening it up.

I expected the whole front panel to come off, but the front is welded on. The sides and back are one piece, so the only ways in are from the top and through the door hole. For other jobs there is a removable hatch at the back and you might get to some things through the bottom, but most access will be through the top.

Remove the three screws along the top at the back of the machine to remove the plastic trim. The top (wood/melamine) slides out the back.

Inside top view

You’ll see a metal duct that goes in to a sleeve at the top of the rubber door seal. I found it easiest to remove this to get better access to the drum for removing the old and fitting the new door seal. It is held on by four screws (10 mm socket). You might need to remove the block of concrete (top right in picture) to be able to lift up the duct (need 10 mm and 13mm socket).

Removing the old door seal

The door seal is held to the front of the machine by a white plastic ring. Remove it by gently prising it away from the rubber and pushing the rubber in through the hole. Be careful not to break it as you will need it to fit the new seal.

White plastic ring

With the outside removed, you can get access to where the rubber attaches to the drum. The rubber seal is held to the drum by a wire ring that is tightened with a nut and bolt.

Wire ring

Tightening bolt for wire ring

You need to loosen the wire ring by undoing the bolt. There’s not much room around it, so it’s quite difficult to get it turning.

Accessing the bolt

I pulled back the rubber and put the 7 mm socket on the bolt. I then held the nut in place with a 7 mm spanner. There wasn’t enough room to use the socket driver, so I needed to turn the socket by reaching through the open top of the machine. A long T-shaped socket driver would be useful, but I used a long screwdriver to turn the socket.

Bolt adjustment top view

Once you’ve loosened the bolt enough, the wire ring will come over the rubber and you will be able to remove the rubber door seal from the drum.

This is the old seal I removed, with lots of lovely mould stains:

Old seal with mould

Fitting the new door seal to the drum

The new door seal just needs to go on in place of the old one. The tricky bit is getting all the folds of rubber in to the right places. I’ll attempt to illustrate with some photos.

The bigger side of the seal goes around the drum. The seal folds under the edge of the drum and has a groove where the wire ring fits to hold it in place. This is it fitting around the outside edge of the drum:

Seal around edge of drum

This is the other side, where it meets the basket (the rotating metal basket where the clothes go):

Seal meets metal drum

It took me a few goes to get it right. I found it easiest to use one hand inside the seal pushing it in place, and the other hand on the outside of the seal pulling the folds open to get it to wrap around the edge of the drum. You’ll want to get this right or the machine might leak water out the bottom.

Make sure the rubber sleeve is in the right place at the top so that the metal duct can plug in to it. you can see it on the left of this photo. The duct is sitting on its side where I disconnected it to make room.

Sleeve at top of seal

Put the wire ring in to the groove so that it will hold the rubber seal securely to the drum. Tighten the bolt the same way you got it off (e.g. with spanner and socket).

Fitting the duct in to the top of the door seal

The new door seal comes with an inner sleeve that attaches to the duct and then goes in to the sleeve at the top of the door seal. Both are held on to the duct with a springy strap that fits in to a groove on the door seal sleeve.

Inner sleeve that fits on duct

Inner sleeve fitted to duct

With the inner sleeve on the duct, push it in to the sleeve part at the top of the door seal. Make sure it’s fitted in well and put the springy strap around the outer sleeve. You can fit the duct back in place and screw it down.

Fitting the door seal to the front of the washing machine

The other side of the seal needs to be fitted to the door hole in the front of the machine. I found this a bit easier, but there are still various folds that fit either side.

Seal around edge of door hole at front of machine

Once it’s on, there should be a groove around the outside in to which the white plastic ring can be fitted. The ring is joined by a toothed connector that lets you tighten it in place.

White plastic ring tightener

You’ve done it

With the white plastic ring holding the door seal firmly in place, you can put the top back on the washing machine and do a little victory dance.

I hope this is helpful to anyone embarking on the same job. If nothing else, at least you know what you are getting in to and whether to tackle it yourself or pay a washing machine engineer.

Filed under: Washing Machine — Scott @ 6:31 pm