Skip to content

Commit 5869fac

Browse files
committed
RHINENG-12954 Don't override OS and cloud provider value
1 parent fcfb767 commit 5869fac

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

ros/lib/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ def system_allowed_in_ros(msg, reporter):
362362
msg.get('type') == 'updated'
363363
and is_platform_metadata_check_pass(msg)
364364
):
365-
return is_valid_cloud_provider(cloud_provider)
365+
return is_valid_cloud_provider(cloud_provider) and is_valid_operating_system(operating_system)
366366
is_ros = msg["platform_metadata"].get("is_ros")
367367
return validate_ros_payload(is_ros, cloud_provider, operating_system)
368368

ros/processor/inventory_events_consumer.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from ros.lib import consume
66
from ros.lib.app import app
77
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
99
from confluent_kafka import KafkaException
1010
from ros.lib.models import RhAccount, System
1111
from ros.lib.config import (
@@ -149,16 +149,22 @@ def process_system_details(self, msg):
149149
host = msg['host']
150150
with app.app_context():
151151
# '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'):
153153
system_fields = {
154154
"inventory_id": host['id'],
155155
"display_name": host['display_name'],
156156
"fqdn": host['fqdn'],
157-
"cloud_provider": host['system_profile']['cloud_provider'],
158157
"stale_timestamp": host['stale_timestamp'],
159-
"operating_system": host['system_profile'].get('operating_system'),
160158
"groups": host.get('groups', [])
161159
}
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+
162168
system = update_system_record(db.session, **system_fields)
163169
if system is not None:
164170
db.session.commit()

0 commit comments

Comments
 (0)