python-neutronclient 12.0.0__py3-none-any.whl → 13.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-neutronclient
3
- Version: 12.0.0
3
+ Version: 13.0.0
4
4
  Summary: CLI and Client Library for OpenStack Networking
5
5
  Home-page: https://docs.openstack.org/python-neutronclient/latest/
6
6
  Author: OpenStack Networking Project
@@ -78,11 +78,6 @@ neutronclient/osc/plugin.py,sha256=w6LxS78C7L1AZ9J-cGYs3LLN7CDQJWTnOm5-8zlIIes,2
78
78
  neutronclient/osc/utils.py,sha256=6lQsswTCMaSPNpXyr94knT95A4VdFvX1vcj5nMbJ4jg,4649
79
79
  neutronclient/osc/v2/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
80
80
  neutronclient/osc/v2/utils.py,sha256=oCfrxLDlmn-ZlvtYEeRVwH12B2IDyl_1ECRLol1VRSQ,888
81
- neutronclient/osc/v2/dynamic_routing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
82
- neutronclient/osc/v2/dynamic_routing/bgp_dragent.py,sha256=WZjRUgkk9THjSiRzl53drKW9faMX_u8Xh2cVvIx6G70,3743
83
- neutronclient/osc/v2/dynamic_routing/bgp_peer.py,sha256=DzasNmIfUjd-FZE-vH18hwFXYuAFcz8Jy2Vbs77-C8k,6604
84
- neutronclient/osc/v2/dynamic_routing/bgp_speaker.py,sha256=Mw-xVRzf-DsIHh1E6Vtl25WrzRA-vAQjqCZ8kjR7EX0,11376
85
- neutronclient/osc/v2/dynamic_routing/constants.py,sha256=KFLE_7d9CTHZxuUIQy_9lGWNf7EGaqTnX6J-i7_CwaI,716
86
81
  neutronclient/osc/v2/fwaas/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
87
82
  neutronclient/osc/v2/fwaas/constants.py,sha256=dI-FnDq-0c-jaZ3YcGe9o19QYa0XpBpELIlJi_tLuvw,961
88
83
  neutronclient/osc/v2/lbaas/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -114,11 +109,6 @@ neutronclient/tests/unit/test_validators.py,sha256=Clm9BLJ9F3cQSzqIExiookZ2Y-zV9
114
109
  neutronclient/tests/unit/osc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
115
110
  neutronclient/tests/unit/osc/v2/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
116
111
  neutronclient/tests/unit/osc/v2/fakes.py,sha256=6qswG_w1Z9FEVYSxkiZCCjxM-nSZYigBAKK67L2lNhA,2031
117
- neutronclient/tests/unit/osc/v2/dynamic_routing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
118
- neutronclient/tests/unit/osc/v2/dynamic_routing/fakes.py,sha256=q1tXGsQCp7o9PtJY9l3Fgg9JmhEzrNbDABbsWuunyao,4765
119
- neutronclient/tests/unit/osc/v2/dynamic_routing/test_bgp_dragent.py,sha256=wpjF6JA6D9Dog1wWLldlLH9VkNVNZOG4MFQALQgA0K4,3295
120
- neutronclient/tests/unit/osc/v2/dynamic_routing/test_bgp_peer.py,sha256=AWFFr-5TGtFjLGjSY4lU7Oji6AbcKYh_w1wd-5AvYPg,4829
121
- neutronclient/tests/unit/osc/v2/dynamic_routing/test_bgp_speaker.py,sha256=GbvYqZATN5dLT1OQrlaAzSgLgT8DX3zIkm7ucrxKKeI,5214
122
112
  neutronclient/tests/unit/osc/v2/lbaas/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
123
113
  neutronclient/tests/unit/osc/v2/logging/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
124
114
  neutronclient/tests/unit/osc/v2/logging/fakes.py,sha256=tNETN4UoB7JVkPF9F34Vs4Nq_BTCrEI8uvBaUElTO4o,2490
@@ -142,11 +132,11 @@ neutronclient/tests/unit/osc/v2/vpnaas/test_ipsecpolicy.py,sha256=XwOQvyj54yHd2x
142
132
  neutronclient/tests/unit/osc/v2/vpnaas/test_vpnservice.py,sha256=dXPhpvfrEA_uvvZ_nhtCWXzXFX7x3uxGu3p8XohH8Ko,9994
143
133
  neutronclient/v2_0/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
144
134
  neutronclient/v2_0/client.py,sha256=uYxHWtHXq2mWhM707UBu8De-q6ohlVp0-xklsH_s8rE,116835
