Add ability to get events from saharaclient
Change-Id: I01a0612ccc912249e01f12cd51181a79f3a155af Implements: blueprint event-log
This commit is contained in:
@@ -20,6 +20,7 @@ from keystoneclient.v3 import client as keystone_client_v3
|
||||
from saharaclient.api import cluster_templates
|
||||
from saharaclient.api import clusters
|
||||
from saharaclient.api import data_sources
|
||||
from saharaclient.api import events
|
||||
from saharaclient.api import httpclient
|
||||
from saharaclient.api import images
|
||||
from saharaclient.api import job_binaries
|
||||
@@ -97,6 +98,7 @@ class Client(object):
|
||||
self.job_binary_internals = (
|
||||
job_binary_internals.JobBinaryInternalsManager(client)
|
||||
)
|
||||
self.events = events.ClusterEventManager(client)
|
||||
|
||||
def get_keystone_client(self, username=None, api_key=None, auth_url=None,
|
||||
token=None, project_id=None, project_name=None):
|
||||
|
||||
31
saharaclient/api/events.py
Normal file
31
saharaclient/api/events.py
Normal file
@@ -0,0 +1,31 @@
|
||||
# Copyright (c) 2014 Mirantis Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
# implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from saharaclient.api import base
|
||||
|
||||
|
||||
class ClusterEvent(base.Resource):
|
||||
resource_name = 'ClusterEvent'
|
||||
|
||||
|
||||
class ClusterEventManager(base.ResourceManager):
|
||||
resource_class = ClusterEvent
|
||||
|
||||
def list(self, cluster_id, provision_step=None):
|
||||
if provision_step:
|
||||
return self._list('/clusters/%s/progress?provision_step=%s'
|
||||
% (cluster_id, provision_step), 'events')
|
||||
else:
|
||||
return self._list('/clusters/%s/progress' % cluster_id, 'events')
|
||||
@@ -796,3 +796,32 @@ def do_job_delete(cs, args):
|
||||
"""Delete a job."""
|
||||
cs.job_executions.delete(args.id)
|
||||
# TODO(mattf): No indication of result
|
||||
|
||||
#
|
||||
# Events
|
||||
# ~~~~~~~~
|
||||
# events-list --name <cluster>|--id <cluster_id>
|
||||
# [--step <step_id>]
|
||||
#
|
||||
|
||||
|
||||
@utils.arg('--name',
|
||||
metavar='<cluster_name>',
|
||||
help='Name of the cluster to show events.')
|
||||
@utils.arg('--id',
|
||||
metavar='<cluster_id>',
|
||||
help='ID of the cluster to show events.')
|
||||
@utils.arg('--step',
|
||||
metavar='<step_id>',
|
||||
default=None,
|
||||
help='ID of provision step to show events.')
|
||||
def do_event_list(cs, args):
|
||||
"""Show events of a cluster."""
|
||||
cluster = _get_by_id_or_name(cs.clusters, args.id, args.name)
|
||||
if args.step:
|
||||
events = cs.events.list(cluster.id, args.step)
|
||||
else:
|
||||
events = cs.events.list(cluster.id)
|
||||
columns = ('node_group_id', 'instance_name',
|
||||
'event_info', 'successful', 'step_id')
|
||||
utils.print_list(events, columns)
|
||||
|
||||
Reference in New Issue
Block a user