Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

Howto use go-xenserver-client #8

Open
jniltinho opened this issue Nov 13, 2015 · 4 comments
Open

Howto use go-xenserver-client #8

jniltinho opened this issue Nov 13, 2015 · 4 comments

Comments

@jniltinho
Copy link

Hi @rdobson I like XenServer and Golang.
Please howto use go-xenserver-client

I'm thinking of using your lib to develop a web interface to manage XenServer golang

Thanks

@rdobson
Copy link
Contributor

rdobson commented Jan 26, 2016

Hi @jniltinho, we've not got any formal examples yet, but please check out these projects which use the library: https://github.com/xenserver/docker-machine-driver-xenserver & https://github.com/rdobson/packer-builder-xenserver which should help you see how to create a session and make various calls etc.

@jniltinho
Copy link
Author

Hi @rdobson , very nice !!! :-)
I'm reading the code of the projects.

Thank's

@jniltinho
Copy link
Author

Hi @rdobson ,
Is there any example like this in Python?
https://github.com/xapi-project/xen-api/tree/master/scripts/examples/python

@jniltinho
Copy link
Author

func (client *XenAPIClient) GetVMAll() (vms []*VM, err error) {
    vms = make([]*VM, 0)
    result := APIResult{}
    err = client.APICall(&result, "VM.get_all")
    if err != nil {
        return vms, err
    }

    for _, elem := range result.Value.([]interface{}) {
        vm := new(VM)
        vm.Ref = elem.(string)
        vm.Client = client
        vms = append(vms, vm)
    }

    return vms, nil
}

https://github.com/xapi-project/xen-api/blob/master/scripts/examples/python/powercycle.py#L25

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants