### GET /volumes/{volumeId}/snapshots Source: https://github.com/vmware-samples/cloud-native-storage-self-service-manager/blob/main/docs/book/features/orphan_snapshots.md Lists all snapshots for a specific volume. Requires datacenter and datastore names. Optionally filters by snapshot description prefix. ```APIDOC ## GET /volumes/{volumeId}/snapshots ### Description This API lists all the snapshots for a specific volume. It takes required parameters datacenter and datastore name to which volume and snapshots belong to. This API also takes optional parameter snapshotPrefix which indicates the prefix used in snapshot description. If snapshot prefix is not specified, then it lists all snapshots of a volume. Otherwise it lists only those snapshots of volume whose description’s prefix matches with the specified snapshot prefix. ### Method GET ### Endpoint /volumes/{volumeId}/snapshots ### Parameters #### Path Parameters - **volumeId** (string) - Required - The ID of the volume. #### Query Parameters - **datacenter** (string) - Required - The datacenter where the volume and snapshots reside. - **datastore** (string) - Required - The datastore where the volume and snapshots reside. - **snapshotPrefix** (string) - Optional - The prefix to match in the snapshot description. ### Response #### Success Response (200) - **snapshots** (array) - A list of snapshot objects for the specified volume. #### Response Example ```json { "snapshots": [ { "snapshotId": "snapshot-xyz", "snapshotName": "backup-20231027", "creationTime": "2023-10-27T11:00:00Z", "sizeInMB": 512 } ] } ``` ``` -------------------------------- ### Invoking CNS Manager API with cURL Source: https://github.com/vmware-samples/cloud-native-storage-self-service-manager/blob/main/docs/book/deployment/basicauth.md This example demonstrates how to invoke a CNS Manager API endpoint using cURL. It shows how to pass basic authentication credentials and specify request parameters. ```shell curl -X 'GET' 'http://10.184.71.61:30008/1.0.0/datastoreresources?datacenter=VSAN-DC&datastore=vsanDatastore' -H 'accept: application/json' -u "Admistrator:Admin123@" ``` -------------------------------- ### GET /orphansnapshots Source: https://github.com/vmware-samples/cloud-native-storage-self-service-manager/blob/main/docs/book/features/orphan_snapshots.md Retrieves a list of orphan snapshots. Supports filtering by datacenter and datastores, with an optional snapshot description prefix. Pagination is supported via limit and offset parameters. Returns cached results and the next operation interval. ```APIDOC ## GET /orphansnapshots ### Description This API is used to get list of orphan snapshots. It takes optional parameters, datacenter & list of datastores, and returns orphan snapshots for them. - If datacenter is not specified, then it returns all orphan snapshots in the vCenter (all datastores on all datacenters ). - If only datacenter is specified, then it returns orphan snapshots in all datastores in the datacenter. - If both datacenter & list of datastores is specified, it returns orphan snapshots in specified datastores on the datacenter. This API also takes optional parameter snapshotPrefix, which indicates the prefix used in the snapshot description. So, this API returns orphan snapshots whose description’s prefix matches with the specified snapshot prefix. Default value of this parameter is “snapshot”. There could be hundreds of orphan snapshots, so this API supports pagination as well. It takes optional parameters limit (default value 50) and offset (default value 0). Limit specifies the maximum entries that should be displayed in single request, whereas offset specifies the starting point of the result set. Detection of orphan snapshots can be a time-consuming operation if there are large number of orphans. Hence it is performed asynchronously at regular intervals and the response is cached. This API returns list of orphan snapshots computed in the last run, along with the next operation interval (`RetryAfterMinutes`). **Note:** For newly deployed CNS manager application, when orphan snapshots are being computed in the background for the first time, the API may return no orphan snapshots. It should then be re-tried after `RetryAfterMinutes` to get orphan snapshots computed in the latest run. ### Method GET ### Endpoint /orphansnapshots ### Parameters #### Query Parameters - **datacenter** (string) - Optional - The datacenter to filter orphan snapshots by. - **datastores** (array[string]) - Optional - A list of datastores within the specified datacenter to filter orphan snapshots by. - **snapshotPrefix** (string) - Optional - The prefix to match in the snapshot description. Defaults to "snapshot". - **limit** (integer) - Optional - The maximum number of entries to return. Defaults to 50. - **offset** (integer) - Optional - The starting point of the result set. Defaults to 0. ### Response #### Success Response (200) - **orphanSnapshots** (array) - A list of orphan snapshot objects. - **RetryAfterMinutes** (integer) - The number of minutes until the next operation interval. #### Response Example ```json { "orphanSnapshots": [ { "snapshotId": "snapshot-123", "snapshotName": "my-orphan-snapshot", "creationTime": "2023-10-27T10:00:00Z", "sizeInMB": 1024 } ], "RetryAfterMinutes": 60 } ``` ``` -------------------------------- ### GET /waitforjob Source: https://github.com/vmware-samples/cloud-native-storage-self-service-manager/blob/main/docs/book/features/orphan_snapshots.md A blocking API that waits for a job to complete (either successfully or with an error) before returning the job result. ```APIDOC ## GET /waitforjob ### Description This is a blocking API that waits for job to be successful or fail. Unlike `getjobstatus` API, this will wait for the job to finish before returning the job result response. ### Method GET ### Endpoint /waitforjob ### Parameters #### Query Parameters - **jobId** (string) - Required - The ID of the job to wait for. - **timeoutMinutes** (integer) - Optional - The maximum time to wait for the job to complete in minutes. ### Response #### Success Response (200) - **status** (string) - The final status of the job (Success or Error). - **result** (object) - The result of the job operation (details depend on the specific job). #### Response Example ```json { "status": "Success", "result": { "message": "All snapshots deleted successfully." } } ``` ``` -------------------------------- ### GET /orphanvolumes Source: https://github.com/vmware-samples/cloud-native-storage-self-service-manager/blob/main/docs/book/features/orphan_volumes.md Retrieves a list of orphan volumes. Supports filtering by datacenter and datastores, inclusion of detailed information, and pagination. ```APIDOC ## GET /orphanvolumes ### Description Retrieves a list of orphan volumes. Supports filtering by datacenter and datastores, inclusion of detailed information, and pagination. ### Method GET ### Endpoint /orphanvolumes ### Parameters #### Query Parameters - **datacenter** (string) - Optional - The datacenter to filter orphan volumes by. - **datastores** (array of strings) - Optional - A list of datastores to filter orphan volumes by. - **includeDetails** (boolean) - Optional - Set to `true` to include detailed information about the orphan volumes. - **limit** (integer) - Optional - The maximum number of entries to return per request. - **offset** (integer) - Optional - The starting point for the result set. ### Request Example ```json { "example": "GET /orphanvolumes?datacenter=mydatacenter&datastores=mydatastore1,mydatastore2&includeDetails=true&limit=10&offset=0" } ``` ### Response #### Success Response (200) - **orphanVolumes** (array) - A list of orphan volumes. - **volumeId** (string) - The ID of the orphan volume. - **datastoreId** (string) - The ID of the datastore where the volume resides. - **creationTime** (string) - The creation timestamp of the volume. - **sizeInMb** (integer) - The size of the volume in megabytes. - **details** (object) - Optional. Detailed information about the orphan volume if `includeDetails` is true. - **RetryAfterMinutes** (integer) - The number of minutes after which the next orphan volume detection operation will be performed. ``` -------------------------------- ### Get Datastore Resources - Go Source: https://context7.com/vmware-samples/cloud-native-storage-self-service-manager/llms.txt Retrieves datastore resources (volumes and VMs) programmatically using the Go client. Requires datacenter and datastore names. The result includes details about volumes and virtual machines on the specified datastore. ```go datacenter := "VSAN-DC" datastore := "vsanDatastore" result, resp, err := client.DatastoreOperationsApi.GetDatastoreResources(ctx, datacenter, datastore) if err != nil { panic(err) } // result contains DatastoreResourcesResult with: // - VolumeDetails: list of volumes on datastore with FCD IDs // - VMDetails: list of VMs on datastore ``` -------------------------------- ### Get Datastore Resources - Bash Source: https://context7.com/vmware-samples/cloud-native-storage-self-service-manager/llms.txt Queries a specific datastore for all associated volumes (CNS and non-CNS) and virtual machines. Requires datacenter and datastore names. Uses BasicAuth for authentication. ```bash curl -X 'GET' \ "http://cns-manager.example.com:30008/1.0.0/datastoreresources?datacenter=VSAN-DC&datastore=vsanDatastore" \ -H 'accept: application/json' \ -u "Administrator:Admin123@" ``` -------------------------------- ### GET /getjobstatus Source: https://github.com/vmware-samples/cloud-native-storage-self-service-manager/blob/main/docs/book/features/orphan_snapshots.md Retrieves the current status of a snapshot deletion job. Possible statuses include Queued, Running, Success, and Error. ```APIDOC ## GET /getjobstatus ### Description This API returns the current status of the job. A job can be in one of the following status: * Queued - Job has been created but hasn't started processing. * Running - Job is currently executing. * Success - Job has completed successfully with all tasks succeeding. * Error - Job ran but some or all of its tasks failed. ### Method GET ### Endpoint /getjobstatus ### Parameters #### Query Parameters - **jobId** (string) - Required - The ID of the job to check. ### Response #### Success Response (200) - **status** (string) - The current status of the job. #### Response Example ```json { "status": "Running" } ``` ``` -------------------------------- ### Get Datastore Resources Source: https://context7.com/vmware-samples/cloud-native-storage-self-service-manager/llms.txt Queries all volumes (CNS and non-CNS) and virtual machines residing on a specified datastore. This is useful for planning datastore decommissioning. ```APIDOC ## GET /1.0.0/datastoreresources ### Description Query all volumes (CNS and non-CNS) and virtual machines on a specific datastore, useful for datastore decommissioning planning. ### Method GET ### Endpoint `/1.0.0/datastoreresources` ### Parameters #### Query Parameters - **datacenter** (string) - Required - The name of the datacenter containing the datastore. - **datastore** (string) - Required - The name of the datastore to query. ### Request Example ```bash curl -X 'GET' \ "http://cns-manager.example.com:30008/1.0.0/datastoreresources?datacenter=VSAN-DC&datastore=vsanDatastore" \ -H 'accept: application/json' \ -u "Administrator:Admin123@" ``` ### Response #### Success Response (200) - **VolumeDetails** (array of objects) - List of volumes on the datastore, each with an `fcdId`. - **fcdId** (string) - The full clone disk ID of the volume. - **VMDetails** (array of objects) - List of virtual machines on the datastore. - **vmName** (string) - The name of the virtual machine. - **vmUUID** (string) - The UUID of the virtual machine. #### Response Example ```json { "VolumeDetails": [ { "fcdId": "volume-fcd-id-1" }, { "fcdId": "volume-fcd-id-2" } ], "VMDetails": [ { "vmName": "my-vm-1", "vmUUID": "vm-uuid-1" }, { "vmName": "my-vm-2", "vmUUID": "vm-uuid-2" } ] } ``` ``` -------------------------------- ### Set up Internal CA - Generate Private Key Source: https://github.com/vmware-samples/cloud-native-storage-self-service-manager/blob/main/docs/book/deployment/tls-certs.md Generates a private key for the internal Certificate Authority (CA). This key is essential for signing certificates issued by the CA. It requires OpenSSL to be installed. ```bash openssl genrsa -des3 -out myCA.key 2048 ``` -------------------------------- ### Get Job Status (Go) Source: https://context7.com/vmware-samples/cloud-native-storage-self-service-manager/llms.txt Fetches the current status of an asynchronous job using the Go client SDK. This function returns the job ID, its current status (Queued, Running, Success, Error), original parameters, and task statuses if available. Requires a job ID. ```go jobId := "volumemigrationjob-64248e96-7cf4-11ec-94b8-165555b18a9c" result, resp, err := client.JobDetailsApi.GetJobStatus(ctx, jobId) if err != nil { panic(err) } // result contains JobResult with: // - JobId: the job identifier // - JobStatus: current status (Queued/Running/Success/Error) // - JobParameters: original job parameters // - TaskStatuses: array of individual task statuses if available ``` -------------------------------- ### Resume Volume Provisioning (Go) Source: https://context7.com/vmware-samples/cloud-native-storage-self-service-manager/llms.txt Unblocks the creation of new volumes on a suspended datastore using the Go client library. It requires the datacenter and datastore names. ```go datacenter := "VSAN-DC" datastore := "local-0" result, resp, err := client.DatastoreOperationsApi.ResumeVolumeProvisioning(ctx, datacenter, datastore) if err != nil { panic(err) } // result contains ResumeVolumeProvisioningResult with operation status ``` -------------------------------- ### VC Credentials JSON Configuration Source: https://github.com/vmware-samples/cloud-native-storage-self-service-manager/blob/main/docs/book/deployment/basicauth.md This JSON file stores the credentials required to connect to your vCenter instance. It includes the vCenter IP address, username, and password. ```json { "vc": "", "user": "", "password": "" } ``` -------------------------------- ### Resume Volume Provisioning (Bash) Source: https://context7.com/vmware-samples/cloud-native-storage-self-service-manager/llms.txt Unblocks the creation of new volumes on a datastore that was previously suspended. This operation restores normal volume provisioning. It requires the datacenter and datastore names. ```bash curl -X 'POST' \ "http://cns-manager.example.com:30008/1.0.0/resumevolumeprovisioning?datacenter=VSAN-DC&datastore=local-0" \ -H 'accept: application/json' \ -u "Administrator:Admin123@" ``` -------------------------------- ### Verifying CNS Manager Pod Status Source: https://github.com/vmware-samples/cloud-native-storage-self-service-manager/blob/main/docs/book/deployment/basicauth.md This command verifies that the CNS Manager pod is running successfully within the specified namespace after deployment. ```shell > kubectl get pods -n cns-manager ``` -------------------------------- ### GET /1.0.0/orphanvolumes Source: https://context7.com/vmware-samples/cloud-native-storage-self-service-manager/llms.txt Detects orphan volumes, which are volumes without a corresponding PersistentVolume in any registered cluster. Detection runs asynchronously at intervals. ```APIDOC ## GET /1.0.0/orphanvolumes ### Description Detect orphan volumes (volumes without corresponding PersistentVolume in any registered cluster). Detection runs asynchronously at intervals. ### Method GET ### Endpoint /1.0.0/orphanvolumes ### Parameters #### Query Parameters - **datacenter** (string) - Required - The datacenter to scan for orphan volumes. - **datastores** (string) - Required - A comma-separated list of datastores to include in the scan. - **includeDetails** (boolean) - Optional - If true, includes detailed information about each orphan volume. - **limit** (integer) - Optional - The maximum number of orphan volumes to return per page. - **offset** (integer) - Optional - The offset for pagination. ### Request Example ```json { "operation": "orphanvolumes", "params": { "datacenter": "VSAN-DC", "datastores": "vsanDatastore", "includeDetails": true, "limit": 50, "offset": 0 } } ``` ### Response #### Success Response (200 OK) - **totalOrphans** (integer) - Total count of orphan volumes found. - **totalOrphansAttached** (integer) - Count of orphan volumes attached to VMs. - **totalOrphansDetached** (integer) - Count of orphan volumes detached. - **orphanVolumes** (array) - An array of orphan volume details (if includeDetails is true). - **retryAfterMinutes** (integer) - Recommended time in minutes to retry for an updated list. - **limit** (integer) - The limit used for pagination. - **nextOffset** (integer) - The offset for the next page of results. #### Response Example ```json { "totalOrphans": 10, "totalOrphansAttached": 2, "totalOrphansDetached": 8, "orphanVolumes": [ { "volumeId": "vol-123", "name": "orphan-vol-1", "size": 1024, "attached": false } ], "retryAfterMinutes": 15, "limit": 50, "nextOffset": 50 } ``` ``` -------------------------------- ### Migrate Volumes API Source: https://github.com/vmware-samples/cloud-native-storage-self-service-manager/blob/main/docs/book/features/storage_vmotion.md Initiates the migration of specified volumes to a target datastore. This is an asynchronous API that returns a job ID for tracking the migration progress. ```APIDOC ## POST /migratevolumes ### Description Initiates the migration of specified volumes to a target datastore. This is an asynchronous API and returns a job ID that can be used to track the migration status. ### Method POST ### Endpoint /migratevolumes ### Parameters #### Request Body - **volumeIds** (array of strings) - Required - A list of volume identifiers to migrate. - **targetDatastoreId** (string) - Required - The unique identifier of the target datastore. ### Request Example ```json { "volumeIds": [ "vol-123", "vol-456" ], "targetDatastoreId": "datastore-abc" } ``` ### Response #### Success Response (200) - **jobId** (string) - The identifier for the background migration job. #### Response Example ```json { "jobId": "job-xyz-789" } ``` ``` -------------------------------- ### Get Job Status API Source: https://context7.com/vmware-samples/cloud-native-storage-self-service-manager/llms.txt Retrieves the current status of an asynchronous job. Job states include Queued, Running, Success, and Error. ```APIDOC ## GET /1.0.0/getjobstatus ### Description Check the current status of an asynchronous job. Job states: Queued, Running, Success, Error. ### Method GET ### Endpoint /1.0.0/getjobstatus #### Query Parameters - **jobId** (string) - Required - The identifier of the job to check. ### Request Example ```bash curl -X 'GET' \ "http://cns-manager.example.com:30008/1.0.0/getjobstatus?jobId=volumemigrationjob-64248e96-7cf4-11ec-94b8-165555b18a9c" \ -H 'accept: application/json' \ -u "Administrator:Admin123@" ``` ### Response #### Success Response (200) - **JobId** (string) - The job identifier. - **JobStatus** (string) - Current status (Queued/Running/Success/Error). - **JobParameters** (object) - Original job parameters. - **TaskStatuses** (array) - Array of individual task statuses if available. #### Response Example ```json { "JobId": "volumemigrationjob-64248e96-7cf4-11ec-94b8-165555b18a9c", "JobStatus": "Success", "JobParameters": {}, "TaskStatuses": [] } ``` ``` -------------------------------- ### CNS Manager Deployment Source: https://github.com/vmware-samples/cloud-native-storage-self-service-manager/blob/main/docs/book/deployment/basicauth.md This section details the deployment process of CNS Manager, including configuration preparation and the execution of the deployment script with various parameters. ```APIDOC ## Deploy CNS Manager ### Description This process involves preparing configuration files, deploying the CNS Manager application on a Kubernetes cluster using a script, and verifying the deployment. ### Method Shell script execution ### Endpoint Not Applicable (Deployment script) ### Parameters #### Command Line Arguments for `deploy.sh` - **``** (string) - Required - The Kubernetes namespace to deploy CNS Manager into. - **``** (string) - Required - Path to the kubeconfig file for the cluster. - **``** (string) - Required - Path to the JSON file containing vCenter credentials. - **``** (string) - Required - The endpoint for CNS Manager APIs (e.g., WORKER_NODE_IP:30008 or LB_SVC_EXTERNAL_IP:30008). - **``** (string) - Required - Authentication type, typically 'basicauth'. - **``** (boolean) - Required - 'true' if TLS is enabled, 'false' otherwise. - **``** (string) - Required if authType is 'basicauth' - The username for basic authentication. - **``** (string) - Required if authType is 'basicauth' - The password for basic authentication. - **``** (string) - Required if tls flag is 'true' - Path to the TLS private key file. - **``** (string) - Required if tls flag is 'true' - Path to the TLS certificate file. ### Request Example ```bash > cd deploy > ./deploy.sh cns-manager ../config/sv_kubeconfig ../config/vc_creds.json 10.184.71.61:30008 basicauth false 'Administrator' 'Admin123@' ``` ### Response #### Success Response - Kubernetes objects are created (e.g., namespace, secrets, configmaps, deployment, service). - CNS Manager pod status is 'Running'. #### Response Example ``` namespace/cns-manager created secret/sv-kubeconfig created secret/vc-creds created secret/basicauth-creds created configmap/swagger-api created serviceaccount/cns-manager created rolebinding.rbac.authorization.k8s.io/cns-manager created customresourcedefinition.apiextensions.k8s.io/orphanvolumestats.cnsmanager.cns.vmware.com configured customresourcedefinition.apiextensions.k8s.io/volumemigrationjobs.cnsmanager.cns.vmware.com configured customresourcedefinition.apiextensions.k8s.io/volumemigrationtasks.cnsmanager.cns.vmware.com configured clusterrole.rbac.authorization.k8s.io/cns-manager configured clusterrolebinding.rbac.authorization.k8s.io/cns-manager-rolebinding unchanged configmap/cnsmanager-config created configmap/nginx-conf created deployment.apps/cns-manager created service/cns-manager created > kubectl get pods -n cns-manager NAME READY STATUS RESTARTS AGE cns-manager-6ff456dc97-nrj65 3/3 Running 0 54s ``` ``` -------------------------------- ### POST /1.0.0/resumevolumeprovisioning Source: https://context7.com/vmware-samples/cloud-native-storage-self-service-manager/llms.txt Unblocks the creation of new volumes on a datastore that was previously suspended. ```APIDOC ## POST /1.0.0/resumevolumeprovisioning ### Description Unblock creation of new volumes on a previously suspended datastore. ### Method POST ### Endpoint /1.0.0/resumevolumeprovisioning ### Parameters #### Query Parameters - **datacenter** (string) - Required - The datacenter where the datastore is located. - **datastore** (string) - Required - The datastore on which to resume volume provisioning. ### Request Example ```json { "operation": "resumevolumeprovisioning", "params": { "datacenter": "VSAN-DC", "datastore": "local-0" } } ``` ### Response #### Success Response (200 OK) - **status** (string) - The status of the operation (e.g., "Success"). #### Response Example ```json { "status": "Success" } ``` ``` -------------------------------- ### Suspend Volume Provisioning (Go) Source: https://context7.com/vmware-samples/cloud-native-storage-self-service-manager/llms.txt Blocks the creation of new volumes on a specified datastore using the Go client library. Existing volume operations are not affected. Requires datacenter and datastore names. ```go datacenter := "VSAN-DC" datastore := "local-0" result, resp, err := client.DatastoreOperationsApi.SuspendVolumeProvisioning(ctx, datacenter, datastore) if err != nil { panic(err) } // result contains SuspendVolumeProvisioningResult with operation status ``` -------------------------------- ### Register Kubernetes Cluster with CNS Manager API Source: https://github.com/vmware-samples/cloud-native-storage-self-service-manager/blob/main/README.md This command uses curl to register a Kubernetes cluster with the CNS manager by invoking the `/registercluster` API. It uploads the generated kubeconfig file and sets specific CSI driver secret name and namespace. Basic authentication is also included. The API can be called from the command line or programmatically. ```bash curl -X 'POST' "http://CNS-MANAGER-ENDPOINT/1.0.0/registercluster?csiDriverSecretName=vsphere-config-secret&csiDriverSecretNamespace=vmware-system-csi" -H 'accept: application/json' -H 'Content-Type: multipart/form-data' -F 'clusterKubeConfigFile=@output_file_name' -u "Admistrator:Admin123@" ``` -------------------------------- ### Accessing CNS Manager APIs Source: https://github.com/vmware-samples/cloud-native-storage-self-service-manager/blob/main/docs/book/deployment/basicauth.md This section explains how to access the CNS Manager APIs, either through the Swagger UI or by making direct calls using tools like cURL, using the credentials provided during deployment. ```APIDOC ## Access CNS Manager APIs ### Description APIs for CNS Manager can be accessed via a Swagger UI or directly using HTTP clients like cURL. Authentication uses the basic auth credentials configured during deployment. ### Method GET, POST, PUT, DELETE, etc. (HTTP methods for API calls) ### Endpoint - **Swagger UI:** `/ui/` - **API Endpoint Prefix:** `/1.0.0/` ### Parameters #### Query Parameters (for API calls) - **`datacenter`** (string) - Optional - The datacenter to filter resources. - **`datastore`** (string) - Optional - The datastore to filter resources. #### Authentication - **Basic Authentication:** Username and password provided during CNS Manager deployment. ### Request Example (cURL) ```bash curl -X 'GET' 'http://10.184.71.61:30008/1.0.0/datastoreresources?datacenter=VSAN-DC&datastore=vsanDatastore' -H 'accept: application/json' -u "Administrator:Admin123@" ``` ### Response #### Success Response (200) - API responses are typically in JSON format, containing requested data. #### Response Example ```json { "example": "API response JSON content" } ``` ``` -------------------------------- ### Get Job Status (Bash) Source: https://context7.com/vmware-samples/cloud-native-storage-self-service-manager/llms.txt Retrieves the current status of an asynchronous job using a cURL command. The job status can be one of: Queued, Running, Success, or Error. Requires the job ID and authentication credentials. ```bash curl -X 'GET' \ "http://cns-manager.example.com:30008/1.0.0/getjobstatus?jobId=volumemigrationjob-64248e96-7cf4-11ec-94b8-165555b18a9c" \ -H 'accept: application/json' \ -u "Administrator:Admin123@" ``` -------------------------------- ### Set New Release Image for cns-manager Deployment Source: https://github.com/vmware-samples/cloud-native-storage-self-service-manager/blob/main/docs/book/deployment/upgrade.md This command updates the cns-manager deployment to use a new container image for a specific release, for example, version 0.2.0. This action will restart the deployment, applying the new image and ensuring updated configurations like nginx and Swagger are utilized. Specify the correct image repository and tag. ```bash kubectl set image deployment/cns-manager cns-manager=projects.registry.vmware.com/cns_manager/cns-manager:r0.2.0 -n ``` -------------------------------- ### Pass TLS Arguments to Deployment Script Source: https://github.com/vmware-samples/cloud-native-storage-self-service-manager/blob/main/docs/book/deployment/tls-enable.md Execute the deployment script with additional arguments to enable TLS. This includes setting the tls-flag to 'true' and providing the file paths for the TLS key and certificate. ```bash > cd deploy > ./deploy.sh <(tls flag)true|false> ``` ```bash > cd deploy > ./deploy.sh cns-manager ../config/sv_kubeconfig ../config/vc_creds.json :30009 basicauth 'Administrator' 'Admin123@' /etc/tls/helloabc.com.key /etc/tls/helloabc.com.pem ``` -------------------------------- ### Suspend Volume Provisioning API Source: https://github.com/vmware-samples/cloud-native-storage-self-service-manager/blob/main/docs/book/features/storage_vmotion.md Suspends new volume provisioning on a specified datastore. This API requires CSI driver version 2.5+ with the `cnsmgr-suspend-create-volume` feature enabled. ```APIDOC ## POST /suspendvolumeprovisioning ### Description Suspends the provisioning of new volumes on a specified datastore. This is typically done before migrating volumes from a datastore to prevent new volumes from being created during the migration process. Requires Kubernetes clusters to be upgraded to CSI driver version 2.5+ with the `cnsmgr-suspend-create-volume` feature state switch enabled. ### Method POST ### Endpoint /suspendvolumeprovisioning ### Parameters #### Query Parameters - **datastoreId** (string) - Required - The unique identifier of the datastore. ### Request Example (No request body for this endpoint) ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating provisioning has been suspended. #### Response Example ```json { "message": "Volume provisioning suspended for datastore datastore-123." } ``` ### Notes - For file volumes, the suspension may take a few minutes to take effect, depending on the `csi-auth-check-intervalinmin` setting. - For block volumes, provisioning is suspended immediately. ``` -------------------------------- ### Generate Minimal Privilege Kubeconfig for CNS Manager Source: https://github.com/vmware-samples/cloud-native-storage-self-service-manager/blob/main/README.md This shell script generates a kubeconfig file with the minimum necessary privileges for the CNS manager to interact with a Kubernetes cluster. It requires the path to the existing cluster kubeconfig and an output file name for the new kubeconfig. Optionally, context name and server URL can be provided for specific cluster access within a combined kubeconfig. ```shell ./get-kubeconfig.sh ``` ```shell ./get-kubeconfig.sh ``` -------------------------------- ### List Volume Snapshots using cURL and Go Source: https://context7.com/vmware-samples/cloud-native-storage-self-service-manager/llms.txt Retrieves all snapshots associated with a specific volume. Requires volume ID, datacenter, and datastore as path parameters, with an optional snapshotPrefix. The response includes a list of snapshots for the given volume. ```bash curl -X 'GET' \ "http://cns-manager.example.com:30008/1.0.0/volumes/ae903e93-b589-4cda-a3af-e59ef4660325/snapshots?datacenter=VSAN-DC&datastore=vsanDatastore&snapshotPrefix=snapshot" \ -H 'accept: application/json' \ -u "Administrator:Admin123@" ``` ```go volumeId := "ae903e93-b589-4cda-a3af-e59ef4660325" datacenter := "VSAN-DC" datastore := "vsanDatastore" opts := &apiclient.SnapshotForVolumeApiListAllSnapshotsForVolumeOpts{ SnapshotPrefix: optional.NewString("snapshot"), } result, resp, err := client.SnapshotForVolumeApi.ListAllSnapshotsForVolume(ctx, volumeId, datacenter, datastore, opts) if err != nil { panic(err) } // result contains SnapshotsForVolumeResult with: // - Snapshots: array of snapshot details for the volume ``` -------------------------------- ### Migrate Volumes Between Datastores (Go) Source: https://context7.com/vmware-samples/cloud-native-storage-self-service-manager/llms.txt Performs storage vMotion to migrate volumes from a source to a target datastore using the Go client library. This asynchronous operation returns a job ID. Optional parameters include skipping policy checks and volume accessibility checks. ```go datacenter := "VSAN-DC" targetDatastore := "nfs-datastore" opts := &apiclient.DatastoreOperationsApiMigrateVolumesOpts{ SourceDatastore: optional.NewString("vsanDatastore"), FcdIdsToMigrate: optional.NewInterface([]string{ "ae903e93-b589-4cda-a3af-e59ef4660325", "f7821abc-1234-5678-9012-abcdef123456", }), SkipPolicyCheck: optional.NewBool(false), SkipVolumeAccessibilityCheck: optional.NewBool(false), } result, resp, err := client.DatastoreOperationsApi.MigrateVolumes(ctx, datacenter, targetDatastore, opts) if err != nil { panic(err) } // result contains MigrateVolumesResult with: // - JobId: use with GetJobStatus to track progress // resp.StatusCode should be 202 (Accepted) ``` -------------------------------- ### Git Workflow: Creating a New Feature Branch Source: https://github.com/vmware-samples/cloud-native-storage-self-service-manager/blob/main/CONTRIBUTING_CLA.md This snippet demonstrates the initial steps for a contributor's workflow: adding the upstream remote, creating a new feature branch from the main branch, committing changes, and pushing the new branch to the origin fork. ```shell git remote add upstream https://github.com/vmware-samples/cloud-native-storage-self-service-manager.git git checkout -b feat/foo main git commit -s -a git push origin feat/foo ``` -------------------------------- ### Suspend Volume Provisioning (Bash) Source: https://context7.com/vmware-samples/cloud-native-storage-self-service-manager/llms.txt Blocks the creation of new volumes on a specified datastore. This operation is useful for maintenance or when controlling storage allocation. It requires the datacenter and datastore names. ```bash curl -X 'POST' \ "http://cns-manager.example.com:30008/1.0.0/suspendvolumeprovisioning?datacenter=VSAN-DC&datastore=local-0" \ -H 'accept: application/json' \ -u "Administrator:Admin123@" ``` -------------------------------- ### Orphan Volume Deletion Configuration Source: https://github.com/vmware-samples/cloud-native-storage-self-service-manager/blob/main/docs/book/features/orphan_volumes.md This section describes how to configure the auto-deletion of orphan volumes using the `auto-delete-ov` setting in the `cnsmanager-config` configmap. ```APIDOC ## Auto-Monitoring and Deletion of Orphan Volumes ### Description Configure automatic monitoring and periodic deletion of orphan volumes. ### Configuration Key `auto-delete-ov` in `cnsmanager-config` configmap ### Possible Values - `disable`: Orphan volumes will not be deleted automatically. - `enable-only-detached-ov`: Only detached orphan volumes will be deleted. - `enable`: All detected orphan volumes (attached and detached) will be deleted. ### Default Value `disable` ``` -------------------------------- ### CNS Manager Deployment Script Source: https://github.com/vmware-samples/cloud-native-storage-self-service-manager/blob/main/docs/book/deployment/basicauth.md This script deploys the CNS Manager on a Kubernetes cluster. It requires several parameters including namespace, paths to kubeconfig and VC credentials, CNS manager endpoint, authentication type, TLS flag, and basic auth credentials if applicable. The script creates various Kubernetes objects like secrets, configmaps, and deployments. ```shell > cd deploy > ./deploy.sh <(tls flag)true|false> ``` ```shell > ./deploy.sh cns-manager ../config/sv_kubeconfig ../config/vc_creds.json :30008 basicauth false 'Administrator' 'Admin123@' ``` ```shell > ./deploy.sh cns-manager ../config/sv_kubeconfig ../config/vc_creds.json 10.184.71.61:30008 basicauth false 'Administrator' 'Admin123@' ``` -------------------------------- ### Datastore Resources API Source: https://github.com/vmware-samples/cloud-native-storage-self-service-manager/blob/main/docs/book/features/storage_vmotion.md Retrieves details of resources on a datastore, including CNS volumes, non-container volumes, and VMs. This is useful for identifying resources that need to be moved if a datastore is decommissioned. ```APIDOC ## GET /datastoreresources ### Description Provides details of resources residing on a specified datastore. This includes a list of CNS volumes, non-container volumes (created out of band), and VMs present on the datastore. ### Method GET ### Endpoint /datastoreresources ### Parameters #### Query Parameters - **datastoreId** (string) - Required - The unique identifier of the datastore. ### Response #### Success Response (200) - **cnsVolumes** (array) - A list of CNS volumes on the datastore. - **nonContainerVolumes** (array) - A list of non-container volumes on the datastore. - **vms** (array) - A list of VMs on the datastore. #### Response Example ```json { "cnsVolumes": [ { "volumeId": "vol-123", "name": "my-cns-volume" } ], "nonContainerVolumes": [ { "volumeId": "fcd-456", "name": "my-fcd-volume" } ], "vms": [ { "vmId": "vm-789", "name": "my-vm" } ] } ``` ``` -------------------------------- ### Job Status APIs Source: https://github.com/vmware-samples/cloud-native-storage-self-service-manager/blob/main/docs/book/features/storage_vmotion.md Provides APIs to check the status of volume migration jobs. Includes `getjobstatus` for current status and `waitforjob` for blocking until completion. ```APIDOC ## GET /getjobstatus ### Description Retrieves the current status of a volume migration job. ### Method GET ### Endpoint /getjobstatus ### Parameters #### Query Parameters - **jobId** (string) - Required - The identifier of the job to query. ### Response #### Success Response (200) - **jobId** (string) - The identifier of the job. - **status** (string) - The current status of the job (Queued, Running, Success, Error). - **tasks** (array) - A list of tasks associated with the job, each with its own status. #### Response Example ```json { "jobId": "job-xyz-789", "status": "Running", "tasks": [ { "volumeId": "vol-123", "status": "Running" }, { "volumeId": "vol-456", "status": "Queued" } ] } ``` ## GET /waitforjob ### Description A blocking API that waits for a volume migration job to complete (either successfully or with an error) before returning the job result. ### Method GET ### Endpoint /waitforjob ### Parameters #### Query Parameters - **jobId** (string) - Required - The identifier of the job to wait for. ### Response #### Success Response (200) - **jobId** (string) - The identifier of the job. - **status** (string) - The final status of the job (Success, Error). - **tasks** (array) - A list of tasks associated with the job, each with its final status. #### Response Example ```json { "jobId": "job-xyz-789", "status": "Success", "tasks": [ { "volumeId": "vol-123", "status": "Success" }, { "volumeId": "vol-456", "status": "Success" } ] } ``` ``` -------------------------------- ### Migrate Volumes Between Datastores (Bash) Source: https://context7.com/vmware-samples/cloud-native-storage-self-service-manager/llms.txt Performs storage vMotion to migrate volumes from a source to a target datastore. This operation runs asynchronously and returns a job ID for tracking. It requires specifying the datacenter, source datastore, target datastore, and a list of volume IDs to migrate. ```bash curl -X 'POST' \ "http://cns-manager.example.com:30008/1.0.0/migratevolumes?datacenter=VSAN-DC&sourceDatastore=vsanDatastore&targetDatastore=nfs-datastore&fcdIdsToMigrate=ae903e93-b589-4cda-a3af-e59ef4660325,f7821abc-1234-5678-9012-abcdef123456" \ -H 'accept: application/json' \ -u "Administrator:Admin123@" ``` -------------------------------- ### List Orphan Snapshots using cURL and Go Source: https://context7.com/vmware-samples/cloud-native-storage-self-service-manager/llms.txt Detects orphan snapshots (FCD snapshots without corresponding VolumeSnapshotContent). Supports vSphere CSI and Velero plugins. Requires datacenter, datastores, and snapshotPrefix as parameters. Returns a list of orphan snapshots and pagination information. ```bash curl -X 'GET' \ "http://cns-manager.example.com:30008/1.0.0/orphansnapshots?datacenter=VSAN-DC&datastores=vsanDatastore&snapshotPrefix=snapshot&limit=50&offset=0" \ -H 'accept: application/json' \ -u "Administrator:Admin123@" ``` ```go opts := &apiclient.OrphanSnapshotApiOrphanSnapshotsListOpts{ Datacenter: optional.NewString("VSAN-DC"), Datastores: optional.NewString("vsanDatastore"), SnapshotPrefix: optional.NewString("snapshot"), Limit: optional.NewInt64(50), Offset: optional.NewInt64(0), } result, resp, err := client.OrphanSnapshotApi.OrphanSnapshotsList(ctx, opts) if err != nil { panic(err) } // result contains OrphanSnapshotResult with: // - TotalOrphanSnapshots: total count // - OrphanSnapshots: array of snapshot details // - RetryAfterMinutes: when to retry for updated list // - Limit, Offset: pagination info ``` -------------------------------- ### POST /1.0.0/migratevolumes Source: https://context7.com/vmware-samples/cloud-native-storage-self-service-manager/llms.txt Performs storage vMotion to migrate volumes from a source datastore to a target datastore. This operation is asynchronous and returns a job ID for tracking. ```APIDOC ## POST /1.0.0/migratevolumes ### Description Perform storage vMotion to migrate volumes from source to target datastore. Operation runs asynchronously and returns a job ID. ### Method POST ### Endpoint /1.0.0/migratevolumes ### Parameters #### Query Parameters - **datacenter** (string) - Required - The datacenter where the volumes are located. - **sourceDatastore** (string) - Required - The source datastore from which to migrate volumes. - **targetDatastore** (string) - Required - The target datastore to which volumes will be migrated. - **fcdIdsToMigrate** (array[string]) - Required - A list of volume IDs (FCD IDs) to migrate. - **skipPolicyCheck** (boolean) - Optional - If true, skips policy checks during migration. - **skipVolumeAccessibilityCheck** (boolean) - Optional - If true, skips volume accessibility checks. ### Request Example ```json { "operation": "migratevolumes", "params": { "datacenter": "VSAN-DC", "sourceDatastore": "vsanDatastore", "targetDatastore": "nfs-datastore", "fcdIdsToMigrate": [ "ae903e93-b589-4cda-a3af-e59ef4660325", "f7821abc-1234-5678-9012-abcdef123456" ], "skipPolicyCheck": false, "skipVolumeAccessibilityCheck": false } } ``` ### Response #### Success Response (202 Accepted) - **jobId** (string) - The ID of the asynchronous job created for the migration. #### Response Example ```json { "jobId": "a1b2c3d4-e5f6-7890-1234-abcdef123456" } ``` ``` -------------------------------- ### List Orphan Volumes (Go) Source: https://context7.com/vmware-samples/cloud-native-storage-self-service-manager/llms.txt Detects orphan volumes using the Go client library. Orphan volumes are those not associated with any registered PersistentVolume. The API allows specifying datacenter, datastores, detail inclusion, and pagination parameters. ```go opts := &apiclient.OrphanVolumeApiOrphanVolumeListOpts{ IncludeDetails: optional.NewBool(true), Datacenter: optional.NewString("VSAN-DC"), Datastores: optional.NewString("vsanDatastore"), Limit: optional.NewInt32(50), Offset: optional.NewInt32(0), } result, resp, err := client.OrphanVolumeApi.OrphanVolumeList(ctx, opts) if err != nil { panic(err) } // result contains OrphanVolumeResult with: // - TotalOrphans: total count of orphan volumes // - TotalOrphansAttached: count attached to VMs // - TotalOrphansDetached: count detached // - OrphanVolumes: array of orphan volume details // - RetryAfterMinutes: when to retry for updated list // - Limit, NextOffset: pagination info ```