Skip to content

Commit e729361

Browse files
authored
VNX: support to specify SP in SMP creation (#336)
1 parent 1c4e44b commit e729361

5 files changed

Lines changed: 29 additions & 3 deletions

File tree

storops/vnx/block_cli.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,11 +370,14 @@ def create_mount_point(self,
370370
primary_lun_id=None,
371371
primary_lun_name=None,
372372
mount_point_name=None,
373-
mount_point_id=None):
373+
mount_point_id=None,
374+
sp_id=None):
374375
cmd = 'lun -create -type snap'.split()
375376
cmd += self._get_primary_lun_opt(primary_lun_id, primary_lun_name)
376377
cmd += self._get_lun_opt(lun_id=mount_point_id,
377378
lun_name=mount_point_name)
379+
if sp_id:
380+
cmd += text_var('-sp', sp_id)
378381
return cmd
379382

380383
@command

storops/vnx/resource/lun.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,14 @@ def create(cli,
118118
return pool.create_lun(lun_name, size_gb, lun_id, provision,
119119
tier, ignore_thresholds, sp_id)
120120

121-
def create_mount_point(self, _id=None, name=None):
121+
def create_mount_point(self, _id=None, name=None, sp_id=None):
122122
lun_id = self.get_id(self)
123123
out = self._cli.create_mount_point(
124124
primary_lun_id=lun_id,
125125
mount_point_name=name,
126126
mount_point_id=_id,
127-
poll=self.poll)
127+
poll=self.poll,
128+
sp_id=sp_id)
128129
ex.raise_if_err(out, default=ex.VNXCreateMpError)
129130
return VNXLun(lun_id=_id, name=name, cli=self._cli)
130131

storops_test/vnx/resource/test_lun.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,19 @@ def test_create_mount_point_success(self):
338338
assert_that(pl._get_name(), equal_to('l1'))
339339
assert_that(m2.attached_snapshot, none())
340340

341+
@patch_cli
342+
def test_create_mount_point_with_sp_success(self):
343+
lun = VNXLun(name='l1', cli=t_cli())
344+
m2 = lun.create_mount_point(name='m2', sp_id='A')
345+
assert_that(lun.snapshot_mount_points, instance_of(VNXLunList))
346+
assert_that(str(lun), contains_string('"VNXLunList": ['))
347+
for smp in lun.snapshot_mount_points:
348+
assert_that(smp, instance_of(VNXLun))
349+
pl = smp.primary_lun
350+
assert_that(pl, instance_of(VNXLun))
351+
assert_that(pl._get_name(), equal_to('l1'))
352+
assert_that(m2.attached_snapshot, none())
353+
341354
@patch_cli
342355
def test_mount_point_properties(self):
343356
lun = VNXLun(name='l1', cli=t_cli())

storops_test/vnx/test_block_cli.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,15 @@ def test_create_mount_point_with_name(self):
511511
equal_to('lun -create -type snap '
512512
'-primaryLunName l1 -name m1'))
513513

514+
@extract_command
515+
def test_create_mount_point_with_sp(self):
516+
cmd = self.client.create_mount_point(primary_lun_name='l1',
517+
mount_point_name='m1',
518+
sp_id='B')
519+
assert_that(cmd,
520+
equal_to('lun -create -type snap '
521+
'-primaryLunName l1 -name m1 -sp B'))
522+
514523
def test_create_mount_point_missing_primary_lun(self):
515524
def f():
516525
self.client.create_mount_point(mount_point_name='m1')

storops_test/vnx/testdata/block_output/lun_-create_-type_snap_-primaryLun_382_-name_m2_-sp_A.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)