|
21 | 21 | CONST_STORAGE_POOL_TYPE_AZURE_DISK, |
22 | 22 | CONST_STORAGE_POOL_TYPE_ELASTIC_SAN, |
23 | 23 | CONST_STORAGE_POOL_TYPE_EPHEMERAL_DISK, |
| 24 | + CONST_STORAGE_POOL_TYPE_DISTRIBUTED_CACHE, |
24 | 25 | ) |
25 | 26 | from azext_aks_preview.azurecontainerstorage._helpers import ( |
26 | 27 | get_vm_sku_details |
@@ -571,6 +572,114 @@ def validate_disable_azure_container_storage_params( |
571 | 572 | ) |
572 | 573 |
|
573 | 574 |
|
| 575 | +def validate_enable_distributed_cache_params( |
| 576 | + enablement_option, |
| 577 | + is_extension_installed, |
| 578 | + storage_pool_name, |
| 579 | + storage_pool_sku, |
| 580 | + storage_pool_option, |
| 581 | + storage_pool_size, |
| 582 | + ephemeral_disk_volume_type, |
| 583 | + ephemeral_disk_nvme_perf_tier, |
| 584 | + container_storage_version=None, |
| 585 | +): |
| 586 | + # Distributed cache has no storage pool construct, so none of the storage |
| 587 | + # pool parameters are supported. |
| 588 | + enablement_option_arr = enablement_option if isinstance(enablement_option, list) else [enablement_option] |
| 589 | + other_pool_types = [ |
| 590 | + opt for opt in enablement_option_arr |
| 591 | + if opt != CONST_STORAGE_POOL_TYPE_DISTRIBUTED_CACHE |
| 592 | + ] |
| 593 | + if other_pool_types: |
| 594 | + options_display = "', '".join(other_pool_types) |
| 595 | + raise InvalidArgumentValueError( |
| 596 | + f"'{CONST_STORAGE_POOL_TYPE_DISTRIBUTED_CACHE}' cannot be combined with other storage " |
| 597 | + f"options ('{options_display}'). Distributed cache is enabled independently. " |
| 598 | + f"Please run --enable-azure-container-storage {CONST_STORAGE_POOL_TYPE_DISTRIBUTED_CACHE} " |
| 599 | + "on its own." |
| 600 | + ) |
| 601 | + |
| 602 | + if is_extension_installed: |
| 603 | + raise InvalidArgumentValueError( |
| 604 | + 'Cannot enable distributed cache as it is already enabled on the cluster.' |
| 605 | + ) |
| 606 | + |
| 607 | + unsupported_params = [] |
| 608 | + if storage_pool_name is not None: |
| 609 | + unsupported_params.append('--storage-pool-name') |
| 610 | + if storage_pool_sku is not None: |
| 611 | + unsupported_params.append('--storage-pool-sku') |
| 612 | + if storage_pool_option is not None: |
| 613 | + unsupported_params.append('--storage-pool-option') |
| 614 | + if storage_pool_size is not None: |
| 615 | + unsupported_params.append('--storage-pool-size') |
| 616 | + if ephemeral_disk_volume_type is not None: |
| 617 | + unsupported_params.append('--ephemeral-disk-volume-type') |
| 618 | + if ephemeral_disk_nvme_perf_tier is not None: |
| 619 | + unsupported_params.append('--ephemeral-disk-nvme-perf-tier') |
| 620 | + if container_storage_version is not None: |
| 621 | + unsupported_params.append('--container-storage-version') |
| 622 | + |
| 623 | + if unsupported_params: |
| 624 | + params_defined = ', '.join(unsupported_params) |
| 625 | + raise InvalidArgumentValueError( |
| 626 | + f'{params_defined} cannot be used with ' |
| 627 | + f'--enable-azure-container-storage {CONST_STORAGE_POOL_TYPE_DISTRIBUTED_CACHE}. ' |
| 628 | + 'Distributed cache does not require or support any storage pool configuration. ' |
| 629 | + 'Please remove these parameters and try again.' |
| 630 | + ) |
| 631 | + |
| 632 | + |
| 633 | +def validate_disable_distributed_cache_params( |
| 634 | + disablement_option, |
| 635 | + is_extension_installed, |
| 636 | + storage_pool_name, |
| 637 | + storage_pool_sku, |
| 638 | + storage_pool_option, |
| 639 | + storage_pool_size, |
| 640 | + container_storage_version=None, |
| 641 | +): |
| 642 | + disablement_option_arr = disablement_option if isinstance(disablement_option, list) else [disablement_option] |
| 643 | + other_pool_types = [ |
| 644 | + opt for opt in disablement_option_arr |
| 645 | + if opt != CONST_STORAGE_POOL_TYPE_DISTRIBUTED_CACHE |
| 646 | + ] |
| 647 | + if other_pool_types: |
| 648 | + options_display = "', '".join(other_pool_types) |
| 649 | + raise InvalidArgumentValueError( |
| 650 | + f"'{CONST_STORAGE_POOL_TYPE_DISTRIBUTED_CACHE}' cannot be combined with other storage " |
| 651 | + f"options ('{options_display}'). Distributed cache is disabled independently. " |
| 652 | + f"Please run --disable-azure-container-storage {CONST_STORAGE_POOL_TYPE_DISTRIBUTED_CACHE} " |
| 653 | + "on its own." |
| 654 | + ) |
| 655 | + |
| 656 | + if not is_extension_installed: |
| 657 | + raise InvalidArgumentValueError( |
| 658 | + 'Cannot disable distributed cache as it could not be found on the cluster.' |
| 659 | + ) |
| 660 | + |
| 661 | + unsupported_params = [] |
| 662 | + if storage_pool_name is not None: |
| 663 | + unsupported_params.append('--storage-pool-name') |
| 664 | + if storage_pool_sku is not None: |
| 665 | + unsupported_params.append('--storage-pool-sku') |
| 666 | + if storage_pool_option is not None: |
| 667 | + unsupported_params.append('--storage-pool-option') |
| 668 | + if storage_pool_size is not None: |
| 669 | + unsupported_params.append('--storage-pool-size') |
| 670 | + if container_storage_version is not None: |
| 671 | + unsupported_params.append('--container-storage-version') |
| 672 | + |
| 673 | + if unsupported_params: |
| 674 | + params_defined = ', '.join(unsupported_params) |
| 675 | + raise InvalidArgumentValueError( |
| 676 | + f'{params_defined} cannot be used with ' |
| 677 | + f'--disable-azure-container-storage {CONST_STORAGE_POOL_TYPE_DISTRIBUTED_CACHE}. ' |
| 678 | + 'Distributed cache does not require or support any storage pool configuration. ' |
| 679 | + 'Please remove these parameters and try again.' |
| 680 | + ) |
| 681 | + |
| 682 | + |
574 | 683 | # _Validate_storage_pool_size validates that the storage_pool_size is |
575 | 684 | # string of a combination of a float number immediately followed by |
576 | 685 | # Ti or Gi e.g. 2Ti, 512Gi, 1.5Ti. The function also validates that the |
|
0 commit comments