core: VM is down check when adding template

AddTemplateCommand explicitly checks if the VM is down in the
canDoAction, so there is no need to recheck it again by passing true to
the relevant argument of PerformImagesChecks.

This patch contains the proposed fix, a test for it, and a minor
refactor required to facilitate the test.

Note: This patch is part of a series intended to remove the VM status
check from ImagesHandler.

Change-Id: Ifec2d9677765502ca6876b31835340d3c4fad5ae
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: RemoveDiskCommand lazy getters

Extracted lazy getters for getDisk() and getDiskImage() in
RemoveDiskCommand.

This is done for two reasons:
1. To avoid ugly casts all over the code
2. To avoid a DB access in the constructor, which facilitates easier
   unit testing.

Change-Id: I5f38b27bd9456c990999660a5df0d6e4b807c207
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: Early return RemoveDiskCommand.canDoAction()

Converted RemoveDiskCommand.canDoAction() to use the early return
pattern for increased readability.

This patch includes the described code changes and a small unit test
proving canDoAction()'s flow was not damaged.

Change-Id: I32eb51e9e3cee5920f90b8f1ff8a8148a10cf2f1
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: Consolidate VM down check when removing disk

Both removing an image and a LUN disk had to check that the VM is down,
and this check was done in two separate places.
This patch consolidates this treatment to one function and stops using
ImagesHandler to perform this check for images.

Note: This patch is part of a series intended to remove the VM status
check from ImagesHandler.

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

Added an explicit test for VM.isDown in
RemoveSnapshotCommand.canDoAction() instead of using
ImagesHandler.PerformImagesChecks to do it.

In order to do this neatly, such a method was added to VmValidator,
which is the standard way of writing canDoActions.

Note: This patch is part of a series intended to remove the VM status
check from ImagesHandler.

Change-Id: Ifd281aa6778a3249162517499b5f0f48b04ed6b6
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: TrybackToAllSnapshots vmDown validation

Added an explicit test for VM.isDown in
TrybackToAllSnapshotsOfVmCommand.canDoAction() instead of using
ImagesHandler.PerformImagesChecks to do it.

This patch contains the aforementioned code change, a test for it, and a
minor refactor required to facilitate the test.

Note: This patch is part of a series intended to remove the VM status
check from ImagesHandler.

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

Added an explicit test for VM.isDown in
ExportVmCommand.canDoAction() instead of using
ImagesHandler.PerformImagesChecks to do it.

Note: This patch is part of a series intended to remove the VM
status check from ImagesHandler.

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

Added an explicit test for VM.isDown in
MoveVmCommand.canDoAction() instead of using
ImagesHandler.PerformImagesChecks to do it.

Note: This patch is part of a series intended to remove the VM
status check from ImagesHandler.

Change-Id: Iec3d1d48192be7256ac55a145e7cb058480901ba
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: Remove checkVmDown from PerformImagesChecks

Following a series of patches that removed all the usecases that set
checkVmDown=true in ImagesHandler.PerformImagesChecks, this parameter is
now useless, and can safely be removed.

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