DaanHoogland commented on code in PR #11053:
URL: https://github.com/apache/cloudstack/pull/11053#discussion_r2177229233


##########
test/integration/plugins/linstor/test_linstor_volumes.py:
##########
@@ -953,9 +953,66 @@ def test_09_create_snapshot(self):
 
         snapshot.delete(self.apiClient)
 
+    @attr(tags=['basic'], required_hardware=False)
+    def test_10_create_template_from_snapshot(self):
+        """
+        Create a template from a snapshot and start an instance from it
+        """
+        self.virtual_machine.stop(self.apiClient)
+
+        volume = list_volumes(
+            self.apiClient,
+            virtualmachineid = self.virtual_machine.id,
+            type = "ROOT",
+            listall = True,
+        )
+        snapshot = Snapshot.create(
+            self.apiClient,
+            volume_id = volume[0].id,
+            account=self.account.name,
+            domainid=self.domain.id,
+        )
+
+        self.assertIsNotNone(snapshot, "Could not create snapshot")
+
+        services = {
+            "displaytext": "IntegrationTestTemplate",
+            "name": "int-test-template",
+            "ostypeid": self.template.ostypeid,
+            "ispublic": "true"
+        }
+
+        custom_template = Template.create_from_snapshot(
+            self.apiClient,
+            snapshot,
+            services,
+        )
+
+        # create VM from custom template
+        test_virtual_machine = VirtualMachine.create(
+            self.apiClient,
+            self.testdata[TestData.virtualMachine2],
+            accountid=self.account.name,
+            zoneid=self.zone.id,
+            serviceofferingid=self.compute_offering.id,
+            templateid=custom_template.id,
+            domainid=self.domain.id,
+            startvm=False,
+            mode='basic',
+        )

Review Comment:
   ```suggestion
           test_virtual_machine = VirtualMachine.create(
               self.apiClient,
               self.testdata[TestData.virtualMachine2],
               accountid=self.account.name,
               zoneid=self.zone.id,
               serviceofferingid=self.compute_offering.id,
               templateid=custom_template.id,
               domainid=self.domain.id,
               startvm=False,
               mode='basic',
           )
           self.cleanup.append(test_virtual_machine)
   ```



##########
plugins/storage/volume/linstor/src/main/java/org/apache/cloudstack/storage/datastore/driver/LinstorPrimaryDataStoreDriverImpl.java:
##########
@@ -668,8 +671,15 @@ private String cloneResource(long csCloneId, VolumeInfo 
volumeInfo, StoragePoolV
             storagePoolVO.getId(), csCloneId, null);
 
         if (tmplPoolRef != null) {
-            final String templateRscName = LinstorUtil.RSC_PREFIX + 
tmplPoolRef.getLocalDownloadPath();
+            final String templateRscName;

Review Comment:
   ok, if it works it works but a buit strange to have a final be assigned 
later (guess it is alright during initialisation)



##########
test/integration/plugins/linstor/test_linstor_volumes.py:
##########
@@ -953,9 +953,66 @@ def test_09_create_snapshot(self):
 
         snapshot.delete(self.apiClient)
 
+    @attr(tags=['basic'], required_hardware=False)
+    def test_10_create_template_from_snapshot(self):
+        """
+        Create a template from a snapshot and start an instance from it
+        """
+        self.virtual_machine.stop(self.apiClient)
+
+        volume = list_volumes(
+            self.apiClient,
+            virtualmachineid = self.virtual_machine.id,
+            type = "ROOT",
+            listall = True,
+        )
+        snapshot = Snapshot.create(
+            self.apiClient,
+            volume_id = volume[0].id,
+            account=self.account.name,
+            domainid=self.domain.id,
+        )

Review Comment:
   ```suggestion
           snapshot = Snapshot.create(
               self.apiClient,
               volume_id = volume[0].id,
               account=self.account.name,
               domainid=self.domain.id,
           )
           self.cleanup.append(snapshot)
   ```



##########
test/integration/plugins/linstor/test_linstor_volumes.py:
##########
@@ -953,9 +953,66 @@ def test_09_create_snapshot(self):
 
         snapshot.delete(self.apiClient)
 
+    @attr(tags=['basic'], required_hardware=False)
+    def test_10_create_template_from_snapshot(self):
+        """
+        Create a template from a snapshot and start an instance from it
+        """
+        self.virtual_machine.stop(self.apiClient)
+
+        volume = list_volumes(
+            self.apiClient,
+            virtualmachineid = self.virtual_machine.id,
+            type = "ROOT",
+            listall = True,
+        )
+        snapshot = Snapshot.create(
+            self.apiClient,
+            volume_id = volume[0].id,
+            account=self.account.name,
+            domainid=self.domain.id,
+        )
+
+        self.assertIsNotNone(snapshot, "Could not create snapshot")
+
+        services = {
+            "displaytext": "IntegrationTestTemplate",
+            "name": "int-test-template",
+            "ostypeid": self.template.ostypeid,
+            "ispublic": "true"
+        }
+
+        custom_template = Template.create_from_snapshot(
+            self.apiClient,
+            snapshot,
+            services,
+        )
+
+        # create VM from custom template
+        test_virtual_machine = VirtualMachine.create(
+            self.apiClient,
+            self.testdata[TestData.virtualMachine2],
+            accountid=self.account.name,
+            zoneid=self.zone.id,
+            serviceofferingid=self.compute_offering.id,
+            templateid=custom_template.id,
+            domainid=self.domain.id,
+            startvm=False,
+            mode='basic',
+        )
+
+        TestLinstorVolumes._start_vm(test_virtual_machine)
+
+        test_virtual_machine.stop(self.apiClient)
+
+        test_virtual_machine.delete(self.apiClient, True)
+
+        custom_template.delete(self.apiClient)
+        snapshot.delete(self.apiClient)

Review Comment:
   ```suggestion
           custom_template.delete(self.apiClient)
           self.cleanup.remove(custom_template)
           snapshot.delete(self.apiClient)
           self.cleanup.remove(snapshot)
   ```



##########
test/integration/plugins/linstor/test_linstor_volumes.py:
##########
@@ -953,9 +953,66 @@ def test_09_create_snapshot(self):
 
         snapshot.delete(self.apiClient)
 
+    @attr(tags=['basic'], required_hardware=False)
+    def test_10_create_template_from_snapshot(self):
+        """
+        Create a template from a snapshot and start an instance from it
+        """
+        self.virtual_machine.stop(self.apiClient)
+
+        volume = list_volumes(
+            self.apiClient,
+            virtualmachineid = self.virtual_machine.id,
+            type = "ROOT",
+            listall = True,
+        )
+        snapshot = Snapshot.create(
+            self.apiClient,
+            volume_id = volume[0].id,
+            account=self.account.name,
+            domainid=self.domain.id,
+        )
+
+        self.assertIsNotNone(snapshot, "Could not create snapshot")
+
+        services = {
+            "displaytext": "IntegrationTestTemplate",
+            "name": "int-test-template",
+            "ostypeid": self.template.ostypeid,
+            "ispublic": "true"
+        }
+
+        custom_template = Template.create_from_snapshot(
+            self.apiClient,
+            snapshot,
+            services,
+        )
+
+        # create VM from custom template
+        test_virtual_machine = VirtualMachine.create(
+            self.apiClient,
+            self.testdata[TestData.virtualMachine2],
+            accountid=self.account.name,
+            zoneid=self.zone.id,
+            serviceofferingid=self.compute_offering.id,
+            templateid=custom_template.id,
+            domainid=self.domain.id,
+            startvm=False,
+            mode='basic',
+        )
+
+        TestLinstorVolumes._start_vm(test_virtual_machine)
+
+        test_virtual_machine.stop(self.apiClient)
+
+        test_virtual_machine.delete(self.apiClient, True)

Review Comment:
   ```suggestion
           test_virtual_machine.delete(self.apiClient, True)
           self.cleanup.remove(test_virtual_machine)
   ```



##########
test/integration/plugins/linstor/test_linstor_volumes.py:
##########
@@ -953,9 +953,66 @@ def test_09_create_snapshot(self):
 
         snapshot.delete(self.apiClient)
 
+    @attr(tags=['basic'], required_hardware=False)
+    def test_10_create_template_from_snapshot(self):
+        """
+        Create a template from a snapshot and start an instance from it
+        """
+        self.virtual_machine.stop(self.apiClient)
+
+        volume = list_volumes(
+            self.apiClient,
+            virtualmachineid = self.virtual_machine.id,
+            type = "ROOT",
+            listall = True,
+        )
+        snapshot = Snapshot.create(
+            self.apiClient,
+            volume_id = volume[0].id,
+            account=self.account.name,
+            domainid=self.domain.id,
+        )
+
+        self.assertIsNotNone(snapshot, "Could not create snapshot")
+
+        services = {
+            "displaytext": "IntegrationTestTemplate",
+            "name": "int-test-template",
+            "ostypeid": self.template.ostypeid,
+            "ispublic": "true"
+        }
+
+        custom_template = Template.create_from_snapshot(
+            self.apiClient,
+            snapshot,
+            services,
+        )

Review Comment:
   ```suggestion
           custom_template = Template.create_from_snapshot(
               self.apiClient,
               snapshot,
               services,
           )
           self.cleanup.append(custom_template)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to