Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f621f86
managed cassandra commands for cli extension
vivek67 Oct 11, 2021
d12f6cf
remove node-status, add backups
vivek67 Oct 12, 2021
4ca4287
fix style and add backup command
vivek67 Oct 12, 2021
2cd4974
AuthenticationMethod param
vivek67 Oct 12, 2021
bdaacbc
add sku, availability and idenitty parameters
vivek67 Oct 13, 2021
2a251c9
bugfix
vivek67 Oct 19, 2021
25521cd
add backup key uri
vivek67 Oct 21, 2021
e283dfc
python vendor sdk changes
vivek67 Oct 21, 2021
5c587c1
bugfix
vivek67 Oct 21, 2021
d0aa608
recorded scenario tests
vivek67 Oct 21, 2021
89f1bff
bugfix on cassandra_stop_start
vivek67 Oct 22, 2021
9107280
update invoke-command arguments
vivek67 Oct 22, 2021
3171066
bugfix
vivek67 Nov 15, 2021
f243c2c
conditionally set ldap properties
vivek67 Nov 17, 2021
2dcd74b
ldap property bugfix
vivek67 Nov 22, 2021
dace7b2
linter fix
vivek67 Nov 22, 2021
0eac2cd
linter fix
vivek67 Nov 22, 2021
39c39b6
remove public commands from preview
vivek67 Dec 8, 2021
015d8c5
linter fix in help text
vivek67 Dec 9, 2021
6961021
linter fix
vivek67 Dec 9, 2021
54607d3
use backup show and backup list
vivek67 Dec 9, 2021
f701de0
preview python sdk
vivek67 Dec 10, 2021
bb30168
Merge branch 'main' into users/visunda/preview-managedCassandra
vivek67 Dec 10, 2021
5bce4be
bugfix
vivek67 Dec 14, 2021
5743b79
removing whitespace
vivek67 Dec 15, 2021
f90026d
Merge branch 'main' into users/visunda/preview-managedCassandra
vivek67 Dec 15, 2021
f890d75
Update History.rst
vivek67 Dec 15, 2021
46e14a0
update setup.py
vivek67 Dec 15, 2021
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
4 changes: 4 additions & 0 deletions src/cosmosdb-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Release History
===============
0.11.0
++++++
* Add Ldap support for Managed Instance for Apache Cassandra.

0.10.0
++++++
* Adding support for Services APIs and Graph Resources.
Expand Down
32 changes: 26 additions & 6 deletions src/cosmosdb-preview/azext_cosmosdb_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,36 @@
az managed-cassandra cluster list
"""

helps['managed-cassandra cluster node-status'] = """
helps['managed-cassandra cluster backup list'] = """
type: command
short-summary: Gets Status of all the nodes in all the datacenters in a given Cluster.
short-summary: List the backups of this cluster that are available to restore.
examples:
- name: This command gets the status of all the nodes in this cluster. By default a json is returned.
- name: This command lists the backups of this cluster that are available to restore.
text: |
az managed-cassandra cluster node-status --resource-group MyResourceGroup --cluster-name MyCluster
- name: This command gets the status of all the nodes in this cluster. When a table output is specified only one token is displayed. Use json output to get all the tokens.
az managed-cassandra cluster backup list --resource-group MyResourceGroup --cluster-name MyCluster
"""

helps['managed-cassandra cluster backup show'] = """
type: command
short-summary: Get a managed cassandra backup resource of this cluster
examples:
- name: Gets a managed cassandra backup resource.
text: |
az managed-cassandra cluster backup show --resource-group MyResourceGroup --cluster-name MyCluster --backup-id BackUpId
"""

helps['managed-cassandra cluster backup'] = """
type: group
short-summary: Azure Managed Cassandra cluster Backup.
"""

helps['managed-cassandra cluster invoke-command'] = """
type: command
short-summary: Invoke a command like nodetool for cassandra maintenance.
examples:
- name: This command runs nodetool with these arguments in a host node of the cluster.
text: |
az managed-cassandra cluster node-status --resource-group MyResourceGroup --cluster-name MyCluster --output table
az managed-cassandra cluster invoke-command --resource-group MyResourceGroup --cluster-name MyCluster --host "10.0.1.12" --command-name "nodetool" --arguments arg1="value1" arg2="value2" arg3="value3"
"""

helps['managed-cassandra datacenter'] = """
Expand Down
31 changes: 27 additions & 4 deletions src/cosmosdb-preview/azext_cosmosdb_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,25 @@
from azext_cosmosdb_preview._validators import (
validate_gossip_certificates,
validate_client_certificates,
validate_server_certificates,
validate_seednodes,
validate_node_count)

from azext_cosmosdb_preview.actions import (
InvokeCommandArgumentsAddAction)


def load_arguments(self, _):
from azure.cli.core.commands.parameters import tags_type
from azure.cli.core.commands.parameters import tags_type, get_enum_type, get_three_state_flag

# Managed Cassandra Cluster
for scope in [
'managed-cassandra cluster create',
'managed-cassandra cluster update',
'managed-cassandra cluster show',
'managed-cassandra cluster delete',
'managed-cassandra cluster node-status']:
'managed-cassandra cluster backup list',
'managed-cassandra cluster backup show']:
with self.argument_context(scope) as c:
c.argument('cluster_name', options_list=['--cluster-name', '-c'], help="Cluster Name", required=True)

Expand All @@ -33,13 +38,13 @@ def load_arguments(self, _):
c.argument('tags', arg_type=tags_type)
c.argument('external_gossip_certificates', nargs='+', validator=validate_gossip_certificates, options_list=['--external-gossip-certificates', '-e'], help="A list of certificates that the managed cassandra data center's should accept.")
c.argument('cassandra_version', help="The version of Cassandra chosen.")
c.argument('authentication_method', help="Authentication mode can be None or Cassandra. If None, no authentication will be required to connect to the Cassandra API. If Cassandra, then passwords will be used.")
c.argument('authentication_method', arg_type=get_enum_type(['None', 'Cassandra', 'Ldap']), help="Authentication mode can be None, Cassandra or Ldap. If None, no authentication will be required to connect to the Cassandra API. If Cassandra, then passwords will be used. Ldap is in preview")
c.argument('hours_between_backups', help="The number of hours between backup attempts.")
c.argument('repair_enabled', help="Enables automatic repair.")
c.argument('client_certificates', nargs='+', validator=validate_client_certificates, help="If specified, enables client certificate authentication to the Cassandra API.")
c.argument('gossip_certificates', help="A list of certificates that should be accepted by on-premise data centers.")
c.argument('external_seed_nodes', nargs='+', validator=validate_seednodes, help="A list of ip addresses of the seed nodes of on-premise data centers.")
c.argument('identity', help="Identity used to authenticate.")
c.argument('identity_type', options_list=['--identity-type'], arg_type=get_enum_type(['None', 'SystemAssigned']), help="Type of identity used for Customer Managed Disk Key.")

# Managed Cassandra Cluster
with self.argument_context('managed-cassandra cluster create') as c:
Expand All @@ -49,6 +54,11 @@ def load_arguments(self, _):
c.argument('restore_from_backup_id', help="The resource id of a backup. If provided on create, the backup will be used to prepopulate the cluster. The cluster data center count and node counts must match the backup.")
c.argument('cluster_name_override', help="If a cluster must have a name that is not a valid azure resource name, this field can be specified to choose the Cassandra cluster name. Otherwise, the resource name will be used as the cluster name.")

# Managed Cassandra Cluster
for scope in ['managed-cassandra cluster backup show']:
with self.argument_context(scope) as c:
c.argument('backup_id', options_list=['--backup-id'], help="The resource id of the backup", required=True)

# Managed Cassandra Datacenter
for scope in [
'managed-cassandra datacenter create',
Expand All @@ -68,12 +78,25 @@ def load_arguments(self, _):
c.argument('base64_encoded_cassandra_yaml_fragment', options_list=['--base64-encoded-cassandra-yaml-fragment', '-b'], help="This is a Base64 encoded yaml file that is a subset of cassandra.yaml. Supported fields will be honored and others will be ignored.")
c.argument('data_center_location', options_list=['--data-center-location', '-l'], help="The region where the virtual machine for this data center will be located.")
c.argument('delegated_subnet_id', options_list=['--delegated-subnet-id', '-s'], help="The resource id of a subnet where ip addresses of the Cassandra virtual machines will be allocated. This must be in the same region as data_center_location.")
c.argument('managed_disk_customer_key_uri', options_list=['--managed-disk-customer-key-uri', '-k'], help="Key uri to use for encryption of managed disks. Ensure the system assigned identity of the cluster has been assigned appropriate permissions(key get/wrap/unwrap permissions) on the key.")
c.argument('backup_storage_customer_key_uri', options_list=['--backup-storage-customer-key-uri', '-p'], help="Indicates the Key Uri of the customer key to use for encryption of the backup storage account.")
c.argument('server_hostname', options_list=['--ldap-server-hostname'], help="Hostname of the LDAP server.")
c.argument('server_port', options_list=['--ldap-server-port'], help="Port of the LDAP server.")
c.argument('service_user_distinguished_name', options_list=['--ldap-user-name'], help="Distinguished name of the look up user account, who can look up user details on authentication.")
c.argument('service_user_password', options_list=['--ldap-user-password'], help="Password of the look up user.")
c.argument('search_base_distinguished_name', options_list=['--ldap-base-name'], help="Distinguished name of the object to start the recursive search of users from.")
c.argument('search_filter_template', options_list=['--ldap-filter-template'], help="Template to use for searching. Defaults to (cn=%s) where %s will be replaced by the username used to login.")
c.argument('server_certificates', nargs='+', validator=validate_server_certificates, options_list=['--ldap-certificates'], help="LDAP server certificate.")

# Managed Cassandra Datacenter
with self.argument_context('managed-cassandra datacenter create') as c:
c.argument('data_center_location', options_list=['--data-center-location', '-l'], help="Azure Location of the Datacenter", required=True)
c.argument('delegated_subnet_id', options_list=['--delegated-subnet-id', '-s'], help="The resource id of a subnet where ip addresses of the Cassandra virtual machines will be allocated. This must be in the same region as data_center_location.", required=True)
c.argument('node_count', options_list=['--node-count', '-n'], validator=validate_node_count, help="The number of Cassandra virtual machines in this data center. The minimum value is 3.", required=True)
c.argument('sku', options_list=['--sku'], help="Virtual Machine SKU used for data centers. Default value is Standard_DS14_v2")
c.argument('disk_sku', options_list=['--disk-sku'], help="Disk SKU used for data centers. Default value is P30.")
c.argument('disk_capacity', options_list=['--disk-capacity'], help="Number of disk used for data centers. Default value is 4.")
c.argument('availability_zone', options_list=['--availability-zone', '-z'], arg_type=get_three_state_flag(), help="If the data center haves Availability Zone feature, apply it to the Virtual Machine ScaleSet that host the data center virtual machines.")

# Managed Cassandra Datacenter
with self.argument_context('managed-cassandra datacenter list') as c:
Expand Down
6 changes: 6 additions & 0 deletions src/cosmosdb-preview/azext_cosmosdb_preview/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ def validate_client_certificates(ns):
ns.client_certificates = get_certificates(ns.client_certificates)


def validate_server_certificates(ns):
""" Extracts multiple comma-separated certificates """
if ns.server_certificates is not None:
ns.server_certificates = get_certificates(ns.server_certificates)


def get_certificates(input_certificates):
from azext_cosmosdb_preview.vendored_sdks.azure_mgmt_cosmosdb.models import Certificate
certificates = []
Expand Down
13 changes: 13 additions & 0 deletions src/cosmosdb-preview/azext_cosmosdb_preview/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,16 @@ def __call__(self, parser, namespace, values, option_string=None):

iso_string = dt_val.isoformat()
setattr(namespace, self.dest, iso_string)


# pylint: disable=protected-access
class InvokeCommandArgumentsAddAction(argparse._AppendAction):
def __call__(self, parser, namespace, values, option_string=None):
kwargs = {}
for item in values:
try:
key, value = item.split('=', 1)
kwargs[key] = value
except ValueError:
raise CLIError('usage error: {} KEY=VALUE [KEY=VALUE ...]'.format(option_string))
namespace.arguments = kwargs
10 changes: 4 additions & 6 deletions src/cosmosdb-preview/azext_cosmosdb_preview/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
cf_graph_resources,
cf_service
)
from azext_cosmosdb_preview._format import (
amc_node_status_table_format
)


def load_command_table(self, _):
Expand All @@ -34,15 +31,16 @@ def load_command_table(self, _):
operations_tmpl='azext_cosmosdb_preview.vendored_sdks.azure_mgmt_cosmosdb.operations#CassandraDataCentersOperations.{}',
client_factory=cf_cassandra_data_center)

with self.command_group('managed-cassandra cluster', cosmosdb_managed_cassandra_cluster_sdk, client_factory=cf_cassandra_cluster, is_preview=True) as g:
with self.command_group('managed-cassandra cluster', cosmosdb_managed_cassandra_cluster_sdk, client_factory=cf_cassandra_cluster) as g:
g.custom_command('create', 'cli_cosmosdb_managed_cassandra_cluster_create', supports_no_wait=True)
g.custom_command('update', 'cli_cosmosdb_managed_cassandra_cluster_update', supports_no_wait=True)
g.custom_command('node-status', 'cli_cosmosdb_managed_cassandra_fetch_node_status', table_transformer=amc_node_status_table_format, supports_no_wait=True)
g.custom_command('backup list', 'cli_cosmosdb_managed_cassandra_cluster_list_backup', is_preview=True)
g.custom_command('backup show', 'cli_cosmosdb_managed_cassandra_cluster_show_backup', is_preview=True)
g.custom_command('list', 'cli_cosmosdb_managed_cassandra_cluster_list')
g.show_command('show', 'get')
g.command('delete', 'begin_delete', confirmation=True, supports_no_wait=True)

with self.command_group('managed-cassandra datacenter', cosmosdb_managed_cassandra_datacenter_sdk, client_factory=cf_cassandra_data_center, is_preview=True) as g:
with self.command_group('managed-cassandra datacenter', cosmosdb_managed_cassandra_datacenter_sdk, client_factory=cf_cassandra_data_center) as g:
g.custom_command('create', 'cli_cosmosdb_managed_cassandra_datacenter_create', supports_no_wait=True)
g.custom_command('update', 'cli_cosmosdb_managed_cassandra_datacenter_update', supports_no_wait=True)
g.command('list', 'list')
Expand Down
Loading