示例#1
0
def cli_cosmosdb_managed_cassandra_cluster_create(
        client,
        resource_group_name,
        cluster_name,
        location,
        delegated_management_subnet_id,
        tags=None,
        identity_type='None',
        cluster_name_override=None,
        initial_cassandra_admin_password=None,
        client_certificates=None,
        external_gossip_certificates=None,
        external_seed_nodes=None,
        restore_from_backup_id=None,
        cassandra_version=None,
        authentication_method=None,
        hours_between_backups=None,
        repair_enabled=None):
    """Creates an Azure Managed Cassandra Cluster"""

    if initial_cassandra_admin_password is None and external_gossip_certificates is None:
        raise CLIError(
            'At least one out of the Initial Cassandra Admin Password or External Gossip Certificates is required.'
        )

    if initial_cassandra_admin_password is not None and external_gossip_certificates is not None:
        raise CLIError(
            'Only one out of the Initial Cassandra Admin Password or External Gossip Certificates has to be specified.'
        )

    cluster_properties = ClusterResourceProperties(
        delegated_management_subnet_id=delegated_management_subnet_id,
        cluster_name_override=cluster_name_override,
        initial_cassandra_admin_password=initial_cassandra_admin_password,
        client_certificates=client_certificates,
        external_gossip_certificates=external_gossip_certificates,
        external_seed_nodes=external_seed_nodes,
        restore_from_backup_id=restore_from_backup_id,
        cassandra_version=cassandra_version,
        authentication_method=authentication_method,
        hours_between_backups=hours_between_backups,
        repair_enabled=repair_enabled)

    managed_service_identity_parameter = ManagedCassandraManagedServiceIdentity(
        type=identity_type)

    cluster_resource_create_update_parameters = ClusterResource(
        location=location,
        tags=tags,
        identity=managed_service_identity_parameter,
        properties=cluster_properties)

    return client.begin_create_update(
        resource_group_name, cluster_name,
        cluster_resource_create_update_parameters)
示例#2
0
def cli_cosmosdb_managed_cassandra_cluster_create(
        client,
        resource_group_name,
        cluster_name,
        location,
        delegated_management_subnet_id,
        tags=None,
        identity=None,
        cluster_name_override=None,
        initial_cassandra_admin_password=None,
        client_certificates=None,
        external_gossip_certificates=None,
        external_seed_nodes=None,
        restore_from_backup_id=None,
        cassandra_version=None,
        authentication_method=None,
        hours_between_backups=None,
        repair_enabled=None):
    """Creates an Azure Managed Cassandra Cluster"""

    cluster_properties = ClusterResourceProperties(
        delegated_management_subnet_id=delegated_management_subnet_id,
        cluster_name_override=cluster_name_override,
        initial_cassandra_admin_password=initial_cassandra_admin_password,
        client_certificates=client_certificates,
        external_gossip_certificates=external_gossip_certificates,
        external_seed_nodes=external_seed_nodes,
        restore_from_backup_id=restore_from_backup_id,
        cassandra_version=cassandra_version,
        authentication_method=authentication_method,
        hours_between_backups=hours_between_backups,
        repair_enabled=repair_enabled)

    cluster_resource_create_update_parameters = ClusterResource(
        location=location,
        tags=tags,
        identity=identity,
        properties=cluster_properties)

    return client.create_update(resource_group_name, cluster_name,
                                cluster_resource_create_update_parameters)
示例#3
0
def cli_cosmosdb_managed_cassandra_cluster_update(
        client,
        resource_group_name,
        cluster_name,
        tags=None,
        identity_type=None,
        client_certificates=None,
        external_gossip_certificates=None,
        external_seed_nodes=None,
        cassandra_version=None,
        authentication_method=None,
        hours_between_backups=None,
        repair_enabled=None):
    """Updates an Azure Managed Cassandra Cluster"""

    cluster_resource = client.get(resource_group_name, cluster_name)

    if client_certificates is None:
        client_certificates = cluster_resource.properties.client_certificates

    if external_gossip_certificates is not None:
        external_gossip_certificates = cluster_resource.properties.external_gossip_certificates

    if external_seed_nodes is None:
        external_seed_nodes = cluster_resource.properties.external_seed_nodes

    if cassandra_version is None:
        cassandra_version = cluster_resource.properties.cassandra_version

    if authentication_method is None:
        authentication_method = cluster_resource.properties.authentication_method

    if hours_between_backups is None:
        hours_between_backups = cluster_resource.properties.hours_between_backups

    if repair_enabled is None:
        repair_enabled = cluster_resource.properties.repair_enabled

    if tags is None:
        tags = cluster_resource.tags

    identity = cluster_resource.identity

    if identity_type is not None:
        identity = ManagedCassandraManagedServiceIdentity(type=identity_type)

    cluster_properties = ClusterResourceProperties(
        provisioning_state=cluster_resource.properties.provisioning_state,
        restore_from_backup_id=cluster_resource.properties.
        restore_from_backup_id,
        delegated_management_subnet_id=cluster_resource.properties.
        delegated_management_subnet_id,
        cassandra_version=cassandra_version,
        cluster_name_override=cluster_resource.properties.
        cluster_name_override,
        authentication_method=authentication_method,
        initial_cassandra_admin_password=cluster_resource.properties.
        initial_cassandra_admin_password,
        hours_between_backups=hours_between_backups,
        repair_enabled=repair_enabled,
        client_certificates=client_certificates,
        external_gossip_certificates=external_gossip_certificates,
        gossip_certificates=cluster_resource.properties.gossip_certificates,
        external_seed_nodes=cluster_resource.properties.external_seed_nodes,
        seed_nodes=cluster_resource.properties.seed_nodes)

    cluster_resource_create_update_parameters = ClusterResource(
        location=cluster_resource.location,
        tags=tags,
        identity=identity,
        properties=cluster_properties)

    return client.begin_create_update(
        resource_group_name, cluster_name,
        cluster_resource_create_update_parameters)