use the common enum DataStorageInterface

This commit is contained in:
Cayo Puigdefabregas 2022-04-08 11:40:39 +02:00
parent 04e11586bf
commit 2471fa90cf
2 changed files with 4 additions and 15 deletions

View File

@ -1,16 +1,15 @@
import json
import logging
import uuid
from enum import Enum, unique
from dmidecode import DMIParse
from marshmallow import ValidationError
from ereuse_devicehub.parser import base2
from ereuse_devicehub.parser.computer import Computer
from ereuse_devicehub.parser.models import SnapshotErrors
from ereuse_devicehub.resources.action.schemas import Snapshot
from ereuse_devicehub.resources.enums import Severity
from ereuse_devicehub.resources.enums import DataStorageInterface, Severity
logger = logging.getLogger(__name__)
@ -312,16 +311,6 @@ class ParseSnapshot:
class ParseSnapshotLsHw:
@unique
class DataStorageInterface(Enum):
ATA = 'ATA'
USB = 'USB'
PCI = 'PCI'
NVME = 'NVME'
def __str__(self):
return self.value
def __init__(self, snapshot, default="n/a"):
self.default = default
self.uuid = snapshot.get("uuid")
@ -502,7 +491,7 @@ class ParseSnapshotLsHw:
def get_data_storage_interface(self, x):
interface = x.get('device', {}).get('protocol', 'ATA')
try:
self.DataStorageInterface(interface.upper())
DataStorageInterface(interface.upper())
except ValueError as err:
txt = "interface {} is not in DataStorageInterface Enum".format(interface)
self.errors("{}".format(err))

View File

@ -199,7 +199,7 @@ class DataStorageInterface(Enum):
ATA = 'ATA'
USB = 'USB'
PCI = 'PCI'
NVMe = 'NVMe'
NVME = 'NVME'
def __str__(self):
return self.value