config/sysinv/cgts-client/cgts-client/cgtsclient/v1/inode.py
Mathieu Robinson 41c563646f Fixing tox pylint errors in cgts-client component
Below is an explanation/reasoning for the fixes:
    - Unused variable 'resp': This came about when unpacking a
      functions return value into multiple variables. These
      variables were replaced with '_' to signal that they are
      unused.

    - Added "# noqa" to lines referencing self.resource_class(...)
      to suppress a false positive pylint error.

    - importing urlparse on it's own instead of from the six module.

    - Multi line format strings cannot be concatenated together
      using '+'. When this is the case, '.format()' only takes into
      account the last of the strings and you get an error similar
      to "too many values to unpack to format string". The fix is
      to remove the '+'s so python sees it as one big string.

    - Removed unused function _get_pvs() from file
      cgtsclient/v1/ilvg.py

    - Removed unused function _get_cpus() from file
      cgtsclient/v1/inode.py

    - Removed a few imports which became unused from the removal
      of the above functions.

    - Added 4 exceptions which were referenced but never created.

Story: 2002888
Task: 23161

Change-Id: Ia1ed9158db5766fbab279950fdcdcea50789de96
Signed-off-by: Mathieu Robinson <mathieu.robinson@windriver.com>
2018-08-24 14:21:43 -04:00

53 lines
1.2 KiB
Python

#
# Copyright (c) 2013-2014 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# -*- encoding: utf-8 -*-
#
from cgtsclient.common import base
from cgtsclient import exc
CREATION_ATTRIBUTES = ['numa_node', 'capabilities', 'ihost_uuid']
class inode(base.Resource):
def __repr__(self):
return "<inode %s>" % self._info
class inodeManager(base.Manager):
resource_class = inode
def list(self, ihost_id):
path = '/v1/ihosts/%s/inodes' % ihost_id
return self._list(path, "inodes")
def get(self, inode_id):
path = '/v1/inodes/%s' % inode_id
try:
return self._list(path)[0]
except IndexError:
return None
def create(self, **kwargs):
path = '/v1/inodes'
new = {}
for (key, value) in kwargs.items():
if key in CREATION_ATTRIBUTES:
new[key] = value
else:
raise exc.InvalidAttribute('%s' % key)
return self._create(path, new)
def delete(self, inode_id):
path = '/v1/inodes/%s' % inode_id
return self._delete(path)
def update(self, inode_id, patch):
path = '/v1/inodes/%s' % inode_id
return self._update(path, patch)