Skip to content

Commit bf389ef

Browse files
Merge branch 'release-v2.7.0' of https://bitbucket.ngage.netapp.com/scm/sie-bb/netapp-dataops-toolkit into feature/code-refactoring/logger
2 parents e28d93b + 62a95f7 commit bf389ef

23 files changed

Lines changed: 4875 additions & 12 deletions

mcp_servers.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ The [NetApp DataOps Toolkit MCP Server for ONTAP](netapp_dataops_traditional/doc
1616
- **List Snapshots**: Retrieve a list of all snapshots for a specific volume.
1717
- **Create SnapMirror Relationship**: Set up SnapMirror relationships for efficient data replication.
1818
- **List SnapMirror Relationships**: Retrieve a list of all SnapMirror relationships on the storage system.
19+
- **Create FlexCache Volume**: Create FlexCache volumes for efficient data access and caching.
1920

2021
## NetApp DataOps Toolkit for Kubernetes MCP Server
2122

@@ -40,3 +41,4 @@ This MCP Server provides the following tools for managing JupyterLab workspaces
4041
- **ListVolumes**: List all volumes.
4142
- **CreateVolumeSnapshot**: Create a snapshot of a volume.
4243
- **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
#Sets up logging
@@ -458,6 +459,62 @@ def list_volume_snapshots_tool(
458459
logger.error(f"Error listing volume snapshots: {e}")
459460
raise
460461

462+
@mcp.tool(name="CreateFlexCache")
463+
def create_flexcache_tool(
464+
source_vol: str,
465+
source_svm: str,
466+
flexcache_vol: str,
467+
flexcache_size: str,
468+
backend_name: str,
469+
junction: Optional[str] = None,
470+
namespace: str = "default",
471+
trident_namespace: str = "trident",
472+
print_output: bool = False
473+
) -> str:
474+
"""
475+
Create a FlexCache volume in ONTAP and a corresponding PersistentVolume (PV) and PersistentVolumeClaim (PVC) in Kubernetes.
476+
477+
This function creates a FlexCache volume in ONTAP and then creates a PV and PVC representing the FlexCache in a specified Kubernetes namespace.
478+
479+
Parameters:
480+
- source_vol (str): The name of the source volume in the source SVM that will be cached by the FlexCache volume.
481+
- source_svm (str): The name of the source Storage Virtual Machine (SVM) that contains the origin volume to be cached.
482+
- flexcache_vol (str): The name of the FlexCache volume to be created.
483+
- 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.
484+
- backend_name (str): The name of the tridentbackendconfig.
485+
- junction (str, optional): The junction path for the FlexCache volume. Default is None.
486+
- namespace (str, optional): Kubernetes namespace to create the new PersistentVolumeClaim (PVC) in. Default is "default".
487+
- trident_namespace (str, optional): Kubernetes namespace where Trident is installed. Default is "trident".
488+
- print_output (bool, optional): Whether to print output messages. Default is False.
489+
490+
Returns:
491+
- str: A message indicating the successful creation of the FlexCache volume and the associated PVC.
492+
493+
Raises:
494+
- InvalidConfigError: If the Kubernetes configuration is invalid.
495+
- APIConnectionError: If there is an error connecting to the Kubernetes API.
496+
- InvalidVolumeParameterError: If the volume parameters are invalid.
497+
- NetAppRestError: If there is an error with the NetApp REST API.
498+
- ConnectionTypeError: If the connection type is invalid.
499+
"""
500+
try:
501+
result = create_flexcache(
502+
source_vol=source_vol,
503+
source_svm=source_svm,
504+
flexcache_vol=flexcache_vol,
505+
flexcache_size=flexcache_size,
506+
backend_name=backend_name,
507+
junction=junction,
508+
namespace=namespace,
509+
trident_namespace=trident_namespace,
510+
print_output=print_output
511+
)
512+
513+
return f"FlexCache volume '{result['ontap_flexcache']}' and PVC '{result['k8s_pvc']}' created successfully."
514+
except Exception as e:
515+
print(f"Error creating FlexCache volume: {e}")
516+
raise
517+
461518
def main():
462519
try:
463520
# Starts the MCP server using stdio transport for local operation
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# NetApp DataOps Toolkit MCP Server for Google Cloud NetApp Volumes (GCNV)
2+
3+
The NetApp DataOps Toolkit MCP Server for Google Cloud NetApp Volumes (GCNV) is an open-source server component written in Python that provides access to Traditional DataOps Toolkit capabilities through the Model Context Protocol (MCP). The server provides a set of tools for managing NetApp volumes in Google Cloud, including volume creation, cloning, snapshot management, and replication relationships.
4+
5+
> [!NOTE]
6+
> This MCP server uses the stdio transport, as shown in the [MCP Server Quickstart](https://modelcontextprotocol.io/quickstart/server), making it a "local MCP server".
7+
8+
## Tools
9+
10+
- **Create Volume**: Rapidly provision new NetApp volumes in Google Cloud with customizable configurations including protocols, security settings, and backup policies.
11+
- **Clone Volume**: Create near-instantaneous, space-efficient clones of existing volumes from snapshots using NetApp technology.
12+
- **List Volumes**: Retrieve a list of all existing data volumes in a specified project and location.
13+
- **Create Snapshot**: Create space-efficient, read-only copies of data volumes for versioning and traceability.
14+
- **List Snapshots**: Retrieve a list of all snapshots for a specific volume.
15+
- **Create Replication**: Set up replication relationships for efficient data replication and disaster recovery between volumes.
16+
17+
## Prerequisites
18+
19+
- Python >= 3.9
20+
- [`uv`](https://docs.astral.sh/uv/) or [`pip`](https://pypi.org/project/pip/)
21+
- [Google Cloud SDK](https://cloud.google.com/sdk/docs/install) installed and authenticated
22+
- NetApp API enabled on GCP project
23+
24+
## Usage Instructions
25+
26+
### Run with `uv` (recommended)
27+
28+
To run the MCP server using `uv`, run the following command. You do not need to install the NetApp DataOps Toolkit package before running this command.
29+
30+
```bash
31+
uvx --from 'netapp-dataops-traditional[gcp]' netapp_dataops_gcnv_mcp.py
32+
```
33+
34+
### Install with `pip` and run from PATH
35+
36+
To install the NetApp DataOps Toolkit for Traditional Environments, run the following command.
37+
38+
```bash
39+
python3 -m pip install 'netapp-dataops-traditional[gcp]'
40+
```
41+
42+
After installation, the `netapp_dataops_gcnv_mcp.py` command will be available in your PATH for direct usage.
43+
44+
## Usage
45+
46+
### Google Cloud Authentication
47+
48+
Before the MCP server can be used to perform GCNV operations, you must authenticate with Google Cloud and ensure proper setup:
49+
50+
1. **Install Google Cloud SDK**: Follow the [installation guide](https://cloud.google.com/sdk/docs/install)
51+
52+
2. **Authenticate with Google Cloud**:
53+
```bash
54+
gcloud auth login
55+
```
56+
57+
3. **Set your default project**:
58+
```bash
59+
gcloud config set project YOUR_PROJECT_ID
60+
```
61+
62+
4. **Authenticate application default credentials**:
63+
```bash
64+
gcloud auth application-default login
65+
```
66+
67+
4. **Enable the NetApp API**:
68+
```bash
69+
gcloud services enable netapp.googleapis.com
70+
```
71+
72+
5. **Verify API is enabled**:
73+
```bash
74+
gcloud services list --enabled --filter="name:netapp.googleapis.com"
75+
```
76+
77+
### Example JSON Config
78+
79+
To use the MCP server with an MCP client, you need to configure the client to use the server. For many clients (such as [VS Code](https://code.visualstudio.com/docs/copilot/chat/mcp-servers), [Claude Desktop](https://modelcontextprotocol.io/quickstart/user), and [AnythingLLM](https://docs.anythingllm.com/mcp-compatibility/overview)), this requires editing a config file that is in JSON format. Below is an example. Refer to the documentation for your MCP client for specific formatting details.
80+
81+
```json
82+
{
83+
"mcpServers": {
84+
"netapp_dataops_gcnv_mcp": {
85+
"type": "stdio",
86+
"command": "uvx",
87+
"args": [
88+
"--from",
89+
"'netapp-dataops-traditional[gcp]'",
90+
"netapp_dataops_gcnv_mcp.py"
91+
]
92+
}
93+
}
94+
}
95+
```
96+
97+
### Alternative: Using `pip` installation
98+
99+
If you've installed the package with `pip`, you can use:
100+
101+
```json
102+
{
103+
"mcpServers": {
104+
"netapp_dataops_gcnv_mcp": {
105+
"type": "stdio",
106+
"command": "netapp_dataops_gcnv_mcp.py"
107+
}
108+
}
109+
}
110+
```
111+
112+
### Alternative: Direct Python execution
113+
114+
For development or testing purposes:
115+
116+
```json
117+
{
118+
"mcpServers": {
119+
"netapp_dataops_gcnv_mcp": {
120+
"type": "stdio",
121+
"command": "python",
122+
"args": [
123+
"/path/to/netapp_dataops_gcnv_mcp.py"
124+
]
125+
}
126+
}
127+
}
128+
```
129+
130+
## Environment Variables
131+
132+
You can optionally set these environment variables:
133+
134+
- `GOOGLE_APPLICATION_CREDENTIALS`: Path to service account key file (if not using default credentials)
135+
- `GOOGLE_CLOUD_PROJECT`: Default project ID to use
136+
137+
## Troubleshooting
138+
139+
### Common Issues
140+
141+
1. **Authentication Failed**:
142+
```bash
143+
gcloud auth login
144+
```
145+
146+
2. **API Not Enabled**:
147+
```bash
148+
gcloud services enable netapp.googleapis.com --project=YOUR_PROJECT_ID
149+
```
150+
151+
3. **Module Not Found**: Ensure the package is properly installed or use the full path
152+
153+
## Support
154+
155+
Report any issues via GitHub: https://github.com/NetApp/netapp-dataops-toolkit/issues.

0 commit comments

Comments
 (0)