Fix issues in naming and few other things
This commit is contained in:
parent
f919719b1e
commit
71279a968f
21 changed files with 274 additions and 281 deletions
|
|
@ -22,7 +22,7 @@ import bitmath
|
|||
from ucloud.common.host import HostStatus
|
||||
from ucloud.common.vm import VMStatus
|
||||
from ucloud.config import etcd_client, config, vm_pool, host_pool
|
||||
from . import helper
|
||||
from . import helper, logger
|
||||
from .common_fields import Field, VmUUIDField
|
||||
from .helper import check_otp, resolve_vm_name
|
||||
|
||||
|
|
@ -102,14 +102,14 @@ class CreateImageSchema(BaseSchema):
|
|||
super().__init__(data, fields)
|
||||
|
||||
def file_uuid_validation(self):
|
||||
file_entry = etcd_client.get(os.path.join(config['etcd']['FILE_PREFIX'], self.uuid.value))
|
||||
file_entry = etcd_client.get(os.path.join(config['etcd']['file_prefix'], self.uuid.value))
|
||||
if file_entry is None:
|
||||
self.add_error(
|
||||
"Image File with uuid '{}' Not Found".format(self.uuid.value)
|
||||
)
|
||||
|
||||
def image_store_name_validation(self):
|
||||
image_stores = list(etcd_client.get_prefix(config['etcd']['IMAGE_STORE_PREFIX']))
|
||||
image_stores = list(etcd_client.get_prefix(config['etcd']['image_store_prefix']))
|
||||
|
||||
image_store = next(
|
||||
filter(
|
||||
|
|
@ -220,6 +220,7 @@ class CreateVMSchema(OTPSchema):
|
|||
try:
|
||||
image_uuid = helper.resolve_image_name(self.image.value, etcd_client)
|
||||
except Exception as e:
|
||||
logger.exception("Cannot resolve image name = %s", self.image.value)
|
||||
self.add_error(str(e))
|
||||
else:
|
||||
self.image_uuid = image_uuid
|
||||
|
|
@ -235,7 +236,7 @@ class CreateVMSchema(OTPSchema):
|
|||
|
||||
if _network:
|
||||
for net in _network:
|
||||
network = etcd_client.get(os.path.join(config['etcd']['NETWORK_PREFIX'],
|
||||
network = etcd_client.get(os.path.join(config['etcd']['network_prefix'],
|
||||
self.name.value,
|
||||
net), value_in_json=True)
|
||||
if not network:
|
||||
|
|
@ -400,7 +401,7 @@ class VmMigrationSchema(OTPSchema):
|
|||
if vm.status != VMStatus.running:
|
||||
self.add_error("Can't migrate non-running VM")
|
||||
|
||||
if vm.hostname == os.path.join(config['etcd']['HOST_PREFIX'], self.destination.value):
|
||||
if vm.hostname == os.path.join(config['etcd']['host_prefix'], self.destination.value):
|
||||
self.add_error("Destination host couldn't be same as Source Host")
|
||||
|
||||
|
||||
|
|
@ -442,7 +443,7 @@ class CreateNetwork(OTPSchema):
|
|||
super().__init__(data, fields=fields)
|
||||
|
||||
def network_name_validation(self):
|
||||
network = etcd_client.get(os.path.join(config['etcd']['NETWORK_PREFIX'],
|
||||
network = etcd_client.get(os.path.join(config['etcd']['network_prefix'],
|
||||
self.name.value,
|
||||
self.network_name.value),
|
||||
value_in_json=True)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue