Skip to content

Commit 1814075

Browse files
committed
Add new parameter to VM.migrate_send in GO SDK
Update VM.MigrateSend call to include new VdiFormatMap parameter. Signed-off-by: Guillaume <guillaume.thouvenin@vates.tech>
1 parent cd18e29 commit 1814075

File tree

3 files changed

+38
-19
lines changed

3 files changed

+38
-19
lines changed

ocaml/sdk-gen/component-test/jsonrpc-client/go/main_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,17 @@ func ConvertMapToVgpuMap(input map[string]interface{}) (map[xenapi.VGPURef]xenap
113113
return output, nil
114114
}
115115

116+
func ConvertMapToVdiFormatMap(input map[string]interface{}) (map[xenapi.VDIRef]string, error) {
117+
output := make(map[xenapi.VDIRef]string)
118+
for key, value := range input {
119+
strValue, ok := value.(string)
120+
if !ok {
121+
return nil, fmt.Errorf("non-string value found for key %s: %v", key, value)
122+
}
123+
output[xenapi.VDIRef(key)] = strValue
124+
}
125+
return output, nil
126+
}
116127
func TestMain(m *testing.M) {
117128
flag.Parse()
118129
exitVal := m.Run()

ocaml/sdk-gen/component-test/jsonrpc-client/go/vm_test.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -269,13 +269,14 @@ func TestVMMigrateSend(t *testing.T) {
269269

270270
inputParams := spec.Key.Params["VM.migrate_send"]
271271
const (
272-
IndexVMRef = 1
273-
IndexDest = 2
274-
IndexLive = 3
275-
IndexVdiMap = 4
276-
IndexVifMap = 5
277-
IndexOptions = 6
278-
IndexVgpuMap = 7
272+
IndexVMRef = 1
273+
IndexDest = 2
274+
IndexLive = 3
275+
IndexVdiMap = 4
276+
IndexVifMap = 5
277+
IndexOptions = 6
278+
IndexVgpuMap = 7
279+
IndexVdiFormatMap = 8
279280
)
280281
vmRef, ok1 := inputParams[IndexVMRef].(string)
281282
destOrg, ok2 := inputParams[IndexDest].(map[string]interface{})
@@ -284,7 +285,8 @@ func TestVMMigrateSend(t *testing.T) {
284285
vifMapOrg, ok5 := inputParams[IndexVifMap].(map[string]interface{})
285286
optionsOrg, ok6 := inputParams[IndexOptions].(map[string]interface{})
286287
vgpuMapOrg, ok7 := inputParams[IndexVgpuMap].(map[string]interface{})
287-
if !ok1 || !ok2 || !ok3 || !ok4 || !ok5 || !ok6 || !ok7 {
288+
vdiFormatMapOrg, ok8 := inputParams[IndexVdiFormatMap].(map[string]interface{})
289+
if !ok1 || !ok2 || !ok3 || !ok4 || !ok5 || !ok6 || !ok7 || !ok8 {
288290
t.Log("Parameter get error from json file")
289291
t.Fail()
290292
return
@@ -319,8 +321,13 @@ func TestVMMigrateSend(t *testing.T) {
319321
t.Fail()
320322
return
321323
}
322-
323-
result, err := xenapi.VM.MigrateSend(session, xenapi.VMRef(vmRef), dest, live, vdiMap, vifMap, options, vgpuMap)
324+
vdiFormatMap, err := ConvertMapToVdiFormatMap(vdiFormatMapOrg)
325+
if err != nil {
326+
t.Log(err)
327+
t.Fail()
328+
return
329+
}
330+
result, err := xenapi.VM.MigrateSend(session, xenapi.VMRef(vmRef), dest, live, vdiMap, vifMap, options, vgpuMap, vdiFormatMap)
324331
if err != nil {
325332
t.Log(err)
326333
t.Fail()

ocaml/sdk-gen/component-test/spec/xapi-24/vm_migrate_send.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
],
66
"params": {
77
"VM.migrate_send": [
8-
"",
9-
"OpaqueRef:5vm2d621-7b62-f571-vm00-754341a973e5",
10-
{"name_label": "host1"},
11-
true,
12-
{"OpaqueRef:5vdid621-7b62-f571-vdi8-754341a973e5": "OpaqueRef:5sr2d621-7b62-f571-s38r-754341a973e5"},
13-
{"OpaqueRef:9vifb8a9-f6a3-69d2-vifb-7a7b7c81c49e": "OpaqueRef:9network-f6a3-69d2-netw-7a7b7c81c49e"},
14-
{},
15-
{"OpaqueRef:9vgpu8a9-f6a3-69d2-vgpu-7a7b7c81c49e": "OpaqueRef:9gpugroup-f6a3-69d2-grou-7a7b7c81c49e"}
8+
"",
9+
"OpaqueRef:5vm2d621-7b62-f571-vm00-754341a973e5",
10+
{"name_label": "host1"},
11+
true,
12+
{"OpaqueRef:5vdid621-7b62-f571-vdi8-754341a973e5": "OpaqueRef:5sr2d621-7b62-f571-s38r-754341a973e5"},
13+
{"OpaqueRef:9vifb8a9-f6a3-69d2-vifb-7a7b7c81c49e": "OpaqueRef:9network-f6a3-69d2-netw-7a7b7c81c49e"},
14+
{},
15+
{"OpaqueRef:9vgpu8a9-f6a3-69d2-vgpu-7a7b7c81c49e": "OpaqueRef:9gpugroup-f6a3-69d2-grou-7a7b7c81c49e"},
16+
{"OpaqueRef:5vdid621-7b62-f571-vdi8-754341a973e5": "vhd"}
1617
]
1718
},
1819
"expected_result": {
@@ -21,4 +22,4 @@
2122
}
2223
}
2324
}
24-
}
25+
}

0 commit comments

Comments
 (0)