@@ -953,9 +953,72 @@ def test_09_create_snapshot(self):
953953
954954 snapshot .delete (self .apiClient )
955955
956+ @attr (tags = ['basic' ], required_hardware = False )
957+ def test_10_create_template_from_snapshot (self ):
958+ """
959+ Create a template from a snapshot and start an instance from it
960+ """
961+ self .virtual_machine .stop (self .apiClient )
962+
963+ volume = list_volumes (
964+ self .apiClient ,
965+ virtualmachineid = self .virtual_machine .id ,
966+ type = "ROOT" ,
967+ listall = True ,
968+ )
969+ snapshot = Snapshot .create (
970+ self .apiClient ,
971+ volume_id = volume [0 ].id ,
972+ account = self .account .name ,
973+ domainid = self .domain .id ,
974+ )
975+ self .cleanup .append (snapshot )
976+
977+ self .assertIsNotNone (snapshot , "Could not create snapshot" )
978+
979+ services = {
980+ "displaytext" : "IntegrationTestTemplate" ,
981+ "name" : "int-test-template" ,
982+ "ostypeid" : self .template .ostypeid ,
983+ "ispublic" : "true"
984+ }
985+
986+ custom_template = Template .create_from_snapshot (
987+ self .apiClient ,
988+ snapshot ,
989+ services ,
990+ )
991+ self .cleanup .append (custom_template )
992+
993+ # create VM from custom template
994+ test_virtual_machine = VirtualMachine .create (
995+ self .apiClient ,
996+ self .testdata [TestData .virtualMachine2 ],
997+ accountid = self .account .name ,
998+ zoneid = self .zone .id ,
999+ serviceofferingid = self .compute_offering .id ,
1000+ templateid = custom_template .id ,
1001+ domainid = self .domain .id ,
1002+ startvm = False ,
1003+ mode = 'basic' ,
1004+ )
1005+ self .cleanup .append (test_virtual_machine )
1006+
1007+ TestLinstorVolumes ._start_vm (test_virtual_machine )
1008+
1009+ test_virtual_machine .stop (self .apiClient )
1010+
1011+ test_virtual_machine .delete (self .apiClient , True )
1012+ self .cleanup .remove (test_virtual_machine )
1013+
1014+ custom_template .delete (self .apiClient )
1015+ self .cleanup .remove (custom_template )
1016+ snapshot .delete (self .apiClient )
1017+ self .cleanup .remove (snapshot )
1018+
9561019
9571020 @attr (tags = ['advanced' , 'migration' ], required_hardware = False )
958- def test_10_migrate_volume_to_same_instance_pool (self ):
1021+ def test_11_migrate_volume_to_same_instance_pool (self ):
9591022 """Migrate volume to the same instance pool"""
9601023
9611024 if not self .testdata [TestData .migrationTests ]:
@@ -1088,7 +1151,7 @@ def test_10_migrate_volume_to_same_instance_pool(self):
10881151 test_virtual_machine .delete (self .apiClient , True )
10891152
10901153 @attr (tags = ['advanced' , 'migration' ], required_hardware = False )
1091- def test_11_migrate_volume_to_distinct_instance_pool (self ):
1154+ def test_12_migrate_volume_to_distinct_instance_pool (self ):
10921155 """Migrate volume to distinct instance pool"""
10931156
10941157 if not self .testdata [TestData .migrationTests ]:
@@ -1221,7 +1284,7 @@ def test_11_migrate_volume_to_distinct_instance_pool(self):
12211284 test_virtual_machine .delete (self .apiClient , True )
12221285
12231286 @attr (tags = ["basic" ], required_hardware = False )
1224- def test_12_create_vm_snapshots (self ):
1287+ def test_13_create_vm_snapshots (self ):
12251288 """Test to create VM snapshots
12261289 """
12271290 vm = TestLinstorVolumes ._start_vm (self .virtual_machine )
@@ -1251,7 +1314,7 @@ def test_12_create_vm_snapshots(self):
12511314 )
12521315
12531316 @attr (tags = ["basic" ], required_hardware = False )
1254- def test_13_revert_vm_snapshots (self ):
1317+ def test_14_revert_vm_snapshots (self ):
12551318 """Test to revert VM snapshots
12561319 """
12571320
@@ -1313,7 +1376,7 @@ def test_13_revert_vm_snapshots(self):
13131376 )
13141377
13151378 @attr (tags = ["basic" ], required_hardware = False )
1316- def test_14_delete_vm_snapshots (self ):
1379+ def test_15_delete_vm_snapshots (self ):
13171380 """Test to delete vm snapshots
13181381 """
13191382
0 commit comments