'Called to reconfigure the VM. Actually customizes the property
setting of the Virtual Machine object.'

def reconfig(self, factory, val):

    if (hasattr(val, 'name') and val.name):
        self.set('name', val.name)
    if hasattr(val, 'extraConfig'):
        extraConfigs = _merge_extraconfig(self.get('config.extraConfig').OptionValue, val.extraConfig)
        self.get('config.extraConfig').OptionValue = extraConfigs
    if (hasattr(val, 'instanceUuid') and (val.instanceUuid is not None)):
        if (val.instanceUuid == ''):
            val.instanceUuid = uuidutils.generate_uuid()
        self.set('summary.config.instanceUuid', val.instanceUuid)
    try:
        if (not hasattr(val, 'deviceChange')):
            return
        if hasattr(val, 'extraConfig'):
            for extra in val.extraConfig:
                self._update_extra_config(extra)
        if (len(val.deviceChange) < 2):
            return
        controller_key = val.deviceChange[0].device.controllerKey
        filename = val.deviceChange[0].device.backing.fileName
        disk = VirtualDisk()
        disk.controllerKey = controller_key
        disk_backing = VirtualDiskFlatVer2BackingInfo()
        disk_backing.fileName = filename
        disk_backing.key = (-101)
        disk.backing = disk_backing
        disk.capacityInBytes = 1024
        disk.capacityInKB = 1
        controller = VirtualLsiLogicController()
        controller.key = controller_key
        devices = _create_array_of_type('VirtualDevice')
        devices.VirtualDevice = [disk, controller, self.device[0]]
        self.set('config.hardware.device', devices)
    except AttributeError:
        pass
