Skip to content

Commit c135165

Browse files
committed
init
0 parents  commit c135165

File tree

11 files changed

+382
-0
lines changed

11 files changed

+382
-0
lines changed

.github/workflows/pre-commit.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: pre-commit
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
pytest:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: actions/setup-python@v2
14+
- uses: actions/cache@v2
15+
with:
16+
path: ~/.cache/pip
17+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
18+
restore-keys: |
19+
${{ runner.os }}-pip-
20+
- name: Install dependencies
21+
run: |
22+
python -m pip install -r requirements.txt pytest
23+
python -m pip install -e .
24+
- name: Test with pytest
25+
run: |
26+
pytest
27+
pre-commit:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v2
31+
- uses: actions/setup-python@v2
32+
- uses: pre-commit/[email protected]

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
*.py[cod]
2+
.envrc
3+
__pycache__/
4+
.direnv/
5+
.tox/
6+
.vscode/
7+
*.egg-info/

.pre-commit-config.yaml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v3.4.0
4+
hooks:
5+
- id: no-commit-to-branch
6+
args: [--branch, main]
7+
- id: check-added-large-files
8+
- id: check-ast
9+
- id: check-builtin-literals
10+
- id: check-byte-order-marker
11+
- id: check-case-conflict
12+
- id: check-docstring-first
13+
- id: check-executables-have-shebangs
14+
- id: check-json
15+
- id: check-merge-conflict
16+
- id: check-symlinks
17+
- id: check-vcs-permalinks
18+
- id: check-xml
19+
- id: check-yaml
20+
- id: debug-statements
21+
- id: detect-private-key
22+
- id: end-of-file-fixer
23+
- id: fix-byte-order-marker
24+
- id: forbid-new-submodules
25+
- id: mixed-line-ending
26+
- id: trailing-whitespace
27+
args: ['--markdown-linebreak-ext=md']
28+
- repo: https://github.com/asottile/add-trailing-comma
29+
rev: v2.1.0
30+
hooks:
31+
- id: add-trailing-comma
32+
- repo: git://github.com/Lucas-C/pre-commit-hooks
33+
rev: v1.1.9
34+
hooks:
35+
- id: forbid-crlf
36+
- id: forbid-tabs
37+
- repo: https://github.com/asottile/pyupgrade
38+
rev: v2.11.0
39+
hooks:
40+
- id: pyupgrade
41+
args: ['--py3-plus']
42+
- repo: https://github.com/PyCQA/isort
43+
rev: 5.8.0
44+
hooks:
45+
- id: isort
46+
- repo: https://github.com/python/black
47+
rev: 20.8b1
48+
hooks:
49+
- id: black
50+
args: ['--target-version', 'py37', '--line-length', '128']
51+
- repo: https://gitlab.com/pycqa/flake8
52+
rev: 3.9.0
53+
hooks:
54+
- id: flake8
55+
additional_dependencies: [flake8-eradicate]
56+
args: ["--max-line-length", "130"]
57+
- repo: https://github.com/pre-commit/mirrors-mypy
58+
rev: v0.812
59+
hooks:
60+
- id: mypy
61+
additional_dependencies: [tokenize-rt==4.1.0]
62+
types: [python]
63+
args: ['--follow-imports=skip', '--ignore-missing-imports']
64+
- repo: https://github.com/pre-commit/pygrep-hooks
65+
rev: v1.8.0
66+
hooks:
67+
- id: python-check-blanket-noqa
68+
- id: python-check-mock-methods
69+
- id: python-no-eval
70+
- id: python-no-log-warn
71+
- id: python-use-type-annotations
72+
- repo: https://github.com/asottile/add-trailing-comma
73+
rev: v2.1.0
74+
hooks:
75+
- id: add-trailing-comma
76+
- repo: https://github.com/Lucas-C/pre-commit-hooks-safety
77+
rev: v1.2.1
78+
hooks:
79+
- id: python-safety-dependencies-check
80+
stages: [manual]
81+
- repo: https://github.com/Lucas-C/pre-commit-hooks-bandit
82+
rev: v1.0.4
83+
hooks:
84+
- id: python-bandit-vulnerability-check
85+
stages: [manual]
86+
- repo: https://github.com/Lucas-C/pre-commit-hooks
87+
rev: v1.1.9
88+
hooks:
89+
- id: forbid-crlf
90+
- id: remove-crlf
91+
- id: forbid-tabs
92+
- id: remove-tabs
93+
- repo: https://github.com/PyCQA/isort
94+
rev: 5.8.0
95+
hooks:
96+
- id: isort
97+
types: [python]
98+
args: ["--profile", "black", "--filter-files", "-l 128"]
99+
- repo: https://github.com/python/black
100+
rev: 20.8b1
101+
hooks:
102+
- id: black
103+
args: ['--target-version', 'py35', '--line-length', '128']

LICENSE

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
This is free and unencumbered software released into the public domain.
2+
3+
Anyone is free to copy, modify, publish, use, compile, sell, or
4+
distribute this software, either in source code form or as a compiled
5+
binary, for any purpose, commercial or non-commercial, and by any
6+
means.
7+
8+
In jurisdictions that recognize copyright laws, the author or authors
9+
of this software dedicate any and all copyright interest in the
10+
software to the public domain. We make this dedication for the benefit
11+
of the public at large and to the detriment of our heirs and
12+
successors. We intend this dedication to be an overt act of
13+
relinquishment in perpetuity of all present and future rights to this
14+
software under copyright law.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
OTHER DEALINGS IN THE SOFTWARE.
23+
24+
For more information, please refer to <https://unlicense.org>

