|
5 | 5 | from ros.lib import consume |
6 | 6 | from ros.lib.app import app |
7 | 7 | from ros.extensions import db, cache |
8 | | -from ros.lib.utils import get_or_create, system_allowed_in_ros, update_system_record, is_platform_metadata_check_pass |
| 8 | +from ros.lib.utils import get_or_create, system_allowed_in_ros, update_system_record |
9 | 9 | from confluent_kafka import KafkaException |
10 | 10 | from ros.lib.models import RhAccount, System |
11 | 11 | from ros.lib.config import ( |
@@ -149,16 +149,22 @@ def process_system_details(self, msg): |
149 | 149 | host = msg['host'] |
150 | 150 | with app.app_context(): |
151 | 151 | # 'platform_metadata' field not included when the host is updated via the API. |
152 | | - if (msg.get('type') == 'updated' and is_platform_metadata_check_pass(msg)): |
| 152 | + if (msg.get('type') == 'updated'): |
153 | 153 | system_fields = { |
154 | 154 | "inventory_id": host['id'], |
155 | 155 | "display_name": host['display_name'], |
156 | 156 | "fqdn": host['fqdn'], |
157 | | - "cloud_provider": host['system_profile']['cloud_provider'], |
158 | 157 | "stale_timestamp": host['stale_timestamp'], |
159 | | - "operating_system": host['system_profile'].get('operating_system'), |
160 | 158 | "groups": host.get('groups', []) |
161 | 159 | } |
| 160 | + |
| 161 | + operating_system = host['system_profile'].get('operating_system') |
| 162 | + cloud_provider = host['system_profile'].get('cloud_provider') |
| 163 | + if (operating_system is not None): |
| 164 | + system_fields.update({"operating_system": operating_system}) |
| 165 | + if (cloud_provider is not None): |
| 166 | + system_fields.update({"cloud_provider": cloud_provider}) |
| 167 | + |
162 | 168 | system = update_system_record(db.session, **system_fields) |
163 | 169 | if system is not None: |
164 | 170 | db.session.commit() |
|
0 commit comments