Skip to content

Commit f3e9c16

Browse files
authored
{Diskpool} Fix issue for generation issue (Azure#3450)
* refine help * test pass * fix style * fix style
1 parent 4f21314 commit f3e9c16

File tree

18 files changed

+1661
-573
lines changed

18 files changed

+1661
-573
lines changed

src/diskpool/HISTORY.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
Release History
44
===============
55

6+
0.1.1
7+
++++++
8+
* Fix generation issue.
9+
610
0.1.0
711
++++++
812
* Initial release.

src/diskpool/azext_diskpool/__init__.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77
# Changes may cause incorrect behavior and will be lost if the code is
88
# regenerated.
99
# --------------------------------------------------------------------------
10-
# pylint: disable=unused-import
1110

12-
import azext_diskpool._help
1311
from azure.cli.core import AzCommandsLoader
12+
from azext_diskpool.generated._help import helps # pylint: disable=unused-import
13+
try:
14+
from azext_diskpool.manual._help import helps # pylint: disable=reimported
15+
except ImportError:
16+
pass
1417

1518

1619
class StoragePoolManagementCommandsLoader(AzCommandsLoader):
@@ -30,11 +33,8 @@ def load_command_table(self, args):
3033
try:
3134
from azext_diskpool.manual.commands import load_command_table as load_command_table_manual
3235
load_command_table_manual(self, args)
33-
except ImportError as e:
34-
if e.name.endswith('manual.commands'):
35-
pass
36-
else:
37-
raise e
36+
except ImportError:
37+
pass
3838
return self.command_table
3939

4040
def load_arguments(self, command):
@@ -43,11 +43,8 @@ def load_arguments(self, command):
4343
try:
4444
from azext_diskpool.manual._params import load_arguments as load_arguments_manual
4545
load_arguments_manual(self, command)
46-
except ImportError as e:
47-
if e.name.endswith('manual._params'):
48-
pass
49-
else:
50-
raise e
46+
except ImportError:
47+
pass
5148

5249

5350
COMMAND_LOADER_CLS = StoragePoolManagementCommandsLoader

src/diskpool/azext_diskpool/action.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,5 @@
1313
from .generated.action import * # noqa: F403
1414
try:
1515
from .manual.action import * # noqa: F403
16-
except ImportError as e:
17-
if e.name.endswith('manual.action'):
18-
pass
19-
else:
20-
raise e
16+
except ImportError:
17+
pass

src/diskpool/azext_diskpool/custom.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,5 @@
1313
from .generated.custom import * # noqa: F403
1414
try:
1515
from .manual.custom import * # noqa: F403
16-
except ImportError as e:
17-
if e.name.endswith('manual.custom'):
18-
pass
19-
else:
20-
raise e
16+
except ImportError:
17+
pass

src/diskpool/azext_diskpool/generated/_client_factory.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,5 @@ def cf_disk_pool(cli_ctx, *_):
2020
return cf_diskpool_cl(cli_ctx).disk_pools
2121

2222

23-
def cf_disk_pool_zone(cli_ctx, *_):
24-
return cf_diskpool_cl(cli_ctx).disk_pool_zones
25-
26-
2723
def cf_iscsi_target(cli_ctx, *_):
2824
return cf_diskpool_cl(cli_ctx).iscsi_targets

src/diskpool/azext_diskpool/generated/_help.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@
1212
from knack.help_files import helps
1313

1414

15-
helps['disk-pool'] = '''
16-
type: group
17-
short-summary: Manage Storage Pool Management
18-
'''
19-
2015
helps['disk-pool'] = """
2116
type: group
2217
short-summary: Manage disk pool with diskpool

src/diskpool/azext_diskpool/generated/action.py

Lines changed: 48 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -7,47 +7,19 @@
77
# Changes may cause incorrect behavior and will be lost if the code is
88
# regenerated.
99
# --------------------------------------------------------------------------
10-
11-
1210
# pylint: disable=protected-access
1311

14-
# pylint: disable=no-self-use
15-
16-
1712
import argparse
1813
from collections import defaultdict
1914
from knack.util import CLIError
2015

2116

22-
class AddDiskPoolUpdateDisks(argparse._AppendAction):
23-
def __call__(self, parser, namespace, values, option_string=None):
24-
action = self.get_action(values, option_string)
25-
26-
for item in action:
27-
super(AddDiskPoolUpdateDisks, self).__call__(parser, namespace, item, option_string)
28-
29-
def get_action(self, values, option_string=None):
30-
try:
31-
value_chunk_list = [values[x: x + 1] for x in range(0, len(values), 1)]
32-
value_list = []
33-
for chunk in value_chunk_list:
34-
id = chunk
35-
value_list.append(
36-
{
37-
'id': id,
38-
}
39-
)
40-
return value_list
41-
except ValueError:
42-
raise CLIError('usage error: {} NAME METRIC OPERATION VALUE'.format(option_string))
43-
44-
4517
class AddSku(argparse.Action):
4618
def __call__(self, parser, namespace, values, option_string=None):
4719
action = self.get_action(values, option_string)
4820
namespace.sku = action
4921

50-
def get_action(self, values, option_string):
22+
def get_action(self, values, option_string): # pylint: disable=no-self-use
5123
try:
5224
properties = defaultdict(list)
5325
for (k, v) in (x.split('=', 1) for x in values):
@@ -57,56 +29,68 @@ def get_action(self, values, option_string):
5729
raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string))
5830
d = {}
5931
for k in properties:
60-
6132
kl = k.lower()
62-
6333
v = properties[k]
64-
6534
if kl == 'name':
66-
6735
d['name'] = v[0]
68-
6936
elif kl == 'tier':
70-
7137
d['tier'] = v[0]
72-
7338
else:
74-
raise CLIError(
75-
'Unsupported Key {} is provided for parameter sku. All possible keys are: name, tier'.format(k)
76-
)
77-
39+
raise CLIError('Unsupported Key {} is provided for parameter sku. All possible keys are: name, tier'.
40+
format(k))
7841
return d
7942

8043

8144
class AddDiskPoolCreateDisks(argparse._AppendAction):
8245
def __call__(self, parser, namespace, values, option_string=None):
8346
action = self.get_action(values, option_string)
84-
8547
for item in action:
8648
super(AddDiskPoolCreateDisks, self).__call__(parser, namespace, item, option_string)
8749

8850
def get_action(self, values, option_string=None):
8951
try:
90-
value_chunk_list = [values[x: x + 1] for x in range(0, len(values), 1)]
52+
value_chunk_list = [values[x:x + 1] for x in range(0, len(values), 1)]
9153
value_list = []
9254
for chunk in value_chunk_list:
93-
id = chunk
55+
id, = chunk
9456
value_list.append(
9557
{
96-
'id': id,
58+
'id': id
9759
}
9860
)
9961
return value_list
10062
except ValueError:
10163
raise CLIError('usage error: {} NAME METRIC OPERATION VALUE'.format(option_string))
10264

10365

104-
class AddDiskPoolIscsiTargetUpdateStaticAcls(argparse._AppendAction):
66+
class AddDiskPoolUpdateDisks(argparse._AppendAction):
10567
def __call__(self, parser, namespace, values, option_string=None):
10668
action = self.get_action(values, option_string)
107-
super(AddDiskPoolIscsiTargetUpdateStaticAcls, self).__call__(parser, namespace, action, option_string)
69+
for item in action:
70+
super(AddDiskPoolUpdateDisks, self).__call__(parser, namespace, item, option_string)
10871

109-
def get_action(self, values, option_string):
72+
def get_action(self, values, option_string=None):
73+
try:
74+
value_chunk_list = [values[x:x + 1] for x in range(0, len(values), 1)]
75+
value_list = []
76+
for chunk in value_chunk_list:
77+
id, = chunk
78+
value_list.append(
79+
{
80+
'id': id
81+
}
82+
)
83+
return value_list
84+
except ValueError:
85+
raise CLIError('usage error: {} NAME METRIC OPERATION VALUE'.format(option_string))
86+
87+
88+
class AddDiskPoolIscsiTargetCreateStaticAcls(argparse._AppendAction):
89+
def __call__(self, parser, namespace, values, option_string=None):
90+
action = self.get_action(values, option_string)
91+
super(AddDiskPoolIscsiTargetCreateStaticAcls, self).__call__(parser, namespace, action, option_string)
92+
93+
def get_action(self, values, option_string): # pylint: disable=no-self-use
11094
try:
11195
properties = defaultdict(list)
11296
for (k, v) in (x.split('=', 1) for x in values):
@@ -116,34 +100,24 @@ def get_action(self, values, option_string):
116100
raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string))
117101
d = {}
118102
for k in properties:
119-
120103
kl = k.lower()
121-
122104
v = properties[k]
123-
124105
if kl == 'initiator-iqn':
125-
126106
d['initiator_iqn'] = v[0]
127-
128107
elif kl == 'mapped-luns':
129-
130108
d['mapped_luns'] = v
131-
132109
else:
133-
raise CLIError(
134-
'Unsupported Key {} is provided for parameter static-acls. All possible keys are: initiator-iqn,'
135-
' mapped-luns'.format(k)
136-
)
137-
110+
raise CLIError('Unsupported Key {} is provided for parameter static_acls. All possible keys are: '
111+
'initiator-iqn, mapped-luns'.format(k))
138112
return d
139113

140114

141-
class AddDiskPoolIscsiTargetUpdateLuns(argparse._AppendAction):
115+
class AddDiskPoolIscsiTargetCreateLuns(argparse._AppendAction):
142116
def __call__(self, parser, namespace, values, option_string=None):
143117
action = self.get_action(values, option_string)
144-
super(AddDiskPoolIscsiTargetUpdateLuns, self).__call__(parser, namespace, action, option_string)
118+
super(AddDiskPoolIscsiTargetCreateLuns, self).__call__(parser, namespace, action, option_string)
145119

146-
def get_action(self, values, option_string):
120+
def get_action(self, values, option_string): # pylint: disable=no-self-use
147121
try:
148122
properties = defaultdict(list)
149123
for (k, v) in (x.split('=', 1) for x in values):
@@ -153,34 +127,24 @@ def get_action(self, values, option_string):
153127
raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string))
154128
d = {}
155129
for k in properties:
156-
157130
kl = k.lower()
158-
159131
v = properties[k]
160-
161132
if kl == 'name':
162-
163133
d['name'] = v[0]
164-
165134
elif kl == 'managed-disk-azure-resource-id':
166-
167135
d['managed_disk_azure_resource_id'] = v[0]
168-
169136
else:
170-
raise CLIError(
171-
'Unsupported Key {} is provided for parameter luns. All possible keys are: name,'
172-
' managed-disk-azure-resource-id'.format(k)
173-
)
174-
137+
raise CLIError('Unsupported Key {} is provided for parameter luns. All possible keys are: name, '
138+
'managed-disk-azure-resource-id'.format(k))
175139
return d
176140

177141

178-
class AddDiskPoolIscsiTargetCreateStaticAcls(argparse._AppendAction):
142+
class AddDiskPoolIscsiTargetUpdateStaticAcls(argparse._AppendAction):
179143
def __call__(self, parser, namespace, values, option_string=None):
180144
action = self.get_action(values, option_string)
181-
super(AddDiskPoolIscsiTargetCreateStaticAcls, self).__call__(parser, namespace, action, option_string)
145+
super(AddDiskPoolIscsiTargetUpdateStaticAcls, self).__call__(parser, namespace, action, option_string)
182146

183-
def get_action(self, values, option_string):
147+
def get_action(self, values, option_string): # pylint: disable=no-self-use
184148
try:
185149
properties = defaultdict(list)
186150
for (k, v) in (x.split('=', 1) for x in values):
@@ -190,34 +154,24 @@ def get_action(self, values, option_string):
190154
raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string))
191155
d = {}
192156
for k in properties:
193-
194157
kl = k.lower()
195-
196158
v = properties[k]
197-
198159
if kl == 'initiator-iqn':
199-
200160
d['initiator_iqn'] = v[0]
201-
202161
elif kl == 'mapped-luns':
203-
204162
d['mapped_luns'] = v
205-
206163
else:
207-
raise CLIError(
208-
'Unsupported Key {} is provided for parameter static-acls. All possible keys are: initiator-iqn,'
209-
' mapped-luns'.format(k)
210-
)
211-
164+
raise CLIError('Unsupported Key {} is provided for parameter static_acls. All possible keys are: '
165+
'initiator-iqn, mapped-luns'.format(k))
212166
return d
213167

214168

215-
class AddDiskPoolIscsiTargetCreateLuns(argparse._AppendAction):
169+
class AddDiskPoolIscsiTargetUpdateLuns(argparse._AppendAction):
216170
def __call__(self, parser, namespace, values, option_string=None):
217171
action = self.get_action(values, option_string)
218-
super(AddDiskPoolIscsiTargetCreateLuns, self).__call__(parser, namespace, action, option_string)
172+
super(AddDiskPoolIscsiTargetUpdateLuns, self).__call__(parser, namespace, action, option_string)
219173

220-
def get_action(self, values, option_string):
174+
def get_action(self, values, option_string): # pylint: disable=no-self-use
221175
try:
222176
properties = defaultdict(list)
223177
for (k, v) in (x.split('=', 1) for x in values):
@@ -227,23 +181,13 @@ def get_action(self, values, option_string):
227181
raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string))
228182
d = {}
229183
for k in properties:
230-
231184
kl = k.lower()
232-
233185
v = properties[k]
234-
235186
if kl == 'name':
236-
237187
d['name'] = v[0]
238-
239188
elif kl == 'managed-disk-azure-resource-id':
240-
241189
d['managed_disk_azure_resource_id'] = v[0]
242-
243190
else:
244-
raise CLIError(
245-
'Unsupported Key {} is provided for parameter luns. All possible keys are: name,'
246-
' managed-disk-azure-resource-id'.format(k)
247-
)
248-
191+
raise CLIError('Unsupported Key {} is provided for parameter luns. All possible keys are: name, '
192+
'managed-disk-azure-resource-id'.format(k))
249193
return d

0 commit comments

Comments
 (0)