python-openstackclient 7.4.0__py3-none-any.whl → 8.1.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.
Files changed (264) hide show
  1. openstackclient/common/availability_zone.py +3 -6
  2. openstackclient/common/clientmanager.py +2 -1
  3. openstackclient/common/envvars.py +57 -0
  4. openstackclient/common/extension.py +3 -11
  5. openstackclient/common/limits.py +1 -1
  6. openstackclient/common/project_cleanup.py +3 -2
  7. openstackclient/common/quota.py +54 -28
  8. openstackclient/compute/client.py +7 -5
  9. openstackclient/compute/v2/agent.py +5 -5
  10. openstackclient/compute/v2/aggregate.py +17 -15
  11. openstackclient/compute/v2/console.py +10 -4
  12. openstackclient/compute/v2/console_connection.py +48 -0
  13. openstackclient/compute/v2/flavor.py +14 -18
  14. openstackclient/compute/v2/host.py +3 -3
  15. openstackclient/compute/v2/hypervisor.py +10 -4
  16. openstackclient/compute/v2/hypervisor_stats.py +1 -1
  17. openstackclient/compute/v2/keypair.py +18 -13
  18. openstackclient/compute/v2/server.py +144 -121
  19. openstackclient/compute/v2/server_backup.py +1 -1
  20. openstackclient/compute/v2/server_event.py +8 -17
  21. openstackclient/compute/v2/server_group.py +6 -6
  22. openstackclient/compute/v2/server_image.py +1 -1
  23. openstackclient/compute/v2/server_migration.py +6 -6
  24. openstackclient/compute/v2/server_volume.py +4 -4
  25. openstackclient/compute/v2/service.py +9 -13
  26. openstackclient/compute/v2/usage.py +4 -6
  27. openstackclient/identity/client.py +2 -4
  28. openstackclient/identity/common.py +95 -17
  29. openstackclient/identity/v2_0/ec2creds.py +4 -3
  30. openstackclient/identity/v2_0/endpoint.py +12 -10
  31. openstackclient/identity/v2_0/project.py +6 -6
  32. openstackclient/identity/v2_0/role.py +1 -1
  33. openstackclient/identity/v2_0/service.py +7 -7
  34. openstackclient/identity/v2_0/user.py +6 -21
  35. openstackclient/identity/v3/access_rule.py +2 -5
  36. openstackclient/identity/v3/application_credential.py +2 -2
  37. openstackclient/identity/v3/consumer.py +4 -3
  38. openstackclient/identity/v3/credential.py +6 -7
  39. openstackclient/identity/v3/domain.py +63 -44
  40. openstackclient/identity/v3/ec2creds.py +4 -3
  41. openstackclient/identity/v3/endpoint.py +104 -88
  42. openstackclient/identity/v3/endpoint_group.py +1 -1
  43. openstackclient/identity/v3/group.py +116 -72
  44. openstackclient/identity/v3/identity_provider.py +1 -2
  45. openstackclient/identity/v3/limit.py +4 -9
  46. openstackclient/identity/v3/mapping.py +4 -3
  47. openstackclient/identity/v3/policy.py +5 -8
  48. openstackclient/identity/v3/project.py +23 -6
  49. openstackclient/identity/v3/region.py +2 -5
  50. openstackclient/identity/v3/registered_limit.py +4 -8
  51. openstackclient/identity/v3/role.py +15 -16
  52. openstackclient/identity/v3/service.py +8 -8
  53. openstackclient/identity/v3/service_provider.py +3 -6
  54. openstackclient/identity/v3/tag.py +2 -2
  55. openstackclient/identity/v3/token.py +1 -2
  56. openstackclient/identity/v3/trust.py +74 -25
  57. openstackclient/identity/v3/user.py +47 -11
  58. openstackclient/image/client.py +7 -5
  59. openstackclient/image/v1/image.py +11 -15
  60. openstackclient/image/v2/cache.py +2 -4
  61. openstackclient/image/v2/image.py +41 -48
  62. openstackclient/image/v2/metadef_namespaces.py +4 -3
  63. openstackclient/image/v2/metadef_resource_type_association.py +1 -2
  64. openstackclient/image/v2/metadef_resource_types.py +1 -2
  65. openstackclient/locale/tr_TR/LC_MESSAGES/openstackclient.po +9 -1370
  66. openstackclient/network/client.py +4 -16
  67. openstackclient/network/common.py +16 -12
  68. openstackclient/network/utils.py +3 -3
  69. openstackclient/network/v2/address_group.py +5 -9
  70. openstackclient/network/v2/address_scope.py +2 -3
  71. openstackclient/network/v2/default_security_group_rule.py +1 -2
  72. openstackclient/network/v2/floating_ip.py +69 -47
  73. openstackclient/network/v2/floating_ip_port_forwarding.py +7 -7
  74. openstackclient/network/v2/ip_availability.py +1 -2
  75. openstackclient/network/v2/l3_conntrack_helper.py +8 -12
  76. openstackclient/network/v2/local_ip.py +24 -26
  77. openstackclient/network/v2/local_ip_association.py +4 -5
  78. openstackclient/network/v2/ndp_proxy.py +9 -10
  79. openstackclient/network/v2/network.py +12 -16
  80. openstackclient/network/v2/network_agent.py +29 -37
  81. openstackclient/network/v2/network_auto_allocated_topology.py +4 -5
  82. openstackclient/network/v2/network_flavor.py +1 -1
  83. openstackclient/network/v2/network_flavor_profile.py +5 -5
  84. openstackclient/network/v2/network_meter.py +3 -3
  85. openstackclient/network/v2/network_meter_rule.py +5 -8
  86. openstackclient/network/v2/network_qos_policy.py +4 -4
  87. openstackclient/network/v2/network_qos_rule.py +7 -16
  88. openstackclient/network/v2/network_rbac.py +4 -4
  89. openstackclient/network/v2/network_segment.py +6 -7
  90. openstackclient/network/v2/network_segment_range.py +16 -20
  91. openstackclient/network/v2/network_trunk.py +24 -16
  92. openstackclient/network/v2/port.py +28 -29
  93. openstackclient/network/v2/router.py +53 -42
  94. openstackclient/network/v2/security_group.py +13 -19
  95. openstackclient/network/v2/security_group_rule.py +10 -11
  96. openstackclient/network/v2/subnet.py +31 -30
  97. openstackclient/network/v2/subnet_pool.py +4 -4
  98. openstackclient/object/client.py +2 -3
  99. openstackclient/object/v1/container.py +2 -3
  100. openstackclient/object/v1/object.py +2 -9
  101. openstackclient/shell.py +22 -5
  102. openstackclient/tests/functional/base.py +7 -3
  103. openstackclient/tests/functional/common/test_quota.py +3 -1
  104. openstackclient/tests/functional/compute/v2/common.py +12 -6
  105. openstackclient/tests/functional/compute/v2/test_keypair.py +41 -5
  106. openstackclient/tests/functional/compute/v2/test_server.py +2 -3
  107. openstackclient/tests/functional/compute/v2/test_server_event.py +1 -1
  108. openstackclient/tests/functional/identity/v2/test_user.py +1 -1
  109. openstackclient/tests/functional/identity/v3/common.py +3 -8
  110. openstackclient/tests/functional/identity/v3/test_application_credential.py +10 -10
  111. openstackclient/tests/functional/identity/v3/test_endpoint.py +3 -3
  112. openstackclient/tests/functional/identity/v3/test_group.py +3 -3
  113. openstackclient/tests/functional/identity/v3/test_idp.py +3 -7
  114. openstackclient/tests/functional/identity/v3/test_limit.py +4 -4
  115. openstackclient/tests/functional/identity/v3/test_project.py +5 -14
  116. openstackclient/tests/functional/identity/v3/test_region.py +1 -3
  117. openstackclient/tests/functional/identity/v3/test_registered_limit.py +3 -3
  118. openstackclient/tests/functional/identity/v3/test_role.py +1 -1
  119. openstackclient/tests/functional/identity/v3/test_role_assignment.py +13 -31
  120. openstackclient/tests/functional/identity/v3/test_service_provider.py +3 -7
  121. openstackclient/tests/functional/identity/v3/test_user.py +8 -8
  122. openstackclient/tests/functional/network/v2/common.py +7 -3
  123. openstackclient/tests/functional/network/v2/test_address_group.py +4 -0
  124. openstackclient/tests/functional/network/v2/test_l3_conntrack_helper.py +15 -11
  125. openstackclient/tests/functional/network/v2/test_local_ip.py +4 -0
  126. openstackclient/tests/functional/network/v2/test_network_meter_rule.py +2 -2
  127. openstackclient/tests/functional/network/v2/test_network_ndp_proxy.py +2 -3
  128. openstackclient/tests/functional/network/v2/test_network_rbac.py +2 -2
  129. openstackclient/tests/functional/network/v2/test_network_trunk.py +1 -1
  130. openstackclient/tests/functional/network/v2/test_port.py +17 -7
  131. openstackclient/tests/functional/network/v2/test_router.py +42 -0
  132. openstackclient/tests/functional/network/v2/test_subnet_pool.py +4 -0
  133. openstackclient/tests/unit/api/test_compute_v2.py +67 -87
  134. openstackclient/tests/unit/common/test_availability_zone.py +6 -14
  135. openstackclient/tests/unit/common/test_command.py +1 -1
  136. openstackclient/tests/unit/common/test_extension.py +5 -7
  137. openstackclient/tests/unit/common/test_limits.py +1 -1
  138. openstackclient/tests/unit/common/test_project_cleanup.py +5 -6
  139. openstackclient/tests/unit/common/test_quota.py +51 -28
  140. openstackclient/tests/unit/compute/v2/fakes.py +85 -315
  141. openstackclient/tests/unit/compute/v2/test_agent.py +16 -16
  142. openstackclient/tests/unit/compute/v2/test_aggregate.py +56 -60
  143. openstackclient/tests/unit/compute/v2/test_console.py +34 -17
  144. openstackclient/tests/unit/compute/v2/test_console_connection.py +72 -0
  145. openstackclient/tests/unit/compute/v2/test_flavor.py +72 -72
  146. openstackclient/tests/unit/compute/v2/test_host.py +8 -8
  147. openstackclient/tests/unit/compute/v2/test_hypervisor.py +22 -30
  148. openstackclient/tests/unit/compute/v2/test_hypervisor_stats.py +2 -2
  149. openstackclient/tests/unit/compute/v2/test_keypair.py +36 -29
  150. openstackclient/tests/unit/compute/v2/test_server.py +693 -606
  151. openstackclient/tests/unit/compute/v2/test_server_backup.py +36 -77
  152. openstackclient/tests/unit/compute/v2/test_server_event.py +18 -20
  153. openstackclient/tests/unit/compute/v2/test_server_group.py +25 -31
  154. openstackclient/tests/unit/compute/v2/test_server_image.py +37 -78
  155. openstackclient/tests/unit/compute/v2/test_server_migration.py +41 -41
  156. openstackclient/tests/unit/compute/v2/test_server_volume.py +12 -12
  157. openstackclient/tests/unit/compute/v2/test_service.py +39 -45
  158. openstackclient/tests/unit/compute/v2/test_usage.py +5 -5
  159. openstackclient/tests/unit/identity/v2_0/fakes.py +1 -1
  160. openstackclient/tests/unit/identity/v3/test_access_rule.py +1 -3
  161. openstackclient/tests/unit/identity/v3/test_application_credential.py +48 -26
  162. openstackclient/tests/unit/identity/v3/test_domain.py +115 -105
  163. openstackclient/tests/unit/identity/v3/test_endpoint.py +167 -172
  164. openstackclient/tests/unit/identity/v3/test_group.py +353 -202
  165. openstackclient/tests/unit/identity/v3/test_mappings.py +2 -2
  166. openstackclient/tests/unit/identity/v3/test_project.py +16 -0
  167. openstackclient/tests/unit/identity/v3/test_trust.py +5 -2
  168. openstackclient/tests/unit/identity/v3/test_user.py +102 -6
  169. openstackclient/tests/unit/image/v1/fakes.py +2 -2
  170. openstackclient/tests/unit/image/v1/test_image.py +8 -9
  171. openstackclient/tests/unit/image/v2/test_image.py +84 -46
  172. openstackclient/tests/unit/integ/cli/test_shell.py +1 -2
  173. openstackclient/tests/unit/network/test_common.py +2 -2
  174. openstackclient/tests/unit/network/v2/fakes.py +405 -485
  175. openstackclient/tests/unit/network/v2/test_floating_ip_compute.py +8 -14
  176. openstackclient/tests/unit/network/v2/test_floating_ip_network.py +62 -54
  177. openstackclient/tests/unit/network/v2/test_floating_ip_pool_compute.py +1 -1
  178. openstackclient/tests/unit/network/v2/test_l3_conntrack_helper.py +2 -2
  179. openstackclient/tests/unit/network/v2/test_ndp_proxy.py +1 -3
  180. openstackclient/tests/unit/network/v2/test_network.py +4 -4
  181. openstackclient/tests/unit/network/v2/test_network_agent.py +15 -29
  182. openstackclient/tests/unit/network/v2/test_network_compute.py +11 -11
  183. openstackclient/tests/unit/network/v2/test_network_qos_policy.py +16 -19
  184. openstackclient/tests/unit/network/v2/test_network_qos_rule.py +79 -152
  185. openstackclient/tests/unit/network/v2/test_network_qos_rule_type.py +4 -6
  186. openstackclient/tests/unit/network/v2/test_network_rbac.py +2 -2
  187. openstackclient/tests/unit/network/v2/test_network_trunk.py +2 -2
  188. openstackclient/tests/unit/network/v2/test_port.py +21 -22
  189. openstackclient/tests/unit/network/v2/test_router.py +130 -51
  190. openstackclient/tests/unit/network/v2/test_security_group_compute.py +11 -19
  191. openstackclient/tests/unit/network/v2/test_security_group_network.py +25 -27
  192. openstackclient/tests/unit/network/v2/test_security_group_rule_compute.py +15 -17
  193. openstackclient/tests/unit/network/v2/test_security_group_rule_network.py +33 -39
  194. openstackclient/tests/unit/object/v1/test_object_all.py +4 -3
  195. openstackclient/tests/unit/test_shell.py +16 -13
  196. openstackclient/tests/unit/volume/v2/fakes.py +1 -2
  197. openstackclient/tests/unit/volume/v2/test_service.py +57 -91
  198. openstackclient/tests/unit/volume/v2/test_volume.py +109 -106
  199. openstackclient/tests/unit/volume/v2/test_volume_backup.py +141 -148
  200. openstackclient/tests/unit/volume/v2/test_volume_snapshot.py +293 -283
  201. openstackclient/tests/unit/volume/v2/test_volume_transfer_request.py +1 -1
  202. openstackclient/tests/unit/volume/v3/fakes.py +2 -8
  203. openstackclient/tests/unit/volume/v3/test_block_storage_log_level.py +61 -71
  204. openstackclient/tests/unit/volume/v3/test_service.py +221 -141
  205. openstackclient/tests/unit/volume/v3/test_volume.py +131 -120
  206. openstackclient/tests/unit/volume/v3/test_volume_attachment.py +4 -4
  207. openstackclient/tests/unit/volume/v3/test_volume_backup.py +198 -203
  208. openstackclient/tests/unit/volume/v3/test_volume_snapshot.py +683 -49
  209. openstackclient/tests/unit/volume/v3/test_volume_transfer_request.py +1 -1
  210. openstackclient/volume/client.py +1 -3
  211. openstackclient/volume/v2/consistency_group.py +4 -8
  212. openstackclient/volume/v2/consistency_group_snapshot.py +1 -2
  213. openstackclient/volume/v2/qos_specs.py +1 -2
  214. openstackclient/volume/v2/service.py +41 -38
  215. openstackclient/volume/v2/volume.py +71 -53
  216. openstackclient/volume/v2/volume_backup.py +15 -10
  217. openstackclient/volume/v2/volume_snapshot.py +129 -93
  218. openstackclient/volume/v2/volume_transfer_request.py +0 -3
  219. openstackclient/volume/v2/volume_type.py +10 -21
  220. openstackclient/volume/v3/block_storage_cluster.py +3 -3
  221. openstackclient/volume/v3/block_storage_log_level.py +22 -28
  222. openstackclient/volume/v3/block_storage_manage.py +1 -3
  223. openstackclient/volume/v3/service.py +105 -14
  224. openstackclient/volume/v3/volume.py +218 -58
  225. openstackclient/volume/v3/volume_attachment.py +3 -2
  226. openstackclient/volume/v3/volume_backup.py +31 -27
  227. openstackclient/volume/v3/volume_group.py +2 -1
  228. openstackclient/volume/v3/volume_group_snapshot.py +2 -1
  229. openstackclient/volume/v3/volume_snapshot.py +489 -13
  230. openstackclient/volume/v3/volume_type.py +10 -21
  231. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.1.0.dist-info}/AUTHORS +11 -0
  232. python_openstackclient-8.1.0.dist-info/METADATA +264 -0
  233. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.1.0.dist-info}/RECORD +238 -259
  234. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.1.0.dist-info}/WHEEL +1 -1
  235. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.1.0.dist-info}/entry_points.txt +7 -47
  236. python_openstackclient-8.1.0.dist-info/pbr.json +1 -0
  237. openstackclient/tests/functional/volume/v1/__init__.py +0 -0
  238. openstackclient/tests/functional/volume/v1/common.py +0 -35
  239. openstackclient/tests/functional/volume/v1/test_qos.py +0 -100
  240. openstackclient/tests/functional/volume/v1/test_service.py +0 -76
  241. openstackclient/tests/functional/volume/v1/test_snapshot.py +0 -232
  242. openstackclient/tests/functional/volume/v1/test_transfer_request.py +0 -111
  243. openstackclient/tests/functional/volume/v1/test_volume.py +0 -228
  244. openstackclient/tests/functional/volume/v1/test_volume_type.py +0 -213
  245. openstackclient/tests/unit/volume/v1/__init__.py +0 -0
  246. openstackclient/tests/unit/volume/v1/fakes.py +0 -615
  247. openstackclient/tests/unit/volume/v1/test_qos_specs.py +0 -471
  248. openstackclient/tests/unit/volume/v1/test_service.py +0 -295
  249. openstackclient/tests/unit/volume/v1/test_transfer_request.py +0 -380
  250. openstackclient/tests/unit/volume/v1/test_type.py +0 -633
  251. openstackclient/tests/unit/volume/v1/test_volume.py +0 -1447
  252. openstackclient/tests/unit/volume/v1/test_volume_backup.py +0 -435
  253. openstackclient/volume/v1/__init__.py +0 -0
  254. openstackclient/volume/v1/qos_specs.py +0 -377
  255. openstackclient/volume/v1/service.py +0 -136
  256. openstackclient/volume/v1/volume.py +0 -734
  257. openstackclient/volume/v1/volume_backup.py +0 -302
  258. openstackclient/volume/v1/volume_snapshot.py +0 -433
  259. openstackclient/volume/v1/volume_transfer_request.py +0 -200
  260. openstackclient/volume/v1/volume_type.py +0 -520
  261. python_openstackclient-7.4.0.dist-info/METADATA +0 -172
  262. python_openstackclient-7.4.0.dist-info/pbr.json +0 -1
  263. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.1.0.dist-info}/LICENSE +0 -0
  264. {python_openstackclient-7.4.0.dist-info → python_openstackclient-8.1.0.dist-info}/top_level.txt +0 -0
