From 7e14c1c9763e5f94d2a808039efa2ec68edbf5ee Mon Sep 17 00:00:00 2001 From: nirupaman Date: Fri, 26 Oct 2018 12:02:17 +0530 Subject: [PATCH 1/9] schedule changes --- hpe3parclient/client.py | 138 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) diff --git a/hpe3parclient/client.py b/hpe3parclient/client.py index 6b49315b..04b17660 100644 --- a/hpe3parclient/client.py +++ b/hpe3parclient/client.py @@ -4439,3 +4439,141 @@ def targetInRemoteCopyGroupExists( except Exception: pass return False + + def check_response(self, resp): + for r in resp: + if 'error' in str.lower(r) or 'invalid' in str.lower(r) or 'the schedule format' in str.lower(r): + err_resp = r.strip() + return err_resp + + def createSchedule(self, schedule_name, task, taskfreq='@hourly'): + """Create Schedule for volume snapshot. + :param schedule_name - The name of the schedule + :type - string + :param task - command to for which schedule is created + :type - string + :param taskfreq - frequency of schedule + :type - string + """ + cmd = ['createsched'] + cmd.append("\""+task+"\"") + if '@' not in taskfreq: + cmd.append("\""+taskfreq+"\"") + else: + cmd.append(taskfreq) + cmd.append(schedule_name) + try: + resp = self._run(cmd) + + err_resp = self.check_response(resp) + if err_resp: + raise exceptions.SSHException(err_resp) + except exceptions.SSHException as ex: + raise exceptions.SSHException(ex) + + + def deleteSchedule(self, schedule_name): + """Delete Schedule + :param schedule_name - The name of the schedule to delete + :type - string + """ + cmd = ['removesched', '-f', schedule_name] + try: + resp = self._run(cmd) + + err_resp = self.check_response(resp) + if err_resp: + err = (("Delete snapschedule failed Error is" + " '%(err_resp)s' ") % + {'err_resp': err_resp}) + raise exceptions.HTTPNotFound(reason=err) + except exceptions.HTTPNotFound as ex: + raise exceptions.HTTPNotFound(reason=ex) + + def getSchedule(self, schedule_name): + """Get Schedule + :param schedule_name - The name of the schedule to get information + :type - string + """ + cmd = ['showsched ', schedule_name] + try: + result = self._run(cmd) + if 'No scheduled tasks ' in result : + msg = "Couldn't find the schedule '%s'" % schedule_name + raise exceptions.HTTPNotFound(error={'desc': msg}) + except exceptions.HTTPNotFound as ex: + raise exceptions.HTTPNotFound(reason=ex) + return result + + def modifySchedule(self, name, schedule_opt): + """Modify Schedule. + :param name - The name of the schedule + :type - string + :param schedule_opt - + :type schedule_opt - dictionary of option to be modified + .. code-block:: python + + mod_request = { + 'newName': 'myNewName', # New name of the schedule + 'taskFrequency': '0 * * * *' # String containing cron or + # @monthly, @hourly, @daily, @yearly + # and @weekly. + } + """ + + cmd = ['setsched'] + if 'newName' in schedule_opt: + cmd.append('-name') + cmd.append(schedule_opt['newName']) + + if 'taskFrequency' in schedule_opt: + cmd.append('-s') + if '@' not in schedule_opt['taskFrequency']: + cmd.append("\""+schedule_opt['taskFrequency']+"\"") + else: + cmd.append(schedule_opt['taskFrequency']) + cmd.append(name) + try: + resp = self._run(cmd) + + err_resp = self.check_response(resp) + if err_resp: + raise exceptions.SSHException(err_resp) + except exceptions.SSHException as ex: + raise exceptions.SSHException(ex) + + def suspendSchedule(self, schedule_name): + """Suspend Schedule + :param schedule_name - The name of the schedule to get information + :type - string + """ + cmd = ['setsched', '-suspend', schedule_name] + try: + resp = self._run(cmd) + err_resp = self.check_response(resp) + if err_resp: + err = (("Schedule suspend failed Error is" + " '%(err_resp)s' ") % + {'err_resp': err_resp}) + raise exceptions.SSHException(reason=err) + except exceptions.SSHException as ex: + raise exceptions.SSHException(reason=ex) + + def resumeSchedule(self, schedule_name): + """Resume Schedule + :param schedule_name - The name of the schedule to get information + :type - string + """ + cmd = ['setsched', '-resume', schedule_name] + try: + resp = self._run(cmd) + err_resp = self.check_response(resp) + if err_resp: + err = (("Schedule resume failed Error is" + " '%(err_resp)s' ") % + {'err_resp': err_resp}) + raise exceptions.SSHException(reason=err) + except exceptions.SSHException as ex: + raise exceptions.SSHException(reason=ex) + + From cc48f8774ddfb82f0d82ab7024d73311a21592d7 Mon Sep 17 00:00:00 2001 From: nirupaman Date: Fri, 26 Oct 2018 16:55:16 +0530 Subject: [PATCH 2/9] review changes --- hpe3parclient/client.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/hpe3parclient/client.py b/hpe3parclient/client.py index 04b17660..cd125e40 100644 --- a/hpe3parclient/client.py +++ b/hpe3parclient/client.py @@ -4446,7 +4446,7 @@ def check_response(self, resp): err_resp = r.strip() return err_resp - def createSchedule(self, schedule_name, task, taskfreq='@hourly'): + def createSchedule(self, schedule_name, task, taskfreq): """Create Schedule for volume snapshot. :param schedule_name - The name of the schedule :type - string @@ -4486,9 +4486,9 @@ def deleteSchedule(self, schedule_name): err = (("Delete snapschedule failed Error is" " '%(err_resp)s' ") % {'err_resp': err_resp}) - raise exceptions.HTTPNotFound(reason=err) - except exceptions.HTTPNotFound as ex: - raise exceptions.HTTPNotFound(reason=ex) + raise exceptions.SSHException(reason=err) + except exceptions.SSHException as ex: + raise exceptions.SSHException(reason=ex) def getSchedule(self, schedule_name): """Get Schedule @@ -4500,9 +4500,9 @@ def getSchedule(self, schedule_name): result = self._run(cmd) if 'No scheduled tasks ' in result : msg = "Couldn't find the schedule '%s'" % schedule_name - raise exceptions.HTTPNotFound(error={'desc': msg}) - except exceptions.HTTPNotFound as ex: - raise exceptions.HTTPNotFound(reason=ex) + raise exceptions.SSHException(error={'desc': msg}) + except exceptions.SSHException as ex: + raise exceptions.SSHException(reason=ex) return result def modifySchedule(self, name, schedule_opt): From 1aa369c2ac39faa9bbe91ed0673d763ddc9bcdd3 Mon Sep 17 00:00:00 2001 From: nirupaman Date: Mon, 29 Oct 2018 08:31:16 +0530 Subject: [PATCH 3/9] review changes check --- hpe3parclient/client.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hpe3parclient/client.py b/hpe3parclient/client.py index cd125e40..6d9d409c 100644 --- a/hpe3parclient/client.py +++ b/hpe3parclient/client.py @@ -4442,7 +4442,7 @@ def targetInRemoteCopyGroupExists( def check_response(self, resp): for r in resp: - if 'error' in str.lower(r) or 'invalid' in str.lower(r) or 'the schedule format' in str.lower(r): + if 'error' in str.lower(r) or 'invalid' in str.lower(r): err_resp = r.strip() return err_resp @@ -4468,6 +4468,10 @@ def createSchedule(self, schedule_name, task, taskfreq): err_resp = self.check_response(resp) if err_resp: raise exceptions.SSHException(err_resp) + else: + for r in resp: + if 'the schedule format is or by @hourly @daily @monthly @weekly @monthly @yearly' in str.lower(r): + raise exceptions.SSHException(r.strip()) except exceptions.SSHException as ex: raise exceptions.SSHException(ex) @@ -4539,6 +4543,11 @@ def modifySchedule(self, name, schedule_opt): err_resp = self.check_response(resp) if err_resp: raise exceptions.SSHException(err_resp) + else: + for r in resp: + if 'the schedule format is or by @hourly @daily @monthly @weekly @monthly @yearly' in str.lower(r): + raise exceptions.SSHException(r.strip()) + except exceptions.SSHException as ex: raise exceptions.SSHException(ex) From 0be41024d797da2896e48c44be50eedb19248ecb Mon Sep 17 00:00:00 2001 From: nirupaman Date: Mon, 29 Oct 2018 08:43:07 +0530 Subject: [PATCH 4/9] check review --- hpe3parclient/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hpe3parclient/client.py b/hpe3parclient/client.py index 6d9d409c..94220b4c 100644 --- a/hpe3parclient/client.py +++ b/hpe3parclient/client.py @@ -4470,7 +4470,7 @@ def createSchedule(self, schedule_name, task, taskfreq): raise exceptions.SSHException(err_resp) else: for r in resp: - if 'the schedule format is or by @hourly @daily @monthly @weekly @monthly @yearly' in str.lower(r): + if 'the schedule format is' in str.lower(r): raise exceptions.SSHException(r.strip()) except exceptions.SSHException as ex: raise exceptions.SSHException(ex) @@ -4545,7 +4545,7 @@ def modifySchedule(self, name, schedule_opt): raise exceptions.SSHException(err_resp) else: for r in resp: - if 'the schedule format is or by @hourly @daily @monthly @weekly @monthly @yearly' in str.lower(r): + if 'the schedule format is' in str.lower(r): raise exceptions.SSHException(r.strip()) except exceptions.SSHException as ex: From becf99ab4bfae1fe3f381e1971264e65e9cdfabe Mon Sep 17 00:00:00 2001 From: nirupaman Date: Mon, 29 Oct 2018 08:50:03 +0530 Subject: [PATCH 5/9] message format --- hpe3parclient/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hpe3parclient/client.py b/hpe3parclient/client.py index 94220b4c..b688a28c 100644 --- a/hpe3parclient/client.py +++ b/hpe3parclient/client.py @@ -4471,7 +4471,7 @@ def createSchedule(self, schedule_name, task, taskfreq): else: for r in resp: if 'the schedule format is' in str.lower(r): - raise exceptions.SSHException(r.strip()) + raise exceptions.SSHException((r.strip()).replace('@', '')) except exceptions.SSHException as ex: raise exceptions.SSHException(ex) @@ -4546,7 +4546,7 @@ def modifySchedule(self, name, schedule_opt): else: for r in resp: if 'the schedule format is' in str.lower(r): - raise exceptions.SSHException(r.strip()) + raise exceptions.SSHException((r.strip()).replace('@', '')) except exceptions.SSHException as ex: raise exceptions.SSHException(ex) From 1214d6b813576384140819f2a375ed05124ddd0d Mon Sep 17 00:00:00 2001 From: nirupaman Date: Mon, 29 Oct 2018 09:59:41 +0530 Subject: [PATCH 6/9] check for string --- hpe3parclient/client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hpe3parclient/client.py b/hpe3parclient/client.py index b688a28c..8a6043c5 100644 --- a/hpe3parclient/client.py +++ b/hpe3parclient/client.py @@ -4470,8 +4470,8 @@ def createSchedule(self, schedule_name, task, taskfreq): raise exceptions.SSHException(err_resp) else: for r in resp: - if 'the schedule format is' in str.lower(r): - raise exceptions.SSHException((r.strip()).replace('@', '')) + if str.lower('The schedule format is or by @hourly @daily @monthly @weekly @monthly @yearly') in str.lower(r): + raise exceptions.SSHException(r.strip()) except exceptions.SSHException as ex: raise exceptions.SSHException(ex) @@ -4545,7 +4545,7 @@ def modifySchedule(self, name, schedule_opt): raise exceptions.SSHException(err_resp) else: for r in resp: - if 'the schedule format is' in str.lower(r): + if str.lower('The schedule format is or by @hourly @daily @monthly @weekly @monthly @yearly') in str.lower(r): raise exceptions.SSHException((r.strip()).replace('@', '')) except exceptions.SSHException as ex: From 1802881986a10be876d727265fbb013cb50bae23 Mon Sep 17 00:00:00 2001 From: nirupaman Date: Mon, 29 Oct 2018 10:33:58 +0530 Subject: [PATCH 7/9] long line --- hpe3parclient/client.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hpe3parclient/client.py b/hpe3parclient/client.py index 8a6043c5..b4fb3b9a 100644 --- a/hpe3parclient/client.py +++ b/hpe3parclient/client.py @@ -4470,7 +4470,8 @@ def createSchedule(self, schedule_name, task, taskfreq): raise exceptions.SSHException(err_resp) else: for r in resp: - if str.lower('The schedule format is or by @hourly @daily @monthly @weekly @monthly @yearly') in str.lower(r): + if str.lower('The schedule format is \ + or by @hourly @daily @monthly @weekly @monthly @yearly') in str.lower(r): raise exceptions.SSHException(r.strip()) except exceptions.SSHException as ex: raise exceptions.SSHException(ex) @@ -4545,7 +4546,8 @@ def modifySchedule(self, name, schedule_opt): raise exceptions.SSHException(err_resp) else: for r in resp: - if str.lower('The schedule format is or by @hourly @daily @monthly @weekly @monthly @yearly') in str.lower(r): + if str.lower('The schedule format is \ + or by @hourly @daily @monthly @weekly @monthly @yearly') in str.lower(r): raise exceptions.SSHException((r.strip()).replace('@', '')) except exceptions.SSHException as ex: From 44c350aa4751e9106f7ad52352e5c13b32939f90 Mon Sep 17 00:00:00 2001 From: nirupaman Date: Mon, 29 Oct 2018 11:43:19 +0530 Subject: [PATCH 8/9] generic exception for schedule not found --- hpe3parclient/client.py | 11 ++++++----- hpe3parclient/exceptions.py | 2 ++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/hpe3parclient/client.py b/hpe3parclient/client.py index b4fb3b9a..2feeef0f 100644 --- a/hpe3parclient/client.py +++ b/hpe3parclient/client.py @@ -4503,11 +4503,12 @@ def getSchedule(self, schedule_name): cmd = ['showsched ', schedule_name] try: result = self._run(cmd) - if 'No scheduled tasks ' in result : - msg = "Couldn't find the schedule '%s'" % schedule_name - raise exceptions.SSHException(error={'desc': msg}) - except exceptions.SSHException as ex: - raise exceptions.SSHException(reason=ex) + for r in result: + if 'No scheduled tasks ' in r : + msg = "Couldn't find the schedule '%s'" % schedule_name + raise exceptions.SSHNotFoundException(msg) + except exceptions.SSHNotFoundException as ex: + raise exceptions.SSHNotFoundException(ex) return result def modifySchedule(self, name, schedule_opt): diff --git a/hpe3parclient/exceptions.py b/hpe3parclient/exceptions.py index c6ff662c..c9578f11 100644 --- a/hpe3parclient/exceptions.py +++ b/hpe3parclient/exceptions.py @@ -471,6 +471,8 @@ class SetQOSRuleException(SSHException): class SrstatldException(SSHException): message = "SSH command failed: %(command)s" +class SSHNotFoundException(SSHException): + message = "SSH command failed: %(command)s" class ProcessExecutionError(Exception): def __init__(self, stdout=None, stderr=None, exit_code=None, cmd=None, From d21e4efd5ace522e228ae3ae564143a949a2610e Mon Sep 17 00:00:00 2001 From: nirupaman Date: Mon, 29 Oct 2018 13:38:33 +0530 Subject: [PATCH 9/9] UT added for schedule --- hpe3parclient/client.py | 72 +++++++++++++++---------------- hpe3parclient/exceptions.py | 2 + test/test_HPE3ParClient_volume.py | 66 +++++++++++++++++++++++++++- 3 files changed, 101 insertions(+), 39 deletions(-) diff --git a/hpe3parclient/client.py b/hpe3parclient/client.py index 2feeef0f..ffeb5dcb 100644 --- a/hpe3parclient/client.py +++ b/hpe3parclient/client.py @@ -4456,11 +4456,11 @@ def createSchedule(self, schedule_name, task, taskfreq): :type - string """ cmd = ['createsched'] - cmd.append("\""+task+"\"") + cmd.append("\"" + task + "\"") if '@' not in taskfreq: - cmd.append("\""+taskfreq+"\"") + cmd.append("\"" + taskfreq + "\"") else: - cmd.append(taskfreq) + cmd.append(taskfreq) cmd.append(schedule_name) try: resp = self._run(cmd) @@ -4471,12 +4471,12 @@ def createSchedule(self, schedule_name, task, taskfreq): else: for r in resp: if str.lower('The schedule format is \ - or by @hourly @daily @monthly @weekly @monthly @yearly') in str.lower(r): + or by @hourly @daily @monthly @weekly @monthly \ +@yearly') in str.lower(r): raise exceptions.SSHException(r.strip()) except exceptions.SSHException as ex: raise exceptions.SSHException(ex) - def deleteSchedule(self, schedule_name): """Delete Schedule :param schedule_name - The name of the schedule to delete @@ -4488,9 +4488,8 @@ def deleteSchedule(self, schedule_name): err_resp = self.check_response(resp) if err_resp: - err = (("Delete snapschedule failed Error is" - " '%(err_resp)s' ") % - {'err_resp': err_resp}) + err = (("Delete snapschedule failed Error is\ + '%(err_resp)s' ") % {'err_resp': err_resp}) raise exceptions.SSHException(reason=err) except exceptions.SSHException as ex: raise exceptions.SSHException(reason=ex) @@ -4502,11 +4501,11 @@ def getSchedule(self, schedule_name): """ cmd = ['showsched ', schedule_name] try: - result = self._run(cmd) - for r in result: - if 'No scheduled tasks ' in r : - msg = "Couldn't find the schedule '%s'" % schedule_name - raise exceptions.SSHNotFoundException(msg) + result = self._run(cmd) + for r in result: + if 'No scheduled tasks ' in r: + msg = "Couldn't find the schedule '%s'" % schedule_name + raise exceptions.SSHNotFoundException(msg) except exceptions.SSHNotFoundException as ex: raise exceptions.SSHNotFoundException(ex) return result @@ -4522,22 +4521,22 @@ def modifySchedule(self, name, schedule_opt): mod_request = { 'newName': 'myNewName', # New name of the schedule 'taskFrequency': '0 * * * *' # String containing cron or - # @monthly, @hourly, @daily, @yearly - # and @weekly. + # @monthly, @hourly, @daily, + # @yearly and @weekly. } """ cmd = ['setsched'] if 'newName' in schedule_opt: - cmd.append('-name') - cmd.append(schedule_opt['newName']) + cmd.append('-name') + cmd.append(schedule_opt['newName']) if 'taskFrequency' in schedule_opt: - cmd.append('-s') - if '@' not in schedule_opt['taskFrequency']: - cmd.append("\""+schedule_opt['taskFrequency']+"\"") - else: - cmd.append(schedule_opt['taskFrequency']) + cmd.append('-s') + if '@' not in schedule_opt['taskFrequency']: + cmd.append("\"" + schedule_opt['taskFrequency'] + "\"") + else: + cmd.append(schedule_opt['taskFrequency']) cmd.append(name) try: resp = self._run(cmd) @@ -4548,8 +4547,9 @@ def modifySchedule(self, name, schedule_opt): else: for r in resp: if str.lower('The schedule format is \ - or by @hourly @daily @monthly @weekly @monthly @yearly') in str.lower(r): - raise exceptions.SSHException((r.strip()).replace('@', '')) + or by @hourly @daily @monthly @weekly @monthly \ +@yearly') in str.lower(r): + raise exceptions.SSHException(r.strip()) except exceptions.SSHException as ex: raise exceptions.SSHException(ex) @@ -4561,12 +4561,11 @@ def suspendSchedule(self, schedule_name): """ cmd = ['setsched', '-suspend', schedule_name] try: - resp = self._run(cmd) - err_resp = self.check_response(resp) - if err_resp: - err = (("Schedule suspend failed Error is" - " '%(err_resp)s' ") % - {'err_resp': err_resp}) + resp = self._run(cmd) + err_resp = self.check_response(resp) + if err_resp: + err = (("Schedule suspend failed Error is\ + '%(err_resp)s' ") % {'err_resp': err_resp}) raise exceptions.SSHException(reason=err) except exceptions.SSHException as ex: raise exceptions.SSHException(reason=ex) @@ -4578,14 +4577,11 @@ def resumeSchedule(self, schedule_name): """ cmd = ['setsched', '-resume', schedule_name] try: - resp = self._run(cmd) - err_resp = self.check_response(resp) - if err_resp: - err = (("Schedule resume failed Error is" - " '%(err_resp)s' ") % - {'err_resp': err_resp}) + resp = self._run(cmd) + err_resp = self.check_response(resp) + if err_resp: + err = (("Schedule resume failed Error is\ + '%(err_resp)s' ") % {'err_resp': err_resp}) raise exceptions.SSHException(reason=err) except exceptions.SSHException as ex: raise exceptions.SSHException(reason=ex) - - diff --git a/hpe3parclient/exceptions.py b/hpe3parclient/exceptions.py index c9578f11..b8aad46c 100644 --- a/hpe3parclient/exceptions.py +++ b/hpe3parclient/exceptions.py @@ -471,9 +471,11 @@ class SetQOSRuleException(SSHException): class SrstatldException(SSHException): message = "SSH command failed: %(command)s" + class SSHNotFoundException(SSHException): message = "SSH command failed: %(command)s" + class ProcessExecutionError(Exception): def __init__(self, stdout=None, stderr=None, exit_code=None, cmd=None, description=None): diff --git a/test/test_HPE3ParClient_volume.py b/test/test_HPE3ParClient_volume.py index 6b6dbea1..e797ebaa 100644 --- a/test/test_HPE3ParClient_volume.py +++ b/test/test_HPE3ParClient_volume.py @@ -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 @@ -29,6 +29,8 @@ 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 +SCHEDULE_NAME2 = 'SCHEDULE_NAME2' + hpe3parbase.TIME DOMAIN = 'UNIT_TEST_DOMAIN' VOLUME_SET_NAME1 = 'VOLUME_SET1_UNIT_TEST' + hpe3parbase.TIME VOLUME_SET_NAME2 = 'VOLUME_SET2_UNIT_TEST' + hpe3parbase.TIME @@ -2189,6 +2191,68 @@ 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_create_schedule(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 + + 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.printFooter('create_schedule') + + @mock.patch('hpe3parclient.client.HPE3ParClient._run') + @mock.patch('hpe3parclient.client.HPE3ParClient.check_response') + def test_delete_schedule(self, mock_res, mock_run): + self.printHeader('delete_schedule') + 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 + + cmd = "createsv -ro snap-"+VOLUME_NAME1+" "+VOLUME_NAME1 + self.cl.createSchedule(SCHEDULE_NAME1,cmd,'hourly') + res = self.cl.getSchedule(SCHEDULE_NAME1) + self.assertIsNotNone(res) + mock_run.return_value = 'No scheduled tasks' + self.cl.deleteSchedule(SCHEDULE_NAME1) + res = self.cl.getSchedule(SCHEDULE_NAME1) + self.assertEqual(res, 'No scheduled tasks') + self.printFooter('delete_schedule') + + @mock.patch('hpe3parclient.client.HPE3ParClient._run') + @mock.patch('hpe3parclient.client.HPE3ParClient.check_response') + def test_modify_schedule(self, mock_res, mock_run): + self.printHeader('modify_schedule') + 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 + + cmd = "createsv -ro snap-"+VOLUME_NAME1+" "+VOLUME_NAME1 + self.cl.createSchedule(SCHEDULE_NAME1,cmd,'hourly') + self.cl.modifySchedule(SCHEDULE_NAME1, {'newName': SCHEDULE_NAME2}) + res = self.cl.getSchedule(SCHEDULE_NAME2) + self.assertIsNotNone(res) + self.printFooter('modify_schedule') + + @mock.patch('hpe3parclient.client.HPE3ParClient._run') + @mock.patch('hpe3parclient.client.HPE3ParClient.check_response') + def test_suspend_resume_schedule(self, mock_res, mock_run): + self.printHeader('suspend_resume_schedule') + 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 + + cmd = "createsv -ro snap-"+VOLUME_NAME1+" "+VOLUME_NAME1 + self.cl.createSchedule(SCHEDULE_NAME1,cmd,'hourly') + self.cl.suspendSchedule(SCHEDULE_NAME1) + self.cl.resumeSchedule(SCHEDULE_NAME1) + self.printFooter('suspend_resume_schedule') + + # testing # suite = unittest.TestLoader(). # loadTestsFromTestCase(HPE3ParClientVolumeTestCase)