various clean & fix w/ changes in functionalities

Fixes not altering funtionalities:
- add missing requirement (requests)
- fix methods called with arguments when its signature doesn't allow it
- fix __init__ calls that didn't use `super()`
- fix string interpolations with wrong arguments

Affecting functionalities:
- remove the TRUST command in the keystone manager since the trust method
  doesn't exist
- add variable affectation in queue_manager.py:setData
- remove unused method parameters in some methods in quota_manager.py

Change-Id: I94655b276944b54922f88538879603c4fd72a11f
This commit is contained in:
Vincent Llorens 2016-06-02 16:37:52 +02:00
parent 5d07e0b8ef
commit 2bf9fb0d8f
7 changed files with 25 additions and 28 deletions

View File

@ -6,4 +6,5 @@ pbr>=1.6
synergy-service==0.2.0.dev4
oslo.config<2.0.0
oslo.messaging<2.0.0
requests==2.10.0
sqlalchemy==1.0.13

View File

@ -37,7 +37,7 @@ LOG = logging.getLogger(__name__)
class FairShareManager(Manager):
def __init__(self):
Manager.__init__(self, name="FairShareManager")
super(FairShareManager, self).__init__(name="FairShareManager")
self.config_opts = [
cfg.IntOpt('periods', default=3),
@ -84,7 +84,7 @@ class FairShareManager(Manager):
elif command == "GET_PROJECT":
return self.getProject(*args, **kargs)
elif command == "GET_PROJECTS":
return self.getProjects(*args, **kargs)
return self.getProjects()
elif command == "REMOVE_PROJECT":
return self.removeProject(*args, **kargs)
elif command == "GET_PRIORITY":

View File

@ -258,7 +258,7 @@ class Token(object):
class KeystoneManager(Manager):
def __init__(self):
Manager.__init__(self, name="KeystoneManager")
super(KeystoneManager, self).__init__(name="KeystoneManager")
self.config_opts = [
cfg.StrOpt("auth_url",
@ -330,13 +330,11 @@ class KeystoneManager(Manager):
elif command == "GET_ENDPOINTS":
return self.getEndpoints()
elif command == "GET_ENDPOINT":
return self.getEndpoints(*args, **kargs)
return self.getEndpoints()
elif command == "GET_SERVICES":
return self.getServices()
elif command == "GET_SERVICE":
return self.getService(*args, **kargs)
elif command == "TRUST":
return self.trust(*args, **kargs)
else:
return None
@ -452,8 +450,9 @@ class KeystoneManager(Manager):
response = self.getResource("/projects/%s" % id, "GET")
except requests.exceptions.HTTPError as ex:
response = ex.response.json()
raise Exception("error on retrieving the project (id=%r, "
% (id, response["error"]["message"]))
raise Exception(
"error on retrieving the project (id=%r, msg=%s)." %
(id, response["error"]["message"]))
if response:
response = response["project"]
@ -565,9 +564,9 @@ class KeystoneManager(Manager):
endpoints = self.getEndpoints()
except requests.exceptions.HTTPError as ex:
response = ex.response.json()
raise Exception("error on retrieving the endpoints list"
"(serviceId=%r): %s"
% response["error"]["message"])
raise Exception(
"error on retrieving the endpoints list (serviceId=%r)" %
response["error"]["message"])
if endpoints:
for endpoint in endpoints:

View File

@ -329,7 +329,7 @@ class NovaConductorComputeAPI(ComputeTaskAPI):
class NovaManager(Manager):
def __init__(self):
Manager.__init__(self, name="NovaManager")
super(NovaManager, self).__init__(name="NovaManager")
self.config_opts = [
cfg.StrOpt("nova_conf",
@ -596,7 +596,7 @@ class NovaManager(Manager):
if command == "GET_PARAMETER":
return self.getParameter(*args, **kargs)
elif command == "GET_FLAVORS":
return self.getFlavors(*args, **kargs)
return self.getFlavors()
elif command == "GET_FLAVOR":
return self.getFlavor(*args, **kargs)
elif command == "GET_SERVERS":
@ -622,7 +622,7 @@ class NovaManager(Manager):
elif command == "GET_TARGET":
return self.getTarget(*args, **kargs)
elif command == "GET_RCP_CLIENT":
return self.getRPCClient()
return self.getRPCClient(*args, **kargs)
elif command == "GET_RCP_SERVER":
return self.getRPCServer(*args, **kargs)
elif command == "GET_NOTIFICATION_LISTENER":
@ -679,7 +679,7 @@ class NovaManager(Manager):
except requests.exceptions.HTTPError as ex:
response = ex.response.json()
raise Exception("error on retrieving the flavors list: %s"
% (id, response["error"]["message"]))
% response["error"]["message"])
if response_data:
response_data = response_data["flavors"]
@ -804,8 +804,8 @@ class NovaManager(Manager):
response_data = self.getResource(url, "GET", data)
except requests.exceptions.HTTPError as ex:
response = ex.response.json()
raise Exception("error on retrieving the hypervisors list (id=%r)"
": %s" % response["error"]["message"])
raise Exception("error on retrieving the hypervisors list: %s"
% response["error"]["message"])
if response_data:
response_data = response_data["hypervisors"]

View File

@ -100,7 +100,7 @@ class QueueItem(object):
return self.data
def setData(self, data):
self.data
self.data = data
class PriorityQueue(object):
@ -400,7 +400,7 @@ retry_count, creation_time, last_update, data from `%s`""" % self.name
class QueueManager(Manager):
def __init__(self):
Manager.__init__(self, name="QueueManager")
super(QueueManager, self).__init__(name="QueueManager")
self.config_opts = [
cfg.StrOpt("db_connection", help="the DB url", required=True),

View File

@ -47,7 +47,7 @@ class DynamicQuota(object):
self.ram["limit"] = ram
self.cores["limit"] = cores
def getSize(self, cores, ram):
def getSize(self):
return {"cores": self.cores["limit"], "ram": self.ram["limit"]}
def getProjects(self):
@ -56,7 +56,7 @@ class DynamicQuota(object):
def getProject(self, prj_id):
return self.projects.get(prj_id, None)
def addProject(self, prj_id, prj_name, usage=None, TTL=0):
def addProject(self, prj_id, prj_name, usage=None):
if prj_id not in self.projects:
with self.condition:
project = {"name": prj_name,
@ -225,7 +225,7 @@ class DynamicQuota(object):
class QuotaManager(Manager):
def __init__(self):
Manager.__init__(self, name="QuotaManager")
super(QuotaManager, self).__init__(name="QuotaManager")
def setup(self):
try:

View File

@ -40,7 +40,7 @@ class Notifications(object):
self.dynamic_quota = dynamic_quota
def info(self, ctxt, publisher_id, event_type, payload, metadata):
def info(self, event_type, payload):
LOG.debug("Notification INFO: event_type=%s payload=%s"
% (event_type, payload))
@ -81,16 +81,13 @@ class Notifications(object):
except Exception as ex:
LOG.warn("Notification INFO: %s" % ex)
def warn(self, ctxt, publisher_id, event_type, payload, metadata):
# LOG.info("Notification WARN: event_type=%s payload=%s metadata=%s"
# % (event_type, payload, metadata))
def warn(self, event_type, payload):
state = payload["state"]
instance_id = payload["instance_id"]
LOG.info("Notification WARN: event_type=%s state=%s instance_id=%s"
% (event_type, state, instance_id))
def error(self, ctxt, publisher_id, event_type, payload, metadata):
def error(self, event_type, payload, metadata):
LOG.info("Notification ERROR: event_type=%s payload=%s metadata=%s"
% (event_type, payload, metadata))