config/sysinv/cgts-client/cgts-client/cgtsclient/v1/pci_device.py
Al Bailey d7330d0f44 Convert cgtsclient from setuptools to pbr. Add tox.
Primary reason for this change was to update the spec and setup files
from basic setuptools to use pbr
This allows the autogenerated  /usr/bin/system file to directly call the
main method without using pkg-resources.
This will provide a performance improvement of .5 seconds per CLI call,
once the other pkg_resources issues are resolved

Second reason for this change was to wire in the tox unit tests.  This
also includes pep8, pylint and coverage.
Currently pep8 does not perform the 80 char limit check
Currently pylint still reports some issues

This should not affect the RPM names being generated or otherwise affect
patching or upgrades.

Change-Id: I9f14c9216fdcc63930a4b2849102b58442706144
2018-06-28 22:07:37 -04:00

46 lines
995 B
Python
Executable File

#
# Copyright (c) 2015 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# -*- encoding: utf-8 -*-
#
from cgtsclient.common import base
class PciDevice(base.Resource):
def __repr__(self):
return "<PciDevice %s>" % self._info
class PciDeviceManager(base.Manager):
resource_class = PciDevice
def list(self, ihost_id):
path = '/v1/ihosts/%s/pci_devices' % ihost_id
return self._list(path, "pci_devices")
def list_all(self):
path = '/v1/pci_devices'
return self._list(path, "pci_devices")
def get(self, pci_id):
path = '/v1/pci_devices/%s' % pci_id
try:
return self._list(path)[0]
except IndexError:
return None
def update(self, pci_id, patch):
path = '/v1/pci_devices/%s' % pci_id
return self._update(path, patch)
def get_pci_device_display_name(p):
if p.name:
return p.name
else:
return '(' + str(p.uuid)[-8:] + ')'