core: SnapshotValidatorTest ID generation

Changed the vmId  and snapshotId used for the test to be data members and
initialized them in the @Before method, as per JUnit best practices.

Change-Id: Ibfbc8e41b3505a104bb8b339fec9d7f9f7865b0c
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: AddDisk preview validation

In AddDiskCommand, moved the validation that the VM is not in preview
from ImagesHandler to SnapshotValidator, which is a more logical place
for it.

This patch contains the following:
* A new method in SnapshotValidator, vmNotInPreview(vmId)
* Tests for the aforementioned method in SnapshotValidatorTest.
* The usage of the aforementioned method in AddDiskCommand
* Minor amendments to AddDiskToVmCommandTest's mocking in light of the
  previous change.

Note: This patch is part of a series of patches aimed at removing the
preview validation from ImagesHandler altogether.

Change-Id: Ib282279a4b938d6fb3b08e9b2d127af4653bd51c
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: CreateAllSnapshotsFromVm preview validation

In CreateAllSnapshotsFromVm, moved the validation that the VM is not
in preview from ImagesHandler to SnapshotValidator, which is a more
logical place for it.

Note: This patch is part of a series of patches aimed at removing the
preview validation from ImagesHandler altogether.

Change-Id: Iaa60843e4bfe5684bd6fee15b49a24bc44c21bc1
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: ExportVm preview validation

In ExportVm, moved the validation that the VM is not
in preview from ImagesHandler to SnapshotValidator, which is a more
logical place for it.

Note: This patch is part of a series of patches aimed at removing the
preview validation from ImagesHandler altogether.

Change-Id: I0000858ad37f2d2b2b51e5bf9e3817ddfdc394e4
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: MoveVm preview validation

In MoveVm, moved the validation that the VM is not
in preview from ImagesHandler to SnapshotValidator, which is a more
logical place for it.

Note: This patch is part of a series of patches aimed at removing the
preview validation from ImagesHandler altogether.

Change-Id: I695a938b5fbb969421deb431f52fd1d0f0caa834
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: RemoveDisk preview validation

In RemoveDisk, moved the validation that the VM is not
in preview from ImagesHandler to SnapshotValidator, which is a more
logical place for it.

This patch does not only clean up the code, it also solves a subtle bug
in RemoveDisk's flow.
Before this patch, the VM's preview status was checked only for plugged
image disks. However, since removing a disk needs to update all of the
VM's OVFs and remove it from them, it would have performed incorrectly
if used on a VM during preview mode.

Note: This patch is part of a series of patches aimed at removing the
preview validation from ImagesHandler altogether.

Change-Id: Iefbea2785b3637ea5df3953d6e8f1a24765742a0
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: RemoveSnapshot preview validation

In RemoveSnapshot, moved the validation that the VM is not
in preview from ImagesHandler to SnapshotValidator, which is a more
logical place for it.

This patch contains the aforementioned change in RemoveSnapshot's code,
and the required adjustments to the mocking done in
RemoveSnapshotCommandTest to allow it to continue functioning.

Note: This patch is part of a series of patches aimed at removing the
preview validation from ImagesHandler altogether.

Change-Id: Ib42871fecd4738a77c657f07a464c8dd68dee592
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: TryBackToAllSnapshotsOfVm preview validation

In TryBackToAllSnapshotsOfVm, moved the validation that the VM is not
in preview from ImagesHandler to SnapshotValidator, which is a more
logical place for it.

Note: This patch is part of a series of patches aimed at removing the
preview validation from ImagesHandler altogether.

Change-Id: I636d7b96f78064fb2ebe9ab54ce7425c1173a596
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: VmPoolCommandBase preview validation

In VmPoolCommandBase, moved the validation that the VM is not
in preview from ImagesHandler to SnapshotValidator, which is a more
logical place for it.

Note: This patch is part of a series of patches aimed at removing the
preview validation from ImagesHandler altogether.

Change-Id: I483bd9bbadbbadb6678b0b0c60fabfdf8c9f0b14
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: RemoveVm preview validation

In RemoveVm, moved the validation that the VM is not
in preview from ImagesHandler to SnapshotValidator, which is a more
logical place for it.

Note: VM preview validation is done only if getForce()==true. This is
done to keep consistency with the current behavior, which has been in
place since this git repository was established. Whether or not it is
correct is a different question, which warrants inspection in an
additional patch.

Note: This patch is part of a series of patches aimed at removing the
preview validation from ImagesHandler altogether.

Change-Id: If49d2094589c639736649ee2eadcd45df9872826
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: Remove VM preview check from ImagesHandler

Removed the logic to check if a VM is in preview from ImagesHandler.
This means removing the isVmInPreview(VM) method and replacing any
explicit calls to it from other classes with a SnapshotValidator and
removing the reference to it from PerformImagesChecks.

Change-Id: I34f5793ff5c8436f488dd4ca507a001023095b9f
Signed-off-by: Allon Mureinik <amureini@redhat.com>