python-openstackclient 7.3.1__py3-none-any.whl → 8.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.
Files changed (235) 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 +2 -5
  9. openstackclient/compute/v2/agent.py +5 -5
  10. openstackclient/compute/v2/aggregate.py +17 -15
  11. openstackclient/compute/v2/console.py +3 -4
  12. openstackclient/compute/v2/flavor.py +14 -18
  13. openstackclient/compute/v2/host.py +3 -3
  14. openstackclient/compute/v2/hypervisor.py +10 -4
  15. openstackclient/compute/v2/hypervisor_stats.py +1 -1
  16. openstackclient/compute/v2/keypair.py +8 -10
  17. openstackclient/compute/v2/server.py +70 -112
  18. openstackclient/compute/v2/server_backup.py +1 -1
  19. openstackclient/compute/v2/server_event.py +7 -16
  20. openstackclient/compute/v2/server_group.py +6 -6
  21. openstackclient/compute/v2/server_image.py +1 -1
  22. openstackclient/compute/v2/server_migration.py +6 -6
  23. openstackclient/compute/v2/server_volume.py +4 -4
  24. openstackclient/compute/v2/service.py +9 -13
  25. openstackclient/compute/v2/usage.py +4 -6
  26. openstackclient/identity/client.py +2 -4
  27. openstackclient/identity/common.py +16 -17
  28. openstackclient/identity/v2_0/ec2creds.py +4 -3
  29. openstackclient/identity/v2_0/endpoint.py +12 -10
  30. openstackclient/identity/v2_0/project.py +6 -6
  31. openstackclient/identity/v2_0/role.py +1 -1
  32. openstackclient/identity/v2_0/service.py +7 -7
  33. openstackclient/identity/v2_0/user.py +6 -21
  34. openstackclient/identity/v3/access_rule.py +2 -5
  35. openstackclient/identity/v3/consumer.py +4 -3
  36. openstackclient/identity/v3/credential.py +8 -9
  37. openstackclient/identity/v3/domain.py +1 -1
  38. openstackclient/identity/v3/ec2creds.py +4 -3
  39. openstackclient/identity/v3/endpoint.py +104 -88
  40. openstackclient/identity/v3/endpoint_group.py +1 -1
  41. openstackclient/identity/v3/group.py +3 -4
  42. openstackclient/identity/v3/identity_provider.py +1 -2
  43. openstackclient/identity/v3/limit.py +4 -9
  44. openstackclient/identity/v3/mapping.py +4 -3
  45. openstackclient/identity/v3/policy.py +5 -8
  46. openstackclient/identity/v3/project.py +6 -6
  47. openstackclient/identity/v3/region.py +2 -5
  48. openstackclient/identity/v3/registered_limit.py +4 -8
  49. openstackclient/identity/v3/role.py +15 -16
  50. openstackclient/identity/v3/service.py +8 -8
  51. openstackclient/identity/v3/service_provider.py +3 -6
  52. openstackclient/identity/v3/tag.py +2 -2
  53. openstackclient/identity/v3/token.py +1 -2
  54. openstackclient/identity/v3/trust.py +74 -25
  55. openstackclient/identity/v3/user.py +9 -6
  56. openstackclient/image/client.py +2 -5
  57. openstackclient/image/v1/image.py +11 -15
  58. openstackclient/image/v2/cache.py +2 -4
  59. openstackclient/image/v2/image.py +30 -37
  60. openstackclient/image/v2/metadef_namespaces.py +4 -3
  61. openstackclient/image/v2/metadef_resource_type_association.py +1 -2
  62. openstackclient/image/v2/metadef_resource_types.py +1 -2
  63. openstackclient/locale/tr_TR/LC_MESSAGES/openstackclient.po +9 -1370
  64. openstackclient/network/client.py +4 -10
  65. openstackclient/network/common.py +16 -12
  66. openstackclient/network/utils.py +3 -3
  67. openstackclient/network/v2/address_group.py +5 -9
  68. openstackclient/network/v2/address_scope.py +2 -3
  69. openstackclient/network/v2/default_security_group_rule.py +1 -2
  70. openstackclient/network/v2/floating_ip.py +14 -21
  71. openstackclient/network/v2/floating_ip_port_forwarding.py +7 -7
  72. openstackclient/network/v2/ip_availability.py +1 -2
  73. openstackclient/network/v2/l3_conntrack_helper.py +8 -12
  74. openstackclient/network/v2/local_ip.py +24 -26
  75. openstackclient/network/v2/local_ip_association.py +4 -5
  76. openstackclient/network/v2/ndp_proxy.py +9 -10
  77. openstackclient/network/v2/network.py +12 -16
  78. openstackclient/network/v2/network_agent.py +29 -37
  79. openstackclient/network/v2/network_auto_allocated_topology.py +4 -5
  80. openstackclient/network/v2/network_flavor.py +1 -1
  81. openstackclient/network/v2/network_flavor_profile.py +5 -5
  82. openstackclient/network/v2/network_meter.py +3 -3
  83. openstackclient/network/v2/network_meter_rule.py +5 -8
  84. openstackclient/network/v2/network_qos_policy.py +4 -4
  85. openstackclient/network/v2/network_qos_rule.py +4 -5
  86. openstackclient/network/v2/network_rbac.py +4 -4
  87. openstackclient/network/v2/network_segment.py +6 -7
  88. openstackclient/network/v2/network_segment_range.py +16 -20
  89. openstackclient/network/v2/network_trunk.py +24 -16
  90. openstackclient/network/v2/port.py +42 -31
  91. openstackclient/network/v2/router.py +55 -41
  92. openstackclient/network/v2/security_group.py +8 -15
  93. openstackclient/network/v2/security_group_rule.py +9 -10
  94. openstackclient/network/v2/subnet.py +31 -30
  95. openstackclient/network/v2/subnet_pool.py +4 -4
  96. openstackclient/object/client.py +2 -3
  97. openstackclient/object/v1/container.py +2 -3
  98. openstackclient/object/v1/object.py +2 -9
  99. openstackclient/shell.py +22 -5
  100. openstackclient/tests/functional/base.py +2 -2
  101. openstackclient/tests/functional/common/test_quota.py +3 -1
  102. openstackclient/tests/functional/compute/v2/common.py +12 -6
  103. openstackclient/tests/functional/compute/v2/test_server.py +2 -3
  104. openstackclient/tests/functional/compute/v2/test_server_event.py +1 -1
  105. openstackclient/tests/functional/identity/v2/test_user.py +1 -1
  106. openstackclient/tests/functional/identity/v3/common.py +3 -8
  107. openstackclient/tests/functional/identity/v3/test_application_credential.py +10 -10
  108. openstackclient/tests/functional/identity/v3/test_endpoint.py +3 -3
  109. openstackclient/tests/functional/identity/v3/test_group.py +3 -3
  110. openstackclient/tests/functional/identity/v3/test_idp.py +3 -7
  111. openstackclient/tests/functional/identity/v3/test_limit.py +4 -4
  112. openstackclient/tests/functional/identity/v3/test_project.py +5 -14
  113. openstackclient/tests/functional/identity/v3/test_region.py +1 -3
  114. openstackclient/tests/functional/identity/v3/test_registered_limit.py +3 -3
  115. openstackclient/tests/functional/identity/v3/test_role.py +1 -1
  116. openstackclient/tests/functional/identity/v3/test_role_assignment.py +13 -31
  117. openstackclient/tests/functional/identity/v3/test_service_provider.py +3 -7
  118. openstackclient/tests/functional/identity/v3/test_user.py +8 -8
  119. openstackclient/tests/functional/network/v2/common.py +7 -3
  120. openstackclient/tests/functional/network/v2/test_address_group.py +4 -0
  121. openstackclient/tests/functional/network/v2/test_l3_conntrack_helper.py +15 -11
  122. openstackclient/tests/functional/network/v2/test_local_ip.py +4 -0
  123. openstackclient/tests/functional/network/v2/test_network_meter_rule.py +2 -2
  124. openstackclient/tests/functional/network/v2/test_network_ndp_proxy.py +2 -3
  125. openstackclient/tests/functional/network/v2/test_network_rbac.py +2 -2
  126. openstackclient/tests/functional/network/v2/test_network_trunk.py +1 -1
  127. openstackclient/tests/functional/network/v2/test_port.py +17 -7
  128. openstackclient/tests/functional/network/v2/test_router.py +42 -0
  129. openstackclient/tests/functional/network/v2/test_subnet_pool.py +4 -0
  130. openstackclient/tests/unit/api/test_compute_v2.py +67 -87
  131. openstackclient/tests/unit/common/test_availability_zone.py +6 -14
  132. openstackclient/tests/unit/common/test_command.py +1 -1
  133. openstackclient/tests/unit/common/test_extension.py +5 -7
  134. openstackclient/tests/unit/common/test_limits.py +1 -1
  135. openstackclient/tests/unit/common/test_project_cleanup.py +5 -6
  136. openstackclient/tests/unit/common/test_quota.py +51 -28
  137. openstackclient/tests/unit/compute/v2/fakes.py +4 -10
  138. openstackclient/tests/unit/compute/v2/test_agent.py +16 -16
  139. openstackclient/tests/unit/compute/v2/test_aggregate.py +56 -60
  140. openstackclient/tests/unit/compute/v2/test_console.py +16 -16
  141. openstackclient/tests/unit/compute/v2/test_flavor.py +71 -71
  142. openstackclient/tests/unit/compute/v2/test_host.py +8 -8
  143. openstackclient/tests/unit/compute/v2/test_hypervisor.py +22 -30
  144. openstackclient/tests/unit/compute/v2/test_hypervisor_stats.py +2 -2
  145. openstackclient/tests/unit/compute/v2/test_keypair.py +24 -24
  146. openstackclient/tests/unit/compute/v2/test_server.py +524 -560
  147. openstackclient/tests/unit/compute/v2/test_server_backup.py +5 -7
  148. openstackclient/tests/unit/compute/v2/test_server_event.py +16 -18
  149. openstackclient/tests/unit/compute/v2/test_server_group.py +25 -31
  150. openstackclient/tests/unit/compute/v2/test_server_image.py +6 -8
  151. openstackclient/tests/unit/compute/v2/test_server_migration.py +37 -37
  152. openstackclient/tests/unit/compute/v2/test_server_volume.py +12 -12
  153. openstackclient/tests/unit/compute/v2/test_service.py +39 -45
  154. openstackclient/tests/unit/compute/v2/test_usage.py +5 -5
  155. openstackclient/tests/unit/identity/v2_0/fakes.py +1 -1
  156. openstackclient/tests/unit/identity/v3/test_access_rule.py +1 -3
  157. openstackclient/tests/unit/identity/v3/test_application_credential.py +1 -1
  158. openstackclient/tests/unit/identity/v3/test_credential.py +4 -4
  159. openstackclient/tests/unit/identity/v3/test_endpoint.py +167 -172
  160. openstackclient/tests/unit/identity/v3/test_mappings.py +2 -2
  161. openstackclient/tests/unit/identity/v3/test_trust.py +5 -2
  162. openstackclient/tests/unit/identity/v3/test_user.py +16 -0
  163. openstackclient/tests/unit/image/v1/fakes.py +2 -2
  164. openstackclient/tests/unit/image/v2/test_image.py +39 -1
  165. openstackclient/tests/unit/integ/cli/test_shell.py +1 -2
  166. openstackclient/tests/unit/network/test_common.py +2 -2
  167. openstackclient/tests/unit/network/v2/test_floating_ip_compute.py +8 -14
  168. openstackclient/tests/unit/network/v2/test_floating_ip_network.py +49 -35
  169. openstackclient/tests/unit/network/v2/test_floating_ip_pool_compute.py +1 -1
  170. openstackclient/tests/unit/network/v2/test_network_compute.py +11 -11
  171. openstackclient/tests/unit/network/v2/test_network_trunk.py +2 -2
  172. openstackclient/tests/unit/network/v2/test_port.py +33 -5
  173. openstackclient/tests/unit/network/v2/test_router.py +120 -7
  174. openstackclient/tests/unit/network/v2/test_security_group_compute.py +11 -19
  175. openstackclient/tests/unit/network/v2/test_security_group_rule_compute.py +14 -14
  176. openstackclient/tests/unit/object/v1/test_object_all.py +4 -3
  177. openstackclient/tests/unit/test_shell.py +16 -13
  178. openstackclient/tests/unit/volume/v2/test_volume.py +1 -1
  179. openstackclient/tests/unit/volume/v2/test_volume_transfer_request.py +1 -1
  180. openstackclient/tests/unit/volume/v3/fakes.py +2 -8
  181. openstackclient/tests/unit/volume/v3/test_volume.py +1 -1
  182. openstackclient/tests/unit/volume/v3/test_volume_attachment.py +3 -3
  183. openstackclient/tests/unit/volume/v3/test_volume_snapshot.py +1 -2
  184. openstackclient/tests/unit/volume/v3/test_volume_transfer_request.py +1 -1
  185. openstackclient/volume/client.py +1 -3
  186. openstackclient/volume/v2/consistency_group.py +4 -8
  187. openstackclient/volume/v2/consistency_group_snapshot.py +1 -2
  188. openstackclient/volume/v2/qos_specs.py +1 -2
  189. openstackclient/volume/v2/volume.py +8 -16
  190. openstackclient/volume/v2/volume_backup.py +6 -7
  191. openstackclient/volume/v2/volume_snapshot.py +8 -9
  192. openstackclient/volume/v2/volume_transfer_request.py +0 -3
  193. openstackclient/volume/v2/volume_type.py +10 -21
  194. openstackclient/volume/v3/block_storage_cluster.py +3 -3
  195. openstackclient/volume/v3/block_storage_manage.py +1 -3
  196. openstackclient/volume/v3/volume.py +18 -19
  197. openstackclient/volume/v3/volume_attachment.py +3 -2
  198. openstackclient/volume/v3/volume_backup.py +7 -8
  199. openstackclient/volume/v3/volume_group.py +2 -1
  200. openstackclient/volume/v3/volume_group_snapshot.py +2 -1
  201. openstackclient/volume/v3/volume_snapshot.py +4 -3
  202. openstackclient/volume/v3/volume_type.py +10 -21
  203. {python_openstackclient-7.3.1.dist-info → python_openstackclient-8.0.0.dist-info}/AUTHORS +4 -0
  204. {python_openstackclient-7.3.1.dist-info → python_openstackclient-8.0.0.dist-info}/METADATA +7 -13
  205. {python_openstackclient-7.3.1.dist-info → python_openstackclient-8.0.0.dist-info}/RECORD +210 -233
  206. {python_openstackclient-7.3.1.dist-info → python_openstackclient-8.0.0.dist-info}/WHEEL +1 -1
  207. {python_openstackclient-7.3.1.dist-info → python_openstackclient-8.0.0.dist-info}/entry_points.txt +0 -41
  208. python_openstackclient-8.0.0.dist-info/pbr.json +1 -0
  209. openstackclient/tests/functional/volume/v1/__init__.py +0 -0
  210. openstackclient/tests/functional/volume/v1/common.py +0 -35
  211. openstackclient/tests/functional/volume/v1/test_qos.py +0 -100
  212. openstackclient/tests/functional/volume/v1/test_service.py +0 -76
  213. openstackclient/tests/functional/volume/v1/test_snapshot.py +0 -232
  214. openstackclient/tests/functional/volume/v1/test_transfer_request.py +0 -111
  215. openstackclient/tests/functional/volume/v1/test_volume.py +0 -228
  216. openstackclient/tests/functional/volume/v1/test_volume_type.py +0 -213
  217. openstackclient/tests/unit/volume/v1/__init__.py +0 -0
  218. openstackclient/tests/unit/volume/v1/fakes.py +0 -615
  219. openstackclient/tests/unit/volume/v1/test_qos_specs.py +0 -471
  220. openstackclient/tests/unit/volume/v1/test_service.py +0 -295
  221. openstackclient/tests/unit/volume/v1/test_transfer_request.py +0 -380
  222. openstackclient/tests/unit/volume/v1/test_type.py +0 -633
  223. openstackclient/tests/unit/volume/v1/test_volume.py +0 -1447
  224. openstackclient/tests/unit/volume/v1/test_volume_backup.py +0 -435
  225. openstackclient/volume/v1/__init__.py +0 -0
  226. openstackclient/volume/v1/qos_specs.py +0 -377
  227. openstackclient/volume/v1/service.py +0 -136
  228. openstackclient/volume/v1/volume.py +0 -734
  229. openstackclient/volume/v1/volume_backup.py +0 -302
  230. openstackclient/volume/v1/volume_snapshot.py +0 -433
  231. openstackclient/volume/v1/volume_transfer_request.py +0 -200
  232. openstackclient/volume/v1/volume_type.py +0 -520
  233. python_openstackclient-7.3.1.dist-info/pbr.json +0 -1
  234. {python_openstackclient-7.3.1.dist-info → python_openstackclient-8.0.0.dist-info}/LICENSE +0 -0
  235. {python_openstackclient-7.3.1.dist-info → python_openstackclient-8.0.0.dist-info}/top_level.txt +0 -0
@@ -1,377 +0,0 @@
1
- # Copyright 2015 iWeb Technologies Inc.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"); you may
4
- # not use this file except in compliance with the License. You may obtain
5
- # a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
- # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
- # License for the specific language governing permissions and limitations
13
- # under the License.
14
- #
15
-
16
- """Volume v1 QoS action implementations"""
17
-
18
- import logging
19
-
20
- from osc_lib.cli import format_columns
21
- from osc_lib.cli import parseractions
22
- from osc_lib.command import command
23
- from osc_lib import exceptions
24
- from osc_lib import utils
25
-
26
- from openstackclient.i18n import _
27
-
28
-
29
- LOG = logging.getLogger(__name__)
30
-
31
-
32
- class AssociateQos(command.Command):
33
- _description = _("Associate a QoS specification to a volume type")
34
-
35
- def get_parser(self, prog_name):
36
- parser = super().get_parser(prog_name)
37
- parser.add_argument(
38
- 'qos_spec',
39
- metavar='<qos-spec>',
40
- help=_('QoS specification to modify (name or ID)'),
41
- )
42
- parser.add_argument(
43
- 'volume_type',
44
- metavar='<volume-type>',
45
- help=_('Volume type to associate the QoS (name or ID)'),
46
- )
47
- return parser
48
-
49
- def take_action(self, parsed_args):
50
- volume_client = self.app.client_manager.volume
51
- qos_spec = utils.find_resource(
52
- volume_client.qos_specs, parsed_args.qos_spec
53
- )
54
- volume_type = utils.find_resource(
55
- volume_client.volume_types, parsed_args.volume_type
56
- )
57
-
58
- volume_client.qos_specs.associate(qos_spec.id, volume_type.id)
59
-
60
-
61
- class CreateQos(command.ShowOne):
62
- _description = _("Create new QoS specification")
63
-
64
- def get_parser(self, prog_name):
65
- parser = super().get_parser(prog_name)
66
- parser.add_argument(
67
- 'name',
68
- metavar='<name>',
69
- help=_('New QoS specification name'),
70
- )
71
- consumer_choices = ['front-end', 'back-end', 'both']
72
- parser.add_argument(
73
- '--consumer',
74
- metavar='<consumer>',
75
- choices=consumer_choices,
76
- default='both',
77
- help=(
78
- _(
79
- 'Consumer of the QoS. Valid consumers: %s '
80
- "(defaults to 'both')"
81
- )
82
- % utils.format_list(consumer_choices)
83
- ),
84
- )
85
- parser.add_argument(
86
- '--property',
87
- metavar='<key=value>',
88
- action=parseractions.KeyValueAction,
89
- help=_(
90
- 'Set a QoS specification property '
91
- '(repeat option to set multiple properties)'
92
- ),
93
- )
94
- return parser
95
-
96
- def take_action(self, parsed_args):
97
- volume_client = self.app.client_manager.volume
98
- specs = {}
99
- specs.update({'consumer': parsed_args.consumer})
100
-
101
- if parsed_args.property:
102
- specs.update(parsed_args.property)
103
-
104
- qos_spec = volume_client.qos_specs.create(parsed_args.name, specs)
105
- qos_spec._info.update(
106
- {
107
- 'properties': format_columns.DictColumn(
108
- qos_spec._info.pop('specs')
109
- )
110
- }
111
- )
112
- return zip(*sorted(qos_spec._info.items()))
113
-
114
-
115
- class DeleteQos(command.Command):
116
- _description = _("Delete QoS specification")
117
-
118
- def get_parser(self, prog_name):
119
- parser = super().get_parser(prog_name)
120
- parser.add_argument(
121
- 'qos_specs',
122
- metavar='<qos-spec>',
123
- nargs="+",
124
- help=_('QoS specification(s) to delete (name or ID)'),
125
- )
126
- parser.add_argument(
127
- '--force',
128
- action='store_true',
129
- default=False,
130
- help=_("Allow to delete in-use QoS specification(s)"),
131
- )
132
- return parser
133
-
134
- def take_action(self, parsed_args):
135
- volume_client = self.app.client_manager.volume
136
- result = 0
137
-
138
- for i in parsed_args.qos_specs:
139
- try:
140
- qos_spec = utils.find_resource(volume_client.qos_specs, i)
141
- volume_client.qos_specs.delete(qos_spec.id, parsed_args.force)
142
- except Exception as e:
143
- result += 1
144
- LOG.error(
145
- _(
146
- "Failed to delete QoS specification with "
147
- "name or ID '%(qos)s': %(e)s"
148
- ),
149
- {'qos': i, 'e': e},
150
- )
151
-
152
- if result > 0:
153
- total = len(parsed_args.qos_specs)
154
- msg = _(
155
- "%(result)s of %(total)s QoS specifications failed"
156
- " to delete."
157
- ) % {'result': result, 'total': total}
158
- raise exceptions.CommandError(msg)
159
-
160
-
161
- class DisassociateQos(command.Command):
162
- _description = _("Disassociate a QoS specification from a volume type")
163
-
164
- def get_parser(self, prog_name):
165
- parser = super().get_parser(prog_name)
166
- parser.add_argument(
167
- 'qos_spec',
168
- metavar='<qos-spec>',
169
- help=_('QoS specification to modify (name or ID)'),
170
- )
171
- volume_type_group = parser.add_mutually_exclusive_group()
172
- volume_type_group.add_argument(
173
- '--volume-type',
174
- metavar='<volume-type>',
175
- help=_('Volume type to disassociate the QoS from (name or ID)'),
176
- )
177
- volume_type_group.add_argument(
178
- '--all',
179
- action='store_true',
180
- default=False,
181
- help=_('Disassociate the QoS from every volume type'),
182
- )
183
-
184
- return parser
185
-
186
- def take_action(self, parsed_args):
187
- volume_client = self.app.client_manager.volume
188
- qos_spec = utils.find_resource(
189
- volume_client.qos_specs, parsed_args.qos_spec
190
- )
191
-
192
- if parsed_args.volume_type:
193
- volume_type = utils.find_resource(
194
- volume_client.volume_types, parsed_args.volume_type
195
- )
196
- volume_client.qos_specs.disassociate(qos_spec.id, volume_type.id)
197
- elif parsed_args.all:
198
- volume_client.qos_specs.disassociate_all(qos_spec.id)
199
-
200
-
201
- class ListQos(command.Lister):
202
- _description = _("List QoS specifications")
203
-
204
- def take_action(self, parsed_args):
205
- volume_client = self.app.client_manager.volume
206
- qos_specs_list = volume_client.qos_specs.list()
207
-
208
- for qos in qos_specs_list:
209
- try:
210
- qos_associations = volume_client.qos_specs.get_associations(
211
- qos,
212
- )
213
- if qos_associations:
214
- associations = [
215
- association.name for association in qos_associations
216
- ]
217
- qos._info.update({'associations': associations})
218
- except Exception as ex:
219
- if type(ex).__name__ == 'NotFound':
220
- qos._info.update({'associations': None})
221
- else:
222
- raise
223
-
224
- display_columns = (
225
- 'ID',
226
- 'Name',
227
- 'Consumer',
228
- 'Associations',
229
- 'Properties',
230
- )
231
- columns = ('ID', 'Name', 'Consumer', 'Associations', 'Specs')
232
- return (
233
- display_columns,
234
- (
235
- utils.get_dict_properties(
236
- s._info,
237
- columns,
238
- formatters={
239
- 'Specs': format_columns.DictColumn,
240
- 'Associations': format_columns.ListColumn,
241
- },
242
- )
243
- for s in qos_specs_list
244
- ),
245
- )
246
-
247
-
248
- class SetQos(command.Command):
249
- _description = _("Set QoS specification properties")
250
-
251
- def get_parser(self, prog_name):
252
- parser = super().get_parser(prog_name)
253
- parser.add_argument(
254
- 'qos_spec',
255
- metavar='<qos-spec>',
256
- help=_('QoS specification to modify (name or ID)'),
257
- )
258
- parser.add_argument(
259
- '--no-property',
260
- dest='no_property',
261
- action='store_true',
262
- help=_(
263
- 'Remove all properties from <qos-spec> '
264
- '(specify both --no-property and --property to remove the '
265
- 'current properties before setting new properties)'
266
- ),
267
- )
268
- parser.add_argument(
269
- '--property',
270
- metavar='<key=value>',
271
- action=parseractions.KeyValueAction,
272
- help=_(
273
- 'Property to add or modify for this QoS specification '
274
- '(repeat option to set multiple properties)'
275
- ),
276
- )
277
- return parser
278
-
279
- def take_action(self, parsed_args):
280
- volume_client = self.app.client_manager.volume
281
- qos_spec = utils.find_resource(
282
- volume_client.qos_specs, parsed_args.qos_spec
283
- )
284
-
285
- result = 0
286
- if parsed_args.no_property:
287
- try:
288
- key_list = list(qos_spec._info['specs'].keys())
289
- volume_client.qos_specs.unset_keys(qos_spec.id, key_list)
290
- except Exception as e:
291
- LOG.error(_("Failed to clean qos properties: %s"), e)
292
- result += 1
293
-
294
- if parsed_args.property:
295
- try:
296
- volume_client.qos_specs.set_keys(
297
- qos_spec.id,
298
- parsed_args.property,
299
- )
300
- except Exception as e:
301
- LOG.error(_("Failed to set qos property: %s"), e)
302
- result += 1
303
-
304
- if result > 0:
305
- raise exceptions.CommandError(
306
- _("One or more of the set operations failed")
307
- )
308
-
309
-
310
- class ShowQos(command.ShowOne):
311
- _description = _("Display QoS specification details")
312
-
313
- def get_parser(self, prog_name):
314
- parser = super().get_parser(prog_name)
315
- parser.add_argument(
316
- 'qos_spec',
317
- metavar='<qos-spec>',
318
- help=_('QoS specification to display (name or ID)'),
319
- )
320
- return parser
321
-
322
- def take_action(self, parsed_args):
323
- volume_client = self.app.client_manager.volume
324
- qos_spec = utils.find_resource(
325
- volume_client.qos_specs, parsed_args.qos_spec
326
- )
327
-
328
- qos_associations = volume_client.qos_specs.get_associations(qos_spec)
329
- if qos_associations:
330
- associations = [
331
- association.name for association in qos_associations
332
- ]
333
- qos_spec._info.update(
334
- {'associations': format_columns.ListColumn(associations)}
335
- )
336
- qos_spec._info.update(
337
- {
338
- 'properties': format_columns.DictColumn(
339
- qos_spec._info.pop('specs')
340
- )
341
- }
342
- )
343
-
344
- return zip(*sorted(qos_spec._info.items()))
345
-
346
-
347
- class UnsetQos(command.Command):
348
- _description = _("Unset QoS specification properties")
349
-
350
- def get_parser(self, prog_name):
351
- parser = super().get_parser(prog_name)
352
- parser.add_argument(
353
- 'qos_spec',
354
- metavar='<qos-spec>',
355
- help=_('QoS specification to modify (name or ID)'),
356
- )
357
- parser.add_argument(
358
- '--property',
359
- metavar='<key>',
360
- action='append',
361
- help=_(
362
- 'Property to remove from the QoS specification. '
363
- '(repeat option to unset multiple properties)'
364
- ),
365
- )
366
- return parser
367
-
368
- def take_action(self, parsed_args):
369
- volume_client = self.app.client_manager.volume
370
- qos_spec = utils.find_resource(
371
- volume_client.qos_specs, parsed_args.qos_spec
372
- )
373
-
374
- if parsed_args.property:
375
- volume_client.qos_specs.unset_keys(
376
- qos_spec.id, parsed_args.property
377
- )
@@ -1,136 +0,0 @@
1
- #
2
- # Licensed under the Apache License, Version 2.0 (the "License"); you may
3
- # not use this file except in compliance with the License. You may obtain
4
- # a copy of the License at
5
- #
6
- # http://www.apache.org/licenses/LICENSE-2.0
7
- #
8
- # Unless required by applicable law or agreed to in writing, software
9
- # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10
- # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11
- # License for the specific language governing permissions and limitations
12
- # under the License.
13
- #
14
-
15
- """Service action implementations"""
16
-
17
- from osc_lib.command import command
18
- from osc_lib import exceptions
19
- from osc_lib import utils
20
-
21
- from openstackclient.i18n import _
22
-
23
-
24
- class ListService(command.Lister):
25
- _description = _("List service command")
26
-
27
- def get_parser(self, prog_name):
28
- parser = super().get_parser(prog_name)
29
- parser.add_argument(
30
- "--host",
31
- metavar="<host>",
32
- help=_("List services on specified host (name only)"),
33
- )
34
- parser.add_argument(
35
- "--service",
36
- metavar="<service>",
37
- help=_("List only specified service (name only)"),
38
- )
39
- parser.add_argument(
40
- "--long",
41
- action="store_true",
42
- default=False,
43
- help=_("List additional fields in output"),
44
- )
45
- return parser
46
-
47
- def take_action(self, parsed_args):
48
- service_client = self.app.client_manager.volume
49
-
50
- if parsed_args.long:
51
- columns = [
52
- "Binary",
53
- "Host",
54
- "Zone",
55
- "Status",
56
- "State",
57
- "Updated At",
58
- "Disabled Reason",
59
- ]
60
- else:
61
- columns = [
62
- "Binary",
63
- "Host",
64
- "Zone",
65
- "Status",
66
- "State",
67
- "Updated At",
68
- ]
69
-
70
- data = service_client.services.list(
71
- parsed_args.host, parsed_args.service
72
- )
73
- return (
74
- columns,
75
- (
76
- utils.get_item_properties(
77
- s,
78
- columns,
79
- )
80
- for s in data
81
- ),
82
- )
83
-
84
-
85
- class SetService(command.Command):
86
- _description = _("Set volume service properties")
87
-
88
- def get_parser(self, prog_name):
89
- parser = super().get_parser(prog_name)
90
- parser.add_argument("host", metavar="<host>", help=_("Name of host"))
91
- parser.add_argument(
92
- "service",
93
- metavar="<service>",
94
- help=_("Name of service (Binary name)"),
95
- )
96
- enabled_group = parser.add_mutually_exclusive_group()
97
- enabled_group.add_argument(
98
- "--enable", action="store_true", help=_("Enable volume service")
99
- )
100
- enabled_group.add_argument(
101
- "--disable", action="store_true", help=_("Disable volume service")
102
- )
103
- parser.add_argument(
104
- "--disable-reason",
105
- metavar="<reason>",
106
- help=_(
107
- "Reason for disabling the service "
108
- "(should be used with --disable option)"
109
- ),
110
- )
111
- return parser
112
-
113
- def take_action(self, parsed_args):
114
- if parsed_args.disable_reason and not parsed_args.disable:
115
- msg = _(
116
- "Cannot specify option --disable-reason without "
117
- "--disable specified."
118
- )
119
- raise exceptions.CommandError(msg)
120
-
121
- service_client = self.app.client_manager.volume
122
- if parsed_args.enable:
123
- service_client.services.enable(
124
- parsed_args.host, parsed_args.service
125
- )
126
- if parsed_args.disable:
127
- if parsed_args.disable_reason:
128
- service_client.services.disable_log_reason(
129
- parsed_args.host,
130
- parsed_args.service,
131
- parsed_args.disable_reason,
132
- )
133
- else:
134
- service_client.services.disable(
135
- parsed_args.host, parsed_args.service
136
- )