VIM: allow cold migrate and evac with remote_storage label
Store the remote_storage label against the host object and always allow cold migration and evacuation for VMs on hosts with the label enabled. Change-Id: Iaf64474893f1426f1c24db9f535ac4c99faa0559 Story: 2004447 Task: 29190 Signed-off-by: Kevin Smith <kevin.smith@windriver.com>
This commit is contained in:
parent
a6498c3e01
commit
78a022103a
@ -134,9 +134,11 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||||||
|
|
||||||
openstack_compute = False
|
openstack_compute = False
|
||||||
openstack_control = False
|
openstack_control = False
|
||||||
|
remote_storage = False
|
||||||
|
|
||||||
OS_COMPUTE = nfvi.objects.v1.HOST_LABEL_KEYS.OS_COMPUTE_NODE
|
OS_COMPUTE = nfvi.objects.v1.HOST_LABEL_KEYS.OS_COMPUTE_NODE
|
||||||
OS_CONTROL = nfvi.objects.v1.HOST_LABEL_KEYS.OS_CONTROL_PLANE
|
OS_CONTROL = nfvi.objects.v1.HOST_LABEL_KEYS.OS_CONTROL_PLANE
|
||||||
|
REMOTE_STORAGE = nfvi.objects.v1.HOST_LABEL_KEYS.REMOTE_STORAGE
|
||||||
LABEL_ENABLED = nfvi.objects.v1.HOST_LABEL_VALUES.ENABLED
|
LABEL_ENABLED = nfvi.objects.v1.HOST_LABEL_VALUES.ENABLED
|
||||||
|
|
||||||
for host_label in host_label_list:
|
for host_label in host_label_list:
|
||||||
@ -147,8 +149,11 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||||||
elif host_label['label_key'] == OS_CONTROL:
|
elif host_label['label_key'] == OS_CONTROL:
|
||||||
if host_label['label_value'] == LABEL_ENABLED:
|
if host_label['label_value'] == LABEL_ENABLED:
|
||||||
openstack_control = True
|
openstack_control = True
|
||||||
|
elif host_label['label_key'] == REMOTE_STORAGE:
|
||||||
|
if host_label['label_value'] == LABEL_ENABLED:
|
||||||
|
remote_storage = True
|
||||||
|
|
||||||
return (openstack_compute, openstack_control)
|
return (openstack_compute, openstack_control, remote_storage)
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(NFVIInfrastructureAPI, self).__init__()
|
super(NFVIInfrastructureAPI, self).__init__()
|
||||||
@ -378,7 +383,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||||||
|
|
||||||
host_label_list = future.result.data['labels']
|
host_label_list = future.result.data['labels']
|
||||||
|
|
||||||
openstack_compute, openstack_control = self._get_host_labels(host_label_list)
|
openstack_compute, openstack_control, remote_storage = \
|
||||||
|
self._get_host_labels(host_label_list)
|
||||||
|
|
||||||
admin_state, oper_state, avail_status, nfvi_data \
|
admin_state, oper_state, avail_status, nfvi_data \
|
||||||
= host_state(host_uuid, host_name, host_personality,
|
= host_state(host_uuid, host_name, host_personality,
|
||||||
@ -400,6 +406,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||||||
target_load,
|
target_load,
|
||||||
openstack_compute,
|
openstack_compute,
|
||||||
openstack_control,
|
openstack_control,
|
||||||
|
remote_storage,
|
||||||
nfvi_data)
|
nfvi_data)
|
||||||
|
|
||||||
host_objs.append(host_obj)
|
host_objs.append(host_obj)
|
||||||
@ -520,7 +527,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||||||
|
|
||||||
host_label_list = future.result.data['labels']
|
host_label_list = future.result.data['labels']
|
||||||
|
|
||||||
openstack_compute, openstack_control = self._get_host_labels(host_label_list)
|
openstack_compute, openstack_control, remote_storage = \
|
||||||
|
self._get_host_labels(host_label_list)
|
||||||
|
|
||||||
host_obj = nfvi.objects.v1.Host(host_uuid, host_name,
|
host_obj = nfvi.objects.v1.Host(host_uuid, host_name,
|
||||||
host_sub_functions,
|
host_sub_functions,
|
||||||
@ -532,6 +540,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||||||
target_load,
|
target_load,
|
||||||
openstack_compute,
|
openstack_compute,
|
||||||
openstack_control,
|
openstack_control,
|
||||||
|
remote_storage,
|
||||||
nfvi_data)
|
nfvi_data)
|
||||||
|
|
||||||
response['result-data'] = host_obj
|
response['result-data'] = host_obj
|
||||||
@ -1006,7 +1015,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||||||
|
|
||||||
host_label_list = future.result.data['labels']
|
host_label_list = future.result.data['labels']
|
||||||
|
|
||||||
openstack_compute, openstack_control = self._get_host_labels(host_label_list)
|
openstack_compute, openstack_control, remote_storage = \
|
||||||
|
self._get_host_labels(host_label_list)
|
||||||
|
|
||||||
host_obj = nfvi.objects.v1.Host(host_uuid, host_name,
|
host_obj = nfvi.objects.v1.Host(host_uuid, host_name,
|
||||||
host_sub_functions,
|
host_sub_functions,
|
||||||
@ -1018,6 +1028,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||||||
target_load,
|
target_load,
|
||||||
openstack_compute,
|
openstack_compute,
|
||||||
openstack_control,
|
openstack_control,
|
||||||
|
remote_storage,
|
||||||
nfvi_data)
|
nfvi_data)
|
||||||
|
|
||||||
response['result-data'] = host_obj
|
response['result-data'] = host_obj
|
||||||
@ -1122,7 +1133,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||||||
|
|
||||||
host_label_list = future.result.data['labels']
|
host_label_list = future.result.data['labels']
|
||||||
|
|
||||||
openstack_compute, openstack_control = self._get_host_labels(host_label_list)
|
openstack_compute, openstack_control, remote_storage = \
|
||||||
|
self._get_host_labels(host_label_list)
|
||||||
|
|
||||||
host_obj = nfvi.objects.v1.Host(host_uuid, host_name,
|
host_obj = nfvi.objects.v1.Host(host_uuid, host_name,
|
||||||
host_sub_functions,
|
host_sub_functions,
|
||||||
@ -1134,6 +1146,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||||||
target_load,
|
target_load,
|
||||||
openstack_compute,
|
openstack_compute,
|
||||||
openstack_control,
|
openstack_control,
|
||||||
|
remote_storage,
|
||||||
nfvi_data)
|
nfvi_data)
|
||||||
|
|
||||||
response['result-data'] = host_obj
|
response['result-data'] = host_obj
|
||||||
@ -1237,7 +1250,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||||||
|
|
||||||
host_label_list = future.result.data['labels']
|
host_label_list = future.result.data['labels']
|
||||||
|
|
||||||
openstack_compute, openstack_control = self._get_host_labels(host_label_list)
|
openstack_compute, openstack_control, remote_storage = \
|
||||||
|
self._get_host_labels(host_label_list)
|
||||||
|
|
||||||
host_obj = nfvi.objects.v1.Host(host_uuid, host_name,
|
host_obj = nfvi.objects.v1.Host(host_uuid, host_name,
|
||||||
host_sub_functions,
|
host_sub_functions,
|
||||||
@ -1249,6 +1263,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||||||
target_load,
|
target_load,
|
||||||
openstack_compute,
|
openstack_compute,
|
||||||
openstack_control,
|
openstack_control,
|
||||||
|
remote_storage,
|
||||||
nfvi_data)
|
nfvi_data)
|
||||||
|
|
||||||
response['result-data'] = host_obj
|
response['result-data'] = host_obj
|
||||||
@ -1351,7 +1366,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||||||
|
|
||||||
host_label_list = future.result.data['labels']
|
host_label_list = future.result.data['labels']
|
||||||
|
|
||||||
openstack_compute, openstack_control = self._get_host_labels(host_label_list)
|
openstack_compute, openstack_control, remote_storage = \
|
||||||
|
self._get_host_labels(host_label_list)
|
||||||
|
|
||||||
host_obj = nfvi.objects.v1.Host(host_uuid, host_name,
|
host_obj = nfvi.objects.v1.Host(host_uuid, host_name,
|
||||||
host_sub_functions,
|
host_sub_functions,
|
||||||
@ -1363,6 +1379,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||||||
target_load,
|
target_load,
|
||||||
openstack_compute,
|
openstack_compute,
|
||||||
openstack_control,
|
openstack_control,
|
||||||
|
remote_storage,
|
||||||
nfvi_data)
|
nfvi_data)
|
||||||
|
|
||||||
response['result-data'] = host_obj
|
response['result-data'] = host_obj
|
||||||
@ -1518,7 +1535,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||||||
|
|
||||||
host_label_list = future.result.data['labels']
|
host_label_list = future.result.data['labels']
|
||||||
|
|
||||||
openstack_compute, openstack_control = self._get_host_labels(host_label_list)
|
openstack_compute, openstack_control, remote_storage = \
|
||||||
|
self._get_host_labels(host_label_list)
|
||||||
|
|
||||||
host_obj = nfvi.objects.v1.Host(host_uuid, host_name,
|
host_obj = nfvi.objects.v1.Host(host_uuid, host_name,
|
||||||
host_sub_functions,
|
host_sub_functions,
|
||||||
@ -1530,6 +1548,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI):
|
|||||||
target_load,
|
target_load,
|
||||||
openstack_compute,
|
openstack_compute,
|
||||||
openstack_control,
|
openstack_control,
|
||||||
|
remote_storage,
|
||||||
nfvi_data)
|
nfvi_data)
|
||||||
|
|
||||||
response['result-data'] = host_obj
|
response['result-data'] = host_obj
|
||||||
|
@ -217,6 +217,7 @@ class TestInstance(testcase.NFVTestCase):
|
|||||||
target_load=target_load,
|
target_load=target_load,
|
||||||
openstack_compute=False,
|
openstack_compute=False,
|
||||||
openstack_control=False,
|
openstack_control=False,
|
||||||
|
remote_storage=False,
|
||||||
uptime='1000'
|
uptime='1000'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -296,6 +296,7 @@ class TestSwPatchStrategy(testcase.NFVTestCase):
|
|||||||
target_load='12.01',
|
target_load='12.01',
|
||||||
openstack_compute=False,
|
openstack_compute=False,
|
||||||
openstack_control=False,
|
openstack_control=False,
|
||||||
|
remote_storage=False,
|
||||||
uptime='1000'
|
uptime='1000'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -274,6 +274,7 @@ class TestSwUpgradeStrategy(testcase.NFVTestCase):
|
|||||||
target_load=target_load,
|
target_load=target_load,
|
||||||
openstack_compute=False,
|
openstack_compute=False,
|
||||||
openstack_control=False,
|
openstack_control=False,
|
||||||
|
remote_storage=False,
|
||||||
uptime='1000'
|
uptime='1000'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -126,6 +126,7 @@ def database_host_get_list():
|
|||||||
nfvi_host_data['target_load'],
|
nfvi_host_data['target_load'],
|
||||||
nfvi_host_data['openstack_compute'],
|
nfvi_host_data['openstack_compute'],
|
||||||
nfvi_host_data['openstack_control'],
|
nfvi_host_data['openstack_control'],
|
||||||
|
nfvi_host_data['remote_storage'],
|
||||||
nfvi_host_data['nfvi_data'])
|
nfvi_host_data['nfvi_data'])
|
||||||
|
|
||||||
host_obj = objects.Host(nfvi_host, host.state, host.action,
|
host_obj = objects.Host(nfvi_host, host.state, host.action,
|
||||||
|
@ -23,6 +23,7 @@ def _migrate_hosts_v5_to_v6(session, hosts_v5, hosts_v6):
|
|||||||
nfvi_host_data = json.loads(host_v5.nfvi_host_data)
|
nfvi_host_data = json.loads(host_v5.nfvi_host_data)
|
||||||
nfvi_host_data['openstack_compute'] = False
|
nfvi_host_data['openstack_compute'] = False
|
||||||
nfvi_host_data['openstack_control'] = False
|
nfvi_host_data['openstack_control'] = False
|
||||||
|
nfvi_host_data['remote_storage'] = False
|
||||||
host_v6.nfvi_host_data = json.dumps(nfvi_host_data)
|
host_v6.nfvi_host_data = json.dumps(nfvi_host_data)
|
||||||
session.add(host_v6)
|
session.add(host_v6)
|
||||||
|
|
||||||
|
@ -88,6 +88,7 @@ class KubernetesLabelKeys(Constants):
|
|||||||
"""
|
"""
|
||||||
OS_COMPUTE_NODE = Constant('openstack-compute-node')
|
OS_COMPUTE_NODE = Constant('openstack-compute-node')
|
||||||
OS_CONTROL_PLANE = Constant('openstack-control-plane')
|
OS_CONTROL_PLANE = Constant('openstack-control-plane')
|
||||||
|
REMOTE_STORAGE = Constant('remote-storage')
|
||||||
|
|
||||||
|
|
||||||
# Host Constant Instantiation
|
# Host Constant Instantiation
|
||||||
@ -108,6 +109,7 @@ class Host(ObjectData):
|
|||||||
avail_status, action, uptime, software_load, target_load,
|
avail_status, action, uptime, software_load, target_load,
|
||||||
openstack_compute=False,
|
openstack_compute=False,
|
||||||
openstack_control=False,
|
openstack_control=False,
|
||||||
|
remote_storage=False,
|
||||||
nfvi_data=None):
|
nfvi_data=None):
|
||||||
super(Host, self).__init__('1.0.0')
|
super(Host, self).__init__('1.0.0')
|
||||||
self.update(dict(uuid=uuid, name=name, personality=personality,
|
self.update(dict(uuid=uuid, name=name, personality=personality,
|
||||||
@ -119,6 +121,7 @@ class Host(ObjectData):
|
|||||||
software_load=software_load,
|
software_load=software_load,
|
||||||
target_load=target_load,
|
target_load=target_load,
|
||||||
openstack_compute=openstack_compute,
|
openstack_compute=openstack_compute,
|
||||||
openstack_control=openstack_control))
|
openstack_control=openstack_control,
|
||||||
|
remote_storage=remote_storage))
|
||||||
|
|
||||||
self.nfvi_data = nfvi_data
|
self.nfvi_data = nfvi_data
|
||||||
|
@ -317,6 +317,13 @@ class Host(ObjectData):
|
|||||||
"""
|
"""
|
||||||
return self._nfvi_host.openstack_control
|
return self._nfvi_host.openstack_control
|
||||||
|
|
||||||
|
@property
|
||||||
|
def remote_storage(self):
|
||||||
|
"""
|
||||||
|
Returns remote_storage for this host
|
||||||
|
"""
|
||||||
|
return self._nfvi_host.remote_storage
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def recover_instances(self):
|
def recover_instances(self):
|
||||||
"""
|
"""
|
||||||
|
@ -1456,6 +1456,8 @@ class Instance(ObjectData):
|
|||||||
"""
|
"""
|
||||||
Returns true if the instance can be cold-migrated
|
Returns true if the instance can be cold-migrated
|
||||||
"""
|
"""
|
||||||
|
from nfv_vim import tables
|
||||||
|
|
||||||
if not system_initiated:
|
if not system_initiated:
|
||||||
# Always allow user initiated cold migration
|
# Always allow user initiated cold migration
|
||||||
return True
|
return True
|
||||||
@ -1464,9 +1466,14 @@ class Instance(ObjectData):
|
|||||||
# Always allow cold migration when booted from a volume
|
# Always allow cold migration when booted from a volume
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# TODO(bwensley): Always allow cold migration for instances using
|
host_table = tables.tables_get_host_table()
|
||||||
# remote storage. There is currently no way to determine this, but we
|
host = host_table.get(self.host_name, None)
|
||||||
# should eventually be able to check for a label on the compute host.
|
|
||||||
|
if host is not None:
|
||||||
|
if host.remote_storage:
|
||||||
|
# Always allow cold migration for instances using
|
||||||
|
# remote storage
|
||||||
|
return True
|
||||||
|
|
||||||
config_option = 'max_cold_migrate_local_image_disk_gb'
|
config_option = 'max_cold_migrate_local_image_disk_gb'
|
||||||
|
|
||||||
@ -1487,6 +1494,8 @@ class Instance(ObjectData):
|
|||||||
"""
|
"""
|
||||||
Returns true if the instance can be evacuated
|
Returns true if the instance can be evacuated
|
||||||
"""
|
"""
|
||||||
|
from nfv_vim import tables
|
||||||
|
|
||||||
if not system_initiated:
|
if not system_initiated:
|
||||||
# Always allow user initiated evacuate
|
# Always allow user initiated evacuate
|
||||||
return True
|
return True
|
||||||
@ -1495,9 +1504,14 @@ class Instance(ObjectData):
|
|||||||
# Always allow evacuate when booted from a volume
|
# Always allow evacuate when booted from a volume
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# TODO(bwensley): Always allow evacuate for instances using remote
|
host_table = tables.tables_get_host_table()
|
||||||
# storage. There is currently no way to determine this, but we should
|
host = host_table.get(self.host_name, None)
|
||||||
# eventually be able to check for a label on the compute host.
|
|
||||||
|
if host is not None:
|
||||||
|
if host.remote_storage:
|
||||||
|
# Always allow evacuation for instances using
|
||||||
|
# remote storage
|
||||||
|
return True
|
||||||
|
|
||||||
config_option = 'max_evacuate_local_image_disk_gb'
|
config_option = 'max_evacuate_local_image_disk_gb'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user