README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
libcloud драйвер для сервиса vdsina.ru
2+
3+
4+
https://vdsina.ru/tech/api#art-04-05
5+
6+
## Поддерживаемые методы Compute
7+
| Метод | Поддержка |
8+
| --- | --- |
9+
|attach_volume||
10+
|copy_image||
11+
|create_image||
12+
|create_key_pair|-|
13+
|create_node|-|
14+
|create_volume||
15+
|create_volume_snapshot||
16+
|delete_image||
17+
|delete_key_pair|-|
18+
|deploy_node||
19+
|destroy_node|-|
20+
|destroy_volume||
21+
|destroy_volume_snapshot||
22+
|detach_volume||
23+
|features||
24+
|get_image||
25+
|get_key_pair|-|
26+
|import_key_pair_from_file|-|
27+
|import_key_pair_from_string|-|
28+
|list_images|-|
29+
|list_key_pairs|-|
30+
|list_locations|-|
31+
|list_nodes|-|
32+
|list_sizes|-|
33+
|list_volume_snapshots||
34+
|list_volumes||
35+
|reboot_node|-|
36+
|start_node||
37+
|stop_node||
38+
|wait_until_running||
39+
40+
41+
42+
43+
## Методы DNS
44+
| Метод | Поддержка |
45+
| --- | --- |
46+
|list zones||
47+
|list records||
48+
|create zone||
49+
|update zone||
50+
|create record||
51+
|update record||
52+
|delete zone||
53+
|delete record||
54+
55+
56+
## Разработка
57+
58+
В проекте настроена автоматическая проверка линтерами и тестами.
59+
60+
Линтеры запускаются в `pre-commit`, тесты в `pytest`.

requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apache-libcloud
2+
cryptography
3+
pytest
4+
vcrpy

setup.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import setuptools
2+
3+
with open("README.md") as fh:
4+
long_description = fh.read()
5+
6+
setuptools.setup(
7+
name="vdsinadriver",
8+
version="0.0.1",
9+
author="Sergey Mezentsev",
10+
author_email="[email protected]",
11+
description="Libcloud driver for vdsina",
12+
license="UNLICENSE",
13+
long_description=long_description,
14+
long_description_content_type="text/markdown",
15+
url="https://github.com/thebits/libcloud-vdsina",
16+
packages=setuptools.find_packages(),
17+
classifiers=[
18+
"Intended Audience :: System Administrators",
19+
"Operating System :: OS Independent",
20+
"Programming Language :: Python :: 3",
21+
"Topic :: Software Development :: Libraries :: Python Modules",
22+
],
23+
)

tests/fixtures/list_key_pairs.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
Accept:
6+
- '*/*'
7+
Accept-Encoding:
8+
- gzip,deflate
9+
Connection:
10+
- keep-alive
11+
Host:
12+
- userapi.vdsina.ru
13+
User-Agent:
14+
- 'libcloud/3.3.1 (Vdsina) '
15+
method: GET
16+
uri: https://userapi.vdsina.ru/v1/ssh-key
17+
response:
18+
body:
19+
string: '{"status":"ok","status_msg":"SSH keys list","data":[{"id":5496,"name":"barracude"}]}'
20+
headers:
21+
Access-Control-Allow-Headers:
22+
- Authorization,Keep-Alive,Content-Type,Origin
23+
Access-Control-Allow-Methods:
24+
- GET, POST, OPTIONS, DELETE, PUT
25+
Access-Control-Max-Age:
26+
- '1728000'
27+
Connection:
28+
- keep-alive
29+
Content-Encoding:
30+
- gzip
31+
Content-Type:
32+
- application/json
33+
Date:
34+
- Sat, 27 Mar 2021 14:27:25 GMT
35+
Server:
36+
- nginx
37+
Transfer-Encoding:
38+
- chunked
39+
Vary:
40+
- Accept-Encoding
41+
status:
42+
code: 200
43+
message: OK
44+
version: 1

tests/test_vdsina.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import os
2+
3+
import vcr
4+
5+
from vdsinadriver import VdsinaDriver
6+
7+
8+
@vcr.use_cassette("./tests/fixtures/list_key_pairs.yaml", filter_headers=["Authorization"])
9+
def test_list_key_pairs():
10+
conn = VdsinaDriver(key=os.getenv("VDSINA_TOKEN"))
11+
keys = conn.list_key_pairs()
12+
key = keys.pop()
13+
assert key.name == "x200s"
14+
assert key.fingerprint == "ca:28:dc:6e:9e:72:48:d3:bc:73:76:19:d2:5f:c3:e8"
15+
assert isinstance(key.driver, VdsinaDriver)
16+
assert key.extra["id"] == 46329

tox.ini

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[testenv]
2+
passenv =
3+
VDSINA_TOKEN
4+
deps =
5+
pytest
6+
vcrpy
7+
apache-libcloud>=3.0.0
8+
commands =
9+
pytest

0 commit comments

Comments
 (0)