def test_assess_status(self, os_application_version_set): with mock.patch.object(swift_utils, 'assess_status_func') as asf: callee = mock.MagicMock() asf.return_value = callee swift_utils.assess_status('test-config') asf.assert_called_once_with('test-config', None) callee.assert_called_once_with() os_application_version_set.assert_called_with( swift_utils.VERSION_PACKAGE)
def test_assess_status(self, os_application_version_set): with mock.patch.object(swift_utils, 'assess_status_func') as asf: callee = mock.MagicMock() asf.return_value = callee swift_utils.assess_status('test-config') asf.assert_called_once_with('test-config', None) callee.assert_called_once_with() os_application_version_set.assert_called_with( swift_utils.VERSION_PACKAGE )
def resume(args): """Resume all the swift services. @raises Exception if any services fail to start """ for service in args.services: started = service_resume(service) if not started: raise Exception("{} didn't start cleanly.".format(service)) clear_unit_paused() assess_status(CONFIGS, args.services)
def pause(args): """Pause all the swift services. @raises Exception if any services fail to stop """ for service in args.services: stopped = service_pause(service) if not stopped: raise Exception("{} didn't stop cleanly.".format(service)) set_unit_paused() assess_status(CONFIGS, args.services)
def resume(args): """Resume all the swift services. @raises Exception if any services fail to start """ for service in args.services: started = service_resume(service) if not started: raise Exception("{} didn't start cleanly.".format(service)) with HookData()(): kv().set('unit-paused', False) assess_status(CONFIGS)
def pause(args): """Pause all the swift services. @raises Exception if any services fail to stop """ for service in args.services: stopped = service_pause(service) if not stopped: raise Exception("{} didn't stop cleanly.".format(service)) with HookData()(): kv().set('unit-paused', True) assess_status(CONFIGS)
def test_assess_status(self, relation_ids, has_min_zones, status_set, ctxt, workload_status, config, is_paused): config.return_value = 3 is_paused.return_value = True swift_utils.assess_status(None) status_set.assert_called_with('maintenance', "Paused. Use 'resume' action to resume " "normal service.") is_paused.return_value = False relation_ids.return_value = [] swift_utils.assess_status(None) status_set.assert_called_with('blocked', 'Missing relation: storage') relation_ids.return_value = ['swift-storage:1'] ctxt.return_value = {'allowed_hosts': ['1.2.3.4']} swift_utils.assess_status(None) status_set.assert_called_with('blocked', 'Not enough related storage nodes') ctxt.return_value = {'allowed_hosts': ['1.2.3.4', '2.3.4.5', '3.4.5.6']} has_min_zones.return_value = False swift_utils.assess_status(None) status_set.assert_called_with('blocked', 'Not enough storage zones for minimum ' 'replicas')
def main(): try: hooks.execute(sys.argv) except UnregisteredHookError as e: log('Unknown hook {} - skipping.'.format(e), level=DEBUG) assess_status(CONFIGS)