'Reboot a VM instance.'

def reboot(self, instance, network_info, reboot_type='SOFT'):

    vm_ref = vm_util.get_vm_ref(self._session, instance)
    lst_properties = ['summary.guest.toolsStatus', 'runtime.powerState', 'summary.guest.toolsRunningStatus']
    props = self._session._call_method(vutil, 'get_object_properties_dict', vm_ref, lst_properties)
    pwr_state = props.get('runtime.powerState')
    tools_status = props.get('summary.guest.toolsStatus')
    tools_running_status = props.get('summary.guest.toolsRunningStatus')
    if (pwr_state not in ['poweredOn']):
        reason = _('instance    is    not    powered    on')
        raise exception.InstanceRebootFailure(reason=reason)
    if ((tools_status == 'toolsOk') and (tools_running_status == 'guestToolsRunning') and (reboot_type == 'SOFT')):
        LOG.debug('Rebooting    guest    OS    of    VM', instance=instance)
        self._session._call_method(self._session.vim, 'RebootGuest', vm_ref)
        LOG.debug('Rebooted    guest    OS    of    VM', instance=instance)
    else:
        LOG.debug('Doing    hard    reboot    of    VM', instance=instance)
        reset_task = self._session._call_method(self._session.vim, 'ResetVM_Task', vm_ref)
        self._session._wait_for_task(reset_task)
        LOG.debug('Did    hard    reboot    of    VM', instance=instance)
