testcloud 0.9.12__tar.gz → 0.10.0__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 (56) hide show
  1. {testcloud-0.9.12 → testcloud-0.10.0}/.gitignore +1 -0
  2. {testcloud-0.9.12/testcloud.egg-info → testcloud-0.10.0}/PKG-INFO +13 -3
  3. {testcloud-0.9.12 → testcloud-0.10.0}/README.md +6 -2
  4. {testcloud-0.9.12 → testcloud-0.10.0}/conf/settings-example.py +20 -3
  5. testcloud-0.10.0/conf/testcloud +90 -0
  6. {testcloud-0.9.12 → testcloud-0.10.0}/docs/source/conf.py +1 -1
  7. testcloud-0.10.0/manpages/testcloud.1 +170 -0
  8. {testcloud-0.9.12 → testcloud-0.10.0}/requirements.txt +1 -1
  9. {testcloud-0.9.12 → testcloud-0.10.0}/run_testcloud.py +1 -1
  10. {testcloud-0.9.12 → testcloud-0.10.0}/setup.py +4 -1
  11. {testcloud-0.9.12 → testcloud-0.10.0}/test/test_image.py +52 -0
  12. {testcloud-0.9.12 → testcloud-0.10.0}/test/test_instance.py +11 -1
  13. testcloud-0.10.0/testcloud/__init__.py +18 -0
  14. {testcloud-0.9.12 → testcloud-0.10.0}/testcloud/cli.py +32 -33
  15. {testcloud-0.9.12 → testcloud-0.10.0}/testcloud/config.py +28 -37
  16. {testcloud-0.9.12 → testcloud-0.10.0}/testcloud/distro_utils/centos.py +5 -1
  17. {testcloud-0.9.12 → testcloud-0.10.0}/testcloud/distro_utils/fedora.py +12 -6
  18. testcloud-0.10.0/testcloud/distro_utils/misc.py +43 -0
  19. {testcloud-0.9.12 → testcloud-0.10.0}/testcloud/distro_utils/ubuntu.py +4 -3
  20. {testcloud-0.9.12 → testcloud-0.10.0}/testcloud/domain_configuration.py +50 -27
  21. testcloud-0.10.0/testcloud/image.py +461 -0
  22. {testcloud-0.9.12 → testcloud-0.10.0}/testcloud/instance.py +64 -36
  23. testcloud-0.10.0/testcloud/sql.py +54 -0
  24. {testcloud-0.9.12 → testcloud-0.10.0}/testcloud/util.py +1 -1
  25. testcloud-0.10.0/testcloud/workarounds.py +75 -0
  26. {testcloud-0.9.12 → testcloud-0.10.0/testcloud.egg-info}/PKG-INFO +13 -3
  27. {testcloud-0.9.12 → testcloud-0.10.0}/testcloud.egg-info/SOURCES.txt +4 -3
  28. testcloud-0.10.0/testcloud.egg-info/requires.txt +7 -0
  29. testcloud-0.9.12/Makefile +0 -133
  30. testcloud-0.9.12/conf/domain-template.jinja +0 -55
  31. testcloud-0.9.12/testcloud/__init__.py +0 -2
  32. testcloud-0.9.12/testcloud/distro_utils/misc.py +0 -18
  33. testcloud-0.9.12/testcloud/image.py +0 -317
  34. testcloud-0.9.12/testcloud.egg-info/requires.txt +0 -3
  35. testcloud-0.9.12/testcloud.spec +0 -519
  36. {testcloud-0.9.12 → testcloud-0.10.0}/LICENSE +0 -0
  37. {testcloud-0.9.12 → testcloud-0.10.0}/conf/99-testcloud-nonroot-libvirt-access.rules +0 -0
  38. {testcloud-0.9.12 → testcloud-0.10.0}/docs/LICENSE +0 -0
  39. {testcloud-0.9.12 → testcloud-0.10.0}/docs/Makefile +0 -0
  40. {testcloud-0.9.12 → testcloud-0.10.0}/docs/source/api.rst +0 -0
  41. {testcloud-0.9.12 → testcloud-0.10.0}/docs/source/indepth.rst +0 -0
  42. {testcloud-0.9.12 → testcloud-0.10.0}/docs/source/index.rst +0 -0
  43. {testcloud-0.9.12 → testcloud-0.10.0}/setup.cfg +0 -0
  44. {testcloud-0.9.12 → testcloud-0.10.0}/test/__init__.py +0 -0
  45. {testcloud-0.9.12 → testcloud-0.10.0}/test/test_cli.py +0 -0
  46. {testcloud-0.9.12 → testcloud-0.10.0}/test/test_config.py +0 -0
  47. {testcloud-0.9.12 → testcloud-0.10.0}/testcloud/distro_utils/__init__.py +0 -0
  48. {testcloud-0.9.12 → testcloud-0.10.0}/testcloud/distro_utils/alma.py +0 -0
  49. {testcloud-0.9.12 → testcloud-0.10.0}/testcloud/distro_utils/debian.py +0 -0
  50. {testcloud-0.9.12 → testcloud-0.10.0}/testcloud/distro_utils/oracle.py +0 -0
  51. {testcloud-0.9.12 → testcloud-0.10.0}/testcloud/distro_utils/rocky.py +0 -0
  52. {testcloud-0.9.12 → testcloud-0.10.0}/testcloud/exceptions.py +0 -0
  53. {testcloud-0.9.12 → testcloud-0.10.0}/testcloud.egg-info/dependency_links.txt +0 -0
  54. {testcloud-0.9.12 → testcloud-0.10.0}/testcloud.egg-info/entry_points.txt +0 -0
  55. {testcloud-0.9.12 → testcloud-0.10.0}/testcloud.egg-info/top_level.txt +0 -0
  56. {testcloud-0.9.12 → testcloud-0.10.0}/tox.ini +0 -0
@@ -16,6 +16,7 @@ conf/settings.py
16
16
 
17
17
  # virtualenv
18
18
  /env*/
19
+ /.env*/
19
20
 
20
21
  # unit testing
21
22
  /.coverage
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: testcloud
3
- Version: 0.9.12
3
+ Version: 0.10.0
4
4
  Summary: A tool to download and boot cloud images locally, with an easy to use API.
5
5
  Home-page: https://pagure.io/testcloud
6
6
  Author: Mike Ruckman
@@ -8,6 +8,12 @@ Author-email: roshi@fedoraproject.org
8
8
  License: GPLv2+
9
9
  Description-Content-Type: text/markdown
10
10
  License-File: LICENSE
11
+ Requires-Dist: libvirt-python
12
+ Requires-Dist: peewee
13
+ Requires-Dist: requests
14
+ Requires-Dist: packaging
15
+ Provides-Extra: image-resolve-caching
16
+ Requires-Dist: requests_cache>=1.2; extra == "image-resolve-caching"
11
17
 
12
18
  # testcloud
13
19
 
@@ -255,10 +261,14 @@ new instance using **testcloud**.
255
261
  \--nic_number
256
262
 
257
263
  : To provide nic number you want
258
- \--virtiofs
259
264
 
265
+ \--virtiofs
260
266
  : To specify a local directory to mount and mount target like <host path>:<guest path>
261
267
 
268
+ \--iommu
269
+
270
+ : To provide virtual iommu device
271
+
262
272
  There are several additional options that can be used to create a
263
273
  new Coreos instance using **testcloud**.
264
274
 
@@ -319,7 +329,7 @@ To install **testcloud** for development purposes:
319
329
  1. Install the dependencies for **testcloud**.
320
330
 
321
331
  ```
322
- $ sudo dnf install libvirt python3-libvirt libguestfs libguestfs-tools python3-requests python3-jinja2
332
+ $ sudo dnf builddep testcloud
323
333
  ```
324
334
 
325
335
  2. Start **libvirtd**.
@@ -244,10 +244,14 @@ new instance using **testcloud**.
244
244
  \--nic_number
245
245
 
246
246
  : To provide nic number you want
247
- \--virtiofs
248
247
 
248
+ \--virtiofs
249
249
  : To specify a local directory to mount and mount target like <host path>:<guest path>
250
250
 
251
+ \--iommu
252
+
253
+ : To provide virtual iommu device
254
+
251
255
  There are several additional options that can be used to create a
252
256
  new Coreos instance using **testcloud**.
253
257
 
@@ -308,7 +312,7 @@ To install **testcloud** for development purposes:
308
312
  1. Install the dependencies for **testcloud**.
309
313
 
310
314
  ```
311
- $ sudo dnf install libvirt python3-libvirt libguestfs libguestfs-tools python3-requests python3-jinja2
315
+ $ sudo dnf builddep testcloud
312
316
  ```
313
317
 
314
318
  2. Start **libvirtd**.
@@ -31,9 +31,18 @@
31
31
  ## Read http://cloudinit.readthedocs.io/en/latest/topics/examples.html to see
32
32
  ## what options you can use here.
33
33
  #USER_DATA = """#cloud-config
34
- #password: %s
35
- #chpasswd: { expire: False }
36
- #ssh_pwauth: True
34
+ #ssh_pwauth: true
35
+ #password: ${password}
36
+ #chpasswd:
37
+ # expire: false
38
+ #users:
39
+ # - default
40
+ # - name: cloud-user
41
+ # plain_text_passwd: ${password}
42
+ # sudo: ALL=(ALL) NOPASSWD:ALL
43
+ # lock_passwd: false
44
+ #runcmd:
45
+ #${runcommands}
37
46
  #"""
38
47
 
39
48
  #COREOS_DATA = """variant: fcos
@@ -60,6 +69,8 @@
60
69
  # failing the boot process. Setting this to 0 disables waiting and
61
70
  # returns immediately after starting the boot process.
62
71
  #BOOT_TIMEOUT = 160
72
+ # timeout after which we should kill unfinished downloads of images
73
+ #IMAGE_DOWNLOAD_TIMEOUT = 1800
63
74
 
64
75
  # Maximum space (in GiB) that unused images can occupy in /var/lib/testcloud/backingstores directory
65
76
  # Once the limit is reached, testcloud will attempt to remove oldest files
@@ -67,6 +78,12 @@
67
78
  # 0 = unlimited
68
79
  BACKINGSTORE_SIZE = 4
69
80
 
81
+ # Is reusing the local image url cache an option?
82
+ #CACHE_IMAGES = True
83
+
84
+ # # How old can a local image url cache be to take it as viable
85
+ #TRUST_DEADLINE = 7 # Days
86
+
70
87
  # ram size, in MiB
71
88
  #RAM = 768
72
89
  #RAM_COREOS = 2048
@@ -0,0 +1,90 @@
1
+ __testcloud()
2
+ {
3
+ local cur prev prev2 prev3 base_opts image_opts instance_opts instance_create_opts
4
+ COMPREPLY=()
5
+ cur="${COMP_WORDS[COMP_CWORD]}"
6
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
7
+ prev2="${COMP_WORDS[COMP_CWORD-2]}"
8
+ prev3="${COMP_WORDS[COMP_CWORD-3]}"
9
+ base_opts="instance image -h --help"
10
+ image_opts="list destroy -h --help"
11
+ instance_opts="list start stop remove create -c -h --help"
12
+ instance_create_opts="-h --ram --no-graphic --vnc --timeout --disksize"
13
+
14
+ echo ${COMP_WORDS[@]} >> /tmp/compwords
15
+
16
+ if [[ ${COMP_WORDS[@]} =~ "testcloud image" || ${COMP_WORDS[@]} =~ "t7d image" ]]; then
17
+ if [[ ${prev} == "image" ]]; then
18
+ COMPREPLY=( $(compgen -W "${image_opts}" -- ${cur}) )
19
+ return 0
20
+
21
+ elif [[ ${prev2} == "image" && ${prev} == "list" ]]; then
22
+ return 0
23
+
24
+ elif [[ ${prev2} == "image" && ${prev} == "destroy" ]]; then
25
+ local images
26
+ images=`testcloud image list 2> /dev/null | grep -E "^ "`
27
+ COMPREPLY=( $(compgen -W "${images}" -- ${cur}) )
28
+ return 0
29
+
30
+ elif [[ ${prev3} == "image" && ${prev2} == "destroy" ]]; then
31
+ return 0
32
+ fi
33
+
34
+ elif [[ ${COMP_WORDS[@]} =~ "testcloud" || ${COMP_WORDS[@]} =~ "t7d" ]]; then
35
+ if [[ ${prev} == "create" ]]; then
36
+ COMPREPLY=( $(compgen -W "${instance_create_opts}" -- ${cur}) )
37
+ return 0
38
+
39
+ elif [[ ${prev} == "remove" ]]; then
40
+ local instances
41
+ instances="`testcloud list | tail -n+3 | head -n-1 | cut -f1 -d' '` --force"
42
+ COMPREPLY=( $(compgen -W "${instances}" -- ${cur}) )
43
+ return 0
44
+
45
+ elif [[ ${prev2} == "remove" ]]; then
46
+ local instances
47
+ COMPREPLY=( $(compgen -W "--force" -- ${cur}) )
48
+ return 0
49
+
50
+ elif [[ ${prev} == "list" ]]; then
51
+ COMPREPLY=( $(compgen -W "--all" -- ${cur}) )
52
+ return 0
53
+
54
+ elif [[ ${prev} == "stop" ]]; then
55
+ local instances
56
+ instances=`testcloud list | grep running | cut -f1 -d" "`
57
+ COMPREPLY=( $(compgen -W "${instances}" -- ${cur}) )
58
+ return 0
59
+
60
+ elif [[ ${prev} == "start" ]]; then
61
+ local instances
62
+ instances=`testcloud list | grep shutoff | cut -f1 -d" "`
63
+ COMPREPLY=( $(compgen -W "${instances}" -- ${cur}) )
64
+ return 0
65
+
66
+ elif [[ ${prev2} == "stop" ]]; then
67
+ return 0
68
+
69
+ elif [[ ${prev2} == "start" ]]; then
70
+ return 0
71
+
72
+ elif [[ ${COMP_WORDS[@]} =~ " -c" && ! ${COMP_WORDS[@]} =~ "///system" && ! ${COMP_WORDS[@]} =~ "///session" ]]; then
73
+ _get_comp_words_by_ref -n : cur
74
+ COMPREPLY=( $(compgen -W "qemu:///system qemu:///session" -- ${cur}) )
75
+ __ltrim_colon_completions "$cur" # left trim colon (blahblah)
76
+ return 0
77
+ fi
78
+
79
+ # fallback
80
+ COMPREPLY=( $(compgen -W "${instance_opts}" -- ${cur}) )
81
+ return 0
82
+
83
+
84
+ elif [[ ${cur} == * ]]; then
85
+ COMPREPLY=( $(compgen -W "${base_opts}" -- ${cur}) )
86
+ return 0
87
+ fi
88
+ }
89
+
90
+ complete -F __testcloud testcloud t7d
@@ -55,7 +55,7 @@ copyright = u'2016-2023, testCloud devs'
55
55
  # built documents.
56
56
  #
57
57
  # The short X.Y version.
58
- version = '0.9.12'
58
+ version = '0.10.0'
59
59
  # The full version, including alpha/beta/rc tags.
60
60
  release = version
61
61
 
