diff --git a/nfv/nfv-plugins/nfv_plugins/nfvi_plugins/nfvi_infrastructure_api.py b/nfv/nfv-plugins/nfv_plugins/nfvi_plugins/nfvi_infrastructure_api.py index a9b9b72f..ce68aa81 100755 --- a/nfv/nfv-plugins/nfv_plugins/nfvi_plugins/nfvi_infrastructure_api.py +++ b/nfv/nfv-plugins/nfv_plugins/nfvi_plugins/nfvi_infrastructure_api.py @@ -128,6 +128,27 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): else: return False + @staticmethod + def _get_host_labels(host_label_list): + + openstack_compute = False + openstack_control = False + + OS_COMPUTE = nfvi.objects.v1.HOST_LABEL_KEYS.OS_COMPUTE_NODE + OS_CONTROL = nfvi.objects.v1.HOST_LABEL_KEYS.OS_CONTROL_PLANE + LABEL_ENABLED = nfvi.objects.v1.HOST_LABEL_VALUES.ENABLED + + for host_label in host_label_list: + + if host_label['label_key'] == OS_COMPUTE: + if host_label['label_value'] == LABEL_ENABLED: + openstack_compute = True + elif host_label['label_key'] == OS_CONTROL: + if host_label['label_value'] == LABEL_ENABLED: + openstack_control = True + + return (openstack_compute, openstack_control) + def __init__(self): super(NFVIInfrastructureAPI, self).__init__() self._platform_token = None @@ -140,6 +161,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): self._host_state_change_callbacks = list() self._host_get_callbacks = list() self._host_upgrade_callbacks = list() + self._host_update_callbacks = list() self._host_notification_callbacks = list() self._neutron_extensions = None self._data_port_fault_handling_enabled = False @@ -346,6 +368,19 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): software_load = host_data['software_load'] target_load = host_data['target_load'] + future.work(sysinv.get_host_labels, self._platform_token, + host_uuid) + future.result = (yield) + + if not future.result.is_complete(): + DLOG.error("Get-Host-Labels did not complete.") + response['incomplete-hosts'].append(host_data['hostname']) + continue + + host_label_list = future.result.data['labels'] + + openstack_compute, openstack_control = self._get_host_labels(host_label_list) + admin_state, oper_state, avail_status, nfvi_data \ = host_state(host_uuid, host_name, host_personality, host_sub_functions, host_admin_state, @@ -364,6 +399,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): host_data['uptime'], software_load, target_load, + openstack_compute, + openstack_control, nfvi_data) host_objs.append(host_obj) @@ -473,6 +510,18 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): data_port_avail_status, self._data_port_fault_handling_enabled) + future.work(sysinv.get_host_labels, self._platform_token, host_uuid) + future.result = (yield) + + if not future.result.is_complete(): + DLOG.error("Get-Host-Labels did not complete, host=%s." + % host_name) + return + + host_label_list = future.result.data['labels'] + + openstack_compute, openstack_control = self._get_host_labels(host_label_list) + host_obj = nfvi.objects.v1.Host(host_uuid, host_name, host_sub_functions, admin_state, oper_state, @@ -481,6 +530,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): host_data['uptime'], software_load, target_load, + openstack_compute, + openstack_control, nfvi_data) response['result-data'] = host_obj @@ -1614,6 +1665,18 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): data_port_avail_status, self._data_port_fault_handling_enabled) + future.work(sysinv.get_host_labels, self._platform_token, host_uuid) + future.result = (yield) + + if not future.result.is_complete(): + DLOG.error("Get-Host-Labels did not complete, host=%s." + % host_name) + return + + host_label_list = future.result.data['labels'] + + openstack_compute, openstack_control = self._get_host_labels(host_label_list) + host_obj = nfvi.objects.v1.Host(host_uuid, host_name, host_sub_functions, admin_state, oper_state, @@ -1622,6 +1685,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): host_data['uptime'], software_load, target_load, + openstack_compute, + openstack_control, nfvi_data) response['result-data'] = host_obj @@ -1715,6 +1780,18 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): data_port_avail_status, self._data_port_fault_handling_enabled) + future.work(sysinv.get_host_labels, self._platform_token, host_uuid) + future.result = (yield) + + if not future.result.is_complete(): + DLOG.error("Get-Host-Labels did not complete, host=%s." + % host_name) + return + + host_label_list = future.result.data['labels'] + + openstack_compute, openstack_control = self._get_host_labels(host_label_list) + host_obj = nfvi.objects.v1.Host(host_uuid, host_name, host_sub_functions, admin_state, oper_state, @@ -1723,6 +1800,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): host_data['uptime'], software_load, target_load, + openstack_compute, + openstack_control, nfvi_data) response['result-data'] = host_obj @@ -1815,6 +1894,18 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): data_port_avail_status, self._data_port_fault_handling_enabled) + future.work(sysinv.get_host_labels, self._platform_token, host_uuid) + future.result = (yield) + + if not future.result.is_complete(): + DLOG.error("Get-Host-Labels did not complete, host=%s." + % host_name) + return + + host_label_list = future.result.data['labels'] + + openstack_compute, openstack_control = self._get_host_labels(host_label_list) + host_obj = nfvi.objects.v1.Host(host_uuid, host_name, host_sub_functions, admin_state, oper_state, @@ -1823,6 +1914,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): host_data['uptime'], software_load, target_load, + openstack_compute, + openstack_control, nfvi_data) response['result-data'] = host_obj @@ -1914,6 +2007,18 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): data_port_avail_status, self._data_port_fault_handling_enabled) + future.work(sysinv.get_host_labels, self._platform_token, host_uuid) + future.result = (yield) + + if not future.result.is_complete(): + DLOG.error("Get-Host-Labels did not complete, host=%s." + % host_name) + return + + host_label_list = future.result.data['labels'] + + openstack_compute, openstack_control = self._get_host_labels(host_label_list) + host_obj = nfvi.objects.v1.Host(host_uuid, host_name, host_sub_functions, admin_state, oper_state, @@ -1922,6 +2027,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): host_data['uptime'], software_load, target_load, + openstack_compute, + openstack_control, nfvi_data) response['result-data'] = host_obj @@ -2065,6 +2172,18 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): data_port_avail_status, self._data_port_fault_handling_enabled) + future.work(sysinv.get_host_labels, self._platform_token, host_uuid) + future.result = (yield) + + if not future.result.is_complete(): + DLOG.error("Get-Host-Labels did not complete, host=%s." + % host_name) + return + + host_label_list = future.result.data['labels'] + + openstack_compute, openstack_control = self._get_host_labels(host_label_list) + host_obj = nfvi.objects.v1.Host(host_uuid, host_name, host_sub_functions, admin_state, oper_state, @@ -2073,6 +2192,8 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): host_data['uptime'], software_load, target_load, + openstack_compute, + openstack_control, nfvi_data) response['result-data'] = host_obj @@ -2887,6 +3008,17 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): % (host_uuid, host_name, upgrade)) http_response = httplib.BAD_REQUEST + elif host_uuid is not None and host_name is not None: + + for callback in self._host_update_callbacks: + success = callback(host_uuid, host_name) + if not success: + http_response = httplib.BAD_REQUEST + + if httplib.OK == http_response: + http_payload = dict() + http_payload['status'] = "success" + else: DLOG.error("Invalid host patch data received, host_data=%s." % host_data) @@ -3035,6 +3167,12 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): """ self._host_upgrade_callbacks.append(callback) + def register_host_update_callback(self, callback): + """ + Register for host update notifications + """ + self._host_update_callbacks.append(callback) + def register_host_notification_callback(self, callback): """ Register for host notifications diff --git a/nfv/nfv-plugins/nfv_plugins/nfvi_plugins/openstack/sysinv.py b/nfv/nfv-plugins/nfv_plugins/nfvi_plugins/openstack/sysinv.py index 15ab9392..e677ef1f 100755 --- a/nfv/nfv-plugins/nfv_plugins/nfvi_plugins/openstack/sysinv.py +++ b/nfv/nfv-plugins/nfv_plugins/nfvi_plugins/openstack/sysinv.py @@ -55,6 +55,20 @@ def get_host(token, host_uuid): return response +def get_host_labels(token, host_uuid): + """ + Asks System Inventory for host label details + """ + url = token.get_service_url(PLATFORM_SERVICE.SYSINV) + if url is None: + raise ValueError("OpenStack SysInv URL is invalid") + + api_cmd = url + "/ihosts/%s/labels" % host_uuid + + response = rest_api_request(token, "GET", api_cmd) + return response + + def get_upgrade(token): """ Asks System Inventory for information about the upgrade diff --git a/nfv/nfv-tests/nfv_unit_tests/tests/test_instance.py b/nfv/nfv-tests/nfv_unit_tests/tests/test_instance.py index 4f9bc86b..b05d210c 100755 --- a/nfv/nfv-tests/nfv_unit_tests/tests/test_instance.py +++ b/nfv/nfv-tests/nfv_unit_tests/tests/test_instance.py @@ -217,6 +217,8 @@ class TestInstance(testcase.NFVTestCase): action=nfvi.objects.v1.HOST_ACTION.NONE, software_load=software_load, target_load=target_load, + openstack_compute=False, + openstack_control=False, uptime='1000' ) diff --git a/nfv/nfv-tests/nfv_unit_tests/tests/test_sw_patch_strategy.py b/nfv/nfv-tests/nfv_unit_tests/tests/test_sw_patch_strategy.py index 01230557..2939483b 100755 --- a/nfv/nfv-tests/nfv_unit_tests/tests/test_sw_patch_strategy.py +++ b/nfv/nfv-tests/nfv_unit_tests/tests/test_sw_patch_strategy.py @@ -292,6 +292,8 @@ class TestSwPatchStrategy(testcase.NFVTestCase): action=nfvi.objects.v1.HOST_ACTION.NONE, software_load='12.01', target_load='12.01', + openstack_compute=False, + openstack_control=False, uptime='1000' ) diff --git a/nfv/nfv-tests/nfv_unit_tests/tests/test_sw_upgrade_strategy.py b/nfv/nfv-tests/nfv_unit_tests/tests/test_sw_upgrade_strategy.py index 3c5dd7a8..67c21da8 100755 --- a/nfv/nfv-tests/nfv_unit_tests/tests/test_sw_upgrade_strategy.py +++ b/nfv/nfv-tests/nfv_unit_tests/tests/test_sw_upgrade_strategy.py @@ -269,6 +269,8 @@ class TestSwUpgradeStrategy(testcase.NFVTestCase): action=nfvi.objects.v1.HOST_ACTION.NONE, software_load=software_load, target_load=target_load, + openstack_compute=False, + openstack_control=False, uptime='1000' ) diff --git a/nfv/nfv-vim/nfv_vim/database/_database_infrastructure_module.py b/nfv/nfv-vim/nfv_vim/database/_database_infrastructure_module.py index b0cbd9f5..34366e7a 100755 --- a/nfv/nfv-vim/nfv_vim/database/_database_infrastructure_module.py +++ b/nfv/nfv-vim/nfv_vim/database/_database_infrastructure_module.py @@ -63,10 +63,10 @@ def database_host_add(host_obj): """ db = database_get() session = db.session() - query = session.query(model.Host_v5).filter(model.Host_v5.name == host_obj.name) + query = session.query(model.Host_v6).filter(model.Host_v6.name == host_obj.name) host = query.first() if not host: - host = model.Host_v5() + host = model.Host_v6() host.uuid = host_obj.uuid host.name = host_obj.name host.personality = host_obj.personality @@ -97,8 +97,8 @@ def database_host_delete(host_name): """ db = database_get() session = db.session() - query = session.query(model.Host_v5) - query.filter(model.Host_v5.name == host_name).delete() + query = session.query(model.Host_v6) + query.filter(model.Host_v6.name == host_name).delete() session.commit() @@ -108,7 +108,7 @@ def database_host_get_list(): """ db = database_get() session = db.session() - query = session.query(model.Host_v5) + query = session.query(model.Host_v6) host_objs = list() for host in query.all(): @@ -123,6 +123,8 @@ def database_host_get_list(): nfvi_host_data['uptime'], nfvi_host_data['software_load'], nfvi_host_data['target_load'], + nfvi_host_data['openstack_compute'], + nfvi_host_data['openstack_control'], nfvi_host_data['nfvi_data']) host_obj = objects.Host(nfvi_host, host.state, host.action, diff --git a/nfv/nfv-vim/nfv_vim/database/_database_migrate.py b/nfv/nfv-vim/nfv_vim/database/_database_migrate.py index 3a6dca59..3c4a9259 100755 --- a/nfv/nfv-vim/nfv_vim/database/_database_migrate.py +++ b/nfv/nfv-vim/nfv_vim/database/_database_migrate.py @@ -12,79 +12,29 @@ from nfv_common import debug DLOG = debug.debug_get_logger('nfv_vim.database') -def _migrate_instances_v4_to_v5(session, instances_v4, instances_v5): +def _migrate_hosts_v5_to_v6(session, hosts_v5, hosts_v6): """ - Migrate instances_v4 table to instances_v5 table + Migrate host_v5 table to host_v6 table """ - if 0 == len(instances_v5): - instance_type_query = session.query(model.InstanceType) - instance_types = instance_type_query.all() - - for instance_v4 in instances_v4: - instance_v5 = model.Instance_v5() - instance_type_uuid = instance_v4.instance_type_uuid - del instance_v4.data['instance_type_uuid'] - instance_v5.data = instance_v4.data - nfvi_instance_data = json.loads(instance_v4.nfvi_instance_data) - - # We can build the flavor details embedded in the instance from - # the flavor referenced from the original instance. - instance_type = None - for i_type in instance_types: - if i_type.uuid == instance_type_uuid: - instance_type = i_type - break - if instance_type is None: - DLOG.error("Missing instance type: %s" % instance_type_uuid) - continue - - flavor = dict() - flavor['vcpus'] = instance_type.vcpus - flavor['ram'] = instance_type.mem_mb - flavor['disk'] = instance_type.disk_gb - flavor['ephemeral'] = instance_type.ephemeral_gb - flavor['swap'] = instance_type.swap_gb - flavor['original_name'] = instance_type.name - - # Re-create the flavor extra_specs, undoing all the mangling that - # the VIM did when converting the flavor to an instance_type. - extra_specs = dict() - guest_services = instance_type.guest_services - if 'heartbeat' in guest_services: - if guest_services['heartbeat'] == 'configured': - extra_specs['sw:wrs:guest:heartbeat'] = 'true' - else: - extra_specs['sw:wrs:guest:heartbeat'] = 'false' - if instance_type.auto_recovery is not None: - if instance_type.auto_recovery: - extra_specs['sw:wrs:auto_recovery'] = 'true' - else: - extra_specs['sw:wrs:auto_recovery'] = 'false' - if instance_type.live_migration_timeout is not None: - extra_specs['hw:wrs:live_migration_timeout'] = \ - instance_type.live_migration_timeout - if instance_type.live_migration_max_downtime is not None: - extra_specs['hw:wrs:live_migration_max_downtime'] = \ - instance_type.live_migration_max_downtime - if instance_type.storage_type is not None: - extra_specs['aggregate_instance_extra_specs:storage'] = \ - instance_type.storage_type - if extra_specs: - flavor['extra_specs'] = extra_specs - - nfvi_instance_data['instance_type'] = flavor - instance_v5.nfvi_instance_data = json.dumps(nfvi_instance_data) - session.add(instance_v5) + if 0 == len(hosts_v6): + for host_v5 in hosts_v5: + host_v6 = model.Host_v6() + host_v6.data = host_v5.data + nfvi_host_data = json.loads(host_v5.nfvi_host_data) + nfvi_host_data['openstack_compute'] = False + nfvi_host_data['openstack_control'] = False + host_v6.nfvi_host_data = json.dumps(nfvi_host_data) + session.add(host_v6) def migrate_tables(session, table_names): """ Migrate database tables """ - if 'instances_v4' in table_names and 'instances_v5' in table_names: - instances_v4_query = session.query(model.Instance_v4) - instances_v4 = instances_v4_query.all() - instances_v5_query = session.query(model.Instance_v5) - instances_v5 = instances_v5_query.all() - _migrate_instances_v4_to_v5(session, instances_v4, instances_v5) - instances_v4_query.delete() + if 'hosts_v5' in table_names and 'hosts_v6' in table_names: + hosts_v5_query = session.query(model.Host_v5) + hosts_v5 = hosts_v5_query.all() + hosts_v6_query = session.query(model.Host_v6) + hosts_v6 = hosts_v6_query.all() + _migrate_hosts_v5_to_v6(session, hosts_v5, hosts_v6) + hosts_v5_query.delete() diff --git a/nfv/nfv-vim/nfv_vim/database/model/__init__.py b/nfv/nfv-vim/nfv_vim/database/model/__init__.py index 5bcbf8a1..c51b5b1f 100755 --- a/nfv/nfv-vim/nfv_vim/database/model/__init__.py +++ b/nfv/nfv-vim/nfv_vim/database/model/__init__.py @@ -11,6 +11,7 @@ from nfv_vim.database.model._volume import Volume # noqa: F401 from nfv_vim.database.model._volume_snapshot import VolumeSnapshot # noqa: F401 from nfv_vim.database.model._system import System # noqa: F401 from nfv_vim.database.model._host import Host_v5 # noqa: F401 +from nfv_vim.database.model._host import Host_v6 # noqa: F401 from nfv_vim.database.model._host_aggregate import HostAggregate # noqa: F401 from nfv_vim.database.model._host_group import HostGroup # noqa: F401 from nfv_vim.database.model._subnet import Subnet # noqa: F401 diff --git a/nfv/nfv-vim/nfv_vim/database/model/_host.py b/nfv/nfv-vim/nfv_vim/database/model/_host.py index 8ce2d311..f377229c 100755 --- a/nfv/nfv-vim/nfv_vim/database/model/_host.py +++ b/nfv/nfv-vim/nfv_vim/database/model/_host.py @@ -11,6 +11,31 @@ from nfv_vim.database.model._base import AsDictMixin from nfv_vim.database.model._base import Base +class Host_v6(AsDictMixin, Base): + """ + Host Database Table Entry + Note: Changes are only in nfvi_host_data. + """ + __tablename__ = 'hosts_v6' + + uuid = Column(String(64), nullable=False, primary_key=True) + name = Column(String(64), nullable=False) + personality = Column(String(64), nullable=False) + state = Column(String(64), nullable=False) + action = Column(String(64), nullable=False) + upgrade_inprogress = Column(Boolean, nullable=False) + recover_instances = Column(Boolean, nullable=False) + uptime = Column(String(64), nullable=False) + elapsed_time_in_state = Column(String(64), nullable=False) + host_services_locked = Column(Boolean, nullable=False) + nfvi_host_data = Column(String(2048), nullable=False) + + def __repr__(self): + return "" % (self.uuid, self.name, + self.personality, self.state, + self.action, self.uptime) + + class Host_v5(AsDictMixin, Base): """ Host Database Table Entry diff --git a/nfv/nfv-vim/nfv_vim/events/_vim_nfvi_events.py b/nfv/nfv-vim/nfv_vim/events/_vim_nfvi_events.py index 694157a6..1fb9ca82 100755 --- a/nfv/nfv-vim/nfv_vim/events/_vim_nfvi_events.py +++ b/nfv/nfv-vim/nfv_vim/events/_vim_nfvi_events.py @@ -153,6 +153,19 @@ def _nfvi_host_upgrade_callback(nfvi_host_uuid, nfvi_host_name, return True +def _nfvi_host_update_callback(nfvi_host_uuid, nfvi_host_name): + """ + NFVI Host update callback + """ + DLOG.debug("Host update, nfvi_host_uuid=%s, nfvi_host_name=%s" % + (nfvi_host_uuid, nfvi_host_name)) + + nfvi.nfvi_get_host(nfvi_host_uuid, nfvi_host_name, + _nfvi_host_query_callback()) + + return True + + def _nfvi_host_notification_callback(host_ip, nfvi_notify_type, nfvi_notify_data): """ NFVI Host notification callback @@ -468,6 +481,9 @@ def vim_nfvi_events_initialize(): nfvi.nfvi_register_host_upgrade_callback( _nfvi_host_upgrade_callback) + nfvi.nfvi_register_host_update_callback( + _nfvi_host_update_callback) + nfvi.nfvi_register_host_notification_callback( _nfvi_host_notification_callback) diff --git a/nfv/nfv-vim/nfv_vim/nfvi/__init__.py b/nfv/nfv-vim/nfv_vim/nfvi/__init__.py index a0b338cc..6f956336 100755 --- a/nfv/nfv-vim/nfv_vim/nfvi/__init__.py +++ b/nfv/nfv-vim/nfv_vim/nfvi/__init__.py @@ -55,6 +55,7 @@ from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_register_host_action_c from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_register_host_state_change_callback # noqa: F401 from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_register_host_get_callback # noqa: F401 from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_register_host_upgrade_callback # noqa: F401 +from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_register_host_update_callback # noqa: F401 from nfv_vim.nfvi._nfvi_infrastructure_module import nfvi_register_host_notification_callback # noqa: F401 from nfv_vim.nfvi._nfvi_image_module import nfvi_image_plugin_disabled # noqa: F401 from nfv_vim.nfvi._nfvi_image_module import nfvi_get_images # noqa: F401 diff --git a/nfv/nfv-vim/nfv_vim/nfvi/_nfvi_infrastructure_module.py b/nfv/nfv-vim/nfv_vim/nfvi/_nfvi_infrastructure_module.py index fa699b48..f716a0dc 100755 --- a/nfv/nfv-vim/nfv_vim/nfvi/_nfvi_infrastructure_module.py +++ b/nfv/nfv-vim/nfv_vim/nfvi/_nfvi_infrastructure_module.py @@ -352,6 +352,14 @@ def nfvi_register_host_upgrade_callback(callback): callback=callback) +def nfvi_register_host_update_callback(callback): + """ + Register for host update notifications + """ + _infrastructure_plugin.invoke_plugin('register_host_update_callback', + callback=callback) + + def nfvi_register_host_notification_callback(callback): """ Register for host notifications diff --git a/nfv/nfv-vim/nfv_vim/nfvi/api/v1/_nfvi_infrastructure_api.py b/nfv/nfv-vim/nfv_vim/nfvi/api/v1/_nfvi_infrastructure_api.py index c3546725..ad04882c 100755 --- a/nfv/nfv-vim/nfv_vim/nfvi/api/v1/_nfvi_infrastructure_api.py +++ b/nfv/nfv-vim/nfv_vim/nfvi/api/v1/_nfvi_infrastructure_api.py @@ -256,6 +256,13 @@ class NFVIInfrastructureAPI(object): """ pass + @abc.abstractmethod + def register_host_update_callback(self, callback): + """ + Register for host update notifications + """ + pass + @abc.abstractmethod def initialize(self, config_file): """ diff --git a/nfv/nfv-vim/nfv_vim/nfvi/objects/v1/__init__.py b/nfv/nfv-vim/nfv_vim/nfvi/objects/v1/__init__.py index 4a089038..1dcc5166 100755 --- a/nfv/nfv-vim/nfv_vim/nfvi/objects/v1/__init__.py +++ b/nfv/nfv-vim/nfv_vim/nfvi/objects/v1/__init__.py @@ -48,6 +48,8 @@ from nfv_vim.nfvi.objects.v1._host import HOST_OPER_STATE # noqa: F401 from nfv_vim.nfvi.objects.v1._host import HOST_AVAIL_STATUS # noqa: F401 from nfv_vim.nfvi.objects.v1._host import HOST_ACTION # noqa: F401 from nfv_vim.nfvi.objects.v1._host import HOST_NOTIFICATIONS # noqa: F401 +from nfv_vim.nfvi.objects.v1._host import HOST_LABEL_KEYS # noqa: F401 +from nfv_vim.nfvi.objects.v1._host import HOST_LABEL_VALUES # noqa: F401 from nfv_vim.nfvi.objects.v1._host import Host # noqa: F401 from nfv_vim.nfvi.objects.v1._host_aggregate import HostAggregate # noqa: F401 from nfv_vim.nfvi.objects.v1._host_group import HOST_GROUP_POLICY # noqa: F401 diff --git a/nfv/nfv-vim/nfv_vim/nfvi/objects/v1/_host.py b/nfv/nfv-vim/nfv_vim/nfvi/objects/v1/_host.py index 4abf0690..15dce4a7 100755 --- a/nfv/nfv-vim/nfv_vim/nfvi/objects/v1/_host.py +++ b/nfv/nfv-vim/nfv_vim/nfvi/objects/v1/_host.py @@ -72,12 +72,32 @@ class HostNotifications(Constants): BOOTING = Constant('booting') +@six.add_metaclass(Singleton) +class KubernetesLabelValues(Constants): + """ + Host Kubernetes Label Value Constants + """ + ENABLED = Constant('enabled') + DISABLED = Constant('disabled') + + +@six.add_metaclass(Singleton) +class KubernetesLabelKeys(Constants): + """ + Host Kubernetes Label Key Constants + """ + OS_COMPUTE_NODE = Constant('openstack-compute-node') + OS_CONTROL_PLANE = Constant('openstack-control-plane') + + # Host Constant Instantiation HOST_ADMIN_STATE = HostAdministrativeState() HOST_OPER_STATE = HostOperationalState() HOST_AVAIL_STATUS = HostAvailabilityStatus() HOST_ACTION = HostAction() HOST_NOTIFICATIONS = HostNotifications() +HOST_LABEL_KEYS = KubernetesLabelKeys() +HOST_LABEL_VALUES = KubernetesLabelValues() class Host(ObjectData): @@ -86,6 +106,8 @@ class Host(ObjectData): """ def __init__(self, uuid, name, personality, admin_state, oper_state, avail_status, action, uptime, software_load, target_load, + openstack_compute=False, + openstack_control=False, nfvi_data=None): super(Host, self).__init__('1.0.0') self.update(dict(uuid=uuid, name=name, personality=personality, @@ -95,6 +117,8 @@ class Host(ObjectData): action=action, uptime=uptime, software_load=software_load, - target_load=target_load)) + target_load=target_load, + openstack_compute=openstack_compute, + openstack_control=openstack_control)) self.nfvi_data = nfvi_data diff --git a/nfv/nfv-vim/nfv_vim/objects/_host.py b/nfv/nfv-vim/nfv_vim/objects/_host.py index 43e03e51..36eab092 100755 --- a/nfv/nfv-vim/nfv_vim/objects/_host.py +++ b/nfv/nfv-vim/nfv_vim/objects/_host.py @@ -208,6 +208,20 @@ class Host(ObjectData): """ return self._nfvi_host.target_load + @property + def openstack_compute(self): + """ + Returns openstack_compute for this host + """ + return self._nfvi_host.openstack_compute + + @property + def openstack_control(self): + """ + Returns openstack_control for this host + """ + return self._nfvi_host.openstack_control + @property def recover_instances(self): """ diff --git a/nfv/nfv-vim/nfv_vim/webserver/templates/hosts.handlebars b/nfv/nfv-vim/nfv_vim/webserver/templates/hosts.handlebars index b51d403b..0f109e9a 100755 --- a/nfv/nfv-vim/nfv_vim/webserver/templates/hosts.handlebars +++ b/nfv/nfv-vim/nfv_vim/webserver/templates/hosts.handlebars @@ -43,6 +43,8 @@ administrative-state operational-state availability-status + openstack-control + openstack-compute @@ -53,6 +55,8 @@ {{nfvi_host.nfvi_data.admin_state}} {{nfvi_host.nfvi_data.oper_state}} {{nfvi_host.nfvi_data.avail_status}} + {{nfvi_host.openstack_control}} + {{nfvi_host.openstack_compute}}