@@ -64,6 +64,7 @@ class NetDetectionMixin(metaclass=abc.ABCMeta):
6464 But the command classes are used for docs builds as well, and docs must
6565 present the options for both network types, often qualified accordingly.
6666 """
67+
6768 @property
6869 def _network_type (self ):
6970 """Discover whether the running cloud is using neutron or nova-network.
@@ -85,7 +86,9 @@ def _network_type(self):
8586 except AttributeError :
8687 LOG .warning (
8788 "%s: Could not detect a network type. Assuming we are "
88- "building docs." , self .__class__ .__name__ )
89+ "building docs." ,
90+ self .__class__ .__name__ ,
91+ )
8992 net_type = None
9093 self ._net_type = net_type
9194 return self ._net_type
@@ -118,11 +121,14 @@ def enhance_help_nova_network(self, _help):
118121 def split_help (network_help , compute_help ):
119122 return (
120123 "*%(network_qualifier)s:*\n %(network_help)s\n \n "
121- "*%(compute_qualifier)s:*\n %(compute_help)s" % dict (
124+ "*%(compute_qualifier)s:*\n %(compute_help)s"
125+ % dict (
122126 network_qualifier = _ ("Network version 2" ),
123127 network_help = network_help ,
124128 compute_qualifier = _ ("Compute version 2" ),
125- compute_help = compute_help ))
129+ compute_help = compute_help ,
130+ )
131+ )
126132
127133 def get_parser (self , prog_name ):
128134 LOG .debug ('get_parser(%s)' , prog_name )
@@ -150,11 +156,13 @@ def update_parser_compute(self, parser):
150156
151157 def take_action (self , parsed_args ):
152158 if self .is_neutron :
153- return self .take_action_network (self .app .client_manager .network ,
154- parsed_args )
159+ return self .take_action_network (
160+ self .app .client_manager .network , parsed_args
161+ )
155162 elif self .is_nova_network :
156- return self .take_action_compute (self .app .client_manager .compute ,
157- parsed_args )
163+ return self .take_action_compute (
164+ self .app .client_manager .compute , parsed_args
165+ )
158166
159167 def take_action_network (self , client , parsed_args ):
160168 """Override to do something useful."""
@@ -165,20 +173,21 @@ def take_action_compute(self, client, parsed_args):
165173 pass
166174
167175
168- class NetworkAndComputeCommand (NetDetectionMixin , command .Command ,
169- metaclass = abc .ABCMeta ):
176+ class NetworkAndComputeCommand (
177+ NetDetectionMixin , command .Command , metaclass = abc .ABCMeta
178+ ):
170179 """Network and Compute Command
171180
172181 Command class for commands that support implementation via
173182 the network or compute endpoint. Such commands have different
174183 implementations for take_action() and may even have different
175184 arguments.
176185 """
186+
177187 pass
178188
179189
180- class NetworkAndComputeDelete (NetworkAndComputeCommand ,
181- metaclass = abc .ABCMeta ):
190+ class NetworkAndComputeDelete (NetworkAndComputeCommand , metaclass = abc .ABCMeta ):
182191 """Network and Compute Delete
183192
184193 Delete class for commands that support implementation via
@@ -196,17 +205,21 @@ def take_action(self, parsed_args):
196205 self .r = r
197206 try :
198207 if self .app .client_manager .is_network_endpoint_enabled ():
199- self .take_action_network (self .app .client_manager .network ,
200- parsed_args )
208+ self .take_action_network (
209+ self .app .client_manager .network , parsed_args
210+ )
201211 else :
202- self .take_action_compute (self .app .client_manager .compute ,
203- parsed_args )
212+ self .take_action_compute (
213+ self .app .client_manager .compute , parsed_args
214+ )
204215 except Exception as e :
205- msg = _ ("Failed to delete %(resource)s with name or ID "
206- "'%(name_or_id)s': %(e)s" ) % {
207- "resource" : self .resource ,
208- "name_or_id" : r ,
209- "e" : e ,
216+ msg = _ (
217+ "Failed to delete %(resource)s with name or ID "
218+ "'%(name_or_id)s': %(e)s"
219+ ) % {
220+ "resource" : self .resource ,
221+ "name_or_id" : r ,
222+ "e" : e ,
210223 }
211224 LOG .error (msg )
212225 ret += 1
@@ -221,20 +234,23 @@ def take_action(self, parsed_args):
221234 raise exceptions .CommandError (msg )
222235
223236
224- class NetworkAndComputeLister (NetDetectionMixin , command .Lister ,
225- metaclass = abc .ABCMeta ):
237+ class NetworkAndComputeLister (
238+ NetDetectionMixin , command .Lister , metaclass = abc .ABCMeta
239+ ):
226240 """Network and Compute Lister
227241
228242 Lister class for commands that support implementation via
229243 the network or compute endpoint. Such commands have different
230244 implementations for take_action() and may even have different
231245 arguments.
232246 """
247+
233248 pass
234249
235250
236- class NetworkAndComputeShowOne (NetDetectionMixin , command .ShowOne ,
237- metaclass = abc .ABCMeta ):
251+ class NetworkAndComputeShowOne (
252+ NetDetectionMixin , command .ShowOne , metaclass = abc .ABCMeta
253+ ):
238254 """Network and Compute ShowOne
239255
240256 ShowOne class for commands that support implementation via
@@ -247,10 +263,12 @@ def take_action(self, parsed_args):
247263 try :
248264 if self .app .client_manager .is_network_endpoint_enabled ():
249265 return self .take_action_network (
250- self .app .client_manager .network , parsed_args )
266+ self .app .client_manager .network , parsed_args
267+ )
251268 else :
252269 return self .take_action_compute (
253- self .app .client_manager .compute , parsed_args )
270+ self .app .client_manager .compute , parsed_args
271+ )
254272 except openstack .exceptions .HttpException as exc :
255273 msg = _ ("Error while executing command: %s" ) % exc .message
256274 if exc .details :
@@ -282,10 +300,13 @@ def _get_property_converter(self, _property):
282300
283301 if not converter :
284302 raise exceptions .CommandError (
285- _ ("Type {property_type} of property {name} "
286- "is not supported" ).format (
287- property_type = _property ['type' ],
288- name = _property ['name' ]))
303+ _ (
304+ "Type {property_type} of property {name} "
305+ "is not supported"
306+ ).format (
307+ property_type = _property ['type' ], name = _property ['name' ]
308+ )
309+ )
289310 return converter
290311
291312 def _parse_extra_properties (self , extra_properties ):
@@ -301,25 +322,26 @@ def get_parser(self, prog_name):
301322 parser .add_argument (
302323 '--extra-property' ,
303324 metavar = 'type=<property_type>,name=<property_name>,'
304- 'value=<property_value>' ,
325+ 'value=<property_value>' ,
305326 dest = 'extra_properties' ,
306327 action = parseractions .MultiKeyValueAction ,
307328 required_keys = ['name' , 'value' ],
308329 optional_keys = ['type' ],
309- help = _ ("Additional parameters can be passed using this property. "
310- "Default type of the extra property is string ('str'), but "
311- "other types can be used as well. Available types are: "
312- "'dict', 'list', 'str', 'bool', 'int'. "
313- "In case of 'list' type, 'value' can be "
314- "semicolon-separated list of values. "
315- "For 'dict' value is semicolon-separated list of the "
316- "key:value pairs." )
330+ help = _ (
331+ "Additional parameters can be passed using this property. "
332+ "Default type of the extra property is string ('str'), but "
333+ "other types can be used as well. Available types are: "
334+ "'dict', 'list', 'str', 'bool', 'int'. "
335+ "In case of 'list' type, 'value' can be "
336+ "semicolon-separated list of values. "
337+ "For 'dict' value is semicolon-separated list of the "
338+ "key:value pairs."
339+ ),
317340 )
318341 return parser
319342
320343
321344class NeutronUnsetCommandWithExtraArgs (NeutronCommandWithExtraArgs ):
322-
323345 def _parse_extra_properties (self , extra_properties ):
324346 result = {}
325347 if extra_properties :
0 commit comments