@@ -0,0 +1,170 @@
1
+ .\" This is the manual page for testcloud.
2
+ .\" Contact lruzicka@redhat.com if you find an errors or a typo.
3
+ .TH TESTCLOUD 1 "11 Nov 2020" "1.0" "testcloud man page"
4
+ .SH NAME
5
+ testcloud \- download \fIqcow2\fR cloud images and boot them locally.
6
+ .SH SYNOPSIS
7
+ \fBtestcloud\fR [-h, --help] [COMMAND]... [OPTION]... [SUBCOMMAND]... [OPTION]...
8
+ .SH DESCRIPTION
9
+ .LP
10
+ \fBtestcloud\fR is a small helper script to download and boot cloud/coreos images
11
+ locally. Testcloud supports wide range of distributions, namely Fedora, Fedora CoreOS,
12
+ CentOS, CentOS Stream, Red Hat Enterprise Linux, Debian and Ubuntu.
13
+
14
+ \fBtestcloud\fR can run either in system mode or in constrained user session mode,
15
+ which is usefull for running it eg. in unprivileged containers.
16
+ .PP
17
+ To run \fBtestcloud\fR, you need to provide the \fBURL\fR of a cloud image or string in \fBdistribution:version\fR format
18
+ to the script which will be used for booting.
19
+
20
+ If you do not have an image location of your own, you can use one
21
+ of the images from the \fBFedora Cloud\fR download pages at \fIhttps://alt.fedoraproject.org/cloud/\fR.
22
+ .PP
23
+ Then, \fBtestcloud\fR will download the image and save it in the \fI/var/lib/testcloud/backingstores/\fR.
24
+ It will use this image to create a backing store for a newly created instance which will be placed in
25
+ \fI/var/tmp/instances/\fR. When the same image has been previously downloaded, \fBtestcloud\fR will NOT
26
+ download it again and it will use the current image to create the instance.
27
+ .PP
28
+ When the new instance is created, \fBtestcloud\fR will show its IP address that you can use to
29
+ access the running instance via \fIssh\fR. The login name is \fBfedora\fR and the password is
30
+ \fBpassw0rd\fR. The IP address of an instance is shown when you list the instance (see COMMANDS).
31
+ .PP
32
+ The instance can also be manipulated and controlled with \fBvirt-manager\fR.
33
+ .SH CONFIGURATION
34
+ The default configuration should work for many people. However, if you need to override the
35
+ default settings, you can do it in the \fIsettings.py\fR file. The example file in
36
+ \fIconf/settings-example.py\fR shows the available configuration values which you can
37
+ alter to suit your needs.
38
+ .PP
39
+ The configuration file must be placed in one of the following locations in order to be
40
+ recognized.
41
+ .IP
42
+ \fIconf/settings.py\fR in the git checkout
43
+ .IP
44
+ \fI~/.config/testcloud/settings.py\fR
45
+ .IP
46
+ \fI/etc/testcloud/settings.py\fR
47
+ .SH COMMANDS
48
+ \fBimage\fR
49
+ Control and manipulate the images (see OPTIONS) for more details.
50
+ .SH OPTIONS
51
+ \fB-h, --help\fR
52
+ Shows the help message and exits.
53
+
54
+ \fB-c CONNECTION, --connection CONNECTION\fR
55
+ Provide the URL of a remote libvirt instance to be used instead of the local one. This option can be used with the \fBinstance\fR command only.
56
+
57
+ .SH SUBCOMMANDS
58
+ \fBcreate\fR
59
+ Create a new instance. See the INSTANCE CREATE OPTIONS section for more details.
60
+
61
+ \fBlist\fR
62
+ List available running instances and images. Use the \fB--all\fR options to list all instances.
63
+
64
+ \fBstart\fR
65
+ Start an existing instance.
66
+
67
+ \fBstop\fR
68
+ Stop a running instance.
69
+
70
+ \fBreboot\fR
71
+ Force the instance to reboot.
72
+
73
+ \fBremove\fR
74
+ Remove an instance or image. If an instance is running, it cannot be removed without the \fB-f\fR option.
75
+
76
+ \fBdestroy\fR
77
+ Remove an instance or image. Deprecated, do not use.
78
+
79
+ \fBclean\fR
80
+ Remove non-existing or unsynced libvirt VMs from testcloud.
81
+
82
+ .SH INSTANCE CREATE OPTIONS
83
+ \fBURL\fR
84
+ Specify the URL from where testcloud should download the instance qcow2 image or distro:version handle. \fBThis option is compulsory\fR.
85
+ Some examples of supported short urls:
86
+ - fedora:rawhide (latest compose), fedora:33, fedora:latest (latest Fedora GA image)
87
+ - fedora-coreos:next, fedora-coreos:testing, fedora-coreos:stable
88
+ - fedora:qa-matrix (image from https://fedoraproject.org/wiki/Test_Results:Current_Cloud_Test )
89
+ - centos:XX (eg. centos:8, centos:latest)
90
+ - centos-stream:XX (eg. centos-stream:8, centos-stream:latest)
91
+ - ubuntu:release_name (eg. ubuntu:focal, ubuntu:latest)
92
+ - debian:release_name/release_number (eg. debian:11, debian:sid, debian:latest)
93
+
94
+ \fB-n, --name NAME\fR
95
+ Set desired instance name. A nice and memorable name will be generated for you if not specified.
96
+
97
+ \fB--arch ARCH\fR
98
+ Set the desired guest architecture. Host arch is the default, supported are: x86_64, aarch64, ppc64le, and s390x.
99
+
100
+ \fB--ram RAM\fR
101
+ Set the amount of RAM that will be available to the instance's VM (in MiB).
102
+
103
+ \fB--vcpus VCPUS\fR
104
+ Set the number of virtual CPU cores to be assinged to the VM.
105
+
106
+ \fB--disksize DISKSIZE\fR
107
+ Set the disk size of the instance VM (in GiB).
108
+
109
+ \fB--vnc\fR
110
+ Open a VNC connection to the \fB:1\fR display of the instance VM.
111
+
112
+ \fB--no-graphic\fR
113
+ Turn off the instance VM's graphical display.
114
+
115
+ \fB--timeout TIMEOUT\fR
116
+ Specify the time (in seconds) to wait for the instance boot to complete. To disable waiting time (default behaviour) set to \fB0\fR.
117
+
118
+ \fB--disk_number\fR
119
+ \fB:\fR To provide disk number you want
120
+
121
+ \fB--nic_number\fR
122
+ \fB:\fR To provide nic number you want
123
+
124
+ \fB--virtiofs\fR
125
+ \fB:\fR To specify a local directory to mount and mount target like <host path>:<guest path>
126
+
127
+ \fB--iommu\fR
128
+ \fB:\fR To provide virtual iommu device
129
+
130
+ \fB ADDITIONAL COREOS OPTIONS\fR
131
+
132
+ \fB--bu_file BU_FILE\fR
133
+ \fB:\fR To provide a bu_file you want to use
134
+
135
+ \fB--ign_file IGN_FILE\fR
136
+ \fB:\fR To provide an ign_file you want to use
137
+
138
+ \fB--ssh_path\fR
139
+ \fB:\fR To provide a ssh pubkey path you want to use
140
+
141
+ .SH EXAMPLES
142
+ .PP
143
+ Create a new instance:
144
+ .IP
145
+ \fBtestcloud create <URL>\fR
146
+ .PP
147
+ List all available instances:
148
+ .IP
149
+ \fBtestcloud list\fR
150
+ .PP
151
+ Start an existing instance:
152
+ .IP
153
+ \fBtestcloud start <instance_name>\fR
154
+ .PP
155
+ Stop an existing instance:
156
+ .IP
157
+ \fBtestcloud stop <instance_name>\fR
158
+ .PP
159
+ Remove a running instance:
160
+ .IP
161
+ \fBtestcloud remove -f <instance_name>\fR
162
+
163
+ .SH SEE ALSO
164
+
165
+ \fBtestcloud's help\fR and the Project's \fBREADME.md\fR file
166
+
167
+ .SH BUGS
168
+ No known bugs. If you have found a bug, please report it at \fIhttps://bugzilla.redhat.com\fR.
169
+ .SH AUTHOR
170
+ Mike Ruckman (roshi@fedoraproject.org)
@@ -1,9 +1,9 @@
1
1
  # This is a list of pypi packages to be installed into virtualenv. Alternatively,
2
2
  # you can install these as RPMs instead of pypi packages. See README.
3
3
 
4
- Jinja2
5
4
  libvirt-python
6
5
  requests
6
+ peewee
7
7
  #guestfs - after it is on pypi ( https://bugzilla.redhat.com/show_bug.cgi?id=1075594 )
8
8
 
9
9
  # Test suite requirements
@@ -1,4 +1,4 @@
1
- #! /usr/bin/python3
1
+ #! /usr/bin/env python3
2
2
  from testcloud import cli
3
3
 
4
4
  cli.main()
@@ -50,9 +50,12 @@ setup(name='testcloud',
50
50
  include_package_data=True,
51
51
  cmdclass={'test': PyTest},
52
52
  entry_points=dict(console_scripts=["testcloud=testcloud.cli:main", "t7d=testcloud.cli:main"]),
53
+ data_files = [('share/man/man1', ['manpages/testcloud.1']), ('share/bash-completion/completions', ['conf/testcloud'])],
53
54
  install_requires=[
54
- 'Jinja2',
55
55
  'libvirt-python',
56
+ 'peewee',
56
57
  'requests',
58
+ 'packaging'
57
59
  ],
60
+ extras_require={"image_resolve_caching": ["requests_cache>=1.2"]}
58
61
  )
@@ -52,6 +52,44 @@ class TestImageUriProcess(object):
52
52
  assert test_data['name'] == self.image_name
53
53
  assert test_data['path'] == ref_path
54
54
 
55
+ # def test_http_ur1_params(self):
56
+ # ref_type = 'http'
57
+ # ref_path = 'localhost/images/{}'.format(self.image_name)
58
+ # ref_uri = '{}://{}?url_param=value'.format(ref_type, ref_path)
59
+ #
60
+ # test_image = image.Image(ref_uri)
61
+ # test_data = test_image._process_uri(ref_uri)
62
+ #
63
+ # assert test_data['type'] == ref_type
64
+ # assert test_data['name'] == self.image_name
65
+ # assert test_data['path'] == ref_path
66
+ #
67
+ # def test_http_ur1_anchor(self):
68
+ # ref_type = 'http'
69
+ # ref_path = 'localhost/images/{}'.format(self.image_name)
70
+ # ref_uri = '{}://{}#anchor'.format(ref_type, ref_path)
71
+ #
72
+ # test_image = image.Image(ref_uri)
73
+ # test_data = test_image._process_uri(ref_uri)
74
+ #
75
+ # assert test_data['type'] == ref_type
76
+ # assert test_data['name'] == self.image_name
77
+ # assert test_data['path'] == ref_path
78
+ #
79
+ #
80
+ # def test_http_ur1_url_quoted(self):
81
+ # ref_type = 'http'
82
+ # ref_path = 'localhost/images/image%20name.img'
83
+ # ref_uri = '{}://{}'.format(ref_type, ref_path)
84
+ #
85
+ # test_image = image.Image(ref_uri)
86
+ # test_data = test_image._process_uri(ref_uri)
87
+ #
88
+ # assert test_data['type'] == ref_type
89
+ # assert test_data['name'] == "image name.img"
90
+ # assert test_data['path'] == ref_path
91
+
92
+
55
93
  def test_https_uri(self):
56
94
  ref_type = 'https'
57
95
  ref_path = 'localhost/images/{}'.format(self.image_name)
@@ -78,6 +116,20 @@ class TestImageUriProcess(object):
78
116
  assert test_data['name'] == self.image_name
79
117
  assert test_data['path'] == ref_path
80
118
 
119
+ # def test_box(self):
120
+ # ref_uri = "http://local.host/file.box"
121
+ # test_image = image.Image(ref_uri)
122
+ # test_data = test_image._process_uri(ref_uri)
123
+ # assert test_data['name'] == "file.qcow2"
124
+ #
125
+ #
126
+ # def test_xz(self):
127
+ # ref_uri = "http://local.host/file.iso.xz"
128
+ # test_image = image.Image(ref_uri)
129
+ # test_data = test_image._process_uri(ref_uri)
130
+ # assert test_data['name'] == "file.iso"
131
+
132
+
81
133
  def test_invalid_uri_type(self):
82
134
  ref_type = 'ftp'
83
135
  ref_path = '/localhost/images/{}'.format(self.image_name)
@@ -9,8 +9,14 @@ import os
9
9
 
10
10
  from unittest import mock
11
11
 
12
- from testcloud import instance, image, config
12
+ from testcloud import instance, image, config, domain_configuration
13
13
 
14
+ class dotdict(dict):
15
+ # https://stackoverflow.com/a/23689767
16
+ """dot.notation access to dictionary attributes"""
17
+ __getattr__ = dict.get
18
+ __setattr__ = dict.__setitem__
19
+ __delattr__ = dict.__delitem__
14
20
 
15
21
  class TestInstance:
16
22
 
@@ -60,6 +66,10 @@ class TestFindInstance(object):
60
66
  stub_listdir.return_value = [ref_name]
61
67
  monkeypatch.setattr(os, 'listdir', stub_listdir)
62
68
 
69
+ stub_data_dir = mock.Mock()
70
+ stub_data_dir.return_value = dotdict({"DATA_DIR": self.conf.DATA_DIR})
71
+ monkeypatch.setattr(config, 'get_config', stub_data_dir)
72
+
63
73
  test_instance = instance.find_instance(ref_name, ref_image)
64
74
 
65
75
  assert test_instance.path == ref_path
@@ -0,0 +1,18 @@
1
+ # NOTE: if you update version, *make sure* to also update `docs/source/conf.py`
2
+ __version__ = "0.10.0"
3
+
4
+ import signal
5
+ import sys
6
+ import threading
7
+
8
+
9
+ def sigterm_handler(_signo, _stack_frame):
10
+ # A call to sys.exit() is translated into an exception so that clean-up handlers
11
+ # (finally clauses of try statements) can be executed, and so that a debugger can
12
+ # execute a script without running the risk of losing control.
13
+ sys.exit(0)
14
+
15
+
16
+
17
+ if threading.current_thread() is threading.main_thread():
18
+ signal.signal(signal.SIGTERM, sigterm_handler)