python-linstor 1.21.0__tar.gz → 1.28.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. {python-linstor-1.21.0 → python_linstor-1.28.2}/MANIFEST.in +0 -1
  2. {python-linstor-1.21.0 → python_linstor-1.28.2}/Makefile +5 -33
  3. {python-linstor-1.21.0/python_linstor.egg-info → python_linstor-1.28.2}/PKG-INFO +33 -13
  4. {python-linstor-1.21.0 → python_linstor-1.28.2}/README.md +17 -0
  5. python_linstor-1.28.2/linstor/config.py +92 -0
  6. {python-linstor-1.21.0 → python_linstor-1.28.2}/linstor/linstorapi.py +894 -652
  7. {python-linstor-1.21.0 → python_linstor-1.28.2}/linstor/properties.py +1405 -701
  8. {python-linstor-1.21.0 → python_linstor-1.28.2}/linstor/resource.py +29 -2
  9. {python-linstor-1.21.0 → python_linstor-1.28.2}/linstor/resourcegroup.py +18 -0
  10. {python-linstor-1.21.0 → python_linstor-1.28.2}/linstor/responses.py +246 -252
  11. {python-linstor-1.21.0 → python_linstor-1.28.2}/linstor/sharedconsts.py +127 -54
  12. python_linstor-1.28.2/linstor/version.py +1 -0
  13. {python-linstor-1.21.0 → python_linstor-1.28.2}/linstor-common/consts.json +461 -218
  14. {python-linstor-1.21.0 → python_linstor-1.28.2}/linstor-common/drbdoptions.json +394 -301
  15. {python-linstor-1.21.0 → python_linstor-1.28.2}/linstor-common/drbdsetup.xml +166 -127
  16. {python-linstor-1.21.0 → python_linstor-1.28.2}/linstor-common/gendrbdoptions.py +31 -13
  17. {python-linstor-1.21.0 → python_linstor-1.28.2}/linstor-common/genproperties.py +22 -1
  18. {python-linstor-1.21.0 → python_linstor-1.28.2}/linstor-common/properties.json +479 -216
  19. python_linstor-1.28.2/linstor_tests/test_linstorapi.py +36 -0
  20. python_linstor-1.28.2/linstor_tests/test_responses.py +86 -0
  21. python_linstor-1.28.2/pyproject.toml +38 -0
  22. {python-linstor-1.21.0 → python_linstor-1.28.2/python_linstor.egg-info}/PKG-INFO +33 -13
  23. {python-linstor-1.21.0 → python_linstor-1.28.2}/python_linstor.egg-info/SOURCES.txt +2 -2
  24. {python-linstor-1.21.0 → python_linstor-1.28.2}/setup.cfg +1 -1
  25. python_linstor-1.28.2/setup.py +71 -0
  26. python-linstor-1.21.0/linstor/config.py +0 -55
  27. python-linstor-1.21.0/linstor/version.py +0 -1
  28. python-linstor-1.21.0/linstor_tests/test_responses.py +0 -30
  29. python-linstor-1.21.0/python_linstor.egg-info/requires.txt +0 -3
  30. python-linstor-1.21.0/setup.cfg.py2 +0 -10
  31. python-linstor-1.21.0/setup.py +0 -131
  32. {python-linstor-1.21.0 → python_linstor-1.28.2}/COPYING +0 -0
  33. {python-linstor-1.21.0 → python_linstor-1.28.2}/linstor/__init__.py +0 -0
  34. {python-linstor-1.21.0 → python_linstor-1.28.2}/linstor/errors.py +0 -0
  35. {python-linstor-1.21.0 → python_linstor-1.28.2}/linstor/kv.py +0 -0
  36. {python-linstor-1.21.0 → python_linstor-1.28.2}/linstor/size_calc.py +0 -0
  37. {python-linstor-1.21.0 → python_linstor-1.28.2}/linstor-common/Makefile +0 -0
  38. {python-linstor-1.21.0 → python_linstor-1.28.2}/linstor-common/genconsts.py +0 -0
  39. {python-linstor-1.21.0 → python_linstor-1.28.2}/linstor_tests/__init__.py +0 -0
  40. {python-linstor-1.21.0 → python_linstor-1.28.2}/linstor_tests/test_utils.py +0 -0
  41. {python-linstor-1.21.0 → python_linstor-1.28.2}/python_linstor.egg-info/dependency_links.txt +0 -0
  42. {python-linstor-1.21.0 → python_linstor-1.28.2}/python_linstor.egg-info/top_level.txt +0 -0
