def test_change_name_failed(self): l = VNXLun(name='l1', cli=t_cli()) try: l.name = 'l3' self.fail('should have raised an exception.') except VNXModifyLunError: assert_that(l._get_name(), equal_to('l1'))
def test_get_snap(self): lun = VNXLun(lun_id=196, cli=t_cli()) assert_that(lun.name, equal_to('Exch-BronzePlan-AppSync-2.2')) assert_that(lun.lun_id, equal_to(196)) snaps = lun.get_snap() assert_that(len(snaps), equal_to(13)) for snap in snaps: assert_that(snap.source_luns, has_item(lun.lun_id))
def test_property_instance_cache(self): m1 = VNXLun(name='m1', cli=t_cli()) s1 = m1.attached_snapshot s2 = m1.attached_snapshot assert_that(hash(s1), equal_to(hash(s2))) m1.update() s3 = m1.attached_snapshot assert_that(hash(s3), is_not(equal_to(hash(s1)))) assert_that(s1._cli, not_none())
def test_mount_point_properties(self): lun = VNXLun(name='l1', cli=t_cli()) m1 = lun.create_mount_point(name='m1') assert_that(m1.name, equal_to('m1')) assert_that(m1.lun_id, equal_to(4057)) s1 = m1.attached_snapshot assert_that(s1, instance_of(VNXSnap)) assert_that(s1._cli, equal_to(t_cli())) assert_that(s1._get_name(), equal_to('s1'))
def test_create_mount_point(self): lun = VNXLun(name='l1', cli=t_cli()) m1 = lun.create_mount_point(mount_point_name='m1') assert_that(m1.name, equal_to('m1')) assert_that(m1.lun_id, equal_to(4057)) assert_that(m1.attached_snapshot, equal_to('s1')) m2 = lun.create_mount_point(mount_point_name='m2') assert_that(lun.snapshot_mount_points, only_contains(4056, 4057)) assert_that(m2.attached_snapshot, equal_to('N/A'))
def luns(self): """Aggregator for ioclass_luns and ioclass_snapshots.""" lun_list, smp_list = [], [] if self.ioclass_luns: lun_list = map(lambda l: VNXLun(lun_id=l.lun_id, name=l.name, cli=self._cli), self.ioclass_luns) if self.ioclass_snapshots: smp_list = map(lambda smp: VNXLun(name=smp.name, cli=self._cli), self.ioclass_snapshots) return list(lun_list) + list(smp_list)
def test_migration_on_complete_session_not_found(self): c = _Counter() def on_complete(): c.increase() l0 = VNXLun(name='lun0', cli=t_cli()) l1 = VNXLun(name='lun1', cli=t_cli()) l0.migrate(l1, on_complete=on_complete).join() assert_that(c.x, equal_to(1))
def test_migration_on_error(self): c = _Counter() def on_error(): c.decrease() l0 = VNXLun(name='lun0', cli=t_cli()) l2 = VNXLun(name='lun2', cli=t_cli()) l2.migrate(l0, on_error=on_error).join() assert_that(c.x, equal_to(-1))
def test_create_mount_point_success(self): lun = VNXLun(name='l1', cli=t_cli()) m2 = lun.create_mount_point(name='m2') assert_that(lun.snapshot_mount_points, instance_of(VNXLunList)) assert_that(str(lun), contains_string('"VNXLunList": [')) for smp in lun.snapshot_mount_points: assert_that(smp, instance_of(VNXLun)) pl = smp.primary_lun assert_that(pl, instance_of(VNXLun)) assert_that(pl._get_name(), equal_to('l1')) assert_that(m2.attached_snapshot, none())
def test_lun_properties(self): wwn = '60:06:01:60:12:60:3D:00:95:63:38:87:9D:69:E5:11' lun = VNXLun(lun_id=3, cli=t_cli()) assert_that(lun.state, equal_to('Ready')) assert_that(lun.wwn, equal_to(wwn)) assert_that(lun.status, equal_to('OK(0x0)')) assert_that(lun.operation, equal_to('None')) assert_that(lun.total_capacity_gb, equal_to(500.0)) assert_that(lun.current_owner, equal_to(VNXSPEnum.SP_A)) assert_that(lun.default_owner, equal_to(VNXSPEnum.SP_A)) assert_that(lun.attached_snapshot, none()) assert_that(lun.lun_id, equal_to(3)) assert_that(lun.name, equal_to('File_CS0_21132_0_d7')) assert_that(lun.pool_name, equal_to('Pool4File')) assert_that(lun.is_thin_lun, equal_to(True)) assert_that(lun.is_compressed, equal_to(False)) assert_that(lun.is_dedup, equal_to(False)) assert_that(lun.initial_tier, equal_to('Optimize Pool')) assert_that(lun.tiering_policy, none()) assert_that(lun.is_private, equal_to(False)) assert_that(lun.user_capacity_gbs, equal_to(500.0)) assert_that(lun.consumed_capacity_gbs, equal_to(512.249)) assert_that(len(lun.snapshot_mount_points), equal_to(0)) assert_that(lun.primary_lun, none()) assert_that(lun.raid_type, equal_to(VNXPoolRaidType.RAID_MIXED))
def test_attach_alu(self): sg = self.test_sg() lun = VNXLun(name='x', cli=t_cli()) assert_that(sg.has_alu(0), equal_to(False)) sg.attach_alu(lun) assert_that(sg.has_alu(0), equal_to(True)) assert_that(sg.get_hlu(0), equal_to(1))
def test_lun_perf_counters(self): lun = VNXLun(lun_id=3, cli=t_cli()) assert_that(lun.read_requests, equal_to(1)) assert_that(lun.read_requests_sp_a, equal_to(2)) assert_that(lun.read_requests_sp_b, equal_to(3)) assert_that(lun.write_requests, equal_to(4)) assert_that(lun.write_requests_sp_a, equal_to(5)) assert_that(lun.write_requests_sp_b, equal_to(6)) assert_that(lun.blocks_read, equal_to(7)) assert_that(lun.blocks_read_sp_a, equal_to(8)) assert_that(lun.blocks_read_sp_b, equal_to(9)) assert_that(lun.blocks_written, equal_to(10)) assert_that(lun.blocks_written_sp_a, equal_to(11)) assert_that(lun.blocks_written_sp_b, equal_to(12)) assert_that(lun.busy_ticks, equal_to(13)) assert_that(lun.busy_ticks_sp_a, equal_to(14)) assert_that(lun.busy_ticks_sp_b, equal_to(15)) assert_that(lun.idle_ticks, equal_to(16)) assert_that(lun.idle_ticks_sp_a, equal_to(17)) assert_that(lun.idle_ticks_sp_b, equal_to(18)) assert_that(lun.sum_of_outstanding_requests, equal_to(19)) assert_that(lun.sum_of_outstanding_requests_sp_a, equal_to(20)) assert_that(lun.sum_of_outstanding_requests_sp_b, equal_to(21)) assert_that(lun.non_zero_request_count_arrivals, equal_to(22)) assert_that(lun.non_zero_request_count_arrivals_sp_a, equal_to(23)) assert_that(lun.non_zero_request_count_arrivals_sp_b, equal_to(24)) assert_that(lun.implicit_trespasses, equal_to(25)) assert_that(lun.implicit_trespasses_sp_a, equal_to(26)) assert_that(lun.implicit_trespasses_sp_b, equal_to(27)) assert_that(lun.explicit_trespasses, equal_to(28)) assert_that(lun.explicit_trespasses_sp_a, equal_to(29)) assert_that(lun.explicit_trespasses_sp_b, equal_to(30)) assert_that(lun.extreme_performance, equal_to(1.96)) assert_that(lun.performance, equal_to(5.68)) assert_that(lun.capacity, equal_to(92.37))
def test_create_with_sp_success(self): lun = VNXLun.create(t_cli(), pool_id=0, lun_id=2, size_gb=2, sp_id='A') assert_that(lun.user_capacity_gbs, equal_to(2.0))
def add_image(self, sp_ip, lun_id, recovery_policy=VNXMirrorViewRecoveryPolicy.AUTO, sync_rate=VNXMirrorViewSyncRate.HIGH): lun_id = VNXLun.get_id(lun_id) self._cli.add_mirror_view_image(self._get_name(), sp_ip, lun_id, recovery_policy, sync_rate, poll=self.poll)
def test_attach_alu_success(self): sg = self.sg_7 lun = VNXLun(name='x', cli=t_cli()) assert_that(sg.has_alu(0), equal_to(False)) hlu = sg.attach_alu(lun) assert_that(sg.has_alu(0), equal_to(True)) assert_that(sg.get_hlu(0), equal_to(1)) assert_that(hlu, equal_to(1))
def normalize_lun(luns, cli): if isinstance(luns, int): return [VNXLun(lun_id=luns, cli=cli)] elif isinstance(luns, VNXLun): return [luns] elif isinstance(luns, list) or isinstance(luns, VNXLunList): return luns elif luns is None: return [] else: raise ValueError('Invalid format for luns.')
def create_lun(self, lun_name=None, size_gb=1, lun_id=None, provision=None, tier=None, ignore_thresholds=None): pool = {} if self._pool_id is not None: pool['pool_id'] = self._pool_id else: pool['pool_name'] = self._get_name() ret = self._cli.create_pool_lun(lun_name=lun_name, lun_id=lun_id, size_gb=size_gb, provision=provision, tier=tier, ignore_thresholds=ignore_thresholds, poll=self.poll, **pool) raise_if_err(ret, ex.VNXCreateLunError, 'error creating lun.') return VNXLun(lun_id, lun_name, self._cli)
def test_lun_tier_invalid_str(self): lun = VNXLun() self.assertRaises(AttributeError, setattr, lun, 'tier', 'invalid')
def test_lun_provision_compressed(self): lun = VNXLun() lun.is_thin_lun = True lun.is_compressed = True lun.dedup_state = False assert_that(lun.provision, equal_to(VNXProvisionEnum.COMPRESSED))
def test_lun_provision_str_not_valid(self): lun = VNXLun() self.assertRaises(AttributeError, setattr, lun, 'provision', 'invalid')
def f(): l = VNXLun(lun_id=4000, cli=t_cli()) l.tier = VNXTieringEnum.LOW
def get_lun(self): return VNXLun(lun_id=2, cli=t_cli())
def test_delete_lun_has_smp(self): l = VNXLun(lun_id=196, cli=t_cli()) # no error raised l.delete(force=True)
def f(): l = VNXLun(lun_id=1, cli=t_cli()) l.expand(12)
def f(): l1 = VNXLun(name='not_exists', cli=t_cli()) l1.delete()
def set_property(): l1 = VNXLun(name='l1', cli=t_cli()) l1.is_dedup = False
def f(): lun = VNXLun(name='y', cli=t_cli()) lun.delete(force=True)
def f(): l2 = VNXLun(name='in_sg', cli=t_cli()) l2.delete()
def test_create_mirror_view(self): l = VNXLun(lun_id=245, cli=t_cli()) mv = l.create_mirror_view('mv0') assert_that(mv.state, equal_to('Active'))
def f(): l1 = VNXLun(lun_id=1, cli=t_cli()) l2 = VNXLun(lun_id=2, cli=t_cli()) l1.migrate(l2)
def f(): l1 = VNXLun(lun_id=3, cli=t_cli()) l1.create_snap('s1')
def test_lun_tier_high(self): lun = VNXLun() lun.tiering_policy = 'Highest Available' lun.initial_tier = 'Highest Available' assert_that(lun.tier, equal_to(VNXTieringEnum.HIGH))
def method_call(): l1 = VNXLun(name='l1', cli=t_cli()) l1.disable_dedup()
def test_create_mirror_view(self): lun = VNXLun(245) mv = self.vnx.create_mirror_view('mv0', lun) assert_that(mv.state, equal_to('Active'))
def f(): l2 = VNXLun(name='l3', cli=t_cli()) l2.enable_dedup()
def get_lun(self, lun_id=None, name=None, lun_type=None): return VNXLun.get(self._cli, lun_id=lun_id, name=name, lun_type=lun_type)
def prop(): l1 = VNXLun(lun_id=19, cli=t_cli()) l1.is_compressed = False
def f(): l = VNXLun(lun_id=0, cli=t_cli()) l.expand(999999)
def method(): l1 = VNXLun(lun_id=19, cli=t_cli()) l1.disable_compression()
def f(): l1 = VNXLun(lun_id=11, cli=t_cli()) l1.create_snap('s1')
def f(): l1 = VNXLun(lun_id=3, cli=t_cli()) l1.enable_compression(VNXCompressionRate.LOW, True)
def test_lun_provision_default(self): lun = VNXLun() self.assertEqual(VNXProvisionEnum.THICK, lun.provision)
def method(): l1 = VNXLun(lun_id=19, cli=t_cli()) l1.enable_compression(VNXCompressionRate.HIGH)
def test_lun_provision_dedup(self): lun = VNXLun() lun.is_thin_lun = True lun.is_compressed = False lun.dedup_state = True assert_that(lun.provision, equal_to(VNXProvisionEnum.DEDUPED))
def test_get_id_list(self): l22 = VNXLun(lun_id=22) l23 = VNXLun(lun_id=23) assert_that(VNXLun.get_id_list(l22, l23), only_contains(22, 23))
def test_lun_tier_default(self): lun = VNXLun() self.assertEqual(VNXTieringEnum.HIGH_AUTO, lun.tier)
def test_get_id_with_update(self): m1 = VNXLun(name='m1', cli=t_cli()) assert_that(VNXLun.get_id(m1), equal_to(4057))
def test_lun_tier_auto(self): lun = VNXLun() lun.tiering_policy = 'Auto Tier' lun.initial_tier = 'Optimize Pool' assert_that(lun.tier, equal_to(VNXTieringEnum.AUTO))
def test_get_id(self): l1 = VNXLun(lun_id=11) assert_that(VNXLun.get_id(l1), equal_to(11))
def test_get_migration_session(self): source = VNXLun(lun_id=0) ms = self.vnx.get_migration_session(source) assert_that(ms.existed, equal_to(True))
def get_lun(self): lun_list = VNXLun.get(self._cli, poll=self.poll) return [l for l in lun_list if l.pool_name == self.name]
def test_create_mirror_view_async(self): lun = VNXLun(71) mv = self.vnx.create_mirror_view_async('testdr_003', lun) assert_that(mv.state, equal_to('Active'))
def f(): l2 = VNXLun(name='l2', cli=t_cli()) l2.delete()