~tbielawa/vmbuilder/macdefining

« back to all changes in this revision

Viewing changes to VMBuilder/vm.py

  • Committer: tim bielawa
  • Date: 2008-10-31 08:12:20 UTC
  • Revision ID: tbielawa@fridge-20081031081220-wif81qh6ntl5i3pa
Added regular expression checking against entered mac to check for valid format

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import ConfigParser
22
22
from   gettext             import gettext
23
23
import logging
 
24
import re
24
25
import os
25
26
import optparse
26
27
import shutil
264
265
        """
265
266
 
266
267
        logging.debug("ip: %s" % self.ip)
 
268
        
 
269
        if self.mac:
 
270
            valid_mac_address = re.compile("([0-9a-f]{2}:){5}([0-9a-f]{2})", re.IGNORECASE)
 
271
            if not valid_mac_address.search(self.mac):
 
272
                raise VMBuilderUserError("Malformed MAC address entered: %s" % self.mac)
 
273
            else:
 
274
                logging.debug("mac: %s" % self.mac)
267
275
 
268
276
        if self.ip != 'dhcp':
269
277
            if self.domain == '':