我很难得到想要的结果。有人能帮我找到正确的解决方案吗。
我尝试了不同的规格,并注意到成功了。当将父id添加到相应的数组中时,我将面临问题。
请在这里帮忙。
输入JSON:
{
"device": {
"id": "336 A6",
"shelves": [
{
"shelfID": "1",
"slots": [
{
"slotID": "1",
"cards": {
"cardID": "1",
"subSlots": [
{
"slotID": "mda-1",
"cards": {
"cardID": "1/1",
"ports": [
{
"portID": "1/1/1",
"adminStatus": "up"
},
{
"portID": "1/1/2",
"adminStatus": "up"
}
]
}
},
{
"slotID": "mda-2",
"cards": {
"cardID": "2/1",
"ports": [
{
"portID": "2/1/1",
"adminStatus": "up"
},
{
"portID": "2/1/2",
"adminStatus": "up"
}
]
}
}
]
}
},
{
"slotID": "11",
"cards": {
"cardID": "11",
"ports": [
{
"portID": "11/1/1",
"adminStatus": "up"
},
{
"portID": "11/1/2",
"adminStatus": "up"
}
]
}
}
]
},
{
"shelfID": "esat-1",
"ports": [
{
"portID": "esat-1/1/1",
"adminStatus": "down"
},
{
"portID": "esat-1/1/2",
"adminStatus": "up"
}
]
}
]
}
}下面是我试过的震动规范
[
{
"operation": "shift",
"spec": {
"device": {
"shelves": {
"*": {
"ports": {
"*": "physicalResource.ports[&2]",
"@(1,shelfID)": "physicalResource.ports[&2].parentId"
},
"slots": {
"*": {
"cards": {
"ports": {
"*": "physicalResource.ports[&5]",
"@(1,cardID)": "physicalResource.ports[&5].parentId"
},
"subSlots": {
"*": {
"cards": {
"ports": {
"*": "physicalResource.ports[&8]",
"@(1,cardID)": "physicalResource.ports[&8].parentId"
}
}
}
}
}
}
}
}
}
}
}
}
]预期产出:
{
"physicalResource": {
"ports": [
{
"id": "1/1/1",
"parentId": "1/1",
"state": "up"
},
{
"id": "1/1/2",
"parentId": "1/1",
"state": "up"
},
{
"id": "2/1/1",
"parentId": "2/1",
"state": "up"
},
{
"id": "2/1/2",
"parentId": "2/1",
"state": "up"
},
{
"id": "11/1/1",
"parentId": "11/1",
"state": "up"
},
{
"id": "11/1/2",
"parentId": "11/1",
"state": "up"
},
{
"id": "11/1/1",
"parentId": "11/1",
"state": "up"
},
{
"id": "11/1/2",
"parentId": "11/1",
"state": "up"
},
{
"id": "esat-1/1/1",
"parentSubCardId": "esat-1",
"state": "up"
},
{
"id": "esat-1/1/2",
"parentSubCardId": "esat-1",
"state": "up"
}
]
}
}谢谢。
发布于 2021-03-12 08:23:20
这可以分两班完成。
。
[
{
"operation": "shift",
"spec": {
"device": {
"shelves": {
"*": {
"ports": {
"*": {
"@(2,shelfID)": "ports_&3_&1.parentSubCardId",
"portID": "ports_&3_&1.id",
"adminStatus": "ports_&3_&1.state"
}
},
"slots": {
"*": {
"cards": {
"ports": {
"*": {
"@(2,cardID)": "slots_cards_&4_&1.parentId",
"portID": "slots_cards_&4_&1.id",
"adminStatus": "slots_cards_&4_&1.state"
}
},
"subSlots": {
"*": {
"cards": {
"ports": {
"*": {
"@(2,cardID)": "sub_slots_&4_&1.parentId",
"portID": "sub_slots_&4_&1.id",
"adminStatus": "sub_slots_&4_&1.state"
}
}
}
}
}
}
}
}
}
}
}
}
},
{
"operation": "shift",
"spec": {
"*": "physicalResource.ports[]"
}
}
]我建议你不用第二次轮班的时间来看看发生了什么事。
https://stackoverflow.com/questions/66321042
复制相似问题