|
17 | 17 | clone_volume, |
18 | 18 | list_volumes, |
19 | 19 | create_volume_snapshot, |
20 | | - list_volume_snapshots |
| 20 | + list_volume_snapshots, |
| 21 | + create_flexcache |
21 | 22 | ) |
22 | 23 |
|
23 | 24 | # Creates the FastMCP server instance |
@@ -453,6 +454,62 @@ def list_volume_snapshots_tool( |
453 | 454 | print(f"Error listing volume snapshots: {e}") |
454 | 455 | raise |
455 | 456 |
|
| 457 | +@mcp.tool(name="CreateFlexCache") |
| 458 | +def create_flexcache_tool( |
| 459 | + source_vol: str, |
| 460 | + source_svm: str, |
| 461 | + flexcache_vol: str, |
| 462 | + flexcache_size: str, |
| 463 | + backend_name: str, |
| 464 | + junction: Optional[str] = None, |
| 465 | + namespace: str = "default", |
| 466 | + trident_namespace: str = "trident", |
| 467 | + print_output: bool = False |
| 468 | +) -> str: |
| 469 | + """ |
| 470 | + Create a FlexCache volume in ONTAP and a corresponding PersistentVolume (PV) and PersistentVolumeClaim (PVC) in Kubernetes. |
| 471 | +
|
| 472 | + This function creates a FlexCache volume in ONTAP and then creates a PV and PVC representing the FlexCache in a specified Kubernetes namespace. |
| 473 | +
|
| 474 | + Parameters: |
| 475 | + - source_vol (str): The name of the source volume in the source SVM that will be cached by the FlexCache volume. |
| 476 | + - source_svm (str): The name of the source Storage Virtual Machine (SVM) that contains the origin volume to be cached. |
| 477 | + - flexcache_vol (str): The name of the FlexCache volume to be created. |
| 478 | + - flexcache_size (str): The size of the FlexCache volume to be created. The size must be specified in a format such as '1024Mi', '100Gi', '10Ti', etc. Note: The size must be at least 50Gi. |
| 479 | + - backend_name (str): The name of the tridentbackendconfig. |
| 480 | + - junction (str, optional): The junction path for the FlexCache volume. Default is None. |
| 481 | + - namespace (str, optional): Kubernetes namespace to create the new PersistentVolumeClaim (PVC) in. Default is "default". |
| 482 | + - trident_namespace (str, optional): Kubernetes namespace where Trident is installed. Default is "trident". |
| 483 | + - print_output (bool, optional): Whether to print output messages. Default is False. |
| 484 | +
|
| 485 | + Returns: |
| 486 | + - str: A message indicating the successful creation of the FlexCache volume and the associated PVC. |
| 487 | +
|
| 488 | + Raises: |
| 489 | + - InvalidConfigError: If the Kubernetes configuration is invalid. |
| 490 | + - APIConnectionError: If there is an error connecting to the Kubernetes API. |
| 491 | + - InvalidVolumeParameterError: If the volume parameters are invalid. |
| 492 | + - NetAppRestError: If there is an error with the NetApp REST API. |
| 493 | + - ConnectionTypeError: If the connection type is invalid. |
| 494 | + """ |
| 495 | + try: |
| 496 | + result = create_flexcache( |
| 497 | + source_vol=source_vol, |
| 498 | + source_svm=source_svm, |
| 499 | + flexcache_vol=flexcache_vol, |
| 500 | + flexcache_size=flexcache_size, |
| 501 | + backend_name=backend_name, |
| 502 | + junction=junction, |
| 503 | + namespace=namespace, |
| 504 | + trident_namespace=trident_namespace, |
| 505 | + print_output=print_output |
| 506 | + ) |
| 507 | + |
| 508 | + return f"FlexCache volume '{result['ontap_flexcache']}' and PVC '{result['k8s_pvc']}' created successfully." |
| 509 | + except Exception as e: |
| 510 | + print(f"Error creating FlexCache volume: {e}") |
| 511 | + raise |
| 512 | + |
456 | 513 | def main(): |
457 | 514 | try: |
458 | 515 | # Sets up basic logging to capture server events and errors |
|
0 commit comments