'state': state,
'time': times,
}
- if name in output and output[name] != value:
- raise errors.HypervisorError("Instance %s running duplicate"
- " with different parameters" % name)
+ if name in output:
+ # we only check static parameters, like memory and vcpus,
+ # and not state and time which can change between the
+ # invocations of the different hypervisors
+ for key in 'memory', 'vcpus':
+ if value[key] != output[name][key]:
+ raise errors.HypervisorError("Instance %s is running twice"
+ " with different parameters" % name)
output[name] = value
return output
return block_devices
-def StartInstance(instance, extra_args):
+def StartInstance(instance):
"""Start an instance.
@type instance: L{objects.Instance}
try:
block_devices = _GatherAndLinkBlockDevs(instance)
hyper = hypervisor.GetHypervisor(instance.hypervisor)
- hyper.StartInstance(instance, block_devices, extra_args)
+ hyper.StartInstance(instance, block_devices)
except errors.BlockDeviceError, err:
logging.exception("Failed to start instance")
return (False, "Block device error: %s" % str(err))
return (True, "Instance has been shutdown successfully")
-def InstanceReboot(instance, reboot_type, extra_args):
+def InstanceReboot(instance, reboot_type):
"""Reboot an instance.
@type instance: L{objects.Instance}
instance OS, do not recreate the VM
- L{constants.INSTANCE_REBOOT_HARD}: tear down and
restart the VM (at the hypervisor level)
- - the other reboot type (L{constants.INSTANCE_REBOOT_HARD})
- is not accepted here, since that mode is handled
- differently
+ - the other reboot type (L{constants.INSTANCE_REBOOT_FULL}) is
+ not accepted here, since that mode is handled differently, in
+ cmdlib, and translates into full stop and start of the
+ instance (instead of a call_instance_reboot RPC)
@rtype: boolean
@return: the success of the operation
return (False, msg)
elif reboot_type == constants.INSTANCE_REBOOT_HARD:
try:
- InstanceShutdown(instance)
- StartInstance(instance, extra_args)
+ stop_result = InstanceShutdown(instance)
+ if not stop_result[0]:
+ return stop_result
+ return StartInstance(instance)
except errors.HypervisorError, err:
msg = "Failed to hard reboot instance %s: %s" % (instance.name, err)
logging.error(msg)
clist.append(crdev)
try:
- device = bdev.Create(disk.dev_type, disk.physical_id, clist, size)
+ device = bdev.Create(disk.dev_type, disk.physical_id, clist, disk.size)
except errors.BlockDeviceError, err:
return False, "Can't create block device: %s" % str(err)
children.append(cdev)
if as_primary or disk.AssembleOnSecondary():
- r_dev = bdev.Assemble(disk.dev_type, disk.physical_id, children)
+ r_dev = bdev.Assemble(disk.dev_type, disk.physical_id, children, disk.size)
r_dev.SetSyncSpeed(constants.SYNC_SPEED)
result = r_dev
if as_primary or disk.OpenOnSecondary():
for chdisk in disk.children:
children.append(_RecursiveFindBD(chdisk))
- return bdev.FindDevice(disk.dev_type, disk.physical_id, children)
+ return bdev.FindDevice(disk.dev_type, disk.physical_id, children, disk.size)
def BlockdevFind(disk):
result['NIC_%d_FRONTEND_TYPE' % idx] = \
instance.hvparams[constants.HV_NIC_TYPE]
+ for source, kind in [(instance.beparams, "BE"), (instance.hvparams, "HV")]:
+ for key, value in source.items():
+ result["INSTANCE_%s_%s" % (kind, key)] = str(value)
+
return result
def BlockdevGrow(disk, amount):
if utils.IsProcessAlive(utils.ReadPidFile(pid_file)):
return (False, "The master daemon is running, will not demote")
try:
- utils.CreateBackup(constants.CLUSTER_CONF_FILE)
+ if os.path.isfile(constants.CLUSTER_CONF_FILE):
+ utils.CreateBackup(constants.CLUSTER_CONF_FILE)
except EnvironmentError, err:
if err.errno != errno.ENOENT:
return (False, "Error while backing up cluster file: %s" % str(err))
# standalone, even though this should not happen with the
# new staged way of changing disk configs
try:
- rd.ReAttachNet(multimaster)
+ rd.AttachNet(multimaster)
except errors.BlockDeviceError, err:
return (False, "Can't change network configuration: %s" % str(err))
if all_connected: