Exemplo n.º 1
0
    def test_01_snapshot_detached_volume(self):
        ''' Test Snapshot Detached Volume
        '''
        self.virtual_machine.stop(
            self.apiClient,
            forced = True
            )
        self.volume = self.virtual_machine.attach_volume(
            self.apiClient,
            self.volume
            )
        self.assertIsNotNone(self.volume, "Attach: Is none")
        self.volume = self.virtual_machine.detach_volume(
            self.apiClient,
            self.volume
            )

        self.assertIsNotNone(self.volume, "Detach: Is none")

        snapshot = Snapshot.create(
            self.apiClient,
            self.volume.id,
            )

        self.assertIsNotNone(snapshot, "Snapshot is None")

        self.assertIsInstance(snapshot, Snapshot, "Snapshot is not Instance of Snappshot")

        snapshot = Snapshot.delete(
            snapshot,
            self.apiClient
            )

        self.assertIsNone(snapshot, "Snapshot was not deleted")
    def test_03_try_delete_primary_with_snapshots(self):
        virtual_machine = VirtualMachine.create(
            self.apiclient, {"name": "StorPool-%s" % uuid.uuid4()},
            zoneid=self.zone.id,
            templateid=self.template.id,
            serviceofferingid=self.serviceOfferings.id,
            hypervisor=self.hypervisor,
            rootdisksize=10)

        volume = list_volumes(self.apiclient,
                              virtualmachineid=virtual_machine.id,
                              type="ROOT")

        volume = volume[0]

        name = volume.path.split("/")[3]
        try:
            spvolume = self.spapi.volumeList(volumeName="~" + name)
            if spvolume[0].templateName != self.template_name:
                raise Exception(
                    "Storpool volume's template %s  is not with the same template %s"
                    % (spvolume[0].templateName, self.template_name))
        except spapi.ApiError as err:
            raise Exception(err)

        snapshot = Snapshot.create(
            self.apiclient,
            volume_id=volume.id,
        )
        id = self.helper.get_snapshot_template_id(self.apiclient, snapshot,
                                                  self.storage_pool_id)
        if id is None:
            raise Exception("There isn't primary storgae id")
        virtual_machine.delete(self.apiclient, expunge=True)
        pool = list_storage_pools(self.apiclient, id=id)
        if pool[0].name == self.template_name:
            try:
                StoragePool.delete(self.sp_primary_storage, self.apiclient)
            except Exception as err:
                StoragePool.cancelMaintenance(self.apiclient,
                                              id=self.sp_primary_storage.id)
                self.debug("Storage pool could not be delete due to %s" % err)
        else:
            self.cleanup.append(snapshot)
            raise Exception("Snapshot is not on the same pool")
        Snapshot.delete(snapshot, self.apiclient)
Exemplo n.º 3
0
    def test_08_snapshot_detached_volume(self):
        ''' Test Snapshot Detached Volume
        '''
        self.virtual_machine.stop(
            self.apiclient,
            forced = True
            )
        self.volume = self.virtual_machine.attach_volume(
            self.apiclient,
            self.volume
            )
        self.assertIsNotNone(self.volume, "Attach: Is none")
        self.volume = self.virtual_machine.detach_volume(
            self.apiclient,
            self.volume
            )

        self.assertIsNotNone(self.volume, "Detach: Is none")
 
        snapshot = Snapshot.create(
            self.apiclient,
            self.volume.id,
            account=self.account.name,
            domainid=self.account.domainid,
            )

        try:
            cmd = getVolumeSnapshotDetails.getVolumeSnapshotDetailsCmd()
            cmd.snapshotid = snapshot.id
            snapshot_details = self.apiclient.getVolumeSnapshotDetails(cmd)
            flag = False
            for s in snapshot_details:
                if s["snapshotDetailsName"] == snapshot.id:
                    name = s["snapshotDetailsValue"].split("/")[3]
                    sp_snapshot = self.spapi.snapshotList(snapshotName = "~" + name)
                    self.debug('################ %s' % sp_snapshot)
                    flag = True
            if flag == False:
                raise Exception("Could not find snapshot in snapshot details")
        except spapi.ApiError as err:
           raise Exception(err)

        self.assertIsNotNone(snapshot, "Snapshot is None")

        self.assertIsInstance(snapshot, Snapshot, "Snapshot is not Instance of Snappshot")

        snapshot = Snapshot.delete(
            snapshot,
            self.apiclient
            )

        self.assertIsNone(snapshot, "Snapshot was not deleted")
Exemplo n.º 4
0
    def test_02_snapshot_attached_volume(self):
        ''' Test Snapshot With Attached Volume
        '''
        list_volumes_of_vm = list_volumes(
            self.apiClient,
            virtualmachineid = self.virtual_machine.id
            )
        self.assertIs(len(list_volumes_of_vm), 1, "VM has more disk than 1")

        snapshot = Snapshot.create(
            self.apiClient,
            list_volumes_of_vm[0].id
            )

        self.assertIsNotNone(snapshot, "Snapshot is None")

        self.assertEqual(list_volumes_of_vm[0].id, snapshot.volumeid, "Snapshot is not for the same volume")

        snapshot = Snapshot.delete(
            snapshot,
            self.apiClient
            )

        self.assertIsNone(snapshot, "Snapshot is not None")
Exemplo n.º 5
0
    def test_01_list_volume_snapshots_pagination(self):
        """
        @Desc: Test to List Volume Snapshots pagination
        @steps:
        Step1: Listing all the volume snapshots for a user
        Step2: Verifying that list size is 0
        Step3: Creating (page size + 1) number of volume snapshots
        Step4: Listing all the volume snapshots again for a user
        Step5: Verifying that list size is (page size + 1)
        Step6: Listing all the volume snapshots in page1
        Step7: Verifying that list size is (page size)
        Step8: Listing all the volume snapshots in page2
        Step9: Verifying that list size is 1
        Step10: Deleting the volume snapshot present in page 2
        Step11: Listing all the volume snapshots in page2
        Step12: Verifying that list size is 0
        """
        if self.hypervisor.lower() in ['hyperv']:
            raise unittest.SkipTest("This feature is not supported on existing hypervisor. Hence, skipping the test")
        # Listing all the volume snapshots for a User
        list_vol_snaps_before = Snapshot.list(
                                              self.userapiclient,
                                              listall=self.services["listall"]
                                              )
        # Verifying list size is 0
        self.assertIsNone(
                          list_vol_snaps_before,
                          "Volume snapshots exists for newly created user"
                          )
        # Listing the root volumes available for the user
        volumes_list = Volume.list(
                                   self.userapiclient,
                                   listall=self.services["listall"]
                                   )
        status = validateList(volumes_list)
        self.assertEquals(
                          PASS,
                          status[0],
                          "Root volume did not get created while deploying a VM"
                          )
        # Verifying list size to be 1
        self.assertEquals(
                          1,
                          len(volumes_list),
                          "More than 1 root volume created for deployed VM"
                          )
        root_volume = volumes_list[0]
        # Creating pagesize + 1 number of volume snapshots
        for i in range(0, (self.services["pagesize"] + 1)):
            snapshot_created = Snapshot.create(
                                               self.userapiclient,
                                               root_volume.id,
                                               )
            self.assertIsNotNone(
                                 snapshot_created,
                                 "Snapshot creation failed"
                                 )
            self.cleanup.append(snapshot_created)

        # Listing all the volume snapshots for user again
        list_vol_snaps_after = Snapshot.list(
                                             self.userapiclient,
                                             listall=self.services["listall"]
                                             )
        status = validateList(list_vol_snaps_after)
        self.assertEquals(
                          PASS,
                          status[0],
                          "Volume snapshot creation failed"
                          )
        # Verifying that list size is pagesize + 1
        self.assertEquals(
                          self.services["pagesize"] + 1,
                          len(list_vol_snaps_after),
                          "Failed to create pagesize + 1 number of Volume snapshots"
                          )
        # Listing all the volume snapshots in page 1
        list_vol_snaps_page1 = Snapshot.list(
                                             self.userapiclient,
                                             listall=self.services["listall"],
                                             page=1,
                                             pagesize=self.services["pagesize"]
                                             )
        status = validateList(list_vol_snaps_page1)
        self.assertEquals(
                          PASS,
                          status[0],
                          "Failed to list volume snapshots in page 1"
                          )
        # Verifying the list size to be equal to pagesize
        self.assertEquals(
                          self.services["pagesize"],
                          len(list_vol_snaps_page1),
                          "Size of volume snapshots in page 1 is not matching"
                          )
        # Listing all the volume snapshots in page 2
        list_vol_snaps_page2 = Snapshot.list(
                                             self.userapiclient,
                                             listall=self.services["listall"],
                                             page=2,
                                             pagesize=self.services["pagesize"]
                                             )
        status = validateList(list_vol_snaps_page2)
        self.assertEquals(
                          PASS,
                          status[0],
                          "Failed to list volume snapshots in page 2"
                          )
        # Verifying the list size to be equal to pagesize
        self.assertEquals(
                          1,
                          len(list_vol_snaps_page2),
                          "Size of volume snapshots in page 2 is not matching"
                          )
        # Deleting the volume snapshot present in page 2
        Snapshot.delete(
                        snapshot_created,
                        self.userapiclient
                        )
        self.cleanup.remove(snapshot_created)
        # Listing all the snapshots in page 2 again
        list_vol_snaps_page2 = Snapshot.list(
                                             self.userapiclient,
                                             listall=self.services["listall"],
                                             page=2,
                                             pagesize=self.services["pagesize"]
                                             )
        # Verifying that list size is 0
        self.assertIsNone(
                          list_vol_snaps_page2,
                          "Volume snapshot not deleted from page 2"
                          )
        return
Exemplo n.º 6
0
    def test_08_delete_snapshot_of_deleted_volume(self):
        ''' Delete snapshot and template if volume is already deleted, bypassing secondary
        '''

        Configurations.update(self.apiclient,
        name = "sp.bypass.secondary.storage",
        value = "true")

        volume = Volume.create(
            self.apiclient,
            {"diskname":"StorPoolDisk-Delete" },
            zoneid = self.zone.id,
            diskofferingid = self.disk_offerings.id,
            account=self.account.name,
            domainid=self.account.domainid,
            )
        delete = volume
        self.virtual_machine2.attach_volume(
            self.apiclient,
            volume
            )
        self.virtual_machine2.detach_volume(
            self.apiclient,
            volume
            )

        volume = list_volumes(self.apiclient, id = volume.id, listall = True,)

        name = volume[0].path.split("/")[3]
        try:
            spvolume = self.spapi.volumeList(volumeName="~" + name)
        except spapi.ApiError as err:
           raise Exception(err)

        snapshot = Snapshot.create(
            self.apiclient,
             volume_id = volume[0].id
            )

        try:
            cmd = getVolumeSnapshotDetails.getVolumeSnapshotDetailsCmd()
            cmd.snapshotid = snapshot.id
            snapshot_details = self.apiclient.getVolumeSnapshotDetails(cmd)
            if snapshot_details is not None:
                flag = False
                for s in snapshot_details:
                    if s["snapshotDetailsName"] == snapshot.id:
                        name = s["snapshotDetailsValue"].split("/")[3]
                        try:
                            sp_snapshot = self.spapi.snapshotList(snapshotName = "~" + name)
                            self.debug('################ %s' % sp_snapshot)
                            flag = True
                        except spapi.ApiError as err:
                           raise Exception(err)
                if flag == False:
                    raise Exception("Could not find snapshot in snapshot details")
        except Exception as err:
            raise Exception(err)  

        template = self.helper.create_template_from_snapshot(self.apiclient, self.services, snapshotid = snapshot.id)

        Volume.delete(delete, self.apiclient, )
        Snapshot.delete(snapshot, self.apiclient)

        flag = False
        try:
            cmd = getVolumeSnapshotDetails.getVolumeSnapshotDetailsCmd()
            cmd.snapshotid = snapshot.id
            snapshot_details = self.apiclient.getVolumeSnapshotDetails(cmd)
            if snapshot_details is not None:
                try:
                    for s in snapshot_details:
                        if s["snapshotDetailsName"] == snapshot.id:
                            name = s["snapshotDetailsValue"].split("/")[3]
                            sp_snapshot = self.spapi.snapshotList(snapshotName = "~" + name)
                            self.debug('################ The snapshot had to be deleted %s' % sp_snapshot)
                            flag = True
                except spapi.ApiError as err:
                    flag = False
    
            if flag is True:
                raise Exception("Snapshot was not deleted")
        except Exception as err:
            self.debug('Snapshot was deleted %s' % err)
            

        Template.delete(template, self.apiclient, zoneid = self.zone.id)
    def test_04_try_delete_primary_with_template(self):
        virtual_machine = VirtualMachine.create(
            self.apiclient, {"name": "StorPool-%s" % uuid.uuid4()},
            zoneid=self.zone.id,
            templateid=self.template.id,
            serviceofferingid=self.serviceOfferings.id,
            hypervisor=self.hypervisor,
            rootdisksize=10)

        volume = list_volumes(self.apiclient,
                              virtualmachineid=virtual_machine.id,
                              type="ROOT",
                              listall=True)

        volume = volume[0]

        name = volume.path.split("/")[3]
        try:
            spvolume = self.spapi.volumeList(volumeName="~" + name)
            if spvolume[0].templateName != self.template_name:
                raise Exception(
                    "Storpool volume's template %s  is not with the same template %s"
                    % (spvolume[0].templateName, self.template_name))
        except spapi.ApiError as err:
            raise Exception(err)

        backup_config = list_configurations(self.apiclient,
                                            name="sp.bypass.secondary.storage")
        if (backup_config[0].value == "false"):
            backup_config = Configurations.update(
                self.apiclient,
                name="sp.bypass.secondary.storage",
                value="true")

        snapshot = Snapshot.create(
            self.apiclient,
            volume_id=volume.id,
        )
        self.debug("###################### %s" % snapshot)
        id = self.helper.get_snapshot_template_id(self.apiclient, snapshot,
                                                  self.storage_pool_id)
        if id is None:
            raise Exception("There isn't primary storgae id")
        virtual_machine.delete(self.apiclient, expunge=True)
        pool = list_storage_pools(self.apiclient, id=id)

        services = {
            "displaytext": "Template-1",
            "name": "Template-1-name",
            "ostypeid": self.template.ostypeid,
            "ispublic": "true"
        }
        template = Template.create_from_snapshot(self.apiclient,
                                                 snapshot=snapshot,
                                                 services=services)
        Snapshot.delete(snapshot, self.apiclient)

        try:
            StoragePool.delete(self.sp_primary_storage, self.apiclient)
        except Exception as err:
            StoragePool.cancelMaintenance(self.apiclient,
                                          id=self.sp_primary_storage.id)
            self.debug("Storge pool could not be delete due to %s" % err)

        Template.delete(template, self.apiclient)
    def test_01_delta_snapshots(self):
        """ Delta Snapshots
            1. Create file on ROOT disk of deployed VM.
            2. Create Snapshot of ROOT disk.
            3. Verify secondary storage count.
            4. Check integrity of Full Snapshot.
            5. Delete delta snaphshot and check integrity of\
               remaining snapshots.
            6. Delete full snapshot and verify it is deleted from\
               secondary storage.
        """
        checksum_created = []
        full_snapshot_count = 0
        delta_snapshot_count = 0

        # Mulitply delta max value by 2 to set loop counter
        # to create 2 Snapshot chains
        snapshot_loop_count = int(self.delta_max) * 2

        # Get ROOT Volume
        root_volumes_list = list_volumes(
            self.apiclient,
            virtualmachineid=self.vm.id,
            type=ROOT,
            listall=True
        )

        status = validateList(root_volumes_list)
        self.assertEqual(
            status[0],
            PASS,
            "Check listVolumes response for ROOT Disk")

        root_volume = root_volumes_list[0]

        # Get Secondary Storage Value from Database
        qryresult_before_snapshot = self.dbclient.execute(
            " select id, account_name, secondaryStorageTotal\
                    from account_view where account_name = '%s';" %
            self.account.name)

        self.assertNotEqual(
            len(qryresult_before_snapshot),
            0,
            "Check sql query to return SecondaryStorageTotal of account")

        storage_qry_result_old = qryresult_before_snapshot[0]
        secondary_storage_old = storage_qry_result_old[2]

        # Create Snapshots

        for i in range(snapshot_loop_count):

            # Step 1
            checksum_root = createChecksum(
                self.testdata,
                self.vm,
                root_volume,
                "rootdiskdevice")

            time.sleep(30)
            checksum_created.append(checksum_root)

            # Step 2
            root_vol_snapshot = Snapshot.create(
                self.apiclient,
                root_volume.id)

            self.snapshots_created.append(root_vol_snapshot)

            snapshots_list = Snapshot.list(self.apiclient,
                                           id=root_vol_snapshot.id)

            status = validateList(snapshots_list)
            self.assertEqual(status[0], PASS, "Check listSnapshots response")

            # Verify Snapshot state
            self.assertEqual(
                snapshots_list[0].state.lower() in [
                    BACKED_UP,
                ],
                True,
                "Snapshot state is not as expected. It is %s" %
                snapshots_list[0].state
            )

            self.assertEqual(
                snapshots_list[0].volumeid,
                root_volume.id,
                "Snapshot volume id is not matching with the vm's volume id")

            # Step 3
            qryresult_after_snapshot = self.dbclient.execute(
                " select id, account_name, secondaryStorageTotal\
                        from account_view where account_name = '%s';" %
                self.account.name)

            self.assertNotEqual(
                len(qryresult_after_snapshot),
                0,
                "Check sql query to return SecondaryStorageTotal of account")

            storage_qry_result_from_database = qryresult_after_snapshot[0]
            secondary_storage_from_database = storage_qry_result_from_database[
                2]

            snapshot_size = snapshots_list[0].physicalsize
            secondary_storage_after_snapshot = secondary_storage_old + \
                snapshot_size

            # Reset full_snapshot_count to 0 before start of new snapshot chain
            if delta_snapshot_count == (int(self.delta_max) - 1):
                full_snapshot_count = 0
                delta_snapshot_count = 0

            # Full Snapshot of each Snapshot chain
            if full_snapshot_count == 0:

                full_snapshot_count += 1
                full_snapshot_size = snapshot_size

                # Check secondary storage count for Full Snapshots
                self.assertEqual(
                    secondary_storage_from_database,
                    secondary_storage_after_snapshot,
                    "Secondary storage count after full snapshot\
                                should be incremented by size of snapshot.")
                # Step 4
                checkIntegrityOfSnapshot(
                    self,
                    snapshots_list[0],
                    checksum_root,
                    disk_type=DATA)

            else:

                # Delta Snapshot of each Snapshot chain
                delta_snapshot_count += 1
                delta_snapshot_size = snapshot_size

                # Check secondary storage count for Delta Snapshots
                self.assertTrue(delta_snapshot_size < full_snapshot_size,
                                "Delta Snapshot size should be less than\
                                Full Snapshot.")

                self.assertEqual(
                    secondary_storage_from_database,
                    secondary_storage_after_snapshot,
                    "Secondary storage count after delta snapshot\
                                should be incremented by size of snapshot.")

            secondary_storage_old = secondary_storage_from_database

        # Step 5

        # Check in Secondary Storage- Snapshots: S1, S2, S3 are present
        for i in range(int(self.delta_max)):
            self.assertTrue(
                is_snapshot_on_nfs(
                    self.apiclient,
                    self.dbclient,
                    self.config,
                    self.zone.id,
                    self.snapshots_created[i].id),
                "Check: Snapshot is not on Secondary Storage.")

        # Delete S2

        Snapshot.delete(self.snapshots_created[1], self.apiclient)

        snapshots_list = Snapshot.list(self.apiclient,
                                       id=self.snapshots_created[1].id)

        status = validateList(snapshots_list)
        self.assertEqual(status[0], FAIL, "Snapshots Not Deleted.")

        # Check integrity of Snapshots for S1 and S3
        checkIntegrityOfSnapshot(
            self,
            self.snapshots_created[0],
            checksum_created[0],
            disk_type=DATA)

        checkIntegrityOfSnapshot(
            self,
            self.snapshots_created[2],
            checksum_created[2],
            disk_type=DATA)

        # Delete S3

        Snapshot.delete(self.snapshots_created[2], self.apiclient)

        snapshots_list = Snapshot.list(self.apiclient,
                                       id=self.snapshots_created[2].id)

        status = validateList(snapshots_list)
        self.assertEqual(status[0], FAIL, "Snapshots Not Deleted.")

        # Check in Secondary Storage - Snapshots: S2, S3 are deleted
        self.assertFalse(
            is_snapshot_on_nfs(
                self.apiclient,
                self.dbclient,
                self.config,
                self.zone.id,
                self.snapshots_created[2].id),
            "Check: Snapshot 2 is still on Secondary Storage. Not Deleted.")

        self.assertFalse(
            is_snapshot_on_nfs(
                self.apiclient,
                self.dbclient,
                self.config,
                self.zone.id,
                self.snapshots_created[1].id),
            "Check: Snapshot 3 is still on Secondary Storage. Not Deleted.")

        # Restore Snapshots for S1
        checkIntegrityOfSnapshot(
            self,
            self.snapshots_created[0],
            checksum_created[0],
            disk_type=DATA)

        # Step 6
        # Delete S1

        Snapshot.delete(self.snapshots_created[0], self.apiclient)

        snapshots_list = Snapshot.list(self.apiclient,
                                       id=self.snapshots_created[0].id)

        status = validateList(snapshots_list)
        self.assertEqual(status[0], FAIL, "Snapshots Not Deleted.")

        # Check in Secondary Storage - Snapshots: All - S1, S2, S3 are deleted

        self.assertFalse(
            is_snapshot_on_nfs(
                self.apiclient,
                self.dbclient,
                self.config,
                self.zone.id,
                self.snapshots_created[2].id),
            "Check: Snapshot 3 is still on Secondary Storage. Not Deleted.")

        self.assertFalse(
            is_snapshot_on_nfs(
                self.apiclient,
                self.dbclient,
                self.config,
                self.zone.id,
                self.snapshots_created[1].id),
            "Check: Snapshot 2 is still on Secondary Storage. Not Deleted.")

        self.assertFalse(
            is_snapshot_on_nfs(
                self.apiclient,
                self.dbclient,
                self.config,
                self.zone.id,
                self.snapshots_created[0].id),
            "Check: Snapshot 1 is still on Secondary Storage. Not Deleted.")

        return
Exemplo n.º 9
0
    def test_01_delta_snapshots(self):
        """ Delta Snapshots
            1. Create file on ROOT disk of deployed VM.
            2. Create Snapshot of ROOT disk.
            3. Verify secondary storage count.
            4. Check integrity of Full Snapshot.
            5. Delete delta snaphshot and check integrity of\
               remaining snapshots.
            6. Delete full snapshot and verify it is deleted from\
               secondary storage.
        """
        checksum_created = []
        full_snapshot_count = 0
        delta_snapshot_count = 0

        # Mulitply delta max value by 2 to set loop counter
        # to create 2 Snapshot chains
        snapshot_loop_count = int(self.delta_max) * 2

        # Get ROOT Volume
        root_volumes_list = list_volumes(self.apiclient,
                                         virtualmachineid=self.vm.id,
                                         type=ROOT,
                                         listall=True)

        status = validateList(root_volumes_list)
        self.assertEqual(status[0], PASS,
                         "Check listVolumes response for ROOT Disk")

        root_volume = root_volumes_list[0]

        # Get Secondary Storage Value from Database
        qryresult_before_snapshot = self.dbclient.execute(
            " select id, account_name, secondaryStorageTotal\
                    from account_view where account_name = '%s';" %
            self.account.name)

        self.assertNotEqual(
            len(qryresult_before_snapshot), 0,
            "Check sql query to return SecondaryStorageTotal of account")

        storage_qry_result_old = qryresult_before_snapshot[0]
        secondary_storage_old = storage_qry_result_old[2]

        # Create Snapshots

        for i in range(snapshot_loop_count):

            # Step 1
            checksum_root = createChecksum(self.testdata, self.vm, root_volume,
                                           "rootdiskdevice")

            time.sleep(30)
            checksum_created.append(checksum_root)

            # Step 2
            root_vol_snapshot = Snapshot.create(self.apiclient, root_volume.id)

            self.snapshots_created.append(root_vol_snapshot)

            snapshots_list = Snapshot.list(self.apiclient,
                                           id=root_vol_snapshot.id)

            status = validateList(snapshots_list)
            self.assertEqual(status[0], PASS, "Check listSnapshots response")

            # Verify Snapshot state
            self.assertEqual(
                snapshots_list[0].state.lower() in [
                    BACKED_UP,
                ], True, "Snapshot state is not as expected. It is %s" %
                snapshots_list[0].state)

            self.assertEqual(
                snapshots_list[0].volumeid, root_volume.id,
                "Snapshot volume id is not matching with the vm's volume id")

            # Step 3
            qryresult_after_snapshot = self.dbclient.execute(
                " select id, account_name, secondaryStorageTotal\
                        from account_view where account_name = '%s';" %
                self.account.name)

            self.assertNotEqual(
                len(qryresult_after_snapshot), 0,
                "Check sql query to return SecondaryStorageTotal of account")

            storage_qry_result_from_database = qryresult_after_snapshot[0]
            secondary_storage_from_database = storage_qry_result_from_database[
                2]

            snapshot_size = snapshots_list[0].physicalsize
            secondary_storage_after_snapshot = secondary_storage_old + \
                snapshot_size

            # Reset full_snapshot_count to 0 before start of new snapshot chain
            if delta_snapshot_count == (int(self.delta_max) - 1):
                full_snapshot_count = 0
                delta_snapshot_count = 0

            # Full Snapshot of each Snapshot chain
            if full_snapshot_count == 0:

                full_snapshot_count += 1
                full_snapshot_size = snapshot_size

                # Check secondary storage count for Full Snapshots
                self.assertEqual(
                    secondary_storage_from_database,
                    secondary_storage_after_snapshot,
                    "Secondary storage count after full snapshot\
                                should be incremented by size of snapshot.")
                # Step 4
                checkIntegrityOfSnapshot(self,
                                         snapshots_list[0],
                                         checksum_root,
                                         disk_type=DATA)

            else:

                # Delta Snapshot of each Snapshot chain
                delta_snapshot_count += 1
                delta_snapshot_size = snapshot_size

                # Check secondary storage count for Delta Snapshots
                self.assertTrue(
                    delta_snapshot_size < full_snapshot_size,
                    "Delta Snapshot size should be less than\
                                Full Snapshot.")

                self.assertEqual(
                    secondary_storage_from_database,
                    secondary_storage_after_snapshot,
                    "Secondary storage count after delta snapshot\
                                should be incremented by size of snapshot.")

            secondary_storage_old = secondary_storage_from_database

        # Step 5

        # Check in Secondary Storage- Snapshots: S1, S2, S3 are present
        for i in range(int(self.delta_max)):
            self.assertTrue(
                is_snapshot_on_nfs(self.apiclient, self.dbclient, self.config,
                                   self.zone.id, self.snapshots_created[i].id),
                "Check: Snapshot is not on Secondary Storage.")

        # Delete S2

        Snapshot.delete(self.snapshots_created[1], self.apiclient)

        snapshots_list = Snapshot.list(self.apiclient,
                                       id=self.snapshots_created[1].id)

        status = validateList(snapshots_list)
        self.assertEqual(status[0], FAIL, "Snapshots Not Deleted.")

        # Check integrity of Snapshots for S1 and S3
        checkIntegrityOfSnapshot(self,
                                 self.snapshots_created[0],
                                 checksum_created[0],
                                 disk_type=DATA)

        checkIntegrityOfSnapshot(self,
                                 self.snapshots_created[2],
                                 checksum_created[2],
                                 disk_type=DATA)

        # Delete S3

        Snapshot.delete(self.snapshots_created[2], self.apiclient)

        snapshots_list = Snapshot.list(self.apiclient,
                                       id=self.snapshots_created[2].id)

        status = validateList(snapshots_list)
        self.assertEqual(status[0], FAIL, "Snapshots Not Deleted.")

        # Check in Secondary Storage - Snapshots: S2, S3 are deleted
        self.assertFalse(
            is_snapshot_on_nfs(self.apiclient, self.dbclient, self.config,
                               self.zone.id, self.snapshots_created[2].id),
            "Check: Snapshot 2 is still on Secondary Storage. Not Deleted.")

        self.assertFalse(
            is_snapshot_on_nfs(self.apiclient, self.dbclient, self.config,
                               self.zone.id, self.snapshots_created[1].id),
            "Check: Snapshot 3 is still on Secondary Storage. Not Deleted.")

        # Restore Snapshots for S1
        checkIntegrityOfSnapshot(self,
                                 self.snapshots_created[0],
                                 checksum_created[0],
                                 disk_type=DATA)

        # Step 6
        # Delete S1

        Snapshot.delete(self.snapshots_created[0], self.apiclient)

        snapshots_list = Snapshot.list(self.apiclient,
                                       id=self.snapshots_created[0].id)

        status = validateList(snapshots_list)
        self.assertEqual(status[0], FAIL, "Snapshots Not Deleted.")

        # Check in Secondary Storage - Snapshots: All - S1, S2, S3 are deleted

        self.assertFalse(
            is_snapshot_on_nfs(self.apiclient, self.dbclient, self.config,
                               self.zone.id, self.snapshots_created[2].id),
            "Check: Snapshot 3 is still on Secondary Storage. Not Deleted.")

        self.assertFalse(
            is_snapshot_on_nfs(self.apiclient, self.dbclient, self.config,
                               self.zone.id, self.snapshots_created[1].id),
            "Check: Snapshot 2 is still on Secondary Storage. Not Deleted.")

        self.assertFalse(
            is_snapshot_on_nfs(self.apiclient, self.dbclient, self.config,
                               self.zone.id, self.snapshots_created[0].id),
            "Check: Snapshot 1 is still on Secondary Storage. Not Deleted.")

        return