Added chachis and processor info in note

This commit is contained in:
Swapnil 2024-06-25 14:52:36 +05:30
parent 064d781607
commit fa67103b20
Signed by untrusted user: swapnil
GPG Key ID: 58029C48BB100574

View File

@ -162,9 +162,27 @@ class ServerData:
return post_data return post_data
def create_note_data(self, server_id): def create_note_data(self, server_id):
chassis_info = None
for section in self.dmidecode_data:
if section['DMIType'] == 1:
chassis_info = section
break
if chassis_info:
chassis_model = chassis_info.get('Product Name', 'Unknown')
chassis_serial = chassis_info.get('Serial Number', 'Unknown')
else:
chassis_model = chassis_serial = 'Unknown'
processor_info = [section for section in self.dmidecode_data if section['DMIType'] == 4]
processor_model = processor_info[0].get('Version', 'Unknown') if processor_info else 'Unknown'
processor_count = len(processor_info)
note = "Chassis Model: {}, Serial Number: {}\nProcessor Model: {}, Count: {}\nRAM Details:\n{}".format(
chassis_model, chassis_serial, processor_model, processor_count, '\n'.join(['R1', 'R2', 'R3']))
note_data = { note_data = {
'service_id': server_id, 'service_id': server_id,
'note': 'Bla bla bla' 'note': note,
} }
return note_data return note_data