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

vcsim: Failed to reboot/shutdown host system #1040

Closed
Akasurde opened this issue Feb 17, 2018 · 2 comments
Closed

vcsim: Failed to reboot/shutdown host system #1040

Akasurde opened this issue Feb 17, 2018 · 2 comments

Comments

@Akasurde
Copy link
Contributor

Python traceback:

python host_reboot.py
Traceback (most recent call last):
  File "host_reboot.py", line 7, in <module>
    host1.RebootHost_Task(False)
  File "/Volumes/data/src/ansible/venv4/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py", line 580, in <lambda>
    self.f(*(self.args + (obj,) + args), **kwargs)
  File "/Volumes/data/src/ansible/venv4/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py", line 386, in _InvokeMethod
    return self._stub.InvokeMethod(self, info, args)
  File "/Volumes/data/src/ansible/venv4/lib/python2.7/site-packages/pyVmomi/SoapAdapter.py", line 1357, in InvokeMethod
    raise exc
pyVmomi.SoapAdapter.ParserError: 'xml document: <httplib.HTTPResponse instance at 0x1110529e0> parse error at: line:2, col:506'

Python reproducer

from pyVim.connect import SmartConnect, Disconnect
import ssl
import atexit
from pyVmomi import vim

def connect():
    context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
    context.verify_mode = ssl.CERT_NONE

    si = SmartConnect(host='0.0.0.0', user='user', pwd='pass', port=443, sslContext=context)
    atexit.register(Disconnect, si)
    content = si.RetrieveContent()
    return content

def get_obj(content, vimtype, name):
    """
    Return an object by name, if name is None the
    first found object is returned
    """
    obj = None
    container = content.viewManager.CreateContainerView(
        content.rootFolder, vimtype, True)
    for c in container.view:
        if name:
            if c.name == name:
                obj = c
                break
        else:
            obj = c
            break

    container.Destroy()
    return obj

content = connect()

host1 = get_obj(content, [vim.HostSystem], 'DC0_H0')
host1.RebootHost_Task(False)
@dougm
Copy link
Member

dougm commented Feb 28, 2018

@Akasurde do you want to implement this one? Have a look at ExitMaintenanceModeTask:

func (h *HostSystem) ExitMaintenanceModeTask(spec *types.ExitMaintenanceMode_Task) soap.HasFault {

Copy and replace "ExitMaintenanceMode" with "Reboot". Instead of setting InMaintenanceMode, you'd probably want check the value of InMaintenanceMode. If true or the request.Force flag is true, return nil. Otherwise, if InMaintenanceMode is false, return the same fault a real VC would. types.ResourceInUse for example.

@github-actions
Copy link
Contributor

This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Mark as fresh by adding the comment /remove-lifecycle stale.

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

No branches or pull requests

2 participants