def get_snap(self, name=None): if name is not None: ret = VNXSnap.get(self._cli, name) else: snaps = VNXSnap.get(self._cli) ret = [s for s in snaps if self.lun_id in s.source_luns] return ret
def test_modify_snap_failed(self): snap = VNXSnap(cli=t_cli(), name='s2') try: snap.modify(new_name='s1') self.fail('should have raise an exception.') except VNXSnapError: assert_that(snap._name, equal_to('s2'))
def create_snap(self, name, allow_rw=None, auto_delete=None, keep_for=None): return VNXSnap.create(self._cli, self.get_id(self), name, allow_rw, auto_delete, keep_for)
def attach_snap(self, snap): snap_name = VNXSnap.get_name(snap) out = self._cli.attach_snap(snap_name, lun_id=self.get_id(self), poll=self.poll) if len(out): raise ex.VNXAttachSnapError(out)
def attach_snap(self, snap): snap_name = VNXSnap.get_name(snap) out = self._cli.attach_snap(snap_name, lun_id=self.get_id(self), poll=self.poll) ex.raise_if_err(out, 'failed to attach snap {}'.format(snap_name), default=ex.VNXAttachSnapError)
def create_snap(self, name, allow_rw=None, auto_delete=None): out = self._cli.create_snap(self.get_id(self), name, allow_rw, auto_delete, poll=self.poll) raise_if_err(out, ex.VNXCreateSnapError, 'failed to create snap "{}"'.format(name)) return VNXSnap(name, self._cli)
def test_properties(self): snap = VNXSnap('gan_snap', t_cli()) assert_that(snap.name, equal_to('gan_snap')) assert_that(snap.description, equal_to('gan snap')) assert_that(snap.creation_time, equal_to('05/24/13 20:06:12')) assert_that(snap.last_modify_time, equal_to('07/23/14 12:28:42')) assert_that(snap.last_modified_by, equal_to('N/A')) assert_that(snap.source_luns, equal_to([57])) assert_that(snap.source_cg, equal_to('N/A')) assert_that(snap.primary_luns, equal_to([57])) assert_that(snap.state, equal_to('Ready')) assert_that(snap.status, equal_to('OK(0x0)')) assert_that(snap.allow_read_write, equal_to(True)) assert_that(snap.modified, equal_to(True)) assert_that(snap.attached_luns, equal_to([])) assert_that(snap.allow_auto_delete, equal_to(True)) assert_that(snap.expiration_date, equal_to('Never')) assert_that(snap.existed, equal_to(True))
def f(): src = VNXSnap.get(t_cli(), name='123') src.copy('456')
def test_get_by_name(self): snap = VNXSnap.get(t_cli(), name='gan_snap') assert_that(snap.creation_time, equal_to('05/24/13 20:06:12'))
def get_snap(self, name=None): return VNXSnap.get(self._cli, name)
def get_snap(self, name=None): if name is not None: ret = VNXSnap.get(self._cli, name) else: ret = VNXSnapList(self._cli, res=self.get_id(self)) return ret
def remove_snap(self, name): VNXSnap(name, self._cli).remove()
def f(): snap = VNXSnap(cli=t_cli(), name='s5') snap.restore(res_id='540', backup_snap='a-existing-snap')
def test_attach_snap(self): m1 = VNXLun(name='m1', cli=t_cli()) s1 = VNXSnap(name='s1', cli=t_cli()) m1.attach_snap(s1) m1.update() assert_that(m1.attached_snapshot, equal_to('s1'))
def name_to_snap(name): if is_valid(name): ret = VNXSnap(name=name) else: ret = None return ret
def f(): snap = VNXSnap(cli=t_cli(), name='s5') snap.restore(res_id='541')
def create_snap(self, name, allow_rw=None, auto_delete=None): return VNXSnap.create(self._cli, self._get_name(), name, allow_rw, auto_delete)
def f(): snap = VNXSnap(cli=t_cli(), name='s3') snap.remove()
def remove_snap(self, name): self._remove_resource(VNXSnap(name, self._cli))
def restore_snap(self, name): VNXSnap(name, self._cli).restore(self.get_id(self))
def delete_snap(self, name): self._delete_resource(VNXSnap(name, self._cli))
def test_get_all(self): snaps = VNXSnap.get(t_cli()) assert_that(len(snaps), equal_to(47))
def test_get_not_found(self): snap = VNXSnap.get(t_cli(), name='xxx') assert_that(snap.existed, equal_to(False))
def test_modify_snap(self): snap = VNXSnap(cli=t_cli(), name='s1') snap.modify(new_name='s2', allow_rw=True) assert_that(snap._name, equal_to('s2'))
def f(): snap = VNXSnap(cli=t_cli(), name='s4') snap.delete()
def test_modify_snap(self): snap = VNXSnap(cli=t_cli(), name='s1') snap.modify(new_name='s2', rw=True) assert_that(snap._name, equal_to('s2'))
def delete_snap(self, name): VNXSnap(name, self._cli).delete()
def test_restore_snap(self): snap = VNXSnap(cli=t_cli(), name='s5') snap.restore(res_id='540')