Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions hpe3par_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3674,3 +3674,45 @@ def removeVolumesFromVolumeSet(self, name, setmembers):
self.client.modifyVolumeSet(
name, action=client.HPE3ParClient.SET_MEM_REMOVE,
setmembers=setmembers)

def createSchedule(self, schedule_name, task, taskfreq):
"""Create Schedule for volume snapshot.
:param schedule_name - The name of the schedule
:type - string
:param volume_name - The name of the volume
:type - string
:param expiration - Expiration period for snapshot
:type - string
:retain - Retaintion period for snapshot
:type - string
:taskschedule - schedule for snapshot created
:type - string
"""
return self.client.createSchedule(schedule_name, task, taskfreq)

def deleteSchedule(self, schedule_name):
"""Delete Schedule
:param schedule_name - The name of the schedule to delete
:type - string
"""
return self.client.deleteSchedule(schedule_name)

def scheduleExists(self, name):
try:
result = self.getSchedule(name)
except exceptions.HTTPNotFound:
return False
if 'No scheduled tasks listed' in result:
return False
else:
return True


def getSchedule(self, schedule_name):
"""Get Schedule
:param schedule_name - The name of the schedule to get information
:type - string
"""
return self.client.getSchedule(schedule_name)


16 changes: 9 additions & 7 deletions test/HPE3ParClient_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import datetime
from functools import wraps
from hpe3par_sdk import client
#from hpe3parclient import client, file_client
from hpe3parclient import file_client

TIME = datetime.datetime.now().strftime('%H%M%S')

Expand Down Expand Up @@ -127,8 +127,8 @@ def setUp(self, withSSH=False, withFilePersona=False):

time.sleep(1)
if self.withFilePersona:
pass
#self.cl = file_client.HPE3ParFilePersonaClient(self.flask_url)
#pass
self.cl = file_client.HPE3ParFilePersonaClient(self.flask_url)
else:
self.cl = client.HPE3ParClient(self.flask_url)

Expand Down Expand Up @@ -209,10 +209,12 @@ def setUp(self, withSSH=False, withFilePersona=False):

if not self.port:
ports = self.cl.getPorts()
for port in ports:
#print port.mode
ports = [port for port in ports if port.linkState == 4 and ( port.device is not None or not port.device) and port.mode == 2]
self.port = ports[0].port_pos
if withFilePersona:
ports = [port for port in ports['members'] if port['linkState'] == 4 and port['mode'] == 2]
self.port = ports[0]['portPos']
else:
ports = [port for port in ports if port.linkState == 4 and ( port.device is not None or not port.device) and port.mode == 2]
self.port = ports[0].port_pos

def tearDown(self):
self.cl.logout()
Expand Down
4 changes: 3 additions & 1 deletion test/test_HPE3ParClient_FilePersona.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def setUp(self, withSSH=True, withFilePersona=True):
self.withSSH = withSSH
self.withFilePersona = withFilePersona
super(HPE3ParFilePersonaClientTestCase, self).setUp(
withSSH=self.withSSH, withFilePersona=self.withFilePersona)
withSSH=True, withFilePersona=True)

# Only get the tpdinterface once and reuse it for all the tests.
if self.interfaces is None:
Expand Down Expand Up @@ -439,6 +439,8 @@ def validate_vfs(self, fpgname=None, vfsname=None, no_vfsname=None,
"Skip on real array which may have exiting VFSs.")
@print_header_and_footer
def test_getvfs_empty(self):
import pdb
pdb.set_trace()
self.validate_vfs(expected_count=0)

@unittest.skipIf(is_live_test() and skip_file_persona(), SKIP_MSG)
Expand Down
39 changes: 28 additions & 11 deletions test/test_HPE3ParClient_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import time
import unittest
from testconfig import config

import mock
from test import HPE3ParClient_base as hpe3parbase

from hpe3parclient import exceptions
Expand All @@ -29,6 +29,7 @@
VOLUME_NAME3 = 'VOLUME3_UNIT_TEST' + hpe3parbase.TIME
SNAP_NAME1 = 'SNAP_UNIT_TEST1' + hpe3parbase.TIME
SNAP_NAME2 = 'SNAP_UNIT_TEST2' + hpe3parbase.TIME
SCHEDULE_NAME1 = 'SCHEDULE_NAME1' + hpe3parbase.TIME
DOMAIN = 'UNIT_TEST_DOMAIN'
VOLUME_SET_NAME1 = 'VOLUME_SET1_UNIT_TEST' + hpe3parbase.TIME
VOLUME_SET_NAME2 = 'VOLUME_SET2_UNIT_TEST' + hpe3parbase.TIME
Expand Down Expand Up @@ -721,8 +722,8 @@ def test_10_modify_volume_set_change_comment(self):

