This commit is contained in:
ahmadbilalkhalid 2019-09-12 20:55:25 +05:00
parent 3f406799db
commit ec032ed0db
9 changed files with 544 additions and 103 deletions

0
.gitmodules vendored
View file

View file

@ -12,12 +12,9 @@ python-decouple = "*"
requests = "*" requests = "*"
flask = "*" flask = "*"
flask-restful = "*" flask-restful = "*"
grpcio = "*" etcd3-wrapper = "*"
etcd3 = "*"
gunicorn = "*"
bitmath = "*" bitmath = "*"
pylint = "*" ucloud-common = "*"
transitions = "*"
[requires] [requires]
python_version = "3.7" python_version = "3.5"

452
Pipfile.lock generated Normal file
View file

@ -0,0 +1,452 @@
{
"_meta": {
"hash": {
"sha256": "a32eccf12e5409ef28a7acce387e6e990d975fe3e5cbf94c0ae56ee68181cdfb"
},
"pipfile-spec": 6,
"requires": {
"python_version": "3.5"
},
"sources": [
{
"name": "pypi",
"url": "https://pypi.org/simple",
"verify_ssl": true
}
]
},
"default": {
"aniso8601": {
"hashes": [
"sha256:529dcb1f5f26ee0df6c0a1ee84b7b27197c3c50fc3a6321d66c544689237d072",
"sha256:c033f63d028b9a58e3ab0c2c7d0532ab4bfa7452bfc788fbfe3ddabd327b181a"
],
"version": "==8.0.0"
},
"bitmath": {
"hashes": [
"sha256:293325f01e65defe966853111df11d39215eb705a967cb115851da8c4cfa3eb8"
],
"index": "pypi",
"version": "==1.3.3.1"
},
"certifi": {
"hashes": [
"sha256:e4f3620cfea4f83eedc95b24abd9cd56f3c4b146dd0177e83a21b4eb49e21e50",
"sha256:fd7c7c74727ddcf00e9acd26bba8da604ffec95bf1c2144e67aff7a8b50e6cef"
],
"version": "==2019.9.11"
},
"chardet": {
"hashes": [
"sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae",
"sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691"
],
"version": "==3.0.4"
},
"click": {
"hashes": [
"sha256:2335065e6395b9e67ca716de5f7526736bfa6ceead690adf616d925bdc622b13",
"sha256:5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7"
],
"version": "==7.0"
},
"etcd3": {
"hashes": [
"sha256:25a524b9f032c6631ff0097532907dea81243eaa63c3744510fd1598cc4e0e87"
],
"version": "==0.10.0"
},
"etcd3-wrapper": {
"hashes": [
"sha256:0296a4cc7c75c6c432f54e95699271894716e99048c9987df55b6885ed9d5d07",
"sha256:8c4e90593ea6586978f0fbd484e46fd7d8554e06cb9804d34805a1f15a046b63"
],
"index": "pypi",
"version": "==0.5.2"
},
"flask": {
"hashes": [
"sha256:13f9f196f330c7c2c5d7a5cf91af894110ca0215ac051b5844701f2bfd934d52",
"sha256:45eb5a6fd193d6cf7e0cf5d8a5b31f83d5faae0293695626f539a823e93b13f6"
],
"index": "pypi",
"version": "==1.1.1"
},
"flask-restful": {
"hashes": [
"sha256:ecd620c5cc29f663627f99e04f17d1f16d095c83dc1d618426e2ad68b03092f8",
"sha256:f8240ec12349afe8df1db168ea7c336c4e5b0271a36982bff7394f93275f2ca9"
],
"index": "pypi",
"version": "==0.3.7"
},
"grpcio": {
"hashes": [
"sha256:1303578092f1f6e4bfbc354c04ac422856c393723d3ffa032fff0f7cb5cfd693",
"sha256:229c6b313cd82bec8f979b059d87f03cc1a48939b543fe170b5a9c5cf6a6bc69",
"sha256:3cd3d99a8b5568d0d186f9520c16121a0f2a4bcad8e2b9884b76fb88a85a7774",
"sha256:41cfb222db358227521f9638a6fbc397f310042a4db5539a19dea01547c621cd",
"sha256:43330501660f636fd6547d1e196e395cd1e2c2ae57d62219d6184a668ffebda0",
"sha256:45d7a2bd8b4f25a013296683f4140d636cdbb507d94a382ea5029a21e76b1648",
"sha256:47dc935658a13b25108823dabd010194ddea9610357c5c1ef1ad7b3f5157ebee",
"sha256:480aa7e2b56238badce0b9413a96d5b4c90c3bfbd79eba5a0501e92328d9669e",
"sha256:4a0934c8b0f97e1d8c18e76c45afc0d02d33ab03125258179f2ac6c7a13f3626",
"sha256:5624dab19e950f99e560400c59d87b685809e4cfcb2c724103f1ab14c06071f7",
"sha256:60515b1405bb3dadc55e6ca99429072dad3e736afcf5048db5452df5572231ff",
"sha256:610f97ebae742a57d336a69b09a9c7d7de1f62aa54aaa8adc635b38f55ba4382",
"sha256:64ea189b2b0859d1f7b411a09185028744d494ef09029630200cc892e366f169",
"sha256:686090c6c1e09e4f49585b8508d0a31d58bc3895e4049ea55b197d1381e9f70f",
"sha256:7745c365195bb0605e3d47b480a2a4d1baa8a41a5fd0a20de5fa48900e2c886a",
"sha256:79491e0d2b77a1c438116bf9e5f9e2e04e78b78524615e2ce453eff62db59a09",
"sha256:825177dd4c601c487836b7d6b4ba268db59787157911c623ba59a7c03c8d3adc",
"sha256:8a060e1f72fb94eee8a035ed29f1201ce903ad14cbe27bda56b4a22a8abda045",
"sha256:90168cc6353e2766e47b650c963f21cfff294654b10b3a14c67e26a4e3683634",
"sha256:94b7742734bceeff6d8db5edb31ac844cb68fc7f13617eca859ff1b78bb20ba1",
"sha256:962aebf2dd01bbb2cdb64580e61760f1afc470781f9ecd5fe8f3d8dcd8cf4556",
"sha256:9c8d9eacdce840b72eee7924c752c31b675f8aec74790e08cff184a4ea8aa9c1",
"sha256:af5b929debc336f6bab9b0da6915f9ee5e41444012aed6a79a3c7e80d7662fdf",
"sha256:b9cdb87fc77e9a3eabdc42a512368538d648fa0760ad30cf97788076985c790a",
"sha256:c5e6380b90b389454669dc67d0a39fb4dc166416e01308fcddd694236b8329ef",
"sha256:d60c90fe2bfbee735397bf75a2f2c4e70c5deab51cd40c6e4fa98fae018c8db6",
"sha256:d8582c8b1b1063249da1588854251d8a91df1e210a328aeb0ece39da2b2b763b",
"sha256:ddbf86ba3aa0ad8fed2867910d2913ee237d55920b55f1d619049b3399f04efc",
"sha256:e46bc0664c5c8a0545857aa7a096289f8db148e7f9cca2d0b760113e8994bddc",
"sha256:f6437f70ec7fed0ca3a0eef1146591bb754b418bb6c6b21db74f0333d624e135",
"sha256:f71693c3396530c6b00773b029ea85e59272557e9bd6077195a6593e4229892a",
"sha256:f79f7455f8fbd43e8e9d61914ecf7f48ba1c8e271801996fef8d6a8f3cc9f39f"
],
"version": "==1.23.0"
},
"idna": {
"hashes": [
"sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407",
"sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c"
],
"version": "==2.8"
},
"itsdangerous": {
"hashes": [
"sha256:321b033d07f2a4136d3ec762eac9f16a10ccd60f53c0c91af90217ace7ba1f19",
"sha256:b12271b2047cb23eeb98c8b5622e2e5c5e9abd9784a153e9d8ef9cb4dd09d749"
],
"version": "==1.1.0"
},
"jinja2": {
"hashes": [
"sha256:065c4f02ebe7f7cf559e49ee5a95fb800a9e4528727aec6f24402a5374c65013",
"sha256:14dd6caf1527abb21f08f86c784eac40853ba93edb79552aa1e4b8aef1b61c7b"
],
"version": "==2.10.1"
},
"markupsafe": {
"hashes": [
"sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473",
"sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161",
"sha256:09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235",
"sha256:1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5",
"sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff",
"sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b",
"sha256:43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1",
"sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e",
"sha256:500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183",
"sha256:535f6fc4d397c1563d08b88e485c3496cf5784e927af890fb3c3aac7f933ec66",
"sha256:62fe6c95e3ec8a7fad637b7f3d372c15ec1caa01ab47926cfdf7a75b40e0eac1",
"sha256:6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1",
"sha256:717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e",
"sha256:79855e1c5b8da654cf486b830bd42c06e8780cea587384cf6545b7d9ac013a0b",
"sha256:7c1699dfe0cf8ff607dbdcc1e9b9af1755371f92a68f706051cc8c37d447c905",
"sha256:88e5fcfb52ee7b911e8bb6d6aa2fd21fbecc674eadd44118a9cc3863f938e735",
"sha256:8defac2f2ccd6805ebf65f5eeb132adcf2ab57aa11fdf4c0dd5169a004710e7d",
"sha256:98c7086708b163d425c67c7a91bad6e466bb99d797aa64f965e9d25c12111a5e",
"sha256:9add70b36c5666a2ed02b43b335fe19002ee5235efd4b8a89bfcf9005bebac0d",
"sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c",
"sha256:ade5e387d2ad0d7ebf59146cc00c8044acbd863725f887353a10df825fc8ae21",
"sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2",
"sha256:b1282f8c00509d99fef04d8ba936b156d419be841854fe901d8ae224c59f0be5",
"sha256:b2051432115498d3562c084a49bba65d97cf251f5a331c64a12ee7e04dacc51b",
"sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6",
"sha256:c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f",
"sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f",
"sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7"
],
"version": "==1.1.1"
},
"protobuf": {
"hashes": [
"sha256:00a1b0b352dc7c809749526d1688a64b62ea400c5b05416f93cfb1b11a036295",
"sha256:01acbca2d2c8c3f7f235f1842440adbe01bbc379fa1cbdd80753801432b3fae9",
"sha256:0a795bca65987b62d6b8a2d934aa317fd1a4d06a6dd4df36312f5b0ade44a8d9",
"sha256:0ec035114213b6d6e7713987a759d762dd94e9f82284515b3b7331f34bfaec7f",
"sha256:31b18e1434b4907cb0113e7a372cd4d92c047ce7ba0fa7ea66a404d6388ed2c1",
"sha256:32a3abf79b0bef073c70656e86d5bd68a28a1fbb138429912c4fc07b9d426b07",
"sha256:55f85b7808766e5e3f526818f5e2aeb5ba2edcc45bcccede46a3ccc19b569cb0",
"sha256:64ab9bc971989cbdd648c102a96253fdf0202b0c38f15bd34759a8707bdd5f64",
"sha256:64cf847e843a465b6c1ba90fb6c7f7844d54dbe9eb731e86a60981d03f5b2e6e",
"sha256:917c8662b585470e8fd42f052661fc66d59fccaae450a60044307dcbf82a3335",
"sha256:afed9003d7f2be2c3df20f64220c30faec441073731511728a2cb4cab4cd46a6",
"sha256:bf8e05d638b585d1752c5a84247134a0350d3a8b73d3632489a014a9f6f1e758",
"sha256:d831b047bd69becaf64019a47179eb22118a50dd008340655266a906c69c6417",
"sha256:de2760583ed28749ff885789c1cbc6c9c06d6de92fc825740ab99deb2f25ea4d",
"sha256:eabc4cf1bc19689af8022ba52fd668564a8d96e0d08f3b4732d26a64255216a4",
"sha256:fcff6086c86fb1628d94ea455c7b9de898afc50378042927a59df8065a79a549"
],
"version": "==3.9.1"
},
"pyotp": {
"hashes": [
"sha256:c88f37fd47541a580b744b42136f387cdad481b560ef410c0d85c957eb2a2bc0",
"sha256:fc537e8acd985c5cbf51e11b7d53c42276fee017a73aec7c07380695671ca1a1"
],
"index": "pypi",
"version": "==2.3.0"
},
"python-decouple": {
"hashes": [
"sha256:1317df14b43efee4337a4aa02914bf004f010cd56d6c4bd894e6474ec8c4fe2d"
],
"index": "pypi",
"version": "==3.1"
},
"pytz": {
"hashes": [
"sha256:26c0b32e437e54a18161324a2fca3c4b9846b74a8dccddd843113109e1116b32",
"sha256:c894d57500a4cd2d5c71114aaab77dbab5eabd9022308ce5ac9bb93a60a6f0c7"
],
"version": "==2019.2"
},
"requests": {
"hashes": [
"sha256:11e007a8a2aa0323f5a921e9e6a2d7e4e67d9877e85773fba9ba6419025cbeb4",
"sha256:9cf5292fcd0f598c671cfc1e0d7d1a7f13bb8085e9a590f48c010551dc6c4b31"
],
"index": "pypi",
"version": "==2.22.0"
},
"six": {
"hashes": [
"sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c",
"sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73"
],
"version": "==1.12.0"
},
"tenacity": {
"hashes": [
"sha256:6a7511a59145c2e319b7d04ddd93c12d48cc3d3c8fa42c2846d33a620ee91f57",
"sha256:a4eb168dbf55ed2cae27e7c6b2bd48ab54dabaf294177d998330cf59f294c112"
],
"version": "==5.1.1"
},
"ucloud-common": {
"hashes": [
"sha256:2b2f10f92c68faec04f55f532c9b0d4e055f208a4f7a5b321ebc4b75dea6cc7e",
"sha256:66e79854bd42c536f8435675627c86e9a79a62b14baea1fa827b476d7652cf8a"
],
"index": "pypi",
"version": "==0.5.0"
},
"urllib3": {
"hashes": [
"sha256:b246607a25ac80bedac05c6f282e3cdaf3afb65420fd024ac94435cabe6e18d1",
"sha256:dbe59173209418ae49d485b87d1681aefa36252ee85884c31346debd19463232"
],
"version": "==1.25.3"
},
"werkzeug": {
"hashes": [
"sha256:00d32beac38fcd48d329566f80d39f10ec2ed994efbecfb8dd4b320062d05902",
"sha256:0a24d43be6a7dce81bae05292356176d6c46d63e42a0dd3f9504b210a9cfaa43"
],
"version": "==0.15.6"
}
},
"develop": {
"astroid": {
"hashes": [
"sha256:6560e1e1749f68c64a4b5dee4e091fce798d2f0d84ebe638cf0e0585a343acf4",
"sha256:b65db1bbaac9f9f4d190199bb8680af6f6f84fd3769a5ea883df8a91fe68b4c4"
],
"version": "==2.2.5"
},
"dodgy": {
"hashes": [
"sha256:65e13cf878d7aff129f1461c13cb5fd1bb6dfe66bb5327e09379c3877763280c"
],
"version": "==0.1.9"
},
"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"
},
"pep8-naming": {
"hashes": [
"sha256:1b419fa45b68b61cd8c5daf4e0c96d28915ad14d3d5f35fcc1e7e95324a33a2e",
"sha256:4eedfd4c4b05e48796f74f5d8628c068ff788b9c2b08471ad408007fc6450e5a"
],
"version": "==0.4.1"
},
"prospector": {
"hashes": [
"sha256:aba551e53dc1a5a432afa67385eaa81d7b4cf4c162dc1a4d0ee00b3a0712ad90"
],
"index": "pypi",
"version": "==1.1.7"
},
"pycodestyle": {
"hashes": [
"sha256:cbc619d09254895b0d12c2c691e237b2e91e9b2ecf5e84c26b35400f93dcfb83",
"sha256:cbfca99bd594a10f674d0cd97a3d802a1fdef635d4361e1a2658de47ed261e3a"
],
"version": "==2.4.0"
},
"pydocstyle": {
"hashes": [
"sha256:04c84e034ebb56eb6396c820442b8c4499ac5eb94a3bda88951ac3dc519b6058",
"sha256:66aff87ffe34b1e49bff2dd03a88ce6843be2f3346b0c9814410d34987fbab59"
],
"version": "==4.0.1"
},
"pyflakes": {
"hashes": [
"sha256:08bd6a50edf8cffa9fa09a463063c425ecaaf10d1eb0335a7e8b1401aef89e6f",
"sha256:8d616a382f243dbf19b54743f280b80198be0bca3a5396f1d2e1fca6223e8805"
],
"version": "==1.6.0"
},
"pylint": {
"hashes": [
"sha256:5d77031694a5fb97ea95e828c8d10fc770a1df6eb3906067aaed42201a8a6a09",
"sha256:723e3db49555abaf9bf79dc474c6b9e2935ad82230b10c1138a71ea41ac0fff1"
],
"version": "==2.3.1"
},
"pylint-celery": {
"hashes": [
"sha256:41e32094e7408d15c044178ea828dd524beedbdbe6f83f712c5e35bde1de4beb"
],
"version": "==0.3"
},
"pylint-django": {
"hashes": [
"sha256:75c69d1ec2275918c37f175976da20e2f1e1e62e067098a685cd263ffa833dfd",
"sha256:c7cb6384ea7b33ea77052a5ae07358c10d377807390ef27b2e6ff997303fadb7"
],
"version": "==2.0.10"
},
"pylint-flask": {
"hashes": [
"sha256:f4d97de2216bf7bfce07c9c08b166e978fe9f2725de2a50a9845a97de7e31517"
],
"version": "==0.6"
},
"pylint-plugin-utils": {
"hashes": [
"sha256:8d9e31d5ea8b7b0003e1f0f136b44a5235896a32e47c5bc2ef1143e9f6ba0b74"
],
"version": "==0.5"
},
"pyyaml": {
"hashes": [
"sha256:0113bc0ec2ad727182326b61326afa3d1d8280ae1122493553fd6f4397f33df9",
"sha256:01adf0b6c6f61bd11af6e10ca52b7d4057dd0be0343eb9283c878cf3af56aee4",
"sha256:5124373960b0b3f4aa7df1707e63e9f109b5263eca5976c66e08b1c552d4eaf8",
"sha256:5ca4f10adbddae56d824b2c09668e91219bb178a1eee1faa56af6f99f11bf696",
"sha256:7907be34ffa3c5a32b60b95f4d95ea25361c951383a894fec31be7252b2b6f34",
"sha256:7ec9b2a4ed5cad025c2278a1e6a19c011c80a3caaac804fd2d329e9cc2c287c9",
"sha256:87ae4c829bb25b9fe99cf71fbb2140c448f534e24c998cc60f39ae4f94396a73",
"sha256:9de9919becc9cc2ff03637872a440195ac4241c80536632fffeb6a1e25a74299",
"sha256:a5a85b10e450c66b49f98846937e8cfca1db3127a9d5d1e31ca45c3d0bef4c5b",
"sha256:b0997827b4f6a7c286c01c5f60384d218dca4ed7d9efa945c3e1aa623d5709ae",
"sha256:b631ef96d3222e62861443cc89d6563ba3eeb816eeb96b2629345ab795e53681",
"sha256:bf47c0607522fdbca6c9e817a6e81b08491de50f3766a7a0e6a5be7905961b41",
"sha256:f81025eddd0327c7d4cfe9b62cf33190e1e736cc6e97502b3ec425f574b3e7a8"
],
"version": "==5.1.2"
},
"requirements-detector": {
"hashes": [
"sha256:9fbc4b24e8b7c3663aff32e3eba34596848c6b91bd425079b386973bd8d08931"
],
"version": "==0.6"
},
"setoptconf": {
"hashes": [
"sha256:5b0b5d8e0077713f5d5152d4f63be6f048d9a1bb66be15d089a11c898c3cf49c"
],
"version": "==0.2.0"
},
"six": {
"hashes": [
"sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c",
"sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73"
],
"version": "==1.12.0"
},
"snowballstemmer": {
"hashes": [
"sha256:713e53b79cbcf97bc5245a06080a33d54a77e7cce2f789c835a143bcdb5c033e"
],
"version": "==1.9.1"
},
"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"
}
}
}

View file

@ -3,31 +3,10 @@
## Installation ## Installation
**Make sure you have Python >= 3.6 and Pipenv installed.** **Make sure you have Python >= 3.5 and Pipenv installed.**
1. Clone the repository and `cd` into it. 1. Clone the repository and `cd` into it.
2. Run the following commands 2. Run the following commands
- `pipenv install` - `pipenv install`
- `pipenv shell` - `pipenv shell`
- `python main.py` - `python main.py`
## Endpoints
### Create VM
To Create VM send a `POST` request at `/vm/create` with JSON body.
An Example JSON Request Body is shown below
```json
{
"name": "username",
"realm": "user realm",
"seed": "user seed",
"specs": {
"cpu": 16,
"ram": 256,
"hdd": "2TB",
"sdd": "256GB"
}
}
```

View file

@ -1,10 +1,14 @@
import os
from specs_parser import SpecsParser from specs_parser import SpecsParser
from config import etcd_client as client from config import etcd_client as client
from config import VM_PREFIX
specs_parser = SpecsParser(exceptional_devices=["cpu"]) specs_parser = SpecsParser(exceptional_devices=["cpu"])
class Field(object): class Field:
def __init__(self, _name, _type, _value=None): def __init__(self, _name, _type, _value=None):
self.name = _name self.name = _name
self.value = _value self.value = _value
@ -16,10 +20,10 @@ class Field(object):
def is_valid(self): def is_valid(self):
if self.value == KeyError: if self.value == KeyError:
self.add_error(f"'{self.name}' field is a required field") self.add_error("'{}' field is a required field".format(self.name))
else: else:
if not isinstance(self.value, self.type): if not isinstance(self.value, self.type):
self.add_error(f"Incorrect Type for '{self.name}' field") self.add_error("Incorrect Type for '{}' field".format(self.name))
else: else:
self.validation() self.validation()
@ -43,9 +47,9 @@ class VmUUIDField(Field):
self.validation = self.vm_uuid_validation self.validation = self.vm_uuid_validation
def vm_uuid_validation(self): def vm_uuid_validation(self):
r = client.get(f"/v1/vm/{self.uuid}") r = client.get(os.path.join(VM_PREFIX, self.uuid))
if not r: if not r:
self.add_error(f"VM with uuid {self.uuid} does not exists") self.add_error("VM with uuid {} does not exists".format(self.uuid))
class SpecsField(Field): class SpecsField(Field):
@ -59,4 +63,4 @@ class SpecsField(Field):
def specs_validation(self): def specs_validation(self):
if not specs_parser.transform_specs(self.specs): if not specs_parser.transform_specs(self.specs):
self.add_error("Invalid unit - " self.add_error("Invalid unit - "
f"Please use following units {specs_parser.get_allowed_units()}") "Please use following units {}".format(specs_parser.get_allowed_units()))

View file

@ -13,5 +13,11 @@ logging.basicConfig(
WITHOUT_CEPH = config("WITHOUT_CEPH", False, cast=bool) WITHOUT_CEPH = config("WITHOUT_CEPH", False, cast=bool)
VM_PREFIX = config("VM_PREFIX")
HOST_PREFIX = config("HOST_PREFIX")
REQUEST_PREFIX = config("REQUEST_PREFIX")
FILE_PREFIX = config("FILE_PREFIX")
IMAGE_PREFIX = config("IMAGE_PREFIX")
IMAGE_STORE_PREFIX = config("IMAGE_STORE_PREFIX")
etcd_client = Etcd3Wrapper(host=config("ETCD_URL")) etcd_client = Etcd3Wrapper(host=config("ETCD_URL"))

View file

@ -1,7 +1,10 @@
import json import json
from uuid import uuid4 import os
from config import etcd_client as client
from uuid import uuid4
from config import etcd_client as client
from config import IMAGE_STORE_PREFIX
data = { data = {
"is_public": True, "is_public": True,
@ -16,6 +19,6 @@ data = {
} }
client.put( client.put(
f"/v1/image_store/{uuid4().hex}", os.path.join(IMAGE_STORE_PREFIX, uuid4().hex),
json.dumps(data), json.dumps(data),
) )

69
main.py
View file

@ -6,16 +6,21 @@ import json
import subprocess import subprocess
import os import os
from uuid import uuid4
from flask import Flask, request from flask import Flask, request
from flask_restful import Resource, Api from flask_restful import Resource, Api
from uuid import uuid4
from os.path import join
from config import etcd_client as client
from config import WITHOUT_CEPH, logging
from ucloud_common.vm import VmPool, VMStatus from ucloud_common.vm import VmPool, VMStatus
from ucloud_common.host import HostPool from ucloud_common.host import HostPool
from ucloud_common.request import RequestEntry, RequestPool, RequestType from ucloud_common.request import (RequestEntry,
RequestPool,
RequestType)
from config import etcd_client as client
from config import (WITHOUT_CEPH, VM_PREFIX,
HOST_PREFIX, REQUEST_PREFIX,
FILE_PREFIX, IMAGE_PREFIX,
logging)
from schemas import (CreateVMSchema, VMStatusSchema, from schemas import (CreateVMSchema, VMStatusSchema,
CreateImageSchema, VmActionSchema, CreateImageSchema, VmActionSchema,
OTPSchema, CreateHostSchema, OTPSchema, CreateHostSchema,
@ -24,9 +29,9 @@ from schemas import (CreateVMSchema, VMStatusSchema,
app = Flask(__name__) app = Flask(__name__)
api = Api(app) api = Api(app)
vm_pool = VmPool(client, "/v1/vm") VM_POOL = VmPool(client, VM_PREFIX)
host_pool = HostPool(client, "/v1/host") HOST_POOL = HostPool(client, HOST_PREFIX)
request_pool = RequestPool(client, "/v1/request") REQUEST_POOL = RequestPool(client, REQUEST_PREFIX)
class CreateVM(Resource): class CreateVM(Resource):
@ -35,10 +40,8 @@ class CreateVM(Resource):
data = request.json data = request.json
validator = CreateVMSchema(data) validator = CreateVMSchema(data)
if validator.is_valid(): if validator.is_valid():
# Create VM Entry under /v1/vm/
# TODO: !!!Generate Mac Address on creation of VM
vm_uuid = uuid4().hex vm_uuid = uuid4().hex
vm_key = f"/v1/vm/{vm_uuid}" vm_key = os.path.join(VM_PREFIX, vm_uuid)
vm_entry = { vm_entry = {
"owner": data["name"], "owner": data["name"],
"specs": data["specs"], "specs": data["specs"],
@ -53,10 +56,9 @@ class CreateVM(Resource):
# Create ScheduleVM Request # Create ScheduleVM Request
r = RequestEntry.from_scratch(type=RequestType.ScheduleVM, r = RequestEntry.from_scratch(type=RequestType.ScheduleVM,
uuid=vm_uuid) uuid=vm_uuid)
request_pool.put(r) REQUEST_POOL.put(r)
return {"message": "VM Creation Queued"}, 200 return {"message": "VM Creation Queued"}, 200
else:
return validator.get_errors(), 400 return validator.get_errors(), 400
@ -66,7 +68,7 @@ class VmStatus(Resource):
data = request.json data = request.json
validator = VMStatusSchema(data) validator = VMStatusSchema(data)
if validator.is_valid(): if validator.is_valid():
vm = vm_pool.get(f"/v1/vm/{data['uuid']}") vm = VM_POOL.get(os.path.join(VM_PREFIX, data['uuid']))
return str(vm) return str(vm)
else: else:
return validator.get_errors(), 400 return validator.get_errors(), 400
@ -78,7 +80,7 @@ class CreateImage(Resource):
data = request.json data = request.json
validator = CreateImageSchema(data) validator = CreateImageSchema(data)
if validator.is_valid(): if validator.is_valid():
file_entry = client.get(f"/v1/file/{data['uuid']}") file_entry = client.get(os.path.join(FILE_PREFIX, data['uuid']))
file_entry_value = json.loads(file_entry.value) file_entry_value = json.loads(file_entry.value)
image_entry_json = { image_entry_json = {
@ -89,21 +91,19 @@ class CreateImage(Resource):
"store_name": data["image_store"], "store_name": data["image_store"],
"visibility": "public", "visibility": "public",
} }
client.put(f"/v1/image/{data['uuid']}", json.dumps(image_entry_json)) client.put(os.path.join(IMAGE_PREFIX, data['uuid']), json.dumps(image_entry_json))
return {"message": "Image successfully created"} return {"message": "Image successfully created"}
else:
return validator.get_errors(), 400 return validator.get_errors(), 400
class ListPublicImages(Resource): class ListPublicImages(Resource):
@staticmethod @staticmethod
def get(): def get():
images = client.get_prefix("/v1/image/") images = client.get_prefix(IMAGE_PREFIX)
r = {} r = {}
for image in images: for image in images:
r[image.key.split("/")[-1]] = json.loads(image.value) r[image.key.split("/")[-1]] = json.loads(image.value)
return r, 200 return r, 200
@ -114,12 +114,12 @@ class VMAction(Resource):
validator = VmActionSchema(data) validator = VmActionSchema(data)
if validator.is_valid(): if validator.is_valid():
vm_entry = vm_pool.get(f"/v1/vm/{data['uuid']}") vm_entry = VM_POOL.get(os.path.join(VM_PREFIX, data['uuid']))
action = data["action"] action = data["action"]
if action == "start": if action == "start":
vm_entry.status = VMStatus.requested_start vm_entry.status = VMStatus.requested_start
vm_pool.put(vm_entry) VM_POOL.put(vm_entry)
action = "schedule" action = "schedule"
if action == "delete" and vm_entry.hostname == "": if action == "delete" and vm_entry.hostname == "":
@ -143,11 +143,11 @@ class VMAction(Resource):
client.client.delete(vm_entry.key) client.client.delete(vm_entry.key)
return {"message": "VM successfully deleted"} return {"message": "VM successfully deleted"}
r = RequestEntry.from_scratch(type=f"{action.title()}VM", r = RequestEntry.from_scratch(type="{}VM".format(action.title()),
uuid=data['uuid'], uuid=data['uuid'],
hostname=vm_entry.hostname) hostname=vm_entry.hostname)
request_pool.put(r) REQUEST_POOL.put(r)
return {"message": f"VM {action.title()} Queued"}, 200 return {"message": "VM {} Queued".format(action.title())}, 200
else: else:
return validator.get_errors(), 400 return validator.get_errors(), 400
@ -159,14 +159,14 @@ class VMMigration(Resource):
validator = VmMigrationSchema(data) validator = VmMigrationSchema(data)
if validator.is_valid(): if validator.is_valid():
vm = vm_pool.get(data['uuid']) vm = VM_POOL.get(data['uuid'])
r = RequestEntry.from_scratch(type=RequestType.ScheduleVM, r = RequestEntry.from_scratch(type=RequestType.ScheduleVM,
uuid=vm.uuid, uuid=vm.uuid,
destination=join("/v1/host", data["destination"]), destination=os.path.join(HOST_PREFIX, data["destination"]),
migration=True) migration=True)
request_pool.put(r) REQUEST_POOL.put(r)
return {"message": f"VM Migration Initialization Queued"}, 200 return {"message": "VM Migration Initialization Queued"}, 200
else: else:
return validator.get_errors(), 400 return validator.get_errors(), 400
@ -178,7 +178,7 @@ class ListUserVM(Resource):
validator = OTPSchema(data) validator = OTPSchema(data)
if validator.is_valid(): if validator.is_valid():
vms = client.get_prefix(f"/v1/vm/", value_in_json=True) vms = client.get_prefix(VM_PREFIX, value_in_json=True)
if vms: if vms:
return_vms = [] return_vms = []
user_vms = list(filter(lambda v: v.value["owner"] == data["name"], vms)) user_vms = list(filter(lambda v: v.value["owner"] == data["name"], vms))
@ -205,8 +205,7 @@ class ListUserFiles(Resource):
validator = OTPSchema(data) validator = OTPSchema(data)
if validator.is_valid(): if validator.is_valid():
files = client.get_prefix(f"/v1/file/", value_in_json=True) files = client.get_prefix(FILE_PREFIX, value_in_json=True)
if files:
return_files = [] return_files = []
user_files = list(filter(lambda f: f.value["owner"] == data["name"], files)) user_files = list(filter(lambda f: f.value["owner"] == data["name"], files))
for file in user_files: for file in user_files:
@ -217,8 +216,6 @@ class ListUserFiles(Resource):
} }
) )
return {"message": return_files}, 200 return {"message": return_files}, 200
else:
return {"message": "No File found"}, 404
else: else:
return validator.get_errors(), 400 return validator.get_errors(), 400
@ -229,7 +226,7 @@ class CreateHost(Resource):
data = request.json data = request.json
validator = CreateHostSchema(data) validator = CreateHostSchema(data)
if validator.is_valid(): if validator.is_valid():
host_key = f"/v1/host/{uuid4().hex}" host_key = os.path.join(HOST_PREFIX, uuid4().hex)
host_entry = { host_entry = {
"specs": data["specs"], "specs": data["specs"],
"hostname": data["hostname"], "hostname": data["hostname"],
@ -246,7 +243,7 @@ class CreateHost(Resource):
class ListHost(Resource): class ListHost(Resource):
@staticmethod @staticmethod
def get(): def get():
hosts = host_pool.hosts hosts = HOST_POOL.hosts
r = {host.key: {"status": host.status, "specs": host.specs, "hostname": host.hostname} for host in hosts} r = {host.key: {"status": host.status, "specs": host.specs, "hostname": host.hostname} for host in hosts}
return r, 200 return r, 200

View file

@ -1,18 +1,22 @@
import json import json
import os
from common_fields import Field, VmUUIDField, SpecsField
from ucloud_common.host import HostPool, HostStatus from ucloud_common.host import HostPool, HostStatus
from ucloud_common.vm import VmPool, VMStatus from ucloud_common.vm import VmPool, VMStatus
from common_fields import Field, VmUUIDField, SpecsField
from helper import check_otp from helper import check_otp
from config import etcd_client as client from config import etcd_client as client
from os.path import join from config import (HOST_PREFIX, VM_PREFIX, IMAGE_PREFIX,
FILE_PREFIX, IMAGE_STORE_PREFIX)
host_pool = HostPool(client, "/v1/host") HOST_POOL = HostPool(client, HOST_PREFIX)
vm_pool = VmPool(client, "/v1/vm") VM_POOL = VmPool(client, VM_PREFIX)
class BaseSchema: class BaseSchema:
def __init__(self, data, fields=None): def __init__(self, data, fields=None):
_ = data # suppress linter warning
self.__errors = [] self.__errors = []
if fields is None: if fields is None:
self.fields = [] self.fields = []
@ -62,8 +66,7 @@ class OTPSchema(BaseSchema):
super().__init__(data=data, fields=_fields) super().__init__(data=data, fields=_fields)
def validation(self): def validation(self):
rc = check_otp(self.name.value, self.realm.value, self.token.value) if check_otp(self.name.value, self.realm.value, self.token.value) != 200:
if rc != 200:
self.add_error("Wrong Credentials") self.add_error("Wrong Credentials")
@ -78,7 +81,7 @@ class CreateVMSchema(OTPSchema):
super().__init__(data=data, fields=fields) super().__init__(data=data, fields=fields)
def image_uuid_validation(self): def image_uuid_validation(self):
images = client.get_prefix("/v1/image/") images = client.get_prefix(IMAGE_PREFIX)
if self.image_uuid.value not in [i.key.split("/")[-1] for i in images]: if self.image_uuid.value not in [i.key.split("/")[-1] for i in images]:
self.add_error("Image UUID not valid") self.add_error("Image UUID not valid")
@ -96,7 +99,7 @@ class VMStatusSchema(BaseSchema):
class CreateImageSchema(BaseSchema): class CreateImageSchema(BaseSchema):
def __init__(self, data): def __init__(self, data):
# Fields # Fields
self.uuid: Field = Field("uuid", str, data.get("uuid", KeyError)) self.uuid = Field("uuid", str, data.get("uuid", KeyError))
self.name = Field("name", str, data.get("name", KeyError)) self.name = Field("name", str, data.get("name", KeyError))
self.image_store = Field("image_store", str, data.get("image_store", KeyError)) self.image_store = Field("image_store", str, data.get("image_store", KeyError))
@ -109,17 +112,17 @@ class CreateImageSchema(BaseSchema):
super().__init__(data, fields) super().__init__(data, fields)
def file_uuid_validation(self): def file_uuid_validation(self):
file_entry = client.get(f"/v1/file/{self.uuid.value}") file_entry = client.get(os.path.join(FILE_PREFIX, self.uuid.value))
if file_entry is None: if file_entry is None:
self.add_error(f"Image File with uuid '{self.uuid.value}' Not Found") self.add_error("Image File with uuid '{}' Not Found".format(self.uuid.value))
def image_store_name_validation(self): def image_store_name_validation(self):
image_stores = list(client.get_prefix("/v1/image_store/")) image_stores = list(client.get_prefix(IMAGE_STORE_PREFIX))
image_store = next(filter(lambda s: json.loads(s.value)["name"] == self.image_store.value, image_store = next(filter(lambda s: json.loads(s.value)["name"] == self.image_store.value,
image_stores), None) image_stores), None)
if not image_store: if not image_store:
self.add_error(f"Store '{self.image_store.value}' does not exists") self.add_error("Store '{}' does not exists".format(self.image_store.value))
class VmActionSchema(OTPSchema): class VmActionSchema(OTPSchema):
@ -135,10 +138,10 @@ class VmActionSchema(OTPSchema):
def action_validation(self): def action_validation(self):
allowed_actions = ["start", "stop", "delete"] allowed_actions = ["start", "stop", "delete"]
if self.action.value not in allowed_actions: if self.action.value not in allowed_actions:
self.add_error(f"Invalid Action. Allowed Actions are {allowed_actions}") self.add_error("Invalid Action. Allowed Actions are {}".format(allowed_actions))
def validation(self): def validation(self):
vm = vm_pool.get(self.uuid.value) vm = VM_POOL.get(self.uuid.value)
if vm.value["owner"] != self.name.value: if vm.value["owner"] != self.name.value:
self.add_error("Invalid User") self.add_error("Invalid User")
@ -161,21 +164,21 @@ class VmMigrationSchema(OTPSchema):
def destination_validation(self): def destination_validation(self):
host_key = self.destination.value host_key = self.destination.value
host = host_pool.get(host_key) host = HOST_POOL.get(host_key)
if not host: if not host:
self.add_error(f"No Such Host ({self.destination.value}) exists") self.add_error("No Such Host ({}) exists".format(self.destination.value))
elif host.status != HostStatus.alive: elif host.status != HostStatus.alive:
self.add_error("Destination Host is dead") self.add_error("Destination Host is dead")
def validation(self): def validation(self):
vm = vm_pool.get(self.uuid.value) vm = VM_POOL.get(self.uuid.value)
if vm.owner != self.name.value: if vm.owner != self.name.value:
self.add_error("Invalid User") self.add_error("Invalid User")
if vm.status != VMStatus.running: if vm.status != VMStatus.running:
self.add_error("Can't migrate non-running VM") self.add_error("Can't migrate non-running VM")
if vm.hostname == join("/v1/host", self.destination.value): if vm.hostname == os.path.join(HOST_PREFIX, self.destination.value):
self.add_error("Destination host couldn't be same as Source Host") self.add_error("Destination host couldn't be same as Source Host")