Revision 55cc0a44 lib/hypervisor/hv_chroot.py

b/lib/hypervisor/hv_chroot.py
31 31
from ganeti import constants
32 32
from ganeti import errors # pylint: disable-msg=W0611
33 33
from ganeti import utils
34
from ganeti import objects
34 35
from ganeti.hypervisor import hv_base
35 36
from ganeti.errors import HypervisorError
36 37

  
......
246 247
    return self.GetLinuxNodeInfo()
247 248

  
248 249
  @classmethod
249
  def GetShellCommandForConsole(cls, instance, hvparams, beparams):
250
    """Return a command for connecting to the console of an instance.
250
  def GetInstanceConsole(cls, instance, # pylint: disable-msg=W0221
251
                         hvparams, beparams, root_dir=None):
252
    """Return information for connecting to the console of an instance.
251 253

  
252 254
    """
253
    root_dir = cls._InstanceDir(instance.name)
254
    if not os.path.ismount(root_dir):
255
      raise HypervisorError("Instance %s is not running" % instance.name)
256

  
257
    return "chroot %s" % root_dir
255
    if root_dir is None:
256
      root_dir = cls._InstanceDir(instance.name)
257
      if not os.path.ismount(root_dir):
258
        raise HypervisorError("Instance %s is not running" % instance.name)
259

  
260
    return objects.InstanceConsole(instance=instance.name,
261
                                   kind=constants.CONS_SSH,
262
                                   host=instance.primary_node,
263
                                   user=constants.GANETI_RUNAS,
264
                                   command=["chroot", root_dir])
258 265

  
259 266
  def Verify(self):
260 267
    """Verify the hypervisor.

Also available in: Unified diff