@@ -9,7 +9,6 @@
9
9
  # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
10
  # License for the specific language governing permissions and limitations
11
11
  # under the License.
12
- #
13
12
 
14
13
  import logging
15
14
 
@@ -17,26 +16,17 @@ from osc_lib import utils
17
16
 
18
17
  from openstackclient.i18n import _
19
18
 
20
-
21
19
  LOG = logging.getLogger(__name__)
22
20
 
21
+ # global variables used when building the shell
23
22
  DEFAULT_API_VERSION = '2.0'
24
23
  API_VERSION_OPTION = 'os_network_api_version'
25
- API_NAME = "network"
26
- API_VERSIONS = {
27
- "2.0": "openstack.connection.Connection",
28
- "2": "openstack.connection.Connection",
29
- }
24
+ API_NAME = 'network'
25
+ API_VERSIONS = ('2.0', '2')
30
26
 
31
27
 
32
28
  def make_client(instance):
33
29
  """Returns a network proxy"""
34
- # NOTE(dtroyer): As of osc-lib 1.8.0 and OpenStackSDK 0.10.0 the
35
- # old Profile interface and separate client creation
36
- # for each API that uses the SDK is unnecessary. This
37
- # callback remains as a remnant of the original plugin
38
- # interface and to avoid the code churn of changing all
39
- # of the existing references.
40
30
  LOG.debug(
41
31
  'Network client initialized using OpenStack SDK: %s',
42
32
  instance.sdk_connection.network,
@@ -50,9 +40,7 @@ def build_option_parser(parser):
50
40
  '--os-network-api-version',
51
41
  metavar='<network-api-version>',
52
42
  default=utils.env('OS_NETWORK_API_VERSION'),
53
- help=_(
54
- "Network API version, default=%s " "(Env: OS_NETWORK_API_VERSION)"
55
- )
43
+ help=_("Network API version, default=%s (Env: OS_NETWORK_API_VERSION)")
56
44
  % DEFAULT_API_VERSION,
57
45
  )
58
46
  return parser
@@ -12,9 +12,12 @@
12
12
  #
13
13
 
14
14
  import abc
15
+ import argparse
15
16
  import contextlib
16
17
  import logging
18
+ import typing as ty
17
19
 
20
+ import cliff.app
18
21
  import openstack.exceptions
19
22
  from osc_lib.cli import parseractions
20
23
  from osc_lib.command import command
@@ -65,6 +68,8 @@ class NetDetectionMixin(metaclass=abc.ABCMeta):
65
68
  present the options for both network types, often qualified accordingly.
66
69
  """
67
70
 
71
+ app: cliff.app.App
72
+
68
73
  @property
69
74
  def _network_type(self):
70
75
  """Discover whether the running cloud is using neutron or nova-network.
@@ -131,9 +136,9 @@ class NetDetectionMixin(metaclass=abc.ABCMeta):
131
136
  )
132
137
  )
133
138
 
134
- def get_parser(self, prog_name):
139
+ def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
135
140
  LOG.debug('get_parser(%s)', prog_name)
136
- parser = super().get_parser(prog_name)
141
+ parser = super().get_parser(prog_name) # type: ignore
137
142
  parser = self.update_parser_common(parser)
138
143
  LOG.debug('common parser: %s', parser)
139
144
  if self.is_neutron or self.is_docs_build:
@@ -162,7 +167,7 @@ class NetDetectionMixin(metaclass=abc.ABCMeta):
162
167
  )
163
168
  elif self.is_nova_network:
164
169
  return self.take_action_compute(
165
- self.app.client_manager.sdk_connection.compute, parsed_args
170
+ self.app.client_manager.compute, parsed_args
166
171
  )
167
172
 
168
173
  def take_action_network(self, client, parsed_args):
@@ -211,7 +216,7 @@ class NetworkAndComputeDelete(NetworkAndComputeCommand, metaclass=abc.ABCMeta):
211
216
  )
212
217
  else:
213
218
  self.take_action_compute(
214
- self.app.client_manager.sdk_connection.compute,
219
+ self.app.client_manager.compute,
215
220
  parsed_args,
216
221
  )
217
222
  except Exception as e:
@@ -269,7 +274,7 @@ class NetworkAndComputeShowOne(
269
274
  )
270
275
  else:
271
276
  return self.take_action_compute(
272
- self.app.client_manager.sdk_connection.compute, parsed_args
277
+ self.app.client_manager.compute, parsed_args
273
278
  )
274
279
  except openstack.exceptions.HttpException as exc:
275
280
  msg = _("Error while executing command: %s") % exc.message
@@ -295,16 +300,15 @@ class NeutronCommandWithExtraArgs(command.Command):
295
300
  }
296
301
 
297
302
  def _get_property_converter(self, _property):
298
- if 'type' not in _property:
299
- converter = str
300
- else:
303
+ if 'type' in _property:
301
304
  converter = self._allowed_types_dict.get(_property['type'])
305
+ else:
306
+ converter = str
302
307
 
303
308
  if not converter:
304
309
  raise exceptions.CommandError(
305
310
  _(
306
- "Type {property_type} of property {name} "
307
- "is not supported"
311
+ "Type {property_type} of property {name} is not supported"
308
312
  ).format(
309
313
  property_type=_property['type'], name=_property['name']
310
314
  )
@@ -312,7 +316,7 @@ class NeutronCommandWithExtraArgs(command.Command):
312
316
  return converter
313
317
 
314
318
  def _parse_extra_properties(self, extra_properties):
315
- result = {}
319
+ result: dict[str, ty.Any] = {}
316
320
  if extra_properties:
317
321
  for _property in extra_properties:
318
322
  converter = self._get_property_converter(_property)
@@ -345,7 +349,7 @@ class NeutronCommandWithExtraArgs(command.Command):
345
349
 
346
350
  class NeutronUnsetCommandWithExtraArgs(NeutronCommandWithExtraArgs):
347
351
  def _parse_extra_properties(self, extra_properties):
348
- result = {}
352
+ result: dict[str, ty.Any] = {}
349
353
  if extra_properties:
350
354
  for _property in extra_properties:
351
355
  result[_property['name']] = None
@@ -23,7 +23,7 @@ def transform_compute_security_group_rule(sg_rule):
23
23
  from_port = info.pop('from_port')
24
24
  to_port = info.pop('to_port')
25
25
  if isinstance(from_port, int) and isinstance(to_port, int):
26
- port_range = {'port_range': "%u:%u" % (from_port, to_port)}
26
+ port_range = {'port_range': f"{from_port}:{to_port}"}
27
27
  elif from_port is None and to_port is None:
28
28
  port_range = {'port_range': ""}
29
29
  else:
@@ -58,12 +58,12 @@ def str2list(strlist):
58
58
  return result
59
59
 
60
60
 
61
- def str2dict(strdict):
61
+ def str2dict(strdict: str) -> dict[str, str]:
62
62
  """Convert key1:value1;key2:value2;... string into dictionary.
63
63
 
64
64
  :param strdict: string in the form of key1:value1;key2:value2
65
65
  """
66
- result = {}
66
+ result: dict[str, str] = {}
67
67
  if not strdict:
68
68
  return result
69
69
  i = 0
@@ -28,10 +28,9 @@ LOG = logging.getLogger(__name__)
28
28
 
29
29
 
30
30
  def _get_columns(item):
31
- column_map = {}
32
31
  hidden_columns = ['location', 'tenant_id']
33
32
  return utils.get_osc_show_columns_for_sdk_resource(
34
- item, column_map, hidden_columns
33
+ item, {}, hidden_columns
35
34
  )
36
35
 
37
36
 
@@ -76,8 +75,7 @@ class CreateAddressGroup(command.ShowOne, common.NeutronCommandWithExtraArgs):
76
75
  action='append',
77
76
  default=[],
78
77
  help=_(
79
- "IP address or CIDR "
80
- "(repeat option to set multiple addresses)"
78
+ "IP address or CIDR (repeat option to set multiple addresses)"
81
79
  ),
82
80
  )
83
81
  parser.add_argument(
@@ -139,7 +137,7 @@ class DeleteAddressGroup(command.Command):
139
137
  if result > 0:
140
138
  total = len(parsed_args.address_group)
141
139
  msg = _(
142
- "%(result)s of %(total)s address groups failed " "to delete."
140
+ "%(result)s of %(total)s address groups failed to delete."
143
141
  ) % {'result': result, 'total': total}
144
142
  raise exceptions.CommandError(msg)
145
143
 
@@ -159,8 +157,7 @@ class ListAddressGroup(command.Lister):
159
157
  '--project',
160
158
  metavar="<project>",
161
159
  help=_(
162
- "List address groups according to their project "
163
- "(name or ID)"
160
+ "List address groups according to their project (name or ID)"
164
161
  ),
165
162
  )
166
163
  identity_common.add_project_domain_option_to_parser(parser)
@@ -233,8 +230,7 @@ class SetAddressGroup(common.NeutronCommandWithExtraArgs):
233
230
  action='append',
234
231
  default=[],
235
232
  help=_(
236
- "IP address or CIDR "
237
- "(repeat option to set multiple addresses)"
233
+ "IP address or CIDR (repeat option to set multiple addresses)"
238
234
  ),
239
235
  )
240
236
  return parser
@@ -144,7 +144,7 @@ class DeleteAddressScope(command.Command):
144
144
  if result > 0:
145
145
  total = len(parsed_args.address_scope)
146
146
  msg = _(
147
- "%(result)s of %(total)s address scopes failed " "to delete."
147
+ "%(result)s of %(total)s address scopes failed to delete."
148
148
  ) % {'result': result, 'total': total}
149
149
  raise exceptions.CommandError(msg)
150
150
 
@@ -176,8 +176,7 @@ class ListAddressScope(command.Lister):
176
176
  '--project',
177
177
  metavar="<project>",
178
178
  help=_(
179
- "List address scopes according to their project "
180
- "(name or ID)"
179
+ "List address scopes according to their project (name or ID)"
181
180
  ),
182
181
  )
183
182
  identity_common.add_project_domain_option_to_parser(parser)
@@ -28,10 +28,9 @@ LOG = logging.getLogger(__name__)
28
28
 
29
29
 
30
30
  def _get_columns(item):
31
- column_map = {}
32
31
  hidden_columns = ['location', 'name', 'revision_number']
33
32
  return utils.get_osc_show_columns_for_sdk_resource(
34
- item, column_map, hidden_columns
33
+ item, {}, hidden_columns
35
34
  )
36
35
 
37
36
 
@@ -13,6 +13,7 @@
13
13
  """IP Floating action implementations"""
14
14
 
15
15
  from openstack import exceptions as sdk_exceptions
16
+ from osc_lib.cli import format_columns
16
17
  from osc_lib import utils
17
18
  from osc_lib.utils import tags as _tag
18
19
 
@@ -22,15 +23,14 @@ from openstackclient.identity import common as identity_common
22
23
  from openstackclient.network import common
23
24
 
24
25
  _formatters = {
25
- 'port_details': utils.format_dict,
26
+ 'port_details': format_columns.DictColumn,
26
27
  }
27
28
 
28
29
 
29
30
  def _get_network_columns(item):
30
- column_map = {}
31
31
  hidden_columns = ['location', 'tenant_id']
32
32
  return utils.get_osc_show_columns_for_sdk_resource(
33
- item, column_map, hidden_columns
33
+ item, {}, hidden_columns
34
34
  )
35
35
 
36
36
 
@@ -123,7 +123,7 @@ class CreateFloatingIP(
123
123
  '--port',
124
124
  metavar='<port>',
125
125
  help=self.enhance_help_neutron(
126
- _("Port to be associated with the floating IP " "(name or ID)")
126
+ _("Port to be associated with the floating IP (name or ID)")
127
127
  ),
128
128
  )
