[lxc-devel] [lxd/master] Instance: Fixes instanceType in instance logger
The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/8213 This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === Fixes issue introduced by github.com/lxc/lxd/pull/8199 Signed-off-by: Thomas Parrott From b34e3792dea0f790695a42448d464bd8eb1304b4 Mon Sep 17 00:00:00 2001 From: Thomas Parrott Date: Fri, 4 Dec 2020 09:07:01 + Subject: [PATCH] lxd/instance/drivers: Fixes instanceType in instance logger Signed-off-by: Thomas Parrott --- lxd/instance/drivers/driver_lxc.go | 4 ++-- lxd/instance/drivers/driver_qemu.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lxd/instance/drivers/driver_lxc.go b/lxd/instance/drivers/driver_lxc.go index 7ce44fec2b..9b1f3dd757 100644 --- a/lxd/instance/drivers/driver_lxc.go +++ b/lxd/instance/drivers/driver_lxc.go @@ -155,7 +155,7 @@ func lxcCreate(s *state.State, args db.InstanceArgs) (instance.Instance, error) lastUsedDate: args.LastUsedDate, localConfig: args.Config, localDevices: args.Devices, - logger: logging.AddContext(logger.Log, log.Ctx{"instanceType": args.Type.String, "instance": args.Name, "project": args.Project}), + logger: logging.AddContext(logger.Log, log.Ctx{"instanceType": args.Type, "instance": args.Name, "project": args.Project}), name: args.Name, node: args.Node, profiles: args.Profiles, @@ -375,7 +375,7 @@ func lxcInstantiate(s *state.State, args db.InstanceArgs, expandedDevices device lastUsedDate: args.LastUsedDate, localConfig: args.Config, localDevices: args.Devices, - logger: logging.AddContext(logger.Log, log.Ctx{"instanceType": args.Type.String, "instance": args.Name, "project": args.Project}), + logger: logging.AddContext(logger.Log, log.Ctx{"instanceType": args.Type, "instance": args.Name, "project": args.Project}), name: args.Name, node: args.Node, profiles: args.Profiles, diff --git a/lxd/instance/drivers/driver_qemu.go b/lxd/instance/drivers/driver_qemu.go index c2f9c04b44..8a5add66c5 100644 --- a/lxd/instance/drivers/driver_qemu.go +++ b/lxd/instance/drivers/driver_qemu.go @@ -113,7 +113,7 @@ func qemuInstantiate(s *state.State, args db.InstanceArgs, expandedDevices devic lastUsedDate: args.LastUsedDate, localConfig: args.Config, localDevices: args.Devices, - logger: logging.AddContext(logger.Log, log.Ctx{"instanceType": args.Type.String, "instance": args.Name, "project": args.Project}), + logger: logging.AddContext(logger.Log, log.Ctx{"instanceType": args.Type, "instance": args.Name, "project": args.Project}), name: args.Name, node: args.Node, profiles: args.Profiles, @@ -167,7 +167,7 @@ func qemuCreate(s *state.State, args db.InstanceArgs) (instance.Instance, error) lastUsedDate: args.LastUsedDate, localConfig: args.Config, localDevices: args.Devices, - logger: logging.AddContext(logger.Log, log.Ctx{"instanceType": args.Type.String, "instance": args.Name, "project": args.Project}), + logger: logging.AddContext(logger.Log, log.Ctx{"instanceType": args.Type, "instance": args.Name, "project": args.Project}), name: args.Name, node: args.Node, profiles: args.Profiles, ___ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel
[lxc-devel] [pylxd/master] Remove uses of # NOQA
The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/pylxd/pull/420 This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === From c3b9b68b75a7ab55d52322e43f5546a8ab1b45df Mon Sep 17 00:00:00 2001 From: Dougal Matthews Date: Fri, 4 Dec 2020 09:59:49 + Subject: [PATCH] Remove uses of NOQA --- pylxd/models/__init__.py | 41 - pylxd/tests/mock_lxd.py | 68 ++-- pylxd/tests/models/test_image.py | 30 ++-- pylxd/tests/models/test_operation.py | 2 +- pylxd/tests/models/test_storage.py | 2 +- pylxd/tests/test_client.py | 2 +- 6 files changed, 80 insertions(+), 65 deletions(-) diff --git a/pylxd/models/__init__.py b/pylxd/models/__init__.py index aa3a3a61..51c3954c 100644 --- a/pylxd/models/__init__.py +++ b/pylxd/models/__init__.py @@ -1,12 +1,29 @@ -from pylxd.models.certificate import Certificate # NOQA -from pylxd.models.cluster import Cluster, ClusterMember # NOQA -from pylxd.models.container import Container # NOQA -from pylxd.models.image import Image # NOQA -from pylxd.models.instance import Instance, Snapshot # NOQA -from pylxd.models.network import Network # NOQA -from pylxd.models.operation import Operation # NOQA -from pylxd.models.profile import Profile # NOQA -from pylxd.models.storage_pool import StoragePool # NOQA; NOQA -from pylxd.models.storage_pool import StorageResources # NOQA -from pylxd.models.storage_pool import StorageVolume # NOQA -from pylxd.models.virtual_machine import VirtualMachine # NOQA +from pylxd.models.certificate import Certificate +from pylxd.models.cluster import Cluster, ClusterMember +from pylxd.models.container import Container +from pylxd.models.image import Image +from pylxd.models.instance import Instance, Snapshot +from pylxd.models.network import Network +from pylxd.models.operation import Operation +from pylxd.models.profile import Profile +from pylxd.models.project import Project +from pylxd.models.storage_pool import StoragePool, StorageResources, StorageVolume +from pylxd.models.virtual_machine import VirtualMachine + +__all__ = [ +"Certificate", +"Cluster", +"ClusterMember", +"Container", +"Image", +"Instance", +"Network", +"Operation", +"Profile", +"Project", +"Snapshot", +"StoragePool", +"StorageResources", +"StorageVolume", +"VirtualMachine", +] diff --git a/pylxd/tests/mock_lxd.py b/pylxd/tests/mock_lxd.py index 0e1febd0..c408cac8 100644 --- a/pylxd/tests/mock_lxd.py +++ b/pylxd/tests/mock_lxd.py @@ -185,13 +185,13 @@ def snapshot_DELETE(request, context): "type": "sync", "metadata": { "certificate": "certificate-content", -"fingerprint": "eaf55b72fc23aa516d709271df9b0116064bf8cfa009cf34c67c33ad32c2320c", # NOQA +"fingerprint": "eaf55b72fc23aa516d709271df9b0116064bf8cfa009cf34c67c33ad32c2320c", "type": "client", }, } ), "method": "GET", -"url": r"^http://pylxd.test/1.0/certificates/eaf55b72fc23aa516d709271df9b0116064bf8cfa009cf34c67c33ad32c2320c$";, # NOQA +"url": r"^http://pylxd.test/1.0/certificates/eaf55b72fc23aa516d709271df9b0116064bf8cfa009cf34c67c33ad32c2320c$";, }, { "text": json.dumps( @@ -275,7 +275,7 @@ def snapshot_DELETE(request, context): } ), "method": "GET", -"url": r"^http://pylxd.test/1.0/cluster/members/an-member$";, # NOQA +"url": r"^http://pylxd.test/1.0/cluster/members/an-member$";, }, # Instances { @@ -431,7 +431,7 @@ def snapshot_DELETE(request, context): }, }, "method": "GET", -"url": r"^http://pylxd.test/1.0/instances/an-instance/state$";, # NOQA +"url": r"^http://pylxd.test/1.0/instances/an-instance/state$";, }, { "json": { @@ -465,7 +465,7 @@ def snapshot_DELETE(request, context): "operation": "/1.0/operations/operation-abc?project=default", }, "method": "PUT", -"url": r"^http://pylxd.test/1.0/instances/an-instance/state$";, # NOQA +"url": r"^http://pylxd.test/1.0/instances/an-instance/state$";, }, { "json": instance_POST, @@ -505,7 +505,7 @@ def snapshot_DELETE(request, context): }, "status_code": 202, "method": "POST", -"url": r"^http://pylxd.test/1.0/instances/an-instance/exec$";, # NOQA +"url": r"^http://pylxd.test/1.0/instances/an-instance/exec$";, }, { "json": instance_PUT, @@ -523,7 +523,7 @@ def snapshot_DELETE(request, context): } ), "method": "GET", -"url": r"^http://pylxd.test/1.0/
[lxc-devel] [pylxd/master] Remove support for Python 2.7 and test 3.6, 3.7 and 3.8
The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/pylxd/pull/421 This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === From b246823c108be95e0c0ff1e35d83003e1fae4584 Mon Sep 17 00:00:00 2001 From: Dougal Matthews Date: Fri, 4 Dec 2020 10:31:44 + Subject: [PATCH] Remove support for Python 2.7 and test 3.6, 3.7 and 3.8 --- .travis.yml| 3 ++- doc/source/contributing.rst| 4 ++-- pylxd/deprecated/connection.py | 14 -- pylxd/exceptions.py| 6 -- pylxd/models/instance.py | 4 requirements.txt | 1 - setup.cfg | 5 ++--- setup.py | 8 tox.ini| 2 +- 9 files changed, 11 insertions(+), 36 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7ad5fb71..70242a5e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,10 @@ language: python python: - "3.6" + - "3.7" + - "3.8" env: matrix: - - TOXENV=py27 - TOXENV=py3 - TOXENV=lint # - TOXENV=integration # requires a remote lxd setup diff --git a/doc/source/contributing.rst b/doc/source/contributing.rst index 103be2b9..4eb8b402 100644 --- a/doc/source/contributing.rst +++ b/doc/source/contributing.rst @@ -78,7 +78,7 @@ Testing Testing pyLXD is in 3 parts: 1. Conformance with `PEP 8`_, using the ``tox -e pep8`` command. -2. Unit tests using ``tox -e py27`` and ``tox -e py3``. +2. Unit tests using ``tox -e py3``. 3. Integration tests using the ``run_integration_tests`` script in the root of the repository. @@ -126,7 +126,7 @@ Some hints on how to run the integration tests: 1. On Ubuntu it's probably easiest to use the `Multipass`_ snap. 2. Launch an LTS instance using ``multipass launch -n foo`` 3. Shell into the instance: ``multipass exec foo -- bash`` -4. Install tox and python2.7: ``sudo apt install python-tox python-2.7`` +4. Install tox and python3.6+: ``sudo apt install python-tox python3-dev`` 5. Clone the branch from the PR (or otherwise copy the repo into the machine) 6. Configure LXD using ``lxd init`` -- follow the prompts provided. 7. Run the integration tests. diff --git a/pylxd/deprecated/connection.py b/pylxd/deprecated/connection.py index b2d27d08..cf5aaa3a 100644 --- a/pylxd/deprecated/connection.py +++ b/pylxd/deprecated/connection.py @@ -31,17 +31,11 @@ from pylxd.deprecated import exceptions, utils -if hasattr(ssl, "SSLContext"): -# For Python >= 2.7.9 and Python 3.x -if hasattr(ssl, "PROTOCOL_TLSv1_2"): -DEFAULT_TLS_VERSION = ssl.PROTOCOL_TLSv1_2 -else: -DEFAULT_TLS_VERSION = ssl.PROTOCOL_TLSv1 +# For Python >= 2.7.9 and Python 3.x +if hasattr(ssl, "PROTOCOL_TLSv1_2"): +DEFAULT_TLS_VERSION = ssl.PROTOCOL_TLSv1_2 else: -# For Python 2.6 and <= 2.7.8 -from OpenSSL import SSL - -DEFAULT_TLS_VERSION = SSL.TLSv1_2_METHOD +DEFAULT_TLS_VERSION = ssl.PROTOCOL_TLSv1 class UnixHTTPConnection(http_client.HTTPConnection): diff --git a/pylxd/exceptions.py b/pylxd/exceptions.py index 605a4f14..941e348c 100644 --- a/pylxd/exceptions.py +++ b/pylxd/exceptions.py @@ -54,9 +54,3 @@ def __init__(self, name, *args, **kwargs): class ClientConnectionFailed(Exception): """An exception raised when the Client connection fails.""" - - -if six.PY2: - -class NotADirectoryError(Exception): -""" An exception raised when not a directory for python2 """ diff --git a/pylxd/models/instance.py b/pylxd/models/instance.py index 47576b73..03acc6a0 100644 --- a/pylxd/models/instance.py +++ b/pylxd/models/instance.py @@ -35,10 +35,6 @@ from pylxd.models import _model as model from pylxd.models.operation import Operation -if six.PY2: -# Python2.7 doesn't have this natively -from pylxd.exceptions import NotADirectoryError - class InstanceState(object): """A simple object for representing instance state.""" diff --git a/requirements.txt b/requirements.txt index bb3c981b..0e9fb89e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,3 @@ requests>=2.20.0 requests-unixsocket>=0.1.5 requests-toolbelt>=0.8.0 cryptography!=1.3.0,>=1.0 -pyOpenSSL>=0.14;python_version<='2.7.8' diff --git a/setup.cfg b/setup.cfg index 6b0e25f3..5a750d74 100644 --- a/setup.cfg +++ b/setup.cfg @@ -15,11 +15,10 @@ classifier = Operating System :: POSIX :: Linux Programming Language :: Python Programming Language :: Python :: 2 -Programming Language :: Python :: 2.7 Programming Language :: Python :: 3 -Programming Language :: Python :: 3.4 -Programming Language :: Python :: 3.5 Programming Language :: Python :: 3.6 +Programming Language :: Python :: 3.7 +Programming Language :: Python :: 3.8 [files] packages = diff --git a/setup.py b/setup.py index ddfcb924..8a58609b 100644 --
[lxc-devel] [lxd/master] lxd/apparmor/qemu: Allow some more files
The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/8214 This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === This allows NSS related files: - nsswitch.conf - passwd - group As well as /proc/version which QEMU apparently accesses sometimes. Signed-off-by: Stéphane Graber From 53127c9b827cac52cc235d3f6b61348ad91f5761 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Fri, 4 Dec 2020 08:44:37 -0500 Subject: [PATCH] lxd/apparmor/qemu: Allow some more files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows NSS related files: - nsswitch.conf - passwd - group As well as /proc/version which QEMU apparently accesses sometimes. Signed-off-by: Stéphane Graber --- lxd/apparmor/instance_qemu.go | 4 1 file changed, 4 insertions(+) diff --git a/lxd/apparmor/instance_qemu.go b/lxd/apparmor/instance_qemu.go index a1183e27e4..4f7e7104f0 100644 --- a/lxd/apparmor/instance_qemu.go +++ b/lxd/apparmor/instance_qemu.go @@ -40,6 +40,10 @@ profile "{{ .name }}" flags=(attach_disconnected,mediate_deleted) { /usr/share/qemu/**kr, /usr/share/seabios/** kr, owner @{PROC}/@{pid}/task/@{tid}/comm rw, + {{ .rootPath }}/etc/nsswitch.conf r, + {{ .rootPath }}/etc/passwdr, + {{ .rootPath }}/etc/group r, + @{PROC}/version r, # Instance specific paths {{ .logPath }}/** rwk, ___ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel
[lxc-devel] [pylxd/master] Add a .git-blame-ignore-revs
The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/pylxd/pull/422 This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === This will allow git to ignore the reformatting changes, so `git blame` keeps the original author. From 720a9a73ab8d8ca9c06e43e6c6a8430e69b19a62 Mon Sep 17 00:00:00 2001 From: Dougal Matthews Date: Fri, 4 Dec 2020 15:10:22 + Subject: [PATCH] Add a .git-blame-ignore-revs This will allow git to ignore the reformatting changes, so `git blame` keeps the original author. --- .git-blame-ignore-revs | 15 +++ 1 file changed, 15 insertions(+) create mode 100644 .git-blame-ignore-revs diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index ..3f66a0c7 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,15 @@ +# This file contains all the revisions that are only formatting changes and +# should usually be ignored when running 'git blame'. +# +# Make use of it on a single file by running: +# +# git blame --ignore-revs-file .git-blame-ignore-revs FILE +# +# ... or for global setting (most useful) configure git: +# +# git config blame.ignoreRevsFile .git-blame-ignore-revs +# +# Note that git 2.23 or newer is required for this to work + +# Blacken all the code +f76cf13e23603717caec8af611e1a1889bca9eb4 ___ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel
[lxc-devel] [pylxd/master] Use stages for travis builds
The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/pylxd/pull/424 This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === From 96ea34c6f73d2aa7bde0d13c3d6b8398440f3950 Mon Sep 17 00:00:00 2001 From: Alberto Donato Date: Fri, 4 Dec 2020 16:51:46 +0100 Subject: [PATCH 1/2] move all configs to setup.cfg Signed-off-by: Alberto Donato --- .coveragerc | 12 -- setup.cfg | 65 + tox.ini | 48 --- 3 files changed, 65 insertions(+), 60 deletions(-) delete mode 100644 .coveragerc delete mode 100644 tox.ini diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 6f82cddc.. --- a/.coveragerc +++ /dev/null @@ -1,12 +0,0 @@ -[run] -branch = True -source = pylxd - -[report] -show_missing=True -omit = -pylxd/tests/* -pylxd/deprecated/* -exclude_lines = -def __str__ -pragma: no cover diff --git a/setup.cfg b/setup.cfg index 55144ac4..f4a58d3b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -28,6 +28,11 @@ install_requires = ws4py!=0.3.5, >=0.3.4 # 0.3.5 is broken for websocket support packages = find: +[globals] +lint_files = +{toxinidir}/pylxd +{toxinidir}/setup.py + [build_sphinx] source-dir = doc/source build-dir = doc/build @@ -52,3 +57,63 @@ output_file = pylxd/locale/pylxd.pot [nosetests] nologcapture=1 + +[flake8] +show-source = True +ignore = E203, E266, E501, W503, W504 +builtins = _ +exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build + +[tox:tox] +minversion = 1.6 +envlist = py3, pypy, lint +skipsdist = True + +[testenv] +usedevelop = True +install_command = pip install -U {opts} {packages} +setenv = +VIRTUAL_ENV={envdir} +PYLXD_WARNINGS=none +deps = +-r{toxinidir}/test-requirements.txt +commands = nosetests --with-coverage --cover-package=pylxd pylxd + +[testenv:integration] +commands = nosetests integration + +[testenv:migration] +commands = nosetests migration + +[testenv:format] +basepython=python3 +deps = +black == 20.8b1 +isort == 5.6.4 +commands= +isort --profile black {[globals]lint_files} +black {[globals]lint_files} + +[testenv:lint] +basepython=python3 +deps = +black == 20.8b1 +flake8 >= 2.5.0 +isort == 5.6.4 +commands= +black --check {[globals]lint_files} +isort --profile black --check-only --diff {[globals]lint_files} +flake8 {[globals]lint_files} + +[coverage:run] +branch = True +source = pylxd + +[coverage:report] +show_missing = True +omit = +pylxd/tests/* +pylxd/deprecated/* +exclude_lines = +def __str__ +pragma: no cover diff --git a/tox.ini b/tox.ini deleted file mode 100644 index a0fb1be6.. --- a/tox.ini +++ /dev/null @@ -1,48 +0,0 @@ -[tox] -minversion = 1.6 -envlist = py3,pypy,lint -skipsdist = True - -[testenv] -usedevelop = True -install_command = pip install -U {opts} {packages} -setenv = - VIRTUAL_ENV={envdir} - PYLXD_WARNINGS=none -deps = - -r{toxinidir}/test-requirements.txt -commands = nosetests --with-coverage --cover-package=pylxd pylxd - -[testenv:integration] -commands = nosetests integration - -[testenv:migration] -commands = nosetests migration - -[testenv:format] -basepython=python3 -deps = - black==20.8b1 - flake8>=2.5.0 - isort==5.6.4 -commands= - isort --profile black {toxinidir}/pylxd - black {toxinidir}/pylxd - -[testenv:lint] -basepython=python3 -deps = - black==20.8b1 - flake8>=2.5.0 - isort==5.6.4 -commands= - black --check {toxinidir}/pylxd - isort --profile black --check-only --diff {toxinidir}/pylxd - flake8 {toxinidir}/pylxd - - -[flake8] -show-source = True -ignore = E203, E266, E501, W503, W504 -builtins = _ -exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build From 3452a0354925a6e702471c85a4e667a5d35334e9 Mon Sep 17 00:00:00 2001 From: Alberto Donato Date: Fri, 4 Dec 2020 16:56:11 +0100 Subject: [PATCH 2/2] use stages for travis builds --- .travis.yml | 24 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 70242a5e..330b524c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,20 +3,20 @@ python: - "3.6" - "3.7" - "3.8" -env: - matrix: - - TOXENV=py3 - - TOXENV=lint - # - TOXENV=integration # requires a remote lxd setup - -install: - - travis_retry pip install tox - - pip install codecov +stages: + - lint + - test +install: pip install tox codecov +jobs: + fast_finish: true + include: +- stage: lint + script: tox -e lint + python: "3.6" script: - - tox + - tox -e py - test -d .tox/$TOXENV/log && cat .tox/$TOXENV/log/*.log || true cache: directories: - $HOME/.cache/pip -after_success: - - codecov +after_success: codecov ___ lx
[lxc-devel] [pylxd/master] Small updates to use Python 3 features
The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/pylxd/pull/425 This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === From 5a4156ec9759c56e6519464ee6615321975d9fa7 Mon Sep 17 00:00:00 2001 From: Dougal Matthews Date: Fri, 4 Dec 2020 16:04:38 + Subject: [PATCH 1/2] Modernize the super() calls to make use of Python 3 features --- pylxd/deprecated/exceptions.py| 2 +- pylxd/deprecated/tests/__init__.py| 2 +- pylxd/deprecated/tests/test_connection.py | 2 +- pylxd/deprecated/tests/test_image.py | 2 +- pylxd/exceptions.py | 4 ++-- pylxd/managers.py | 4 ++-- pylxd/models/_model.py| 8 pylxd/models/cluster.py | 2 +- pylxd/models/instance.py | 6 +++--- pylxd/models/network.py | 2 +- pylxd/models/operation.py | 2 +- pylxd/models/storage_pool.py | 18 +- pylxd/tests/models/test_instance.py | 6 +++--- pylxd/tests/models/test_model.py | 2 +- 14 files changed, 31 insertions(+), 31 deletions(-) diff --git a/pylxd/deprecated/exceptions.py b/pylxd/deprecated/exceptions.py index 55965790..cd6c8848 100644 --- a/pylxd/deprecated/exceptions.py +++ b/pylxd/deprecated/exceptions.py @@ -40,6 +40,6 @@ class ImageInvalidSize(PyLXDException): class APIError(PyLXDException): def __init__(self, error, status_code): msg = "Error %s - %s." % (status_code, error) -super(APIError, self).__init__(msg) +super().__init__(msg) self.status_code = status_code self.error = error diff --git a/pylxd/deprecated/tests/__init__.py b/pylxd/deprecated/tests/__init__.py index 2cd41518..12fca5ff 100644 --- a/pylxd/deprecated/tests/__init__.py +++ b/pylxd/deprecated/tests/__init__.py @@ -21,7 +21,7 @@ class LXDAPITestBase(unittest.TestCase): def setUp(self): -super(LXDAPITestBase, self).setUp() +super().setUp() self.lxd = api.API() diff --git a/pylxd/deprecated/tests/test_connection.py b/pylxd/deprecated/tests/test_connection.py index 9665f389..d4027ec3 100644 --- a/pylxd/deprecated/tests/test_connection.py +++ b/pylxd/deprecated/tests/test_connection.py @@ -102,7 +102,7 @@ def __init__(self, status, data): @mock.patch("pylxd.deprecated.connection.LXDConnection.get_connection") class LXDConnectionTest(unittest.TestCase): def setUp(self): -super(LXDConnectionTest, self).setUp() +super().setUp() self.conn = connection.LXDConnection() @annotated_data( diff --git a/pylxd/deprecated/tests/test_image.py b/pylxd/deprecated/tests/test_image.py index 9131e01f..35763654 100644 --- a/pylxd/deprecated/tests/test_image.py +++ b/pylxd/deprecated/tests/test_image.py @@ -200,7 +200,7 @@ def test_image_export_fail(self, ms): ) class LXDAPIImageInfoTest(unittest.TestCase): def setUp(self): -super(LXDAPIImageInfoTest, self).setUp() +super().setUp() self.image = image.LXDImage() info_list = ( diff --git a/pylxd/exceptions.py b/pylxd/exceptions.py index 50e6aff0..8b6309b5 100644 --- a/pylxd/exceptions.py +++ b/pylxd/exceptions.py @@ -11,7 +11,7 @@ class LXDAPIException(Exception): """ def __init__(self, response): -super(LXDAPIException, self).__init__() +super().__init__() self.response = response def __str__(self): @@ -44,7 +44,7 @@ def __init__(self, name, *args, **kwargs): :param name: the api_extension that was needed. :type name: str """ -super(LXDAPIExtensionNotAvailable, self).__init__( +super().__init__( "LXD API extension '{}' is not available".format(name), *args, **kwargs ) diff --git a/pylxd/managers.py b/pylxd/managers.py index 477d70df..f6256eac 100644 --- a/pylxd/managers.py +++ b/pylxd/managers.py @@ -22,7 +22,7 @@ def __init__(self, *args, **kwargs): for name, method in methods: func = functools.partial(method, *args, **kwargs) setattr(self, name, func) -return super(BaseManager, self).__init__() +return super().__init__() class CertificateManager(BaseManager): @@ -74,7 +74,7 @@ class ClusterManager(BaseManager): manager_for = "pylxd.models.Cluster" def __init__(self, client, *args, **kwargs): -super(ClusterManager, self).__init__(client, *args, **kwargs) +super().__init__(client, *args, **kwargs) self._client = client self.members = ClusterMemberManager(client) diff --git a/pylxd/models/_model.py b/pylxd/models/_model.py index b605e1f9..13d5bb84 100644 --- a/pylxd/models/_model.py +++ b/pylxd/models/_model.py @@ -82,7 +82,7 @@ def __new__(cls, name, bases, att
[lxc-devel] [pylxd/master] Switch to pytest
The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/pylxd/pull/426 This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === From c7b5c6b65d24f57174e58c97e9708589662f8d19 Mon Sep 17 00:00:00 2001 From: Dougal Matthews Date: Fri, 4 Dec 2020 16:21:39 + Subject: [PATCH] Switch to pytest --- setup.cfg | 3 --- test-requirements.txt | 4 ++-- tox.ini | 6 +++--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/setup.cfg b/setup.cfg index 55144ac4..7b176763 100644 --- a/setup.cfg +++ b/setup.cfg @@ -49,6 +49,3 @@ input_file = pylxd/locale/pylxd.pot keywords = _ gettext ngettext l_ lazy_gettext mapping_file = babel.cfg output_file = pylxd/locale/pylxd.pot - -[nosetests] -nologcapture=1 diff --git a/test-requirements.txt b/test-requirements.txt index 6357aeeb..b0bb1f91 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,8 +1,8 @@ ddt>=0.7.0 -nose>=1.3.7 +pytest>=6.1.2 mock>=1.3.0 -coverage>=4.1 mock-services>=0.3 # mock-services is old and unmaintained. Doesn't work with newer versions of # requests-mock. Thus, we have to pin it down. requests-mock<1.2 +pytest-cov==2.10.1 diff --git a/tox.ini b/tox.ini index a0fb1be6..3778d7b7 100644 --- a/tox.ini +++ b/tox.ini @@ -11,13 +11,13 @@ setenv = PYLXD_WARNINGS=none deps = -r{toxinidir}/test-requirements.txt -commands = nosetests --with-coverage --cover-package=pylxd pylxd +commands = pytest --cov=pylxd pylxd [testenv:integration] -commands = nosetests integration +commands = pytest pytest integration [testenv:migration] -commands = nosetests migration +commands = pytest migration [testenv:format] basepython=python3 ___ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel
[lxc-devel] [pylxd/master] Add support for lxd projects
The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/pylxd/pull/427 This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === Signed-off-by: Dougal Matthews From 2687a67764f8c9504a801793f9699edfd0fae3b6 Mon Sep 17 00:00:00 2001 From: Dougal Matthews Date: Thu, 3 Dec 2020 10:40:05 + Subject: [PATCH] Add support for lxd projects Signed-off-by: Dougal Matthews --- integration/test_projects.py | 87 +++ pylxd/client.py| 5 + pylxd/managers.py | 4 + pylxd/models/__init__.py | 2 + pylxd/models/project.py| 70 pylxd/tests/models/test_project.py | 174 + 6 files changed, 342 insertions(+) create mode 100644 integration/test_projects.py create mode 100644 pylxd/models/project.py create mode 100644 pylxd/tests/models/test_project.py diff --git a/integration/test_projects.py b/integration/test_projects.py new file mode 100644 index ..e8db0f2b --- /dev/null +++ b/integration/test_projects.py @@ -0,0 +1,87 @@ +# Copyright (c) 2016 Canonical Ltd +# +#Licensed under the Apache License, Version 2.0 (the "License"); you may +#not use this file except in compliance with the License. You may obtain +#a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +#Unless required by applicable law or agreed to in writing, software +#distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +#WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +#License for the specific language governing permissions and limitations +#under the License. +from pylxd import exceptions + +from integration.testing import IntegrationTestCase + + +class TestProjects(IntegrationTestCase): +"""Tests for `Client.projects.`""" + +def test_get(self): +"""A project is fetched by name.""" +name = self.create_project() +self.addCleanup(self.delete_project, name) + +project = self.client.projects.get(name) + +self.assertEqual(name, project.name) + +def test_all(self): +"""All projects are fetched.""" +name = self.create_project() +self.addCleanup(self.delete_project, name) + +projects = self.client.projects.all() + +self.assertIn(name, [project.name for project in projects]) + +def test_create(self): +"""A project is created.""" +name = "an-project" +config = {"limits.memory": "1GB"} +project = self.client.projects.create(name, config) +self.addCleanup(self.delete_project, name) + +self.assertEqual(name, project.name) +self.assertEqual(config, project.config) + + +class TestProject(IntegrationTestCase): +"""Tests for `Project`.""" + +def setUp(self): +super(TestProject, self).setUp() +name = self.create_project() +self.project = self.client.projects.get(name) + +def tearDown(self): +super(TestProject, self).tearDown() +self.delete_project(self.project.name) + +def test_save(self): +"""A project is updated.""" +self.project.config["limits.memory"] = "16GB" +self.project.save() + +project = self.client.projects.get(self.project.name) +self.assertEqual("16GB", project.config["limits.memory"]) + +def test_rename(self): +"""A project is renamed.""" +name = "a-other-project" +self.addCleanup(self.delete_project, name) + +self.project.rename(name) +project = self.client.projects.get(name) + +self.assertEqual(name, project.name) + +def test_delete(self): +"""A project is deleted.""" +self.project.delete() + +self.assertRaises( +exceptions.LXDAPIException, self.client.projects.get, self.project.name +) diff --git a/pylxd/client.py b/pylxd/client.py index 78c848ee..ae3007f1 100644 --- a/pylxd/client.py +++ b/pylxd/client.py @@ -258,6 +258,10 @@ class Client(object): Instance of :class:`Client.Profiles `. +.. attribute::projects + +Instance of :class:`Client.Project `. + .. attribute:: api This attribute provides tree traversal syntax to LXD's REST API for @@ -345,6 +349,7 @@ def __init__( self.networks = managers.NetworkManager(self) self.operations = managers.OperationManager(self) self.profiles = managers.ProfileManager(self) +self.projects = managers.ProjectManager(self) self.storage_pools = managers.StoragePoolManager(self) self._resource_cache = None diff --git a/pylxd/managers.py b/pylxd/managers.py index 477d70df..723a6822 100644 --- a/pylxd/managers.py +++ b/pylxd/managers.py @@ -57,6 +57,10 @@ class ProfileManager(
[lxc-devel] [pylxd/master] Remove debugging prints
The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/pylxd/pull/428 This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === Signed-off-by: Dougal Matthews From 3e1a4f3ed361b49d1eef06e3247f23a636d716ef Mon Sep 17 00:00:00 2001 From: Dougal Matthews Date: Fri, 4 Dec 2020 16:44:45 + Subject: [PATCH] Remove debugging prints Signed-off-by: Dougal Matthews --- pylxd/models/cluster.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pylxd/models/cluster.py b/pylxd/models/cluster.py index 99fc8fa1..7d83d765 100644 --- a/pylxd/models/cluster.py +++ b/pylxd/models/cluster.py @@ -35,9 +35,7 @@ def api(self): @classmethod def get(cls, client, *args): """Get cluster details""" -print(args) response = client.api.cluster.get() -print(response.json()) container = cls(client, **response.json()["metadata"]) return container ___ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel
[lxc-devel] [pylxd/master] Unused code
The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/pylxd/pull/429 This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === From b3b67fe0e68423fc2f85bccf1f20acdb779a38ba Mon Sep 17 00:00:00 2001 From: Dougal Matthews Date: Fri, 4 Dec 2020 16:51:41 + Subject: [PATCH 1/2] Remove unused testing utility function Signed-off-by: Dougal Matthews --- pylxd/deprecated/tests/utils.py | 21 - 1 file changed, 21 deletions(-) diff --git a/pylxd/deprecated/tests/utils.py b/pylxd/deprecated/tests/utils.py index 9a3270c9..c2e0859c 100644 --- a/pylxd/deprecated/tests/utils.py +++ b/pylxd/deprecated/tests/utils.py @@ -13,27 +13,6 @@ #under the License. from pylxd import api -from pylxd import exceptions as lxd_exceptions - - -def upload_image(image): -alias = "{}/{}/{}/{}".format( -image["os"], image["release"], image["arch"], image["variant"] -) -lxd = api.API() -imgs = api.API(host="images.linuxcontainers.org") -d = imgs.alias_show(alias) - -meta = d[1]["metadata"] -tgt = meta["target"] - -try: -lxd.alias_update(meta) -except lxd_exceptions.APIError as ex: -if ex.status_code == 404: -lxd.alias_create(meta) - -return tgt def delete_image(image): From a87a3f35fac24d0f1b6a1eddfc76029565fa19e9 Mon Sep 17 00:00:00 2001 From: Dougal Matthews Date: Fri, 4 Dec 2020 16:52:42 + Subject: [PATCH 2/2] Remove unused testing utility method delete_image Signed-off-by: Dougal Matthews --- pylxd/deprecated/tests/utils.py | 20 1 file changed, 20 deletions(-) delete mode 100644 pylxd/deprecated/tests/utils.py diff --git a/pylxd/deprecated/tests/utils.py b/pylxd/deprecated/tests/utils.py deleted file mode 100644 index c2e0859c.. --- a/pylxd/deprecated/tests/utils.py +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright (c) 2015 Canonical Ltd -# -#Licensed under the Apache License, Version 2.0 (the "License"); you may -#not use this file except in compliance with the License. You may obtain -#a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -#Unless required by applicable law or agreed to in writing, software -#distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -#WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -#License for the specific language governing permissions and limitations -#under the License. - -from pylxd import api - - -def delete_image(image): -lxd = api.API() -lxd.image_delete(image) ___ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel
[lxc-devel] [lxc/lxc] 7d40e5: Update Japanese pam_cgfs(8) to reflect lack of sup...
Branch: refs/heads/stable-4.0 Home: https://github.com/lxc/lxc Commit: 7d40e58be4339d8242e676959e520b6974df3794 https://github.com/lxc/lxc/commit/7d40e58be4339d8242e676959e520b6974df3794 Author: KATOH Yasufumi Date: 2020-12-04 (Fri, 04 Dec 2020) Changed paths: M doc/ja/pam_cgfs.sgml.in Log Message: --- Update Japanese pam_cgfs(8) to reflect lack of support for pure cgroupv2 Update for commit b87ed83bbc7db3f826b4f54df1bb458c2c539be7 Signed-off-by: KATOH Yasufumi Commit: 687f9b9bbe07d5a226491f4214314f35dac4e889 https://github.com/lxc/lxc/commit/687f9b9bbe07d5a226491f4214314f35dac4e889 Author: Ruben Jenster Date: 2020-12-04 (Fri, 04 Dec 2020) Changed paths: M src/lxc/seccomp.c Log Message: --- seccomp: Fix handling of pseudo syscalls and improve logging for rule processing. Signed-off-by: Ruben Jenster Commit: 55cbb1a69783ded6a541b6905cf7f9e7f696482c https://github.com/lxc/lxc/commit/55cbb1a69783ded6a541b6905cf7f9e7f696482c Author: Ruben Jenster Date: 2020-12-04 (Fri, 04 Dec 2020) Changed paths: M src/lxc/seccomp.c Log Message: --- seccomp: Avoid duplicate processing of rules for host native arch. Signed-off-by: Ruben Jenster Commit: c14c31d4691a3b4dfe54f521ccd2a193fb0cbbc9 https://github.com/lxc/lxc/commit/c14c31d4691a3b4dfe54f521ccd2a193fb0cbbc9 Author: Ruben Jenster Date: 2020-12-04 (Fri, 04 Dec 2020) Changed paths: M src/lxc/confile.c M src/lxc/confile.h M src/lxc/lxccontainer.c M src/tests/get_item.c Log Message: --- lxccontainer: fix lxc_config_item_is_supported Use exact match instead of longest prefix match to check whether a config item is supported. Signed-off-by: Ruben Jenster Commit: 15190a6a238fa82bb299cf4d523212edbda643a6 https://github.com/lxc/lxc/commit/15190a6a238fa82bb299cf4d523212edbda643a6 Author: Ruben Jenster Date: 2020-12-04 (Fri, 04 Dec 2020) Changed paths: M src/tests/Makefile.am Log Message: --- tests: Fix compilation with appamor enabled. Signed-off-by: Ruben Jenster Commit: bd5ed71d71cde3220cac896d5d0a21bf7206901c https://github.com/lxc/lxc/commit/bd5ed71d71cde3220cac896d5d0a21bf7206901c Author: Christian Brauner Date: 2020-12-04 (Fri, 04 Dec 2020) Changed paths: M src/lxc/commands.c Log Message: --- commands: don't deref after NULL check Fixes: Coverity 1465657 Signed-off-by: Christian Brauner Commit: 64163d8dc8480e5b9a3c52041560b68a020e708f https://github.com/lxc/lxc/commit/64163d8dc8480e5b9a3c52041560b68a020e708f Author: Christian Brauner Date: 2020-12-04 (Fri, 04 Dec 2020) Changed paths: M src/lxc/utils.c Log Message: --- utils: don't deref after NULL check Fixes: Coverity 1465855 Signed-off-by: Christian Brauner Commit: c6c2cf30278203a9a9a4498b49a0f76bb586d813 https://github.com/lxc/lxc/commit/c6c2cf30278203a9a9a4498b49a0f76bb586d813 Author: Christian Brauner Date: 2020-12-04 (Fri, 04 Dec 2020) Changed paths: M src/lxc/conf.c Log Message: --- conf: check snprint return value Fixes: Coverity 1465854 Signed-off-by: Christian Brauner Commit: c253925b4bfc3f79f658308e03859429c98aac07 https://github.com/lxc/lxc/commit/c253925b4bfc3f79f658308e03859429c98aac07 Author: Christian Brauner Date: 2020-12-04 (Fri, 04 Dec 2020) Changed paths: M src/lxc/utils.c Log Message: --- utils: check snprintf return value Fixes: Coverity 1465853 Signed-off-by: Christian Brauner Commit: cbb504c95d7b4d3c30e83c094a0f95f76a2a601d https://github.com/lxc/lxc/commit/cbb504c95d7b4d3c30e83c094a0f95f76a2a601d Author: Christian Brauner Date: 2020-12-04 (Fri, 04 Dec 2020) Changed paths: M src/lxc/file_utils.c M src/lxc/file_utils.h M src/lxc/seccomp.c Log Message: --- seccomp: make seccomp notifier fd non-blocking Suggested-by: Jann Horn Signed-off-by: Christian Brauner Commit: 9436750e5a6bb7e80b2fa4ffd03fd39614b6d956 https://github.com/lxc/lxc/commit/9436750e5a6bb7e80b2fa4ffd03fd39614b6d956 Author: Christian Brauner Date: 2020-12-04 (Fri, 04 Dec 2020) Changed paths: M src/lxc/seccomp.c Log Message: --- seccomp: log aborted system calls Suggested-by: Jann Horn Signed-off-by: Christian Brauner Commit: c5e1a70cffb794cf6eea6f020e35594e36aeaea2 https://github.com/lxc/lxc/commit/c5e1a70cffb794cf6eea6f020e35594e36aeaea2 Author: Christian Brauner Date: 2020-12-04 (Fri, 04 Dec 2020) Changed paths: M src/lxc/attach.c M src/lxc/utils.c Log Message: --- attach: silence stdio permission adjust warnings Closes: #3576. Signed-off-by: Christian Brauner Commit: 1bd5fb39b78517ccfb47eb686da854dc3fd6bbf0 https://github.com/lxc/lxc/commit/1bd5fb39b78517ccfb47eb686da854dc3fd6bbf0 Author: lifeng68 Date: