Skip to content

Commit 4914c9e

Browse files
committed
Merge pull request #700 from QualiSystems/develop
Fixing Bug with Linked Clone Deployment
2 parents 85daf33 + 455aa4d commit 4914c9e

3 files changed

Lines changed: 20 additions & 14 deletions

File tree

package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -432,22 +432,26 @@ def clone_vm(self, clone_params, logger):
432432

433433
'# set relo_spec'
434434
placement = self.vim.vm.RelocateSpec()
435-
placement.datastore = datastore
436435
if resource_pool:
437436
placement.pool = resource_pool
438437
if host:
439438
placement.host = host
440439

441440
clone_spec = self.vim.vm.CloneSpec()
441+
442+
if snapshot:
443+
clone_spec.snapshot = snapshot
444+
clone_spec.template = False
445+
placement.diskMoveType = 'createNewChildDiskBacking'
446+
else:
447+
placement.datastore = datastore
448+
449+
# after deployment the vm must be powered off and will be powered on if needed by orchestration driver
442450
clone_spec.location = placement
443451
# clone_params.power_on
444452
# due to hotfix 1 for release 1.0,
445-
# after deployment the vm must be powered off and will be powered on if needed by orchestration driver
446453
clone_spec.powerOn = False
447454

448-
if snapshot:
449-
clone_spec.snapshot = snapshot
450-
451455
logger.info("cloning VM...")
452456
try:
453457
task = template.Clone(folder=dest_folder, name=clone_params.vm_name, spec=clone_spec)

package/cloudshell/tests/test_commands/test_command_orchestrator.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from mock import Mock, create_autospec
66

77

8-
98
class TestCommandOrchestrator(TestCase):
109
def setUp(self):
1110
self.resource = create_autospec(ResourceInfo)
@@ -49,31 +48,34 @@ def test_disconnect_all(self):
4948

5049
def test_disconnect(self):
5150
# act
52-
self.command_orchestrator.disconnect(self.context, self.ports, 'network')
51+
self.command_orchestrator.disconnect(self.context, self.ports, 'network')
5352
# assert
5453
self.assertTrue(self.command_orchestrator.command_wrapper.execute_command_with_connection.called)
5554

5655
def test_destroy_vm(self):
5756
# act
58-
self.command_orchestrator.destroy_vm(self.context, self.ports)
57+
self.command_orchestrator.destroy_vm(self.context, self.ports)
5958
# assert
6059
self.assertTrue(self.command_orchestrator.command_wrapper.execute_command_with_connection.called)
6160

6261
def test_deploy_from_template(self):
6362
# act
64-
self.command_orchestrator.deploy_from_template(self.context, '{"name": "name", "template_resource_model": {"vcenter_template": ""}}')
63+
self.command_orchestrator.deploy_from_template(self.context,
64+
'{"name": "name", "template_resource_model": {"vcenter_template": ""}}')
6565
# assert
6666
self.assertTrue(self.command_orchestrator.command_wrapper.execute_command_with_connection.called)
6767

6868
def test_deploy_vm_from_vm(self):
6969
# act
70-
self.command_orchestrator.deploy_clone_from_vm(self.context, '{"name": "name", "template_resource_model": {"vcenter_vm": ""}}')
70+
self.command_orchestrator.deploy_clone_from_vm(self.context,
71+
'{"name": "name", "template_resource_model": {"vcenter_vm": ""}}')
7172
# assert
7273
self.assertTrue(self.command_orchestrator.command_wrapper.execute_command_with_connection.called)
7374

7475
def test_deploy_from_snapshot(self):
7576
# act
76-
self.command_orchestrator.deploy_from_linked_clone(self.context, '{"name": "name", "template_resource_model": {"vcenter_vm": "name", "vcenter_vm_snapshot": "snap"}}')
77+
self.command_orchestrator.deploy_from_linked_clone(self.context,
78+
'{"name": "name", "template_resource_model": {"vcenter_vm": "name", "vcenter_vm_snapshot": "snap"}}')
7779
# assert
7880
self.assertTrue(self.command_orchestrator.command_wrapper.execute_command_with_connection.called)
7981

@@ -91,7 +93,7 @@ def test_power_off(self):
9193

9294
def test_power_on(self):
9395
# act
94-
self.command_orchestrator.power_on(self.context, self.ports)
96+
self.command_orchestrator.power_on(self.context, self.ports)
9597
# assert
9698
self.assertTrue(self.command_orchestrator.command_wrapper.execute_command_with_connection.called)
9799

package/cloudshell/tests/test_common/test_utilities/test_command_result.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
class TestCommandResult(TestCase):
1111
def test_get_result_from_command_output_with_result(self):
12-
result = get_result_from_command_output('{"result":"MY RESULT"}')
13-
self.assertEqual(result["result"], 'MY RESULT')
12+
result = get_result_from_command_output('{"result":"MY RESULT1"}')
13+
self.assertEqual(result["result"], 'MY RESULT1')
1414

1515
def test_command_result_empty(self):
1616
result = get_result_from_command_output('')

0 commit comments

Comments
 (0)