+ session.add(machine)
+ session.commit()
+ except:
+ session.rollback()
+ raise
+
+ session.begin()
+ try:
+ if hasattr(validate, 'disksize'):
+ disksize = validate.disksize
+ disk = machine.disks[0]
+ if disk.size != disksize:
+ olddisk[disk.guest_device_name] = disksize
+ disk.size = disksize
+ session.add(disk)
+ for diskname in olddisk:
+ controls.resizeDisk(oldname, diskname, str(olddisk[diskname]))
+ session.add(machine)
+ session.commit()
+ except:
+ session.rollback()
+ raise
+
+ session.begin()
+ try:
+ if hasattr(validate, 'name'):
+ machine.name = validate.name
+ for n in machine.nics:
+ if n.hostname == oldname:
+ n.hostname = validate.name
+ if hasattr(validate, 'name'):
+ controls.renameMachine(machine, oldname, validate.name)
+ session.add(machine)