summaryrefslogtreecommitdiff
path: root/novaclient/v2/contrib/list_extensions.py
diff options
context:
space:
mode:
Diffstat (limited to 'novaclient/v2/contrib/list_extensions.py')
-rw-r--r--novaclient/v2/contrib/list_extensions.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/novaclient/v2/contrib/list_extensions.py b/novaclient/v2/contrib/list_extensions.py
new file mode 100644
index 0000000..7eb9f16
--- /dev/null
+++ b/novaclient/v2/contrib/list_extensions.py
@@ -0,0 +1,46 @@
1# Copyright 2011 OpenStack Foundation
2# All Rights Reserved.
3#
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
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
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
14# under the License.
15
16from novaclient import base
17from novaclient import utils
18
19
20class ListExtResource(base.Resource):
21 @property
22 def summary(self):
23 descr = self.description.strip()
24 if not descr:
25 return '??'
26 lines = descr.split("\n")
27 if len(lines) == 1:
28 return lines[0]
29 else:
30 return lines[0] + "..."
31
32
33class ListExtManager(base.Manager):
34 resource_class = ListExtResource
35
36 def show_all(self):
37 return self._list("/extensions", 'extensions')
38
39
40def do_list_extensions(client, _args):
41 """
42 List all the os-api extensions that are available.
43 """
44 extensions = client.list_extensions.show_all()
45 fields = ["Name", "Summary", "Alias", "Updated"]
46 utils.print_list(extensions, fields)