summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2023-05-29 11:50:40 +0000
committerCoprDistGit <infra@openeuler.org>2023-05-29 11:50:40 +0000
commitfa67ddffdf6d434762145e57d0efeda51d024361 (patch)
treeda00a8a47593b6b7169d326d6e35f96fe97a66db
parentaedf70288b5ffbfe274a28d59c0a9152d8e5db20 (diff)
automatic import of python-lifeguard
-rw-r--r--.gitignore1
-rw-r--r--python-lifeguard.spec659
-rw-r--r--sources1
3 files changed, 661 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..260d568 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/lifeguard-1.1.0.tar.gz
diff --git a/python-lifeguard.spec b/python-lifeguard.spec
new file mode 100644
index 0000000..2c9a7b8
--- /dev/null
+++ b/python-lifeguard.spec
@@ -0,0 +1,659 @@
+%global _empty_manifest_terminate_build 0
+Name: python-lifeguard
+Version: 1.1.0
+Release: 1
+Summary: Application to monitor your systems and give you the security to sleep peacefully at night
+License: GPL2
+URL: https://github.com/LifeguardSystem/lifeguard
+Source0: https://mirrors.nju.edu.cn/pypi/web/packages/31/74/053c7907859194dc69071c6585a4a5d68bc4dd107b5287bc905135791c1e/lifeguard-1.1.0.tar.gz
+BuildArch: noarch
+
+Requires: python3-flask
+Requires: python3-schedule
+Requires: python3-gunicorn
+Requires: python3-requests
+Requires: python3-tabulate
+
+%description
+# Lifeguard
+
+![Build Status](https://github.com/LifeguardSystem/lifeguard/workflows/Lifeguard%20Core%20CI/badge.svg)
+![Lifeguard Core Publish](https://github.com/LifeguardSystem/lifeguard/workflows/Lifeguard%20Core%20Publish/badge.svg)
+[![PyPI version](https://badge.fury.io/py/lifeguard.svg)](https://badge.fury.io/py/lifeguard)
+
+## Examples of Usage
+
+See a complete example at: https://github.com/LifeguardSystem/lifeguard-example
+
+### Settings File
+
+In the root of project should be exists a file called `lifeguard_settings.py` like the example:
+
+```python
+"""
+Lifeguard Settings
+"""
+import lifeguard_mongodb
+# other dependecies
+
+# Plugins modules
+PLUGINS = [
+ lifeguard_mongodb,
+ # other plugins
+]
+
+# You can execute code in the lifeguard startup process
+def setup(_lifeguard_context):
+ pass
+```
+
+### Create a validation
+
+To create a validation you should create a file into `validations` directory. The file should ends with `_validation.py`.
+Example:
+
+```python
+import requests
+from lifeguard import NORMAL, PROBLEM, change_status
+from lifeguard.actions.database import save_result_into_database
+from lifeguard.actions.notifications import notify_in_single_message
+from lifeguard.logger import lifeguard_logger as logger
+from lifeguard.validations import ValidationResponse, validation
+
+
+@validation(
+ "check if pudim is alive",
+ actions=[save_result_into_database, notify_in_single_message],
+ schedule={"every": {"minutes": 1}},
+)
+def pudim_is_alive():
+ status = NORMAL
+ result = requests.get("http://pudim.com.br")
+ logger.info("pudim status code: %s", result.status_code)
+
+ if result.status_code != 200:
+ status = change_status(status, PROBLEM)
+
+ return ValidationResponse(
+ "pudim_is_alive",
+ NORMAL,
+ {status: result.status_code},
+ {"notification": {"notify": True}},
+ )
+```
+
+### Validation Actions
+
+Action is a simple python function with only 2 arguments: a validation response and a dict called settings. These settings are the parameter called settings in validation.
+
+```python
+def custom_action(validation_response, settings):
+ pass
+```
+
+Builtin validations can be found in [Wiki](https://github.com/LifeguardSystem/lifeguard/wiki).
+
+### Create a custom controller
+
+To create a custom controller with decorators see the example
+
+```python
+import json
+
+from lifeguard.controllers import controller
+
+
+@controller("/hello/<name>")
+def hello(name):
+ return json.dumps({"name": name})
+```
+
+This file should be in the `controllers` directory and should ends with `_controller.py`.
+
+### Init Lifeguard
+
+Execute: `lifeguard`
+
+To init only web server: `lifeguard --no-scheduler`
+
+To init only scheduler: `lifeguard --no-server`
+
+### Settings
+
+To see all settings avaiable run command:
+
+`lifeguard -d`
+
+## Builtin Endpoints
+
+### Recover Status
+
+__To get global status and all validations.__
+
+`GET /lifeguard/status/complete`
+
+```json
+{
+
+ "status": "NORMAL",
+ "validations": [
+ {
+ "validation_name": "pudim",
+ "status": "NORMAL",
+ "details": {
+ "NORMAL": 200
+ },
+ "settings": {
+ "notification": {
+ "notify": true
+ }
+ },
+ "last_execution": "2021-06-15T10:46"
+ },
+ {
+ "validation_name": "my site",
+ "status": "NORMAL",
+ "details": {
+ "NORMAL": 200
+ },
+ "settings": {
+ "notification": {
+ "notify": true
+ }
+ },
+ "last_execution": "2021-06-15T10:46"
+ }
+ ]
+}
+```
+
+__To get global status and only non normal validations.__
+
+`GET /lifeguard/status`
+
+```json
+{
+
+ "status": "PROBLEM",
+ "validations": [
+ {
+ "validation_name": "my site",
+ "status": "PROBLEM",
+ "details": {
+ "NORMAL": 200
+ },
+ "settings": {
+ "notification": {
+ "notify": true
+ }
+ },
+ "last_execution": "2021-06-15T10:46"
+ }
+ ]
+}
+```
+
+## Authentication
+
+### Builtin Methods
+
+#### Basic Authentication
+
+Set users in lifeguard context like in the example:
+
+```python
+# in lifeguard_settings.py
+from lifeguard.auth import BASIC_AUTH_METHOD
+
+def setup(lifeguard_context):
+ lifeguard_context.auth_method = BASIC_AUTH_METHOD
+ lifeguard_context.users = [{"username": "test", "password": "pass"}]
+```
+
+
+%package -n python3-lifeguard
+Summary: Application to monitor your systems and give you the security to sleep peacefully at night
+Provides: python-lifeguard
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-lifeguard
+# Lifeguard
+
+![Build Status](https://github.com/LifeguardSystem/lifeguard/workflows/Lifeguard%20Core%20CI/badge.svg)
+![Lifeguard Core Publish](https://github.com/LifeguardSystem/lifeguard/workflows/Lifeguard%20Core%20Publish/badge.svg)
+[![PyPI version](https://badge.fury.io/py/lifeguard.svg)](https://badge.fury.io/py/lifeguard)
+
+## Examples of Usage
+
+See a complete example at: https://github.com/LifeguardSystem/lifeguard-example
+
+### Settings File
+
+In the root of project should be exists a file called `lifeguard_settings.py` like the example:
+
+```python
+"""
+Lifeguard Settings
+"""
+import lifeguard_mongodb
+# other dependecies
+
+# Plugins modules
+PLUGINS = [
+ lifeguard_mongodb,
+ # other plugins
+]
+
+# You can execute code in the lifeguard startup process
+def setup(_lifeguard_context):
+ pass
+```
+
+### Create a validation
+
+To create a validation you should create a file into `validations` directory. The file should ends with `_validation.py`.
+Example:
+
+```python
+import requests
+from lifeguard import NORMAL, PROBLEM, change_status
+from lifeguard.actions.database import save_result_into_database
+from lifeguard.actions.notifications import notify_in_single_message
+from lifeguard.logger import lifeguard_logger as logger
+from lifeguard.validations import ValidationResponse, validation
+
+
+@validation(
+ "check if pudim is alive",
+ actions=[save_result_into_database, notify_in_single_message],
+ schedule={"every": {"minutes": 1}},
+)
+def pudim_is_alive():
+ status = NORMAL
+ result = requests.get("http://pudim.com.br")
+ logger.info("pudim status code: %s", result.status_code)
+
+ if result.status_code != 200:
+ status = change_status(status, PROBLEM)
+
+ return ValidationResponse(
+ "pudim_is_alive",
+ NORMAL,
+ {status: result.status_code},
+ {"notification": {"notify": True}},
+ )
+```
+
+### Validation Actions
+
+Action is a simple python function with only 2 arguments: a validation response and a dict called settings. These settings are the parameter called settings in validation.
+
+```python
+def custom_action(validation_response, settings):
+ pass
+```
+
+Builtin validations can be found in [Wiki](https://github.com/LifeguardSystem/lifeguard/wiki).
+
+### Create a custom controller
+
+To create a custom controller with decorators see the example
+
+```python
+import json
+
+from lifeguard.controllers import controller
+
+
+@controller("/hello/<name>")
+def hello(name):
+ return json.dumps({"name": name})
+```
+
+This file should be in the `controllers` directory and should ends with `_controller.py`.
+
+### Init Lifeguard
+
+Execute: `lifeguard`
+
+To init only web server: `lifeguard --no-scheduler`
+
+To init only scheduler: `lifeguard --no-server`
+
+### Settings
+
+To see all settings avaiable run command:
+
+`lifeguard -d`
+
+## Builtin Endpoints
+
+### Recover Status
+
+__To get global status and all validations.__
+
+`GET /lifeguard/status/complete`
+
+```json
+{
+
+ "status": "NORMAL",
+ "validations": [
+ {
+ "validation_name": "pudim",
+ "status": "NORMAL",
+ "details": {
+ "NORMAL": 200
+ },
+ "settings": {
+ "notification": {
+ "notify": true
+ }
+ },
+ "last_execution": "2021-06-15T10:46"
+ },
+ {
+ "validation_name": "my site",
+ "status": "NORMAL",
+ "details": {
+ "NORMAL": 200
+ },
+ "settings": {
+ "notification": {
+ "notify": true
+ }
+ },
+ "last_execution": "2021-06-15T10:46"
+ }
+ ]
+}
+```
+
+__To get global status and only non normal validations.__
+
+`GET /lifeguard/status`
+
+```json
+{
+
+ "status": "PROBLEM",
+ "validations": [
+ {
+ "validation_name": "my site",
+ "status": "PROBLEM",
+ "details": {
+ "NORMAL": 200
+ },
+ "settings": {
+ "notification": {
+ "notify": true
+ }
+ },
+ "last_execution": "2021-06-15T10:46"
+ }
+ ]
+}
+```
+
+## Authentication
+
+### Builtin Methods
+
+#### Basic Authentication
+
+Set users in lifeguard context like in the example:
+
+```python
+# in lifeguard_settings.py
+from lifeguard.auth import BASIC_AUTH_METHOD
+
+def setup(lifeguard_context):
+ lifeguard_context.auth_method = BASIC_AUTH_METHOD
+ lifeguard_context.users = [{"username": "test", "password": "pass"}]
+```
+
+
+%package help
+Summary: Development documents and examples for lifeguard
+Provides: python3-lifeguard-doc
+%description help
+# Lifeguard
+
+![Build Status](https://github.com/LifeguardSystem/lifeguard/workflows/Lifeguard%20Core%20CI/badge.svg)
+![Lifeguard Core Publish](https://github.com/LifeguardSystem/lifeguard/workflows/Lifeguard%20Core%20Publish/badge.svg)
+[![PyPI version](https://badge.fury.io/py/lifeguard.svg)](https://badge.fury.io/py/lifeguard)
+
+## Examples of Usage
+
+See a complete example at: https://github.com/LifeguardSystem/lifeguard-example
+
+### Settings File
+
+In the root of project should be exists a file called `lifeguard_settings.py` like the example:
+
+```python
+"""
+Lifeguard Settings
+"""
+import lifeguard_mongodb
+# other dependecies
+
+# Plugins modules
+PLUGINS = [
+ lifeguard_mongodb,
+ # other plugins
+]
+
+# You can execute code in the lifeguard startup process
+def setup(_lifeguard_context):
+ pass
+```
+
+### Create a validation
+
+To create a validation you should create a file into `validations` directory. The file should ends with `_validation.py`.
+Example:
+
+```python
+import requests
+from lifeguard import NORMAL, PROBLEM, change_status
+from lifeguard.actions.database import save_result_into_database
+from lifeguard.actions.notifications import notify_in_single_message
+from lifeguard.logger import lifeguard_logger as logger
+from lifeguard.validations import ValidationResponse, validation
+
+
+@validation(
+ "check if pudim is alive",
+ actions=[save_result_into_database, notify_in_single_message],
+ schedule={"every": {"minutes": 1}},
+)
+def pudim_is_alive():
+ status = NORMAL
+ result = requests.get("http://pudim.com.br")
+ logger.info("pudim status code: %s", result.status_code)
+
+ if result.status_code != 200:
+ status = change_status(status, PROBLEM)
+
+ return ValidationResponse(
+ "pudim_is_alive",
+ NORMAL,
+ {status: result.status_code},
+ {"notification": {"notify": True}},
+ )
+```
+
+### Validation Actions
+
+Action is a simple python function with only 2 arguments: a validation response and a dict called settings. These settings are the parameter called settings in validation.
+
+```python
+def custom_action(validation_response, settings):
+ pass
+```
+
+Builtin validations can be found in [Wiki](https://github.com/LifeguardSystem/lifeguard/wiki).
+
+### Create a custom controller
+
+To create a custom controller with decorators see the example
+
+```python
+import json
+
+from lifeguard.controllers import controller
+
+
+@controller("/hello/<name>")
+def hello(name):
+ return json.dumps({"name": name})
+```
+
+This file should be in the `controllers` directory and should ends with `_controller.py`.
+
+### Init Lifeguard
+
+Execute: `lifeguard`
+
+To init only web server: `lifeguard --no-scheduler`
+
+To init only scheduler: `lifeguard --no-server`
+
+### Settings
+
+To see all settings avaiable run command:
+
+`lifeguard -d`
+
+## Builtin Endpoints
+
+### Recover Status
+
+__To get global status and all validations.__
+
+`GET /lifeguard/status/complete`
+
+```json
+{
+
+ "status": "NORMAL",
+ "validations": [
+ {
+ "validation_name": "pudim",
+ "status": "NORMAL",
+ "details": {
+ "NORMAL": 200
+ },
+ "settings": {
+ "notification": {
+ "notify": true
+ }
+ },
+ "last_execution": "2021-06-15T10:46"
+ },
+ {
+ "validation_name": "my site",
+ "status": "NORMAL",
+ "details": {
+ "NORMAL": 200
+ },
+ "settings": {
+ "notification": {
+ "notify": true
+ }
+ },
+ "last_execution": "2021-06-15T10:46"
+ }
+ ]
+}
+```
+
+__To get global status and only non normal validations.__
+
+`GET /lifeguard/status`
+
+```json
+{
+
+ "status": "PROBLEM",
+ "validations": [
+ {
+ "validation_name": "my site",
+ "status": "PROBLEM",
+ "details": {
+ "NORMAL": 200
+ },
+ "settings": {
+ "notification": {
+ "notify": true
+ }
+ },
+ "last_execution": "2021-06-15T10:46"
+ }
+ ]
+}
+```
+
+## Authentication
+
+### Builtin Methods
+
+#### Basic Authentication
+
+Set users in lifeguard context like in the example:
+
+```python
+# in lifeguard_settings.py
+from lifeguard.auth import BASIC_AUTH_METHOD
+
+def setup(lifeguard_context):
+ lifeguard_context.auth_method = BASIC_AUTH_METHOD
+ lifeguard_context.users = [{"username": "test", "password": "pass"}]
+```
+
+
+%prep
+%autosetup -n lifeguard-1.1.0
+
+%build
+%py3_build
+
+%install
+%py3_install
+install -d -m755 %{buildroot}/%{_pkgdocdir}
+if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
+if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
+if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
+if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
+pushd %{buildroot}
+if [ -d usr/lib ]; then
+ find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/lib64 ]; then
+ find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/bin ]; then
+ find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/sbin ]; then
+ find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+touch doclist.lst
+if [ -d usr/share/man ]; then
+ find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
+fi
+popd
+mv %{buildroot}/filelist.lst .
+mv %{buildroot}/doclist.lst .
+
+%files -n python3-lifeguard -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Mon May 29 2023 Python_Bot <Python_Bot@openeuler.org> - 1.1.0-1
+- Package Spec generated
diff --git a/sources b/sources
new file mode 100644
index 0000000..acb6aca
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+ec953646e6bd7d9c0fd6001c2eec4f99 lifeguard-1.1.0.tar.gz