Debian Codegraph @

neutronclient/neutron/v2_0/lb/member.py

raw
1 # Copyright 2013 Mirantis 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
17 from neutronclient._i18n import _
18 from neutronclient.neutron import v2_0 as neutronV20
19
20
21 class ListMember(neutronV20.ListCommand):
22 """List members that belong to a given tenant."""
23
24 resource = 'member'
25 list_columns = [
26 'id', 'address', 'protocol_port', 'weight', 'admin_state_up', 'status'
27 ]
28 pagination_support = True
29 sorting_support = True
30
31
32 class ShowMember(neutronV20.ShowCommand):
33 """Show information of a given member."""
34
35 resource = 'member'
36 allow_names = False
37
38
39 class CreateMember(neutronV20.CreateCommand):
40 """Create a member."""
41
42 resource = 'member'
43
44 def add_known_arguments(self, parser):
45 parser.add_argument(
46 '--admin-state-down',
47 dest='admin_state', action='store_false',
48 help=_('Set admin state up to false.'))
49 parser.add_argument(
50 '--weight',
51 help=_('Weight of pool member in the pool (default:1, [0..256]).'))
52 parser.add_argument(
53 '--address',
54 required=True,
55 help=_('IP address of the pool member on the pool network.'))
56 parser.add_argument(
57 '--protocol-port',
58 required=True,
59 help=_('Port on which the pool member listens for requests or '
60 'connections.'))
61 parser.add_argument(
62 'pool_id', metavar='POOL',
63 help=_('ID or name of the pool this vip belongs to.'))
64
65 def args2body(self, parsed_args):
66 _pool_id = neutronV20.find_resourceid_by_name_or_id(
67 self.get_client(), 'pool', parsed_args.pool_id)
68 body = {'pool_id': _pool_id,
69 'admin_state_up': parsed_args.admin_state}
70 neutronV20.update_dict(
71 parsed_args,
72 body,
73 ['address', 'protocol_port', 'weight', 'tenant_id']
74 )
75 return {self.resource: body}
76
77
78 class UpdateMember(neutronV20.UpdateCommand):
79 """Update a given member."""
80
81 resource = 'member'
82
83
84 class DeleteMember(neutronV20.DeleteCommand):
85 """Delete a given member."""
86
87 resource = 'member'