Start a Conversation

Solved!

Go to Solution

1323

September 25th, 2020 04:00

Vplex api v2 patch operation

Hi,

I'm testing vplex api v2 to update a distributed consistency group with python request.

There is no call examples into the api v2 guide and I fail to patch my distributed consistency group with an error 400 :

{'cause': 'Unexpected parsing exception', 'error_code': 400, 'message': 'Failed to parse JSON for PATCH'}

Here is what I doing with my vplex api v2 guide interpretation :

uri : https// /vplex/v2/distributed_storage/distributed_consistency_groups/

method : PATCH

body : [{'op': 'remove', 'path': 'virtual_volumes', 'value': ['/vplex/v2/distributed_storage/distributed_virtual_volumes/ ']}]

Does anybody try this type of operation on new vplex api ?

11 Posts

September 25th, 2020 08:00

got it.

as the emc's doc about api v2 is very poor (no examples, no base_path, ...) I have looking for jsonpatchops resource and I found a way to make it work :

assume we have a consistency group with some volumes inside :

#curl --user : -k -X GET "https:// /vplex/v2/distributed_storage/distributed_consistency_groups/ "

{
"detach_rule":{
"cluster":"/vplex/v2/clusters/cluster-2",
"delay":5,
"type":"winner"
},
"operational_status":[
{
"summary":"ok",
"cluster":"cluster-1",
"details":[]
},
{
"summary":"ok",
"cluster":"cluster-2",
"details":[]
}
],
"read_only":false,
"recoverpoint_enabled":false,
"storage_at_clusters":[
"/vplex/v2/clusters/cluster-1",
"/vplex/v2/clusters/cluster-2"
],
"virtual_volumes":[
"/vplex/v2/distributed_storage/distributed_virtual_volumes/ ",
"/vplex/v2/distributed_storage/distributed_virtual_volumes/ ",
"/vplex/v2/distributed_storage/distributed_virtual_volumes/ ",
"/vplex/v2/distributed_storage/distributed_virtual_volumes/ "
],
"visibility":[
"/vplex/v2/clusters/cluster-1",
"/vplex/v2/clusters/cluster-2"
],
"auto_resume_at_loser":true,
"recoverpoint":null,
"name":"mycg"
}

To remove vol1 from mycg I need to do this api call :

# curl --user : -k -X PATCH "https:// /vplex/v2/distributed_storage/distributed_consistency_groups/ " -H "Content-Type:application/json-patch+json" --data '[{"op": "remove", "path": "/virtual_volumes", "value": "/vplex/v2/distributed_storage/distributed_virtual_volumes/ "}]'

{
"detach_rule":{
"cluster":"/vplex/v2/clusters/cluster-2",
"delay":5,
"type":"winner"
},
"operational_status":[
{
"summary":"ok",
"cluster":"cluster-1",
"details":[]
},
{
"summary":"ok",
"cluster":"cluster-2",
"details":[]
}
],
"read_only":false,
"recoverpoint_enabled":false,
"storage_at_clusters":[
"/vplex/v2/clusters/cluster-1",
"/vplex/v2/clusters/cluster-2"
],
"virtual_volumes":[
"/vplex/v2/distributed_storage/distributed_virtual_volumes/ ",
"/vplex/v2/distributed_storage/distributed_virtual_volumes/ ",
"/vplex/v2/distributed_storage/distributed_virtual_volumes/ "
],
"visibility":[
"/vplex/v2/clusters/cluster-1",
"/vplex/v2/clusters/cluster-2"
],
"auto_resume_at_loser":true,
"recoverpoint":null,
"name":" "
}

 

So, to explain the vplex api doc :

you need to use the method "PATCH" of an object  /distributed_storage/distributed_consistency_groups/{name} (where name is the consistency group name).

The full uri to use is https:// /vplex/v2/

The header has to bet set to "Content-Type:application/json-patch+json"

Then the body :

You need to provide a json object (or an array of json objects) with 3 attributes :

op : test|add|remove|replace

path : this is the object's parameter you want to update (beginning with a /)

value: this the value to be tested|removed|added|replaced

I've just tested the operation remove on a single attribute. I have not tested array of json operations to test, then add|remove, then test if it's ok.

 

 

No Events found!

Top