a
This commit is contained in:
		
					parent
					
						
							
								0a1cdf5bf0
							
						
					
				
			
			
				commit
				
					
						cd925bfb1e
					
				
			
		
					 4 changed files with 116 additions and 14 deletions
				
			
		
							
								
								
									
										6
									
								
								Pipfile
									
										
									
									
									
								
							
							
						
						
									
										6
									
								
								Pipfile
									
										
									
									
									
								
							|  | @ -4,11 +4,11 @@ url = "https://pypi.org/simple" | ||||||
| verify_ssl = true | verify_ssl = true | ||||||
| 
 | 
 | ||||||
| [dev-packages] | [dev-packages] | ||||||
|  | pylint = "*" | ||||||
| 
 | 
 | ||||||
| [packages] | [packages] | ||||||
| grpcio = "*" | etcd3-wrapper = "*" | ||||||
| etcd3 = "*" |  | ||||||
| python-decouple = "*" | python-decouple = "*" | ||||||
| 
 | 
 | ||||||
| [requires] | [requires] | ||||||
| python_version = "3.7" | python_version = "3.5" | ||||||
|  |  | ||||||
							
								
								
									
										102
									
								
								Pipfile.lock
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										102
									
								
								Pipfile.lock
									
										
									
										generated
									
									
									
								
							|  | @ -1,11 +1,11 @@ | ||||||
| { | { | ||||||
|     "_meta": { |     "_meta": { | ||||||
|         "hash": { |         "hash": { | ||||||
|             "sha256": "001ed819cce7626b2f7ea59352daad458c2fbd8730abbf1e64b42044b73f7aa8" |             "sha256": "213705549ed95daa6239b49d760360a81c905a618622dd206041bb4d2f62e6c8" | ||||||
|         }, |         }, | ||||||
|         "pipfile-spec": 6, |         "pipfile-spec": 6, | ||||||
|         "requires": { |         "requires": { | ||||||
|             "python_version": "3.7" |             "python_version": "3.5" | ||||||
|         }, |         }, | ||||||
|         "sources": [ |         "sources": [ | ||||||
|             { |             { | ||||||
|  | @ -20,9 +20,16 @@ | ||||||
|             "hashes": [ |             "hashes": [ | ||||||
|                 "sha256:25a524b9f032c6631ff0097532907dea81243eaa63c3744510fd1598cc4e0e87" |                 "sha256:25a524b9f032c6631ff0097532907dea81243eaa63c3744510fd1598cc4e0e87" | ||||||
|             ], |             ], | ||||||
|             "index": "pypi", |  | ||||||
|             "version": "==0.10.0" |             "version": "==0.10.0" | ||||||
|         }, |         }, | ||||||
|  |         "etcd3-wrapper": { | ||||||
|  |             "hashes": [ | ||||||
|  |                 "sha256:0296a4cc7c75c6c432f54e95699271894716e99048c9987df55b6885ed9d5d07", | ||||||
|  |                 "sha256:8c4e90593ea6586978f0fbd484e46fd7d8554e06cb9804d34805a1f15a046b63" | ||||||
|  |             ], | ||||||
|  |             "index": "pypi", | ||||||
|  |             "version": "==0.5.2" | ||||||
|  |         }, | ||||||
|         "grpcio": { |         "grpcio": { | ||||||
|             "hashes": [ |             "hashes": [ | ||||||
|                 "sha256:1303578092f1f6e4bfbc354c04ac422856c393723d3ffa032fff0f7cb5cfd693", |                 "sha256:1303578092f1f6e4bfbc354c04ac422856c393723d3ffa032fff0f7cb5cfd693", | ||||||
|  | @ -103,5 +110,92 @@ | ||||||
|             "version": "==5.1.1" |             "version": "==5.1.1" | ||||||
|         } |         } | ||||||
|     }, |     }, | ||||||
|     "develop": {} |     "develop": { | ||||||
|  |         "astroid": { | ||||||
|  |             "hashes": [ | ||||||
|  |                 "sha256:6560e1e1749f68c64a4b5dee4e091fce798d2f0d84ebe638cf0e0585a343acf4", | ||||||
|  |                 "sha256:b65db1bbaac9f9f4d190199bb8680af6f6f84fd3769a5ea883df8a91fe68b4c4" | ||||||
|  |             ], | ||||||
|  |             "version": "==2.2.5" | ||||||
|  |         }, | ||||||
|  |         "isort": { | ||||||
|  |             "hashes": [ | ||||||
|  |                 "sha256:54da7e92468955c4fceacd0c86bd0ec997b0e1ee80d97f67c35a78b719dccab1", | ||||||
|  |                 "sha256:6e811fcb295968434526407adb8796944f1988c5b65e8139058f2014cbe100fd" | ||||||
|  |             ], | ||||||
|  |             "version": "==4.3.21" | ||||||
|  |         }, | ||||||
|  |         "lazy-object-proxy": { | ||||||
|  |             "hashes": [ | ||||||
|  |                 "sha256:02b260c8deb80db09325b99edf62ae344ce9bc64d68b7a634410b8e9a568edbf", | ||||||
|  |                 "sha256:18f9c401083a4ba6e162355873f906315332ea7035803d0fd8166051e3d402e3", | ||||||
|  |                 "sha256:1f2c6209a8917c525c1e2b55a716135ca4658a3042b5122d4e3413a4030c26ce", | ||||||
|  |                 "sha256:2f06d97f0ca0f414f6b707c974aaf8829c2292c1c497642f63824119d770226f", | ||||||
|  |                 "sha256:616c94f8176808f4018b39f9638080ed86f96b55370b5a9463b2ee5c926f6c5f", | ||||||
|  |                 "sha256:63b91e30ef47ef68a30f0c3c278fbfe9822319c15f34b7538a829515b84ca2a0", | ||||||
|  |                 "sha256:77b454f03860b844f758c5d5c6e5f18d27de899a3db367f4af06bec2e6013a8e", | ||||||
|  |                 "sha256:83fe27ba321e4cfac466178606147d3c0aa18e8087507caec78ed5a966a64905", | ||||||
|  |                 "sha256:84742532d39f72df959d237912344d8a1764c2d03fe58beba96a87bfa11a76d8", | ||||||
|  |                 "sha256:874ebf3caaf55a020aeb08acead813baf5a305927a71ce88c9377970fe7ad3c2", | ||||||
|  |                 "sha256:9f5caf2c7436d44f3cec97c2fa7791f8a675170badbfa86e1992ca1b84c37009", | ||||||
|  |                 "sha256:a0c8758d01fcdfe7ae8e4b4017b13552efa7f1197dd7358dc9da0576f9d0328a", | ||||||
|  |                 "sha256:a4def978d9d28cda2d960c279318d46b327632686d82b4917516c36d4c274512", | ||||||
|  |                 "sha256:ad4f4be843dace866af5fc142509e9b9817ca0c59342fdb176ab6ad552c927f5", | ||||||
|  |                 "sha256:ae33dd198f772f714420c5ab698ff05ff900150486c648d29951e9c70694338e", | ||||||
|  |                 "sha256:b4a2b782b8a8c5522ad35c93e04d60e2ba7f7dcb9271ec8e8c3e08239be6c7b4", | ||||||
|  |                 "sha256:c462eb33f6abca3b34cdedbe84d761f31a60b814e173b98ede3c81bb48967c4f", | ||||||
|  |                 "sha256:fd135b8d35dfdcdb984828c84d695937e58cc5f49e1c854eb311c4d6aa03f4f1" | ||||||
|  |             ], | ||||||
|  |             "version": "==1.4.2" | ||||||
|  |         }, | ||||||
|  |         "mccabe": { | ||||||
|  |             "hashes": [ | ||||||
|  |                 "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42", | ||||||
|  |                 "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f" | ||||||
|  |             ], | ||||||
|  |             "version": "==0.6.1" | ||||||
|  |         }, | ||||||
|  |         "pylint": { | ||||||
|  |             "hashes": [ | ||||||
|  |                 "sha256:5d77031694a5fb97ea95e828c8d10fc770a1df6eb3906067aaed42201a8a6a09", | ||||||
|  |                 "sha256:723e3db49555abaf9bf79dc474c6b9e2935ad82230b10c1138a71ea41ac0fff1" | ||||||
|  |             ], | ||||||
|  |             "index": "pypi", | ||||||
|  |             "version": "==2.3.1" | ||||||
|  |         }, | ||||||
|  |         "six": { | ||||||
|  |             "hashes": [ | ||||||
|  |                 "sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c", | ||||||
|  |                 "sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73" | ||||||
|  |             ], | ||||||
|  |             "version": "==1.12.0" | ||||||
|  |         }, | ||||||
|  |         "typed-ast": { | ||||||
|  |             "hashes": [ | ||||||
|  |                 "sha256:18511a0b3e7922276346bcb47e2ef9f38fb90fd31cb9223eed42c85d1312344e", | ||||||
|  |                 "sha256:262c247a82d005e43b5b7f69aff746370538e176131c32dda9cb0f324d27141e", | ||||||
|  |                 "sha256:2b907eb046d049bcd9892e3076c7a6456c93a25bebfe554e931620c90e6a25b0", | ||||||
|  |                 "sha256:354c16e5babd09f5cb0ee000d54cfa38401d8b8891eefa878ac772f827181a3c", | ||||||
|  |                 "sha256:4e0b70c6fc4d010f8107726af5fd37921b666f5b31d9331f0bd24ad9a088e631", | ||||||
|  |                 "sha256:630968c5cdee51a11c05a30453f8cd65e0cc1d2ad0d9192819df9978984529f4", | ||||||
|  |                 "sha256:66480f95b8167c9c5c5c87f32cf437d585937970f3fc24386f313a4c97b44e34", | ||||||
|  |                 "sha256:71211d26ffd12d63a83e079ff258ac9d56a1376a25bc80b1cdcdf601b855b90b", | ||||||
|  |                 "sha256:95bd11af7eafc16e829af2d3df510cecfd4387f6453355188342c3e79a2ec87a", | ||||||
|  |                 "sha256:bc6c7d3fa1325a0c6613512a093bc2a2a15aeec350451cbdf9e1d4bffe3e3233", | ||||||
|  |                 "sha256:cc34a6f5b426748a507dd5d1de4c1978f2eb5626d51326e43280941206c209e1", | ||||||
|  |                 "sha256:d755f03c1e4a51e9b24d899561fec4ccaf51f210d52abdf8c07ee2849b212a36", | ||||||
|  |                 "sha256:d7c45933b1bdfaf9f36c579671fec15d25b06c8398f113dab64c18ed1adda01d", | ||||||
|  |                 "sha256:d896919306dd0aa22d0132f62a1b78d11aaf4c9fc5b3410d3c666b818191630a", | ||||||
|  |                 "sha256:ffde2fbfad571af120fcbfbbc61c72469e72f550d676c3342492a9dfdefb8f12" | ||||||
|  |             ], | ||||||
|  |             "markers": "implementation_name == 'cpython'", | ||||||
|  |             "version": "==1.4.0" | ||||||
|  |         }, | ||||||
|  |         "wrapt": { | ||||||
|  |             "hashes": [ | ||||||
|  |                 "sha256:565a021fd19419476b9362b05eeaa094178de64f8361e44468f9e9d7843901e1" | ||||||
|  |             ], | ||||||
|  |             "version": "==1.11.2" | ||||||
|  |         } | ||||||
|  |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -6,7 +6,7 @@ from decouple import config | ||||||
| BASE_PATH = config("BASE_DIR", "/var/www") | BASE_PATH = config("BASE_DIR", "/var/www") | ||||||
| WITHOUT_CEPH = config("WITHOUT_CEPH", False, cast=bool) | WITHOUT_CEPH = config("WITHOUT_CEPH", False, cast=bool) | ||||||
| ETCD_URL = config("ETCD_URL") | ETCD_URL = config("ETCD_URL") | ||||||
| 
 | IMAGE_PREFIX = config("IMAGE_PREFIX") | ||||||
| 
 | 
 | ||||||
| logging.basicConfig( | logging.basicConfig( | ||||||
|     level=logging.DEBUG, |     level=logging.DEBUG, | ||||||
|  |  | ||||||
							
								
								
									
										20
									
								
								main.py
									
										
									
									
									
								
							
							
						
						
									
										20
									
								
								main.py
									
										
									
									
									
								
							|  | @ -2,7 +2,9 @@ import os | ||||||
| import json | import json | ||||||
| import subprocess | import subprocess | ||||||
| 
 | 
 | ||||||
| from config import logging, client, BASE_PATH, WITHOUT_CEPH | from config import (logging, client, | ||||||
|  |                     BASE_PATH, WITHOUT_CEPH, | ||||||
|  |                     IMAGE_PREFIX) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| # If you are using WITHOUT_CEPH FLAG in .env | # If you are using WITHOUT_CEPH FLAG in .env | ||||||
|  | @ -13,7 +15,7 @@ if WITHOUT_CEPH and not os.path.isdir("/var/image"): | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| # We want to get images entries that requests images to be created | # We want to get images entries that requests images to be created | ||||||
| images = client.get_prefix("/v1/image/", value_in_json=True) | images = client.get_prefix(IMAGE_PREFIX, value_in_json=True) | ||||||
| images_to_be_created = filter(lambda im: im.value["status"] == "TO_BE_CREATED", images) | images_to_be_created = filter(lambda im: im.value["status"] == "TO_BE_CREATED", images) | ||||||
| 
 | 
 | ||||||
| for image in images_to_be_created: | for image in images_to_be_created: | ||||||
|  | @ -35,11 +37,17 @@ for image in images_to_be_created: | ||||||
|         # At least our basic data is available |         # At least our basic data is available | ||||||
| 
 | 
 | ||||||
|         qemu_img_info_command = ["qemu-img", "info", image_full_path] |         qemu_img_info_command = ["qemu-img", "info", image_full_path] | ||||||
|         qemu_img_convert_command = ["qemu-img", "convert", "-f", "qcow2", "-O", "raw", image_full_path, f"image.raw"] |         qemu_img_convert_command = ["qemu-img", "convert", "-f", "qcow2", | ||||||
|  |                                     "-O", "raw", image_full_path, "image.raw"] | ||||||
| 
 | 
 | ||||||
|         image_import_command = ["rbd", "import", "image.raw", f"{image_store_pool}/{image_uuid}"] |         image_import_command = ["rbd", "import", "image.raw", | ||||||
|         snapshot_creation_command = ["rbd", "snap", "create", f"{image_store_pool}/{image_uuid}@protected"] |                                 "{}/{}".format(image_store_pool, image_uuid)] | ||||||
|         snapshot_protect_command = ["rbd", "snap", "protect", f"{image_store_pool}/{image_uuid}@protected"] | 
 | ||||||
|  |         snapshot_creation_command = ["rbd", "snap", "create", | ||||||
|  |                                      "{}/{}@protected".format(image_store_pool, image_uuid)] | ||||||
|  | 
 | ||||||
|  |         snapshot_protect_command = ["rbd", "snap", "protect", | ||||||
|  |                                     "{}/{}@protected".format(image_store_pool, image_uuid)] | ||||||
| 
 | 
 | ||||||
|         if WITHOUT_CEPH: |         if WITHOUT_CEPH: | ||||||
|             image_import_command = ["mv", "image.raw", os.path.join("/var/image", image_uuid)] |             image_import_command = ["mv", "image.raw", os.path.join("/var/image", image_uuid)] | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue