Refactoring, VMM added, uncloud-host mostly new, migration is better now
This commit is contained in:
parent
cd9d4cb78c
commit
ba515f0b48
12 changed files with 423 additions and 364 deletions
|
|
@ -30,7 +30,7 @@ def generate_mac(uaa=False, multicast=False, oui=None, separator=':', byte_fmt='
|
|||
|
||||
|
||||
def create_dev(script, _id, dev, ip=None):
|
||||
command = [script, _id, dev]
|
||||
command = [script, str(_id), dev]
|
||||
if ip:
|
||||
command.append(ip)
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ class RequestType:
|
|||
class RequestEntry(SpecificEtcdEntryBase):
|
||||
|
||||
def __init__(self, e):
|
||||
self.destination_host_key = None
|
||||
self.type = None # type: str
|
||||
self.migration = None # type: bool
|
||||
self.destination = None # type: str
|
||||
|
|
|
|||
39
ucloud/common/schemas.py
Normal file
39
ucloud/common/schemas.py
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import bitmath
|
||||
|
||||
from marshmallow import fields, Schema
|
||||
|
||||
|
||||
class StorageUnit(fields.Field):
|
||||
def _serialize(self, value, attr, obj, **kwargs):
|
||||
return str(value)
|
||||
|
||||
def _deserialize(self, value, attr, data, **kwargs):
|
||||
return bitmath.parse_string_unsafe(value)
|
||||
|
||||
|
||||
class SpecsSchema(Schema):
|
||||
cpu = fields.Int()
|
||||
ram = StorageUnit()
|
||||
os_ssd = StorageUnit(data_key='os-ssd', attribute='os-ssd')
|
||||
hdd = fields.List(StorageUnit())
|
||||
|
||||
|
||||
class VMSchema(Schema):
|
||||
name = fields.Str()
|
||||
owner = fields.Str()
|
||||
owner_realm = fields.Str()
|
||||
specs = fields.Nested(SpecsSchema)
|
||||
status = fields.Str()
|
||||
log = fields.List(fields.Str())
|
||||
vnc_socket = fields.Str()
|
||||
image_uuid = fields.Str()
|
||||
hostname = fields.Str()
|
||||
metadata = fields.Dict()
|
||||
network = fields.List(fields.Tuple((fields.Str(), fields.Str(), fields.Int())))
|
||||
in_migration = fields.Bool()
|
||||
|
||||
|
||||
class NetworkSchema(Schema):
|
||||
_id = fields.Int(data_key='id', attribute='id')
|
||||
_type = fields.Str(data_key='type', attribute='type')
|
||||
ipv6 = fields.Str()
|
||||
|
|
@ -19,8 +19,8 @@ class ImageStorageHandler(ABC):
|
|||
|
||||
def import_image(self, image_src, image_dest, protect=False):
|
||||
"""Put an image at the destination
|
||||
:param src: An Image file
|
||||
:param dest: A path where :param src: is to be put.
|
||||
:param image_src: An Image file
|
||||
:param image_dest: A path where :param src: is to be put.
|
||||
:param protect: If protect is true then the dest is protect (readonly etc)
|
||||
The obj must exist on filesystem.
|
||||
"""
|
||||
|
|
@ -30,8 +30,8 @@ class ImageStorageHandler(ABC):
|
|||
def make_vm_image(self, image_path, path):
|
||||
"""Copy image from src to dest
|
||||
|
||||
:param src: A path
|
||||
:param dest: A path
|
||||
:param image_path: A path
|
||||
:param path: A path
|
||||
|
||||
src and destination must be on same storage system i.e both on file system or both on CEPH etc.
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -12,6 +12,12 @@ class VMStatus:
|
|||
error = "ERROR" # An error occurred that cannot be resolved automatically
|
||||
|
||||
|
||||
def declare_stopped(vm):
|
||||
vm['hostname'] = ''
|
||||
vm['in_migration'] = False
|
||||
vm['status'] = VMStatus.stopped
|
||||
|
||||
|
||||
class VMEntry(SpecificEtcdEntryBase):
|
||||
|
||||
def __init__(self, e):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue