1
# Copyright 2013 OpenStack LLC.
4
# Licensed under the Apache License, Version 2.0 (the "License"); you may
5
# not use this file except in compliance with the License. You may obtain
6
# a copy of the License at
8
# http://www.apache.org/licenses/LICENSE-2.0
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
# License for the specific language governing permissions and limitations
16
# vim: tabstop=4 shiftwidth=4 softtabstop=4
20
from quantumclient.quantum import v2_0 as quantumV20
23
def _format_timestamp(component):
25
return component['heartbeat_timestamp'].split(".", 2)[0]
30
class ListAgent(quantumV20.ListCommand):
34
log = logging.getLogger(__name__ + '.ListAgent')
35
list_columns = ['id', 'agent_type', 'host', 'alive', 'admin_state_up']
36
_formatters = {'heartbeat_timestamp': _format_timestamp}
38
def extend_list(self, data, parsed_args):
40
agent['alive'] = ":-)" if agent['alive'] else 'xxx'
43
class ShowAgent(quantumV20.ShowCommand):
44
"""Show information of a given agent."""
47
log = logging.getLogger(__name__ + '.ShowAgent')
52
class DeleteAgent(quantumV20.DeleteCommand):
53
"""Delete a given agent."""
55
log = logging.getLogger(__name__ + '.DeleteAgent')
59
class UpdateAgent(quantumV20.UpdateCommand):
60
"""Update a given agent."""
62
log = logging.getLogger(__name__ + '.UpdateAgent')