Add stricter checks for OpInstanceSetParams.{nics,disks}
[ganeti-local] / lib / hypervisor / hv_chroot.py
index f33fed2..3830f5f 100644 (file)
@@ -29,8 +29,9 @@ import time
 import logging
 
 from ganeti import constants
-from ganeti import errors # pylint: disable-msg=W0611
+from ganeti import errors # pylint: disable=W0611
 from ganeti import utils
+from ganeti import objects
 from ganeti.hypervisor import hv_base
 from ganeti.errors import HypervisorError
 
@@ -134,7 +135,7 @@ class ChrootManager(hv_base.BaseHypervisor):
         data.append((file_name, 0, 0, 0, 0, 0))
     return data
 
-  def StartInstance(self, instance, block_devices):
+  def StartInstance(self, instance, block_devices, startup_paused):
     """Start an instance.
 
     For the chroot manager, we try to mount the block device and
@@ -232,6 +233,18 @@ class ChrootManager(hv_base.BaseHypervisor):
     raise HypervisorError("The chroot manager doesn't implement the"
                           " reboot functionality")
 
+  def BalloonInstanceMemory(self, instance, mem):
+    """Balloon an instance memory to a certain value.
+
+    @type instance: L{objects.Instance}
+    @param instance: instance to be accepted
+    @type mem: int
+    @param mem: actual memory size to use for instance runtime
+
+    """
+    # Currently chroots don't have memory limits
+    pass
+
   def GetNodeInfo(self):
     """Return information about the node.
 
@@ -246,15 +259,21 @@ class ChrootManager(hv_base.BaseHypervisor):
     return self.GetLinuxNodeInfo()
 
   @classmethod
-  def GetShellCommandForConsole(cls, instance, hvparams, beparams):
-    """Return a command for connecting to the console of an instance.
+  def GetInstanceConsole(cls, instance, # pylint: disable=W0221
+                         hvparams, beparams, root_dir=None):
+    """Return information for connecting to the console of an instance.
 
     """
-    root_dir = cls._InstanceDir(instance.name)
-    if not os.path.ismount(root_dir):
-      raise HypervisorError("Instance %s is not running" % instance.name)
+    if root_dir is None:
+      root_dir = cls._InstanceDir(instance.name)
+      if not os.path.ismount(root_dir):
+        raise HypervisorError("Instance %s is not running" % instance.name)
 
-    return "chroot %s" % root_dir
+    return objects.InstanceConsole(instance=instance.name,
+                                   kind=constants.CONS_SSH,
+                                   host=instance.primary_node,
+                                   user=constants.GANETI_RUNAS,
+                                   command=["chroot", root_dir])
 
   def Verify(self):
     """Verify the hypervisor.
@@ -284,3 +303,16 @@ class ChrootManager(hv_base.BaseHypervisor):
 
     """
     raise HypervisorError("Migration not supported by the chroot hypervisor")
+
+  def GetMigrationStatus(self, instance):
+    """Get the migration status
+
+    @type instance: L{objects.Instance}
+    @param instance: the instance that is being migrated
+    @rtype: L{objects.MigrationStatus}
+    @return: the status of the current migration (one of
+             L{constants.HV_MIGRATION_VALID_STATUSES}), plus any additional
+             progress info that can be retrieved from the hypervisor
+
+    """
+    raise HypervisorError("Migration not supported by the chroot hypervisor")