@@ -7,4 +7,3 @@ include MANIFEST.in
7
7
  include COPYING
8
8
  include README.md
9
9
  include Makefile
10
- include setup.cfg.py2
@@ -1,34 +1,23 @@
1
- GIT = git
2
1
  INSTALLFILES=.installfiles
3
2
  PYTHON ?= python3
4
- override GITHEAD := $(shell test -e .git && $(GIT) rev-parse HEAD)
5
3
 
6
- U := $(shell $(PYTHON) ./setup.py versionup2date >/dev/null 2>&1; echo $$?;)
7
4
  TESTS = $(wildcard unit-tests/*_test.py)
8
5
 
9
6
  all:
10
7
  $(PYTHON) setup.py build
11
8
 
12
- install: gensrc linstor/consts_githash.py
9
+ install: gensrc
13
10
  $(PYTHON) setup.py install --record $(INSTALLFILES)
14
11
 
15
12
  uninstall:
16
13
  test -f $(INSTALLFILES) && cat $(INSTALLFILES) | xargs rm -rf || true
17
14
  rm -f $(INSTALLFILES)
18
15
 
19
- ifneq ($(U),0)
20
- up2date:
21
- $(error "Update your Version strings/Changelogs")
22
- else
23
- up2date: linstor/consts_githash.py
24
- $(info "Version strings/Changelogs up to date")
25
- endif
26
-
27
16
  .PHONY: linstor/drbdsetup_options.py
28
17
  linstor/drbdsetup_options.py:
29
18
  linstor-common/gendrbdoptions.py python $@
30
19
 
31
- release: up2date clean
20
+ release: clean
32
21
  $(PYTHON) setup.py sdist
33
22
  @echo && echo "Did you run distclean?"
34
23
  @echo && echo "Did you generate and commit the latest drbdsetup options?"
@@ -45,29 +34,16 @@ gensrc:
45
34
  make -C linstor-common python
46
35
 
47
36
  # no gensrc here, that is in debian/rules
48
- deb: up2date
37
+ deb:
49
38
  [ -d ./debian ] || (echo "Your checkout/tarball does not contain a debian directory" && false)
50
39
  debuild -i -us -uc -b
51
40
 
52
41
  # it is up to you (or the buildenv) to provide a distri specific setup.cfg
53
- rpm: gensrc up2date
42
+ rpm: gensrc
54
43
  $(PYTHON) setup.py bdist_rpm
55
44
 
56
- .PHONY: linstor/consts_githash.py
57
- ifdef GITHEAD
58
- override GITDIFF := $(shell $(GIT) diff --name-only HEAD 2>/dev/null | \
59
- grep -vxF "MANIFEST.in" | \
60
- tr -s '\t\n' ' ' | \
61
- sed -e 's/^/ /;s/ *$$//')
62
- linstor/consts_githash.py:
63
- @echo "GITHASH = 'GIT-hash: $(GITHEAD)$(GITDIFF)'" > $@
64
- else
65
- linstor/consts_githash.py:
66
- @echo >&2 "Need a git checkout to regenerate $@"; test -s $@
67
- endif
68
-
69
45
  md5sums:
70
- CURDATE=$$(date +%s); for i in $$(${GIT} ls-files | sort); do md5sum $$i >> md5sums.$${CURDATE}; done
46
+ CURDATE=$$(date +%s); for i in $$(git ls-files | sort); do md5sum $$i >> md5sums.$${CURDATE}; done
71
47
 
72
48
  clean:
73
49
  $(PYTHON) setup.py clean
@@ -75,10 +51,6 @@ clean:
75
51
  distclean: clean
76
52
  git clean -d -f || true
77
53
 
78
- check:
79
- # currently none
80
- # $(PYTHON) $(TESTS)
81
-
82
54
  .PHONY: doc upload-doc
83
55
  doc: gensrc
84
56
  make -C doc html
@@ -1,27 +1,30 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: python-linstor
3
- Version: 1.21.0
3
+ Version: 1.28.2
4
4
  Summary: Linstor python api
5
5
  Home-page: https://www.linbit.com
6
- Author: Robert Altnoeder <robert.altnoeder@linbit.com>, Roland Kammerer <roland.kammerer@linbit.com>, Rene Peinthor <rene.peinthor@linbit.com>, Moritz Wanzenboeck <moritz.wanzenboeck@linbit.com>
7
- Author-email: rene.peinthor@linbit.com
8
- Maintainer: LINBIT HA-Solutions GmbH
9
- Maintainer-email: drbd-user@lists.linbit.com
10
- License: LGPLv3
11
- Project-URL: Source Code, https://github.com/LINBIT/linstor-api-py
12
- Project-URL: Documentation, https://linbit.github.io/linstor-api-py
6
+ Author-email: Rene Peinthor <rene.peinthor@linbit.com>, Roland Kammerer <roland.kammerer@linbit.com>, Gabor Hernadi <gabor.hernadi@linbit.com>, Moritz Wanzenboeck <moritz.wanzenboeck@linbit.com>
7
+ Maintainer-email: Rene Peinthor <rene.peinthor@linbit.com>
8
+ License: LGPL-3.0-or-later
9
+ Project-URL: Homepage, https://github.com/LINBIT/linstor-api-py
10
+ Project-URL: Documentation, https://linbit.github.io/linstor-api-py/
11
+ Project-URL: Repository, https://github.com/LINBIT/linstor-api-py.git
12
+ Project-URL: Issues, https://github.com/LINBIT/linstor-api-py/issues
13
+ Project-URL: Changelog, https://github.com/LINBIT/linstor-api-py/blob/master/CHANGELOG.md
13
14
  Classifier: Development Status :: 5 - Production/Stable
14
15
  Classifier: Intended Audience :: Developers
15
- Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
16
- Classifier: Programming Language :: Python :: 2.7
17
- Classifier: Programming Language :: Python :: 3.5
18
16
  Classifier: Programming Language :: Python :: 3.6
19
17
  Classifier: Programming Language :: Python :: 3.7
20
18
  Classifier: Programming Language :: Python :: 3.8
21
19
  Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Requires-Python: >=3.6
22
24
  Description-Content-Type: text/markdown
23
25
  License-File: COPYING
24
- Requires-Dist: enum34; python_version < "3"
26
+ Dynamic: home-page
27
+ Dynamic: license-file
25
28
 
26
29
  # LINSTOR Python API
27
30
 
@@ -32,6 +35,23 @@ LVM/ZFS volumes across a group of machines. It maintains DRBD configuration on t
32
35
  creates/deletes the backing LVM/ZFS volumes. It automatically places the backing LVM/ZFS volumes among the
33
36
  participating machines.
34
37
 
38
+ # Building
39
+
40
+ To build the package, install the `build` module and run it from the project root:
41
+
42
+ ```bash
43
+ pip install build
44
+ python -m build
45
+ ```
46
+
47
+ This will create both source distribution (`.tar.gz`) and wheel (`.whl`) files in the `dist/` directory.
48
+
49
+ To install the package locally for development:
50
+
51
+ ```bash
52
+ pip install -e .
53
+ ```
54
+
35
55
  # Online API documentation
36
56
  A rendered html documentation for the LINSTOR Python API can be found [here](https://linbit.github.io/linstor-api-py/).
37
57
 
@@ -7,6 +7,23 @@ LVM/ZFS volumes across a group of machines. It maintains DRBD configuration on t
7
7
  creates/deletes the backing LVM/ZFS volumes. It automatically places the backing LVM/ZFS volumes among the
8
8
  participating machines.
9
9
 
10
+ # Building
11
+
12
+ To build the package, install the `build` module and run it from the project root:
13
+
14
+ ```bash
15
+ pip install build
16
+ python -m build
17
+ ```
18
+
19
+ This will create both source distribution (`.tar.gz`) and wheel (`.whl`) files in the `dist/` directory.
20
+
21
+ To install the package locally for development:
22
+
23
+ ```bash
24
+ pip install -e .
25
+ ```
26
+
10
27
  # Online API documentation
11
28
  A rendered html documentation for the LINSTOR Python API can be found [here](https://linbit.github.io/linstor-api-py/).
12
29
 
@@ -0,0 +1,92 @@
1
+ import os
2
+ from enum import Enum
3
+ from configparser import ConfigParser
4
+
5
+ from linstor.linstorapi import MultiLinstor
6
+
7
+
8
+ class ConfigFileLevel(Enum):
9
+ USER = 1
10
+ SYS = 2
11
+
12
+ def to_config_path(self):
13
+ config_file = "linstor-client.conf"
14
+ if self.value == 1:
15
+ home_dir = os.path.expanduser("~")
16
+ return os.path.join(home_dir, ".config", "linstor", config_file)
17
+ elif self.value == 2:
18
+ return os.path.join('/etc', 'linstor', config_file)
19
+ else:
20
+ return None
21
+
22
+
23
+ class Config(object):
24
+ CONFIG = None # cache object
25
+
26
+ @staticmethod
27
+ def read_config(config_file):
28
+ cp = ConfigParser()
29
+ cp.read(config_file)
30
+ config = {}
31
+ for section in cp.sections():
32
+ config[section] = cp.items(section)
33
+ return config
34
+
35
+ @staticmethod
36
+ def get_section(section, config_file_name=None):
37
+ if Config.CONFIG is None:
38
+ home_dir = os.path.expanduser("~")
39
+ config_file = "linstor-client.conf"
40
+ user_conf = os.path.join(home_dir, ".config", "linstor", config_file)
41
+ sys_conf = os.path.join('/etc', 'linstor', config_file)
42
+ sys_d_conf_dir = os.path.join('/etc', 'linstor', 'linstor-client.d')
43
+
44
+ config = {}
45
+ if os.path.exists(sys_d_conf_dir):
46
+ conf_files = [x for x in os.listdir(sys_d_conf_dir) if x.endswith('.conf')]
47
+ conf_files.sort()
48
+ for file in conf_files:
49
+ config.update(Config.read_config(os.path.join(sys_d_conf_dir, file)))
50
+
51
+ if config_file_name and os.path.exists(config_file_name):
52
+ config.update(Config.read_config(config_file_name))
53
+ elif os.path.exists(user_conf):
54
+ config.update(Config.read_config(user_conf))
55
+ elif os.path.exists(sys_conf):
56
+ config.update(Config.read_config(sys_conf))
57
+ Config.CONFIG = config
58
+
59
+ entries = Config.CONFIG.get(section, []) if Config.CONFIG else []
60
+ return {k: v for k, v in entries}
61
+
62
+ @staticmethod
63
+ def set_value(section: str, key: str, value: str, level: ConfigFileLevel = ConfigFileLevel.USER):
64
+ config_path = level.to_config_path()
65
+ cp = ConfigParser()
66
+ cp.read(config_path)
67
+ if section not in cp.sections():
68
+ cp.add_section(section)
69
+ cp.set(section, key, value)
70
+ config_dir = os.path.dirname(config_path)
71
+ if config_dir:
72
+ os.makedirs(config_dir, exist_ok=True)
73
+ with open(config_path, 'w') as f:
74
+ cp.write(f)
75
+
76
+ @staticmethod
77
+ def get_controllers(section='global', config_file_name=None, fallback='linstor://localhost'):
78
+ """
79
+ :param str section: Section to parse, defaults to 'global'
80
+ :param str config_file_name: Config file to parse, if not set, the default files in /etc and $HOME are
81
+ parsed
82
+ :param str fallback: Fallback controller if none was found in the environment or the config. Defaults
83
+ to 'linstor://localhost'.
84
+ :return: List of linstor uris. This list is intended to be used via the MultiLinstor class.
85
+ :rtype: list[str]
86
+ """
87
+ controllers = os.environ.get('LS_CONTROLLERS', None)
88
+ if not controllers:
89
+ cfg = Config.get_section(section, config_file_name)
90
+ controllers = cfg.get('controllers', fallback)
91
+
92
+ return MultiLinstor.controller_uri_list(controllers)