SchedulerManager initialization fixed

- SchedulerManager.setup() fixed
- added missing client.__init__.py

Change-Id: I6bc4a99d5aa96c4a572c97a8a6716be88467d3a6
This commit is contained in:
Lisa Zangrando 2016-06-07 16:54:22 +02:00
parent 6dd88f7b32
commit 069ac71d61
4 changed files with 50 additions and 49 deletions

View File

@ -100,6 +100,8 @@ class FairShareManager(Manager):
return result
elif command == "CALCULATE_PRIORITY":
return self.calculatePriority(*args, **kargs)
elif command == "CALCULATE_FAIRSHARE":
return self.calculateFairShare(*args, **kargs)
else:
raise Exception("command=%r not supported!" % command)
@ -177,6 +179,9 @@ class FairShareManager(Manager):
self.condition.notifyAll()
def calculateFairShare(self):
if not self.projects:
return
total_prj_share = float(0)
total_usage_ram = float(0)
total_usage_cores = float(0)

View File

@ -949,7 +949,7 @@ class NovaManager(Manager):
try:
ids = ""
if prj_ids is not None:
if prj_ids is not None and prj_ids:
ids = " project_id IN ("
for prj_id in prj_ids:
@ -972,11 +972,9 @@ launched_at<='%(to_date)s' and (terminated_at>='%(from_date)s' or \
terminated_at is NULL) group by user_id, project_id\
""" % {"prj_ids": ids, "from_date": from_date, "to_date": to_date}
result = connection.execute(QUERY)
LOG.debug("getResourceUsage query: %s" % QUERY)
# LOG.info("QUERY %s\n" % QUERY)
# print("from_date %s\n" % from_date)
# print("to_date %s\n" % to_date)
result = connection.execute(QUERY)
prj_id = 0
user_id = 0
@ -1019,6 +1017,8 @@ where project_id='%(project_id)s' and deleted_at is NULL and (vm_state in \
('error') or (vm_state in ('active') and terminated_at is NULL))\
""" % {"project_id": prj_id}
LOG.debug("getProjectUsage query: %s" % QUERY)
result = connection.execute(QUERY)
for row in result.fetchall():
@ -1051,7 +1051,8 @@ utc_timestamp()) >= 20))))""" % {"project_id": prj_id,
"instances": ids,
"expiration": TTL}
# LOG.info(QUERY)
LOG.debug("getProjectUsage query: %s" % QUERY)
result = connection.execute(QUERY)
for row in result.fetchall():

View File

@ -249,7 +249,40 @@ class SchedulerManager(Manager):
self.listener = None
self.exit = False
try:
def parseAttribute(self, attribute):
if attribute is None:
return None
prj_name = None
value = float(0)
parsed_attribute = re.split('=', attribute)
if len(parsed_attribute) > 1:
if not parsed_attribute[-1].isdigit():
raise Exception("wrong value %r found in %r!"
% (parsed_attribute[-1], parsed_attribute))
if len(parsed_attribute) == 2:
prj_name = parsed_attribute[0]
value = float(parsed_attribute[1])
else:
raise Exception("wrong attribute definition: %r"
% parsed_attribute)
else:
raise Exception("wrong attribute definition: %r"
% parsed_attribute)
return (prj_name, value)
def execute(self, command, *args, **kargs):
if command == "PROCESS_REQUEST":
return self.processRequest(*args, **kargs)
else:
raise Exception("command=%r not supported!" % command)
def task(self):
if self.listener is None:
self.dynamic_quota = self.quota_manager.execute(
"GET_DYNAMIC_QUOTA")
@ -302,6 +335,9 @@ class SchedulerManager(Manager):
prj_id=prj_id,
prj_name=prj_name,
share=prj_share)
self.fairshare_manager.execute("CALCULATE_FAIRSHARE")
try:
self.dynamic_queue = self.queue_manager.execute("CREATE_QUEUE",
name="DYNAMIC")
@ -320,48 +356,6 @@ class SchedulerManager(Manager):
self.workers.append(dynamic_worker)
print(self.projects)
print(self.dynamic_quota.toDict())
except Exception as ex:
LOG.error("Exception has occured", exc_info=1)
LOG.error(ex)
raise ex
def parseAttribute(self, attribute):
if attribute is None:
return None
prj_name = None
value = float(0)
parsed_attribute = re.split('=', attribute)
if len(parsed_attribute) > 1:
if not parsed_attribute[-1].isdigit():
raise Exception("wrong value %r found in %r!"
% (parsed_attribute[-1], parsed_attribute))
if len(parsed_attribute) == 2:
prj_name = parsed_attribute[0]
value = float(parsed_attribute[1])
else:
raise Exception("wrong attribute definition: %r"
% parsed_attribute)
else:
raise Exception("wrong attribute definition: %r"
% parsed_attribute)
return (prj_name, value)
def execute(self, command, *args, **kargs):
if command == "PROCESS_REQUEST":
return self.processRequest(*args, **kargs)
else:
raise Exception("command=%r not supported!" % command)
def task(self):
if self.listener is None:
self.notifications = Notifications(self.dynamic_quota)
target = self.nova_manager.execute("GET_TARGET",
@ -375,6 +369,7 @@ class SchedulerManager(Manager):
LOG.info("listener created")
self.listener.start()
for prj_id, project in self.dynamic_quota.getProjects().items():
instances = project["instances"]["active"]
TTL = self.projects[prj_id]["TTL"]