def test_10_modify_volume_set_change_flash_cache(self):
self.printHeader('modify_volume_set_change_flash_cache')
self.cl.FLASH_CACHE_ENABLED = 1
self.cl.FLASH_CACHE_DISABLED = 2
self.cl.FLASH_CACHE_ENABLED = 1
self.cl.FLASH_CACHE_DISABLED = 2
try:
self.cl.createVolumeSet(VOLUME_SET_NAME1, domain=self.DOMAIN,
comment="First")
Expand Down Expand Up @@ -755,7 +756,7 @@ def test_10_modify_volume_set_change_flash_cache(self):

def test_10_modify_volume_set_add_members_to_empty(self):
self.printHeader('modify_volume_set_add_members_to_empty')
self.cl.SET_MEM_ADD = 1
self.cl.SET_MEM_ADD = 1
optional = {'comment': 'test volume 1', 'tpvv': True}
self.cl.createVolume(VOLUME_NAME1, CPG_NAME1, SIZE, optional)
optional = {'comment': 'test volume 2', 'tpvv': True}
Expand All @@ -777,7 +778,7 @@ def test_10_modify_volume_set_add_members_to_empty(self):

def test_10_modify_volume_set_add_members(self):
self.printHeader('modify_volume_set_add_members')
#HPE3ParClient.SET_MEM_ADD = 1
#HPE3ParClient.SET_MEM_ADD = 1
optional = {'comment': 'test volume 1', 'tpvv': True}
self.cl.createVolume(VOLUME_NAME1, CPG_NAME1, SIZE, optional)
optional = {'comment': 'test volume 2', 'tpvv': True}
Expand All @@ -789,8 +790,8 @@ def test_10_modify_volume_set_add_members(self):
comment="Unit test volume set 1")

members = [VOLUME_NAME2]
# ----------- TODO-----------------
# change 1 to HPE3ParClient.SET_MEM_ADD,
# ----------- TODO-----------------
# change 1 to HPE3ParClient.SET_MEM_ADD,
self.cl.modifyVolumeSet(VOLUME_SET_NAME1, 1,
setmembers=members)

Expand All @@ -803,10 +804,10 @@ def test_10_modify_volume_set_add_members(self):

def test_10_modify_volume_set_del_members(self):
self.printHeader('modify_volume_del_members')
#--------TODO----------
# Remove below declartion to use the parent class value
self.cl.SET_MEM_REMOVE = 2
#--------TODO----------
# Remove below declartion to use the parent class value
self.cl.SET_MEM_REMOVE = 2

optional = {'comment': 'test volume 1', 'tpvv': True}
self.cl.createVolume(VOLUME_NAME1, CPG_NAME1, SIZE, optional)
Expand Down Expand Up @@ -2202,6 +2203,22 @@ def test_25_promote_vcopy_on_rep_vol_with_bad_param(self):

self.printFooter('promote_vcopy_on_rep_vol_with_bad_param')

@mock.patch('hpe3parclient.client.HPE3ParClient._run')
@mock.patch('hpe3parclient.client.HPE3ParClient.check_response')
def test_run(self,mock_res, mock_run):
self.printHeader('schedule_test')
mock_run.return_value = "SchedName File/Command Min Hour DOM Month DOW CreatedBy Status Alert NextRunTim\
schedule1 createsv svro-vol@h@@m@ test_volume 0* * * * 3paradm active Y 2"
mock_res.return_value = None
#self.cl = client.HPE3ParClient(self.flask_url)
cmd = "createsv -ro snap-"+VOLUME_NAME1+" "+VOLUME_NAME1
self.cl.createSchedule(SCHEDULE_NAME1,cmd,'hourly')
res = self.cl.getSchedule(SCHEDULE_NAME1)
self.assertIsNotNone(res)
self.cl.deleteSchedule(SCHEDULE_NAME1)
self.printFooter('schedule_test')


# testing
# suite = unittest.TestLoader().
# loadTestsFromTestCase(HPE3ParClientVolumeTestCase)
Expand Down