def _audit_nfvi_volume_snapshots_callback(timer_id): """ Audit Volume Snapshots """ global _main_audit_inprogress response = (yield) DLOG.verbose("Audit-Volume-Snapshots callback, response=%s." % response) if response['completed']: volume_snapshot_table = tables.tables_get_volume_snapshot_table() _deletable_volume_snapshots = volume_snapshot_table.keys() for nfvi_volume_snapshot in response['result-data']: volume_snapshot = volume_snapshot_table.get(nfvi_volume_snapshot.uuid, None) if volume_snapshot is None: volume_snapshot = objects.VolumeSnapshot(nfvi_volume_snapshot) volume_snapshot_table[nfvi_volume_snapshot.uuid] = volume_snapshot else: volume_snapshot.nfvi_volume_snapshot_update(nfvi_volume_snapshot) if nfvi_volume_snapshot.uuid in _deletable_volume_snapshots: _deletable_volume_snapshots.remove(nfvi_volume_snapshot.uuid) for volume_snapshot_uuid in _deletable_volume_snapshots: if volume_snapshot_uuid in volume_snapshot_table.keys(): del volume_snapshot_table[volume_snapshot_uuid] else: DLOG.error("Audit-Volume-Snapshots callback, not completed, " "responses=%s." % response) _main_audit_inprogress = False timers.timers_reschedule_timer(timer_id, 2) # 2 seconds later
def _audit_nfvi_tenants_callback(timer_id): """ Audit Tenants """ global _main_audit_inprogress response = (yield) DLOG.verbose("Audit-Tenants callback, responses=%s." % response) if response['completed']: tenant_table = tables.tables_get_tenant_table() deletable_tenants = list(tenant_table) for nfvi_tenant in response['result-data']: tenant = tenant_table.get(nfvi_tenant.uuid, None) if tenant is None: tenant = objects.Tenant(nfvi_tenant.uuid, nfvi_tenant.name, nfvi_tenant.description, nfvi_tenant.enabled) tenant_table[nfvi_tenant.uuid] = tenant else: tenant.name = nfvi_tenant.name tenant.description = nfvi_tenant.description tenant.enabled = nfvi_tenant.enabled deletable_tenants.remove(tenant.uuid) for tenant_uuid in deletable_tenants: del tenant_table[tenant_uuid] else: DLOG.error("Audit-Tenants callback, not completed, responses=%s." % response) _main_audit_inprogress = False timers.timers_reschedule_timer(timer_id, 2) # 2 seconds later
def _audit_nfvi_host_aggregates_callback(timer_id): """ Audit Host Aggregates """ global _main_audit_inprogress response = (yield) DLOG.verbose("Audit-Host Aggregates callback, responses=%s." % response) if response['completed']: host_aggregate_table = tables.tables_get_host_aggregate_table() deletable_host_aggregates = list(host_aggregate_table) for nfvi_host_aggregate in response['result-data']: host_aggregate = host_aggregate_table.get(nfvi_host_aggregate.name, None) if host_aggregate is None: host_aggregate = objects.HostAggregate(nfvi_host_aggregate) host_aggregate_table[host_aggregate.name] = host_aggregate else: host_aggregate.nfvi_host_aggregate_update(nfvi_host_aggregate) if nfvi_host_aggregate.name in deletable_host_aggregates: deletable_host_aggregates.remove(nfvi_host_aggregate.name) for host_aggregate_name in deletable_host_aggregates: if host_aggregate_name in list(host_aggregate_table): del host_aggregate_table[host_aggregate_name] else: DLOG.error( "Audit-Host Aggregates callback, not completed, responses=%s." % response) _main_audit_inprogress = False timers.timers_reschedule_timer(timer_id, 2) # 2 seconds later
def _audit_nfvi_system_info_callback(timer_id): """ Audit System Information """ global _main_audit_inprogress response = (yield) DLOG.verbose("Audit-System callback, responses=%s." % response) if response['completed']: nfvi_system = response['result-data'] system_table = tables.tables_get_system_table() deletable_systems = list(system_table) if nfvi_system is not None: system = system_table.get(nfvi_system.name, None) if system is None: system_table[nfvi_system.name] \ = objects.System(nfvi_system.name, nfvi_system.description) else: deletable_systems.remove(system.name) for system_name in deletable_systems: del system_table[system_name] else: DLOG.error("Audit-System callback, not completed, responses=%s." % response) _main_audit_inprogress = False timers.timers_reschedule_timer(timer_id, 2) # 2 seconds later
def _audit_nfvi_subnets_callback(timer_id): """ Audit Subnets """ global _main_audit_inprogress global _deletable_subnets, _nfvi_subnets_paging response = (yield) DLOG.verbose("Audit-Subnets callback, response=%s." % response) if response['completed']: if response['page-request-id'] == _nfvi_subnets_paging.page_request_id: subnet_table = tables.tables_get_subnet_table() if _deletable_subnets is None: _deletable_subnets = subnet_table.keys() for nfvi_subnet in response['result-data']: subnet = subnet_table.get(nfvi_subnet.uuid, None) if subnet is None: subnet = objects.Subnet(nfvi_subnet.uuid, nfvi_subnet.name, nfvi_subnet.ip_version, nfvi_subnet.subnet_ip, nfvi_subnet.subnet_prefix, nfvi_subnet.gateway_ip, nfvi_subnet.network_uuid, nfvi_subnet.is_dhcp_enabled) subnet_table[nfvi_subnet.uuid] = subnet else: subnet.is_dhcp_enabled = nfvi_subnet.is_dhcp_enabled if nfvi_subnet.uuid in _deletable_subnets: _deletable_subnets.remove(nfvi_subnet.uuid) if _nfvi_subnets_paging.done: for subnet_uuid in _deletable_subnets: if subnet_uuid in subnet_table.keys(): del subnet_table[subnet_uuid] _deletable_subnets = subnet_table.keys() _nfvi_subnets_paging.first_page() else: DLOG.error("Audit-Subnets callback, page-request-id mismatch, " "responses=%s, page-request-id=%s." % (response, _nfvi_subnets_paging.page_request_id)) subnet_table = tables.tables_get_subnet_table() _deletable_subnets = subnet_table.keys() _nfvi_subnets_paging.first_page() else: DLOG.error("Audit-Subnets callback, not completed, responses=%s." % response) subnet_table = tables.tables_get_subnet_table() _deletable_subnets = subnet_table.keys() _nfvi_subnets_paging.first_page() _nfvi_subnets_paging.set_page_request_id() _main_audit_inprogress = False timers.timers_reschedule_timer(timer_id, 2) # 2 seconds later
def _audit_nfvi_images_callback(timer_id): """ Audit Images """ global _main_audit_inprogress global _deletable_images, _nfvi_images_paging response = (yield) DLOG.verbose("Audit-Images callback, response=%s." % response) if response['completed']: if response['page-request-id'] == _nfvi_images_paging.page_request_id: image_table = tables.tables_get_image_table() if _deletable_images is None: _deletable_images = list(image_table) for nfvi_image in response['result-data']: image = image_table.get(nfvi_image.uuid, None) if image is None: image = objects.Image(nfvi_image) image_table[nfvi_image.uuid] = image else: if not image.is_deleted(): if nfvi_image.uuid in _deletable_images: _deletable_images.remove(nfvi_image.uuid) image.nfvi_image_update(nfvi_image) if _nfvi_images_paging.done: for image_uuid in _deletable_images: image = image_table.get(image_uuid, None) image.nfvi_image_deleted() if image.is_deleted(): del image_table[image_uuid] _deletable_images = list(image_table) _nfvi_images_paging.first_page() else: DLOG.error("Audit-Images callback, page-request-id mismatch, " "responses=%s, page-request-id=%s." % (response, _nfvi_images_paging.page_request_id)) image_table = tables.tables_get_image_table() _deletable_images = list(image_table) _nfvi_images_paging.first_page() else: DLOG.error("Audit-Images callback, not completed, responses=%s." % response) image_table = tables.tables_get_image_table() _deletable_images = list(image_table) _nfvi_images_paging.first_page() _nfvi_images_paging.set_page_request_id() _main_audit_inprogress = False timers.timers_reschedule_timer(timer_id, 2) # 2 seconds later
def _audit_nfvi_hypervisors_callback(timer_id): """ Audit Hypervisors """ global _main_audit_inprogress global _nfvi_hypervisors_to_audit response = (yield) DLOG.verbose("Audit-Hypervisors callback, response=%s." % response) trigger_recovery = False if response['completed']: hypervisor_table = tables.tables_get_hypervisor_table() deletable_hypervisors = list(hypervisor_table) for nfvi_hypervisor in response['result-data']: hypervisor = hypervisor_table.get(nfvi_hypervisor.uuid, None) if hypervisor is None: hypervisor = objects.Hypervisor(nfvi_hypervisor) hypervisor_table[nfvi_hypervisor.uuid] = hypervisor trigger_recovery = True else: deletable_hypervisors.remove(nfvi_hypervisor.uuid) if nfvi_hypervisor.uuid not in _nfvi_hypervisors_to_audit: _nfvi_hypervisors_to_audit[nfvi_hypervisor.uuid] \ = nfvi_hypervisor.uuid prev_state = hypervisor.oper_state hypervisor.nfvi_hypervisor_update(nfvi_hypervisor) if (hypervisor.oper_state != prev_state and nfvi.objects.v1.HYPERVISOR_OPER_STATE.ENABLED == hypervisor.oper_state): trigger_recovery = True for hypervisor_id in deletable_hypervisors: del hypervisor_table[hypervisor_id] if hypervisor_id in _nfvi_hypervisors_to_audit: del _nfvi_hypervisors_to_audit[hypervisor_id] else: DLOG.error("Audit-Hypervisors callback, not completed, responses=%s." % response) _main_audit_inprogress = False timers.timers_reschedule_timer(timer_id, 2) # 2 seconds later if trigger_recovery: # Hypervisor is now available, there is potential to recover instances. DLOG.info("Recover-Instances-Audit triggered by hypervisor audit.") instance_director = directors.get_instance_director() instance_director.recover_instances()
def strategy_abort_complete(self, success, reason): """ Abort of a software update strategy complete """ if success: event_log.sw_update_issue_log( self.event_id(SW_UPDATE_EVENT_IDS.APPLY_ABORTED)) else: event_log.sw_update_issue_log(self.event_id( SW_UPDATE_EVENT_IDS.APPLY_ABORT_FAILED), reason=reason) if self._nfvi_timer_id is not None: timers.timers_reschedule_timer(self._nfvi_timer_id, 2)
def nfvi_alarms_callback(self, timer_id): """ Audit Alarms Callback """ response = (yield) if response['completed']: DLOG.verbose("Audit-Alarms callback, response=%s." % response) self._nfvi_alarms = response['result-data'] else: DLOG.error("Audit-Alarms callback, not completed, " "response=%s." % response) self._nfvi_audit_inprogress = False timers.timers_reschedule_timer(timer_id, 2) # 2 seconds later
def nfvi_sw_patch_hosts_callback(self, timer_id): """ Audit Software Patch Hosts Callback """ response = (yield) if response['completed']: DLOG.verbose("Audit-Software-Update-Hosts callback, response=%s." % response) self._nfvi_sw_patch_hosts = response['result-data'] else: DLOG.error("Audit-Software-Update-Hosts callback, not completed, " "response=%s." % response) self._nfvi_audit_inprogress = False timers.timers_reschedule_timer(timer_id, 30) # 30 seconds later
def _audit_nfvi_instance_groups_callback(timer_id): """ Audit Instance Groups """ global _main_audit_inprogress response = (yield) DLOG.verbose("Audit-Instance-Groups callback, response=%s." % response) if response['completed']: instance_group_table = tables.tables_get_instance_group_table() _deletable_instance_groups = list(instance_group_table) for nfvi_instance_group in response['result-data']: instance_group = instance_group_table.get(nfvi_instance_group.uuid, None) if instance_group is None: instance_group = objects.InstanceGroup(nfvi_instance_group) instance_group_table[nfvi_instance_group.uuid] = instance_group else: instance_group.nfvi_instance_group_update(nfvi_instance_group) if nfvi_instance_group.uuid in _deletable_instance_groups: _deletable_instance_groups.remove(nfvi_instance_group.uuid) for instance_group_uuid in _deletable_instance_groups: if instance_group_uuid in list(instance_group_table): instance_group = instance_group_table[instance_group_uuid] instance_group.clear_alarms() del instance_group_table[instance_group_uuid] else: DLOG.error("Audit-Instance-Groups callback, not completed, " "responses=%s." % response) _main_audit_inprogress = False timers.timers_reschedule_timer(timer_id, 2) # 2 seconds later
def _audit_nfvi_hosts_callback(timer_id): """ Audit Hosts """ global _main_audit_inprogress response = (yield) DLOG.verbose("Audit-Hosts callback, responses=%s." % response) if response['completed']: host_table = tables.tables_get_host_table() deletable_host_groups = host_table.keys() for host_name in response['incomplete-hosts']: if host_name in deletable_host_groups: deletable_host_groups.remove(host_name) DLOG.info("Not deleting host %s, incomplete information " "returned." % host_name) for nfvi_host in response['result-data']: host = host_table.get(nfvi_host.name, None) if host is None: host = objects.Host(nfvi_host) host_table[host.name] = host else: if not host.is_deleted(): deletable_host_groups.remove(host.name) host.nfvi_host_update(nfvi_host) for host_name in deletable_host_groups: host = host_table[host_name] host.nfvi_host_delete() if host.is_deleted(): del host_table[host.name] # Manage host groups host_group_table = tables.tables_get_host_group_table() deletable_host_groups = host_group_table.keys() for host_name in response['incomplete-hosts']: host_group = next((x for x in host_group_table if host_name in x.member_names), None) if host_group is not None: if host_group.name in deletable_host_groups: deletable_host_groups.remove(host_group.name) DLOG.info("Not deleting host group %s, incomplete information " "returned for host %s." % (host_group.name, host_name)) for nfvi_host_group in response['host-groups']: host_group = host_group_table.get(nfvi_host_group.name, None) if host_group is None: host_group = objects.HostGroup(nfvi_host_group) host_group_table[host_group.name] = host_group else: deletable_host_groups.remove(host_group.name) host_group.nfvi_host_group_update(nfvi_host_group) for host_group_name in deletable_host_groups: del host_group_table[host_group_name] else: DLOG.error("Audit-Hosts callback, not completed, responses=%s." % response) _main_audit_inprogress = False timers.timers_reschedule_timer(timer_id, 2) # 2 seconds later
def _audit_nfvi_networks_callback(timer_id): """ Audit Networks """ global _main_audit_inprogress global _deletable_networks, _nfvi_networks_paging response = (yield) DLOG.verbose("Audit-Networks callback, response=%s." % response) if response['completed']: if response[ 'page-request-id'] == _nfvi_networks_paging.page_request_id: network_table = tables.tables_get_network_table() if _deletable_networks is None: _deletable_networks = list(network_table) for nfvi_network in response['result-data']: network = network_table.get(nfvi_network.uuid, None) if network is None: network = objects.Network( nfvi_network.uuid, nfvi_network.name, nfvi_network.admin_state, nfvi_network.oper_state, nfvi_network.avail_status, nfvi_network.is_shared, nfvi_network.mtu, nfvi_network.provider_data) network_table[nfvi_network.uuid] = network else: network.admin_state = nfvi_network.admin_state network.oper_state = nfvi_network.oper_state network.avail_status = nfvi_network.avail_status network.is_shared = nfvi_network.is_shared network.provider_data = nfvi_network.provider_data if nfvi_network.uuid in _deletable_networks: _deletable_networks.remove(nfvi_network.uuid) if _nfvi_networks_paging.done: for network_uuid in _deletable_networks: if network_uuid in list(network_table): del network_table[network_uuid] _deletable_networks = list(network_table) _nfvi_networks_paging.first_page() else: DLOG.error("Audit-Networks callback, page-request-id mismatch, " "responses=%s, page-request-id=%s." % (response, _nfvi_networks_paging.page_request_id)) network_table = tables.tables_get_network_table() _deletable_networks = list(network_table) _nfvi_networks_paging.first_page() else: DLOG.error("Audit-Networks callback, not completed, responses=%s." % response) network_table = tables.tables_get_network_table() _deletable_networks = list(network_table) _nfvi_networks_paging.first_page() _nfvi_networks_paging.set_page_request_id() _main_audit_inprogress = False timers.timers_reschedule_timer(timer_id, 20) # 20 seconds later
def _audit_nfvi_volumes_callback(timer_id): """ Audit Volumes """ global _main_audit_inprogress global _added_volumes, _deletable_volumes, _nfvi_volumes_paging global _nfvi_volumes_to_audit, _nfvi_volumes_outstanding response = (yield) DLOG.verbose("Audit-Volumes callback, response=%s." % response) if response['completed']: if response['page-request-id'] == _nfvi_volumes_paging.page_request_id: volume_table = tables.tables_get_volume_table() if _added_volumes is None: _added_volumes = list() if _deletable_volumes is None: _deletable_volumes = list(volume_table) for volume_uuid, volume_name in response['result-data']: volume = volume_table.get(volume_uuid, None) if volume is not None: if volume.uuid in _deletable_volumes: _deletable_volumes.remove(volume.uuid) if volume_uuid not in _nfvi_volumes_to_audit: _nfvi_volumes_to_audit[volume_uuid] = volume_name _added_volumes.append(volume_uuid) if _nfvi_volumes_paging.done: for volume_uuid in _deletable_volumes: volume = volume_table[volume_uuid] volume.nfvi_volume_deleted() if volume.is_deleted(): del volume_table[volume_uuid] if volume_uuid in _nfvi_volumes_to_audit: del _nfvi_volumes_to_audit[volume_uuid] if volume_uuid in _nfvi_volumes_outstanding: del _nfvi_volumes_outstanding[volume_uuid] for volume_uuid in _nfvi_volumes_to_audit: if volume_uuid not in _added_volumes: volume = volume_table.get(volume_uuid, None) if volume is None: del _nfvi_volumes_to_audit[volume_uuid] if volume_uuid in _nfvi_volumes_outstanding: del _nfvi_volumes_outstanding[volume_uuid] _added_volumes[:] = [] _deletable_volumes = list(volume_table) _nfvi_volumes_paging.first_page() else: DLOG.error("Audit-Volumes callback, page-request-id mismatch, " "responses=%s, page-request-id=%s." % (response, _nfvi_volumes_paging.page_request_id)) volume_table = tables.tables_get_volume_table() if _added_volumes is None: _added_volumes = list() else: _added_volumes[:] = [] _deletable_volumes = list(volume_table) _nfvi_volumes_paging.first_page() else: DLOG.error("Audit-Volumes callback, not completed, responses=%s." % response) volume_table = tables.tables_get_volume_table() if _added_volumes is None: _added_volumes = list() else: _added_volumes[:] = [] _deletable_volumes = list(volume_table) _nfvi_volumes_paging.first_page() _nfvi_volumes_paging.set_page_request_id() _main_audit_inprogress = False timers.timers_reschedule_timer(timer_id, 2) # 2 seconds later
def _audit_nfvi_instances_callback(timer_id): """ Audit Instances """ global _main_audit_inprogress global _deletable_instances, _nfvi_instances_paging global _nfvi_instances_to_audit, _nfvi_instance_outstanding response = (yield) DLOG.verbose("Audit-Instances callback, response=%s." % response) trigger_recovery = False if response['completed']: if response[ 'page-request-id'] == _nfvi_instances_paging.page_request_id: instance_table = tables.tables_get_instance_table() if _deletable_instances is None: _deletable_instances = list(instance_table) for instance_uuid, instance_name in response['result-data']: instance = instance_table.get(instance_uuid, None) if instance is not None: if instance.uuid in _deletable_instances: _deletable_instances.remove(instance.uuid) if instance_uuid not in _nfvi_instances_to_audit: _nfvi_instances_to_audit[instance_uuid] = instance_name if _nfvi_instances_paging.done: for instance_uuid in _deletable_instances: instance = instance_table.get(instance_uuid, None) if instance is not None: DLOG.info("Deleting instance %s, audit mismatch" % instance_uuid) instance.nfvi_instance_deleted() if instance.is_deleted(): trigger_recovery = True del instance_table[instance_uuid] if instance_uuid in _nfvi_instances_to_audit: del _nfvi_instances_to_audit[instance_uuid] if instance_uuid in _nfvi_instance_outstanding: del _nfvi_instance_outstanding[instance_uuid] _deletable_instances = list(instance_table) _nfvi_instances_paging.first_page() else: DLOG.verbose("Paging is not done for instances.") else: DLOG.error("Audit-Instances callback, page-request-id mismatch, " "responses=%s, page-request-id=%s." % (response, _nfvi_instances_paging.page_request_id)) instance_table = tables.tables_get_instance_table() _deletable_instances = list(instance_table) _nfvi_instances_paging.first_page() else: DLOG.error("Audit-Instances callback, not completed, responses=%s." % response) instance_table = tables.tables_get_instance_table() _deletable_instances = list(instance_table) _nfvi_instances_paging.first_page() _nfvi_instances_paging.set_page_request_id() _main_audit_inprogress = False timers.timers_reschedule_timer(timer_id, 2) # 2 seconds later if trigger_recovery: # Resources have been freed, there is potential to recover instances. DLOG.info("Recover-Instances-Audit triggered by instance deletion.") instance_director = directors.get_instance_director() instance_director.recover_instances()
def _audit_nfvi_instance_types_callback(timer_id): """ Audit Instance Types """ global _main_audit_inprogress global _deletable_instance_types, _nfvi_instance_types_paging global _nfvi_instance_types_to_audit, _nfvi_instance_types_outstanding response = (yield) DLOG.verbose("Audit-Instance-Types callback, response=%s." % response) if response['completed']: if response['page-request-id'] == \ _nfvi_instance_types_paging.page_request_id: instance_type_table = tables.tables_get_instance_type_table() if _deletable_instance_types is None: _deletable_instance_types = list(instance_type_table) for nfvi_instance_type in response['result-data']: instance_type = instance_type_table.get( nfvi_instance_type.uuid, None) if instance_type is None: instance_type = objects.InstanceType( nfvi_instance_type.uuid, nfvi_instance_type.name) instance_type_table[ nfvi_instance_type.uuid] = instance_type else: if nfvi_instance_type.uuid in _deletable_instance_types: _deletable_instance_types.remove( nfvi_instance_type.uuid) if nfvi_instance_type.uuid not in _nfvi_instance_types_to_audit: _nfvi_instance_types_to_audit[nfvi_instance_type.uuid] \ = nfvi_instance_type.name if nfvi_instance_type.have_details(): instance_type.update_details( nfvi_instance_type.vcpus, nfvi_instance_type.mem_mb, nfvi_instance_type.disk_gb, nfvi_instance_type.ephemeral_gb, nfvi_instance_type.swap_gb, nfvi_instance_type.guest_services, nfvi_instance_type.auto_recovery, nfvi_instance_type.live_migration_timeout, nfvi_instance_type.live_migration_max_downtime) if _nfvi_instance_types_paging.done: for instance_type_uuid in _deletable_instance_types: del instance_type_table[instance_type_uuid] if instance_type_uuid in _nfvi_instance_types_to_audit: del _nfvi_instance_types_to_audit[instance_type_uuid] if instance_type_uuid in _nfvi_instance_types_outstanding: del _nfvi_instance_types_outstanding[ instance_type_uuid] _deletable_instance_types = list(instance_type_table) _nfvi_instance_types_paging.first_page() else: DLOG.error( "Audit-Instance-Types callback, page-request-id mismatch, " "responses=%s, page-request-id=%s." % (response, _nfvi_instance_types_paging.page_request_id)) instance_type_table = tables.tables_get_instance_type_table() _deletable_instance_types = list(instance_type_table) _nfvi_instance_types_paging.first_page() else: DLOG.error("Audit-Instance-Types callback, not completed, " "responses=%s." % response) instance_type_table = tables.tables_get_instance_type_table() _deletable_instance_types = list(instance_type_table) _nfvi_instance_types_paging.first_page() _nfvi_instance_types_paging.set_page_request_id() _main_audit_inprogress = False timers.timers_reschedule_timer(timer_id, 2) # 2 seconds later
def _audit_nfvi_hosts_callback(timer_id): """ Audit Hosts """ global _main_audit_inprogress response = (yield) DLOG.verbose("Audit-Hosts callback, responses=%s." % response) if response['completed']: host_table = tables.tables_get_host_table() deletable_host_groups = list(host_table) for host_name in response['incomplete-hosts']: if host_name in deletable_host_groups: deletable_host_groups.remove(host_name) DLOG.info("Not deleting host %s, incomplete information " "returned." % host_name) for nfvi_host in response['result-data']: host = host_table.get(nfvi_host.name, None) if host is None: host = objects.Host(nfvi_host) host_table[host.name] = host else: if not host.is_deleted(): deletable_host_groups.remove(host.name) if 30 <= host.elapsed_time_in_state: # Only process the audited host information if the host has # been in the current state for at least 30 seconds. This is # necessary because the host state information comes from # maintenance and the maintenance states may lag the states in # the VIM because the VIM and maintenance process some actions # at the same time (e.g. when a host is locked). host.nfvi_host_update(nfvi_host) else: DLOG.info("Ignoring audit reply for host %s" % nfvi_host.name) for host_name in deletable_host_groups: host = host_table[host_name] host.nfvi_host_delete() if host.is_deleted(): del host_table[host.name] # Manage host groups host_group_table = tables.tables_get_host_group_table() deletable_host_groups = list(host_group_table) for host_name in response['incomplete-hosts']: host_group = next( (x for x in host_group_table if host_name in x.member_names), None) if host_group is not None: if host_group.name in deletable_host_groups: deletable_host_groups.remove(host_group.name) DLOG.info( "Not deleting host group %s, incomplete information " "returned for host %s." % (host_group.name, host_name)) for nfvi_host_group in response['host-groups']: host_group = host_group_table.get(nfvi_host_group.name, None) if host_group is None: host_group = objects.HostGroup(nfvi_host_group) host_group_table[host_group.name] = host_group else: deletable_host_groups.remove(host_group.name) host_group.nfvi_host_group_update(nfvi_host_group) for host_group_name in deletable_host_groups: del host_group_table[host_group_name] else: DLOG.error("Audit-Hosts callback, not completed, responses=%s." % response) _main_audit_inprogress = False timers.timers_reschedule_timer(timer_id, 2) # 2 seconds later