Debian Codegraph @

neutronclient/common/extension.py

raw
1 # Copyright 2015 Rackspace Hosting Inc.
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 #
16 from stevedore import extension
17
18 from neutronclient.neutron import v2_0 as neutronV20
19
20
21 def _discover_via_entry_points():
22 emgr = extension.ExtensionManager('neutronclient.extension',
23 invoke_on_load=False)
24 return ((ext.name, ext.plugin) for ext in emgr)
25
26
27 class NeutronClientExtension(neutronV20.NeutronCommand):
28 pagination_support = False
29 _formatters = {}
30 sorting_support = False
31
32
33 class ClientExtensionShow(NeutronClientExtension, neutronV20.ShowCommand):
34 def take_action(self, parsed_args):
35 # NOTE(mdietz): Calls 'execute' to provide a consistent pattern
36 # for any implementers adding extensions with
37 # regard to any other extension verb.
38 return self.execute(parsed_args)
39
40 def execute(self, parsed_args):
41 return super(ClientExtensionShow, self).take_action(parsed_args)
42
43
44 class ClientExtensionList(NeutronClientExtension, neutronV20.ListCommand):
45 def take_action(self, parsed_args):
46 # NOTE(mdietz): Calls 'execute' to provide a consistent pattern
47 # for any implementers adding extensions with
48 # regard to any other extension verb.
49 return self.execute(parsed_args)
50
51 def execute(self, parsed_args):
52 return super(ClientExtensionList, self).take_action(parsed_args)
53
54
55 class ClientExtensionDelete(NeutronClientExtension, neutronV20.DeleteCommand):
56 def take_action(self, parsed_args):
57 # NOTE(mdietz): Calls 'execute' to provide a consistent pattern
58 # for any implementers adding extensions with
59 # regard to any other extension verb.
60 return self.execute(parsed_args)
61
62 def execute(self, parsed_args):
63 return super(ClientExtensionDelete, self).take_action(parsed_args)
64
65
66 class ClientExtensionCreate(NeutronClientExtension, neutronV20.CreateCommand):
67 def take_action(self, parsed_args):
68 # NOTE(mdietz): Calls 'execute' to provide a consistent pattern
69 # for any implementers adding extensions with
70 # regard to any other extension verb.
71 return self.execute(parsed_args)
72
73 def execute(self, parsed_args):
74 return super(ClientExtensionCreate, self).take_action(parsed_args)
75
76
77 class ClientExtensionUpdate(NeutronClientExtension, neutronV20.UpdateCommand):
78 def take_action(self, parsed_args):
79 # NOTE(mdietz): Calls 'execute' to provide a consistent pattern
80 # for any implementers adding extensions with
81 # regard to any other extension verb.
82 return self.execute(parsed_args)
83
84 def execute(self, parsed_args):
85 return super(ClientExtensionUpdate, self).take_action(parsed_args)