Added note and refactor code #16

Merged
PeterSurda merged 6 commits from swapnil/idlers-agent:main into main 2024-06-26 01:47:20 +02:00
Showing only changes of commit 064d781607 - Show all commits

View File

@ -161,6 +161,13 @@ class ServerData:
logging.info("Post data created") logging.info("Post data created")
return post_data return post_data
def create_note_data(self, server_id):
note_data = {
'service_id': server_id,
'note': 'Bla bla bla'
}
return note_data
class ServerManager: class ServerManager:
Review

We should also report "baseboard", and "system", if present. Traditional servers seem to report "system" and/or "chassis" whereas custom build machines report only "baseboard" (i.e. motherboard), as there is no way for the motherboard to find out what kind of chassis it is mounted into.

We should also report "baseboard", and "system", if present. Traditional servers seem to report "system" and/or "chassis" whereas custom build machines report only "baseboard" (i.e. motherboard), as there is no way for the motherboard to find out what kind of chassis it is mounted into.
Review

Please share a sample sudo dmidecode -t1 output.
Here's what I see on test2:

root@test2:~# sudo dmidecode -t1
# dmidecode 3.3
Getting SMBIOS data from sysfs.
SMBIOS 2.7 present.

Handle 0x0001, DMI type 1, 27 bytes
System Information
	Manufacturer: System manufacturer
	Product Name: System Product Name
	Version: System Version
	Serial Number: System Serial Number
	UUID: 2aa1f520-d7da-11dd-b8b7-08606ee5b794
	Wake-up Type: Power Switch
	SKU Number: SKU
	Family: To be filled by O.E.M.
Please share a sample `sudo dmidecode -t1` output. Here's what I see on test2: ```bash root@test2:~# sudo dmidecode -t1 # dmidecode 3.3 Getting SMBIOS data from sysfs. SMBIOS 2.7 present. Handle 0x0001, DMI type 1, 27 bytes System Information Manufacturer: System manufacturer Product Name: System Product Name Version: System Version Serial Number: System Serial Number UUID: 2aa1f520-d7da-11dd-b8b7-08606ee5b794 Wake-up Type: Power Switch SKU Number: SKU Family: To be filled by O.E.M. ```
Review

one:

Handle 0x0001, DMI type 1, 27 bytes
System Information
	Manufacturer: To Be Filled By O.E.M.
	Product Name: X570D4U
	Version: To Be Filled By O.E.M.
	Serial Number: To Be Filled By O.E.M.
	UUID: 7533e379-96c4-49d9-f452-a8a159c72190
	Wake-up Type: Power Switch
	SKU Number: To Be Filled By O.E.M.
	Family: To Be Filled By O.E.M.

two:

Handle 0x0100, DMI type 1, 27 bytes
System Information
	Manufacturer: Dell Inc.
	Product Name: PowerEdge R630
	Version: Not Specified
	Serial Number: 1W9PPM2
	UUID: 4c4c4544-0057-3910-8050-b1c04f504d32
	Wake-up Type: Power Switch
	SKU Number: SKU=NotProvided;ModelName=PowerEdge R630
	Family: Not Specified
one: ``` Handle 0x0001, DMI type 1, 27 bytes System Information Manufacturer: To Be Filled By O.E.M. Product Name: X570D4U Version: To Be Filled By O.E.M. Serial Number: To Be Filled By O.E.M. UUID: 7533e379-96c4-49d9-f452-a8a159c72190 Wake-up Type: Power Switch SKU Number: To Be Filled By O.E.M. Family: To Be Filled By O.E.M. ``` two: ``` Handle 0x0100, DMI type 1, 27 bytes System Information Manufacturer: Dell Inc. Product Name: PowerEdge R630 Version: Not Specified Serial Number: 1W9PPM2 UUID: 4c4c4544-0057-3910-8050-b1c04f504d32 Wake-up Type: Power Switch SKU Number: SKU=NotProvided;ModelName=PowerEdge R630 Family: Not Specified ```
def __init__(self, host, api_key): def __init__(self, host, api_key):
@ -249,10 +256,7 @@ def main():
logging.info('Server does not exist, Creating...') logging.info('Server does not exist, Creating...')
logging.info(server_manager.create_server(post_data)) logging.info(server_manager.create_server(post_data))
note_data = { note_data = server_data.create_note_data(server_id)
'service_id': server_id,
'note': 'Bla bla bla'
}
try: try:
note = server_manager.get_note(server_id) note = server_manager.get_note(server_id)
except urllib.error.HTTPError: except urllib.error.HTTPError: