Skip to content

Commit ffc0ffb

Browse files
heindsightddelnano
authored andcommitted
Work around XenAPI compatibility issue to get default SR
1 parent 416c734 commit ffc0ffb

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

builder/xenserver/common/common_config.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,21 +272,29 @@ func (config CommonConfig) GetISOSR(c *Connection) (xenapi.SRRef, error) {
272272

273273
func getDefaultSR(c *Connection) (xenapi.SRRef, error) {
274274
var srRef xenapi.SRRef
275-
hostRef, err := c.GetClient().Session.GetThisHost(c.session, c.session)
275+
client := c.GetClient()
276+
hostRef, err := client.Session.GetThisHost(c.session, c.session)
276277

277278
if err != nil {
278279
return srRef, err
279280
}
280281

281-
pools, err := c.GetClient().Pool.GetAllRecords(c.session)
282+
// The current version of the go-xen-api-client does not fully support XenAPI version 8.2
283+
// In particular, some values for the pool `allowed_operations` are not recognised, resulting
284+
// in a parse error when retrieving pool records. As a workaround, we only fetch pool refs.
285+
pool_refs, err := client.Pool.GetAll(c.session)
282286

283287
if err != nil {
284288
return srRef, err
285289
}
286290

287-
for _, pool := range pools {
288-
if pool.Master == hostRef {
289-
return pool.DefaultSR, nil
291+
for _, pool_ref := range pool_refs {
292+
pool_master, err := client.Pool.GetMaster(c.session, pool_ref)
293+
if err != nil {
294+
return srRef, err
295+
}
296+
if pool_master == hostRef {
297+
return client.Pool.GetDefaultSR(c.session, pool_ref)
290298
}
291299
}
292300

0 commit comments

Comments
 (0)