145
- python_neutronclient-12.0.0.dist-info/licenses/AUTHORS,sha256=hUa35KbI6UW9BTxvh4kgQrm3uxle5ket9_kfETkZ5zU,13611
146
- python_neutronclient-12.0.0.dist-info/licenses/LICENSE,sha256=XfKg2H1sVi8OoRxoisUlMqoo10TKvHmU_wU39ks7MyA,10143
147
- python_neutronclient-12.0.0.dist-info/METADATA,sha256=dIClGrjNX5ZCcan1baW7sCNsvdW2NiLzEE0mFMub8eM,3496
148
- python_neutronclient-12.0.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
149
- python_neutronclient-12.0.0.dist-info/entry_points.txt,sha256=f1N0Ez4Zajmw7yQ1KGyY7_Wjk0HqQgbokUxsAsH-ZAI,6745
150
- python_neutronclient-12.0.0.dist-info/pbr.json,sha256=ThbeTag8WoZXJ65GoTSiXCEbfUJ_qo1mrLrmewp5rW0,46
151
- python_neutronclient-12.0.0.dist-info/top_level.txt,sha256=SxHuzHShRY_O8UAQAiwIMIjwHRm7Tr05U-cvrn1fLgU,14
152
- python_neutronclient-12.0.0.dist-info/RECORD,,
135
+ python_neutronclient-13.0.0.dist-info/licenses/AUTHORS,sha256=hUa35KbI6UW9BTxvh4kgQrm3uxle5ket9_kfETkZ5zU,13611
136
+ python_neutronclient-13.0.0.dist-info/licenses/LICENSE,sha256=XfKg2H1sVi8OoRxoisUlMqoo10TKvHmU_wU39ks7MyA,10143
137
+ python_neutronclient-13.0.0.dist-info/METADATA,sha256=QPIsZmt_S4qQ9MhZ8lHoP_RR3MneS-ob8KUc2T0eLjc,3496
138
+ python_neutronclient-13.0.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
139
+ python_neutronclient-13.0.0.dist-info/entry_points.txt,sha256=56GVgksRYYRJYqDwzVkHpfqVh0w_mbNNjyuIZxee1D0,5164
140
+ python_neutronclient-13.0.0.dist-info/pbr.json,sha256=VHcOk_QNlgsISyg0LB5D-76hzNfK0Qe_4NeGcmektSY,46
141
+ python_neutronclient-13.0.0.dist-info/top_level.txt,sha256=SxHuzHShRY_O8UAQAiwIMIjwHRm7Tr05U-cvrn1fLgU,14
142
+ python_neutronclient-13.0.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (82.0.1)
2
+ Generator: setuptools (83.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -2,24 +2,6 @@
2
2
  neutronclient = neutronclient.osc.plugin
3
3
 
4
4
  [openstack.neutronclient.v2]
5
- bgp_dragent_add_speaker = neutronclient.osc.v2.dynamic_routing.bgp_dragent:AddBgpSpeakerToDRAgent
6
- bgp_dragent_list = neutronclient.osc.v2.dynamic_routing.bgp_dragent:ListDRAgent
7
- bgp_dragent_remove_speaker = neutronclient.osc.v2.dynamic_routing.bgp_dragent:RemoveBgpSpeakerFromDRAgent
8
- bgp_peer_create = neutronclient.osc.v2.dynamic_routing.bgp_peer:CreateBgpPeer
9
- bgp_peer_delete = neutronclient.osc.v2.dynamic_routing.bgp_peer:DeleteBgpPeer
10
- bgp_peer_list = neutronclient.osc.v2.dynamic_routing.bgp_peer:ListBgpPeer
11
- bgp_peer_set = neutronclient.osc.v2.dynamic_routing.bgp_peer:SetBgpPeer
12
- bgp_peer_show = neutronclient.osc.v2.dynamic_routing.bgp_peer:ShowBgpPeer
13
- bgp_speaker_add_network = neutronclient.osc.v2.dynamic_routing.bgp_speaker:AddNetworkToSpeaker
14
- bgp_speaker_add_peer = neutronclient.osc.v2.dynamic_routing.bgp_speaker:AddPeerToSpeaker
15
- bgp_speaker_create = neutronclient.osc.v2.dynamic_routing.bgp_speaker:CreateBgpSpeaker
16
- bgp_speaker_delete = neutronclient.osc.v2.dynamic_routing.bgp_speaker:DeleteBgpSpeaker
17
- bgp_speaker_list = neutronclient.osc.v2.dynamic_routing.bgp_speaker:ListBgpSpeaker
18
- bgp_speaker_list_advertised_routes = neutronclient.osc.v2.dynamic_routing.bgp_speaker:ListRoutesAdvertisedBySpeaker
19
- bgp_speaker_remove_network = neutronclient.osc.v2.dynamic_routing.bgp_speaker:RemoveNetworkFromSpeaker
20
- bgp_speaker_remove_peer = neutronclient.osc.v2.dynamic_routing.bgp_speaker:RemovePeerFromSpeaker
21
- bgp_speaker_set = neutronclient.osc.v2.dynamic_routing.bgp_speaker:SetBgpSpeaker
22
- bgp_speaker_show = neutronclient.osc.v2.dynamic_routing.bgp_speaker:ShowBgpSpeaker
23
5
  network_log_create = neutronclient.osc.v2.logging.network_log:CreateNetworkLog
24
6
  network_log_delete = neutronclient.osc.v2.logging.network_log:DeleteNetworkLog
25
7
  network_log_list = neutronclient.osc.v2.logging.network_log:ListNetworkLog
@@ -0,0 +1 @@
1
+ {"git_version": "2c92697", "is_release": true}
File without changes
@@ -1,112 +0,0 @@
1
- # Licensed under the Apache License, Version 2.0 (the "License"); you may
2
- # not use this file except in compliance with the License. You may obtain
3
- # a copy of the License at
4
- #
5
- # http://www.apache.org/licenses/LICENSE-2.0
6
- #
7
- # Unless required by applicable law or agreed to in writing, software
8
- # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9
- # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
- # License for the specific language governing permissions and limitations
11
- # under the License.
12
- #
13
-
14
- from osc_lib.command import command
15
- from osc_lib import utils
16
-
17
- from neutronclient._i18n import _
18
-
19
-
20
- def _format_alive_state(item):
21
- return ':-)' if item else 'XXX'
22
-
23
-
24
- _formatters = {
25
- 'alive': _format_alive_state
26
- }
27
-
28
-
29
- def add_common_args(parser):
30
- parser.add_argument('dragent_id',
31
- metavar='<agent-id>',
32
- help=_("ID of the dynamic routing agent"))
33
- parser.add_argument('bgp_speaker',
34
- metavar='<bgp-speaker>',
35
- help=_("ID or name of the BGP speaker"))
36
-
37
-
38
- class AddBgpSpeakerToDRAgent(command.Command):
39
- """Add a BGP speaker to a dynamic routing agent"""
40
-
41
- def get_parser(self, prog_name):
42
- parser = super(AddBgpSpeakerToDRAgent, self).get_parser(prog_name)
43
- add_common_args(parser)
44
- return parser
45
-
46
- def take_action(self, parsed_args):
47
- client = self.app.client_manager.network
48
- speaker_id = client.find_bgp_speaker(parsed_args.bgp_speaker).id
49
- client.add_bgp_speaker_to_dragent(parsed_args.dragent_id, speaker_id)
50
-
51
-
52
- class RemoveBgpSpeakerFromDRAgent(command.Command):
53
- """Removes a BGP speaker from a dynamic routing agent"""
54
-
55
- def get_parser(self, prog_name):
56
- parser = super(RemoveBgpSpeakerFromDRAgent, self).get_parser(
57
- prog_name)
58
- add_common_args(parser)
59
- return parser
60
-
61
- def take_action(self, parsed_args):
62
- client = self.app.client_manager.network
63
- speaker_id = client.find_bgp_speaker(parsed_args.bgp_speaker).id
64
- client.remove_bgp_speaker_from_dragent(parsed_args.dragent_id,
65
- speaker_id)
66
-
67
-
68
- class ListDRAgent(command.Lister):
69
- """List dynamic routing agents"""
70
-
71
- resource = 'agent'
72
- list_columns = ['id', 'host', 'admin_state_up', 'alive']
73
- unknown_parts_flag = False
74
-
75
- def get_parser(self, prog_name):
76
- parser = super(ListDRAgent,
77
- self).get_parser(prog_name)
78
- parser.add_argument('--bgp-speaker',
79
- metavar='<bgp-speaker>',
80
- help=_("List dynamic routing agents hosting a "
81
- "BGP speaker (name or ID)"))
82
- return parser
83
-
84
- def take_action(self, parsed_args):
85
- client = self.app.client_manager.network
86
- if parsed_args.bgp_speaker is not None:
87
- speaker_id = client.find_bgp_speaker(parsed_args.bgp_speaker).id
88
- data = client.get_bgp_dragents_hosting_speaker(speaker_id)
89
- else:
90
- attrs = {'agent_type': 'BGP dynamic routing agent'}
91
- data = client.agents(**attrs)
92
- columns = (
93
- 'id',
94
- 'agent_type',
95
- 'host',
96
- 'availability_zone',
97
- 'is_alive',
98
- 'is_admin_state_up',
99
- 'binary'
100
- )
101
- column_headers = (
102
- 'ID',
103
- 'Agent Type',
104
- 'Host',
105
- 'Availability Zone',
106
- 'Alive',
107
- 'State',
108
- 'Binary'
109
- )
110
- return (column_headers,
111
- (utils.get_item_properties(
112
- s, columns,) for s in data))
@@ -1,181 +0,0 @@
1
- # Licensed under the Apache License, Version 2.0 (the "License"); you may
2
- # not use this file except in compliance with the License. You may obtain
3
- # a copy of the License at
4
- #
5
- # http://www.apache.org/licenses/LICENSE-2.0
6
- #
7
- # Unless required by applicable law or agreed to in writing, software
8
- # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9
- # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
- # License for the specific language governing permissions and limitations
11
- # under the License.
12
- #
13
-
14
- from osc_lib.command import command
15
- from osc_lib import utils
16
-
17
- from neutronclient._i18n import _
18
- from neutronclient.common import exceptions
19
- from neutronclient.common import utils as nc_utils
20
- from neutronclient.osc import utils as nc_osc_utils
21
- from neutronclient.osc.v2.dynamic_routing import constants
22
-
23
-
24
- def _get_attrs(client_manager, parsed_args):
25
- attrs = {}
26
-
27
- # Validate password
28
- if 'auth_type' in parsed_args:
29
- if parsed_args.auth_type != 'none':
30
- if 'password' not in parsed_args or parsed_args.password is None:
31
- raise exceptions.CommandError(_('Must provide password if '
32
- 'auth-type is specified.'))
33
- if (
34
- parsed_args.auth_type == 'none' and
35
- parsed_args.password is not None
36
- ):
37
- raise exceptions.CommandError(_('Must provide auth-type if '
38
- 'password is specified.'))
39
- attrs['auth_type'] = parsed_args.auth_type
40
-
41
- if parsed_args.name is not None:
42
- attrs['name'] = parsed_args.name
43
- if 'remote_as' in parsed_args:
44
- attrs['remote_as'] = parsed_args.remote_as
45
- if 'peer_ip' in parsed_args:
46
- attrs['peer_ip'] = parsed_args.peer_ip
47
- if 'password' in parsed_args:
48
- attrs['password'] = parsed_args.password
49
-
50
- if 'project' in parsed_args and parsed_args.project is not None:
51
- identity_client = client_manager.identity
52
- project_id = nc_osc_utils.find_project(
53
- identity_client,
54
- parsed_args.project,
55
- parsed_args.project_domain,
56
- ).id
57
- attrs['tenant_id'] = project_id
58
- return attrs
59
-
60
-
61
- class CreateBgpPeer(command.ShowOne):
62
- _description = _("Create a BGP peer")
63
-
64
- def get_parser(self, prog_name):
65
- parser = super(CreateBgpPeer, self).get_parser(prog_name)
66
- parser.add_argument(
67
- 'name',
68
- metavar='<name>',
69
- help=_("Name of the BGP peer to create"))
70
- parser.add_argument(
71
- '--peer-ip',
72
- metavar='<peer-ip-address>',
73
- required=True,
74
- help=_("Peer IP address"))
75
- parser.add_argument(
76
- '--remote-as',
77
- required=True,
78
- metavar='<peer-remote-as>',
79
- help=_("Peer AS number. (Integer in [%(min_val)s, %(max_val)s] "
80
- "is allowed)") % {'min_val': constants.MIN_AS_NUM,
81
- 'max_val': constants.MAX_AS_NUM})
82
- parser.add_argument(
83
- '--auth-type',
84
- metavar='<peer-auth-type>',
85
- choices=['none', 'md5'],
86
- type=nc_utils.convert_to_lowercase,
87
- default='none',
88
- help=_("Authentication algorithm. Supported algorithms: "
89
- "none (default), md5"))
90
- parser.add_argument(
91
- '--password',
92
- metavar='<auth-password>',
93
- help=_("Authentication password"))
94
- nc_osc_utils.add_project_owner_option_to_parser(parser)
95
- return parser
96
-
97
- def take_action(self, parsed_args):
98
- client = self.app.client_manager.network
99
- attrs = _get_attrs(self.app.client_manager, parsed_args)
100
- obj = client.create_bgp_peer(**attrs)
101
- display_columns, columns = nc_osc_utils._get_columns(obj)
102
- data = utils.get_dict_properties(obj, columns)
103
- return display_columns, data
104
-
105
-
106
- class DeleteBgpPeer(command.Command):
107
- _description = _("Delete a BGP peer")
108
-
109
- def get_parser(self, prog_name):
110
- parser = super(DeleteBgpPeer, self).get_parser(prog_name)
111
- parser.add_argument(
112
- 'bgp_peer',
113
- metavar="<bgp-peer>",
114
- help=_("BGP peer to delete (name or ID)")
115
- )
116
- return parser
117
-
118
- def take_action(self, parsed_args):
119
- client = self.app.client_manager.network
120
- id = client.find_bgp_peer(parsed_args.bgp_peer)['id']
121
- client.delete_bgp_peer(id)
122
-
123
-
124
- class ListBgpPeer(command.Lister):
125
- _description = _("List BGP peers")
126
-
127
- def take_action(self, parsed_args):
128
- data = self.app.client_manager.network.bgp_peers(retrieve_all=True)
129
- headers = ('ID', 'Name', 'Peer IP', 'Remote AS')
130
- columns = ('id', 'name', 'peer_ip', 'remote_as')
131
- return (headers,
132
- (utils.get_dict_properties(s, columns,) for s in data))
133
-
134
-
135
- class SetBgpPeer(command.Command):
136
- _description = _("Update a BGP peer")
137
- resource = constants.BGP_PEER
138
-
139
- def get_parser(self, prog_name):
140
- parser = super(SetBgpPeer, self).get_parser(prog_name)
141
- parser.add_argument(
142
- '--name',
143
- help=_("Updated name of the BGP peer"))
144
- parser.add_argument(
145
- '--password',
146
- metavar='<auth-password>',
147
- help=_("Updated authentication password"))
148
- parser.add_argument(
149
- 'bgp_peer',
150
- metavar="<bgp-peer>",
151
- help=_("BGP peer to update (name or ID)")
152
- )
153
- return parser
154
-
155
- def take_action(self, parsed_args):
156
- client = self.app.client_manager.network
157
- id = client.find_bgp_peer(parsed_args.bgp_peer)['id']
158
- attrs = _get_attrs(self.app.client_manager, parsed_args)
159
- client.update_bgp_peer(id, **attrs)
160
-
161
-
162
- class ShowBgpPeer(command.ShowOne):
163
- _description = _("Show information for a BGP peer")
164
-
165
- def get_parser(self, prog_name):
166
- parser = super(ShowBgpPeer, self).get_parser(prog_name)
167
- parser.add_argument(
168
- 'bgp_peer',
169
- metavar="<bgp-peer>",
170
- help=_("BGP peer to display (name or ID)")
171
- )
172
- return parser
173
-
174
- def take_action(self, parsed_args):
175
- client = self.app.client_manager.network
176
- id = client.find_bgp_peer(parsed_args.bgp_peer,
177
- ignore_missing=False).id
178
- obj = client.get_bgp_peer(id)
179
- display_columns, columns = nc_osc_utils._get_columns(obj)
180
- data = utils.get_dict_properties(obj, columns)
181
- return display_columns, data
@@ -1,305 +0,0 @@
1
- # Licensed under the Apache License, Version 2.0 (the "License"); you may
2
- # not use this file except in compliance with the License. You may obtain
3
- # a copy of the License at
4
- #
5
- # http://www.apache.org/licenses/LICENSE-2.0
6
- #
7
- # Unless required by applicable law or agreed to in writing, software
8
- # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9
- # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
- # License for the specific language governing permissions and limitations
11
- # under the License.
12
- #
13
-
14
- from osc_lib.command import command
15
- from osc_lib import utils
16
-
17
- from neutronclient._i18n import _
18
- from neutronclient.osc import utils as nc_osc_utils
19
- from neutronclient.osc.v2.dynamic_routing import constants
20
-
21
-
22
- def _get_attrs(client_manager, parsed_args):
23
- attrs = {}
24
- if parsed_args.name is not None:
25
- attrs['name'] = str(parsed_args.name)
26
- if 'local_as' in parsed_args:
27
- attrs['local_as'] = parsed_args.local_as
28
- if 'ip_version' in parsed_args:
29
- attrs['ip_version'] = parsed_args.ip_version
30
- if parsed_args.advertise_tenant_networks:
31
- attrs['advertise_tenant_networks'] = True
32
- if parsed_args.no_advertise_tenant_networks:
33
- attrs['advertise_tenant_networks'] = False
34
- if parsed_args.advertise_floating_ip_host_routes:
35
- attrs['advertise_floating_ip_host_routes'] = True
36
- if parsed_args.no_advertise_floating_ip_host_routes:
37
- attrs['advertise_floating_ip_host_routes'] = False
38
-
39
- if 'project' in parsed_args and parsed_args.project is not None:
40
- identity_client = client_manager.identity
41
- project_id = nc_osc_utils.find_project(
42
- identity_client,
43
- parsed_args.project,
44
- parsed_args.project_domain,
45
- ).id
46
- attrs['tenant_id'] = project_id
47
- return attrs
48
-
49
-
50
- def add_common_arguments(parser):
51
- parser.add_argument(
52
- '--advertise-floating-ip-host-routes',
53
- action='store_true',
54
- help=_("Enable the advertisement of floating IP host routes "
55
- "by the BGP speaker. (default)"))
56
- parser.add_argument(
57
- '--no-advertise-floating-ip-host-routes',
58
- action='store_true',
59
- help=_("Disable the advertisement of floating IP host routes "
60
- "by the BGP speaker."))
61
- parser.add_argument(
62
- '--advertise-tenant-networks',
63
- action='store_true',
64
- help=_("Enable the advertisement of tenant network routes "
65
- "by the BGP speaker. (default)"))
66
- parser.add_argument(
67
- '--no-advertise-tenant-networks',
68
- action='store_true',
69
- help=_("Disable the advertisement of tenant network routes "
70
- "by the BGP speaker."))
71
-
72
-
73
- class AddNetworkToSpeaker(command.Command):
74
- _description = _("Add a network to a BGP speaker")
75
-
76
- def get_parser(self, prog_name):
77
- parser = super(AddNetworkToSpeaker, self).get_parser(prog_name)
78
- parser.add_argument(
79
- 'bgp_speaker',
80
- metavar='<bgp-speaker>',
81
- help=_("BGP speaker (name or ID)"))
82
- parser.add_argument(
83
- 'network',
84
- metavar='<network>',
85
- help=_("Network to add (name or ID)"))
86
- return parser
87
-
88
- def take_action(self, parsed_args):
89
- client = self.app.client_manager.network
90
- speaker_id = client.find_bgp_speaker(parsed_args.bgp_speaker,
91
- ignore_missing=False).id
92
- net_id = client.find_network(parsed_args.network,
93
- ignore_missing=False).id
94
- client.add_gateway_network_to_speaker(speaker_id, net_id)
95
-
96
-
97
- class AddPeerToSpeaker(command.Command):
98
- _description = _("Add a peer to a BGP speaker")
99
-
100
- def get_parser(self, prog_name):
101
- parser = super(AddPeerToSpeaker, self).get_parser(prog_name)
102
- parser.add_argument(
103
- 'bgp_speaker',
104
- metavar='<bgp-speaker>',
105
- help=_("BGP speaker (name or ID)"))
106
- parser.add_argument(
107
- 'bgp_peer',
108
- metavar='<bgp-peer>',
109
- help=_("BGP Peer to add (name or ID)"))
110
- return parser
111
-
112
- def take_action(self, parsed_args):
113
- client = self.app.client_manager.network
114
- speaker_id = client.find_bgp_speaker(parsed_args.bgp_speaker)['id']
115
- peer_id = client.find_bgp_peer(parsed_args.bgp_peer)['id']
116
- client.add_bgp_peer_to_speaker(speaker_id, peer_id)
117
-
118
-
119
- class CreateBgpSpeaker(command.ShowOne):
120
- _description = _("Create a BGP speaker")
121
-
122
- def get_parser(self, prog_name):
123
- parser = super(CreateBgpSpeaker, self).get_parser(prog_name)
124
- parser.add_argument(
125
- 'name',
126
- metavar='<name>',
127
- help=_("Name of the BGP speaker to create"))
128
- parser.add_argument(
129
- '--local-as',
130
- metavar='<local-as>',
131
- required=True,
132
- help=_("Local AS number. (Integer in [%(min_val)s, %(max_val)s] "
133
- "is allowed.)") % {'min_val': constants.MIN_AS_NUM,
134
- 'max_val': constants.MAX_AS_NUM})
135
- parser.add_argument(
136
- '--ip-version',
137
- type=int, choices=[4, 6],
138
- default=4,
139
- help=_("IP version for the BGP speaker (default is 4)"))
140
- add_common_arguments(parser)
141
- nc_osc_utils.add_project_owner_option_to_parser(parser)
142
- return parser
143
-
144
- def take_action(self, parsed_args):
145
- client = self.app.client_manager.network
146
- attrs = _get_attrs(self.app.client_manager, parsed_args)
147
- obj = client.create_bgp_speaker(**attrs)
148
- display_columns, columns = nc_osc_utils._get_columns(obj)
149
- data = utils.get_dict_properties(obj, columns)
150
- return display_columns, data
151
-
152
-
153
- class DeleteBgpSpeaker(command.Command):
154
- _description = _("Delete a BGP speaker")
155
-
156
- def get_parser(self, prog_name):
157
- parser = super(DeleteBgpSpeaker, self).get_parser(prog_name)
158
- parser.add_argument(
159
- 'bgp_speaker',
160
- metavar="<bgp-speaker>",
161
- help=_("BGP speaker to delete (name or ID)")
162
- )
163
- return parser
164
-
165
- def take_action(self, parsed_args):
166
- client = self.app.client_manager.network
167
- id = client.find_bgp_speaker(parsed_args.bgp_speaker)['id']
168
- client.delete_bgp_speaker(id)
169
-
170
-
171
- class ListBgpSpeaker(command.Lister):
172
- _description = _("List BGP speakers")
173
-
174
- def get_parser(self, prog_name):
175
- parser = super(ListBgpSpeaker, self).get_parser(prog_name)
176
- parser.add_argument(
177
- '--agent',
178
- metavar='<agent-id>',
179
- help=_("List BGP speakers hosted by an agent (ID only)"))
180
- return parser
181
-
182
- def take_action(self, parsed_args):
183
- client = self.app.client_manager.network
184
- if parsed_args.agent is not None:
185
- data = client.get_bgp_speakers_hosted_by_dragent(parsed_args.agent)
186
- else:
187
- data = client.bgp_speakers(retrieve_all=True)
188
-
189
- headers = ('ID', 'Name', 'Local AS', 'IP Version')
190
- columns = ('id', 'name', 'local_as', 'ip_version')
191
- return (headers, (utils.get_dict_properties(s, columns)
192
- for s in data))
193
-
194
-
195
- class ListRoutesAdvertisedBySpeaker(command.Lister):
196
- _description = _("List routes advertised")
197
-
198
- def get_parser(self, prog_name):
199
- parser = super(ListRoutesAdvertisedBySpeaker,
200
- self).get_parser(prog_name)
201
- parser.add_argument(
202
- 'bgp_speaker',
203
- metavar='<bgp-speaker>',
204
- help=_("BGP speaker (name or ID)"))
205
- return parser
206
-
207
- def take_action(self, parsed_args):
208
- client = self.app.client_manager.network
209
- speaker_id = client.find_bgp_speaker(parsed_args.bgp_speaker)['id']
210
- data = client.get_advertised_routes_of_speaker(speaker_id)
211
- headers = ('Destination', 'Nexthop')
212
- columns = ('destination', 'next_hop')
213
- return (headers, (utils.get_dict_properties(s, columns)
214
- for s in data['advertised_routes']))
215
-
216
-
217
- class RemoveNetworkFromSpeaker(command.Command):
218
- _description = _("Remove a network from a BGP speaker")
219
-
220
- def get_parser(self, prog_name):
221
- parser = super(RemoveNetworkFromSpeaker, self).get_parser(prog_name)
222
- parser.add_argument(
223
- 'bgp_speaker',
224
- metavar='<bgp-speaker>',
225
- help=_("BGP speaker (name or ID)"))
226
- parser.add_argument(
227
- 'network',
228
- metavar='<network>',
229
- help=_("Network to remove (name or ID)"))
230
- return parser
231
-
232
- def take_action(self, parsed_args):
233
- client = self.app.client_manager.network
234
- speaker_id = client.find_bgp_speaker(parsed_args.bgp_speaker)['id']
235
- net_id = client.find_network(parsed_args.network)['id']
236
- client.remove_gateway_network_from_speaker(speaker_id, net_id)
237
-
238
-
239
- class RemovePeerFromSpeaker(command.Command):
240
- _description = _("Remove a peer from a BGP speaker")
241
-
242
- def get_parser(self, prog_name):
243
- parser = super(RemovePeerFromSpeaker, self).get_parser(prog_name)
244
- parser.add_argument(
245
- 'bgp_speaker',
246
- metavar='<bgp-speaker>',
247
- help=_("BGP speaker (name or ID)"))
248
- parser.add_argument(
249
- 'bgp_peer',
250
- metavar='<bgp-peer>',
251
- help=_("BGP Peer to remove (name or ID)"))
252
- return parser
253
-
254
- def take_action(self, parsed_args):
255
- client = self.app.client_manager.network
256
- speaker_id = client.find_bgp_speaker(parsed_args.bgp_speaker)['id']
257
- peer_id = client.find_bgp_peer(parsed_args.bgp_peer)['id']
258
- client.remove_bgp_peer_from_speaker(speaker_id, peer_id)
259
-
260
-
261
- class SetBgpSpeaker(command.Command):
262
- _description = _("Set BGP speaker properties")
263
-
264
- resource = constants.BGP_SPEAKER
265
-
266
- def get_parser(self, prog_name):
267
- parser = super(SetBgpSpeaker, self).get_parser(prog_name)
268
- parser.add_argument(
269
- 'bgp_speaker',
270
- metavar="<bgp-speaker>",
271
- help=_("BGP speaker to update (name or ID)")
272
- )
273
- parser.add_argument(
274
- '--name',
275
- help=_("New name for the BGP speaker"))
276
- add_common_arguments(parser)
277
- return parser
278
-
279
- def take_action(self, parsed_args):
280
- client = self.app.client_manager.network
281
- id = client.find_bgp_speaker(parsed_args.bgp_speaker)['id']
282
- attrs = _get_attrs(self.app.client_manager, parsed_args)
283
- client.update_bgp_speaker(id, **attrs)
284
-
285
-
286
- class ShowBgpSpeaker(command.ShowOne):
287
- _description = _("Show a BGP speaker")
288
-
289
- def get_parser(self, prog_name):
290
- parser = super(ShowBgpSpeaker, self).get_parser(prog_name)
291
- parser.add_argument(
292
- 'bgp_speaker',
293
- metavar="<bgp-speaker>",
294
- help=_("BGP speaker to display (name or ID)")
295
- )
296
- return parser
297
-
298
- def take_action(self, parsed_args):
299
- client = self.app.client_manager.network
300
- id = client.find_bgp_speaker(parsed_args.bgp_speaker,
301
- ignore_missing=False).id
302
- obj = client.get_bgp_speaker(id)
303
- display_columns, columns = nc_osc_utils._get_columns(obj)
304
- data = utils.get_dict_properties(obj, columns)
305
- return display_columns, data
@@ -1,18 +0,0 @@
1
- # Licensed under the Apache License, Version 2.0 (the "License"); you may
2
- # not use this file except in compliance with the License. You may obtain
3
- # a copy of the License at
4
- #
5
- # http://www.apache.org/licenses/LICENSE-2.0
6
- #
7
- # Unless required by applicable law or agreed to in writing, software
8
- # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9
- # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
- # License for the specific language governing permissions and limitations
11
- # under the License.
12
-
13
- BGP_SPEAKERS = 'bgp_speakers'
14
- BGP_SPEAKER = 'bgp_speaker'
15
- BGP_PEERS = 'bgp_peers'
16
- BGP_PEER = 'bgp_peer'
17
- MIN_AS_NUM = 1
18
- MAX_AS_NUM = 4294967295
@@ -1,145 +0,0 @@
1
- # Licensed under the Apache License, Version 2.0 (the "License"); you may
2
- # not use this file except in compliance with the License. You may obtain
3
- # a copy of the License at
4
- #
5
- # http://www.apache.org/licenses/LICENSE-2.0
6
- #
7
- # Unless required by applicable law or agreed to in writing, software
8
- # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9
- # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
- # License for the specific language governing permissions and limitations
11
- # under the License.
12
-
13
- from unittest import mock
14
- import uuid
15
-
16
- from openstack.network.v2 import agent as _agent
17
- from openstack.network.v2 import bgp_peer as _bgp_peer
18
- from openstack.network.v2 import bgp_speaker as _bgp_speaker
19
-
20
- from neutronclient.tests.unit.osc.v2 import fakes
21
-
22
-
23
- class TestNeutronDynamicRoutingOSCV2(fakes.TestNeutronClientOSCV2):
24
- def setUp(self):
25
- super(TestNeutronDynamicRoutingOSCV2, self).setUp()
26
- self.neutronclient.find_resource = mock.Mock(
27
- side_effect=lambda resource, name_or_id, project_id=None,
28
- cmd_resource=None, parent_id=None, fields=None:
29
- {'id': name_or_id})
30
-
31
- self.networkclient.find_bgp_speaker = mock.Mock(
32
- side_effect=lambda name_or_id, project_id=None,
33
- cmd_resource=None, parent_id=None, fields=None,
34
- ignore_missing=False:
35
- _bgp_speaker.BgpSpeaker(id=name_or_id))
36
- self.networkclient.find_bgp_peer = mock.Mock(
37
- side_effect=lambda name_or_id, project_id=None,
38
- cmd_resource=None, parent_id=None, fields=None,
39
- ignore_missing=False:
40
- _bgp_peer.BgpPeer(id=name_or_id))
41
-
42
-
43
- class FakeBgpSpeaker(object):
44
- """Fake one or more bgp speakers."""
45
-
46
- @staticmethod
47
- def create_one_bgp_speaker(attrs=None):
48
- attrs = attrs or {}
49
- # Set default attributes.
50
- bgp_speaker_attrs = {
51
- 'peers': [],
52
- 'local_as': 200,
53
- 'advertise_tenant_networks': True,
54
- 'networks': [],
55
- 'ip_version': 4,
56
- 'advertise_floating_ip_host_routes': True,
57
- 'id': uuid.uuid4().hex,
58
- 'name': 'bgp-speaker-' + uuid.uuid4().hex,
59
- 'tenant_id': uuid.uuid4().hex,
60
- }
61
-
62
- # Overwrite default attributes.
63
- bgp_speaker_attrs.update(attrs)
64
- ret_bgp_speaker = _bgp_speaker.BgpSpeaker(**bgp_speaker_attrs)
65
-
66
- return ret_bgp_speaker
67
-
68
- @staticmethod
69
- def create_bgp_speakers(attrs=None, count=1):
70
- """Create multiple fake bgp speakers.
71
-
72
- """
73
- bgp_speakers = []
74
- for i in range(count):
75
- bgp_speaker = FakeBgpSpeaker.create_one_bgp_speaker(attrs)
76
- bgp_speakers.append(bgp_speaker)
77
-
78
- return bgp_speakers
79
-
80
-
81
- class FakeBgpPeer(object):
82
- """Fake one or more bgp peers."""
83
-
84
- @staticmethod
85
- def create_one_bgp_peer(attrs=None):
86
- attrs = attrs or {}
87
- # Set default attributes.
88
- bgp_peer_attrs = {
89
- 'auth_type': None,
90
- 'peer_ip': '1.1.1.1',
91
- 'remote_as': 100,
92
- 'id': uuid.uuid4().hex,
93
- 'name': 'bgp-peer-' + uuid.uuid4().hex,
94
- 'tenant_id': uuid.uuid4().hex,
95
- }
96
-
97
- # Overwrite default attributes.
98
- bgp_peer_attrs.update(attrs)
99
- ret_bgp_peer = _bgp_peer.BgpPeer(**bgp_peer_attrs)
100
-
101
- return ret_bgp_peer
102
-
103
- @staticmethod
104
- def create_bgp_peers(attrs=None, count=1):
105
- """Create one or multiple fake bgp peers."""
106
- bgp_peers = []
107
- for i in range(count):
108
- bgp_peer = FakeBgpPeer.create_one_bgp_peer(attrs)
109
- bgp_peers.append(bgp_peer)
110
-
111
- return bgp_peers
112
-
113
-
114
- class FakeDRAgent(object):
115
- """Fake one or more dynamic routing agents."""
116
-
117
- @staticmethod
118
- def create_one_dragent(attrs=None):
119
- attrs = attrs or {}
120
- # Set default attributes.
121
- dragent_attrs = {
122
- 'binary': 'neutron-bgp-dragent',
123
- 'admin_state_up': True,
124
- 'availability_zone': None,
125
- 'alive': True,
126
- 'topic': 'bgp_dragent',
127
- 'host': 'network-' + uuid.uuid4().hex,
128
- 'name': 'bgp-dragent-' + uuid.uuid4().hex,
129
- 'agent_type': 'BGP dynamic routing agent',
130
- 'id': uuid.uuid4().hex,
131
- }
132
-
133
- # Overwrite default attributes.
134
- dragent_attrs.update(attrs)
135
- return _agent.Agent(**dragent_attrs)
136
-
137
- @staticmethod
138
- def create_dragents(attrs=None, count=1):
139
- """Create one or multiple fake dynamic routing agents."""
140
- agents = []
141
- for i in range(count):
142
- agent = FakeDRAgent.create_one_dragent(attrs)
143
- agents.append(agent)
144
-
145
- return agents
@@ -1,84 +0,0 @@
1
- # Licensed under the Apache License, Version 2.0 (the "License"); you may
2
- # not use this file except in compliance with the License. You may obtain
3
- # a copy of the License at
4
- #
5
- # http://www.apache.org/licenses/LICENSE-2.0
6
- #
7
- # Unless required by applicable law or agreed to in writing, software
8
- # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9
- # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
- # License for the specific language governing permissions and limitations
11
- # under the License.
12
- #
13
- from unittest import mock
14
-
15
- from neutronclient.osc.v2.dynamic_routing import bgp_dragent
16
- from neutronclient.tests.unit.osc.v2.dynamic_routing import fakes
17
-
18
-
19
- class TestAddBgpSpeakerToDRAgent(fakes.TestNeutronDynamicRoutingOSCV2):
20
- _bgp_speaker = fakes.FakeBgpSpeaker.create_one_bgp_speaker()
21
- _bgp_dragent = fakes.FakeDRAgent.create_one_dragent()
22
- _bgp_speaker_id = _bgp_speaker['id']
23
- _bgp_dragent_id = _bgp_dragent['id']
24
-
25
- def setUp(self):
26
- super(TestAddBgpSpeakerToDRAgent, self).setUp()
27
-
28
- # Get the command object to test
29
- self.cmd = bgp_dragent.AddBgpSpeakerToDRAgent(self.app, self.namespace)
30
-
31
- def test_add_bgp_speaker_to_dragent(self):
32
- arglist = [
33
- self._bgp_dragent_id,
34
- self._bgp_speaker_id,
35
- ]
36
- verifylist = [
37
- ('dragent_id', self._bgp_dragent_id),
38
- ('bgp_speaker', self._bgp_speaker_id),
39
- ]
40
- parsed_args = self.check_parser(self.cmd, arglist, verifylist)
41
-
42
- with mock.patch.object(self.networkclient,
43
- "add_bgp_speaker_to_dragent",
44
- return_value=None):
45
-
46
- result = self.cmd.take_action(parsed_args)
47
- self.networkclient.add_bgp_speaker_to_dragent.\
48
- assert_called_once_with(
49
- self._bgp_dragent_id, self._bgp_speaker_id)
50
- self.assertIsNone(result)
51
-
52
-
53
- class TestRemoveBgpSpeakerFromDRAgent(fakes.TestNeutronDynamicRoutingOSCV2):
54
- _bgp_speaker = fakes.FakeBgpSpeaker.create_one_bgp_speaker()
55
- _bgp_dragent = fakes.FakeDRAgent.create_one_dragent()
56
- _bgp_speaker_id = _bgp_speaker['id']
57
- _bgp_dragent_id = _bgp_dragent['id']
58
-
59
- def setUp(self):
60
- super(TestRemoveBgpSpeakerFromDRAgent, self).setUp()
61
-
62
- # Get the command object to test
63
- self.cmd = bgp_dragent.RemoveBgpSpeakerFromDRAgent(
64
- self.app, self.namespace)
65
-
66
- def test_remove_bgp_speaker_from_dragent(self):
67
- arglist = [
68
- self._bgp_dragent_id,
69
- self._bgp_speaker_id,
70
- ]
71
- verifylist = [
72
- ('dragent_id', self._bgp_dragent_id),
73
- ('bgp_speaker', self._bgp_speaker_id),
74
- ]
75
- parsed_args = self.check_parser(self.cmd, arglist, verifylist)
76
-
77
- with mock.patch.object(self.networkclient,
78
- "remove_bgp_speaker_from_dragent",
79
- return_value=None):
80
- result = self.cmd.take_action(parsed_args)
81
- self.networkclient.remove_bgp_speaker_from_dragent.\
82
- assert_called_once_with(self._bgp_dragent_id,
83
- self._bgp_speaker_id)
84
- self.assertIsNone(result)
@@ -1,150 +0,0 @@
1
- # Licensed under the Apache License, Version 2.0 (the "License"); you may
2
- # not use this file except in compliance with the License. You may obtain
3
- # a copy of the License at
4
- #
5
- # http://www.apache.org/licenses/LICENSE-2.0
6
- #
7
- # Unless required by applicable law or agreed to in writing, software
8
- # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9
- # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
- # License for the specific language governing permissions and limitations
11
- # under the License.
12
- #
13
- from unittest import mock
14
-
15
- from neutronclient.osc.v2.dynamic_routing import bgp_peer
16
- from neutronclient.tests.unit.osc.v2.dynamic_routing import fakes
17
-
18
-
19
- class TestListBgpPeer(fakes.TestNeutronDynamicRoutingOSCV2):
20
- _bgp_peers = fakes.FakeBgpPeer.create_bgp_peers(count=1)
21
- columns = ('ID', 'Name', 'Peer IP', 'Remote AS')
22
- data = []
23
- for _bgp_peer in _bgp_peers:
24
- data.append((
25
- _bgp_peer['id'],
26
- _bgp_peer['name'],
27
- _bgp_peer['peer_ip'],
28
- _bgp_peer['remote_as']))
29
-
30
- def setUp(self):
31
- super(TestListBgpPeer, self).setUp()
32
-
33
- self.networkclient.bgp_peers = mock.Mock(
34
- return_value=self._bgp_peers
35
- )
36
-
37
- # Get the command object to test
38
- self.cmd = bgp_peer.ListBgpPeer(self.app, self.namespace)
39
-
40
- def test_bgp_peer_list(self):
41
- parsed_args = self.check_parser(self.cmd, [], [])
42
-
43
- columns, data = self.cmd.take_action(parsed_args)
44
- self.networkclient.bgp_peers.assert_called_once_with(
45
- retrieve_all=True)
46
- self.assertEqual(self.columns, columns)
47
- self.assertEqual(self.data, list(data))
48
-
49
-
50
- class TestDeleteBgpPeer(fakes.TestNeutronDynamicRoutingOSCV2):
51
-
52
- _bgp_peer = fakes.FakeBgpPeer.create_one_bgp_peer()
53
-
54
- def setUp(self):
55
- super(TestDeleteBgpPeer, self).setUp()
56
-
57
- self.networkclient.delete_bgp_peer = mock.Mock(return_value=None)
58
-
59
- self.cmd = bgp_peer.DeleteBgpPeer(self.app, self.namespace)
60
-
61
- def test_delete_bgp_peer(self):
62
- arglist = [
63
- self._bgp_peer['name'],
64
- ]
65
- verifylist = [
66
- ('bgp_peer', self._bgp_peer['name']),
67
- ]
68
- parsed_args = self.check_parser(self.cmd, arglist, verifylist)
69
-
70
- result = self.cmd.take_action(parsed_args)
71
-
72
- self.networkclient.delete_bgp_peer.assert_called_once_with(
73
- self._bgp_peer['name'])
74
- self.assertIsNone(result)
75
-
76
-
77
- class TestShowBgpPeer(fakes.TestNeutronDynamicRoutingOSCV2):
78
- _one_bgp_peer = fakes.FakeBgpPeer.create_one_bgp_peer()
79
- data = (
80
- _one_bgp_peer['auth_type'],
81
- _one_bgp_peer['id'],
82
- _one_bgp_peer['name'],
83
- _one_bgp_peer['peer_ip'],
84
- _one_bgp_peer['tenant_id'],
85
- _one_bgp_peer['remote_as'],
86
- )
87
- _bgp_peer = _one_bgp_peer
88
- _bgp_peer_name = _one_bgp_peer['name']
89
- columns = (
90
- 'auth_type',
91
- 'id',
92
- 'name',
93
- 'peer_ip',
94
- 'project_id',
95
- 'remote_as',
96
- )
97
-
98
- def setUp(self):
99
- super(TestShowBgpPeer, self).setUp()
100
-
101
- self.networkclient.get_bgp_peer = mock.Mock(
102
- return_value=self._bgp_peer
103
- )
104
- # Get the command object to test
105
- self.cmd = bgp_peer.ShowBgpPeer(self.app, self.namespace)
106
-
107
- def test_bgp_peer_show(self):
108
- arglist = [
109
- self._bgp_peer_name,
110
- ]
111
- verifylist = [
112
- ('bgp_peer', self._bgp_peer_name),
113
- ]
114
- parsed_args = self.check_parser(self.cmd, arglist, verifylist)
115
-
116
- data = self.cmd.take_action(parsed_args)
117
- self.networkclient.get_bgp_peer.assert_called_once_with(
118
- self._bgp_peer_name)
119
- self.assertEqual(self.columns, data[0])
120
- self.assertEqual(self.data, data[1])
121
-
122
-
123
- class TestSetBgpPeer(fakes.TestNeutronDynamicRoutingOSCV2):
124
- _one_bgp_peer = fakes.FakeBgpPeer.create_one_bgp_peer()
125
- _bgp_peer_name = _one_bgp_peer['name']
126
-
127
- def setUp(self):
128
- super(TestSetBgpPeer, self).setUp()
129
- self.networkclient.update_bgp_peer = mock.Mock(return_value=None)
130
- bgp_peer.get_bgp_peer_id = mock.Mock(return_value=self._bgp_peer_name)
131
-
132
- self.cmd = bgp_peer.SetBgpPeer(self.app, self.namespace)
133
-
134
- def test_set_bgp_peer(self):
135
- arglist = [
136
- self._bgp_peer_name,
137
- '--name', 'noob',
138
- ]
139
- verifylist = [
140
- ('bgp_peer', self._bgp_peer_name),
141
- ('name', 'noob'),
142
- ]
143
-
144
- parsed_args = self.check_parser(self.cmd, arglist, verifylist)
145
- result = self.cmd.take_action(parsed_args)
146
-
147
- attrs = {'name': 'noob', 'password': None}
148
- self.networkclient.update_bgp_peer.assert_called_once_with(
149
- self._bgp_peer_name, **attrs)
150
- self.assertIsNone(result)
@@ -1,157 +0,0 @@
1
- # Licensed under the Apache License, Version 2.0 (the "License"); you may
2
- # not use this file except in compliance with the License. You may obtain
3
- # a copy of the License at
4
- #
5
- # http://www.apache.org/licenses/LICENSE-2.0
6
- #
7
- # Unless required by applicable law or agreed to in writing, software
8
- # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9
- # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
- # License for the specific language governing permissions and limitations
11
- # under the License.
12
- #
13
- from unittest import mock
14
-
15
- from neutronclient.osc.v2.dynamic_routing import bgp_speaker
16
- from neutronclient.tests.unit.osc.v2.dynamic_routing import fakes
17
-
18
-
19
- class TestListBgpSpeaker(fakes.TestNeutronDynamicRoutingOSCV2):
20
- _bgp_speakers = fakes.FakeBgpSpeaker.create_bgp_speakers()
21
- columns = ('ID', 'Name', 'Local AS', 'IP Version')
22
- data = []
23
- for _bgp_speaker in _bgp_speakers:
24
- data.append((
25
- _bgp_speaker['id'],
26
- _bgp_speaker['name'],
27
- _bgp_speaker['local_as'],
28
- _bgp_speaker['ip_version']))
29
-
30
- def setUp(self):
31
- super(TestListBgpSpeaker, self).setUp()
32
-
33
- self.networkclient.bgp_speakers = mock.Mock(
34
- return_value=self._bgp_speakers
35
- )
36
-
37
- # Get the command object to test
38
- self.cmd = bgp_speaker.ListBgpSpeaker(self.app, self.namespace)
39
-
40
- def test_bgp_speaker_list(self):
41
- parsed_args = self.check_parser(self.cmd, [], [])
42
-
43
- columns, data = self.cmd.take_action(parsed_args)
44
- self.networkclient.bgp_speakers.assert_called_once_with(
45
- retrieve_all=True)
46
-
47
- self.assertEqual(self.columns, columns)
48
- self.assertEqual(self.data, list(data))
49
-
50
-
51
- class TestDeleteBgpSpeaker(fakes.TestNeutronDynamicRoutingOSCV2):
52
-
53
- _bgp_speaker = fakes.FakeBgpSpeaker.create_one_bgp_speaker()
54
-
55
- def setUp(self):
56
- super(TestDeleteBgpSpeaker, self).setUp()
57
-
58
- self.networkclient.delete_bgp_speaker = mock.Mock(return_value=None)
59
-
60
- self.cmd = bgp_speaker.DeleteBgpSpeaker(self.app, self.namespace)
61
-
62
- def test_delete_bgp_speaker(self):
63
- arglist = [
64
- self._bgp_speaker['name'],
65
- ]
66
- verifylist = [
67
- ('bgp_speaker', self._bgp_speaker['name']),
68
- ]
69
- parsed_args = self.check_parser(self.cmd, arglist, verifylist)
70
-
71
- result = self.cmd.take_action(parsed_args)
72
-
73
- self.networkclient.delete_bgp_speaker.assert_called_once_with(
74
- self._bgp_speaker['name'])
75
- self.assertIsNone(result)
76
-
77
-
78
- class TestShowBgpSpeaker(fakes.TestNeutronDynamicRoutingOSCV2):
79
- _one_bgp_speaker = fakes.FakeBgpSpeaker.create_one_bgp_speaker()
80
- data = (
81
- _one_bgp_speaker['advertise_floating_ip_host_routes'],
82
- _one_bgp_speaker['advertise_tenant_networks'],
83
- _one_bgp_speaker['id'],
84
- _one_bgp_speaker['ip_version'],
85
- _one_bgp_speaker['local_as'],
86
- _one_bgp_speaker['name'],
87
- _one_bgp_speaker['networks'],
88
- _one_bgp_speaker['peers'],
89
- _one_bgp_speaker['tenant_id']
90
- )
91
- _bgp_speaker = _one_bgp_speaker
92
- _bgp_speaker_name = _one_bgp_speaker['name']
93
- columns = (
94
- 'advertise_floating_ip_host_routes',
95
- 'advertise_tenant_networks',
96
- 'id',
97
- 'ip_version',
98
- 'local_as',
99
- 'name',
100
- 'networks',
101
- 'peers',
102
- 'project_id'
103
- )
104
-
105
- def setUp(self):
106
- super(TestShowBgpSpeaker, self).setUp()
107
-
108
- self.networkclient.get_bgp_speaker = mock.Mock(
109
- return_value=self._bgp_speaker
110
- )
111
- # Get the command object to test
112
- self.cmd = bgp_speaker.ShowBgpSpeaker(self.app, self.namespace)
113
-
114
- def test_bgp_speaker_show(self):
115
- arglist = [
116
- self._bgp_speaker_name,
117
- ]
118
- verifylist = [
119
- ('bgp_speaker', self._bgp_speaker_name),
120
- ]
121
- parsed_args = self.check_parser(self.cmd, arglist, verifylist)
122
-
123
- data = self.cmd.take_action(parsed_args)
124
- self.networkclient.get_bgp_speaker.assert_called_once_with(
125
- self._bgp_speaker_name)
126
- self.assertEqual(self.columns, data[0])
127
- self.assertEqual(self.data, data[1])
128
-
129
-
130
- class TestSetBgpSpeaker(fakes.TestNeutronDynamicRoutingOSCV2):
131
- _one_bgp_speaker = fakes.FakeBgpSpeaker.create_one_bgp_speaker()
132
- _bgp_speaker_name = _one_bgp_speaker['name']
133
-
134
- def setUp(self):
135
- super(TestSetBgpSpeaker, self).setUp()
136
- self.networkclient.update_bgp_speaker = mock.Mock(
137
- return_value=None)
138
-
139
- self.cmd = bgp_speaker.SetBgpSpeaker(self.app, self.namespace)
140
-
141
- def test_set_bgp_speaker(self):
142
- arglist = [
143
- self._bgp_speaker_name,
144
- '--name', 'noob',
145
- ]
146
- verifylist = [
147
- ('bgp_speaker', self._bgp_speaker_name),
148
- ('name', 'noob'),
149
- ]
150
-
151
- parsed_args = self.check_parser(self.cmd, arglist, verifylist)
152
- result = self.cmd.take_action(parsed_args)
153
-
154
- attrs = {'name': 'noob'}
155
- self.networkclient.update_bgp_speaker.assert_called_once_with(
156
- self._bgp_speaker_name, **attrs)
157
- self.assertIsNone(result)
@@ -1 +0,0 @@
1
- {"git_version": "9d338dc", "is_release": true}