diff --git a/freezer_ui/api/api.py b/freezer_ui/api/api.py index 20abca2..5174cb2 100644 --- a/freezer_ui/api/api.py +++ b/freezer_ui/api/api.py @@ -258,7 +258,9 @@ def action_delete(request, ids): def client_list(request): clients = _freezerclient(request).registration.list() - clients = [Client(c['uuid'], c['client']['hostname']) + clients = [Client(c['uuid'], + c['client']['hostname'], + c['client']['client_id']) for c in clients] return clients @@ -272,7 +274,9 @@ def client_list_json(request): def client_get(request, client_id): """Get a single client""" client = _freezerclient(request).registration.get(client_id) - client = Client(client['uuid'], client['client']['hostname']) + client = Client(client['uuid'], + client['client']['hostname'], + client['client']['client_id']) return client diff --git a/freezer_ui/jobs/workflows/configure.py b/freezer_ui/jobs/workflows/configure.py index de30642..34c6f14 100644 --- a/freezer_ui/jobs/workflows/configure.py +++ b/freezer_ui/jobs/workflows/configure.py @@ -10,6 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. +from collections import namedtuple import datetime from django.utils.translation import ugettext_lazy as _ @@ -56,7 +57,7 @@ class ClientsConfigurationAction(workflows.MembershipAction): all_clients = freezer_api.client_list(request) except Exception: exceptions.handle(request, err_msg) - client_list = [(c.client, c.hostname) + client_list = [(c.uuid, c.hostname) for c in all_clients] field_name = self.get_member_field_name('member') @@ -221,9 +222,21 @@ class ConfigureJob(workflows.Workflow): return freezer_api.job_edit(request, context) else: if context['clients']: - for client in context['clients']: - context['client_id'] = client - freezer_api.job_create(request, context) + # we have to query the api to get the list of clients + # because MembershipAction for clients works with uuid's + # and we need to send the client_id instead of the uuid + # for the job creation + clients = freezer_api.client_list(request) + ClientIDS = namedtuple('Client', ['client_id', 'uuid']) + + client_list = [ClientIDS(c.client_id, c.uuid) + for c in clients] + + for client_uuid in context['clients']: + for client_id, uuid in client_list: + if client_uuid == uuid: + context['client_id'] = client_id + freezer_api.job_create(request, context) else: messages.warning(request, _("At least one client is " "required to create a job")) diff --git a/freezer_ui/utils.py b/freezer_ui/utils.py index 34f76a4..de69a07 100644 --- a/freezer_ui/utils.py +++ b/freezer_ui/utils.py @@ -83,9 +83,10 @@ class Backup(Dict2Object): class Client(object): - def __init__(self, client, hostname): - self.client = client + def __init__(self, uuid, hostname, client_id): + self.uuid = uuid self.hostname = hostname + self.client_id = client_id class ActionJob(object):