From a5b086f6adf5ca4475830d44abe17fdbac3b9207 Mon Sep 17 00:00:00 2001 From: Eran Cohen Date: Tue, 18 Aug 2020 17:18:46 +0300 Subject: [PATCH] Revert "Use munchify instead of assisted_service_client moduels (#9)" This reverts commit 7b30afd1bfb1d4ab7caa5ea3b8486046bfef9704. --- requirements.txt | 1 - utils.py | 19 +++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/requirements.txt b/requirements.txt index 2986550..6f627d7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ boto3 botocore pyyaml -munch==2.5.0 diff --git a/utils.py b/utils.py index 5f4a066..5ad1c40 100644 --- a/utils.py +++ b/utils.py @@ -1,34 +1,33 @@ import os import json -from assisted_service_client import ApiClient, Configuration, api -from munch import munchify +from assisted_service_client import ApiClient, Configuration, api, models class InventoryHost: def __init__(self, host_dict): - self._host = munchify(**host_dict) - self._inventory = munchify(**json.loads(self._host.inventory)) + self._host = models.Host(**host_dict) + self._inventory = models.Inventory(**json.loads(self._host.inventory)) def get_inventory_host_nics_data(self): - interfaces_list = [munchify(**interface) for interface in self._inventory.interfaces] + interfaces_list = [models.Interface(**interface) for interface in self._inventory.interfaces] return [{'name': interface.name, 'model': interface.product, 'mac': interface.mac_address, 'ip': self._get_network_interface_ip(interface), 'speed': interface.speed_mbps} for interface in interfaces_list] def get_inventory_host_cpu_data(self): - cpu = munchify(**self._inventory.cpu) + cpu = models.Cpu(**self._inventory.cpu) return {'model': cpu.model_name, 'arch': cpu.architecture, 'flags': cpu.flags, 'clockMegahertz': cpu.frequency, 'count': cpu.count} def get_inventory_host_storage_data(self): - disks_list = [munchify(**disk) for disk in self._inventory.disks] - return [{'name': disk.name, 'vendor': disk.vendor, 'sizeBytes': disk.size_bytes, 'model': disk.model, 'wwn': disk.wwn, 'hctl': disk.hctl, 'serialNumber': disk.serial, 'rotational': True if disk.drive_type == 'HDD' else False} for disk in disks_list] + disks_list = [models.Disk(**disk) for disk in self._inventory.disks] + return [{'name': disk.name, 'vendor': disk.vendor, 'sizeBytes': disk.size_bytes, 'model': disk.model, 'wwn': disk.wwn, 'hctl': disk.hctl, 'serialNumber': disk.serial, 'rotational': True if disk.drive_type == 'HDD' else False} for disk in disks_list] def get_inventory_host_memory(self): - memory = munchify(**self._inventory.memory) + memory = models.Memory(**self._inventory.memory) return int(memory.physical_bytes / 1024 / 1024) @@ -37,7 +36,7 @@ def get_inventory_host_name(self): def get_inventory_host_system_vendor(self): - system_vendor = munchify(**self._inventory.system_vendor) + system_vendor = models.SystemVendor(**self._inventory.system_vendor) return {'manufacturer': system_vendor.manufacturer, 'productName': system_vendor.product_name, 'serialNumber': system_vendor.serial_number} def is_role(self, role):