Merge into master

This commit is contained in:
Ahmed Bilal 2019-09-03 18:01:40 +02:00
commit 4a3c81852a
12 changed files with 18 additions and 364 deletions

9
schemas.py Normal file → Executable file
View file

@ -4,18 +4,15 @@ from common_fields import Field, VmUUIDField, SpecsField
from ucloud_common.host import HostPool, HostStatus
from ucloud_common.vm import VmPool, VMStatus
from helper import check_otp
from etcd3_wrapper import Etcd3Wrapper
from config import etcd_client as client
from os.path import join
client = Etcd3Wrapper()
host_pool = HostPool(client, "/v1/host")
vm_pool = VmPool(client, "/v1/vm")
class BaseSchema(object):
class BaseSchema:
def __init__(self, data, fields=None):
_ = data
self.__errors = []
if fields is None:
self.fields = []
@ -118,7 +115,7 @@ class CreateImageSchema(BaseSchema):
image_stores = list(client.get_prefix("/v1/image_store/"))
image_store = next(filter(lambda s: json.loads(s.value)["name"] == self.image_store.value,
image_stores))
image_stores), None)
if not image_store:
self.add_error(f"Store '{self.image_store.value}' does not exists")