From 0be4795d33e5aa081a2df6182fc297919e455200 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20P=C3=A1ral?= Date: Mon, 20 Feb 2017 11:27:39 +0100 Subject: [PATCH 1/5] make `setup.py test` work, add requirements.txt Also print coverage by default. --- README.rst | 7 ++++--- requirements.txt | 9 +++++++++ setup.py | 15 ++++++++++++++- test/pytest.ini | 4 ---- tox.ini | 2 +- 5 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 requirements.txt delete mode 100644 test/pytest.ini diff --git a/README.rst b/README.rst index 99b08d2..c0cf914 100644 --- a/README.rst +++ b/README.rst @@ -15,8 +15,9 @@ Packages: - libguestfs-tools - python-requests (for whatever python version you're running) -Optional: - - py.test (if you plan on running or working on the tests) +Optional (if you plan on running or working on the tests): + - python2-pytest + - python-pytest-cov All of these packages are in the Fedora repos (and likely other distros as well). @@ -122,7 +123,7 @@ There is a small testsuite you can run with: .. code:: bash - py.test test/ + py.test This is a good place to contribute if you're looking to help out. diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..c54cb4f --- /dev/null +++ b/requirements.txt @@ -0,0 +1,9 @@ +# This is a list of pypi packages to be installed into virtualenv. Alternatively, +# you can install these as RPMs instead of pypi packages. See README. + +libvirt-python +requests + +# Test suite requirements +pytest +pytest-cov diff --git a/setup.py b/setup.py index 6dd9042..cc1fb9e 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -from setuptools import setup +from setuptools import setup, Command import codecs import re import os @@ -18,6 +18,18 @@ def find_version(*file_paths): raise RuntimeError("Unable to find version string.") +class PyTest(Command): + user_options = [] + def initialize_options(self): + pass + def finalize_options(self): + pass + def run(self): + import subprocess + errno = subprocess.call(['py.test']) + raise SystemExit(errno) + + setup(name='testcloud', version=find_version('testcloud', '__init__.py'), description="small helper script to download and " @@ -29,5 +41,6 @@ def find_version(*file_paths): packages=["testcloud"], package_dir={"testcloud": "testcloud"}, include_package_data=True, + cmdclass={'test': PyTest}, entry_points=dict(console_scripts=["testcloud=testcloud.cli:main"]), ) diff --git a/test/pytest.ini b/test/pytest.ini deleted file mode 100644 index 2c789da..0000000 --- a/test/pytest.ini +++ /dev/null @@ -1,4 +0,0 @@ -[pytest] -minversion = 2.0 -python_functions=test should -python_files=test_* functest_* diff --git a/tox.ini b/tox.ini index 579f8c0..22dd1f2 100644 --- a/tox.ini +++ b/tox.ini @@ -6,4 +6,4 @@ exclude = conf/*,docs/source/conf.py minversion=2.0 python_functions=test should python_files=test_* functest_* -addopts=test/ +addopts=test/ --cov-report=term-missing --cov testcloud From fbe338a5b4d9c087a4ce1aea6ccc3f9de35586d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20P=C3=A1ral?= Date: Wed, 22 Feb 2017 04:23:13 +0100 Subject: [PATCH 2/5] settings.py: improve comments --- conf/settings-example.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/conf/settings-example.py b/conf/settings-example.py index 51d71a3..4fafa0a 100644 --- a/conf/settings-example.py +++ b/conf/settings-example.py @@ -1,18 +1,22 @@ -# Commented out default values with details are displayed below. To override -# these default values, uncomment the values, rename the file to settings.py -# and place it in a supported config location +# Commented out default values with details are displayed below. If you want +# to change the values, make sure this file is available in one of the three +# supported config locations: +# - conf/settings.py in the git checkout +# - ~/.config/testcloud/settings.py +# - /etc/testcloud/settings.py -# Do not modify this file directly, it will not be picked up unless the filename -# is changed to settings.py #DOWNLOAD_PROGRESS = True #LOG_FILE = None -# Directories for data and cached downloaded images + +## Directories for data and cached downloaded images ## + #DATA_DIR = "/var/lib/testcloud/" #STORE_DIR = "/var/lib/testcloud/backingstores" -# Data for cloud-init + +## Data for cloud-init ## #PASSWORD = 'passw0rd' #HOSTNAME = 'testcloud' @@ -20,6 +24,8 @@ #META_DATA = """instance-id: iid-123456 #local-hostname: %s #""" +## Read http://cloudinit.readthedocs.io/en/latest/topics/examples.html to see +## what options you can use here. #USER_DATA = """#cloud-config #password: %s #chpasswd: { expire: False } @@ -32,9 +38,10 @@ #runcmd: # - [ sh, -c, 'echo -e "ROOT_SIZE=4G\nDATA_SIZE=10G" > /etc/sysconfig/docker-storage-setup'] #""" -# -# Extra cmdline args for the qemu invocation. -# Customize as needed :) + + +## Extra cmdline args for the qemu invocation ## +## Customize as needed :) #CMD_LINE_ARGS = [] From 4ce3b404fa9db7de32ba5320b646cf5913a8c001 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20P=C3=A1ral?= Date: Wed, 22 Feb 2017 05:05:48 +0100 Subject: [PATCH 3/5] README: fix Phab link --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index c0cf914..8b1b656 100644 --- a/README.rst +++ b/README.rst @@ -131,7 +131,7 @@ Issue Tracking and Roadmap -------------------------- Our project tracker is on the Fedora QA-devel -`Phabricator `_ +`Phabricator `_ instance. Credit From 4d5eddc4bf2fcef164305de0d2980583ce0bf8a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20P=C3=A1ral?= Date: Wed, 22 Feb 2017 05:17:09 +0100 Subject: [PATCH 4/5] README: update polkit instructions Remove outdated instructions and link to the rules file for detailed info. --- README.rst | 12 +++--------- conf/99-testcloud-nonroot-libvirt-access.rules | 16 +++++++++++----- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.rst b/README.rst index 8b1b656..53d2018 100644 --- a/README.rst +++ b/README.rst @@ -34,15 +34,9 @@ of the current refactoring/transition process. If you are running testcloud as a non-administrative user (ie. not in wheel) or on a system that doesn't have a polkit agent running (custom setups, headless -systems etc.), you may need to adjust local polkit configuration to allow non-root -users to manage VMs with libvirt. Add the following data into ``/etc/polkit-1/localauthority/50-local.d/50-nonrootlivirt.pkla``:: - - [nonroot libvirt system connection] - Identity=unix-group:testcloud - Action=org.libvirt.unix.manage - ResultActive=yes - ResultInactive=yes - ResultAny=yes +systems etc.), you may need to adjust local polkit configuration to allow +non-admin users to manage VMs with libvirt. Look into +``conf/99-testcloud-nonroot-libvirt-access.rules`` file. After writing that file, restart polkit (``systemctl restart polkit``) and if the user in question is a member of the unix group ``testcloud``, that user diff --git a/conf/99-testcloud-nonroot-libvirt-access.rules b/conf/99-testcloud-nonroot-libvirt-access.rules index 4a58b74..d14d219 100644 --- a/conf/99-testcloud-nonroot-libvirt-access.rules +++ b/conf/99-testcloud-nonroot-libvirt-access.rules @@ -1,11 +1,17 @@ -/* testcloud is often used on headless machines (Taskotron uses it this way) -where the user only has ssh access to the virt host. This rule file allows -users in the 'testcloud' group to be able to manipulate spawned machines over -ssh. */ +/* If you are running testcloud as a non-administrative user (ie. not in wheel) or +on a system that doesn't have a polkit agent running (custom setups, headless +systems etc.), you may need to adjust local polkit configuration to allow +non-admin users to manage VMs with libvirt. + +Copy this to /etc/polkit-1/rules.d/ . Then restart polkit +$ systemctl restart polkit +and if the user in question is a member of the unix group 'testcloud', that +user should be able to run testcloud with no additional permissions. +*/ polkit.addRule(function(action, subject) { if (action.id == "org.libvirt.unix.manage" && subject.isInGroup('testcloud')) { - return polkit.Result.YES; + return polkit.Result.YES; } }); From 14801bc8d1f8c278ba7b020a81bc5f40b9acbe44 Mon Sep 17 00:00:00 2001 From: Sumantro Mukherjee Date: Wed, 22 Feb 2017 17:48:02 +0530 Subject: [PATCH 5/5] fix link update obsolete url --- docs/source/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index 692a7e9..fb7ee31 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -75,7 +75,7 @@ Self service methods for asking questions and filing tickets: * `Source Repository `_ - * `Currently Open Issues `_ + * `Currently Open Issues `_ For other questions, the best places to ask are: