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 686157c2..78786f69 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 @@ -33,6 +33,7 @@ def host_state(host_uuid, host_name, host_personality, host_sub_functions, data_port_oper_state, data_port_avail_status, data_port_fault_handling_enabled): """ + Takes as input the host state info received from maintenance. Returns a tuple of administrative state, operational state, availability status and nfvi-data for a host from the perspective of being able to host services and instances. @@ -417,6 +418,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): host_action = host_action.rstrip('-') software_load = host_data['software_load'] target_load = host_data['target_load'] + device_image_update = host_data['device_image_update'] future.work(sysinv.get_host_labels, self._platform_token, host_uuid) @@ -450,6 +452,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): host_data['uptime'], software_load, target_load, + device_image_update, openstack_compute, openstack_control, remote_storage, @@ -552,6 +555,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): host_action = (host_data.get('ihost_action') or "").rstrip('-') software_load = host_data['software_load'] target_load = host_data['target_load'] + device_image_update = host_data['device_image_update'] admin_state, oper_state, avail_status, nfvi_data \ = host_state(host_uuid, host_name, host_personality, @@ -584,6 +588,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): host_data['uptime'], software_load, target_load, + device_image_update, openstack_compute, openstack_control, remote_storage, @@ -1268,6 +1273,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): host_action = (host_data.get('ihost_action') or "").rstrip('-') software_load = host_data['software_load'] target_load = host_data['target_load'] + device_image_update = host_data['device_image_update'] admin_state, oper_state, avail_status, nfvi_data \ = host_state(host_uuid, host_name, host_personality, @@ -1300,6 +1306,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): host_data['uptime'], software_load, target_load, + device_image_update, openstack_compute, openstack_control, remote_storage, @@ -1386,6 +1393,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): host_action = (host_data.get('ihost_action') or "").rstrip('-') software_load = host_data['software_load'] target_load = host_data['target_load'] + device_image_update = host_data['device_image_update'] admin_state, oper_state, avail_status, nfvi_data \ = host_state(host_uuid, host_name, host_personality, @@ -1418,6 +1426,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): host_data['uptime'], software_load, target_load, + device_image_update, openstack_compute, openstack_control, remote_storage, @@ -1503,6 +1512,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): data_port_avail_status = state.get('data_ports_avail', None) software_load = host_data['software_load'] target_load = host_data['target_load'] + device_image_update = host_data['device_image_update'] admin_state, oper_state, avail_status, nfvi_data \ = host_state(host_uuid, host_name, host_personality, @@ -1535,6 +1545,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): host_data['uptime'], software_load, target_load, + device_image_update, openstack_compute, openstack_control, remote_storage, @@ -1619,6 +1630,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): data_port_avail_status = state.get('data_ports_avail', None) software_load = host_data['software_load'] target_load = host_data['target_load'] + device_image_update = host_data['device_image_update'] admin_state, oper_state, avail_status, nfvi_data \ = host_state(host_uuid, host_name, host_personality, @@ -1651,6 +1663,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): host_data['uptime'], software_load, target_load, + device_image_update, openstack_compute, openstack_control, remote_storage, @@ -1788,6 +1801,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): data_port_avail_status = state.get('data_ports_avail', None) software_load = host_data['software_load'] target_load = host_data['target_load'] + device_image_update = host_data['device_image_update'] admin_state, oper_state, avail_status, nfvi_data \ = host_state(host_uuid, host_name, host_personality, @@ -1820,6 +1834,7 @@ class NFVIInfrastructureAPI(nfvi.api.v1.NFVIInfrastructureAPI): host_data['uptime'], software_load, target_load, + device_image_update, openstack_compute, openstack_control, remote_storage, diff --git a/nfv/nfv-tests/nfv_unit_tests/test_data/nfv_vim_db_stx_19.12 b/nfv/nfv-tests/nfv_unit_tests/test_data/nfv_vim_db_stx_19.12 new file mode 100644 index 00000000..0a6e748e --- /dev/null +++ b/nfv/nfv-tests/nfv_unit_tests/test_data/nfv_vim_db_stx_19.12 @@ -0,0 +1 @@ +{"tables": {"instances_v5": [{"last_action_data": "{\"action_uuid\": \"7fdae047-13d6-441d-abf3-300a8495f35f\", \"action_seqnum\": 36, \"action_state\": \"completed\", \"reason\": \"\", \"nfvi_action_data\": {\"context\": {\"content\": \"{\\\"resize\\\": {\\\"flavorRef\\\": \\\"36ef7356-c794-4d74-b2dd-b9b336e6b256\\\"}}\", \"token_id\": \"gAAAAABe1UwVFjN69TMvAYmBOqwlultMSFw2CkBdpiUvdL7T6rMEetBZKVmTtoer0BvtAKh9hjl3npL5u2PTsc_0QqRyd2wO2dkKfuoWLN_MEOQILowwhNEQxyO0prbNVlWsyuvVvjTYS6o5O4YReSEKXkDX2Rv9wFxerC-mL3_a09OJZF_7uVA\", \"request_uuid\": \"7fdae047-13d6-441d-abf3-300a8495f35f\", \"version\": \"2.53\", \"tenant_id\": \"1ea3514a93114153b1099397b7d038c6\"}, \"from_cli\": true, \"skip_guest_notify\": false, \"action_uuid\": \"7fdae047-13d6-441d-abf3-300a8495f35f\", \"last_update_timestamp\": \"2020-06-01T18:42:29Z\", \"action_parameters\": \"{'instance-type-uuid': u'36ef7356-c794-4d74-b2dd-b9b336e6b256'}\", \"action_state\": \"initial\", \"skip_guest_vote\": false, \"reason\": \"\", \"action_type\": \"resize\", \"created_timestamp\": \"2020-06-01T18:42:29Z\"}, \"action_type\": \"resize\"}", "guest_services": "{\"services\": {}, \"state\": null, \"nfvi_guest_services\": []}", "uuid": "bc183e1f-86c2-41b1-88b1-e844bcbb7521", "elapsed_time_on_host": "387", "avail_status": "[]", "nfvi_instance_data": "{\"attached_volumes\": [\"7a57b69c-3b55-4537-8cc8-c97beb75471a\"], \"live_migration_timeout\": null, \"name\": \"cirros-1\", \"recovery_priority\": null, \"tenant_id\": \"1ea3514a-9311-4153-b109-9397b7d038c6\", \"avail_status\": [], \"nfvi_data\": {\"last_update_timestamp\": \"2020-06-01T18:44:57Z\", \"vm_state\": \"active\", \"task_state\": \"none\", \"power_state\": \"running\"}, \"live_migration_support\": true, \"instance_type\": {\"ephemeral\": 0, \"ram\": 128, \"original_name\": \"medium\", \"vcpus\": 2, \"extra_specs\": {}, \"swap\": 0, \"disk\": 1}, \"oper_state\": \"enabled\", \"host_name\": \"compute-0\", \"image_uuid\": null, \"action\": \"\", \"admin_state\": \"unlocked\", \"uuid\": \"bc183e1f-86c2-41b1-88b1-e844bcbb7521\"}", "live_migration_support": true, "unlock_to_recover": false, "oper_state": "enabled", "host_name": "compute-0", "action_data": "{\"action_uuid\": \"4536b1f3-2ddd-4bda-8f22-b5a54d3ef61e\", \"action_seqnum\": 37, \"action_state\": \"completed\", \"reason\": null, \"nfvi_action_data\": {\"context\": {\"content\": \"{\\\"revertResize\\\": null}\", \"token_id\": \"gAAAAABe1UwVFjN69TMvAYmBOqwlultMSFw2CkBdpiUvdL7T6rMEetBZKVmTtoer0BvtAKh9hjl3npL5u2PTsc_0QqRyd2wO2dkKfuoWLN_MEOQILowwhNEQxyO0prbNVlWsyuvVvjTYS6o5O4YReSEKXkDX2Rv9wFxerC-mL3_a09OJZF_7uVA\", \"request_uuid\": \"4536b1f3-2ddd-4bda-8f22-b5a54d3ef61e\", \"version\": \"2.53\", \"tenant_id\": \"1ea3514a93114153b1099397b7d038c6\"}, \"from_cli\": true, \"skip_guest_notify\": false, \"action_uuid\": \"4536b1f3-2ddd-4bda-8f22-b5a54d3ef61e\", \"last_update_timestamp\": \"2020-06-01T18:44:57Z\", \"action_parameters\": \"\", \"action_state\": \"completed\", \"skip_guest_vote\": false, \"reason\": null, \"action_type\": \"revert-resize\", \"created_timestamp\": \"2020-06-01T18:44:23Z\"}, \"action_type\": \"revert-resize\"}", "image_uuid": null, "action": "", "admin_state": "unlocked", "recoverable": true, "elapsed_time_in_state": "355", "name": "cirros-1"}, {"last_action_data": "{\"action_uuid\": null, \"action_seqnum\": 4, \"action_state\": null, \"reason\": \"\", \"nfvi_action_data\": null, \"action_type\": \"\"}", "guest_services": "{\"services\": {}, \"state\": null, \"nfvi_guest_services\": []}", "uuid": "107fc056-6c1d-4aec-8c5b-de9203aae97b", "elapsed_time_on_host": "3716", "avail_status": "[]", "nfvi_instance_data": "{\"attached_volumes\": [\"1fccdb35-55ce-468e-a034-3f4d449dbb43\"], \"live_migration_timeout\": null, \"name\": \"cirros-ephemeral-1\", \"recovery_priority\": null, \"tenant_id\": \"1ea3514a-9311-4153-b109-9397b7d038c6\", \"avail_status\": [], \"nfvi_data\": {\"last_update_timestamp\": \"2020-06-01T17:48:35Z\", \"vm_state\": \"active\", \"task_state\": \"none\", \"power_state\": \"running\"}, \"live_migration_support\": true, \"instance_type\": {\"ephemeral\": 1, \"ram\": 64, \"original_name\": \"small_ephemeral\", \"vcpus\": 1, \"extra_specs\": {}, \"swap\": 0, \"disk\": 1}, \"oper_state\": \"enabled\", \"host_name\": \"compute-0\", \"image_uuid\": null, \"action\": \"\", \"admin_state\": \"unlocked\", \"uuid\": \"107fc056-6c1d-4aec-8c5b-de9203aae97b\"}", "live_migration_support": true, "unlock_to_recover": false, "oper_state": "enabled", "host_name": "compute-0", "action_data": "{\"action_uuid\": null, \"action_seqnum\": 3, \"action_state\": null, \"reason\": \"\", \"nfvi_action_data\": null, \"action_type\": \"\"}", "image_uuid": null, "action": "", "admin_state": "unlocked", "recoverable": true, "elapsed_time_in_state": "3716", "name": "cirros-ephemeral-1"}, {"last_action_data": "{\"action_uuid\": null, \"action_seqnum\": 6, \"action_state\": null, \"reason\": \"\", \"nfvi_action_data\": null, \"action_type\": \"\"}", "guest_services": "{\"services\": {}, \"state\": null, \"nfvi_guest_services\": []}", "uuid": "84e315ce-56f8-49dc-ae25-ba06472261eb", "elapsed_time_on_host": "3687", "avail_status": "[]", "nfvi_instance_data": "{\"attached_volumes\": [\"1a002e19-52b2-4e3d-bfbb-b8eba2f14930\"], \"live_migration_timeout\": null, \"name\": \"cirros-swap-1\", \"recovery_priority\": null, \"tenant_id\": \"1ea3514a-9311-4153-b109-9397b7d038c6\", \"avail_status\": [], \"nfvi_data\": {\"last_update_timestamp\": \"2020-06-01T17:49:10Z\", \"vm_state\": \"active\", \"task_state\": \"none\", \"power_state\": \"running\"}, \"live_migration_support\": true, \"instance_type\": {\"ephemeral\": 0, \"ram\": 64, \"original_name\": \"small_swap\", \"vcpus\": 1, \"extra_specs\": {}, \"swap\": 1, \"disk\": 1}, \"oper_state\": \"enabled\", \"host_name\": \"compute-1\", \"image_uuid\": null, \"action\": \"\", \"admin_state\": \"unlocked\", \"uuid\": \"84e315ce-56f8-49dc-ae25-ba06472261eb\"}", "live_migration_support": true, "unlock_to_recover": false, "oper_state": "enabled", "host_name": "compute-1", "action_data": "{\"action_uuid\": null, \"action_seqnum\": 5, \"action_state\": null, \"reason\": \"\", \"nfvi_action_data\": null, \"action_type\": \"\"}", "image_uuid": null, "action": "", "admin_state": "unlocked", "recoverable": true, "elapsed_time_in_state": "3666", "name": "cirros-swap-1"}, {"last_action_data": "{\"action_uuid\": null, \"action_seqnum\": 8, \"action_state\": null, \"reason\": \"\", \"nfvi_action_data\": null, \"action_type\": \"\"}", "guest_services": "{\"services\": {}, \"state\": null, \"nfvi_guest_services\": []}", "uuid": "d9cc5957-f50f-4e5f-aee0-deaba829ff4a", "elapsed_time_on_host": "3617", "avail_status": "[]", "nfvi_instance_data": "{\"attached_volumes\": [\"a547de3f-b504-4917-bc9f-48242e9a1d79\"], \"live_migration_timeout\": null, \"name\": \"cirros-ephemeral-swap-1\", \"recovery_priority\": null, \"tenant_id\": \"1ea3514a-9311-4153-b109-9397b7d038c6\", \"avail_status\": [], \"nfvi_data\": {\"last_update_timestamp\": \"2020-06-01T17:49:59Z\", \"vm_state\": \"active\", \"task_state\": \"none\", \"power_state\": \"running\"}, \"live_migration_support\": true, \"instance_type\": {\"ephemeral\": 1, \"ram\": 64, \"original_name\": \"small_ephemeral_swap\", \"vcpus\": 1, \"extra_specs\": {}, \"swap\": 1, \"disk\": 1}, \"oper_state\": \"enabled\", \"host_name\": \"compute-0\", \"image_uuid\": null, \"action\": \"\", \"admin_state\": \"unlocked\", \"uuid\": \"d9cc5957-f50f-4e5f-aee0-deaba829ff4a\"}", "live_migration_support": true, "unlock_to_recover": false, "oper_state": "enabled", "host_name": "compute-0", "action_data": "{\"action_uuid\": null, \"action_seqnum\": 7, \"action_state\": null, \"reason\": \"\", \"nfvi_action_data\": null, \"action_type\": \"\"}", "image_uuid": null, "action": "", "admin_state": "unlocked", "recoverable": true, "elapsed_time_in_state": "3617", "name": "cirros-ephemeral-swap-1"}, {"last_action_data": "{\"action_uuid\": null, \"action_seqnum\": 9, \"action_state\": null, \"reason\": \"\", \"nfvi_action_data\": null, \"action_type\": \"\"}", "guest_services": "{\"services\": {}, \"state\": null, \"nfvi_guest_services\": []}", "uuid": "c62009f4-7a31-4bfd-a056-7427fa5b5c6d", "elapsed_time_on_host": "3555", "avail_status": "[]", "nfvi_instance_data": "{\"attached_volumes\": [], \"live_migration_timeout\": null, \"name\": \"cirros-image-1\", \"recovery_priority\": null, \"tenant_id\": \"1ea3514a-9311-4153-b109-9397b7d038c6\", \"avail_status\": [], \"nfvi_data\": {\"last_update_timestamp\": \"2020-06-01T18:46:54Z\", \"vm_state\": \"active\", \"task_state\": \"none\", \"power_state\": \"running\"}, \"live_migration_support\": true, \"instance_type\": {\"ephemeral\": 0, \"ram\": 64, \"original_name\": \"small\", \"vcpus\": 1, \"extra_specs\": {}, \"swap\": 0, \"disk\": 1}, \"oper_state\": \"enabled\", \"host_name\": \"compute-1\", \"image_uuid\": \"fe42cee6-c2d5-478f-a8e2-d5f9c540ab7d\", \"action\": \"\", \"admin_state\": \"unlocked\", \"uuid\": \"c62009f4-7a31-4bfd-a056-7427fa5b5c6d\"}", "live_migration_support": true, "unlock_to_recover": false, "oper_state": "enabled", "host_name": "compute-1", "action_data": "{\"action_uuid\": \"59f1020b-cf1b-434d-abc1-7b7348498f81\", \"action_seqnum\": 38, \"action_state\": \"completed\", \"reason\": \"\", \"nfvi_action_data\": {\"context\": {\"content\": \"{\\\"rebuild\\\": {\\\"name\\\": \\\"cirros-image-1\\\", \\\"imageRef\\\": \\\"fe42cee6-c2d5-478f-a8e2-d5f9c540ab7d\\\"}}\", \"token_id\": \"gAAAAABe1UzIhO0ugVQx3Kcb6N76f4F2BJcFjxw16z7bYXT3q4HhiarNMDgfY6ldZtAv54kuohtarT6zbDkBMP7TeeB_J1UbuqkIyFmcGRgYjC1hAYovqgZhx7mQSWgkzeGIaMFuEroAcn532TN-ThT04SBNk0qCdHZvySs63tZmvKLc2RpMp_Q\", \"request_uuid\": \"59f1020b-cf1b-434d-abc1-7b7348498f81\", \"version\": \"2.53\", \"tenant_id\": \"1ea3514a93114153b1099397b7d038c6\"}, \"from_cli\": true, \"skip_guest_notify\": false, \"action_uuid\": \"59f1020b-cf1b-434d-abc1-7b7348498f81\", \"last_update_timestamp\": \"2020-06-01T18:45:29Z\", \"action_parameters\": \"{'instance-image-uuid': u'fe42cee6-c2d5-478f-a8e2-d5f9c540ab7d', 'instance-name': u'cirros-image-1'}\", \"action_state\": \"initial\", \"skip_guest_vote\": false, \"reason\": \"\", \"action_type\": \"rebuild\", \"created_timestamp\": \"2020-06-01T18:45:29Z\"}, \"action_type\": \"rebuild\"}", "image_uuid": "fe42cee6-c2d5-478f-a8e2-d5f9c540ab7d", "action": "", "admin_state": "unlocked", "recoverable": true, "elapsed_time_in_state": "231", "name": "cirros-image-1"}, {"last_action_data": "{\"action_uuid\": null, \"action_seqnum\": 12, \"action_state\": null, \"reason\": \"\", \"nfvi_action_data\": null, \"action_type\": \"\"}", "guest_services": "{\"services\": {}, \"state\": null, \"nfvi_guest_services\": []}", "uuid": "21c551cf-3135-4ab3-9da5-85c3cf396526", "elapsed_time_on_host": "3557", "avail_status": "[]", "nfvi_instance_data": "{\"attached_volumes\": [\"f81227f6-a8b9-459e-b195-97ede3ddb71a\"], \"live_migration_timeout\": null, \"name\": \"cirros-image-with-volumes-1\", \"recovery_priority\": null, \"tenant_id\": \"1ea3514a-9311-4153-b109-9397b7d038c6\", \"avail_status\": [], \"nfvi_data\": {\"last_update_timestamp\": \"2020-06-01T17:51:38Z\", \"vm_state\": \"active\", \"task_state\": \"none\", \"power_state\": \"running\"}, \"live_migration_support\": true, \"instance_type\": {\"ephemeral\": 0, \"ram\": 64, \"original_name\": \"small\", \"vcpus\": 1, \"extra_specs\": {}, \"swap\": 0, \"disk\": 1}, \"oper_state\": \"enabled\", \"host_name\": \"compute-0\", \"image_uuid\": \"fe42cee6-c2d5-478f-a8e2-d5f9c540ab7d\", \"action\": \"\", \"admin_state\": \"unlocked\", \"uuid\": \"21c551cf-3135-4ab3-9da5-85c3cf396526\"}", "live_migration_support": true, "unlock_to_recover": false, "oper_state": "enabled", "host_name": "compute-0", "action_data": "{\"action_uuid\": null, \"action_seqnum\": 11, \"action_state\": null, \"reason\": \"\", \"nfvi_action_data\": null, \"action_type\": \"\"}", "image_uuid": "fe42cee6-c2d5-478f-a8e2-d5f9c540ab7d", "action": "", "admin_state": "unlocked", "recoverable": true, "elapsed_time_in_state": "3524", "name": "cirros-image-with-volumes-1"}], "instances_v4": [], "hypervisors": [{"stats_available": true, "mem_max_mb": 8191, "uuid": "2056f1d0-68fe-4e1e-ac34-52f3ee485f35", "vcpus_used": 2, "vcpus_max": 2, "running_instances": 2, "disk_max_gb": 9, "nfvi_hypervisor_data": "{\"mem_max_mb\": 8191, \"uuid\": \"2056f1d0-68fe-4e1e-ac34-52f3ee485f35\", \"vcpus_used\": 2, \"vcpus_max\": 2, \"disk_max_gb\": 9, \"admin_state\": \"unlocked\", \"host_name\": \"compute-1\", \"mem_free_mb\": 5563, \"mem_used_mb\": 2628, \"disk_used_gb\": 1, \"oper_state\": \"enabled\", \"running_vms\": 2}", "oper_state": "enabled", "host_name": "compute-1", "mem_free_mb": 5563, "admin_state": "unlocked", "mem_used_mb": 2628, "disk_used_gb": 1}, {"stats_available": true, "mem_max_mb": 8191, "uuid": "77ece7e2-4b5d-46ee-8c65-43d69e64a7f9", "vcpus_used": 5, "vcpus_max": 2, "running_instances": 4, "disk_max_gb": 9, "nfvi_hypervisor_data": "{\"mem_max_mb\": 8191, \"uuid\": \"77ece7e2-4b5d-46ee-8c65-43d69e64a7f9\", \"vcpus_used\": 5, \"vcpus_max\": 2, \"disk_max_gb\": 9, \"admin_state\": \"unlocked\", \"host_name\": \"compute-0\", \"mem_free_mb\": 5371, \"mem_used_mb\": 2820, \"disk_used_gb\": 3, \"oper_state\": \"enabled\", \"running_vms\": 4}", "oper_state": "enabled", "host_name": "compute-0", "mem_free_mb": 5371, "admin_state": "unlocked", "mem_used_mb": 2820, "disk_used_gb": 3}], "subnets": [{"is_dhcp_enabled": true, "network_uuid": "78b76f2e-4e34-4534-a991-d946acb439f5", "uuid": "b248db56-4a16-4951-9657-b54544a48b1c", "subnet_prefix": 24, "gateway_ip": "192.168.51.1", "ip_version": "4", "subnet_ip": "192.168.51.0", "name": "external"}, {"is_dhcp_enabled": true, "network_uuid": "b9ac0c6a-105a-45b2-834b-e0b751e25d5b", "uuid": "c97f8d67-6ffb-4daf-80ec-0082a2d8da2f", "subnet_prefix": 24, "gateway_ip": "192.168.50.1", "ip_version": "4", "subnet_ip": "192.168.50.0", "name": "internal"}], "hosts_v6": [{"uptime": "19072", "uuid": "9d36913b-53d7-4d1a-ab51-106672fe8411", "recover_instances": true, "host_services_locked": false, "name": "controller-0", "nfvi_host_data": "{\"software_load\": \"19.12\", \"uptime\": 19072, \"openstack_control\": true, \"target_load\": \"19.12\", \"openstack_compute\": false, \"avail_status\": \"available\", \"nfvi_data\": {\"subfunction_oper\": \"n/a\", \"uuid\": \"9d36913b-53d7-4d1a-ab51-106672fe8411\", \"subfunctions\": \"controller\", \"avail_status\": \"available\", \"subfunction_avail\": \"n/a\", \"name\": \"controller-0\", \"subfunction_name\": \"n/a\", \"admin_state\": \"unlocked\", \"data_ports_avail\": \"n/a\", \"oper_state\": \"enabled\", \"data_ports_oper\": \"n/a\", \"data_ports_name\": \"n/a\", \"personality\": \"controller\"}, \"name\": \"controller-0\", \"oper_state\": \"enabled\", \"remote_storage\": false, \"action\": \"unlock\", \"admin_state\": \"unlocked\", \"personality\": \"controller\", \"uuid\": \"9d36913b-53d7-4d1a-ab51-106672fe8411\"}", "state": "enabled", "upgrade_inprogress": false, "action": "", "elapsed_time_in_state": "18419", "personality": "controller"}, {"uptime": "17116", "uuid": "9fb70a98-4e1d-48df-8ef2-ade117bb28b4", "recover_instances": true, "host_services_locked": false, "name": "controller-1", "nfvi_host_data": "{\"software_load\": \"19.12\", \"uptime\": 17116, \"openstack_control\": true, \"target_load\": \"19.12\", \"openstack_compute\": false, \"avail_status\": \"available\", \"nfvi_data\": {\"subfunction_oper\": \"n/a\", \"uuid\": \"9fb70a98-4e1d-48df-8ef2-ade117bb28b4\", \"subfunctions\": \"controller\", \"avail_status\": \"available\", \"subfunction_avail\": \"n/a\", \"name\": \"controller-1\", \"subfunction_name\": \"n/a\", \"admin_state\": \"unlocked\", \"data_ports_avail\": \"n/a\", \"oper_state\": \"enabled\", \"data_ports_oper\": \"n/a\", \"data_ports_name\": \"n/a\", \"personality\": \"controller\"}, \"name\": \"controller-1\", \"oper_state\": \"enabled\", \"remote_storage\": false, \"action\": \"unlock\", \"admin_state\": \"unlocked\", \"personality\": \"controller\", \"uuid\": \"9fb70a98-4e1d-48df-8ef2-ade117bb28b4\"}", "state": "enabled", "upgrade_inprogress": false, "action": "", "elapsed_time_in_state": "16844", "personality": "controller"}, {"uptime": "15967", "uuid": "3bc1506f-3375-4204-8319-269b2b00ab58", "recover_instances": true, "host_services_locked": false, "name": "compute-0", "nfvi_host_data": "{\"software_load\": \"19.12\", \"uptime\": 15967, \"openstack_control\": false, \"target_load\": \"19.12\", \"openstack_compute\": true, \"avail_status\": \"available\", \"nfvi_data\": {\"subfunction_oper\": \"n/a\", \"uuid\": \"3bc1506f-3375-4204-8319-269b2b00ab58\", \"subfunctions\": \"worker\", \"avail_status\": \"available\", \"subfunction_avail\": \"n/a\", \"name\": \"compute-0\", \"subfunction_name\": \"n/a\", \"admin_state\": \"unlocked\", \"data_ports_avail\": \"n/a\", \"oper_state\": \"enabled\", \"data_ports_oper\": \"n/a\", \"data_ports_name\": \"n/a\", \"personality\": \"worker\"}, \"name\": \"compute-0\", \"oper_state\": \"enabled\", \"remote_storage\": false, \"action\": \"unlock\", \"admin_state\": \"unlocked\", \"personality\": \"worker\", \"uuid\": \"3bc1506f-3375-4204-8319-269b2b00ab58\"}", "state": "enabled", "upgrade_inprogress": false, "action": "", "elapsed_time_in_state": "11671", "personality": "worker"}, {"uptime": "15963", "uuid": "97ba87d6-27d4-4daa-9ca1-40b580e3d5b7", "recover_instances": true, "host_services_locked": false, "name": "compute-1", "nfvi_host_data": "{\"software_load\": \"19.12\", \"uptime\": 15963, \"openstack_control\": false, \"target_load\": \"19.12\", \"openstack_compute\": true, \"avail_status\": \"available\", \"nfvi_data\": {\"subfunction_oper\": \"n/a\", \"uuid\": \"97ba87d6-27d4-4daa-9ca1-40b580e3d5b7\", \"subfunctions\": \"worker\", \"avail_status\": \"available\", \"subfunction_avail\": \"n/a\", \"name\": \"compute-1\", \"subfunction_name\": \"n/a\", \"admin_state\": \"unlocked\", \"data_ports_avail\": \"n/a\", \"oper_state\": \"enabled\", \"data_ports_oper\": \"n/a\", \"data_ports_name\": \"n/a\", \"personality\": \"worker\"}, \"name\": \"compute-1\", \"oper_state\": \"enabled\", \"remote_storage\": false, \"action\": \"unlock\", \"admin_state\": \"unlocked\", \"personality\": \"worker\", \"uuid\": \"97ba87d6-27d4-4daa-9ca1-40b580e3d5b7\"}", "state": "enabled", "upgrade_inprogress": false, "action": "", "elapsed_time_in_state": "11672", "personality": "worker"}], "instance_types_v5": [{"mem_mb": 512, "live_migration_max_downtime": null, "uuid": "2fa093ba-f9fc-4a73-b7a4-32b155eebf39", "disk_gb": 1, "guest_services": "{}", "auto_recovery": null, "ephemeral_gb": 0, "swap_gb": 0, "vcpus": 1, "have_details": true, "live_migration_timeout": null, "name": "m1.tiny"}, {"mem_mb": 2048, "live_migration_max_downtime": null, "uuid": "962d3c7b-d8cd-4bdd-9807-62ee58387c9a", "disk_gb": 20, "guest_services": "{}", "auto_recovery": null, "ephemeral_gb": 0, "swap_gb": 0, "vcpus": 1, "have_details": true, "live_migration_timeout": null, "name": "m1.small"}, {"mem_mb": 8192, "live_migration_max_downtime": null, "uuid": "cbe77f5f-4ec6-45f5-be58-a3e6085bcac9", "disk_gb": 80, "guest_services": "{}", "auto_recovery": null, "ephemeral_gb": 0, "swap_gb": 0, "vcpus": 4, "have_details": true, "live_migration_timeout": null, "name": "m1.large"}, {"mem_mb": 16384, "live_migration_max_downtime": null, "uuid": "de4bce8d-be10-42eb-b706-2fdae7c96ed8", "disk_gb": 160, "guest_services": "{}", "auto_recovery": null, "ephemeral_gb": 0, "swap_gb": 0, "vcpus": 8, "have_details": true, "live_migration_timeout": null, "name": "m1.xlarge"}, {"mem_mb": 4096, "live_migration_max_downtime": null, "uuid": "e2e2d2f7-15a4-4c6a-a016-aa96a1c6807b", "disk_gb": 40, "guest_services": "{}", "auto_recovery": null, "ephemeral_gb": 0, "swap_gb": 0, "vcpus": 2, "have_details": true, "live_migration_timeout": null, "name": "m1.medium"}, {"mem_mb": 128, "live_migration_max_downtime": null, "uuid": "1dbc5262-1671-48b8-9473-6033dfd7fe21", "disk_gb": 1, "guest_services": "{}", "auto_recovery": null, "ephemeral_gb": 0, "swap_gb": 1, "vcpus": 2, "have_details": true, "live_migration_timeout": null, "name": "medium_swap"}, {"mem_mb": 64, "live_migration_max_downtime": null, "uuid": "36ef7356-c794-4d74-b2dd-b9b336e6b256", "disk_gb": 1, "guest_services": "{}", "auto_recovery": null, "ephemeral_gb": 0, "swap_gb": 0, "vcpus": 1, "have_details": true, "live_migration_timeout": null, "name": "small"}, {"mem_mb": 64, "live_migration_max_downtime": null, "uuid": "56c244d2-8430-40d0-b7be-9a7a3a454805", "disk_gb": 1, "guest_services": "{}", "auto_recovery": null, "ephemeral_gb": 1, "swap_gb": 1, "vcpus": 1, "have_details": true, "live_migration_timeout": null, "name": "small_ephemeral_swap"}, {"mem_mb": 128, "live_migration_max_downtime": null, "uuid": "5d049d11-a990-4a40-865f-d9ea3bb1bddc", "disk_gb": 1, "guest_services": "{}", "auto_recovery": null, "ephemeral_gb": 1, "swap_gb": 0, "vcpus": 2, "have_details": true, "live_migration_timeout": null, "name": "medium_ephemeral"}, {"mem_mb": 64, "live_migration_max_downtime": null, "uuid": "ad83e761-ce7e-4e6c-ae49-93d8fc07348b", "disk_gb": 1, "guest_services": "{}", "auto_recovery": null, "ephemeral_gb": 0, "swap_gb": 1, "vcpus": 1, "have_details": true, "live_migration_timeout": null, "name": "small_swap"}, {"mem_mb": 64, "live_migration_max_downtime": null, "uuid": "b0b2a3a9-126f-4759-8c8b-f95f0dd8e83f", "disk_gb": 1, "guest_services": "{}", "auto_recovery": null, "ephemeral_gb": 1, "swap_gb": 0, "vcpus": 1, "have_details": true, "live_migration_timeout": null, "name": "small_ephemeral"}, {"mem_mb": 128, "live_migration_max_downtime": null, "uuid": "fabfbe43-69ed-458e-9b42-fe3420457d59", "disk_gb": 1, "guest_services": "{}", "auto_recovery": null, "ephemeral_gb": 1, "swap_gb": 1, "vcpus": 2, "have_details": true, "live_migration_timeout": null, "name": "medium_ephemeral_swap"}, {"mem_mb": 128, "live_migration_max_downtime": null, "uuid": "fe00e091-fd6e-4d8e-81e0-ee0ead80b032", "disk_gb": 1, "guest_services": "{}", "auto_recovery": null, "ephemeral_gb": 0, "swap_gb": 0, "vcpus": 2, "have_details": true, "live_migration_timeout": null, "name": "medium"}], "host_aggregates": [], "hosts_v5": [], "volume_snapshots": [], "volumes_v1": [{"size_gb": 1, "description": "", "nfvi_volume_data": "{\"size_gb\": 1, \"description\": \"\", \"bootable\": \"yes\", \"encrypted\": \"no\", \"avail_status\": [\"in-use\"], \"name\": \"cirros\", \"action\": \"\", \"image_uuid\": \"fe42cee6-c2d5-478f-a8e2-d5f9c540ab7d\", \"uuid\": \"7a57b69c-3b55-4537-8cc8-c97beb75471a\"}", "bootable": "yes", "encrypted": "no", "avail_status": "[\"in-use\"]", "name": "cirros", "action": "", "image_uuid": "fe42cee6-c2d5-478f-a8e2-d5f9c540ab7d", "uuid": "7a57b69c-3b55-4537-8cc8-c97beb75471a"}, {"size_gb": 1, "description": "", "nfvi_volume_data": "{\"size_gb\": 1, \"description\": \"\", \"bootable\": \"no\", \"encrypted\": \"no\", \"avail_status\": [\"in-use\"], \"name\": \"empty_volume\", \"action\": \"\", \"image_uuid\": null, \"uuid\": \"f81227f6-a8b9-459e-b195-97ede3ddb71a\"}", "bootable": "no", "encrypted": "no", "avail_status": "[\"in-use\"]", "name": "empty_volume", "action": "", "image_uuid": null, "uuid": "f81227f6-a8b9-459e-b195-97ede3ddb71a"}, {"size_gb": 1, "description": "", "nfvi_volume_data": "{\"size_gb\": 1, \"description\": \"\", \"bootable\": \"yes\", \"encrypted\": \"no\", \"avail_status\": [\"in-use\"], \"name\": \"cirros-ephemeral-swap\", \"action\": \"\", \"image_uuid\": \"fe42cee6-c2d5-478f-a8e2-d5f9c540ab7d\", \"uuid\": \"a547de3f-b504-4917-bc9f-48242e9a1d79\"}", "bootable": "yes", "encrypted": "no", "avail_status": "[\"in-use\"]", "name": "cirros-ephemeral-swap", "action": "", "image_uuid": "fe42cee6-c2d5-478f-a8e2-d5f9c540ab7d", "uuid": "a547de3f-b504-4917-bc9f-48242e9a1d79"}, {"size_gb": 1, "description": "", "nfvi_volume_data": "{\"size_gb\": 1, \"description\": \"\", \"bootable\": \"yes\", \"encrypted\": \"no\", \"avail_status\": [\"in-use\"], \"name\": \"cirros-swap\", \"action\": \"\", \"image_uuid\": \"fe42cee6-c2d5-478f-a8e2-d5f9c540ab7d\", \"uuid\": \"1a002e19-52b2-4e3d-bfbb-b8eba2f14930\"}", "bootable": "yes", "encrypted": "no", "avail_status": "[\"in-use\"]", "name": "cirros-swap", "action": "", "image_uuid": "fe42cee6-c2d5-478f-a8e2-d5f9c540ab7d", "uuid": "1a002e19-52b2-4e3d-bfbb-b8eba2f14930"}, {"size_gb": 1, "description": "", "nfvi_volume_data": "{\"size_gb\": 1, \"description\": \"\", \"bootable\": \"yes\", \"encrypted\": \"no\", \"avail_status\": [\"in-use\"], \"name\": \"cirros-ephemeral\", \"action\": \"\", \"image_uuid\": \"fe42cee6-c2d5-478f-a8e2-d5f9c540ab7d\", \"uuid\": \"1fccdb35-55ce-468e-a034-3f4d449dbb43\"}", "bootable": "yes", "encrypted": "no", "avail_status": "[\"in-use\"]", "name": "cirros-ephemeral", "action": "", "image_uuid": "fe42cee6-c2d5-478f-a8e2-d5f9c540ab7d", "uuid": "1fccdb35-55ce-468e-a034-3f4d449dbb43"}, {"size_gb": 1, "description": "", "nfvi_volume_data": "{\"size_gb\": 1, \"description\": \"\", \"bootable\": \"no\", \"encrypted\": \"no\", \"avail_status\": [\"available\"], \"name\": \"image-fe42cee6-c2d5-478f-a8e2-d5f9c540ab7d\", \"action\": \"\", \"image_uuid\": null, \"uuid\": \"baf68b4a-f108-476c-8df5-325591054132\"}", "bootable": "no", "encrypted": "no", "avail_status": "[\"available\"]", "name": "image-fe42cee6-c2d5-478f-a8e2-d5f9c540ab7d", "action": "", "image_uuid": null, "uuid": "baf68b4a-f108-476c-8df5-325591054132"}], "instance_types_v4": [], "service_hosts": [], "instance_groups": [], "systems": [{"name": "8b37cd27-dd14-43e8-b8aa-6977758dca0e", "description": ""}], "host_groups": [], "sw_updates": [], "images": [{"properties": "{\"hw_wrs_live_migration_timeout\": null, \"hw_wrs_live_migration_max_downtime\": null}", "description": "", "container_format": "bare", "avail_status": "[\"available\"]", "disk_format": "qcow2", "visibility": "public", "name": "cirros", "min_disk_size_gb": 0, "protected": "no", "nfvi_image_data": "{\"description\": \"\", \"name\": \"cirros\", \"container_format\": \"bare\", \"min_memory_size_mb\": 0, \"disk_format\": \"qcow2\", \"visibility\": \"public\", \"properties\": {\"hw_wrs_live_migration_timeout\": null, \"hw_wrs_live_migration_max_downtime\": null}, \"min_disk_size_gb\": 0, \"protected\": \"no\", \"action\": \"\", \"avail_status\": [\"available\"], \"uuid\": \"fe42cee6-c2d5-478f-a8e2-d5f9c540ab7d\"}", "action": "", "min_memory_size_mb": 0, "uuid": "fe42cee6-c2d5-478f-a8e2-d5f9c540ab7d"}], "tenants": [{"description": "Bootstrap project for initializing the cloud.", "enabled": "1", "uuid": "1ea3514a-9311-4153-b109-9397b7d038c6", "name": "admin"}, {"description": "", "enabled": "1", "uuid": "66d84487-4cab-4bb5-94fd-de6170aed20c", "name": "internal_cinder"}, {"description": "Service Project for RegionOne/service", "enabled": "1", "uuid": "f1dcf022-82b9-4e7a-9376-f01b05276ff2", "name": "service"}], "networks": [{"is_shared": true, "segmentation_id": "500", "avail_status": "[]", "physical_network": "physnet1", "name": "external", "oper_state": "enabled", "admin_state": "unlocked", "mtu": 1500, "network_type": "vlan", "uuid": "78b76f2e-4e34-4534-a991-d946acb439f5"}, {"is_shared": true, "segmentation_id": "400", "avail_status": "[]", "physical_network": "physnet0", "name": "internal", "oper_state": "enabled", "admin_state": "unlocked", "mtu": 1500, "network_type": "vlan", "uuid": "b9ac0c6a-105a-45b2-834b-e0b751e25d5b"}]}, "version": 1} \ No newline at end of file diff --git a/nfv/nfv-tests/nfv_unit_tests/tests/test_database_upgrades.py b/nfv/nfv-tests/nfv_unit_tests/tests/test_database_upgrades.py index de64e84d..5098ec53 100755 --- a/nfv/nfv-tests/nfv_unit_tests/tests/test_database_upgrades.py +++ b/nfv/nfv-tests/nfv_unit_tests/tests/test_database_upgrades.py @@ -14,16 +14,16 @@ from . import testcase # noqa: H304 class TestNFVDatabaseUpgrade(testcase.NFVTestCase): - def test_nfv_vim_database_upgrade_from_18_03(self): + def test_nfv_vim_database_upgrade_from_19_12(self): """ - Test VIM database upgrades from 18.03 GA + Test VIM database upgrades from stx 19_12 """ root_dir = os.environ['VIRTUAL_ENV'] devnull = open(os.devnull, 'w') try: vim_cmd = ("nfv-vim-manage db-load-data -d %s " - "-f %s/nfv_vim_db_18.03_GA" % (root_dir, root_dir)) + "-f %s/nfv_vim_db_stx_19.12" % (root_dir, root_dir)) subprocess.check_call([vim_cmd], shell=True, stderr=devnull) 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 08c08a8b..a28993fc 100755 --- a/nfv/nfv-vim/nfv_vim/database/_database_infrastructure_module.py +++ b/nfv/nfv-vim/nfv_vim/database/_database_infrastructure_module.py @@ -64,10 +64,10 @@ def database_host_add(host_obj): """ db = database_get() session = db.session() - query = session.query(model.Host_v6).filter(model.Host_v6.name == host_obj.name) + query = session.query(model.Host_v7).filter(model.Host_v7.name == host_obj.name) host = query.first() if not host: - host = model.Host_v6() + host = model.Host_v7() host.uuid = host_obj.uuid host.name = host_obj.name host.personality = host_obj.personality @@ -98,8 +98,8 @@ def database_host_delete(host_name): """ db = database_get() session = db.session() - query = session.query(model.Host_v6) - query.filter(model.Host_v6.name == host_name).delete() + query = session.query(model.Host_v7) + query.filter(model.Host_v7.name == host_name).delete() session.commit() @@ -124,6 +124,7 @@ def database_host_get_list(): nfvi_host_data['uptime'], nfvi_host_data['software_load'], nfvi_host_data['target_load'], + nfvi_host_data['device_image_update'], nfvi_host_data['openstack_compute'], nfvi_host_data['openstack_control'], nfvi_host_data['remote_storage'], diff --git a/nfv/nfv-vim/nfv_vim/database/_database_migrate.py b/nfv/nfv-vim/nfv_vim/database/_database_migrate.py index 350764af..b06df3a7 100755 --- a/nfv/nfv-vim/nfv_vim/database/_database_migrate.py +++ b/nfv/nfv-vim/nfv_vim/database/_database_migrate.py @@ -12,53 +12,28 @@ from nfv_common import debug DLOG = debug.debug_get_logger('nfv_vim.database') -def _migrate_hosts_v5_to_v6(session, hosts_v5, hosts_v6): +def _migrate_hosts_v6_to_v7(session, hosts_v6, hosts_v7): """ - Migrate host_v5 table to host_v6 table + Migrate host_v6 table to host_v7 table """ - 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 - nfvi_host_data['remote_storage'] = False - host_v6.nfvi_host_data = json.dumps(nfvi_host_data) - session.add(host_v6) - - -def _migrate_instance_types_v4_to_v5(session, instance_types_v4, - instance_types_v5): - """ - Migrate instance_types_v4 table to instance_types_v5 table - """ - if 0 == len(instance_types_v5): - for instance_type_v4 in instance_types_v4: - instance_type_v5 = model.InstanceType_v5() - del instance_type_v4.data['storage_type'] - instance_type_v5.data = instance_type_v4.data - session.add(instance_type_v5) + if 0 == len(hosts_v7): + for host_v6 in hosts_v6: + host_v7 = model.Host_v7() + host_v7.data = host_v6.data + nfvi_host_data = json.loads(host_v6.nfvi_host_data) + nfvi_host_data['device_image_update'] = None + host_v7.nfvi_host_data = json.dumps(nfvi_host_data) + session.add(host_v7) def migrate_tables(session, table_names): """ Migrate database tables """ - 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() + if 'hosts_v6' in table_names and 'hosts_v7' in table_names: 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() - - if 'instance_types_v4' in table_names and \ - 'instance_types_v5' in table_names: - instance_types_v4_query = session.query(model.InstanceType) - instance_types_v4 = instance_types_v4_query.all() - instance_types_v5_query = session.query(model.InstanceType_v5) - instance_types_v5 = instance_types_v5_query.all() - _migrate_instance_types_v4_to_v5(session, instance_types_v4, - instance_types_v5) - instance_types_v4_query.delete() + hosts_v7_query = session.query(model.Host_v7) + hosts_v7 = hosts_v7_query.all() + _migrate_hosts_v6_to_v7(session, hosts_v6, hosts_v7) + hosts_v6_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 8cfbafe5..315a7401 100755 --- a/nfv/nfv-vim/nfv_vim/database/model/__init__.py +++ b/nfv/nfv-vim/nfv_vim/database/model/__init__.py @@ -5,8 +5,8 @@ # from nfv_vim.database.model._base import Base # noqa: F401 from nfv_vim.database.model._base import lookup_class_by_table # 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 import Host_v7 # 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._hypervisor import Hypervisor # 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 f377229c..02237a3c 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_v7(AsDictMixin, Base): + """ + Host Database Table Entry + Note: Changes are only in nfvi_host_data to add device_image_update string + """ + __tablename__ = 'hosts_v7' + + 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_v6(AsDictMixin, Base): """ Host Database Table Entry @@ -34,28 +59,3 @@ class Host_v6(AsDictMixin, Base): return "" % (self.uuid, self.name, self.personality, self.state, self.action, self.uptime) - - -class Host_v5(AsDictMixin, Base): - """ - Host Database Table Entry - Note: There were changes in both the attributes and the nfvi_host_data. - """ - __tablename__ = 'hosts_v5' - - 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) 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 d3f314be..f3630c39 100755 --- a/nfv/nfv-vim/nfv_vim/nfvi/objects/v1/_host.py +++ b/nfv/nfv-vim/nfv_vim/nfvi/objects/v1/_host.py @@ -107,6 +107,7 @@ class Host(ObjectData): """ def __init__(self, uuid, name, personality, admin_state, oper_state, avail_status, action, uptime, software_load, target_load, + device_image_update=None, openstack_compute=False, openstack_control=False, remote_storage=False, @@ -120,6 +121,7 @@ class Host(ObjectData): uptime=uptime, software_load=software_load, target_load=target_load, + device_image_update=device_image_update, openstack_compute=openstack_compute, openstack_control=openstack_control, remote_storage=remote_storage)) diff --git a/nfv/nfv-vim/nfv_vim/strategy/__init__.py b/nfv/nfv-vim/nfv_vim/strategy/__init__.py index 01f340af..080f4904 100755 --- a/nfv/nfv-vim/nfv_vim/strategy/__init__.py +++ b/nfv/nfv-vim/nfv_vim/strategy/__init__.py @@ -16,7 +16,7 @@ from nfv_vim.strategy._strategy_steps import FwUpdateHostsStep # noqa: F401 from nfv_vim.strategy._strategy_steps import LockHostsStep # noqa: F401 from nfv_vim.strategy._strategy_steps import MigrateInstancesStep # noqa: F401 from nfv_vim.strategy._strategy_steps import QueryAlarmsStep # noqa: F401 -from nfv_vim.strategy._strategy_steps import QueryHostDeviceListStep # noqa: F401 +from nfv_vim.strategy._strategy_steps import QueryFwUpdateHostStep # noqa: F401 from nfv_vim.strategy._strategy_steps import QuerySwPatchesStep # noqa: F401 from nfv_vim.strategy._strategy_steps import QuerySwPatchHostsStep # noqa: F401 from nfv_vim.strategy._strategy_steps import QueryUpgradeStep # noqa: F401 diff --git a/nfv/nfv-vim/nfv_vim/strategy/_strategy.py b/nfv/nfv-vim/nfv_vim/strategy/_strategy.py index 054338f4..04b4bdcf 100755 --- a/nfv/nfv-vim/nfv_vim/strategy/_strategy.py +++ b/nfv/nfv-vim/nfv_vim/strategy/_strategy.py @@ -1732,7 +1732,7 @@ class FwUpdateStrategy(SwUpdateStrategy): for host in host_table.values(): if HOST_PERSONALITY.WORKER in host.personality: if host.is_unlocked() and host.is_enabled(): - stage.add_step(strategy.QueryHostDeviceListStep(host)) + stage.add_step(strategy.QueryFwUpdateHostStep(host)) self.build_phase.add_stage(stage) super(FwUpdateStrategy, self).build() diff --git a/nfv/nfv-vim/nfv_vim/strategy/_strategy_steps.py b/nfv/nfv-vim/nfv_vim/strategy/_strategy_steps.py index 28be5496..5d17ffe9 100755 --- a/nfv/nfv-vim/nfv_vim/strategy/_strategy_steps.py +++ b/nfv/nfv-vim/nfv_vim/strategy/_strategy_steps.py @@ -45,8 +45,7 @@ class StrategyStepNames(Constants): WAIT_DATA_SYNC = Constant('wait-data-sync') QUERY_SW_PATCHES = Constant('query-sw-patches') QUERY_SW_PATCH_HOSTS = Constant('query-sw-patch-hosts') - QUERY_HOST_DEVICES = Constant('query-host-devices') - QUERY_HOST_DEVICE = Constant('query-host-device') + QUERY_FW_UPDATE_HOST = Constant('query-fw-update-host') QUERY_UPGRADE = Constant('query-upgrade') DISABLE_HOST_SERVICES = Constant('disable-host-services') ENABLE_HOST_SERVICES = Constant('enable-host-services') @@ -1751,19 +1750,18 @@ class QuerySwPatchHostsStep(strategy.StrategyStep): return data -class QueryHostDeviceListStep(strategy.StrategyStep): +class QueryFwUpdateHostStep(strategy.StrategyStep): """ - Query Host Device List + Query Host """ - # This step queries system inventory for each host's device list. - # Any hosts whose devices have a firmware update pending have its name - # added to _fw_update_hosts to build a list of host names that require - # firmware update. + # This step queries system inventory for the host in self._host_names + # If the host's 'device_image_update' field shows 'pending' then its + # hostname is added to the strategy's fw_update_hosts list. def __init__(self, host): - super(QueryHostDeviceListStep, self).__init__( - STRATEGY_STEP_NAME.QUERY_HOST_DEVICES, timeout_in_secs=60) + super(QueryFwUpdateHostStep, self).__init__( + STRATEGY_STEP_NAME.QUERY_FW_UPDATE_HOST, timeout_in_secs=60) self._host_names = list() self._host_uuids = list() @@ -1771,38 +1769,36 @@ class QueryHostDeviceListStep(strategy.StrategyStep): self._host_uuids.append(host.uuid) @coroutine - def _get_host_devices_callback(self): + def _get_host_callback(self): """ - Query Host Device List callback + Query Host callback """ - from nfv_vim import tables response = (yield) - DLOG.verbose("get-host-devices %s callback response=%s." % + DLOG.verbose("Get-Host %s callback response=%s." % (self._host_names[0], response)) if response['completed']: if self.strategy is not None: - pci_devices = response['result-data'].get('pci_devices') - if pci_devices: - host_added_to_fw_update_hosts_list = False - for pci_device in pci_devices: - if pci_device.get(FW_UPDATE_LABEL.DEVICE_IMAGE_NEEDS_FIRMWARE_UPDATE) is False: - DLOG.verbose("%s:%s device is up-to-date" % - (self._host_names[0], - pci_device.get('name'))) - continue - - # using existing vim host inventory for host info - host_table = tables.tables_get_host_table() - for host in host_table.values(): - if host.uuid == pci_device['host_uuid']: - DLOG.info("%s:%s device requires update" % - (host.name, pci_device.get('name'))) - if host_added_to_fw_update_hosts_list is False: - self.strategy.fw_update_hosts.append(host.name) - host_added_to_fw_update_hosts_list = True + hostname = response['result-data'].get('name') + if hostname: + device_image_update = response['result-data'].get('device_image_update') + # device_image_update = 'pending' + if device_image_update is None: + DLOG.verbose("%s no firmware update required" % hostname) + elif device_image_update == FW_UPDATE_LABEL.DEVICE_IMAGE_UPDATE_PENDING: + self.strategy.fw_update_hosts.append(hostname) + # DLOG.verbose("%s requires firmware update" % hostname) + DLOG.info("%s requires firmware update" % hostname) + elif device_image_update == FW_UPDATE_LABEL.DEVICE_IMAGE_UPDATE_IN_PROGRESS: + DLOG.info("%s firmware update in-progress" % hostname) + elif device_image_update == FW_UPDATE_LABEL.DEVICE_IMAGE_UPDATE_COMPLETED: + DLOG.info("%s firmware update complete" % hostname) + elif device_image_update == FW_UPDATE_LABEL.DEVICE_IMAGE_UPDATE_FAILED: + DLOG.info("%s firmware update failed" % hostname) + else: + DLOG.error("%s firmware update ; unknown state '%s'" % (hostname, device_image_update)) result = strategy.STRATEGY_STEP_RESULT.SUCCESS self.stage.step_complete(result, "") @@ -1812,23 +1808,23 @@ class QueryHostDeviceListStep(strategy.StrategyStep): def apply(self): """ - Query Host Device List Apply + Query Host Apply """ from nfv_vim import nfvi DLOG.info("%s %s step apply" % (self._host_names[0], self._name)) # This step is only ever called with one host name. - nfvi.nfvi_get_host_devices(self._host_uuids[0], - self._host_names[0], - self._get_host_devices_callback()) + nfvi.nfvi_get_host(self._host_uuids[0], + self._host_names[0], + self._get_host_callback()) return strategy.STRATEGY_STEP_RESULT.WAIT, "" def from_dict(self, data): """ Load the firmware update host device list step """ - super(QueryHostDeviceListStep, self).from_dict(data) + super(QueryFwUpdateHostStep, self).from_dict(data) self._host_names = data['entity_names'] self._host_uuids = data['entity_uuids'] return self @@ -1837,7 +1833,7 @@ class QueryHostDeviceListStep(strategy.StrategyStep): """ Represent the object as a dictionary for the strategy """ - data = super(QueryHostDeviceListStep, self).as_dict() + data = super(QueryFwUpdateHostStep, self).as_dict() data['entity_type'] = '' data['entity_names'] = self._host_names data['entity_uuids'] = self._host_uuids @@ -1853,66 +1849,95 @@ class FwUpdateHostsStep(strategy.StrategyStep): super(FwUpdateHostsStep, self).__init__( STRATEGY_STEP_NAME.FW_UPDATE_HOSTS, timeout_in_secs=3600) - # Constants - self.MONITOR_THRESHOLD = 0 - self._hosts = hosts self._host_names = list() self._host_uuids = list() self._monitoring_fw_update = False self._wait_time = 0 self._host_failed_device_update = dict() - self._host_monitor_counter = dict() self._host_completed = dict() for host in hosts: self._host_names.append(host.name) self._host_uuids.append(host.uuid) self._host_completed[host.name] = (False, False, '') - self._host_monitor_counter[host.uuid] = 0 self._host_failed_device_update[host.name] = list() @coroutine - def _host_devices_list_callback(self): + def _get_host_callback(self): """ - Query Host Device List callback used for monitoring update process + Query Host callback used for monitoring update process """ response = (yield) - DLOG.debug("Host-Device-List callback response=%s." % response) + DLOG.debug("Get-Host callback response=%s." % response) try: if response['completed']: if self.strategy is not None: - # find the host for this callback response - host_uuid = response['result-data']['pci_devices'][0].get('host_uuid') - if host_uuid: - if len(self._hosts): - for host in self._hosts: - if host.uuid == host_uuid: - # found it - self._host_monitor_counter[host.uuid] += 1 - pci_devices = response['result-data'].get('pci_devices') - if len(pci_devices): - self._check_status(host.name, - host.uuid, - pci_devices) - return - else: - DLOG.info("failed to find any pci devices") + hostname = response['result-data'].get('name') + if hostname: + device_image_update = response['result-data'].get('device_image_update') + if device_image_update is None: + DLOG.verbose("%s no firmware update required" % hostname) + elif device_image_update == FW_UPDATE_LABEL.DEVICE_IMAGE_UPDATE_PENDING: + self.strategy.fw_update_hosts.append(hostname) + DLOG.info("%s requires firmware update" % hostname) + elif device_image_update == FW_UPDATE_LABEL.DEVICE_IMAGE_UPDATE_IN_PROGRESS: + DLOG.info("%s firmware update in-progress" % hostname) + elif device_image_update == FW_UPDATE_LABEL.DEVICE_IMAGE_UPDATE_COMPLETED: + if self._host_completed[hostname][0] is False: + self._host_completed[hostname] = (True, True, '') + DLOG.info("%s firmware update complete" % hostname) + elif device_image_update == FW_UPDATE_LABEL.DEVICE_IMAGE_UPDATE_FAILED: + if self._host_completed[hostname][0] is False: + failed_msg = hostname + ' firmware update failed' + self._host_completed[hostname] = (True, False, failed_msg) + DLOG.error(failed_msg) else: - DLOG.error("failed to find %s in hosts list" % host_uuid) + if self._host_completed[hostname][0] is False: + failed_msg = hostname + ' firmware update failed ; unknown state ' + device_image_update + self._host_completed[hostname] = (True, False, failed_msg) + DLOG.error(failed_msg) + + # Check for firmware upgrade step complete + self._check_step_complete() + return else: - DLOG.error("failed to get hostname in host device list response") + DLOG.error("failed to get hostname or data from get host response") else: - DLOG.error("failed to get host-device-list ; no strategy") + DLOG.error("failed to monitor firmware update ; no strategy") else: - DLOG.error("get host device list request did not complete") + DLOG.error("get host request did not complete") except Exception as e: - DLOG.exception("Caught exception interpreting host device list") + DLOG.exception("Caught exception interpreting host info") DLOG.error("Response: %s" % response) result = strategy.STRATEGY_STEP_RESULT.FAILED fail_msg = "failed to get or parse fw update info" self.stage.step_complete(result, fail_msg) + def _check_step_complete(self): + """ + Check for firmware upgrade step complete + """ + + failed_hosts = "" + done = True + for hostname in self._host_names: + if self._host_completed[hostname][0] is False: + done = False + elif self._host_completed[hostname][1] is False: + failed_hosts += hostname + ' ' + else: + DLOG.verbose("%s firmware update is complete" % hostname) + + if done: + if len(failed_hosts) == 0: + result = strategy.STRATEGY_STEP_RESULT.SUCCESS + self.stage.step_complete(result, '') + else: + result = strategy.STRATEGY_STEP_RESULT.FAILED + failed_msg = 'Firmware update failed ; %s' % failed_hosts + self.stage.step_complete(result, failed_msg) + def apply(self): """ Firmware Update Hosts Apply @@ -1971,94 +1996,15 @@ class FwUpdateHostsStep(strategy.StrategyStep): DLOG.info("%s update already done") continue - DLOG.info("%s firmware update monitor request %d" % - (host.name, self._host_monitor_counter[host.uuid] + 1)) - nfvi.nfvi_get_host_devices(host.uuid, - host.name, - self._host_devices_list_callback()) + nfvi.nfvi_get_host(host.uuid, + host.name, + self._get_host_callback()) return True else: DLOG.warn("Unexpected event (%s)" % event) return False - def _check_status(self, host_name, host_uuid, pci_devices): - """Check firmware update status for specified host""" - - done = True - for pci_device in pci_devices: - if pci_device.get(FW_UPDATE_LABEL.DEVICE_IMAGE_NEEDS_FIRMWARE_UPDATE) is False: - continue - - status = pci_device.get('status') - pci_device_name = pci_device.get('name') - - # Handle simulated testing ; Remove after integration testing - if self.MONITOR_THRESHOLD > 0 or status is None: - if self._host_monitor_counter[host_uuid] >= self.MONITOR_THRESHOLD: - status = FW_UPDATE_LABEL.DEVICE_IMAGE_UPDATE_COMPLETED - else: - status = FW_UPDATE_LABEL.DEVICE_IMAGE_UPDATE_IN_PROGRESS - - # stop monitoring failed devices - if pci_device_name in self._host_failed_device_update[host_name]: - continue - - elif status == FW_UPDATE_LABEL.DEVICE_IMAGE_UPDATE_IN_PROGRESS: - done = False - DLOG.verbose("%s pci device %s firmware update in-progress" % - (host_name, pci_device_name)) - - elif status == FW_UPDATE_LABEL.DEVICE_IMAGE_UPDATE_COMPLETED: - DLOG.verbose("%s %s firmware update complete" % - (host_name, pci_device_name)) - - elif status == FW_UPDATE_LABEL.DEVICE_IMAGE_UPDATE_FAILED: - if pci_device_name not in self._host_failed_device_update[host_name]: - DLOG.info("%s %s firmware update failed" % - (host_name, pci_device_name)) - self._host_failed_device_update[host_name].append(pci_device_name) - - else: - if pci_device_name not in self._host_failed_device_update[host_name]: - self._host_failed_device_update[host_name].append(pci_device_name) - DLOG.info('unexpected device image status (%s)' % status) - - if done: - if len(self._host_failed_device_update[host_name]): - failed_msg = "firmware update failed for devices: " - failed_msg += str(self._host_failed_device_update[host_name]) - self._host_completed[host_name] = (True, False, failed_msg) - else: - self._host_completed[host_name] = (True, True, '') - - # Check for firmware upgrade step complete - self._check_step_complete() - - def _check_step_complete(self): - """ - Check for firmware upgrade step complete - """ - - failed_hosts = "" - done = True - for hostname in self._host_names: - if self._host_completed[hostname][0] is False: - done = False - elif self._host_completed[hostname][1] is False: - failed_hosts += hostname + ' ' - else: - DLOG.info("%s firmware update is complete" % hostname) - - if done: - if len(failed_hosts) == 0: - result = strategy.STRATEGY_STEP_RESULT.SUCCESS - self.stage.step_complete(result, '') - else: - result = strategy.STRATEGY_STEP_RESULT.FAILED - failed_msg = 'Firmware update failed ; %s' % failed_hosts - self.stage.step_complete(result, failed_msg) - def abort(self): """ Returns the abort step related to this step @@ -2538,8 +2484,8 @@ def strategy_step_rebuild_from_dict(data): elif STRATEGY_STEP_NAME.FW_UPDATE_ABORT_HOSTS == data['name']: step_obj = object.__new__(FwUpdateAbortHostsStep) - elif STRATEGY_STEP_NAME.QUERY_HOST_DEVICES == data['name']: - step_obj = object.__new__(QueryHostDeviceListStep) + elif STRATEGY_STEP_NAME.QUERY_FW_UPDATE_HOST == data['name']: + step_obj = object.__new__(QueryFwUpdateHostStep) else: step_obj = object.__new__(strategy.StrategyStep) diff --git a/nfv/tox.ini b/nfv/tox.ini index cfe3bc90..84652c09 100644 --- a/nfv/tox.ini +++ b/nfv/tox.ini @@ -133,7 +133,7 @@ deps = {[nfv]deps} stestr testtools setenv = PYTHONDONTWRITEBYTECODE=True -commands = cp -v {[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/test_data/nfv_vim_db_18.03_GA {envdir}/ +commands = cp -v {[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/test_data/nfv_vim_db_stx_19.12 {envdir}/ stestr --test-path={[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/tests run '{posargs}' stestr slowest @@ -146,7 +146,7 @@ deps = {[nfv]deps} stestr testtools setenv = PYTHONDONTWRITEBYTECODE=True -commands = cp -v {[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/test_data/nfv_vim_db_18.03_GA {envdir}/ +commands = cp -v {[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/test_data/nfv_vim_db_stx_19.12 {envdir}/ stestr --test-path={[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/tests run '{posargs}' stestr slowest @@ -161,7 +161,7 @@ deps = {[nfv]deps} setenv = PYTHON=coverage run --parallel-mode PYTHONDONTWRITEBYTECODE=True -commands = cp -v {[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/test_data/nfv_vim_db_18.03_GA {envdir}/ +commands = cp -v {[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/test_data/nfv_vim_db_stx_19.12 {envdir}/ coverage erase stestr --test-path={[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/tests run '{posargs}' coverage combine