Merge "P3: Fix pep8 error in cyborg/common and cyborg/conductor"
This commit is contained in:
commit
d9e51efbbd
@ -63,7 +63,8 @@ class CyborgException(Exception):
|
||||
# log the issue and the kwargs
|
||||
LOG.exception('Exception in string format operation')
|
||||
for name, value in kwargs.items():
|
||||
LOG.error("%s: %s" % (name, value))
|
||||
LOG.error("%(name)s: %(value)s",
|
||||
{"name": name, "value": value})
|
||||
|
||||
if CONF.fatal_exception_format_errors:
|
||||
raise
|
||||
@ -77,13 +78,13 @@ class CyborgException(Exception):
|
||||
def __str__(self):
|
||||
"""Encode to utf-8 then wsme api can consume it as well."""
|
||||
if not six.PY3:
|
||||
return unicode(self.args[0]).encode('utf-8')
|
||||
return six.text_type(self.args[0]).encode('utf-8')
|
||||
|
||||
return self.args[0]
|
||||
|
||||
def __unicode__(self):
|
||||
"""Return a unicode representation of the exception message."""
|
||||
return unicode(self.args[0])
|
||||
return six.text_type(self.args[0])
|
||||
|
||||
|
||||
class Forbidden(CyborgException):
|
||||
@ -409,6 +410,6 @@ class InvalidType(Invalid):
|
||||
"Expected: %(expected)s")
|
||||
|
||||
|
||||
# TODO Merge other NotFound in this generic one?
|
||||
# TODO() Merge other NotFound in this generic one?
|
||||
class ResourceNotFound(Invalid):
|
||||
_msg_fmt = _("%(resource)s not found %(msg)s")
|
||||
|
@ -27,16 +27,16 @@ def get_placement():
|
||||
return _PlacementClient()
|
||||
|
||||
|
||||
class _PlacementClient():
|
||||
class _PlacementClient(object):
|
||||
|
||||
def __init__(self):
|
||||
global _CONN
|
||||
if _CONN is None:
|
||||
default_user = 'devstack-admin'
|
||||
try:
|
||||
# TODO CONF access fails.
|
||||
# TODO() CONF access fails.
|
||||
auth_user = CONF.placement.username or default_user
|
||||
except:
|
||||
except Exception:
|
||||
auth_user = default_user
|
||||
_CONN = connection.Connection(cloud=auth_user)
|
||||
self._client = _CONN.placement
|
||||
@ -56,9 +56,9 @@ class _PlacementClient():
|
||||
for trait in trait_names:
|
||||
resp = placement.put('/traits/' + trait, microversion='1.6')
|
||||
if resp.status_code == 201:
|
||||
LOG.info("Created trait %s" % trait)
|
||||
LOG.info("Created trait %(trait)s", {"trait": trait})
|
||||
elif resp.status_code == 204:
|
||||
LOG.info("Trait %s already existed" % trait)
|
||||
LOG.info("Trait %(trait)s already existed", {"trait": trait})
|
||||
else:
|
||||
raise Exception(
|
||||
"Failed to create trait %s: HTTP %d: %s" %
|
||||
@ -79,7 +79,8 @@ class _PlacementClient():
|
||||
traits = list(set(traits_json['traits'] + trait_names))
|
||||
traits_json['traits'] = traits
|
||||
self._put_rp_traits(rp_uuid, traits_json)
|
||||
LOG.info('Added traits %s to RP %s' % (traits, rp_uuid))
|
||||
LOG.info('Added traits %(traits)s to RP %(rp_uuid)s',
|
||||
{"traits": traits, "rp_uuid": rp_uuid})
|
||||
|
||||
def delete_traits_with_prefixes(self, rp_uuid, trait_prefixes):
|
||||
traits_json = self._get_rp_traits(rp_uuid)
|
||||
@ -89,4 +90,5 @@ class _PlacementClient():
|
||||
for prefix in trait_prefixes)]
|
||||
traits_json['traits'] = traits
|
||||
self._put_rp_traits(rp_uuid, traits_json)
|
||||
LOG.info('Deleted traits %s from RP %s' % (traits, rp_uuid))
|
||||
LOG.info('Deleted traits %(traits)s to RP %(rp_uuid)s',
|
||||
{"traits": traits, "rp_uuid": rp_uuid})
|
||||
|
@ -14,11 +14,11 @@
|
||||
# under the License.
|
||||
|
||||
from oslo_config import cfg
|
||||
from cyborg import context as cyborg_context
|
||||
import oslo_messaging as messaging
|
||||
from oslo_messaging.rpc import dispatcher
|
||||
|
||||
from cyborg.common import exception
|
||||
from cyborg import context as cyborg_context
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
@ -14,7 +14,6 @@
|
||||
# under the License.
|
||||
|
||||
from oslo_concurrency import processutils
|
||||
from cyborg import context
|
||||
from oslo_log import log
|
||||
import oslo_messaging as messaging
|
||||
from oslo_service import service
|
||||
@ -27,6 +26,7 @@ from cyborg.common import exception
|
||||
from cyborg.common.i18n import _
|
||||
from cyborg.common import rpc
|
||||
from cyborg.conf import CONF
|
||||
from cyborg import context
|
||||
from cyborg import objects
|
||||
from cyborg.objects import base as objects_base
|
||||
|
||||
|
@ -13,24 +13,18 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo_log import log as logging
|
||||
import oslo_messaging as messaging
|
||||
|
||||
from cyborg.conf import CONF
|
||||
from cyborg import objects
|
||||
from cyborg.objects.attach_handle import AttachHandle
|
||||
from cyborg.objects.attribute import Attribute
|
||||
from cyborg.objects.control_path import ControlpathID
|
||||
from cyborg.objects.deployable import Deployable
|
||||
from cyborg.objects.device import Device
|
||||
from cyborg.objects.attribute import Attribute
|
||||
from cyborg.objects.attach_handle import AttachHandle
|
||||
from cyborg.objects.control_path import ControlpathID
|
||||
from cyborg.objects.driver_objects.driver_attribute import DriverAttribute
|
||||
from cyborg.objects.driver_objects.driver_controlpath_id import \
|
||||
DriverControlPathID
|
||||
from cyborg.objects.driver_objects.driver_attach_handle import \
|
||||
DriverAttachHandle
|
||||
from cyborg.objects.driver_objects.driver_deployable import DriverDeployable
|
||||
from cyborg.objects.driver_objects.driver_device import DriverDevice
|
||||
|
||||
from oslo_log import log as logging
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@ -134,7 +128,7 @@ class ConductorManager(object):
|
||||
:param driver_device_list: a list of driver_device object
|
||||
discovered by agent in the host.
|
||||
"""
|
||||
# TODO: Everytime get from the DB?
|
||||
# TODO(): Everytime get from the DB?
|
||||
# First retrieve the old_device_list from the DB.
|
||||
old_driver_device_list = DriverDevice.list(context, hostname)
|
||||
# TODO(wangzhh): Remove invalid driver_devices without controlpath_id.
|
||||
@ -146,9 +140,10 @@ class ConductorManager(object):
|
||||
def drv_device_make_diff(cls, context, host, old_driver_device_list,
|
||||
new_driver_device_list):
|
||||
"""Compare new driver-side device object list with the old one in
|
||||
one host."""
|
||||
one host.
|
||||
"""
|
||||
LOG.info("Start differing devices.")
|
||||
# TODO:The placement report will be implemented here.
|
||||
# TODO(): The placement report will be implemented here.
|
||||
# Use cpid.cpid_info to identify whether the device is the same.
|
||||
stub_cpid_list = [driver_dev_obj.controlpath_id.cpid_info for
|
||||
driver_dev_obj in new_driver_device_list
|
||||
@ -200,7 +195,8 @@ class ConductorManager(object):
|
||||
def drv_deployable_make_diff(cls, context, device_id, cpid_id,
|
||||
old_driver_dep_list, new_driver_dep_list):
|
||||
"""Compare new driver-side deployable object list with the old one in
|
||||
one host."""
|
||||
one host.
|
||||
"""
|
||||
# use name to identify whether the deployable is the same.
|
||||
LOG.info("Start differing deploybles.")
|
||||
new_name_list = [driver_dep_obj.name for driver_dep_obj in
|
||||
|
2
tox.ini
2
tox.ini
@ -107,7 +107,7 @@ show-source = True
|
||||
ignore = E123,E125,H405
|
||||
builtins = _
|
||||
enable-extensions = H106,H203,H904
|
||||
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,*sqlalchemy/alembic/versions/*,demo/,releasenotes,cyborg/accelerator/,cyborg/api,cyborg/agent/,cyborg/common,cyborg/conductor,cyborg/db,dyborg/hacking/,cyborg/tests/,cyborg/image,cyborg/objects
|
||||
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,*sqlalchemy/alembic/versions/*,demo/,releasenotes,cyborg/accelerator/,cyborg/api,cyborg/agent/,cyborg/db,dyborg/hacking/,cyborg/tests/,cyborg/image,cyborg/objects
|
||||
|
||||
[hacking]
|
||||
local-check-factory = cyborg.hacking.checks.factory
|
||||
|
Loading…
Reference in New Issue
Block a user