Skip to content

Commit 302146a

Browse files
committed
Pull request #8: Feature/mcp flexcache k8s
Merge in SIE-BB/netapp-dataops-toolkit from feature/mcp-flexcache-k8s to release-v2.7.0 * commit 'a675aa583879d194078a0f50be4e0714d2fe255f': removed extra line adding 'create flexcache' to list of tools in mcp_servers.md updating docs returning str as output for mcp tool correction updating create_flexcache_volume_tool @K8s mcp server addded 'create_flexcache_tool' to mcp server K8s
2 parents 2b33925 + a675aa5 commit 302146a

3 files changed

Lines changed: 60 additions & 1 deletion

File tree

mcp_servers.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ This MCP Server provides the following tools for managing JupyterLab workspaces
4141
- **ListVolumes**: List all volumes.
4242
- **CreateVolumeSnapshot**: Create a snapshot of a volume.
4343
- **ListVolumeSnapshots**: List all snapshots of volumes.
44+
- **CreateFlexCache**: Create a FlexCache volume.

netapp_dataops_k8s/docs/mcp_server_k8s.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ The MCP server provides the following tools for managing JupyterLab workspaces a
2626
- **ListVolumes**: List all volumes.
2727
- **CreateVolumeSnapshot**: Create a snapshot of a volume.
2828
- **ListVolumeSnapshots**: List all snapshots of volumes.
29+
- **CreateFlexCache**: Create a new FlexCache volume.
2930

3031
## Quick Start
3132

netapp_dataops_k8s/netapp_dataops/netapp_dataops_k8s_mcp.py

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
clone_volume,
1818
list_volumes,
1919
create_volume_snapshot,
20-
list_volume_snapshots
20+
list_volume_snapshots,
21+
create_flexcache
2122
)
2223

2324
# Creates the FastMCP server instance
@@ -453,6 +454,62 @@ def list_volume_snapshots_tool(
453454
print(f"Error listing volume snapshots: {e}")
454455
raise
455456

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+
456513
def main():
457514
try:
458515
# Sets up basic logging to capture server events and errors

0 commit comments

Comments
 (0)