Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If there is only one VM, the list of VMs remains stuck on "Loading…" #5

Open
andydavies opened this issue Jan 4, 2015 · 3 comments

Comments

@andydavies
Copy link
Contributor

This is the first time I've installed esxi-simple-web so I can't tell whether this is a general problem or just particular to me.

The host is running ESXi 5.5u2 main page appears OK but when I switch to the list of VMs it get's stuck on loading.

screen shot 2015-01-04 at 14 46 00

The AJAX call to /mob/?moid=ha-folder-vm returns the following response

screen shot 2015-01-04 at 14 50 15

Raw content of the response is https://gist.github.com/andydavies/1ed8a11158bae8656b61

@andydavies
Copy link
Contributor Author

Issue only happens when the host has one VM - if there's more that one VM the list is fine

Issue appears to be data.childEntity.ManagedObjectReference when there's more that one VM it's an array of objects but when there's only one VM it's an object rather than an array with one object.

When there's only one VM the code below iterates over the object properties rather than over the objects in the array and so doesn't 'find' the VM.

https://github.com/weikinhuang/esxi-simple-web/blob/master/web/js/controllers.js#L99

    var newVms = {};
    angular.forEach(data.childEntity.ManagedObjectReference, function(vm) {
        var vmId = vm["#text"];

@andydavies andydavies changed the title List of VMs stuck on loading If there is only one VM, the list of VMs remains stuck on "Loading…" Jan 4, 2015
@andydavies
Copy link
Contributor Author

Looks like transforming the data from XML to JSON doesn't account for single entry arrays
https://github.com/weikinhuang/esxi-simple-web/blob/master/web/js/services.js#L43

    xmlData = xmlData.replace(/xsi:/g, "").replace(/(type="[^"]+".+?)type="[^"]+"/g, "$1");

https://github.com/weikinhuang/esxi-simple-web/blob/master/web/js/services.js#L49

removes xsi:type="ArrayOfManagedObjectReference"

e.g. from

<childEntity xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:vim25" versionId="5.5" xsi:type="ArrayOfManagedObjectReference">
    <ManagedObjectReference type="VirtualMachine" xsi:type="ManagedObjectReference">4</ManagedObjectReference>
</childEntity>

to

<childEntity xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:vim25" versionId="5.5" >
    <ManagedObjectReference type="VirtualMachine" >4</ManagedObjectReference>
</childEntity>

But removing this line causes breakage elsewhere and doesn't fix the issue anyway!

@andydavies
Copy link
Contributor Author

See #6 for a fix, might be a more elegant way of achieving same result.

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

No branches or pull requests

1 participant