def test_cl_vols_ssc_single(self):
        """Test cluster ssc for single vol."""
        na_server = api.NaServer('127.0.0.1')
        vserver = 'openstack'
        test_vols = set([copy.deepcopy(self.vol1)])
        sis = {'vola': {'dedup': False, 'compression': False}}
        mirrored = {'vola': [{'dest_loc': 'openstack1:vol1',
                              'rel_type': 'data_protection',
                              'mirr_state': 'broken'},
                             {'dest_loc': 'openstack2:vol2',
                              'rel_type': 'data_protection',
                              'mirr_state': 'snapmirrored'}]}

        self.mox.StubOutWithMock(ssc_utils, 'query_cluster_vols_for_ssc')
        self.mox.StubOutWithMock(ssc_utils, 'get_sis_vol_dict')
        self.mox.StubOutWithMock(ssc_utils, 'get_snapmirror_vol_dict')
        self.mox.StubOutWithMock(ssc_utils, 'query_aggr_options')
        self.mox.StubOutWithMock(ssc_utils, 'query_aggr_storage_disk')
        ssc_utils.query_cluster_vols_for_ssc(
            na_server, vserver, 'vola').AndReturn(test_vols)
        ssc_utils.get_sis_vol_dict(
            na_server, vserver, 'vola').AndReturn(sis)
        ssc_utils.get_snapmirror_vol_dict(
            na_server, vserver, 'vola').AndReturn(mirrored)
        raiddp = {'ha_policy': 'cfo', 'raid_type': 'raiddp'}
        ssc_utils.query_aggr_options(
            na_server, 'aggr1').AndReturn(raiddp)
        ssc_utils.query_aggr_storage_disk(na_server, 'aggr1').AndReturn('SSD')
        self.mox.ReplayAll()

        res_vols = ssc_utils.get_cluster_vols_with_ssc(
            na_server, vserver, volume='vola')

        self.mox.VerifyAll()
        self.assertEqual(len(res_vols), 1)
    def test_get_cluster_ssc(self):
        """Test get cluster ssc map."""
        na_server = api.NaServer('127.0.0.1')
        vserver = 'openstack'
        test_vols = set(
            [self.vol1, self.vol2, self.vol3, self.vol4, self.vol5])

        self.mox.StubOutWithMock(ssc_utils, 'get_cluster_vols_with_ssc')
        ssc_utils.get_cluster_vols_with_ssc(
            na_server, vserver).AndReturn(test_vols)
        self.mox.ReplayAll()

        res_map = ssc_utils.get_cluster_ssc(na_server, vserver)

        self.mox.VerifyAll()
        self.assertEqual(len(res_map['mirrored']), 1)
        self.assertEqual(len(res_map['dedup']), 3)
        self.assertEqual(len(res_map['compression']), 1)
        self.assertEqual(len(res_map['thin']), 2)
        self.assertEqual(len(res_map['all']), 5)
    def test_cl_vols_ssc_all(self):
        """Test cluster ssc for all vols."""
        na_server = api.NaServer('127.0.0.1')
        vserver = 'openstack'
        test_vols = set([copy.deepcopy(self.vol1),
                         copy.deepcopy(self.vol2), copy.deepcopy(self.vol3)])
        sis = {'vola': {'dedup': False, 'compression': False},
               'volb': {'dedup': True, 'compression': False}}
        mirrored = {'vola': [{'dest_loc': 'openstack1:vol1',
                              'rel_type': 'data_protection',
                              'mirr_state': 'broken'},
                             {'dest_loc': 'openstack2:vol2',
                              'rel_type': 'data_protection',
                              'mirr_state': 'snapmirrored'}],
                    'volb': [{'dest_loc': 'openstack1:vol2',
                              'rel_type': 'data_protection',
                              'mirr_state': 'broken'}]}

        self.mox.StubOutWithMock(ssc_utils, 'query_cluster_vols_for_ssc')
        self.mox.StubOutWithMock(ssc_utils, 'get_sis_vol_dict')
        self.mox.StubOutWithMock(ssc_utils, 'get_snapmirror_vol_dict')
        self.mox.StubOutWithMock(ssc_utils, 'query_aggr_options')
        self.mox.StubOutWithMock(ssc_utils, 'query_aggr_storage_disk')
        ssc_utils.query_cluster_vols_for_ssc(
            na_server, vserver, None).AndReturn(test_vols)
        ssc_utils.get_sis_vol_dict(na_server, vserver, None).AndReturn(sis)
        ssc_utils.get_snapmirror_vol_dict(na_server, vserver, None).AndReturn(
            mirrored)
        raiddp = {'ha_policy': 'cfo', 'raid_type': 'raiddp'}
        ssc_utils.query_aggr_options(
            na_server, IgnoreArg()).AndReturn(raiddp)
        ssc_utils.query_aggr_storage_disk(
            na_server, IgnoreArg()).AndReturn('SSD')
        raid4 = {'ha_policy': 'cfo', 'raid_type': 'raid4'}
        ssc_utils.query_aggr_options(
            na_server, IgnoreArg()).AndReturn(raid4)
        ssc_utils.query_aggr_storage_disk(
            na_server, IgnoreArg()).AndReturn('SAS')
        self.mox.ReplayAll()

        res_vols = ssc_utils.get_cluster_vols_with_ssc(
            na_server, vserver, volume=None)

        self.mox.VerifyAll()
        for vol in res_vols:
            if vol.id['name'] == 'volc':
                self.assertEqual(vol.sis['compression'], False)
                self.assertEqual(vol.sis['dedup'], False)
            else:
                pass