Exemplo n.º 1
0
    def rollback(machineguid, timestamp):
        """
        Rolls back a VM based on a given disk snapshot timestamp
        :param machineguid: Guid of the machine to rollback
        :param timestamp: Timestamp to rollback to
        """
        vmachine = VMachine(machineguid)
        if vmachine.hypervisor_status == 'RUNNING':
            raise RuntimeError(
                'vMachine {0} may not be running to set it as vTemplate'.
                format(vmachine.name))

        snapshots = [
            snap for snap in vmachine.snapshots
            if snap['timestamp'] == timestamp
        ]
        if not snapshots:
            raise ValueError(
                'No vmachine snapshots found for timestamp {0}'.format(
                    timestamp))

        for disk in vmachine.vdisks:
            VDiskController.rollback(diskguid=disk.guid, timestamp=timestamp)

        vmachine.invalidate_dynamics(['snapshots'])
Exemplo n.º 2
0
    def rollback(machineguid, timestamp):
        """
        Rolls back a VM based on a given disk snapshot timestamp
        """
        vmachine = VMachine(machineguid)
        if vmachine.hypervisor_status == 'RUNNING':
            raise RuntimeError('vMachine {0} may not be running to set it as vTemplate'.format(
                vmachine.name
            ))

        snapshots = [snap for snap in vmachine.snapshots if snap['timestamp'] == timestamp]
        if not snapshots:
            raise ValueError('No vmachine snapshots found for timestamp {0}'.format(timestamp))

        for disk in vmachine.vdisks:
            VDiskController.rollback(diskguid=disk.guid,
                                     timestamp=timestamp)

        vmachine.invalidate_dynamics(['snapshots'])