Skip to content

Commit

Permalink
{Diskpool} Fix issue for generation issue (#3450)
Browse files Browse the repository at this point in the history
* refine help

* test pass

* fix style

* fix style
  • Loading branch information
Juliehzl authored Jun 2, 2021
1 parent 4f21314 commit f3e9c16
Show file tree
Hide file tree
Showing 18 changed files with 1,661 additions and 573 deletions.
4 changes: 4 additions & 0 deletions src/diskpool/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

0.1.1
++++++
* Fix generation issue.

0.1.0
++++++
* Initial release.
21 changes: 9 additions & 12 deletions src/diskpool/azext_diskpool/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
# pylint: disable=unused-import

import azext_diskpool._help
from azure.cli.core import AzCommandsLoader
from azext_diskpool.generated._help import helps # pylint: disable=unused-import
try:
from azext_diskpool.manual._help import helps # pylint: disable=reimported
except ImportError:
pass


class StoragePoolManagementCommandsLoader(AzCommandsLoader):
Expand All @@ -30,11 +33,8 @@ def load_command_table(self, args):
try:
from azext_diskpool.manual.commands import load_command_table as load_command_table_manual
load_command_table_manual(self, args)
except ImportError as e:
if e.name.endswith('manual.commands'):
pass
else:
raise e
except ImportError:
pass
return self.command_table

def load_arguments(self, command):
Expand All @@ -43,11 +43,8 @@ def load_arguments(self, command):
try:
from azext_diskpool.manual._params import load_arguments as load_arguments_manual
load_arguments_manual(self, command)
except ImportError as e:
if e.name.endswith('manual._params'):
pass
else:
raise e
except ImportError:
pass


COMMAND_LOADER_CLS = StoragePoolManagementCommandsLoader
7 changes: 2 additions & 5 deletions src/diskpool/azext_diskpool/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,5 @@
from .generated.action import * # noqa: F403
try:
from .manual.action import * # noqa: F403
except ImportError as e:
if e.name.endswith('manual.action'):
pass
else:
raise e
except ImportError:
pass
7 changes: 2 additions & 5 deletions src/diskpool/azext_diskpool/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,5 @@
from .generated.custom import * # noqa: F403
try:
from .manual.custom import * # noqa: F403
except ImportError as e:
if e.name.endswith('manual.custom'):
pass
else:
raise e
except ImportError:
pass
4 changes: 0 additions & 4 deletions src/diskpool/azext_diskpool/generated/_client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,5 @@ def cf_disk_pool(cli_ctx, *_):
return cf_diskpool_cl(cli_ctx).disk_pools


def cf_disk_pool_zone(cli_ctx, *_):
return cf_diskpool_cl(cli_ctx).disk_pool_zones


def cf_iscsi_target(cli_ctx, *_):
return cf_diskpool_cl(cli_ctx).iscsi_targets
5 changes: 0 additions & 5 deletions src/diskpool/azext_diskpool/generated/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
from knack.help_files import helps


helps['disk-pool'] = '''
type: group
short-summary: Manage Storage Pool Management
'''

helps['disk-pool'] = """
type: group
short-summary: Manage disk pool with diskpool
Expand Down
152 changes: 48 additions & 104 deletions src/diskpool/azext_diskpool/generated/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,19 @@
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------


# pylint: disable=protected-access

# pylint: disable=no-self-use


import argparse
from collections import defaultdict
from knack.util import CLIError


class AddDiskPoolUpdateDisks(argparse._AppendAction):
def __call__(self, parser, namespace, values, option_string=None):
action = self.get_action(values, option_string)

for item in action:
super(AddDiskPoolUpdateDisks, self).__call__(parser, namespace, item, option_string)

def get_action(self, values, option_string=None):
try:
value_chunk_list = [values[x: x + 1] for x in range(0, len(values), 1)]
value_list = []
for chunk in value_chunk_list:
id = chunk
value_list.append(
{
'id': id,
}
)
return value_list
except ValueError:
raise CLIError('usage error: {} NAME METRIC OPERATION VALUE'.format(option_string))


class AddSku(argparse.Action):
def __call__(self, parser, namespace, values, option_string=None):
action = self.get_action(values, option_string)
namespace.sku = action

def get_action(self, values, option_string):
def get_action(self, values, option_string): # pylint: disable=no-self-use
try:
properties = defaultdict(list)
for (k, v) in (x.split('=', 1) for x in values):
Expand All @@ -57,56 +29,68 @@ def get_action(self, values, option_string):
raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string))
d = {}
for k in properties:

kl = k.lower()

v = properties[k]

if kl == 'name':

d['name'] = v[0]

elif kl == 'tier':

d['tier'] = v[0]

else:
raise CLIError(
'Unsupported Key {} is provided for parameter sku. All possible keys are: name, tier'.format(k)
)

raise CLIError('Unsupported Key {} is provided for parameter sku. All possible keys are: name, tier'.
format(k))
return d


class AddDiskPoolCreateDisks(argparse._AppendAction):
def __call__(self, parser, namespace, values, option_string=None):
action = self.get_action(values, option_string)

for item in action:
super(AddDiskPoolCreateDisks, self).__call__(parser, namespace, item, option_string)

def get_action(self, values, option_string=None):
try:
value_chunk_list = [values[x: x + 1] for x in range(0, len(values), 1)]
value_chunk_list = [values[x:x + 1] for x in range(0, len(values), 1)]
value_list = []
for chunk in value_chunk_list:
id = chunk
id, = chunk
value_list.append(
{
'id': id,
'id': id
}
)
return value_list
except ValueError:
raise CLIError('usage error: {} NAME METRIC OPERATION VALUE'.format(option_string))


class AddDiskPoolIscsiTargetUpdateStaticAcls(argparse._AppendAction):
class AddDiskPoolUpdateDisks(argparse._AppendAction):
def __call__(self, parser, namespace, values, option_string=None):
action = self.get_action(values, option_string)
super(AddDiskPoolIscsiTargetUpdateStaticAcls, self).__call__(parser, namespace, action, option_string)
for item in action:
super(AddDiskPoolUpdateDisks, self).__call__(parser, namespace, item, option_string)

def get_action(self, values, option_string):
def get_action(self, values, option_string=None):
try:
value_chunk_list = [values[x:x + 1] for x in range(0, len(values), 1)]
value_list = []
for chunk in value_chunk_list:
id, = chunk
value_list.append(
{
'id': id
}
)
return value_list
except ValueError:
raise CLIError('usage error: {} NAME METRIC OPERATION VALUE'.format(option_string))


class AddDiskPoolIscsiTargetCreateStaticAcls(argparse._AppendAction):
def __call__(self, parser, namespace, values, option_string=None):
action = self.get_action(values, option_string)
super(AddDiskPoolIscsiTargetCreateStaticAcls, self).__call__(parser, namespace, action, option_string)

def get_action(self, values, option_string): # pylint: disable=no-self-use
try:
properties = defaultdict(list)
for (k, v) in (x.split('=', 1) for x in values):
Expand All @@ -116,34 +100,24 @@ def get_action(self, values, option_string):
raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string))
d = {}
for k in properties:

kl = k.lower()

v = properties[k]

if kl == 'initiator-iqn':

d['initiator_iqn'] = v[0]

elif kl == 'mapped-luns':

d['mapped_luns'] = v

else:
raise CLIError(
'Unsupported Key {} is provided for parameter static-acls. All possible keys are: initiator-iqn,'
' mapped-luns'.format(k)
)

raise CLIError('Unsupported Key {} is provided for parameter static_acls. All possible keys are: '
'initiator-iqn, mapped-luns'.format(k))
return d


class AddDiskPoolIscsiTargetUpdateLuns(argparse._AppendAction):
class AddDiskPoolIscsiTargetCreateLuns(argparse._AppendAction):
def __call__(self, parser, namespace, values, option_string=None):
action = self.get_action(values, option_string)
super(AddDiskPoolIscsiTargetUpdateLuns, self).__call__(parser, namespace, action, option_string)
super(AddDiskPoolIscsiTargetCreateLuns, self).__call__(parser, namespace, action, option_string)

def get_action(self, values, option_string):
def get_action(self, values, option_string): # pylint: disable=no-self-use
try:
properties = defaultdict(list)
for (k, v) in (x.split('=', 1) for x in values):
Expand All @@ -153,34 +127,24 @@ def get_action(self, values, option_string):
raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string))
d = {}
for k in properties:

kl = k.lower()

v = properties[k]

if kl == 'name':

d['name'] = v[0]

elif kl == 'managed-disk-azure-resource-id':

d['managed_disk_azure_resource_id'] = v[0]

else:
raise CLIError(
'Unsupported Key {} is provided for parameter luns. All possible keys are: name,'
' managed-disk-azure-resource-id'.format(k)
)

raise CLIError('Unsupported Key {} is provided for parameter luns. All possible keys are: name, '
'managed-disk-azure-resource-id'.format(k))
return d


class AddDiskPoolIscsiTargetCreateStaticAcls(argparse._AppendAction):
class AddDiskPoolIscsiTargetUpdateStaticAcls(argparse._AppendAction):
def __call__(self, parser, namespace, values, option_string=None):
action = self.get_action(values, option_string)
super(AddDiskPoolIscsiTargetCreateStaticAcls, self).__call__(parser, namespace, action, option_string)
super(AddDiskPoolIscsiTargetUpdateStaticAcls, self).__call__(parser, namespace, action, option_string)

def get_action(self, values, option_string):
def get_action(self, values, option_string): # pylint: disable=no-self-use
try:
properties = defaultdict(list)
for (k, v) in (x.split('=', 1) for x in values):
Expand All @@ -190,34 +154,24 @@ def get_action(self, values, option_string):
raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string))
d = {}
for k in properties:

kl = k.lower()

v = properties[k]

if kl == 'initiator-iqn':

d['initiator_iqn'] = v[0]

elif kl == 'mapped-luns':

d['mapped_luns'] = v

else:
raise CLIError(
'Unsupported Key {} is provided for parameter static-acls. All possible keys are: initiator-iqn,'
' mapped-luns'.format(k)
)

raise CLIError('Unsupported Key {} is provided for parameter static_acls. All possible keys are: '
'initiator-iqn, mapped-luns'.format(k))
return d


class AddDiskPoolIscsiTargetCreateLuns(argparse._AppendAction):
class AddDiskPoolIscsiTargetUpdateLuns(argparse._AppendAction):
def __call__(self, parser, namespace, values, option_string=None):
action = self.get_action(values, option_string)
super(AddDiskPoolIscsiTargetCreateLuns, self).__call__(parser, namespace, action, option_string)
super(AddDiskPoolIscsiTargetUpdateLuns, self).__call__(parser, namespace, action, option_string)

def get_action(self, values, option_string):
def get_action(self, values, option_string): # pylint: disable=no-self-use
try:
properties = defaultdict(list)
for (k, v) in (x.split('=', 1) for x in values):
Expand All @@ -227,23 +181,13 @@ def get_action(self, values, option_string):
raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string))
d = {}
for k in properties:

kl = k.lower()

v = properties[k]

if kl == 'name':

d['name'] = v[0]

elif kl == 'managed-disk-azure-resource-id':

d['managed_disk_azure_resource_id'] = v[0]

else:
raise CLIError(
'Unsupported Key {} is provided for parameter luns. All possible keys are: name,'
' managed-disk-azure-resource-id'.format(k)
)

raise CLIError('Unsupported Key {} is provided for parameter luns. All possible keys are: name, '
'managed-disk-azure-resource-id'.format(k))
return d
Loading

0 comments on commit f3e9c16

Please sign in to comment.