Skip to content

Commit

Permalink
VNX: support to specify SP in SMP creation (#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
yong-huang authored Dec 28, 2020
1 parent 1c4e44b commit e729361
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
5 changes: 4 additions & 1 deletion storops/vnx/block_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,14 @@ def create_mount_point(self,
primary_lun_id=None,
primary_lun_name=None,
mount_point_name=None,
mount_point_id=None):
mount_point_id=None,
sp_id=None):
cmd = 'lun -create -type snap'.split()
cmd += self._get_primary_lun_opt(primary_lun_id, primary_lun_name)
cmd += self._get_lun_opt(lun_id=mount_point_id,
lun_name=mount_point_name)
if sp_id:
cmd += text_var('-sp', sp_id)
return cmd

@command
Expand Down
5 changes: 3 additions & 2 deletions storops/vnx/resource/lun.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,14 @@ def create(cli,
return pool.create_lun(lun_name, size_gb, lun_id, provision,
tier, ignore_thresholds, sp_id)

def create_mount_point(self, _id=None, name=None):
def create_mount_point(self, _id=None, name=None, sp_id=None):
lun_id = self.get_id(self)
out = self._cli.create_mount_point(
primary_lun_id=lun_id,
mount_point_name=name,
mount_point_id=_id,
poll=self.poll)
poll=self.poll,
sp_id=sp_id)
ex.raise_if_err(out, default=ex.VNXCreateMpError)
return VNXLun(lun_id=_id, name=name, cli=self._cli)

Expand Down
13 changes: 13 additions & 0 deletions storops_test/vnx/resource/test_lun.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,19 @@ def test_create_mount_point_success(self):
assert_that(pl._get_name(), equal_to('l1'))
assert_that(m2.attached_snapshot, none())

@patch_cli
def test_create_mount_point_with_sp_success(self):
lun = VNXLun(name='l1', cli=t_cli())
m2 = lun.create_mount_point(name='m2', sp_id='A')
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())

@patch_cli
def test_mount_point_properties(self):
lun = VNXLun(name='l1', cli=t_cli())
Expand Down
9 changes: 9 additions & 0 deletions storops_test/vnx/test_block_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,15 @@ def test_create_mount_point_with_name(self):
equal_to('lun -create -type snap '
'-primaryLunName l1 -name m1'))

@extract_command
def test_create_mount_point_with_sp(self):
cmd = self.client.create_mount_point(primary_lun_name='l1',
mount_point_name='m1',
sp_id='B')
assert_that(cmd,
equal_to('lun -create -type snap '
'-primaryLunName l1 -name m1 -sp B'))

def test_create_mount_point_missing_primary_lun(self):
def f():
self.client.create_mount_point(mount_point_name='m1')
Expand Down

0 comments on commit e729361

Please sign in to comment.