How to use delete_snapshot_schedule method in localstack

Best Python code snippet using localstack_python

dellemc_isilon_snapshotschedule.py

Source:dellemc_isilon_snapshotschedule.py Github

copy

Full Screen

...450 error_message = 'Failed to modify snapshot schedule {0} with ' \451 'error : {1}'.format(name, error_msg)452 LOG.error(error_message)453 self.module.fail_json(msg=error_message)454 def delete_snapshot_schedule(self, name):455 """Delete snapshot schedule"""456 try:457 self.api_instance.delete_snapshot_schedule(name)458 return True459 except Exception as e:460 error_msg = self.determine_error(error_obj=e)461 error_message = 'Failed to delete snapshot schedule: {0} with ' \462 'error: {1}'.format(name, error_msg)463 LOG.error(error_message)464 self.module.fail_json(msg=error_message)465 def determine_error(self, error_obj):466 """Determine the error message to return"""467 if isinstance(error_obj, utils.ApiException):468 error = re.sub("[\n \"]+", ' ', str(error_obj.body))469 else:470 error = error_obj471 return error472 def perform_module_operation(self):473 """474 Perform different actions on snapshot schedule module based on475 parameters chosen in playbook476 """477 name = self.module.params['name']478 state = self.module.params['state']479 access_zone = self.module.params['access_zone']480 path = self.module.params['path']481 new_name = self.module.params['new_name']482 pattern = self.module.params['pattern']483 schedule = self.module.params['schedule']484 desired_retention = self.module.params['desired_retention']485 retention_unit = self.module.params['retention_unit']486 alias = self.module.params['alias']487 # result is a dictionary that contains changed status and snapshot488 # schedule details489 result = dict(490 changed=False,491 snapshot_schedule_details=''492 )493 effective_path = None494 if access_zone is not None:495 if access_zone.lower() == 'system':496 effective_path = path497 else:498 if path:499 effective_path = self.get_zone_base_path(access_zone) + \500 path501 if desired_retention:502 self.validate_desired_retention(desired_retention)503 snapshot_schedule_details = self.get_details(name)504 is_schedule_modified = False505 snapshot_schedule_modification_details = dict()506 if snapshot_schedule_details is not None:507 is_schedule_modified, snapshot_schedule_modification_details = \508 self.check_snapshot_schedule_modified(509 snapshot_schedule_details, alias, desired_retention,510 retention_unit, effective_path, pattern, schedule)511 if state == 'present' and not snapshot_schedule_details:512 LOG.info("Creating new snapshot schedule: %s for path: %s",513 name, effective_path)514 result['changed'] = self.create_snapshot_schedule(515 name, alias, effective_path, desired_retention,516 retention_unit, pattern, schedule) or result['changed']517 if state == 'present' and new_name is not None:518 if len(new_name) == 0:519 self.module.fail_json(msg="Please provide valid string for "520 "new_name")521 if snapshot_schedule_details is None:522 self.module.fail_json(msg="Snapshot schedule not found.")523 if new_name != snapshot_schedule_details['schedules'][0]['name']:524 self.validate_new_name(new_name)525 LOG.info("Renaming snapshot schedule %s to new name %s",526 name, new_name)527 result['changed'] = self.rename_snapshot_schedule(528 snapshot_schedule_details, new_name) or result['changed']529 name = new_name530 if state == 'present' and is_schedule_modified:531 LOG.info("Modifying snapshot schedule %s", name)532 result['changed'] = self.modify_snapshot_schedule(533 name, snapshot_schedule_modification_details) or \534 result['changed']535 if state == 'absent' and snapshot_schedule_details:536 LOG.info("Deleting snapshot schedule %s", name)537 result['changed'] = self.delete_snapshot_schedule(name) or \538 result['changed']539 snapshot_schedule_details = self.get_details(name)540 result['snapshot_schedule_details'] = snapshot_schedule_details541 self.module.exit_json(**result)542def get_isilon_snapshotschedule_parameters():543 """This method provide parameters required for the ansible snapshot544 schedule module on Isilon"""545 return dict(546 name=dict(required=True, type='str'),547 access_zone=dict(type='str', default='System'),548 path=dict(type='str'),549 new_name=dict(type='str'),550 pattern=dict(type='str'),551 schedule=dict(type='str'),...

Full Screen

Full Screen

snapshotschedule.py

Source:snapshotschedule.py Github

copy

Full Screen

...434 error_message = 'Failed to modify snapshot schedule {0} with ' \435 'error : {1}'.format(name, error_msg)436 LOG.error(error_message)437 self.module.fail_json(msg=error_message)438 def delete_snapshot_schedule(self, name):439 """Delete snapshot schedule"""440 try:441 self.api_instance.delete_snapshot_schedule(name)442 return True443 except Exception as e:444 error_msg = self.determine_error(error_obj=e)445 error_message = 'Failed to delete snapshot schedule: {0} with ' \446 'error: {1}'.format(name, error_msg)447 LOG.error(error_message)448 self.module.fail_json(msg=error_message)449 def determine_error(self, error_obj):450 """Determine the error message to return"""451 if isinstance(error_obj, utils.ApiException):452 error = re.sub("[\n \"]+", ' ', str(error_obj.body))453 else:454 error = error_obj455 return error456 def perform_module_operation(self):457 """458 Perform different actions on snapshot schedule module based on459 parameters chosen in playbook460 """461 name = self.module.params['name']462 state = self.module.params['state']463 access_zone = self.module.params['access_zone']464 path = self.module.params['path']465 new_name = self.module.params['new_name']466 pattern = self.module.params['pattern']467 schedule = self.module.params['schedule']468 desired_retention = self.module.params['desired_retention']469 retention_unit = self.module.params['retention_unit']470 alias = self.module.params['alias']471 # result is a dictionary that contains changed status and snapshot472 # schedule details473 result = dict(474 changed=False,475 snapshot_schedule_details=''476 )477 effective_path = None478 if path:479 if access_zone.lower() == 'system':480 effective_path = path.rstrip("/")481 else:482 effective_path = self.get_zone_base_path(access_zone) + \483 path.rstrip("/")484 if desired_retention:485 self.validate_desired_retention(desired_retention)486 snapshot_schedule_details = self.get_details(name)487 is_schedule_modified = False488 snapshot_schedule_modification_details = dict()489 if snapshot_schedule_details is not None:490 is_schedule_modified, snapshot_schedule_modification_details = \491 self.check_snapshot_schedule_modified(492 snapshot_schedule_details, alias, desired_retention,493 retention_unit, effective_path, pattern, schedule)494 if state == 'present' and not snapshot_schedule_details:495 LOG.debug("Creating new snapshot schedule: %s for path: %s",496 name, effective_path)497 result['changed'] = self.create_snapshot_schedule(498 name, alias, effective_path, desired_retention,499 retention_unit, pattern, schedule) or result['changed']500 if state == 'present' and new_name is not None:501 if len(new_name) == 0:502 self.module.fail_json(msg="Please provide valid string for "503 "new_name")504 if snapshot_schedule_details is None:505 self.module.fail_json(msg="Snapshot schedule not found.")506 if new_name != snapshot_schedule_details['schedules'][0]['name']:507 self.validate_new_name(new_name)508 LOG.info("Renaming snapshot schedule %s to new name %s",509 name, new_name)510 result['changed'] = self.rename_snapshot_schedule(511 snapshot_schedule_details, new_name) or result['changed']512 name = new_name513 if state == 'present' and is_schedule_modified:514 LOG.info("Modifying snapshot schedule %s", name)515 result['changed'] = self.modify_snapshot_schedule(516 name, snapshot_schedule_modification_details) or \517 result['changed']518 if state == 'absent' and snapshot_schedule_details:519 LOG.info("Deleting snapshot schedule %s", name)520 result['changed'] = self.delete_snapshot_schedule(name) or \521 result['changed']522 snapshot_schedule_details = self.get_details(name)523 result['snapshot_schedule_details'] = snapshot_schedule_details524 self.module.exit_json(**result)525def get_snapshotschedule_parameters():526 """This method provide parameters required for the ansible snapshot527 schedule module on PowerScale"""528 return dict(529 name=dict(required=True, type='str'),530 access_zone=dict(type='str', default='System'),531 path=dict(type='str', no_log=True),532 new_name=dict(type='str'),533 pattern=dict(type='str'),534 schedule=dict(type='str'),...

Full Screen

Full Screen

test_snapshot_api.py

Source:test_snapshot_api.py Github

copy

Full Screen

...52 def test_delete_snapshot_repstate(self):53 """Test case for delete_snapshot_repstate54 """55 pass56 def test_delete_snapshot_schedule(self):57 """Test case for delete_snapshot_schedule58 """59 pass60 def test_delete_snapshot_schedules(self):61 """Test case for delete_snapshot_schedules62 """63 pass64 def test_delete_snapshot_snapshot(self):65 """Test case for delete_snapshot_snapshot66 """67 pass68 def test_delete_snapshot_snapshots(self):69 """Test case for delete_snapshot_snapshots70 """...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful