Skip to content

Commit

Permalink
[NetAppFiles] az netappfiles volume create: Fix subnet id as resour…
Browse files Browse the repository at this point in the history
…ce id (#29813)

* fix subnetid as resourceid

* remove unused paramter vnet from volume update, msrestazure.tools to azure.mgmt.core.tools

* style

* empty

* add --vnet again to avoid breaking

* add --vnet again to avoid breaking2

* empty

* empty

* empty
  • Loading branch information
audunn authored Sep 12, 2024
1 parent 71e98cd commit a84d470
Show file tree
Hide file tree
Showing 6 changed files with 1,500 additions and 389 deletions.
27 changes: 11 additions & 16 deletions src/azure-cli/azure/cli/command_modules/netappfiles/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from knack.log import get_logger
from azure.cli.core.azclierror import ValidationError
from azure.cli.core.aaz import has_value, AAZJsonSelector
from msrestazure.tools import is_valid_resource_id, parse_resource_id
from azure.mgmt.core.tools import is_valid_resource_id, parse_resource_id
from .aaz.latest.netappfiles import UpdateNetworkSiblingSet as _UpdateNetworkSiblingSet
from .aaz.latest.netappfiles.account import Create as _AccountCreate, Update as _AccountUpdate
from .aaz.latest.netappfiles.account.ad import Add as _ActiveDirectoryAdd, List as _ActiveDirectoryList, Update as _ActiveDirectoryUpdate
Expand Down Expand Up @@ -332,26 +332,21 @@ def pre_operations(self):
subnet_rg = args.resource_group
subs_id = self.ctx.subscription_id
vnetArg = args.vnet.to_serialized_data()
# determine vnet - supplied value can be name or ARM resource Id
if is_valid_resource_id(vnetArg):
resource_parts = parse_resource_id(vnetArg)
vnetArg = resource_parts['resource_name']
subnet_rg = resource_parts['resource_group']

# determine subnet - supplied value can be name or ARM resource Id
if is_valid_resource_id(args.subnet_id.to_serialized_data()):
resource_parts = parse_resource_id(args.subnet_id.to_serialized_data())
subnet = resource_parts['resource_name']
subnet_rg = resource_parts['resource_group']

args.subnet_id = f"/subscriptions/{subs_id}/resourceGroups/{subnet_rg}/providers/Microsoft.Network/virtualNetworks/{vnetArg}/subnets/{subnet}"
if not is_valid_resource_id(args.subnet_id.to_serialized_data()):
if is_valid_resource_id(vnetArg):
# determine vnet - supplied value can be name or ARM resource Id
resource_parts = parse_resource_id(vnetArg)
vnetArg = resource_parts['resource_name']
subnet_rg = resource_parts['resource_group']
args.subnet_id = f"/subscriptions/{subs_id}/resourceGroups/{subnet_rg}/providers/Microsoft.Network/virtualNetworks/{vnetArg}/subnets/{subnet}"

# if NFSv4 is specified then the export policy must reflect this
# the RP ordinarily only creates a default setting NFSv3.
logger.debug("ANF log: ProtocolTypes rules len:%s", len(args.protocol_types))

for protocl in args.protocol_types:
logger.debug("ANF log: ProtocolType: %s", protocl)
for protocol in args.protocol_types:
logger.debug("ANF log: ProtocolType: %s", protocol)

logger.debug("ANF log: exportPolicy rules len:%s", len(args.export_policy_rules))

Expand Down Expand Up @@ -426,7 +421,7 @@ def pre_operations(self):
class VolumeUpdate(_VolumeUpdate):
@classmethod
def _build_arguments_schema(cls, *args, **kwargs):
from azure.cli.core.aaz import AAZStrArg, AAZIntArgFormat
from azure.cli.core.aaz import AAZIntArgFormat, AAZStrArg
args_schema = super()._build_arguments_schema(*args, **kwargs)
args_schema.vnet = AAZStrArg(
options=["--vnet"],
Expand Down
Loading

0 comments on commit a84d470

Please sign in to comment.