Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SQL] az sql instance-pool: Add instance pools command group #11721

Merged
merged 141 commits into from
Apr 28, 2020
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
13c8465
Added CLI functions with tests
Dec 31, 2019
48e690b
Resolved comments, added vnet-name to create
Jan 11, 2020
3a3b6fd
Fixed no_Wait call in create command
Jan 11, 2020
83df496
Changed active/passive voice issues and added enum to license type
Feb 5, 2020
4685279
Deleted existing recording file
Feb 5, 2020
790d5af
Merge branch 'dev' into cli_for_ip
rohands Feb 5, 2020
68e28be
Added test recording file
Feb 6, 2020
cc855e7
Merge branch 'cli_for_ip' of https://github.com/rohands/azure-cli int…
Feb 6, 2020
c09d4f7
upgrade azure-mgmt-version to 0.16.0
Juliehzl Feb 10, 2020
7c68e19
preview enabled for flexibility
Feb 10, 2020
9c1c370
Added CLI functions with tests
Dec 31, 2019
65db7c5
Resolved comments, added vnet-name to create
Jan 11, 2020
c7f375c
Fixed no_Wait call in create command
Jan 11, 2020
6a406cf
Changed active/passive voice issues and added enum to license type
Feb 5, 2020
4a80b03
Deleted existing recording file
Feb 5, 2020
2056186
Added test recording file
Feb 6, 2020
01ce464
init colorama in az --version to fix issue on windows (#11609)
fengzhou-msft Dec 19, 2019
65953fb
[Storage] Remove Preview for -enable-hierarchical-namespace (#11639)
Juliehzl Dec 29, 2019
aa26746
Adding new license type for az sql vm (#11570)
yareyes Dec 29, 2019
bd445ab
[Storage] Bump azure-mgmt-storage version to use api version 2019-06-…
Juliehzl Dec 30, 2019
5776312
ACR: deprecate os parameter (#11699)
shahzzzam Dec 31, 2019
04d059d
[App Service] On webapp up set httpsonly true (#11539)
ammanifold Dec 31, 2019
88be5f3
Fix typo in `KeyVaultMgmtScenarioTest` (#11722)
bim-msft Dec 31, 2019
3688593
[General][Minor]Update Code Onwers (#11705)
mmyyrroonn Dec 31, 2019
0294081
[Compute][Feature]az vm create: Support default data source settings …
mmyyrroonn Dec 31, 2019
22a4001
[RecoveryServices Backup]Added disk exclusion Feature for IAASVM (#11…
sambitratha Jan 2, 2020
b21ebc2
fix typo in authoring_commands.md (#11730)
Jan 2, 2020
dc0ef32
update codeowner for resource (#11739)
Juliehzl Jan 2, 2020
575013f
Fix the test of test_managedapp (#11727)
zhoxing-ms Jan 2, 2020
5cd1f31
Fix the test of test_resource_policyset (#11723)
zhoxing-ms Jan 2, 2020
f6450b4
add libc6-compat in dockerfile (#11742)
fengzhou-msft Jan 2, 2020
3a0dcf3
Update Cosmos DB python package (#11551)
shurd Jan 2, 2020
ff5ea20
[AppConfig] Adding new command 'set-keyvault' to kv subgroup (#11571)
avanigupta Jan 2, 2020
ef997f3
[AppConfig] Support Import/Export of features in yaml files (#11637)
avanigupta Jan 3, 2020
4afb97a
[App Service] Add az webapp up flag for HTML static sites (#11719)
ammanifold Jan 3, 2020
70e3ee9
[Compute] Feature issue #11203 Add new reapply command action for az …
arrownj Jan 3, 2020
08e8f50
Added new parameters for account blob service properties to manage de…
zhoxing-ms Jan 3, 2020
384707c
[misc] Add 'az version' (#11680)
jiasli Jan 3, 2020
cd195b5
Removing ReceiveDisabled status from EventHub and ServiceBus CLI doc …
basilhariri Jan 3, 2020
4ebc0e0
[RBAC] Return exit code 3 if app or sp doesn't exist (#11725)
jiasli Jan 3, 2020
00e8a48
update azure-cli version to 2.0.79 (#11762)
Jan 3, 2020
33d1f1c
add codeonwer for sql (#11777)
Juliehzl Jan 6, 2020
1780e56
fix: az monitor metric alert create. Fix test failure. (#11776)
mmyyrroonn Jan 6, 2020
434b450
updating BYOS commands to mark them as preview (#11755)
btardif Jan 6, 2020
34b5bd0
Fix: tox can use ADO default Python 2.7 (#11802)
Jan 9, 2020
21a528d
python3.8 migration for homebrew (#11803)
fengzhou-msft Jan 10, 2020
2bb3f47
[Storage] Support Table and Queue Encryption Service for storage acco…
Juliehzl Jan 10, 2020
b6e84a7
update CODEOWNERS (#11814)
Juliehzl Jan 10, 2020
8c19ded
[Webapp] Adding E2E tests for az webapp up (#11774)
panchagnula Jan 10, 2020
0f66071
[Doc] Try new features before release (#11784)
qwordy Jan 10, 2020
6f5c74a
Chore: move CredScansuppressions.json to codeownder guarded folder (#…
Jan 10, 2020
0e9029d
[Compute] disk update: Add --disk-encryption-set and --encryption-typ…
qwordy Jan 12, 2020
b40a37e
[AKS] Update example help text to reflect change of defaults to Stand…
seanmck Jan 13, 2020
654493e
Upgrade to Azure CLI 2.0.80 (#11826)
Jan 13, 2020
8777cd9
Add table output to backup commands (#11764)
sambitratha Jan 13, 2020
fef4d3a
Fix typo in History.rst (#11835)
ankitkumarr Jan 14, 2020
305bf6d
[IoT Central] Add new sku name to iotcentral (#11810)
poanchen Jan 14, 2020
9aee89a
[Core] Expose example_provider hook to include AI examples (#10987)
mirdaki Jan 14, 2020
d1238c0
fix: enabling monitoring for OpenShift managed cluster (#11778)
ganga1980 Jan 14, 2020
8cc55f1
Update fedora install troubleshooting doc (#11827)
fengzhou-msft Jan 14, 2020
dbcddb3
Fix: 'az redis update' operation for RDB/AOF enabled redis caches (#1…
MECHANDR Jan 14, 2020
93bb3c3
Chore: disable CredScan job temporary for ADO security concern (#11844)
Jan 14, 2020
bb38e1c
[KeyVault] Add example for container sas-definition (#11846)
bim-msft Jan 15, 2020
823938c
refact: update global --tags help content (#11847)
Jan 15, 2020
cc100eb
[Rest] Make --method -m optional (#11843)
jiasli Jan 15, 2020
3eb5247
[Core] Support filename and environment variable completion (#11817)
jiasli Jan 15, 2020
bebe8b4
Chore: add code owner for command module appconfig (#11860)
Jan 15, 2020
f0ee2b0
Update code owner (#11875)
jiasli Jan 16, 2020
7aa766c
[AppService] Fix #10476: Support appservice in 2019-03-01-hybrid prof…
Juliehzl Jan 16, 2020
bfac05f
Bump argcomplete version (#11866)
jiasli Jan 16, 2020
5e0672f
[AppConfig] Support import/export of keyvault ref from appservice (#1…
avanigupta Jan 17, 2020
c3f6073
fix test_get_clouds_concurrent on python 3.8 windows (#11864)
jiasli Jan 17, 2020
51c85a6
Documented sql db restore time format (#11838)
jaredmoo Jan 19, 2020
f28c3d2
[ARM] Fix az group export command does not support --query and --outp…
zhoxing-ms Jan 19, 2020
bf15a70
acr: add notary version compatibility checks (#11792)
Isaac-Lee-msft Jan 19, 2020
1bc435a
{Storage} Update help for pattern (#11782)
Juliehzl Jan 19, 2020
7f2f54d
[ARM] Fix the exit code of az group deployment validate when the veri…
zhoxing-ms Jan 19, 2020
f89ab44
[Storage]: Add a new command group `az storage share-rm` to use the M…
jsntcy Jan 19, 2020
1033ab5
delete cli_license_terms.md (#11902)
jiasli Jan 20, 2020
bbc5a01
[Network]az network dns record-set add/remove: show warning when a n…
mmyyrroonn Jan 20, 2020
2716d99
[ACR]: Add a prompt for command "az acr delete" to avoid accidental o…
Wwwsylvia Jan 20, 2020
deb8cfe
[Storage] Fix errors for storage blob update (#11907)
Juliehzl Jan 20, 2020
b1cbfe7
[AppConfig] Support import/export of all labels between 2 config stor…
avanigupta Jan 21, 2020
2fca734
{Storage} Refine help for storage data plane commands and log warning…
Juliehzl Jan 21, 2020
cb65e9f
[AppConfig] Validate key and feature names before setting and importi…
avanigupta Jan 21, 2020
c46779c
[IoT] Deprecated command group 'iot hub job' (#11794)
anusapan Jan 21, 2020
abe3550
[AppConfig] Expose sku and managed identity for GA (#11795)
shenmuxiaosen Jan 21, 2020
cba42c1
[Storage] Upgrade Azcopy for storage copy/remove and blob sync (#11874)
Juliehzl Jan 21, 2020
8fff40d
remove pydocumentdb (#11918)
fengzhou-msft Jan 22, 2020
2c5c6ce
[ACR] Add new commands `az acr taskrun show/list/delete` for show lis…
huanwu Jan 24, 2020
e88a711
[Azure Red Hat OpenShift] Add `monitor` subgroup to manage Log Analyt…
Jan 29, 2020
ca1e645
[CDN] Add support for Rules engine feature (#11854)
hytao Jan 30, 2020
7e3db70
[Security] Add new commands `az atp show` and `az atp update` to view…
libronsh Jan 30, 2020
a87fd96
{Network} az network application-gateway create: set https when key_v…
sputnik13 Jan 30, 2020
e022aa8
[SQL] BREAKING CHANGE: az sql db create: Remove WideWorldImportersStd…
jaredmoo Jan 30, 2020
fd467fd
[RBAC] BREAKING CHANGE: Fix #11883: `az role assignment create`: empt…
arrownj Jan 30, 2020
ded0433
{Packaging} Generate Homebrew formula by updating existing one by def…
fengzhou-msft Jan 30, 2020
dd1fec7
[ARM] Fix az resource list cannot use tag when there is a default loc…
zhoxing-ms Jan 30, 2020
50188cc
[ARM] Fix az resource tag crashed when the parameter --ids passed in …
zhoxing-ms Jan 30, 2020
f20761e
[Key Vault] Add a new command `az keyvault key download` for download…
bim-msft Jan 30, 2020
3aa8f2e
[Core][Profile] Add `tenant` parameter to `get_raw_token` (#11798)
jiasli Jan 30, 2020
9c007cf
Improve the error message of the conflict between tag and other filte…
zhoxing-ms Jan 30, 2020
4b6cb76
[Deployment Manager] Add `az deploymentmanager rollout/service/servic…
deveshguha Jan 30, 2020
4ba74ff
[SQL] Add new commands `sql db classification show/list/update/delete…
ranisha2 Jan 30, 2020
65d31f6
Improve intercluster isolation (#11848)
cristiklein Jan 30, 2020
7afca98
{Document} Modify PR template and document (#11913)
fengzhou-msft Jan 30, 2020
b971dca
Service Fabric Application commands (#10666)
a-santamaria Jan 30, 2020
1779468
[ACS] add support for the aks 1.16/1.17 in "aks browse" command. (#11…
andyliuliming Jan 31, 2020
426e29b
[Policy] Update policyinsights to 0.4.0 package (#11820)
pilor Jan 31, 2020
d794c75
[SQL] BREAKING CHANGE: `az sql dw create`: Deprecate `--zone-redundan…
jaredmoo Jan 31, 2020
9ba02c4
[BotService] Refactor tests, make bot create idempotent (#11935)
stevengum Jan 31, 2020
832de7f
[SQL] az sql db audit-policy: Fix for empty audit actions and groups …
ranisha2 Jan 31, 2020
9cdfd3c
{CI} Add PR title check (#11982)
fengzhou-msft Jan 31, 2020
9da3518
[ACS] aks create/update: add --load-balancer-outbound-ports and --loa…
gtracer Jan 31, 2020
d2b36f3
[functionapp]: add ability to create java apps on Linux (#11811)
ankitkumarr Jan 31, 2020
dc6a7d3
update azure-cli version to 2.0.81 (#12005)
Jan 31, 2020
11184ac
Re-run functionapp tests (#12006)
jiasli Jan 31, 2020
1808216
{CI} Enable CredScan task of Microsoft Security Code Analysis (Previe…
Feb 3, 2020
fb13977
{Monitor} az monitor diagnostic-settings category list: fix bug(#12020)
mmyyrroonn Feb 3, 2020
c1dc7a1
[AMS] az ams is GA now (#12004)
giakas Feb 4, 2020
3109764
{Compute} Fix typo in error message when attaching unmanaged disk (#1…
gaoruifeng Feb 4, 2020
f927a70
[KeyVault] az keyvault key create: add a new value `import` for param…
bim-msft Feb 4, 2020
b726d06
{Network} Clean up zone*.txt_export.txt files after tests (#12032)
jiasli Feb 5, 2020
bcc85ef
[ACS] aks create/update: add validation for --vnet-subnet-id argument…
Czhang0727 Feb 5, 2020
8cf30f0
[AppConfig] Revise help message to exclude unsupported key/label filt…
shenmuxiaosen Feb 5, 2020
2884873
{Resource} Bump to azure-mgmt-resource~=8.0.1 (#12050)
jiasli Feb 5, 2020
53965a7
[Compute] vm/vmss/availability-set update: add --ppg to allowing upda…
qwordy Feb 5, 2020
077c9b6
[Compute] vmss create: add --data-disk-iops and --data-disk-mbps (#11…
qwordy Feb 5, 2020
d1aae73
upgrade azure-mgmt-version to 0.16.0
Juliehzl Feb 10, 2020
df0c460
preview enabled for flexibility
Feb 10, 2020
242ce28
Added SQL changes to the changeList
Apr 13, 2020
c226f5d
Merging with upstream/dev
Apr 13, 2020
7d084cd
Merge remote-tracking branch 'upstream/dev' into cli_for_ip
Apr 14, 2020
1f684d2
Added --no-wait and list command to the tests
Apr 22, 2020
2caed06
Fixing lint issues
Apr 22, 2020
df33780
Resolving PR comments
Apr 22, 2020
ba47cd7
Added transformer to create command
Apr 22, 2020
a807ec2
Merge remote-tracking branch 'upstream/dev' into cli_for_ip
Apr 24, 2020
a74dfec
Updated network by syncing with upstream/dev
Apr 24, 2020
7143623
Removed description from HISTORY
Apr 24, 2020
a140481
Adding new test for list
Apr 28, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/azure-cli/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
Release History
===============

**SQL**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part should be removed and add it in description.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to change history.rst because we will generate it automatically.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh okay, where is the description section?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#11721 (comment) or title


* Add new cmdlets for Instance Pools 'sql instance-pool'
* Support create, delete, show, list and update for Instance Pools.

**AMS**

* az ams is now GA.
Expand Down
26 changes: 26 additions & 0 deletions src/azure-cli/azure/cli/command_modules/sql/_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,32 @@ def _apply_format(result, format_group):
# Apply format function to list
return [format_group(item) for item in obj_list]

###############################################
# sql instance-pool #
###############################################


def instance_pool_table_format(result):
'''
Formats an instance pool or list of instance pools as summary results for display with "-o table".
'''
def _instance_pool_table_format(result):
'''
Formats an instance pool or list of instance pools as summary results for display with "-o table".
'''
from collections import OrderedDict
sku = result['sku']
return OrderedDict([
rohands marked this conversation as resolved.
Show resolved Hide resolved
('name', result['name']),
('resourceGroup', result['resourceGroup']),
('location', result['location']),
('Capacity', result['vCores']),
('SKU Family', sku['family']),
('SKU Tier', sku['tier']),
('Tags', str(result['tags']) if result['tags'] else '')
])

return _apply_format(result, _instance_pool_table_format)

###############################################
# sql server #
Expand Down
59 changes: 59 additions & 0 deletions src/azure-cli/azure/cli/command_modules/sql/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,65 @@
short-summary: Updates the instance failover group.
"""

helps['sql instance-pool'] = """
type: group
short-summary: Manage instance pools.
"""

rohands marked this conversation as resolved.
Show resolved Hide resolved
helps['sql instance-pool create'] = """
type: command
short-summary: Create an instance pool.
examples:
- name: Example to create an instance pool (include --no-wait in the end to get an asynchronous experience)
rohands marked this conversation as resolved.
Show resolved Hide resolved
text: az sql instance-pool create -g resource_group_name -n instance_pool_name -l location --subnet /subscriptions/{SubID}/resourceGroups/{ResourceGroup}/providers/Microsoft.Network/virtualNetworks/{VNETName}/subnets/{SubnetName} --license-type LicenseIncluded --capacity 8 -e GeneralPurpose -f Gen5 --no-wait
- name: Example to create an instance pool with subnet name and vnet-name
text: az sql instance-pool create --license-type LicenseIncluded -l northcentralus -n myinstancepool -c 8 -e GeneralPurpose -f Gen5 -g billingPools --subnet mysubnetname --vnet-name myvnetname
"""

helps['sql instance-pool delete'] = """
type: command
short-summary: Delete an instance pool.
examples:
- name: Delete an instance pool
text: az sql instance-pool delete -g mygroup -n myinstancepool --yes
"""

helps['sql instance-pool list'] = """
type: command
short-summary: List available instance pools.
examples:
- name: List all instance pools in the current subscription.
text: az sql instance-pool list
- name: List all instance pools in a resource group.
text: az sql instance-pool list -g mygroup
"""

helps['sql instance-pool show'] = """
type: command
short-summary: Get the details for an instance pool.
examples:
- name: Get the details for an instance pool
text: az sql instance-pool show -g mygroup -n myinstancepool
"""

helps['sql instance-pool update'] = """
type: command
short-summary: Update an instance pool.
examples:
- name: Update an instance pool with new tags (make sure they are space separated if there are multiple tags)
text: az sql instance-pool update -n myinstancepool -g mygroup --tags mykey1=myvalue1 mykey2=myvalue2
- name: Clear the tags assigned to an instance pool
text: az sql instance-pool update -n myinstancepool -g mygroup --tags ""
"""

helps['sql instance-pool wait'] = """
type: command
short-summary: Wait for an instance pool to reach a desired state.
examples:
- name: Wait until an instance pool gets created.
text: az sql instance-pool wait -n myinstancepool -g mygroup --created
"""

helps['sql mi'] = """
type: group
short-summary: Manage SQL managed instances.
Expand Down
64 changes: 64 additions & 0 deletions src/azure-cli/azure/cli/command_modules/sql/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
ElasticPoolPerDatabaseSettings,
ImportExtensionRequest,
ExportRequest,
InstancePool,
ManagedDatabase,
ManagedInstance,
ManagedInstanceAdministrator,
Expand Down Expand Up @@ -1020,6 +1021,69 @@ def _configure_security_policy_storage_params(arg_ctx):
c.argument('allow_data_loss',
arg_type=allow_data_loss_param_type)

###############################################
# sql instance pool #
###############################################

with self.argument_context('sql instance-pool') as c:
c.argument('instance_pool_name',
options_list=['--name', '-n'],
help="Instance Pool Name")
rohands marked this conversation as resolved.
Show resolved Hide resolved

c.argument(
'tier',
arg_type=tier_param_type,
rohands marked this conversation as resolved.
Show resolved Hide resolved
required=True,
help='The edition component of the sku. Allowed value: GeneralPurpose.')

c.argument('family',
arg_type=family_param_type,
required=True,
help='The compute generation component of the sku. '
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as above. Please use get_enum_type()

'Allowed value: Gen5')

c.argument('license_type',
arg_type=get_enum_type(DatabaseLicenseType),
help='The license type to apply for this instance pool.')

with self.argument_context('sql instance-pool create') as c:
# Create args that will be used to build up the InstancePool object
create_args_for_complex_type(
rohands marked this conversation as resolved.
Show resolved Hide resolved
c, 'parameters', InstancePool, [
'location',
'license_type',
rohands marked this conversation as resolved.
Show resolved Hide resolved
'subnet_id',
'vcores',
'tags'
])

c.argument('vcores',
required=True,
arg_type=capacity_param_type,
help='Capacity of the instance pool in vcores.')

c.argument(
'subnet_id',
rohands marked this conversation as resolved.
Show resolved Hide resolved
rohands marked this conversation as resolved.
Show resolved Hide resolved
options_list=['--subnet'],
required=True,
help='Name or ID of the subnet that allows access to an Instance Pool. '
'If subnet name is provided, --vnet-name must be provided.')

# Create args that will be used to build up the Instance Pool's Sku object
create_args_for_complex_type(
c, 'sku', Sku, [
'family',
'name',
'tier',
])

c.ignore('name') # Hide sku name

c.extra('vnet_name',
options_list=['--vnet-name'],
help='The virtual network name',
validator=validate_subnet)

###############################################
# sql server #
###############################################
Expand Down
4 changes: 4 additions & 0 deletions src/azure-cli/azure/cli/command_modules/sql/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ def get_sql_firewall_rules_operations(cli_ctx, _):
return get_sql_management_client(cli_ctx).firewall_rules


def get_sql_instance_pools_operations(cli_ctx, _):
return get_sql_management_client(cli_ctx).instance_pools


def get_sql_recommended_elastic_pools_operations(cli_ctx, _):
return get_sql_management_client(cli_ctx).recommended_elastic_pools

Expand Down
14 changes: 12 additions & 2 deletions src/azure-cli/azure/cli/command_modules/sql/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,31 @@ def validate_subnet(cmd, namespace):
from msrestazure.tools import resource_id, is_valid_resource_id
from azure.cli.core.commands.client_factory import get_subscription_id

subnet = namespace.virtual_network_subnet_id
is_instance_pool = False
rohands marked this conversation as resolved.
Show resolved Hide resolved
if hasattr(namespace, "subnet_id"):
rohands marked this conversation as resolved.
Show resolved Hide resolved
is_instance_pool = True
subnet = namespace.subnet_id
else:
subnet = namespace.virtual_network_subnet_id

subnet_is_id = is_valid_resource_id(subnet)
vnet = namespace.vnet_name

if (subnet_is_id and not vnet) or (not subnet and not vnet):
pass
elif subnet and not subnet_is_id and vnet:
namespace.virtual_network_subnet_id = resource_id(
virtual_network_subnet_id = resource_id(
subscription=get_subscription_id(cmd.cli_ctx),
resource_group=namespace.resource_group_name,
namespace='Microsoft.Network',
type='virtualNetworks',
name=vnet,
child_type_1='subnets',
child_name_1=subnet)
if is_instance_pool:
namespace.subnet_id = virtual_network_subnet_id
else:
namespace.virtual_network_subnet_id = virtual_network_subnet_id
else:
raise CLIError('incorrect usage: [--subnet ID | --subnet NAME --vnet-name NAME]')
delattr(namespace, 'vnet_name')
Expand Down
22 changes: 22 additions & 0 deletions src/azure-cli/azure/cli/command_modules/sql/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
elastic_pool_table_format,
elastic_pool_edition_table_format,
firewall_rule_table_format,
instance_pool_table_format,
server_table_format,
usage_table_format,
LongRunningOperationResultTransform,
Expand All @@ -36,6 +37,7 @@
get_sql_encryption_protectors_operations,
get_sql_failover_groups_operations,
get_sql_firewall_rules_operations,
get_sql_instance_pools_operations,
get_sql_managed_databases_operations,
get_sql_managed_instance_azure_ad_administrators_operations,
get_sql_managed_instance_encryption_protectors_operations,
Expand Down Expand Up @@ -345,6 +347,26 @@ def load_command_table(self, _):
g.command('delete', 'delete')
g.custom_command('set-primary', 'failover_group_failover')

###############################################
# sql instance-pool #
###############################################

instance_pools_operations = CliCommandType(
operations_tmpl='azure.mgmt.sql.operations#InstancePoolsOperations.{}',
client_factory=get_sql_instance_pools_operations)
with self.command_group('sql instance-pool', instance_pools_operations, client_factory=get_sql_instance_pools_operations, is_preview=True) as g:
g.command('show', 'get',
rohands marked this conversation as resolved.
Show resolved Hide resolved
table_transformer=instance_pool_table_format)
g.custom_command('list', 'instance_pool_list',
table_transformer=instance_pool_table_format)
g.command('update', 'update')
g.command('delete', 'delete', supports_no_wait=True, confirmation=True)
g.custom_command(
rohands marked this conversation as resolved.
Show resolved Hide resolved
'create',
'instance_pool_create',
supports_no_wait=True)
g.wait_command('wait')

###############################################
# sql server #
###############################################
Expand Down
76 changes: 76 additions & 0 deletions src/azure-cli/azure/cli/command_modules/sql/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1898,6 +1898,82 @@ def elastic_pool_list_capabilities(

return editions

###############################################
# sql instance-pool #
###############################################


def instance_pool_list(
client,
resource_group_name=None):
'''
Lists servers in a resource group or subscription
'''

if resource_group_name:
# List all instance pools in the resource group
return client.list_by_resource_group(
resource_group_name=resource_group_name)

# List all instance pools in the subscription
return client.list()


def instance_pool_create(
cmd,
client,
instance_pool_name,
resource_group_name,
no_wait=False,
sku=None,
**kwargs):
'''
Creates a new instance pool
'''

kwargs['sku'] = _find_instance_pool_sku_from_capabilities(
cmd.cli_ctx, kwargs['location'], sku)

return sdk_no_wait(no_wait, client.create_or_update,
instance_pool_name=instance_pool_name,
resource_group_name=resource_group_name,
parameters=kwargs)


def _find_instance_pool_sku_from_capabilities(cli_ctx, location, sku):
'''
Validate if the sku family and edition input by user are permissible in the region using
capabilities API and get the SKU name
'''

logger.debug('_find_instance_pool_sku_from_capabilities input: %s', sku)

# Get location capability
loc_capability = _get_location_capability(
cli_ctx, location, CapabilityGroup.supported_managed_instance_versions)

# Get default server version capability
managed_instance_version_capability = _get_default_capability(
loc_capability.supported_managed_instance_versions)

# Find edition capability, based on requested sku properties
edition_capability = _find_edition_capability(
sku, managed_instance_version_capability.supported_instance_pool_editions)

# Find family level capability, based on requested sku properties
_find_family_capability(
sku, edition_capability.supported_families)

result = Sku(
name="instance-pool",
tier=sku.tier,
family=sku.family)

logger.debug(
'_find_instance_pool_sku_from_capabilities return: %s',
result)
return result


###############################################
# sql server #
Expand Down
Loading