Нема описа

ChenHaolong f62faa8ebd 创建LDS任务添加返回错误信息,根据是否包含uuid判断创建是否成功 пре 3 месеци
proto @ 15ffd7fb7a 79168dd0fc bugfix:修复ListSSLCert方法解析证书列表出错的问题 пре 1 година
src f62faa8ebd 创建LDS任务添加返回错误信息,根据是否包含uuid判断创建是否成功 пре 3 месеци
.gitignore c05a222d43 更新README пре 1 година
.gitlab-ci.yml 85092b446e change illegal path пре 2 година
.gitmodules b2d584b450 更新模块依赖关系 пре 1 година
LICENSE 0b3614e0e1 Readme/Licence updates пре 4 година
README.md c05a222d43 更新README пре 1 година
pyproject.toml 8341cf42fd changed name from dash to underscore пре 2 година
测试.ipynb 8eb8503d3a feature:新增llnw的证书列表获取接口 пре 1 година

README.md

llnw 环境部署

相关资料

网站 https://control.llnw.com/acontrol/#/login

API explorer: https://support.limelight.com/public/explorer/llnw-api-explorer.html

文档 https://support.limelight.com/public/openapi/configuration/index.html

SDK https://github.com/llnw/llnw-sdk-python

Python打包工具Nuitka https://github.com/Nuitka/Nuitka

GRPC https://grpc.io/docs/languages/python/basics/

信息

GRPC 端口:50052

代码生成

python3 gencode.py

启动

python3 src/main.py

编译流程

Miniconda 安装

#下载
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
#安装
./Miniconda3-latest-Linux-x86_64.sh
#关闭自启动conda
conda config --set auto_activate_base false
#miniconda源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/

设置环境

conda create -n llnw python=3.10 libpython-static grpcio grpcio-tools pydash requests nuitka
conda activate llnw

编译

python3 -m nuitka --onefile src/main.py

Public Limelight python SDK for Limelight Networks services

Download and deployment

git clone <git_hub_url>
cd llnw-sdk-python
pip install -e .

Example of usage config-api

import client:

from sdk.config_api import ConfigApiClient

Initialize client:

username = "{llnw_user}"
shared_key = "{llnw_shared_key}"

cl = ConfigApiClient('apis.llnw.com', username, shared_key)

Verify that it works

print(cl.get_status().json()) Should be returned something like this: {'version': '5.9-RC2', 'timestamp': '2020-04-03T15:39:03+0300', 'branch': 'ea4b4ca4c77cf8185d8b55381936a451bad87622', 'commitId': 'ea4b4ca4c77cf8185d8b55381936a451bad87622', 'mysqlConnection': {'connectionTime': '3'}, 'cfgMgmtConnection': {'available': 'true'}, 'remoteComponentsConnection': {'available': 'true'}, 'serviceDbConnection': {'available': 'true'}}

How to create Delivery config

Generate delivery payload:
 ```
from sdk.utils.config_api_helper.deilver import DeliverServiceInstanceObj
a = DeliverServiceInstanceObj()
a.generate_default('{llnw_shortname}', 'example.pub.llnw.com', 'w.example.orig.llnw.com', 'LLNW-Generic', 'https', 'https')

{'accounts': [{'shortname': '{llnw_shortname}'}],
      'body': {'protocolSets': [{'options': [],
                        'publishedProtocol': 'http',
                        'sourceProtocol': 'http'}],
      'publishedHostname': 'example.pub.llnw.com',
      'publishedUrlPath': '',
      'serviceKey': {'name': 'delivery'},
      'serviceProfileName': 'LLNW-Generic',
      'sourceHostname': 'w.example.orig.llnw.com',
      'sourceUrlPath': ''}}
```

Using this payload you can create or validate delivery service instance:

```
cl.validate_delivery_service_instance(a)
```

Validate call always return 200, but in body it has key 'Success' it can be True if everything is fine or False if an error occurs

```
cl.create_delivery_service_instance(a)
```

Return 200 if config was successfully created or error code(400, 403, etc) for errors

Example of usage realtime-reporting-api

import client:

from sdk.realtime-reporting-api import RealtimeReportingClient

username = "{llnw_user}"
shared_key = "{llnw_shared_key}"

Initialize client:

cl = RealtimeReportingClient('apis.llnw.com', username, shared_key)

Verify that it works

print(cl.health_check().json()) ['OK']

Get traffic data via realtime-reporting-api

response = cl.traffic(shortname="{llnw_shortname}",
                      service=[cl.SERVICE_HTTP, cl.SERVICE_HLS],
                      requestedFields=cl.TRAFFIC_REQUESTED_FIELDS,
                      timespan=cl.LAST_24_HOURS,
                      granularity=cl.GRANULARITY_FIVE_MINUTES)

or via general request and key: value argument (similar in limelight javaScript sdk)

response2 = cl2.request(**{"report": 'traffic', 
                           "shortname": "{llnw_shortname}",
                           "service": [cl2.SERVICE_HTTP, cl2.SERVICE_HLS],
                           "requestedFields": cl2.REQUESTED_FIELDS_INBYTES,
                           "timespan": cl2.LAST_24_HOURS,
                           "granularity": cl2.GRANULARITY_FIVE_MINUTES})

Congratulate you've done well

Running the tests

Run tests

pytest -v --pyargs sdk.test