129
129
  parser.add_argument(
@@ -243,18 +243,26 @@ class ListFloatingIP(common.NetworkAndComputeLister):
243
243
  parser.add_argument(
244
244
  '--network',
245
245
  metavar='<network>',
246
+ dest='networks',
247
+ action='append',
246
248
  help=self.enhance_help_neutron(
247
249
  _(
248
- "List floating IP(s) according to "
249
- "given network (name or ID)"
250
+ "List floating IP(s) according to given network "
251
+ "(name or ID) "
252
+ "(repeat option to fiter on multiple networks)"
250
253
  )
251
254
  ),
252
255
  )
253
256
  parser.add_argument(
254
257
  '--port',
255
258
  metavar='<port>',
259
+ dest='ports',
260
+ action='append',
256
261
  help=self.enhance_help_neutron(
257
- _("List floating IP(s) according to given port (name or ID)")
262
+ _(
263
+ "List floating IP(s) according to given port (name or ID) "
264
+ "(repeat option to fiter on multiple ports)"
265
+ )
258
266
  ),
259
267
  )
260
268
  parser.add_argument(
@@ -268,18 +276,7 @@ class ListFloatingIP(common.NetworkAndComputeLister):
268
276
  '--floating-ip-address',
269
277
  metavar='<ip-address>',
270
278
  help=self.enhance_help_neutron(
271
- _(
272
- "List floating IP(s) according to given floating IP "
273
- "address"
274
- )
275
- ),
276
- )
277
- parser.add_argument(
278
- '--long',
279
- action='store_true',
280
- default=False,
281
- help=self.enhance_help_neutron(
282
- _("List additional fields in output")
279
+ _("List floating IP(s) according to given floating IP address")
283
280
  ),
284
281
  )
285
282
  parser.add_argument(
@@ -298,8 +295,8 @@ class ListFloatingIP(common.NetworkAndComputeLister):
298
295
  metavar='<project>',
299
296
  help=self.enhance_help_neutron(
300
297
  _(
301
- "List floating IP(s) according to given project (name or "
302
- "ID)"
298
+ "List floating IP(s) according to given project "
299
+ "(name or ID) "
303
300
  )
304
301
  ),
305
302
  )
@@ -307,16 +304,27 @@ class ListFloatingIP(common.NetworkAndComputeLister):
307
304
  parser.add_argument(
308
305
  '--router',
309
306
  metavar='<router>',
307
+ dest='routers',
308
+ action='append',
310
309
  help=self.enhance_help_neutron(
311
310
  _(
312
- "List floating IP(s) according to given router (name or "
313
- "ID)"
311
+ "List floating IP(s) according to given router "
312
+ "(name or ID) "
313
+ "(repeat option to fiter on multiple routers)"
314
314
  )
315
315
  ),
316
316
  )
317
317
  _tag.add_tag_filtering_option_to_parser(
318
318
  parser, _('floating IP'), enhance_help=self.enhance_help_neutron
319
319
  )
320
+ parser.add_argument(
321
+ '--long',
322
+ action='store_true',
323
+ default=False,
324
+ help=self.enhance_help_neutron(
325
+ _("List additional fields in output")
326
+ ),
327
+ )
320
328
 
321
329
  return parser
322
330
 
@@ -324,7 +332,7 @@ class ListFloatingIP(common.NetworkAndComputeLister):
324
332
  network_client = self.app.client_manager.network
325
333
  identity_client = self.app.client_manager.identity
326
334
 
327
- columns = (
335
+ columns: tuple[str, ...] = (
328
336
  'id',
329
337
  'floating_ip_address',
330
338
  'fixed_ip_address',
@@ -332,7 +340,7 @@ class ListFloatingIP(common.NetworkAndComputeLister):
332
340
  'floating_network_id',
333
341
  'project_id',
334
342
  )
335
- headers = (
343
+ headers: tuple[str, ...] = (
336
344
  'ID',
337
345
  'Floating IP Address',
338
346
  'Fixed IP Address',
@@ -341,7 +349,7 @@ class ListFloatingIP(common.NetworkAndComputeLister):
341
349
  'Project',
342
350
  )
343
351
  if parsed_args.long:
344
- columns = columns + (
352
+ columns += (
345
353
  'router_id',
346
354
  'status',
347
355
  'description',
@@ -349,7 +357,7 @@ class ListFloatingIP(common.NetworkAndComputeLister):
349
357
  'dns_name',
350
358
  'dns_domain',
351
359
  )
352
- headers = headers + (
360
+ headers += (
353
361
  'Router',
354
362
  'Status',
355
363
  'Description',
@@ -360,22 +368,33 @@ class ListFloatingIP(common.NetworkAndComputeLister):
360
368
 
361
369
  query = {}
362
370
 
363
- if parsed_args.network is not None:
364
- network = network_client.find_network(
365
- parsed_args.network, ignore_missing=False
366
- )
367
- query['floating_network_id'] = network.id
368
- if parsed_args.port is not None:
369
- port = network_client.find_port(
370
- parsed_args.port, ignore_missing=False
371
- )
372
- query['port_id'] = port.id
371
+ if parsed_args.networks is not None:
372
+ network_ids = []
373
+ for network in parsed_args.networks:
374
+ network_id = network_client.find_network(
375
+ network, ignore_missing=False
376
+ ).id
377
+ network_ids.append(network_id)
378
+ query['floating_network_id'] = network_ids
379
+
380
+ if parsed_args.ports is not None:
381
+ port_ids = []
382
+ for port in parsed_args.ports:
383
+ port_id = network_client.find_port(
384
+ port, ignore_missing=False
385
+ ).id
386
+ port_ids.append(port_id)
387
+ query['port_id'] = port_ids
388
+
373
389
  if parsed_args.fixed_ip_address is not None:
374
390
  query['fixed_ip_address'] = parsed_args.fixed_ip_address
391
+
375
392
  if parsed_args.floating_ip_address is not None:
376
393
  query['floating_ip_address'] = parsed_args.floating_ip_address
394
+
377
395
  if parsed_args.status:
378
396
  query['status'] = parsed_args.status
397
+
379
398
  if parsed_args.project is not None:
380
399
  project = identity_common.find_project(
381
400
  identity_client,
@@ -383,11 +402,15 @@ class ListFloatingIP(common.NetworkAndComputeLister):
383
402
  parsed_args.project_domain,
384
403
  )
385
404
  query['project_id'] = project.id
386
- if parsed_args.router is not None:
387
- router = network_client.find_router(
388
- parsed_args.router, ignore_missing=False
389
- )
390
- query['router_id'] = router.id
405
+
406
+ if parsed_args.routers is not None:
407
+ router_ids = []
408
+ for router in parsed_args.routers:
409
+ router_id = network_client.find_router(
410
+ router, ignore_missing=False
411
+ ).id
412
+ router_ids.append(router_id)
413
+ query['router_id'] = router_ids
391
414
 
392
415
  _tag.get_tag_filtering_args(parsed_args, query)
393
416
 
@@ -409,14 +432,14 @@ class ListFloatingIP(common.NetworkAndComputeLister):
409
432
  )
410
433
 
411
434
  def take_action_compute(self, client, parsed_args):
412
- columns = (
435
+ columns: tuple[str, ...] = (
413
436
  'ID',
414
437
  'IP',
415
438
  'Fixed IP',
416
439
  'Instance ID',
417
440
  'Pool',
418
441
  )
419
- headers = (
442
+ headers: tuple[str, ...] = (
420
443
  'ID',
421
444
  'Floating IP Address',
422
445
  'Fixed IP Address',
@@ -458,8 +481,7 @@ class SetFloatingIP(common.NeutronCommandWithExtraArgs):
458
481
  metavar='<ip-address>',
459
482
  dest='fixed_ip_address',
460
483
  help=_(
461
- "Fixed IP of the port "
462
- "(required only if port has multiple IPs)"
484
+ "Fixed IP of the port (required only if port has multiple IPs)"
463
485
  ),
464
486
  )
465
487
  parser.add_argument(
@@ -578,7 +600,7 @@ class UnsetFloatingIP(common.NeutronCommandWithExtraArgs):
578
600
  parsed_args.floating_ip,
579
601
  ignore_missing=False,
580
602
  )
581
- attrs = {}
603
+ attrs: dict[str, None] = {}
582
604
  if parsed_args.port:
583
605
  attrs['port_id'] = None
584
606
  if parsed_args.qos_policy:
@@ -14,6 +14,7 @@
14
14
  """Floating IP Port Forwarding action implementations"""
15
15
 
16
16
  import logging
17
+ import typing as ty
17
18
 
18
19
  from osc_lib.command import command
19
20
  from osc_lib import exceptions
@@ -85,10 +86,9 @@ def validate_port(port):
85
86
 
86
87
 
87
88
  def _get_columns(item):
88
- column_map = {}
89
89
  hidden_columns = ['location', 'tenant_id']
90
90
  return utils.get_osc_show_columns_for_sdk_resource(
91
- item, column_map, hidden_columns
91
+ item, {}, hidden_columns
92
92
  )
93
93
 
94
94
 
@@ -149,7 +149,7 @@ class CreateFloatingIPPortForwarding(
149
149
  '--description',
150
150
  metavar='<description>',
151
151
  help=_(
152
- "A text to describe/contextualize the use of the "
152
+ "Text to describe/contextualize the use of the "
153
153
  "port forwarding configuration"
154
154
  ),
155
155
  )
@@ -165,7 +165,7 @@ class CreateFloatingIPPortForwarding(
165
165
  return parser
166
166
 
167
167
  def take_action(self, parsed_args):
168
- attrs = {}
168
+ attrs: dict[str, ty.Any] = {}
169
169
  client = self.app.client_manager.network
170
170
  floating_ip = client.find_ip(
171
171
  parsed_args.floating_ip,
@@ -243,7 +243,7 @@ class DeleteFloatingIPPortForwarding(command.Command):
243
243
  if result > 0:
244
244
  total = len(parsed_args.port_forwarding_id)
245
245
  msg = _(
246
- "%(result)s of %(total)s Port forwarding failed " "to delete."
246
+ "%(result)s of %(total)s Port forwarding failed to delete."
247
247
  ) % {'result': result, 'total': total}
248
248
  raise exceptions.CommandError(msg)
249
249
 
@@ -280,7 +280,7 @@ class ListFloatingIPPortForwarding(command.Lister):
280
280
  )
281
281
  parser.add_argument(
282
282
  '--protocol',
283
- metavar='protocol',
283
+ metavar='<protocol>',
284
284
  help=_("Filter the list result by the port protocol"),
285
285
  )
286
286
 
@@ -409,7 +409,7 @@ class SetFloatingIPPortForwarding(common.NeutronCommandWithExtraArgs):
409
409
  '--description',
410
410
  metavar='<description>',
411
411
  help=_(
412
- "A text to describe/contextualize the use of "
412
+ "Text to describe/contextualize the use of "
413
413
  "the port forwarding configuration"
414
414
  ),
415
415
  )
@@ -26,10 +26,9 @@ _formatters = {
26
26
 
27
27
 
28
28
  def _get_columns(item):
29
- column_map = {}
30
29
  hidden_columns = ['id', 'name', 'location', 'tenant_id']
31
30
  return utils.get_osc_show_columns_for_sdk_resource(
32
- item, column_map, hidden_columns
31
+ item, {}, hidden_columns
33
32
  )
34
33
 
35
34
 
@@ -25,10 +25,9 @@ LOG = logging.getLogger(__name__)
25
25
 
26
26
 
27
27
  def _get_columns(item):
28
- column_map = {}
29
28
  hidden_columns = ['location', 'tenant_id']
30
29
  return utils.get_osc_show_columns_for_sdk_resource(
31
- item, column_map, hidden_columns
30
+ item, {}, hidden_columns
32
31
  )
33
32
 
34
33
 
@@ -66,8 +65,7 @@ class CreateConntrackHelper(command.ShowOne):
66
65
  required=True,
67
66
  metavar='<protocol>',
68
67
  help=_(
69
- 'The network protocol for the netfilter conntrack target '
70
- 'rule'
68
+ 'The network protocol for the netfilter conntrack target rule'
71
69
  ),
72
70
  )
73
71
  parser.add_argument(
@@ -99,7 +97,7 @@ class DeleteConntrackHelper(command.Command):
99
97
  parser.add_argument(
100
98
  'router',
101
99
  metavar='<router>',
102
- help=_('Router that the conntrack helper belong to'),
100
+ help=_('Router that the conntrack helper belongs to'),
103
101
  )
104
102
  parser.add_argument(
105
103
  'conntrack_helper_id',
@@ -147,7 +145,7 @@ class ListConntrackHelper(command.Lister):
147
145
  parser.add_argument(
148
146
  'router',
149
147
  metavar='<router>',
150
- help=_('Router that the conntrack helper belong to'),
148
+ help=_('Router that the conntrack helper belongs to'),
151
149
  )
152
150
  parser.add_argument(
153
151
  '--helper',
@@ -158,8 +156,7 @@ class ListConntrackHelper(command.Lister):
158
156
  '--protocol',
159
157
  metavar='<protocol>',
160
158
  help=_(
161
- 'The network protocol for the netfilter conntrack target '
162
- 'rule'
159
+ 'The network protocol for the netfilter conntrack target rule'
163
160
  ),
164
161
  )
165
162
  parser.add_argument(
@@ -210,7 +207,7 @@ class SetConntrackHelper(command.Command):
210
207
  parser.add_argument(
211
208
  'router',
212
209
  metavar='<router>',
213
- help=_('Router that the conntrack helper belong to'),
210
+ help=_('Router that the conntrack helper belongs to'),
214
211
  )
215
212
  parser.add_argument(
216
213
  'conntrack_helper_id',
@@ -226,8 +223,7 @@ class SetConntrackHelper(command.Command):
226
223
  '--protocol',
227
224
  metavar='<protocol>',
228
225
  help=_(
229
- 'The network protocol for the netfilter conntrack target '
230
- 'rule'
226
+ 'The network protocol for the netfilter conntrack target rule'
231
227
  ),
232
228
  )
233
229
  parser.add_argument(
@@ -257,7 +253,7 @@ class ShowConntrackHelper(command.ShowOne):
257
253
  parser.add_argument(
258
254
  'router',
259
255
  metavar='<router>',
260
- help=_('Router that the conntrack helper belong to'),
256
+ help=_('Router that the conntrack helper belongs to'),
261
257
  )
262
258
  parser.add_argument(
263
259
  'conntrack_helper_id',