Commit 998ea91f authored by Christos Stavrakakis's avatar Christos Stavrakakis

cyclades: Add 'name' to all commissions.

Make all quotaholder commissions to have a name. Since, Cyclades does
not store the association of a commission with a resource, we include
the resource in the commission name.
parent 7470e316
......@@ -96,9 +96,12 @@ def handle_vm_quotas(vm, job_id, job_opcode, job_status, job_fields):
previous_serial = vm.serial
if previous_serial and not previous_serial.resolved:
quotas.resolve_vm_commission(previous_serial)
commission_name = ("client: dispatcher, resource: %s, ganeti_job: %s"
% (vm, job_id))
serial = quotas.issue_commission(user=vm.userid,
source=quotas.DEFAULT_SOURCE,
provisions=commission_info,
name=commission_name,
force=True,
auto_accept=True)
# Clear VM's serial. Expected job may arrive later. However correlated
......
......@@ -89,9 +89,11 @@ def server_command(action):
commission_info = quotas.get_commission_info(vm, action=action)
if commission_info is not None:
# Issue new commission, associate it with the VM
commission_name = "client: api, resource %s" % vm
serial = quotas.issue_commission(user=user_id,
source=quotas.DEFAULT_SOURCE,
provisions=commission_info,
name=commission_name,
force=False,
auto_accept=False)
vm.serial = serial
......@@ -327,7 +329,8 @@ def resize(vm, flavor):
# Save serial to VM, since it is needed by server_command decorator
vm.serial = quotas.issue_commission(user=vm.userid,
source=quotas.DEFAULT_SOURCE,
provisions=commission_info)
provisions=commission_info,
name="resource: %s. resize" % vm)
return backend.resize_instance(vm, vcpus=flavor.cpu, memory=flavor.ram)
......
......@@ -83,7 +83,7 @@ def handle_astakosclient_error(func):
@handle_astakosclient_error
def issue_commission(user, source, provisions,
def issue_commission(user, source, provisions, name="",
force=False, auto_accept=False):
"""Issue a new commission to the quotaholder.
......@@ -95,7 +95,7 @@ def issue_commission(user, source, provisions,
qh = Quotaholder.get()
try:
serial = qh.issue_one_commission(ASTAKOS_TOKEN,
user, source, provisions,
user, source, provisions, name=name,
force=force, auto_accept=auto_accept)
except QuotaLimit as e:
msg, details = render_overlimit_exception(e)
......@@ -254,8 +254,11 @@ def issue_and_accept_commission(resource, delete=False):
qh_resources = reverse_quantities(qh_resources)
# Issue commission and get the assigned serial
serial = issue_commission(resource.userid, DEFAULT_SOURCE,
qh_resources)
commission_reason = ("client: api, resource: %s, delete: %s"
% (resource, delete))
serial = issue_commission(user=resource.userid, source=DEFAULT_SOURCE,
provisions=qh_resources,
name=commission_reason)
except:
transaction.rollback()
raise
......
......@@ -31,6 +31,7 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from datetime import datetime
from django.core.management.base import BaseCommand
from optparse import make_option
......@@ -123,7 +124,9 @@ class Command(BaseCommand):
request = {}
request["force"] = options["force"]
request["auto_accept"] = True
request["name"] = "RECONCILE"
request["name"] = \
("client: reconcile-resources-cyclades, time: %s"
% datetime.now())
request["provisions"] = map(create_provision, unsynced)
try:
qh.issue_commission(ASTAKOS_TOKEN, request)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment